From: Justin Pryzby Date: Fri, 5 Nov 2021 18:06:43 -0500 Subject: [PATCH 3/3] Justin's contribution --- doc/src/sgml/advanced.sgml | 2 +- doc/src/sgml/ref/create_variable.sgml | 12 ++--- doc/src/sgml/ref/grant.sgml | 4 +- doc/src/sgml/ref/let.sgml | 4 +- src/backend/catalog/aclchk.c | 4 +- src/backend/catalog/namespace.c | 21 ++++---- src/backend/catalog/pg_variable.c | 14 ++--- src/backend/commands/schemavariable.c | 51 +++++++++---------- src/backend/executor/execExpr.c | 4 +- src/backend/executor/execMain.c | 4 +- src/backend/executor/execParallel.c | 10 ++-- src/backend/optimizer/plan/setrefs.c | 5 +- src/backend/parser/analyze.c | 8 +-- src/backend/parser/parse_expr.c | 20 ++++---- src/bin/psql/tab-complete.c | 2 +- src/include/catalog/pg_variable.h | 2 +- src/include/nodes/pathnodes.h | 2 +- src/include/nodes/primnodes.h | 2 +- src/pl/plpgsql/src/pl_exec.c | 10 ++-- .../regress/expected/schema_variables.out | 2 +- src/test/regress/sql/schema_variables.sql | 2 +- 21 files changed, 92 insertions(+), 93 deletions(-) diff --git a/doc/src/sgml/advanced.sgml b/doc/src/sgml/advanced.sgml index bd4733c0bb..6ae3e7b281 100644 --- a/doc/src/sgml/advanced.sgml +++ b/doc/src/sgml/advanced.sgml @@ -714,7 +714,7 @@ SELECT name, elevation Schema variables are database objects that can hold a value. - Schema variables, like relations, exist within a schema and the access is + Schema variables, like relations, exist within a schema and their access is controlled via GRANT and REVOKE commands. A schema variable can be created by the CREATE VARIABLE command. diff --git a/doc/src/sgml/ref/create_variable.sgml b/doc/src/sgml/ref/create_variable.sgml index 859c0bc2f1..977bd5511a 100644 --- a/doc/src/sgml/ref/create_variable.sgml +++ b/doc/src/sgml/ref/create_variable.sgml @@ -44,7 +44,7 @@ CREATE [ { TEMPORARY | TEMP } ] [ IMMUTABLE ] VARIABLE [ IF NOT EXISTS ] @@ -101,7 +101,7 @@ CREATE [ { TEMPORARY | TEMP } ] [ IMMUTABLE ] VARIABLE [ IF NOT EXISTS ] The COLLATE clause assigns a collation to the variable (which must be of a collatable data type). - If not specified, the variable data type's default collation is used. + If not specified, the data type's default collation is used. @@ -110,10 +110,10 @@ CREATE [ { TEMPORARY | TEMP } ] [ IMMUTABLE ] VARIABLE [ IF NOT EXISTS ] NOT NULL - The NOT NULL clause forbids to set the variable to + The NOT NULL clause forbids setting the variable to a null value. A variable created as NOT NULL and without an explicitly declared default value cannot be read until it is initialized by a LET - command. This obliges the user to explicitly initialize the variable + command. This requires the user to explicitly initialize the variable content before reading it. @@ -134,10 +134,10 @@ CREATE [ { TEMPORARY | TEMP } ] [ IMMUTABLE ] VARIABLE [ IF NOT EXISTS ] The ON COMMIT DROP clause specifies the behaviour - of a temporary schema variable at transaction commit. With this clause the + of a temporary schema variable at transaction commit. With this clause, the      variable is dropped at commit time. The clause is only allowed      for temporary variables. The ON TRANSACTION END RESET - clause enforces the variable to be reset to its default value when + clause causes the variable to be reset to its default value when the transaction is committed or rolled back. diff --git a/doc/src/sgml/ref/grant.sgml b/doc/src/sgml/ref/grant.sgml index 6586e412c1..2bf8eb9d54 100644 --- a/doc/src/sgml/ref/grant.sgml +++ b/doc/src/sgml/ref/grant.sgml @@ -210,7 +210,7 @@ GRANT { READ | WRITE | ALL [ PRIVILEGES ] } READ - Allows to read a schema variable. + Allows reading of a schema variable. @@ -219,7 +219,7 @@ GRANT { READ | WRITE | ALL [ PRIVILEGES ] } WRITE - Allows to set a schema variable's content. + Allows setting the value of a schema variable. diff --git a/doc/src/sgml/ref/let.sgml b/doc/src/sgml/ref/let.sgml index d4396cad3c..0abb995f5a 100644 --- a/doc/src/sgml/ref/let.sgml +++ b/doc/src/sgml/ref/let.sgml @@ -35,7 +35,7 @@ LET schema_variable = DEFAULT Description - The LET command updates the specified schema variable value. + The LET command assigns a value to the specified schema variable. @@ -57,7 +57,7 @@ LET schema_variable = DEFAULT sql_expression - An SQL expression. The result is cast into the schema variable's type. + An SQL expression. The result is cast to the data type of the schema variable. diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index 715208af23..c794e3f4b1 100644 --- a/src/backend/catalog/aclchk.c +++ b/src/backend/catalog/aclchk.c @@ -3325,7 +3325,7 @@ ExecGrant_Variable(InternalGrant *istmt) tuple = SearchSysCache1(VARIABLEOID, ObjectIdGetDatum(varId)); if (!HeapTupleIsValid(tuple)) - elog(ERROR, "cache lookup failed for schema variables %u", varId); + elog(ERROR, "cache lookup failed for schema variable %u", varId); pg_variable_tuple = (Form_pg_variable) GETSTRUCT(tuple); @@ -5707,7 +5707,7 @@ pg_statistics_object_ownercheck(Oid stat_oid, Oid roleid) } /* - * Ownership check for a schema variables (specified by OID). + * Ownership check for a schema variable (specified by OID). */ bool pg_variable_ownercheck(Oid db_oid, Oid roleid) diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c index 789f41876c..a241dd6330 100644 --- a/src/backend/catalog/namespace.c +++ b/src/backend/catalog/namespace.c @@ -2951,7 +2951,7 @@ LookupVariable(const char *nspname, const char *varname, bool missing_ok) if (nspname) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("variable \"%s\".\"%s\" does not exist", + errmsg("variable \"%s.%s\" does not exist", nspname, varname))); else ereport(ERROR, @@ -2964,10 +2964,9 @@ LookupVariable(const char *nspname, const char *varname, bool missing_ok) } /* - * The source list holds names with indirection expressions used - * as left part of LET statement. Following routine makes new - * list with only initial strings (names) - without indirection - * expressions. + * The input list contains names with indirection expressions used as the left + * part of LET statement. The following routine returns a new list with only + * initial strings (names) - without indirection expressions. */ List * NamesFromList(List *names) @@ -2993,9 +2992,9 @@ NamesFromList(List *names) /* * IdentifyVariable * - * Returns oid of not ambigonuous variable specified by qualified path - * or InvalidOid. When the path is ambigonuous, then not_uniq flag is - * is true. + * Returns the oid of an unambiguous variable specified by the qualified path, + * or InvalidOid. When the path is ambiguous, then not_uniq flag is set to + * true. * * XXX Do we need the not_uniq flag, when we return InvalidOid anyway? * XXX Maybe use not_unique, it's not much longer. @@ -3093,7 +3092,7 @@ IdentifyVariable(List *names, char **attrname, bool *not_uniq) * a.b.c can mean "catalog"."schema"."variable" or * "schema"."variable"."field", Check both variants, and returns * InvalidOid with not_uniq flag, when both interpretations are - * possible. When third node is star, then only possible + * possible. When third node is star, the only possible * interpretation is "schema"."variable"."*". */ varoid_without_attr = LookupVariable(b, c, true); @@ -3115,7 +3114,7 @@ IdentifyVariable(List *names, char **attrname, bool *not_uniq) *attrname = NULL; /* - * We in this case a "a" is used as catalog name, check it. + * In this case, "a" is used as catalog name - check it. */ if (strcmp(a, get_database_name(MyDatabaseId)) != 0) ereport(ERROR, @@ -3147,7 +3146,7 @@ IdentifyVariable(List *names, char **attrname, bool *not_uniq) c = strVal(field3); /* - * We in this case a "a" is used as catalog name, check it. + * In this case, "a" is used as catalog name - check it. */ if (strcmp(a, get_database_name(MyDatabaseId)) != 0) ereport(ERROR, diff --git a/src/backend/catalog/pg_variable.c b/src/backend/catalog/pg_variable.c index 451b57a0b7..eb1ce6d0fd 100644 --- a/src/backend/catalog/pg_variable.c +++ b/src/backend/catalog/pg_variable.c @@ -74,8 +74,8 @@ to_eoxaction(VariableEOXActionCodes code) } /* - * Returns name of schema variable. When variable is not on path, - * then the name is qualified. + * Returns name of schema variable. When the variable is not in the path, + * the name is qualified. */ char * schema_variable_get_name(Oid varid) @@ -202,8 +202,8 @@ initVariable(Variable *var, Oid varid, bool missing_ok, bool fast_only) var->has_defexpr = !defexpr_isnull; /* - * Sometimes we don't need deserialized defexpr, but we need info about - * existence of defexpr. + * Sometimes we don't need to deserialize defexpr, but we need info about + * the existence of defexpr. */ if (!fast_only) @@ -291,7 +291,7 @@ VariableCreate(const char *varName, values[Anum_pg_variable_vareoxaction - 1] = CharGetDatum((char) to_eoxaction_code(eoxaction)); values[Anum_pg_variable_varisnotnull - 1] = BoolGetDatum(is_not_null); values[Anum_pg_variable_varisimmutable - 1] = BoolGetDatum(is_immutable); - /* proacl will be determined later */ + /* varacl will be determined later */ if (varDefexpr) values[Anum_pg_variable_vardefexpr - 1] = CStringGetTextDatum(nodeToString(varDefexpr)); @@ -372,8 +372,8 @@ VariableCreate(const char *varName, recordDependencyOnCurrentExtension(&myself, false); /* - * register on commit action if it is necessary. This moment, the variable - * has not any value, so we don't need to solve content transactionality. + * register on commit action if it is necessary. At this moment, the variable + * has no value, so we don't need to solve content transactionality. */ register_variable_on_commit_action(myself.objectId, eoxaction); diff --git a/src/backend/commands/schemavariable.c b/src/backend/commands/schemavariable.c index 5426e5fa21..aa40910405 100644 --- a/src/backend/commands/schemavariable.c +++ b/src/backend/commands/schemavariable.c @@ -60,10 +60,10 @@ typedef struct OnCommitItem static List *on_commits = NIL; /* - * The content of variables is not transactional. Due this fact the + * The content of variables is not transactional. Due to this fact, the * implementation of DROP can be simple, because although DROP VARIABLE * can be reverted, the content of variable can be lost. In this example, - * DROP VARIABLE is same like reset variable. + * DROP VARIABLE is the same as reset variable. * * XXX Seems misplaced? There is no example here. * XXX Also, is it really true that discarding the value even if DROP @@ -110,7 +110,7 @@ static void clean_cache_variable(Oid varid); /* * Save info about necessity to clean hash table, because some - * schema variable was dropped. Don't do here more, recheck + * schema variable was dropped. Don't do more here, recheck * needs to be in transaction state. * * XXX Not sure "needs to be in transaction state" means? Perhaps @@ -202,7 +202,7 @@ create_schema_variable_hashtable(void) first_time = false; } - /* needs own long life memory context */ + /* needs its own long lived memory context */ if (SchemaVariableMemoryContext == NULL) { SchemaVariableMemoryContext = @@ -253,7 +253,7 @@ ResetSchemaVariableCache(void) * and was not modified already in this transaction, then it archives * current value for possible future usage on rollback. * - * When force is true, then release current and possibly archived value. + * When force is true, release current and possibly archived value. * * XXX The "force" flag is not really used. * XXX Can't the value be something more complex? @@ -273,7 +273,7 @@ free_schema_variable(SchemaVariable svar, bool force) } /* - * Assign some content to the schema variable. It does copy to + * Assign some content to the schema variable. It's copied to * SchemaVariableMemoryContext if it is necessary. */ static void @@ -282,7 +282,7 @@ set_schema_variable(SchemaVariable svar, Datum value, bool isnull, Oid typid) MemoryContext oldcxt; Datum newval = value; - /* Don't allow assign null to NOT NULL variable */ + /* Don't allow assignment of null to NOT NULL variable */ if (isnull && svar->is_not_null) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), @@ -346,11 +346,11 @@ init_schema_variable(SchemaVariable svar, Variable *var) } /* - * Try to search value in hash table. If doesn't - * exists insert it (and calculate defexpr if exists. - * When reset is true, we would to enforce calculate - * defexpr. When some is wrong, then this function try - * don't break previous value. + * Try to search value in hash table. If it doesn't + * exist, then insert it (and calculate defexpr if it exists). + * When reset is true, we enforce calculation of defexpr. + * When something is wrong, then this function tries not to + * break the previous value. */ static SchemaVariable prepare_variable_for_reading(Oid varid, bool reset) @@ -387,7 +387,7 @@ prepare_variable_for_reading(Oid varid, bool reset) if (!found) init_schema_variable(svar, &var); - /* Raise a error when we cannot to initialize variable correctly */ + /* Raise an error when we cannot initialize variable correctly */ if (var.is_not_null && !var.defexpr) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), @@ -434,7 +434,7 @@ prepare_variable_for_reading(Oid varid, bool reset) /* * Write value to variable. We expect secured access in this moment. - * We try to don't break previous value, if some is wrong. + * We try not to break the previous value, if something is wrong. */ void SetSchemaVariable(Oid varid, Datum value, bool isNull, Oid typid) @@ -448,7 +448,7 @@ SetSchemaVariable(Oid varid, Datum value, bool isNull, Oid typid) svar = (SchemaVariable) hash_search(schemavarhashtab, &varid, HASH_ENTER, &found); - /* Initialize svar when was not initialized or when stored value is null */ + /* Initialize svar when not initialized or when stored value is null */ if (!found) { Variable var; @@ -459,7 +459,7 @@ SetSchemaVariable(Oid varid, Datum value, bool isNull, Oid typid) register_variable_on_commit_action(varid, var.eoxaction); } - /* don't allow a update on immutable variable */ + /* don't allow updating an immutable variable */ if (svar->is_immutable) ereport(ERROR, (errcode(ERRCODE_ERROR_IN_ASSIGNMENT), @@ -472,7 +472,7 @@ SetSchemaVariable(Oid varid, Datum value, bool isNull, Oid typid) /* * Write value to variable with security check. - * We try to don't break previous value, if some is wrong. + * We try not to break the previous value, if something is wrong. */ void SetSchemaVariableWithSecurityCheck(Oid varid, Datum value, bool isNull, Oid typid) @@ -490,7 +490,7 @@ SetSchemaVariableWithSecurityCheck(Oid varid, Datum value, bool isNull, Oid typi } /* - * Returns copy of value of schema variable spcified by varid + * Returns a copy of value of the schema variable specified by varid */ Datum CopySchemaVariable(Oid varid, bool *isNull, Oid *typid) @@ -510,8 +510,8 @@ CopySchemaVariable(Oid varid, bool *isNull, Oid *typid) } /* - * Returns value of schema variable specified by varid. Check correct - * result type. Optionaly the result can be copy. + * Returns the value of the schema variable specified by varid. Check correct + * result type. Optionally the result can be copied. */ Datum GetSchemaVariable(Oid varid, bool *isNull, Oid expected_typid, bool copy) @@ -539,7 +539,7 @@ GetSchemaVariable(Oid varid, bool *isNull, Oid expected_typid, bool copy) } /* - * Clean variable defined by varid + * Clean the variable defined by varid */ static void clean_cache_variable(Oid varid) @@ -614,7 +614,7 @@ ExecuteLetStmt(ParseState *pstate, Assert(OidIsValid(varid)); /* - * Is possible to write to schema variable? + * Is it allowed to write to schema variable? */ aclresult = pg_variable_aclcheck(varid, GetUserId(), ACL_WRITE); if (aclresult != ACLCHECK_OK) @@ -624,7 +624,7 @@ ExecuteLetStmt(ParseState *pstate, dest = CreateDestReceiver(DestVariable); SetVariableDestReceiverParams(dest, varid); - /* run rewriter - there can be used for replacement of DEFAULT node */ + /* run rewriter - can be used for replacement of DEFAULT node */ query = copyObject(query); rewritten = QueryRewrite(query); @@ -846,8 +846,8 @@ AtPreEOXact_SchemaVariable_on_commit_actions(bool isCommit) { /* * ON COMMIT DROP is allowed only for temp schema - * variables. So we should explicit delete only when - * current transaction was committed. When is rollback, + * variables. So we should explicitly delete only when + * current transaction was committed. When it's rollback, * then schema variable is removed automatically. */ if (isCommit) @@ -876,7 +876,6 @@ AtPreEOXact_SchemaVariable_on_commit_actions(bool isCommit) * Post-commit or post-abort cleanup for ON COMMIT management. * * All we do here is remove no-longer-needed OnCommitItem entries. - * */ void AtEOXact_SchemaVariable_on_commit_actions(bool isCommit) diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c index 35a8523f98..a35bce8ff1 100644 --- a/src/backend/executor/execExpr.c +++ b/src/backend/executor/execExpr.c @@ -1037,8 +1037,8 @@ ExecInitExprRec(Expr *node, ExprState *state, else { /* - * When we have not a full PlanState (plpgsql - * simple expr evaluation, then we should to + * When we have no full PlanState (plpgsql + * simple expr evaluation), then we should * use direct access. */ scratch.opcode = EEOP_PARAM_VARIABLE; diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 95dac87ca7..62c9fddd6e 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -203,7 +203,7 @@ standard_ExecutorStart(QueryDesc *queryDesc, int eflags) estate->es_sourceText = queryDesc->sourceText; /* - * Prepare schema variables, if are not prepared in queryDesc + * Prepare schema variables, if not prepared in queryDesc */ if (queryDesc->num_schema_variables > 0) { @@ -223,7 +223,7 @@ standard_ExecutorStart(QueryDesc *queryDesc, int eflags) nSchemaVariables = list_length(queryDesc->plannedstmt->schemaVariables); - /* Create buffer for used schema variables */ + /* Create buffer used for schema variables */ estate->es_schema_variables = (SchemaVariableValue *) palloc(nSchemaVariables * sizeof(SchemaVariableValue)); diff --git a/src/backend/executor/execParallel.c b/src/backend/executor/execParallel.c index 341c817371..43ff881042 100644 --- a/src/backend/executor/execParallel.c +++ b/src/backend/executor/execParallel.c @@ -13,8 +13,8 @@ * leader; see src/backend/access/transam/README.parallel for details. * However, we must save and restore relevant executor state, such as * any ParamListInfo associated with the query, buffer/WAL usage info, - * used schema variables buffer, and the actual plan to be passed down - * to the worker. + * schema variables buffer, and the actual plan to be passed down to + * the worker. * * IDENTIFICATION * src/backend/executor/execParallel.c @@ -142,7 +142,7 @@ static bool ExecParallelRetrieveInstrumentation(PlanState *planstate, /* Helper function that runs in the parallel worker. */ static DestReceiver *ExecParallelGetReceiver(dsm_segment *seg, shm_toc *toc); -/* Helper functions that can pass values of used schema variables */ +/* Helper functions that can pass values of schema variables */ static Size EstimateSchemaVariables(EState *estate); static void SerializeSchemaVariables(EState *estate, char **start_address); static SchemaVariableValue * RestoreSchemaVariables(char **start_address, @@ -1527,8 +1527,8 @@ ParallelQueryMain(dsm_segment *seg, shm_toc *toc) } /* - * Estimate the amount of space required to serialize a used - * schema variables. + * Estimate the amount of space required to serialize a + * schema variable. */ static Size EstimateSchemaVariables(EState *estate) diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index 91717cd4e1..daba475101 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -175,6 +175,7 @@ static List *set_returning_clause_references(PlannerInfo *root, static bool pull_up_has_schema_variables_walker(Node *node, PlannerInfo *root); + /***************************************************************************** * * SUBPLAN REFERENCES @@ -1937,8 +1938,8 @@ fix_alternative_subplan(PlannerInfo *root, AlternativeSubPlan *asplan, * choosing the best implementation for AlternativeSubPlans, * looking up operator opcode info for OpExpr and related nodes, * and adding OIDs from regclass Const nodes into root->glob->relationOids, - * and replacing PARAM_VARIABLE paramid, that is oid of schema variable - * to offset to array of by query used schema variables. + * and replacing PARAM_VARIABLE paramid, that is the oid of the schema variable + * to offset the array by query used schema variables. ??? * * 'node': the expression to be modified * 'rtoffset': how much to increment varnos by diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 34cbaa9100..2efd77f499 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -1288,7 +1288,7 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt) /* * Transform targetlist. Second usage of this transformation - * is for Let statement. In this case we would to allow DEFAULT + * is for Let statement. In this case we want to allow DEFAULT * keyword - we specify EXPR_KIND_LET_TARGET. * * XXX This is really hard to understand. What if p_expr_kind is @@ -1672,7 +1672,7 @@ transformLetStmt(ParseState *pstate, LetStmt * stmt) if (!OidIsValid(varid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("schema variable \"%s\" doesn't exists", + errmsg("schema variable \"%s\" doesn't exist", NameListToString(names)), parser_errposition(pstate, stmt->location))); @@ -1859,8 +1859,8 @@ transformLetStmt(ParseState *pstate, LetStmt * stmt) /* * When statement is executed as an expression as PLpgSQL LET - * statement, then we should to return query. We should not - * to use an utility wrapper node. + * statement, then we should return query. We should not + * use a utility wrapper node. */ if (stmt->plpgsql_mode) return query; diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index 31b5b55a09..d26b825382 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -88,6 +88,7 @@ static Node *makeParamSchemaVariable(ParseState *pstate, Oid varid, Oid typid, int32 typmod, Oid collid, char *attrname, int location); + /* * transformExpr - * Analyze and transform expressions. Type checking and type casting is @@ -851,18 +852,17 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) FreeTupleDesc(tupdesc); - /* there are not composite variable with this field */ + /* there is no composite variable with this field */ if (!found) varid = InvalidOid; } else - /* there are not composite variable with this name */ + /* there is no composite variable with this name */ varid = InvalidOid; } /* - * Raise error if varid is still valid. It should be really - * amigonuous + * Raise error if varid is still valid, since it is ambiguous. */ if (OidIsValid(varid)) ereport(ERROR, @@ -932,13 +932,13 @@ makeParamSchemaVariable(ParseState *pstate, param->paramcollid = collid; /* - * There are two access to schema variables - direct, used by simple - * plpgsql expressions, where there are not necessary to emulate - * stability. Buffered access is used elsewhere. We should to ensure + * There are two ways to access schema variables - direct, used by simple + * plpgsql expressions, where it is not necessary to emulate stability. + * And Buffered access, which is used everywhere else. We should ensure * stable values, and because schema variables are global, then we should - * to work with copied values instead direct access to variables. For - * direct access the varid is best for access. For buffered access we need - * to assign index to buffer - later, when we will know what variables are + * work with copied values instead of directly accessing variables. For + * direct access, the varid is best. For buffered access, we need + * to assign an index to the buffer - later, when we know what variables are * used. Now, we just remember, so we use schema variables. */ pstate->p_hasSchemaVariables = true; diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 7045be20bf..dd6d5a1dcb 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -629,7 +629,7 @@ static const SchemaQuery Query_for_list_of_collations = { }; static const SchemaQuery Query_for_list_of_variables = { - .min_server_version = 120000, + .min_server_version = 150000, .catname = "pg_catalog.pg_variable v", .viscondition = "pg_catalog.pg_variable_is_visible(v.oid)", .namespace = "v.varnamespace", diff --git a/src/include/catalog/pg_variable.h b/src/include/catalog/pg_variable.h index 7e53880a3c..e159a5f6a5 100644 --- a/src/include/catalog/pg_variable.h +++ b/src/include/catalog/pg_variable.h @@ -63,7 +63,7 @@ typedef enum VariableEOXActionCodes * the format of pg_variable relation. * ---------------- */ -typedef FormData_pg_variable * Form_pg_variable; +typedef FormData_pg_variable *Form_pg_variable; DECLARE_UNIQUE_INDEX_PKEY(pg_variable_oid_index, 9223, VariableOidIndexId, on pg_variable using btree(oid oid_ops)); #define VariableObjectIndexId 9223 diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h index a2d3fa5b4b..1af7cca067 100644 --- a/src/include/nodes/pathnodes.h +++ b/src/include/nodes/pathnodes.h @@ -352,7 +352,7 @@ struct PlannerInfo * pseudoconstant = true */ bool hasAlternativeSubPlans; /* true if we've made any of those */ bool hasRecursion; /* true if planning a recursive WITH item */ - bool hasSchemaVariables; /* true if schema variables was used */ + bool hasSchemaVariables; /* true if schema variables were used */ /* * Information about aggregates. Filled by preprocess_aggrefs(). diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index dc7c2008b0..2f5cedec4e 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -263,7 +263,7 @@ typedef struct Const * the low-order 16 bits contain the column number. (This type * of Param is also converted to PARAM_EXEC during planning.) * - * PARAM_VARIABLE: The parameter is a access to schema variable + * PARAM_VARIABLE: The parameter is an access to schema variable * paramid holds varid. */ typedef enum ParamKind diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index ab9a3c99a7..545f82abd5 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -4982,11 +4982,11 @@ exec_stmt_let(PLpgSQL_execstate *estate, PLpgSQL_stmt_let *stmt) /* * Oid of target schema variable is stored in Query structure. - * It is safer to read this value directly from plan, then to - * hold this value in plpgsql context, because I don't need to - * solve invalidation of this cached value. Next operations - * are read only without any allocations, so we can expect so - * taking varid from Query should be fast. + * It is safer to read this value directly from the plan than to + * hold this value in the plpgsql context, because it's not necessary + * to handle invalidation of the cached value. Next operations + * are read only without any allocations, so we can expect that + * retrieving varid from Query should be fast. */ plansources = SPI_plan_get_plan_sources(stmt->expr->plan); if (list_length(plansources) != 1) diff --git a/src/test/regress/expected/schema_variables.out b/src/test/regress/expected/schema_variables.out index 0246d86673..58e85a44ea 100644 --- a/src/test/regress/expected/schema_variables.out +++ b/src/test/regress/expected/schema_variables.out @@ -299,7 +299,7 @@ SELECT v2; (3.14159265358979,Hello) (1 row) --- shoudl fail due dependency +-- should fail due dependency DROP TYPE t2; ERROR: cannot drop type t2 because other objects depend on it DETAIL: schema variable v2 depends on type t2 diff --git a/src/test/regress/sql/schema_variables.sql b/src/test/regress/sql/schema_variables.sql index 0bd7798cf9..a6419990dd 100644 --- a/src/test/regress/sql/schema_variables.sql +++ b/src/test/regress/sql/schema_variables.sql @@ -206,7 +206,7 @@ CREATE VARIABLE v2 AS t2 DEFAULT (NULL, 'Hello'); LET svartest.v2.a = pi(); SELECT v2; --- shoudl fail due dependency +-- should fail due dependency DROP TYPE t2; -- should be ok -- 2.17.0 --qxfKREH7IwbezJ+T--