diff options
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/analyze.c | 534 | ||||
-rw-r--r-- | src/backend/parser/keywords.c | 6 | ||||
-rw-r--r-- | src/backend/parser/parse_agg.c | 79 | ||||
-rw-r--r-- | src/backend/parser/parse_clause.c | 257 | ||||
-rw-r--r-- | src/backend/parser/parse_coerce.c | 246 | ||||
-rw-r--r-- | src/backend/parser/parse_expr.c | 176 | ||||
-rw-r--r-- | src/backend/parser/parse_func.c | 241 | ||||
-rw-r--r-- | src/backend/parser/parse_node.c | 38 | ||||
-rw-r--r-- | src/backend/parser/parse_oper.c | 108 | ||||
-rw-r--r-- | src/backend/parser/parse_relation.c | 156 | ||||
-rw-r--r-- | src/backend/parser/parse_target.c | 113 | ||||
-rw-r--r-- | src/backend/parser/parse_type.c | 18 | ||||
-rw-r--r-- | src/backend/parser/scansup.c | 24 |
13 files changed, 968 insertions, 1028 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index be91872df55..46dbb3f1488 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.325 2005/10/02 23:50:09 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.326 2005/10/15 02:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,14 +59,13 @@ typedef struct List *indexes; /* CREATE INDEX items */ List *triggers; /* CREATE TRIGGER items */ List *grants; /* GRANT items */ - List *fwconstraints; /* Forward referencing FOREIGN KEY - * constraints */ + List *fwconstraints; /* Forward referencing FOREIGN KEY constraints */ List *alters; /* Generated ALTER items (from the above) */ List *ixconstraints; /* index-creating constraints */ List *blist; /* "before list" of things to do before * creating the schema */ - List *alist; /* "after list" of things to do after - * creating the schema */ + List *alist; /* "after list" of things to do after creating + * the schema */ } CreateSchemaStmtContext; /* State shared by transformCreateStmt and its subroutines */ @@ -83,8 +82,8 @@ typedef struct List *ixconstraints; /* index-creating constraints */ List *blist; /* "before list" of things to do before * creating the table */ - List *alist; /* "after list" of things to do after - * creating the table */ + List *alist; /* "after list" of things to do after creating + * the table */ IndexStmt *pkey; /* PRIMARY KEY index, if any */ } CreateStmtContext; @@ -140,7 +139,7 @@ static void transformColumnType(ParseState *pstate, ColumnDef *column); static void release_pstate_resources(ParseState *pstate); static FromExpr *makeFromExpr(List *fromlist, Node *quals); static bool check_parameter_resolution_walker(Node *node, - check_parameter_resolution_context *context); + check_parameter_resolution_context *context); /* @@ -255,11 +254,10 @@ do_parse_analyze(Node *parseTree, ParseState *pstate) result = list_concat(result, parse_sub_analyze(lfirst(l), pstate)); /* - * Make sure that only the original query is marked original. We have - * to do this explicitly since recursive calls of do_parse_analyze - * will have marked some of the added-on queries as "original". Also - * mark only the original query as allowed to set the command-result - * tag. + * Make sure that only the original query is marked original. We have to + * do this explicitly since recursive calls of do_parse_analyze will have + * marked some of the added-on queries as "original". Also mark only the + * original query as allowed to set the command-result tag. */ foreach(l, result) { @@ -371,19 +369,19 @@ transformStmt(ParseState *pstate, Node *parseTree, (SelectStmt *) parseTree); else result = transformSetOperationStmt(pstate, - (SelectStmt *) parseTree); + (SelectStmt *) parseTree); break; case T_DeclareCursorStmt: result = transformDeclareCursorStmt(pstate, - (DeclareCursorStmt *) parseTree); + (DeclareCursorStmt *) parseTree); break; default: /* - * other statements don't require any transformation-- just - * return the original parsetree, yea! + * other statements don't require any transformation-- just return + * the original parsetree, yea! */ result = makeNode(Query); result->commandType = CMD_UTILITY; @@ -396,10 +394,9 @@ transformStmt(ParseState *pstate, Node *parseTree, result->canSetTag = true; /* - * Check that we did not produce too many resnos; at the very - * least we cannot allow more than 2^16, since that would exceed - * the range of a AttrNumber. It seems safest to use - * MaxTupleAttributeNumber. + * Check that we did not produce too many resnos; at the very least we + * cannot allow more than 2^16, since that would exceed the range of a + * AttrNumber. It seems safest to use MaxTupleAttributeNumber. */ if (pstate->p_next_resno - 1 > MaxTupleAttributeNumber) ereport(ERROR, @@ -423,11 +420,11 @@ transformViewStmt(ParseState *pstate, ViewStmt *stmt, extras_before, extras_after); /* - * If a list of column names was given, run through and insert these - * into the actual query tree. - thomas 2000-03-08 + * If a list of column names was given, run through and insert these into + * the actual query tree. - thomas 2000-03-08 * - * Outer loop is over targetlist to make it easier to skip junk - * targetlist entries. + * Outer loop is over targetlist to make it easier to skip junk targetlist + * entries. */ if (stmt->aliases != NIL) { @@ -472,17 +469,17 @@ transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt) /* set up range table with just the result rel */ qry->resultRelation = setTargetTable(pstate, stmt->relation, - interpretInhOption(stmt->relation->inhOpt), + interpretInhOption(stmt->relation->inhOpt), true, ACL_DELETE); qry->distinctClause = NIL; /* - * The USING clause is non-standard SQL syntax, and is equivalent - * in functionality to the FROM list that can be specified for - * UPDATE. The USING keyword is used rather than FROM because FROM - * is already a keyword in the DELETE syntax. + * The USING clause is non-standard SQL syntax, and is equivalent in + * functionality to the FROM list that can be specified for UPDATE. The + * USING keyword is used rather than FROM because FROM is already a + * keyword in the DELETE syntax. */ transformFromClause(pstate, stmt->usingClause); @@ -526,11 +523,11 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, /* * If a non-nil rangetable/namespace was passed in, and we are doing * INSERT/SELECT, arrange to pass the rangetable/namespace down to the - * SELECT. This can only happen if we are inside a CREATE RULE, and - * in that case we want the rule's OLD and NEW rtable entries to - * appear as part of the SELECT's rtable, not as outer references for - * it. (Kluge!) The SELECT's joinlist is not affected however. We - * must do this before adding the target table to the INSERT's rtable. + * SELECT. This can only happen if we are inside a CREATE RULE, and in + * that case we want the rule's OLD and NEW rtable entries to appear as + * part of the SELECT's rtable, not as outer references for it. (Kluge!) + * The SELECT's joinlist is not affected however. We must do this before + * adding the target table to the INSERT's rtable. */ if (stmt->selectStmt) { @@ -549,10 +546,10 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, } /* - * Must get write lock on INSERT target table before scanning SELECT, - * else we will grab the wrong kind of initial lock if the target - * table is also mentioned in the SELECT part. Note that the target - * table is not added to the joinlist or namespace. + * Must get write lock on INSERT target table before scanning SELECT, else + * we will grab the wrong kind of initial lock if the target table is also + * mentioned in the SELECT part. Note that the target table is not added + * to the joinlist or namespace. */ qry->resultRelation = setTargetTable(pstate, stmt->relation, false, false, ACL_INSERT); @@ -563,11 +560,11 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, if (stmt->selectStmt) { /* - * We make the sub-pstate a child of the outer pstate so that it - * can see any Param definitions supplied from above. Since the - * outer pstate's rtable and namespace are presently empty, there - * are no side-effects of exposing names the sub-SELECT shouldn't - * be able to see. + * We make the sub-pstate a child of the outer pstate so that it can + * see any Param definitions supplied from above. Since the outer + * pstate's rtable and namespace are presently empty, there are no + * side-effects of exposing names the sub-SELECT shouldn't be able to + * see. */ ParseState *sub_pstate = make_parsestate(pstate); RangeTblEntry *rte; @@ -576,19 +573,18 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, /* * Process the source SELECT. * - * It is important that this be handled just like a standalone - * SELECT; otherwise the behavior of SELECT within INSERT might be - * different from a stand-alone SELECT. (Indeed, Postgres up - * through 6.5 had bugs of just that nature...) + * It is important that this be handled just like a standalone SELECT; + * otherwise the behavior of SELECT within INSERT might be different + * from a stand-alone SELECT. (Indeed, Postgres up through 6.5 had + * bugs of just that nature...) */ sub_pstate->p_rtable = sub_rtable; sub_pstate->p_relnamespace = sub_relnamespace; sub_pstate->p_varnamespace = sub_varnamespace; /* - * Note: we are not expecting that extras_before and extras_after - * are going to be used by the transformation of the SELECT - * statement. + * Note: we are not expecting that extras_before and extras_after are + * going to be used by the transformation of the SELECT statement. */ selectQuery = transformStmt(sub_pstate, stmt->selectStmt, extras_before, extras_after); @@ -604,8 +600,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, errmsg("INSERT ... SELECT may not specify INTO"))); /* - * Make the source be a subquery in the INSERT's rangetable, and - * add it to the INSERT's joinlist. + * Make the source be a subquery in the INSERT's rangetable, and add + * it to the INSERT's joinlist. */ rte = addRangeTableEntryForSubquery(pstate, selectQuery, @@ -640,7 +636,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, if (tle->resjunk) continue; if (tle->expr && - (IsA(tle->expr, Const) || IsA(tle->expr, Param)) && + (IsA(tle->expr, Const) ||IsA(tle->expr, Param)) && exprType((Node *) tle->expr) == UNKNOWNOID) expr = tle->expr; else @@ -659,8 +655,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, else { /* - * For INSERT ... VALUES, transform the given list of values to - * form a targetlist for the INSERT. + * For INSERT ... VALUES, transform the given list of values to form a + * targetlist for the INSERT. */ qry->targetList = transformTargetList(pstate, stmt->targetList); } @@ -690,7 +686,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, if (icols == NULL || attnos == NULL) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("INSERT has more expressions than target columns"))); + errmsg("INSERT has more expressions than target columns"))); col = (ResTarget *) lfirst(icols); Assert(IsA(col, ResTarget)); @@ -711,7 +707,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, if (stmt->cols != NIL && (icols != NULL || attnos != NULL)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("INSERT has more target columns than expressions"))); + errmsg("INSERT has more target columns than expressions"))); /* done building the range table and jointree */ qry->rtable = pstate->p_rtable; @@ -756,8 +752,8 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt, cxt.hasoids = interpretOidsOption(stmt->hasoids); /* - * Run through each primary element in the table creation clause. - * Separate column defs from constraints, and do preliminary analysis. + * Run through each primary element in the table creation clause. Separate + * column defs from constraints, and do preliminary analysis. */ foreach(elements, stmt->tableElts) { @@ -870,11 +866,11 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, * * Although we use ChooseRelationName, it's not guaranteed that the * selected sequence name won't conflict; given sufficiently long - * field names, two different serial columns in the same table - * could be assigned the same sequence name, and we'd not notice - * since we aren't creating the sequence quite yet. In practice - * this seems quite unlikely to be a problem, especially since few - * people would need two serial columns in one table. + * field names, two different serial columns in the same table could + * be assigned the same sequence name, and we'd not notice since we + * aren't creating the sequence quite yet. In practice this seems + * quite unlikely to be a problem, especially since few people would + * need two serial columns in one table. */ snamespaceid = RangeVarGetCreationNamespace(cxt->relation); snamespace = get_namespace_name(snamespaceid); @@ -889,9 +885,9 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, cxt->relation->relname, column->colname))); /* - * Build a CREATE SEQUENCE command to create the sequence object, - * and add it to the list of things to be done before this - * CREATE/ALTER TABLE. + * Build a CREATE SEQUENCE command to create the sequence object, and + * add it to the list of things to be done before this CREATE/ALTER + * TABLE. */ seqstmt = makeNode(CreateSeqStmt); seqstmt->sequence = makeRangeVar(snamespace, sname); @@ -907,14 +903,13 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, /* * Create appropriate constraints for SERIAL. We do this in full, - * rather than shortcutting, so that we will detect any - * conflicting constraints the user wrote (like a different - * DEFAULT). + * rather than shortcutting, so that we will detect any conflicting + * constraints the user wrote (like a different DEFAULT). * * Create an expression tree representing the function call - * nextval('sequencename'). We cannot reduce the raw tree - * to cooked form until after the sequence is created, but - * there's no need to do so. + * nextval('sequencename'). We cannot reduce the raw tree to cooked + * form until after the sequence is created, but there's no need to do + * so. */ qstring = quote_qualified_identifier(snamespace, sname); snamenode = makeNode(A_Const); @@ -949,9 +944,9 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, constraint = lfirst(clist); /* - * If this column constraint is a FOREIGN KEY constraint, then we - * fill in the current attribute's name and throw it into the list - * of FK constraints to be processed later. + * If this column constraint is a FOREIGN KEY constraint, then we fill + * in the current attribute's name and throw it into the list of FK + * constraints to be processed later. */ if (IsA(constraint, FkConstraint)) { @@ -971,7 +966,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("conflicting NULL/NOT NULL declarations for column \"%s\" of table \"%s\"", - column->colname, cxt->relation->relname))); + column->colname, cxt->relation->relname))); column->is_not_null = FALSE; saw_nullable = true; break; @@ -981,7 +976,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("conflicting NULL/NOT NULL declarations for column \"%s\" of table \"%s\"", - column->colname, cxt->relation->relname))); + column->colname, cxt->relation->relname))); column->is_not_null = TRUE; saw_nullable = true; break; @@ -991,7 +986,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("multiple default values specified for column \"%s\" of table \"%s\"", - column->colname, cxt->relation->relname))); + column->colname, cxt->relation->relname))); column->raw_default = constraint->raw_expr; Assert(constraint->cooked_expr == NULL); break; @@ -1113,8 +1108,8 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt, /* * Create a new inherited column. * - * For constraints, ONLY the NOT NULL constraint is inherited by the - * new column definition per SQL99. + * For constraints, ONLY the NOT NULL constraint is inherited by the new + * column definition per SQL99. */ def = makeNode(ColumnDef); def->colname = pstrdup(attributeName); @@ -1158,8 +1153,8 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt, Assert(this_default != NULL); /* - * If default expr could contain any vars, we'd need to fix - * 'em, but it can't; so default is ready to apply to child. + * If default expr could contain any vars, we'd need to fix 'em, + * but it can't; so default is ready to apply to child. */ def->cooked_default = pstrdup(this_default); @@ -1168,8 +1163,8 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt, /* * Close the parent rel, but keep our AccessShareLock on it until xact - * commit. That will prevent someone else from deleting or ALTERing - * the parent before the child is committed. + * commit. That will prevent someone else from deleting or ALTERing the + * parent before the child is committed. */ heap_close(relation, NoLock); } @@ -1183,10 +1178,9 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) ListCell *l; /* - * Run through the constraints that need to generate an index. For - * PRIMARY KEY, mark each column as NOT NULL and create an index. For - * UNIQUE, create an index as for PRIMARY KEY, but do not insist on - * NOT NULL. + * Run through the constraints that need to generate an index. For PRIMARY + * KEY, mark each column as NOT NULL and create an index. For UNIQUE, + * create an index as for PRIMARY KEY, but do not insist on NOT NULL. */ foreach(listptr, cxt->ixconstraints) { @@ -1212,8 +1206,8 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) cxt->pkey = index; /* - * In ALTER TABLE case, a primary index might already exist, - * but DefineIndex will check for it. + * In ALTER TABLE case, a primary index might already exist, but + * DefineIndex will check for it. */ } index->isconstraint = true; @@ -1230,10 +1224,10 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) index->whereClause = NULL; /* - * Make sure referenced keys exist. If we are making a PRIMARY - * KEY index, also make sure they are NOT NULL, if possible. - * (Although we could leave it to DefineIndex to mark the columns - * NOT NULL, it's more efficient to get it right the first time.) + * Make sure referenced keys exist. If we are making a PRIMARY KEY + * index, also make sure they are NOT NULL, if possible. (Although we + * could leave it to DefineIndex to mark the columns NOT NULL, it's + * more efficient to get it right the first time.) */ foreach(keys, constraint->keys) { @@ -1261,9 +1255,9 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) else if (SystemAttributeByName(key, cxt->hasoids) != NULL) { /* - * column will be a system column in the new table, so - * accept it. System columns can't ever be null, so no - * need to worry about PRIMARY/NOT NULL constraint. + * column will be a system column in the new table, so accept + * it. System columns can't ever be null, so no need to worry + * about PRIMARY/NOT NULL constraint. */ found = true; } @@ -1283,8 +1277,8 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) if (rel->rd_rel->relkind != RELKIND_RELATION) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("inherited relation \"%s\" is not a table", - inh->relname))); + errmsg("inherited relation \"%s\" is not a table", + inh->relname))); for (count = 0; count < rel->rd_att->natts; count++) { Form_pg_attribute inhattr = rel->rd_att->attrs[count]; @@ -1298,10 +1292,9 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) /* * We currently have no easy way to force an - * inherited column to be NOT NULL at - * creation, if its parent wasn't so already. - * We leave it to DefineIndex to fix things up - * in this case. + * inherited column to be NOT NULL at creation, if + * its parent wasn't so already. We leave it to + * DefineIndex to fix things up in this case. */ break; } @@ -1313,16 +1306,16 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) } /* - * In the ALTER TABLE case, don't complain about index keys - * not created in the command; they may well exist already. - * DefineIndex will complain about them if not, and will also - * take care of marking them NOT NULL. + * In the ALTER TABLE case, don't complain about index keys not + * created in the command; they may well exist already. + * DefineIndex will complain about them if not, and will also take + * care of marking them NOT NULL. */ if (!found && !cxt->isalter) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("column \"%s\" named in key does not exist", - key))); + errmsg("column \"%s\" named in key does not exist", + key))); /* Check for PRIMARY KEY(foo, foo) */ foreach(columns, index->indexParams) @@ -1355,14 +1348,13 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) } /* - * Scan the index list and remove any redundant index specifications. - * This can happen if, for instance, the user writes UNIQUE PRIMARY - * KEY. A strict reading of SQL92 would suggest raising an error - * instead, but that strikes me as too anal-retentive. - tgl - * 2001-02-14 + * Scan the index list and remove any redundant index specifications. This + * can happen if, for instance, the user writes UNIQUE PRIMARY KEY. A + * strict reading of SQL92 would suggest raising an error instead, but + * that strikes me as too anal-retentive. - tgl 2001-02-14 * - * XXX in ALTER TABLE case, it'd be nice to look for duplicate - * pre-existing indexes, too. + * XXX in ALTER TABLE case, it'd be nice to look for duplicate pre-existing + * indexes, too. */ cxt->alist = NIL; if (cxt->pkey != NULL) @@ -1430,10 +1422,10 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt, } /* - * For CREATE TABLE or ALTER TABLE ADD COLUMN, gin up an ALTER TABLE - * ADD CONSTRAINT command to execute after the basic command is - * complete. (If called from ADD CONSTRAINT, that routine will add the - * FK constraints to its own subcommand list.) + * For CREATE TABLE or ALTER TABLE ADD COLUMN, gin up an ALTER TABLE ADD + * CONSTRAINT command to execute after the basic command is complete. (If + * called from ADD CONSTRAINT, that routine will add the FK constraints to + * its own subcommand list.) * * Note: the ADD CONSTRAINT command must also execute after any index * creation commands. Thus, this should run after @@ -1481,11 +1473,11 @@ transformIndexStmt(ParseState *pstate, IndexStmt *stmt) if (stmt->whereClause) { /* - * Put the parent table into the rtable so that the WHERE clause - * can refer to its fields without qualification. Note that this - * only works if the parent table already exists --- so we can't - * easily support predicates on indexes created implicitly by - * CREATE TABLE. Fortunately, that's not necessary. + * Put the parent table into the rtable so that the WHERE clause can + * refer to its fields without qualification. Note that this only + * works if the parent table already exists --- so we can't easily + * support predicates on indexes created implicitly by CREATE TABLE. + * Fortunately, that's not necessary. */ rte = addRangeTableEntry(pstate, stmt->relation, NULL, false, true); @@ -1514,14 +1506,14 @@ transformIndexStmt(ParseState *pstate, IndexStmt *stmt) ielem->expr = transformExpr(pstate, ielem->expr); /* - * We check only that the result type is legitimate; this is - * for consistency with what transformWhereClause() checks for - * the predicate. DefineIndex() will make more checks. + * We check only that the result type is legitimate; this is for + * consistency with what transformWhereClause() checks for the + * predicate. DefineIndex() will make more checks. */ if (expression_returns_set(ielem->expr)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("index expression may not return a set"))); + errmsg("index expression may not return a set"))); } } @@ -1560,9 +1552,9 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, rel = heap_openrv(stmt->relation, AccessExclusiveLock); /* - * NOTE: 'OLD' must always have a varno equal to 1 and 'NEW' equal to - * 2. Set up their RTEs in the main pstate for use in parsing the - * rule qualification. + * NOTE: 'OLD' must always have a varno equal to 1 and 'NEW' equal to 2. + * Set up their RTEs in the main pstate for use in parsing the rule + * qualification. */ Assert(pstate->p_rtable == NIL); oldrte = addRangeTableEntryForRelation(pstate, rel, @@ -1576,11 +1568,11 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, newrte->requiredPerms = 0; /* - * They must be in the namespace too for lookup purposes, but only add - * the one(s) that are relevant for the current kind of rule. In an - * UPDATE rule, quals must refer to OLD.field or NEW.field to be - * unambiguous, but there's no need to be so picky for INSERT & - * DELETE. We do not add them to the joinlist. + * They must be in the namespace too for lookup purposes, but only add the + * one(s) that are relevant for the current kind of rule. In an UPDATE + * rule, quals must refer to OLD.field or NEW.field to be unambiguous, but + * there's no need to be so picky for INSERT & DELETE. We do not add them + * to the joinlist. */ switch (stmt->event) { @@ -1616,17 +1608,16 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, if (pstate->p_hasAggs) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("rule WHERE condition may not contain aggregate functions"))); + errmsg("rule WHERE condition may not contain aggregate functions"))); /* save info about sublinks in where clause */ qry->hasSubLinks = pstate->p_hasSubLinks; /* - * 'instead nothing' rules with a qualification need a query - * rangetable so the rewrite handler can add the negated rule - * qualification to the original query. We create a query with the new - * command type CMD_NOTHING here that is treated specially by the - * rewrite system. + * 'instead nothing' rules with a qualification need a query rangetable so + * the rewrite handler can add the negated rule qualification to the + * original query. We create a query with the new command type CMD_NOTHING + * here that is treated specially by the rewrite system. */ if (stmt->actions == NIL) { @@ -1656,11 +1647,11 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, has_new; /* - * Set up OLD/NEW in the rtable for this statement. The - * entries are added only to relnamespace, not varnamespace, - * because we don't want them to be referred to by unqualified - * field names nor "*" in the rule actions. We decide later - * whether to put them in the joinlist. + * Set up OLD/NEW in the rtable for this statement. The entries + * are added only to relnamespace, not varnamespace, because we + * don't want them to be referred to by unqualified field names + * nor "*" in the rule actions. We decide later whether to put + * them in the joinlist. */ oldrte = addRangeTableEntryForRelation(sub_pstate, rel, makeAlias("*OLD*", NIL), @@ -1678,9 +1669,9 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, extras_before, extras_after); /* - * We cannot support utility-statement actions (eg NOTIFY) - * with nonempty rule WHERE conditions, because there's no way - * to make the utility action execute conditionally. + * We cannot support utility-statement actions (eg NOTIFY) with + * nonempty rule WHERE conditions, because there's no way to make + * the utility action execute conditionally. */ if (top_subqry->commandType == CMD_UTILITY && stmt->whereClause != NULL) @@ -1689,18 +1680,17 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, errmsg("rules with WHERE conditions may only have SELECT, INSERT, UPDATE, or DELETE actions"))); /* - * If the action is INSERT...SELECT, OLD/NEW have been pushed - * down into the SELECT, and that's what we need to look at. - * (Ugly kluge ... try to fix this when we redesign - * querytrees.) + * If the action is INSERT...SELECT, OLD/NEW have been pushed down + * into the SELECT, and that's what we need to look at. (Ugly + * kluge ... try to fix this when we redesign querytrees.) */ sub_qry = getInsertSelectQuery(top_subqry, NULL); /* - * If the sub_qry is a setop, we cannot attach any - * qualifications to it, because the planner won't notice - * them. This could perhaps be relaxed someday, but for now, - * we may as well reject such a rule immediately. + * If the sub_qry is a setop, we cannot attach any qualifications + * to it, because the planner won't notice them. This could + * perhaps be relaxed someday, but for now, we may as well reject + * such a rule immediately. */ if (sub_qry->setOperations != NULL && stmt->whereClause != NULL) ereport(ERROR, @@ -1722,12 +1712,12 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, case CMD_SELECT: if (has_old) ereport(ERROR, - (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("ON SELECT rule may not use OLD"))); + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmsg("ON SELECT rule may not use OLD"))); if (has_new) ereport(ERROR, - (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("ON SELECT rule may not use NEW"))); + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmsg("ON SELECT rule may not use NEW"))); break; case CMD_UPDATE: /* both are OK */ @@ -1735,14 +1725,14 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, case CMD_INSERT: if (has_old) ereport(ERROR, - (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("ON INSERT rule may not use OLD"))); + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmsg("ON INSERT rule may not use OLD"))); break; case CMD_DELETE: if (has_new) ereport(ERROR, - (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("ON DELETE rule may not use NEW"))); + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmsg("ON DELETE rule may not use NEW"))); break; default: elog(ERROR, "unrecognized event type: %d", @@ -1751,28 +1741,26 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, } /* - * For efficiency's sake, add OLD to the rule action's - * jointree only if it was actually referenced in the - * statement or qual. + * For efficiency's sake, add OLD to the rule action's jointree + * only if it was actually referenced in the statement or qual. * - * For INSERT, NEW is not really a relation (only a reference to - * the to-be-inserted tuple) and should never be added to the + * For INSERT, NEW is not really a relation (only a reference to the + * to-be-inserted tuple) and should never be added to the * jointree. * * For UPDATE, we treat NEW as being another kind of reference to - * OLD, because it represents references to *transformed* - * tuples of the existing relation. It would be wrong to - * enter NEW separately in the jointree, since that would - * cause a double join of the updated relation. It's also - * wrong to fail to make a jointree entry if only NEW and not - * OLD is mentioned. + * OLD, because it represents references to *transformed* tuples + * of the existing relation. It would be wrong to enter NEW + * separately in the jointree, since that would cause a double + * join of the updated relation. It's also wrong to fail to make + * a jointree entry if only NEW and not OLD is mentioned. */ if (has_old || (has_new && stmt->event == CMD_UPDATE)) { /* - * If sub_qry is a setop, manipulating its jointree will - * do no good at all, because the jointree is dummy. (This - * should be a can't-happen case because of prior tests.) + * If sub_qry is a setop, manipulating its jointree will do no + * good at all, because the jointree is dummy. (This should be + * a can't-happen case because of prior tests.) */ if (sub_qry->setOperations != NULL) ereport(ERROR, @@ -1919,8 +1907,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) qry->commandType = CMD_SELECT; /* - * Find leftmost leaf SelectStmt; extract the one-time-only items from - * it and from the top-level node. + * Find leftmost leaf SelectStmt; extract the one-time-only items from it + * and from the top-level node. */ leftmostSelect = stmt->larg; while (leftmostSelect && leftmostSelect->op != SETOP_NONE) @@ -1935,9 +1923,9 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) leftmostSelect->intoColNames = NIL; /* - * These are not one-time, exactly, but we want to process them here - * and not let transformSetOperationTree() see them --- else it'll - * just recurse right back here! + * These are not one-time, exactly, but we want to process them here and + * not let transformSetOperationTree() see them --- else it'll just + * recurse right back here! */ sortClause = stmt->sortClause; limitOffset = stmt->limitOffset; @@ -1976,13 +1964,13 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) /* * Generate dummy targetlist for outer query using column names of * leftmost select and common datatypes of topmost set operation. Also - * make lists of the dummy vars and their names for use in parsing - * ORDER BY. + * make lists of the dummy vars and their names for use in parsing ORDER + * BY. * - * Note: we use leftmostRTI as the varno of the dummy variables. It - * shouldn't matter too much which RT index they have, as long as they - * have one that corresponds to a real RT entry; else funny things may - * happen when the tree is mashed by rule rewriting. + * Note: we use leftmostRTI as the varno of the dummy variables. It shouldn't + * matter too much which RT index they have, as long as they have one that + * corresponds to a real RT entry; else funny things may happen when the + * tree is mashed by rule rewriting. */ qry->targetList = NIL; targetvars = NIL; @@ -2017,9 +2005,9 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) /* * Handle SELECT INTO/CREATE TABLE AS. * - * Any column names from CREATE TABLE AS need to be attached to both the - * top level and the leftmost subquery. We do not do this earlier - * because we do *not* want the targetnames list to be affected. + * Any column names from CREATE TABLE AS need to be attached to both the top + * level and the leftmost subquery. We do not do this earlier because we + * do *not* want the targetnames list to be affected. */ qry->into = into; if (intoColNames) @@ -2029,15 +2017,14 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) } /* - * As a first step towards supporting sort clauses that are - * expressions using the output columns, generate a varnamespace entry - * that makes the output columns visible. A Join RTE node is handy - * for this, since we can easily control the Vars generated upon - * matches. + * As a first step towards supporting sort clauses that are expressions + * using the output columns, generate a varnamespace entry that makes the + * output columns visible. A Join RTE node is handy for this, since we + * can easily control the Vars generated upon matches. * - * Note: we don't yet do anything useful with such cases, but at least - * "ORDER BY upper(foo)" will draw the right error message rather than - * "foo not found". + * Note: we don't yet do anything useful with such cases, but at least "ORDER + * BY upper(foo)" will draw the right error message rather than "foo not + * found". */ jrte = addRangeTableEntryForJoin(NULL, targetnames, @@ -2050,7 +2037,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) pstate->p_rtable = list_make1(jrte); sv_relnamespace = pstate->p_relnamespace; - pstate->p_relnamespace = NIL; /* no qualified names allowed */ + pstate->p_relnamespace = NIL; /* no qualified names allowed */ sv_varnamespace = pstate->p_varnamespace; pstate->p_varnamespace = list_make1(jrte); @@ -2058,15 +2045,15 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) /* * For now, we don't support resjunk sort clauses on the output of a * setOperation tree --- you can only use the SQL92-spec options of - * selecting an output column by name or number. Enforce by checking - * that transformSortClause doesn't add any items to tlist. + * selecting an output column by name or number. Enforce by checking that + * transformSortClause doesn't add any items to tlist. */ tllen = list_length(qry->targetList); qry->sortClause = transformSortClause(pstate, sortClause, &qry->targetList, - false /* no unknowns expected */ ); + false /* no unknowns expected */ ); pstate->p_rtable = sv_rtable; pstate->p_relnamespace = sv_relnamespace; @@ -2122,9 +2109,9 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt) /* * If an internal node of a set-op tree has ORDER BY, UPDATE, or LIMIT - * clauses attached, we need to treat it like a leaf node to generate - * an independent sub-Query tree. Otherwise, it can be represented by - * a SetOperationStmt node underneath the parent Query. + * clauses attached, we need to treat it like a leaf node to generate an + * independent sub-Query tree. Otherwise, it can be represented by a + * SetOperationStmt node underneath the parent Query. */ if (stmt->op == SETOP_NONE) { @@ -2153,9 +2140,9 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt) /* * Transform SelectStmt into a Query. * - * Note: previously transformed sub-queries don't affect the parsing - * of this sub-query, because they are not in the toplevel - * pstate's namespace list. + * Note: previously transformed sub-queries don't affect the parsing of + * this sub-query, because they are not in the toplevel pstate's + * namespace list. */ selectList = parse_sub_analyze((Node *) stmt, pstate); @@ -2164,10 +2151,10 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt) Assert(IsA(selectQuery, Query)); /* - * Check for bogus references to Vars on the current query level - * (but upper-level references are okay). Normally this can't - * happen because the namespace will be empty, but it could happen - * if we are inside a rule. + * Check for bogus references to Vars on the current query level (but + * upper-level references are okay). Normally this can't happen + * because the namespace will be empty, but it could happen if we are + * inside a rule. */ if (pstate->p_relnamespace || pstate->p_varnamespace) { @@ -2188,8 +2175,7 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt) false); /* - * Return a RangeTblRef to replace the SelectStmt in the set-op - * tree. + * Return a RangeTblRef to replace the SelectStmt in the set-op tree. */ rtr = makeNode(RangeTblRef); /* assume new rte is at end */ @@ -2229,8 +2215,8 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt) if (list_length(lcoltypes) != list_length(rcoltypes)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("each %s query must have the same number of columns", - context))); + errmsg("each %s query must have the same number of columns", + context))); op->colTypes = NIL; forboth(l, lcoltypes, r, rcoltypes) @@ -2300,7 +2286,7 @@ applyColumnNames(List *dst, List *src) if (list_length(src) > list_length(dst)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("CREATE TABLE AS specifies too many column names"))); + errmsg("CREATE TABLE AS specifies too many column names"))); forboth(dst_item, dst, src_item, src) { @@ -2329,13 +2315,13 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt) pstate->p_is_update = true; qry->resultRelation = setTargetTable(pstate, stmt->relation, - interpretInhOption(stmt->relation->inhOpt), + interpretInhOption(stmt->relation->inhOpt), true, ACL_UPDATE); /* - * the FROM clause is non-standard SQL syntax. We used to be able to - * do this with REPLACE in POSTQUEL so we keep the feature. + * the FROM clause is non-standard SQL syntax. We used to be able to do + * this with REPLACE in POSTQUEL so we keep the feature. */ transformFromClause(pstate, stmt->fromClause); @@ -2371,10 +2357,10 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt) if (tle->resjunk) { /* - * Resjunk nodes need no additional processing, but be sure - * they have resnos that do not match any target columns; else - * rewriter or planner might get confused. They don't need a - * resname either. + * Resjunk nodes need no additional processing, but be sure they + * have resnos that do not match any target columns; else rewriter + * or planner might get confused. They don't need a resname + * either. */ tle->resno = (AttrNumber) pstate->p_next_resno++; tle->resname = NULL; @@ -2428,9 +2414,9 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt, cxt.pkey = NULL; /* - * The only subtypes that currently require parse transformation - * handling are ADD COLUMN and ADD CONSTRAINT. These largely re-use - * code from CREATE TABLE. + * The only subtypes that currently require parse transformation handling + * are ADD COLUMN and ADD CONSTRAINT. These largely re-use code from + * CREATE TABLE. */ foreach(lcmd, stmt->cmds) { @@ -2472,8 +2458,8 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt, } /* - * All constraints are processed in other ways. Remove - * the original list + * All constraints are processed in other ways. Remove the + * original list */ def->constraints = NIL; @@ -2482,8 +2468,7 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt, case AT_AddConstraint: /* - * The original AddConstraint cmd node doesn't go to - * newcmds + * The original AddConstraint cmd node doesn't go to newcmds */ if (IsA(cmd->def, Constraint)) @@ -2502,8 +2487,8 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt, case AT_ProcessedConstraint: /* - * Already-transformed ADD CONSTRAINT, so just make it - * look like the standard case. + * Already-transformed ADD CONSTRAINT, so just make it look + * like the standard case. */ cmd->subtype = AT_AddConstraint; newcmds = lappend(newcmds, cmd); @@ -2521,8 +2506,8 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt, transformFKConstraints(pstate, &cxt, skipValidation, true); /* - * Push any index-creation commands into the ALTER, so that they can - * be scheduled nicely by tablecmds.c. + * Push any index-creation commands into the ALTER, so that they can be + * scheduled nicely by tablecmds.c. */ foreach(l, cxt.alist) { @@ -2669,8 +2654,8 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt) if (nparams != nexpected) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("wrong number of parameters for prepared statement \"%s\"", - stmt->name), + errmsg("wrong number of parameters for prepared statement \"%s\"", + stmt->name), errdetail("Expected %d parameters but got %d.", nexpected, nparams))); @@ -2686,7 +2671,7 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt) if (pstate->p_hasSubLinks) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot use subquery in EXECUTE parameter"))); + errmsg("cannot use subquery in EXECUTE parameter"))); if (pstate->p_hasAggs) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), @@ -2706,7 +2691,7 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt) i, format_type_be(given_type_id), format_type_be(expected_type_id)), - errhint("You will need to rewrite or cast the expression."))); + errhint("You will need to rewrite or cast the expression."))); lfirst(l) = expr; i++; @@ -2730,28 +2715,28 @@ CheckSelectLocking(Query *qry, bool forUpdate) if (qry->setOperations) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - /* translator: %s is a SQL command, like SELECT FOR UPDATE */ - errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT", operation))); + /* translator: %s is a SQL command, like SELECT FOR UPDATE */ + errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT", operation))); if (qry->distinctClause != NIL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - /* translator: %s is a SQL command, like SELECT FOR UPDATE */ - errmsg("%s is not allowed with DISTINCT clause", operation))); + /* translator: %s is a SQL command, like SELECT FOR UPDATE */ + errmsg("%s is not allowed with DISTINCT clause", operation))); if (qry->groupClause != NIL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - /* translator: %s is a SQL command, like SELECT FOR UPDATE */ - errmsg("%s is not allowed with GROUP BY clause", operation))); + /* translator: %s is a SQL command, like SELECT FOR UPDATE */ + errmsg("%s is not allowed with GROUP BY clause", operation))); if (qry->havingQual != NULL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - /* translator: %s is a SQL command, like SELECT FOR UPDATE */ + /* translator: %s is a SQL command, like SELECT FOR UPDATE */ errmsg("%s is not allowed with HAVING clause", operation))); if (qry->hasAggs) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - /* translator: %s is a SQL command, like SELECT FOR UPDATE */ - errmsg("%s is not allowed with aggregate functions", operation))); + /* translator: %s is a SQL command, like SELECT FOR UPDATE */ + errmsg("%s is not allowed with aggregate functions", operation))); } /* @@ -2775,7 +2760,7 @@ transformLockingClause(Query *qry, LockingClause *lc) if (lc->forUpdate != qry->forUpdate) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot use both FOR UPDATE and FOR SHARE in one query"))); + errmsg("cannot use both FOR UPDATE and FOR SHARE in one query"))); if (lc->nowait != qry->rowNoWait) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -2788,7 +2773,7 @@ transformLockingClause(Query *qry, LockingClause *lc) /* make a clause we can pass down to subqueries to select all rels */ allrels = makeNode(LockingClause); - allrels->lockedRels = NIL; /* indicates all rels */ + allrels->lockedRels = NIL; /* indicates all rels */ allrels->forUpdate = lc->forUpdate; allrels->nowait = lc->nowait; @@ -2813,8 +2798,8 @@ transformLockingClause(Query *qry, LockingClause *lc) case RTE_SUBQUERY: /* - * FOR UPDATE/SHARE of subquery is propagated to all - * of subquery's rels + * FOR UPDATE/SHARE of subquery is propagated to all of + * subquery's rels */ transformLockingClause(rte->subquery, allrels); break; @@ -2856,18 +2841,18 @@ transformLockingClause(Query *qry, LockingClause *lc) break; case RTE_JOIN: ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("SELECT FOR UPDATE/SHARE cannot be applied to a join"))); + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("SELECT FOR UPDATE/SHARE cannot be applied to a join"))); break; case RTE_SPECIAL: ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("SELECT FOR UPDATE/SHARE cannot be applied to NEW or OLD"))); + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("SELECT FOR UPDATE/SHARE cannot be applied to NEW or OLD"))); break; case RTE_FUNCTION: ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("SELECT FOR UPDATE/SHARE cannot be applied to a function"))); + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("SELECT FOR UPDATE/SHARE cannot be applied to a function"))); break; default: elog(ERROR, "unrecognized RTE type: %d", @@ -2940,7 +2925,7 @@ transformConstraintAttrs(List *constraintList) !IsA(lastprimarynode, FkConstraint)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("misplaced NOT DEFERRABLE clause"))); + errmsg("misplaced NOT DEFERRABLE clause"))); if (saw_deferrability) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -2958,7 +2943,7 @@ transformConstraintAttrs(List *constraintList) !IsA(lastprimarynode, FkConstraint)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("misplaced INITIALLY DEFERRED clause"))); + errmsg("misplaced INITIALLY DEFERRED clause"))); if (saw_initially) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -2967,8 +2952,7 @@ transformConstraintAttrs(List *constraintList) ((FkConstraint *) lastprimarynode)->initdeferred = true; /* - * If only INITIALLY DEFERRED appears, assume - * DEFERRABLE + * If only INITIALLY DEFERRED appears, assume DEFERRABLE */ if (!saw_deferrability) ((FkConstraint *) lastprimarynode)->deferrable = true; @@ -2982,7 +2966,7 @@ transformConstraintAttrs(List *constraintList) !IsA(lastprimarynode, FkConstraint)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("misplaced INITIALLY IMMEDIATE clause"))); + errmsg("misplaced INITIALLY IMMEDIATE clause"))); if (saw_initially) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -3082,8 +3066,8 @@ analyzeCreateSchemaStmt(CreateSchemaStmt *stmt) cxt.alist = NIL; /* - * Run through each schema element in the schema element list. - * Separate statements by type, and do preliminary analysis. + * Run through each schema element in the schema element list. Separate + * statements by type, and do preliminary analysis. */ foreach(elements, stmt->schemaElts) { @@ -3173,7 +3157,7 @@ analyzeCreateSchemaStmt(CreateSchemaStmt *stmt) */ static bool check_parameter_resolution_walker(Node *node, - check_parameter_resolution_context *context) + check_parameter_resolution_context *context) { if (node == NULL) return false; @@ -3194,8 +3178,8 @@ check_parameter_resolution_walker(Node *node, if (param->paramtype != context->paramTypes[paramno - 1]) ereport(ERROR, (errcode(ERRCODE_AMBIGUOUS_PARAMETER), - errmsg("could not determine data type of parameter $%d", - paramno))); + errmsg("could not determine data type of parameter $%d", + paramno))); } return false; } diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c index 6733d1b1240..f80b655280b 100644 --- a/src/backend/parser/keywords.c +++ b/src/backend/parser/keywords.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.165 2005/08/23 22:40:27 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.166 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -393,8 +393,8 @@ ScanKeywordLookup(const char *text) return NULL; /* - * Apply an ASCII-only downcasing. We must not use tolower() since it - * may produce the wrong translation in some locales (eg, Turkish). + * Apply an ASCII-only downcasing. We must not use tolower() since it may + * produce the wrong translation in some locales (eg, Turkish). */ for (i = 0; i < len; i++) { diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index 799bacd233e..743442895a5 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.69 2005/06/05 22:32:57 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.70 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,22 +56,22 @@ transformAggregateCall(ParseState *pstate, Aggref *agg) /* * The aggregate's level is the same as the level of the lowest-level - * variable or aggregate in its argument; or if it contains no - * variables at all, we presume it to be local. + * variable or aggregate in its argument; or if it contains no variables + * at all, we presume it to be local. */ min_varlevel = find_minimum_var_level((Node *) agg->target); /* - * An aggregate can't directly contain another aggregate call of the - * same level (though outer aggs are okay). We can skip this check if - * we didn't find any local vars or aggs. + * An aggregate can't directly contain another aggregate call of the same + * level (though outer aggs are okay). We can skip this check if we + * didn't find any local vars or aggs. */ if (min_varlevel == 0) { if (checkExprHasAggs((Node *) agg->target)) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("aggregate function calls may not be nested"))); + errmsg("aggregate function calls may not be nested"))); } if (min_varlevel < 0) @@ -127,8 +127,8 @@ parseCheckAggregates(ParseState *pstate, Query *qry) /* * No aggregates allowed in GROUP BY clauses, either. * - * While we are at it, build a list of the acceptable GROUP BY - * expressions for use by check_ungrouped_columns(). + * While we are at it, build a list of the acceptable GROUP BY expressions + * for use by check_ungrouped_columns(). */ foreach(l, qry->groupClause) { @@ -141,15 +141,15 @@ parseCheckAggregates(ParseState *pstate, Query *qry) if (checkExprHasAggs(expr)) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("aggregates not allowed in GROUP BY clause"))); + errmsg("aggregates not allowed in GROUP BY clause"))); groupClauses = lcons(expr, groupClauses); } /* - * If there are join alias vars involved, we have to flatten them to - * the underlying vars, so that aliased and unaliased vars will be - * correctly taken as equal. We can skip the expense of doing this if - * no rangetable entries are RTE_JOIN kind. + * If there are join alias vars involved, we have to flatten them to the + * underlying vars, so that aliased and unaliased vars will be correctly + * taken as equal. We can skip the expense of doing this if no rangetable + * entries are RTE_JOIN kind. */ hasJoinRTEs = false; foreach(l, pstate->p_rtable) @@ -165,8 +165,8 @@ parseCheckAggregates(ParseState *pstate, Query *qry) /* * We use the planner's flatten_join_alias_vars routine to do the - * flattening; it wants a PlannerInfo root node, which fortunately - * can be mostly dummy. + * flattening; it wants a PlannerInfo root node, which fortunately can be + * mostly dummy. */ if (hasJoinRTEs) { @@ -175,15 +175,15 @@ parseCheckAggregates(ParseState *pstate, Query *qry) root->hasJoinRTEs = true; groupClauses = (List *) flatten_join_alias_vars(root, - (Node *) groupClauses); + (Node *) groupClauses); } else root = NULL; /* keep compiler quiet */ /* - * Detect whether any of the grouping expressions aren't simple Vars; - * if they're all Vars then we don't have to work so hard in the - * recursive scans. (Note we have to flatten aliases before this.) + * Detect whether any of the grouping expressions aren't simple Vars; if + * they're all Vars then we don't have to work so hard in the recursive + * scans. (Note we have to flatten aliases before this.) */ have_non_var_grouping = false; foreach(l, groupClauses) @@ -259,23 +259,23 @@ check_ungrouped_columns_walker(Node *node, return false; /* constants are always acceptable */ /* - * If we find an aggregate call of the original level, do not recurse - * into its arguments; ungrouped vars in the arguments are not an - * error. We can also skip looking at the arguments of aggregates of - * higher levels, since they could not possibly contain Vars that are - * of concern to us (see transformAggregateCall). We do need to look - * into the arguments of aggregates of lower levels, however. + * If we find an aggregate call of the original level, do not recurse into + * its arguments; ungrouped vars in the arguments are not an error. We can + * also skip looking at the arguments of aggregates of higher levels, + * since they could not possibly contain Vars that are of concern to us + * (see transformAggregateCall). We do need to look into the arguments of + * aggregates of lower levels, however. */ if (IsA(node, Aggref) && (int) ((Aggref *) node)->agglevelsup >= context->sublevels_up) return false; /* - * If we have any GROUP BY items that are not simple Vars, check to - * see if subexpression as a whole matches any GROUP BY item. We need - * to do this at every recursion level so that we recognize GROUPed-BY - * expressions before reaching variables within them. But this only - * works at the outer query level, as noted above. + * If we have any GROUP BY items that are not simple Vars, check to see if + * subexpression as a whole matches any GROUP BY item. We need to do this + * at every recursion level so that we recognize GROUPed-BY expressions + * before reaching variables within them. But this only works at the outer + * query level, as noted above. */ if (context->have_non_var_grouping && context->sublevels_up == 0) { @@ -288,10 +288,9 @@ check_ungrouped_columns_walker(Node *node, /* * If we have an ungrouped Var of the original query level, we have a - * failure. Vars below the original query level are not a problem, - * and neither are Vars from above it. (If such Vars are ungrouped as - * far as their own query level is concerned, that's someone else's - * problem...) + * failure. Vars below the original query level are not a problem, and + * neither are Vars from above it. (If such Vars are ungrouped as far as + * their own query level is concerned, that's someone else's problem...) */ if (IsA(node, Var)) { @@ -321,7 +320,7 @@ check_ungrouped_columns_walker(Node *node, /* Found an ungrouped local variable; generate error message */ Assert(var->varno > 0 && - (int) var->varno <= list_length(context->pstate->p_rtable)); + (int) var->varno <= list_length(context->pstate->p_rtable)); rte = rt_fetch(var->varno, context->pstate->p_rtable); attname = get_rte_attribute_name(rte, var->varattno); if (context->sublevels_up == 0) @@ -390,10 +389,10 @@ build_aggregate_fnexprs(Oid agg_input_type, transfn_nargs = get_func_nargs(transfn_oid); /* - * Build arg list to use in the transfn FuncExpr node. We really only - * care that transfn can discover the actual argument types at runtime - * using get_fn_expr_argtype(), so it's okay to use Param nodes that - * don't correspond to any real Param. + * Build arg list to use in the transfn FuncExpr node. We really only care + * that transfn can discover the actual argument types at runtime using + * get_fn_expr_argtype(), so it's okay to use Param nodes that don't + * correspond to any real Param. */ arg0 = makeNode(Param); arg0->paramkind = PARAM_EXEC; diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index 593f8f1f4b6..95e1045ba2d 100644 --- a/src/backend/parser/parse_clause.c +++ b/src/backend/parser/parse_clause.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.142 2005/06/05 00:38:09 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.143 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -87,10 +87,10 @@ transformFromClause(ParseState *pstate, List *frmList) ListCell *fl; /* - * The grammar will have produced a list of RangeVars, - * RangeSubselects, RangeFunctions, and/or JoinExprs. Transform each - * one (possibly adding entries to the rtable), check for duplicate - * refnames, and then add it to the joinlist and namespaces. + * The grammar will have produced a list of RangeVars, RangeSubselects, + * RangeFunctions, and/or JoinExprs. Transform each one (possibly adding + * entries to the rtable), check for duplicate refnames, and then add it + * to the joinlist and namespaces. */ foreach(fl, frmList) { @@ -148,8 +148,8 @@ setTargetTable(ParseState *pstate, RangeVar *relation, heap_close(pstate->p_target_relation, NoLock); /* - * Open target rel and grab suitable lock (which we will hold till end - * of transaction). + * Open target rel and grab suitable lock (which we will hold till end of + * transaction). * * analyze.c will eventually do the corresponding heap_close(), but *not* * release the lock. @@ -168,14 +168,13 @@ setTargetTable(ParseState *pstate, RangeVar *relation, Assert(rte == rt_fetch(rtindex, pstate->p_rtable)); /* - * Override addRangeTableEntry's default ACL_SELECT permissions check, - * and instead mark target table as requiring exactly the specified + * Override addRangeTableEntry's default ACL_SELECT permissions check, and + * instead mark target table as requiring exactly the specified * permissions. * - * If we find an explicit reference to the rel later during parse - * analysis, scanRTEForColumn will add the ACL_SELECT bit back again. - * That can't happen for INSERT but it is possible for UPDATE and - * DELETE. + * If we find an explicit reference to the rel later during parse analysis, + * scanRTEForColumn will add the ACL_SELECT bit back again. That can't + * happen for INSERT but it is possible for UPDATE and DELETE. */ rte->requiredPerms = requiredPerms; @@ -294,10 +293,9 @@ transformJoinUsingClause(ParseState *pstate, List *leftVars, List *rightVars) *rvars; /* - * We cheat a little bit here by building an untransformed operator - * tree whose leaves are the already-transformed Vars. This is OK - * because transformExpr() won't complain about already-transformed - * subnodes. + * We cheat a little bit here by building an untransformed operator tree + * whose leaves are the already-transformed Vars. This is OK because + * transformExpr() won't complain about already-transformed subnodes. */ forboth(lvars, leftVars, rvars, rightVars) { @@ -319,10 +317,10 @@ transformJoinUsingClause(ParseState *pstate, List *leftVars, List *rightVars) } /* - * Since the references are already Vars, and are certainly from the - * input relations, we don't have to go through the same pushups that - * transformJoinOnClause() does. Just invoke transformExpr() to fix - * up the operators, and we're done. + * Since the references are already Vars, and are certainly from the input + * relations, we don't have to go through the same pushups that + * transformJoinOnClause() does. Just invoke transformExpr() to fix up + * the operators, and we're done. */ result = transformExpr(pstate, result); @@ -349,14 +347,13 @@ transformJoinOnClause(ParseState *pstate, JoinExpr *j, int varno; /* - * This is a tad tricky, for two reasons. First, the namespace that - * the join expression should see is just the two subtrees of the JOIN - * plus any outer references from upper pstate levels. So, - * temporarily set this pstate's namespace accordingly. (We need not - * check for refname conflicts, because transformFromClauseItem() - * already did.) NOTE: this code is OK only because the ON clause - * can't legally alter the namespace by causing implicit relation refs - * to be added. + * This is a tad tricky, for two reasons. First, the namespace that the + * join expression should see is just the two subtrees of the JOIN plus + * any outer references from upper pstate levels. So, temporarily set + * this pstate's namespace accordingly. (We need not check for refname + * conflicts, because transformFromClauseItem() already did.) NOTE: this + * code is OK only because the ON clause can't legally alter the namespace + * by causing implicit relation refs to be added. */ save_relnamespace = pstate->p_relnamespace; save_varnamespace = pstate->p_varnamespace; @@ -371,11 +368,10 @@ transformJoinOnClause(ParseState *pstate, JoinExpr *j, /* * Second, we need to check that the ON condition doesn't refer to any - * rels outside the input subtrees of the JOIN. It could do that - * despite our hack on the namespace if it uses fully-qualified names. - * So, grovel through the transformed clause and make sure there are - * no bogus references. (Outer references are OK, and are ignored - * here.) + * rels outside the input subtrees of the JOIN. It could do that despite + * our hack on the namespace if it uses fully-qualified names. So, grovel + * through the transformed clause and make sure there are no bogus + * references. (Outer references are OK, and are ignored here.) */ clause_varnos = pull_varnos(result); clause_varnos = bms_del_members(clause_varnos, containedRels); @@ -383,8 +379,8 @@ transformJoinOnClause(ParseState *pstate, JoinExpr *j, { ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), - errmsg("JOIN/ON clause refers to \"%s\", which is not part of JOIN", - rt_fetch(varno, pstate->p_rtable)->eref->aliasname))); + errmsg("JOIN/ON clause refers to \"%s\", which is not part of JOIN", + rt_fetch(varno, pstate->p_rtable)->eref->aliasname))); } bms_free(clause_varnos); @@ -400,9 +396,9 @@ transformTableEntry(ParseState *pstate, RangeVar *r) RangeTblEntry *rte; /* - * mark this entry to indicate it comes from the FROM clause. In SQL, - * the target list can only refer to range variables specified in the - * from clause but we follow the more powerful POSTQUEL semantics and + * mark this entry to indicate it comes from the FROM clause. In SQL, the + * target list can only refer to range variables specified in the from + * clause but we follow the more powerful POSTQUEL semantics and * automatically generate the range variable if not specified. However * there are times we need to know whether the entries are legitimate. */ @@ -424,9 +420,9 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r) RangeTblEntry *rte; /* - * We require user to supply an alias for a subselect, per SQL92. To - * relax this, we'd have to be prepared to gin up a unique alias for - * an unlabeled subselect. + * We require user to supply an alias for a subselect, per SQL92. To relax + * this, we'd have to be prepared to gin up a unique alias for an + * unlabeled subselect. */ if (r->alias == NULL) ereport(ERROR, @@ -439,9 +435,9 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r) parsetrees = parse_sub_analyze(r->subquery, pstate); /* - * Check that we got something reasonable. Most of these conditions - * are probably impossible given restrictions of the grammar, but - * check 'em anyway. + * Check that we got something reasonable. Most of these conditions are + * probably impossible given restrictions of the grammar, but check 'em + * anyway. */ if (list_length(parsetrees) != 1) elog(ERROR, "unexpected parse analysis result for subquery in FROM"); @@ -457,19 +453,17 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r) errmsg("subquery in FROM may not have SELECT INTO"))); /* - * The subquery cannot make use of any variables from FROM items - * created earlier in the current query. Per SQL92, the scope of a - * FROM item does not include other FROM items. Formerly we hacked - * the namespace so that the other variables weren't even visible, but - * it seems more useful to leave them visible and give a specific - * error message. + * The subquery cannot make use of any variables from FROM items created + * earlier in the current query. Per SQL92, the scope of a FROM item does + * not include other FROM items. Formerly we hacked the namespace so that + * the other variables weren't even visible, but it seems more useful to + * leave them visible and give a specific error message. * * XXX this will need further work to support SQL99's LATERAL() feature, * wherein such references would indeed be legal. * - * We can skip groveling through the subquery if there's not anything - * visible in the current query. Also note that outer references are - * OK. + * We can skip groveling through the subquery if there's not anything visible + * in the current query. Also note that outer references are OK. */ if (pstate->p_relnamespace || pstate->p_varnamespace) { @@ -500,9 +494,9 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) /* * Get function name for possible use as alias. We use the same - * transformation rules as for a SELECT output expression. For a - * FuncCall node, the result will be the function name, but it is - * possible for the grammar to hand back other node types. + * transformation rules as for a SELECT output expression. For a FuncCall + * node, the result will be the function name, but it is possible for the + * grammar to hand back other node types. */ funcname = FigureColname(r->funccallnode); @@ -514,8 +508,8 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) /* * The function parameters cannot make use of any variables from other * FROM items. (Compare to transformRangeSubselect(); the coding is - * different though because we didn't parse as a sub-select with its - * own level of namespace.) + * different though because we didn't parse as a sub-select with its own + * level of namespace.) * * XXX this will need further work to support SQL99's LATERAL() feature, * wherein such references would indeed be legal. @@ -529,8 +523,8 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) } /* - * Disallow aggregate functions in the expression. (No reason to - * postpone this check until parseCheckAggregates.) + * Disallow aggregate functions in the expression. (No reason to postpone + * this check until parseCheckAggregates.) */ if (pstate->p_hasAggs) { @@ -541,8 +535,8 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) } /* - * If a coldeflist is supplied, ensure it defines a legal set of names - * (no duplicates) and datatypes (no pseudo-types, for instance). + * If a coldeflist is supplied, ensure it defines a legal set of names (no + * duplicates) and datatypes (no pseudo-types, for instance). */ if (r->coldeflist) { @@ -576,7 +570,7 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) * (We could extract this from the function return node, but it saves cycles * to pass it back separately.) * - * *top_rti: receives the rangetable index of top_rte. (Ditto.) + * *top_rti: receives the rangetable index of top_rte. (Ditto.) * * *relnamespace: receives a List of the RTEs exposed as relation names * by this item. @@ -599,7 +593,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, /* Plain relation reference */ RangeTblRef *rtr; RangeTblEntry *rte; - int rtindex; + int rtindex; rte = transformTableEntry(pstate, (RangeVar *) n); /* assume new rte is at end */ @@ -618,7 +612,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, /* sub-SELECT is like a plain relation */ RangeTblRef *rtr; RangeTblEntry *rte; - int rtindex; + int rtindex; rte = transformRangeSubselect(pstate, (RangeSubselect *) n); /* assume new rte is at end */ @@ -637,7 +631,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, /* function is like a plain relation */ RangeTblRef *rtr; RangeTblEntry *rte; - int rtindex; + int rtindex; rte = transformRangeFunction(pstate, (RangeFunction *) n); /* assume new rte is at end */ @@ -688,8 +682,8 @@ transformFromClauseItem(ParseState *pstate, Node *n, &r_containedRels); /* - * Check for conflicting refnames in left and right subtrees. Must - * do this because higher levels will assume I hand back a self- + * Check for conflicting refnames in left and right subtrees. Must do + * this because higher levels will assume I hand back a self- * consistent namespace subtree. */ checkNameSpaceConflicts(pstate, l_relnamespace, r_relnamespace); @@ -715,12 +709,12 @@ transformFromClauseItem(ParseState *pstate, Node *n, /* * Natural join does not explicitly specify columns; must generate - * columns to join. Need to run through the list of columns from - * each table or join result and match up the column names. Use - * the first table, and check every column in the second table for - * a match. (We'll check that the matches were unique later on.) - * The result of this step is a list of column names just like an - * explicitly-written USING list. + * columns to join. Need to run through the list of columns from each + * table or join result and match up the column names. Use the first + * table, and check every column in the second table for a match. + * (We'll check that the matches were unique later on.) The result of + * this step is a list of column names just like an explicitly-written + * USING list. */ if (j->isNatural) { @@ -763,9 +757,9 @@ transformFromClauseItem(ParseState *pstate, Node *n, if (j->using) { /* - * JOIN/USING (or NATURAL JOIN, as transformed above). - * Transform the list into an explicit ON-condition, and - * generate a list of merged result columns. + * JOIN/USING (or NATURAL JOIN, as transformed above). Transform + * the list into an explicit ON-condition, and generate a list of + * merged result columns. */ List *ucols = j->using; List *l_usingvars = NIL; @@ -917,10 +911,10 @@ transformFromClauseItem(ParseState *pstate, Node *n, *top_rti = j->rtindex; /* - * Prepare returned namespace list. If the JOIN has an alias - * then it hides the contained RTEs as far as the relnamespace - * goes; otherwise, put the contained RTEs and *not* the JOIN - * into relnamespace. + * Prepare returned namespace list. If the JOIN has an alias then it + * hides the contained RTEs as far as the relnamespace goes; + * otherwise, put the contained RTEs and *not* the JOIN into + * relnamespace. */ if (j->alias) { @@ -975,10 +969,10 @@ buildMergedJoinVar(ParseState *pstate, JoinType jointype, } /* - * Insert coercion functions if needed. Note that a difference in - * typmod can only happen if input has typmod but outcoltypmod is -1. - * In that case we insert a RelabelType to clearly mark that result's - * typmod is not same as input. We never need coerce_type_typmod. + * Insert coercion functions if needed. Note that a difference in typmod + * can only happen if input has typmod but outcoltypmod is -1. In that + * case we insert a RelabelType to clearly mark that result's typmod is + * not same as input. We never need coerce_type_typmod. */ if (l_colvar->vartype != outcoltype) l_node = coerce_type(pstate, (Node *) l_colvar, l_colvar->vartype, @@ -1030,8 +1024,8 @@ buildMergedJoinVar(ParseState *pstate, JoinType jointype, case JOIN_FULL: { /* - * Here we must build a COALESCE expression to ensure that - * the join output is non-null if either input is. + * Here we must build a COALESCE expression to ensure that the + * join output is non-null if either input is. */ CoalesceExpr *c = makeNode(CoalesceExpr); @@ -1095,9 +1089,9 @@ transformLimitClause(ParseState *pstate, Node *clause, qual = coerce_to_integer(pstate, qual, constructName); /* - * LIMIT can't refer to any vars or aggregates of the current query; - * we don't allow subselects either (though that case would at least - * be sensible) + * LIMIT can't refer to any vars or aggregates of the current query; we + * don't allow subselects either (though that case would at least be + * sensible) */ if (contain_vars_of_level(qual, 0)) { @@ -1193,20 +1187,19 @@ findTargetlistEntry(ParseState *pstate, Node *node, List **tlist, int clause) { /* * In GROUP BY, we must prefer a match against a FROM-clause - * column to one against the targetlist. Look to see if there - * is a matching column. If so, fall through to let - * transformExpr() do the rest. NOTE: if name could refer - * ambiguously to more than one column name exposed by FROM, - * colNameToVar will ereport(ERROR). That's just what we want - * here. + * column to one against the targetlist. Look to see if there is + * a matching column. If so, fall through to let transformExpr() + * do the rest. NOTE: if name could refer ambiguously to more + * than one column name exposed by FROM, colNameToVar will + * ereport(ERROR). That's just what we want here. * - * Small tweak for 7.4.3: ignore matches in upper query levels. - * This effectively changes the search order for bare names to - * (1) local FROM variables, (2) local targetlist aliases, (3) - * outer FROM variables, whereas before it was (1) (3) (2). - * SQL92 and SQL99 do not allow GROUPing BY an outer - * reference, so this breaks no cases that are legal per spec, - * and it seems a more self-consistent behavior. + * Small tweak for 7.4.3: ignore matches in upper query levels. This + * effectively changes the search order for bare names to (1) + * local FROM variables, (2) local targetlist aliases, (3) outer + * FROM variables, whereas before it was (1) (3) (2). SQL92 and + * SQL99 do not allow GROUPing BY an outer reference, so this + * breaks no cases that are legal per spec, and it seems a more + * self-consistent behavior. */ if (colNameToVar(pstate, name, true) != NULL) name = NULL; @@ -1292,9 +1285,9 @@ findTargetlistEntry(ParseState *pstate, Node *node, List **tlist, int clause) } /* - * If no matches, construct a new target entry which is appended to - * the end of the target list. This target is given resjunk = TRUE so - * that it will not be projected into the final tuple. + * If no matches, construct a new target entry which is appended to the + * end of the target list. This target is given resjunk = TRUE so that it + * will not be projected into the final tuple. */ target_result = transformTargetEntry(pstate, node, expr, NULL, true); @@ -1349,11 +1342,11 @@ transformGroupClause(ParseState *pstate, List *grouplist, /* * If the GROUP BY clause matches the ORDER BY clause, we want to - * adopt the ordering operators from the latter rather than using - * the default ops. This allows "GROUP BY foo ORDER BY foo DESC" - * to be done with only one sort step. Note we are assuming that - * any user-supplied ordering operator will bring equal values - * together, which is all that GROUP BY needs. + * adopt the ordering operators from the latter rather than using the + * default ops. This allows "GROUP BY foo ORDER BY foo DESC" to be + * done with only one sort step. Note we are assuming that any + * user-supplied ordering operator will bring equal values together, + * which is all that GROUP BY needs. */ if (sortItem && ((SortClause *) lfirst(sortItem))->tleSortGroupRef == @@ -1435,11 +1428,11 @@ transformDistinctClause(ParseState *pstate, List *distinctlist, /* We had SELECT DISTINCT */ /* - * All non-resjunk elements from target list that are not already - * in the sort list should be added to it. (We don't really care - * what order the DISTINCT fields are checked in, so we can leave - * the user's ORDER BY spec alone, and just add additional sort - * keys to it to ensure that all targetlist items get sorted.) + * All non-resjunk elements from target list that are not already in + * the sort list should be added to it. (We don't really care what + * order the DISTINCT fields are checked in, so we can leave the + * user's ORDER BY spec alone, and just add additional sort keys to it + * to ensure that all targetlist items get sorted.) */ *sortClause = addAllTargetsToSortList(pstate, *sortClause, @@ -1449,9 +1442,9 @@ transformDistinctClause(ParseState *pstate, List *distinctlist, /* * Now, DISTINCT list consists of all non-resjunk sortlist items. * Actually, all the sortlist items had better be non-resjunk! - * Otherwise, user wrote SELECT DISTINCT with an ORDER BY item - * that does not appear anywhere in the SELECT targetlist, and we - * can't implement that with only one sorting pass... + * Otherwise, user wrote SELECT DISTINCT with an ORDER BY item that + * does not appear anywhere in the SELECT targetlist, and we can't + * implement that with only one sorting pass... */ foreach(slitem, *sortClause) { @@ -1474,16 +1467,16 @@ transformDistinctClause(ParseState *pstate, List *distinctlist, * If the user writes both DISTINCT ON and ORDER BY, then the two * expression lists must match (until one or the other runs out). * Otherwise the ORDER BY requires a different sort order than the - * DISTINCT does, and we can't implement that with only one sort - * pass (and if we do two passes, the results will be rather + * DISTINCT does, and we can't implement that with only one sort pass + * (and if we do two passes, the results will be rather * unpredictable). However, it's OK to have more DISTINCT ON - * expressions than ORDER BY expressions; we can just add the - * extra DISTINCT values to the sort list, much as we did above - * for ordinary DISTINCT fields. + * expressions than ORDER BY expressions; we can just add the extra + * DISTINCT values to the sort list, much as we did above for ordinary + * DISTINCT fields. * - * Actually, it'd be OK for the common prefixes of the two lists to - * match in any order, but implementing that check seems like more - * trouble than it's worth. + * Actually, it'd be OK for the common prefixes of the two lists to match + * in any order, but implementing that check seems like more trouble + * than it's worth. */ ListCell *nextsortlist = list_head(*sortClause); @@ -1508,12 +1501,12 @@ transformDistinctClause(ParseState *pstate, List *distinctlist, else { *sortClause = addTargetToSortList(pstate, tle, - *sortClause, *targetlist, + *sortClause, *targetlist, SORTBY_ASC, NIL, true); /* - * Probably, the tle should always have been added at the - * end of the sort list ... but search to be safe. + * Probably, the tle should always have been added at the end + * of the sort list ... but search to be safe. */ foreach(slitem, *sortClause) { @@ -1638,7 +1631,7 @@ assignSortGroupRef(TargetEntry *tle, List *tlist) Index maxRef; ListCell *l; - if (tle->ressortgroupref) /* already has one? */ + if (tle->ressortgroupref) /* already has one? */ return tle->ressortgroupref; /* easiest way to pick an unused refnumber: max used + 1 */ diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index 32a20fc3622..3bee3c31ad5 100644 --- a/src/backend/parser/parse_coerce.c +++ b/src/backend/parser/parse_coerce.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.131 2005/06/04 19:19:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.132 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -82,9 +82,9 @@ coerce_to_target_type(ParseState *pstate, Node *expr, Oid exprtype, ccontext, cformat); /* - * If the target is a fixed-length type, it may need a length coercion - * as well as a type coercion. If we find ourselves adding both, - * force the inner coercion node to implicit display form. + * If the target is a fixed-length type, it may need a length coercion as + * well as a type coercion. If we find ourselves adding both, force the + * inner coercion node to implicit display form. */ result = coerce_type_typmod(result, targettype, targettypmod, @@ -140,9 +140,9 @@ coerce_type(ParseState *pstate, Node *node, if (inputTypeId == UNKNOWNOID && IsA(node, Const)) { /* - * Input is a string constant with previously undetermined type. - * Apply the target type's typinput function to it to produce a - * constant of the target type. + * Input is a string constant with previously undetermined type. Apply + * the target type's typinput function to it to produce a constant of + * the target type. * * NOTE: this case cannot be folded together with the other * constant-input case, since the typinput function does not @@ -151,10 +151,10 @@ coerce_type(ParseState *pstate, Node *node, * float-to-int type conversion will round to integer. * * XXX if the typinput function is not immutable, we really ought to - * postpone evaluation of the function call until runtime. But - * there is no way to represent a typinput function call as an - * expression tree, because C-string values are not Datums. (XXX - * This *is* possible as of 7.3, do we want to do it?) + * postpone evaluation of the function call until runtime. But there + * is no way to represent a typinput function call as an expression + * tree, because C-string values are not Datums. (XXX This *is* + * possible as of 7.3, do we want to do it?) */ Const *con = (Const *) node; Const *newcon = makeNode(Const); @@ -176,14 +176,13 @@ coerce_type(ParseState *pstate, Node *node, /* * We pass typmod -1 to the input routine, primarily because - * existing input routines follow implicit-coercion semantics - * for length checks, which is not always what we want here. - * Any length constraint will be applied later by our caller. + * existing input routines follow implicit-coercion semantics for + * length checks, which is not always what we want here. Any + * length constraint will be applied later by our caller. * - * Note that we call stringTypeDatum using the domain's pg_type - * row, if it's a domain. This works because the domain row - * has the same typinput and typelem as the base type --- - * ugly... + * Note that we call stringTypeDatum using the domain's pg_type row, + * if it's a domain. This works because the domain row has the + * same typinput and typelem as the base type --- ugly... */ newcon->constvalue = stringTypeDatum(targetType, val, -1); } @@ -204,8 +203,8 @@ coerce_type(ParseState *pstate, Node *node, pstate != NULL && pstate->p_variableparams) { /* - * Input is a Param of previously undetermined type, and we want - * to update our knowledge of the Param's type. Find the topmost + * Input is a Param of previously undetermined type, and we want to + * update our knowledge of the Param's type. Find the topmost * ParseState and update the state. */ Param *param = (Param *) node; @@ -236,10 +235,10 @@ coerce_type(ParseState *pstate, Node *node, /* Ooops */ ereport(ERROR, (errcode(ERRCODE_AMBIGUOUS_PARAMETER), - errmsg("inconsistent types deduced for parameter $%d", - paramno), + errmsg("inconsistent types deduced for parameter $%d", + paramno), errdetail("%s versus %s", - format_type_be(toppstate->p_paramtypes[paramno - 1]), + format_type_be(toppstate->p_paramtypes[paramno - 1]), format_type_be(targetTypeId)))); } @@ -252,11 +251,11 @@ coerce_type(ParseState *pstate, Node *node, if (OidIsValid(funcId)) { /* - * Generate an expression tree representing run-time - * application of the conversion function. If we are dealing - * with a domain target type, the conversion function will - * yield the base type, and we need to extract the correct - * typmod to use from the domain's typtypmod. + * Generate an expression tree representing run-time application + * of the conversion function. If we are dealing with a domain + * target type, the conversion function will yield the base type, + * and we need to extract the correct typmod to use from the + * domain's typtypmod. */ Oid baseTypeId = getBaseType(targetTypeId); int32 baseTypeMod; @@ -269,13 +268,12 @@ coerce_type(ParseState *pstate, Node *node, result = build_coercion_expression(node, funcId, baseTypeId, baseTypeMod, cformat, - (cformat != COERCE_IMPLICIT_CAST)); + (cformat != COERCE_IMPLICIT_CAST)); /* - * If domain, coerce to the domain type and relabel with - * domain type ID. We can skip the internal length-coercion - * step if the selected coercion function was a type-and-length - * coercion. + * If domain, coerce to the domain type and relabel with domain + * type ID. We can skip the internal length-coercion step if the + * selected coercion function was a type-and-length coercion. */ if (targetTypeId != baseTypeId) result = coerce_to_domain(result, baseTypeId, targetTypeId, @@ -286,10 +284,9 @@ coerce_type(ParseState *pstate, Node *node, else { /* - * We don't need to do a physical conversion, but we do need - * to attach a RelabelType node so that the expression will be - * seen to have the intended type when inspected by - * higher-level code. + * We don't need to do a physical conversion, but we do need to + * attach a RelabelType node so that the expression will be seen + * to have the intended type when inspected by higher-level code. * * Also, domains may have value restrictions beyond the base type * that must be accounted for. If the destination is a domain @@ -300,11 +297,10 @@ coerce_type(ParseState *pstate, Node *node, if (result == node) { /* - * XXX could we label result with exprTypmod(node) instead - * of default -1 typmod, to save a possible - * length-coercion later? Would work if both types have - * same interpretation of typmod, which is likely but not - * certain. + * XXX could we label result with exprTypmod(node) instead of + * default -1 typmod, to save a possible length-coercion + * later? Would work if both types have same interpretation of + * typmod, which is likely but not certain. */ result = (Node *) makeRelabelType((Expr *) result, targetTypeId, -1, @@ -331,8 +327,8 @@ coerce_type(ParseState *pstate, Node *node, { /* * Input class type is a subclass of target, so generate an - * appropriate runtime conversion (removing unneeded columns - * and possibly rearranging the ones that are wanted). + * appropriate runtime conversion (removing unneeded columns and + * possibly rearranging the ones that are wanted). */ ConvertRowtypeExpr *r = makeNode(ConvertRowtypeExpr); @@ -386,23 +382,23 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids, } /* - * If input is an untyped string constant, assume we can convert - * it to anything. + * If input is an untyped string constant, assume we can convert it to + * anything. */ if (inputTypeId == UNKNOWNOID) continue; /* - * If pg_cast shows that we can coerce, accept. This test now - * covers both binary-compatible and coercion-function cases. + * If pg_cast shows that we can coerce, accept. This test now covers + * both binary-compatible and coercion-function cases. */ if (find_coercion_pathway(targetTypeId, inputTypeId, ccontext, &funcId)) continue; /* - * If input is RECORD and target is a composite type, assume we - * can coerce (may need tighter checking here) + * If input is RECORD and target is a composite type, assume we can + * coerce (may need tighter checking here) */ if (inputTypeId == RECORDOID && ISCOMPLEX(targetTypeId)) @@ -472,22 +468,21 @@ coerce_to_domain(Node *arg, Oid baseTypeId, Oid typeId, hide_coercion_node(arg); /* - * If the domain applies a typmod to its base type, build the - * appropriate coercion step. Mark it implicit for display purposes, - * because we don't want it shown separately by ruleutils.c; but the - * isExplicit flag passed to the conversion function depends on the - * manner in which the domain coercion is invoked, so that the - * semantics of implicit and explicit coercion differ. (Is that - * really the behavior we want?) + * If the domain applies a typmod to its base type, build the appropriate + * coercion step. Mark it implicit for display purposes, because we don't + * want it shown separately by ruleutils.c; but the isExplicit flag passed + * to the conversion function depends on the manner in which the domain + * coercion is invoked, so that the semantics of implicit and explicit + * coercion differ. (Is that really the behavior we want?) * * NOTE: because we apply this as part of the fixed expression structure, - * ALTER DOMAIN cannot alter the typtypmod. But it's unclear that - * that would be safe to do anyway, without lots of knowledge about - * what the base type thinks the typmod means. + * ALTER DOMAIN cannot alter the typtypmod. But it's unclear that that + * would be safe to do anyway, without lots of knowledge about what the + * base type thinks the typmod means. */ if (!lengthCoercionDone) { - int32 typmod = get_typtypmod(typeId); + int32 typmod = get_typtypmod(typeId); if (typmod >= 0) arg = coerce_type_typmod(arg, baseTypeId, typmod, @@ -497,10 +492,9 @@ coerce_to_domain(Node *arg, Oid baseTypeId, Oid typeId, } /* - * Now build the domain coercion node. This represents run-time - * checking of any constraints currently attached to the domain. This - * also ensures that the expression is properly labeled as to result - * type. + * Now build the domain coercion node. This represents run-time checking + * of any constraints currently attached to the domain. This also ensures + * that the expression is properly labeled as to result type. */ result = makeNode(CoerceToDomain); result->arg = (Expr *) arg; @@ -541,8 +535,8 @@ coerce_type_typmod(Node *node, Oid targetTypeId, int32 targetTypMod, Oid funcId; /* - * A negative typmod is assumed to mean that no coercion is wanted. - * Also, skip coercion if already done. + * A negative typmod is assumed to mean that no coercion is wanted. Also, + * skip coercion if already done. */ if (targetTypMod < 0 || targetTypMod == exprTypmod(node)) return node; @@ -616,9 +610,9 @@ build_coercion_expression(Node *node, Oid funcId, procstruct = (Form_pg_proc) GETSTRUCT(tp); /* - * Asserts essentially check that function is a legal coercion - * function. We can't make the seemingly obvious tests on prorettype - * and proargtypes[0], because of various binary-compatibility cases. + * Asserts essentially check that function is a legal coercion function. + * We can't make the seemingly obvious tests on prorettype and + * proargtypes[0], because of various binary-compatibility cases. */ /* Assert(targetTypeId == procstruct->prorettype); */ Assert(!procstruct->proretset); @@ -685,8 +679,8 @@ coerce_record_to_complex(ParseState *pstate, Node *node, if (node && IsA(node, RowExpr)) { /* - * Since the RowExpr must be of type RECORD, we needn't worry - * about it containing any dropped columns. + * Since the RowExpr must be of type RECORD, we needn't worry about it + * containing any dropped columns. */ args = ((RowExpr *) node)->args; } @@ -721,8 +715,8 @@ coerce_record_to_complex(ParseState *pstate, Node *node, if (tupdesc->attrs[i]->attisdropped) { /* - * can't use atttypid here, but it doesn't really matter what - * type the Const claims to be. + * can't use atttypid here, but it doesn't really matter what type + * the Const claims to be. */ newargs = lappend(newargs, makeNullConst(INT4OID)); continue; @@ -752,7 +746,7 @@ coerce_record_to_complex(ParseState *pstate, Node *node, format_type_be(targetTypeId)), errdetail("Cannot cast type %s to %s in column %d.", format_type_be(exprtype), - format_type_be(tupdesc->attrs[i]->atttypid), + format_type_be(tupdesc->attrs[i]->atttypid), ucolno))); newargs = lappend(newargs, expr); ucolno++; @@ -798,8 +792,8 @@ coerce_to_boolean(ParseState *pstate, Node *node, ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), /* translator: first %s is name of a SQL construct, eg WHERE */ - errmsg("argument of %s must be type boolean, not type %s", - constructName, format_type_be(inputTypeId)))); + errmsg("argument of %s must be type boolean, not type %s", + constructName, format_type_be(inputTypeId)))); } if (expression_returns_set(node)) @@ -837,8 +831,8 @@ coerce_to_integer(ParseState *pstate, Node *node, ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), /* translator: first %s is name of a SQL construct, eg LIMIT */ - errmsg("argument of %s must be type integer, not type %s", - constructName, format_type_be(inputTypeId)))); + errmsg("argument of %s must be type integer, not type %s", + constructName, format_type_be(inputTypeId)))); } if (expression_returns_set(node)) @@ -889,15 +883,13 @@ select_common_type(List *typeids, const char *context) else if (TypeCategory(ntype) != pcategory) { /* - * both types in different categories? then not much - * hope... + * both types in different categories? then not much hope... */ ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), /* - * translator: first %s is name of a SQL construct, eg - * CASE + * translator: first %s is name of a SQL construct, eg CASE */ errmsg("%s types %s and %s cannot be matched", context, @@ -905,13 +897,12 @@ select_common_type(List *typeids, const char *context) format_type_be(ntype)))); } else if (!IsPreferredType(pcategory, ptype) && - can_coerce_type(1, &ptype, &ntype, COERCION_IMPLICIT) && - !can_coerce_type(1, &ntype, &ptype, COERCION_IMPLICIT)) + can_coerce_type(1, &ptype, &ntype, COERCION_IMPLICIT) && + !can_coerce_type(1, &ntype, &ptype, COERCION_IMPLICIT)) { /* - * take new type if can coerce to it implicitly but not - * the other way; but if we have a preferred type, stay on - * it. + * take new type if can coerce to it implicitly but not the + * other way; but if we have a preferred type, stay on it. */ ptype = ntype; pcategory = TypeCategory(ptype); @@ -920,15 +911,15 @@ select_common_type(List *typeids, const char *context) } /* - * If all the inputs were UNKNOWN type --- ie, unknown-type literals - * --- then resolve as type TEXT. This situation comes up with - * constructs like SELECT (CASE WHEN foo THEN 'bar' ELSE 'baz' END); - * SELECT 'foo' UNION SELECT 'bar'; It might seem desirable to leave - * the construct's output type as UNKNOWN, but that really doesn't - * work, because we'd probably end up needing a runtime coercion from - * UNKNOWN to something else, and we usually won't have it. We need - * to coerce the unknown literals while they are still literals, so a - * decision has to be made now. + * If all the inputs were UNKNOWN type --- ie, unknown-type literals --- + * then resolve as type TEXT. This situation comes up with constructs + * like SELECT (CASE WHEN foo THEN 'bar' ELSE 'baz' END); SELECT 'foo' + * UNION SELECT 'bar'; It might seem desirable to leave the construct's + * output type as UNKNOWN, but that really doesn't work, because we'd + * probably end up needing a runtime coercion from UNKNOWN to something + * else, and we usually won't have it. We need to coerce the unknown + * literals while they are still literals, so a decision has to be made + * now. */ if (ptype == UNKNOWNOID) ptype = TEXTOID; @@ -1005,9 +996,8 @@ check_generic_type_consistency(Oid *actual_arg_types, bool have_anyelement = false; /* - * Loop through the arguments to see if we have any that are ANYARRAY - * or ANYELEMENT. If so, require the actual types to be - * self-consistent + * Loop through the arguments to see if we have any that are ANYARRAY or + * ANYELEMENT. If so, require the actual types to be self-consistent */ for (j = 0; j < nargs; j++) { @@ -1050,8 +1040,7 @@ check_generic_type_consistency(Oid *actual_arg_types, if (!OidIsValid(elem_typeid)) { /* - * if we don't have an element type yet, use the one we just - * got + * if we don't have an element type yet, use the one we just got */ elem_typeid = array_typelem; } @@ -1118,9 +1107,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, bool have_anyelement = (rettype == ANYELEMENTOID); /* - * Loop through the arguments to see if we have any that are ANYARRAY - * or ANYELEMENT. If so, require the actual types to be - * self-consistent + * Loop through the arguments to see if we have any that are ANYARRAY or + * ANYELEMENT. If so, require the actual types to be self-consistent */ for (j = 0; j < nargs; j++) { @@ -1137,7 +1125,7 @@ enforce_generic_type_consistency(Oid *actual_arg_types, if (OidIsValid(elem_typeid) && actual_type != elem_typeid) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("arguments declared \"anyelement\" are not all alike"), + errmsg("arguments declared \"anyelement\" are not all alike"), errdetail("%s versus %s", format_type_be(elem_typeid), format_type_be(actual_type)))); @@ -1154,7 +1142,7 @@ enforce_generic_type_consistency(Oid *actual_arg_types, if (OidIsValid(array_typeid) && actual_type != array_typeid) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("arguments declared \"anyarray\" are not all alike"), + errmsg("arguments declared \"anyarray\" are not all alike"), errdetail("%s versus %s", format_type_be(array_typeid), format_type_be(actual_type)))); @@ -1163,8 +1151,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, } /* - * Fast Track: if none of the arguments are ANYARRAY or ANYELEMENT, - * return the unmodified rettype. + * Fast Track: if none of the arguments are ANYARRAY or ANYELEMENT, return + * the unmodified rettype. */ if (!have_generics) return rettype; @@ -1190,8 +1178,7 @@ enforce_generic_type_consistency(Oid *actual_arg_types, if (!OidIsValid(elem_typeid)) { /* - * if we don't have an element type yet, use the one we just - * got + * if we don't have an element type yet, use the one we just got */ elem_typeid = array_typelem; } @@ -1236,8 +1223,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, if (!OidIsValid(array_typeid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("could not find array type for data type %s", - format_type_be(elem_typeid)))); + errmsg("could not find array type for data type %s", + format_type_be(elem_typeid)))); } declared_arg_types[j] = array_typeid; } @@ -1253,8 +1240,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, if (!OidIsValid(array_typeid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("could not find array type for data type %s", - format_type_be(elem_typeid)))); + errmsg("could not find array type for data type %s", + format_type_be(elem_typeid)))); } return array_typeid; } @@ -1307,8 +1294,8 @@ resolve_generic_type(Oid declared_type, if (!OidIsValid(array_typeid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("could not find array type for data type %s", - format_type_be(context_actual_type)))); + errmsg("could not find array type for data type %s", + format_type_be(context_actual_type)))); return array_typeid; } } @@ -1471,8 +1458,8 @@ IsPreferredType(CATEGORY category, Oid type) return false; /* - * This switch should agree with TypeCategory(), above. Note that at - * this point, category certainly matches the type. + * This switch should agree with TypeCategory(), above. Note that at this + * point, category certainly matches the type. */ switch (category) { @@ -1679,17 +1666,16 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, else { /* - * If there's no pg_cast entry, perhaps we are dealing with a pair - * of array types. If so, and if the element types have a - * suitable cast, use array_type_coerce() or - * array_type_length_coerce(). + * If there's no pg_cast entry, perhaps we are dealing with a pair of + * array types. If so, and if the element types have a suitable cast, + * use array_type_coerce() or array_type_length_coerce(). * - * Hack: disallow coercions to oidvector and int2vector, which - * otherwise tend to capture coercions that should go to "real" array - * types. We want those types to be considered "real" arrays for many - * purposes, but not this one. (Also, array_type_coerce isn't - * guaranteed to produce an output that meets the restrictions of - * these datatypes, such as being 1-dimensional.) + * Hack: disallow coercions to oidvector and int2vector, which otherwise + * tend to capture coercions that should go to "real" array types. We + * want those types to be considered "real" arrays for many purposes, + * but not this one. (Also, array_type_coerce isn't guaranteed to + * produce an output that meets the restrictions of these datatypes, + * such as being 1-dimensional.) */ Oid targetElemType; Oid sourceElemType; @@ -1699,7 +1685,7 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, return false; if ((targetElemType = get_element_type(targetTypeId)) != InvalidOid && - (sourceElemType = get_element_type(sourceTypeId)) != InvalidOid) + (sourceElemType = get_element_type(sourceTypeId)) != InvalidOid) { if (find_coercion_pathway(targetElemType, sourceElemType, ccontext, &elemfuncid)) diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index fdb4c4dcf25..ab9279abd30 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.184 2005/06/26 22:05:39 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.185 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -278,8 +278,8 @@ transformIndirection(ParseState *pstate, Node *basenode, List *indirection) /* * We have to split any field-selection operations apart from - * subscripting. Adjacent A_Indices nodes have to be treated as a - * single multidimensional subscript operation. + * subscripting. Adjacent A_Indices nodes have to be treated as a single + * multidimensional subscript operation. */ foreach(i, indirection) { @@ -295,7 +295,7 @@ transformIndirection(ParseState *pstate, Node *basenode, List *indirection) if (subscripts) result = (Node *) transformArraySubscripts(pstate, result, - exprType(result), + exprType(result), InvalidOid, -1, subscripts, @@ -365,10 +365,10 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) /* * Not known as a column of any range-table entry. * - * Consider the possibility that it's VALUE in a domain - * check expression. (We handle VALUE as a name, not - * a keyword, to avoid breaking a lot of applications - * that have used VALUE as a column name in the past.) + * Consider the possibility that it's VALUE in a domain check + * expression. (We handle VALUE as a name, not a keyword, + * to avoid breaking a lot of applications that have used + * VALUE as a column name in the past.) */ if (pstate->p_value_substitute != NULL && strcmp(name, "value") == 0) @@ -379,12 +379,12 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) /* * Try to find the name as a relation. Note that only - * relations already entered into the rangetable will - * be recognized. + * relations already entered into the rangetable will be + * recognized. * * This is a hack for backwards compatibility with - * PostQUEL-inspired syntax. The preferred form now - * is "rel.*". + * PostQUEL-inspired syntax. The preferred form now is + * "rel.*". */ if (refnameRangeTblEntry(pstate, NULL, name, &levels_up) != NULL) @@ -414,13 +414,13 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) if (node == NULL) { /* - * Not known as a column of any range-table entry, so - * try it as a function call. Here, we will create an + * Not known as a column of any range-table entry, so try + * it as a function call. Here, we will create an * implicit RTE for tables not already entered. */ node = transformWholeRowRef(pstate, NULL, name1); node = ParseFuncOrColumn(pstate, - list_make1(makeString(name2)), + list_make1(makeString(name2)), list_make1(node), false, false, true); } @@ -446,7 +446,7 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) /* Try it as a function call */ node = transformWholeRowRef(pstate, name1, name2); node = ParseFuncOrColumn(pstate, - list_make1(makeString(name3)), + list_make1(makeString(name3)), list_make1(node), false, false, true); } @@ -482,7 +482,7 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) /* Try it as a function call */ node = transformWholeRowRef(pstate, name2, name3); node = ParseFuncOrColumn(pstate, - list_make1(makeString(name4)), + list_make1(makeString(name4)), list_make1(node), false, false, true); } @@ -491,8 +491,8 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) default: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("improper qualified name (too many dotted names): %s", - NameListToString(cref->fields)))); + errmsg("improper qualified name (too many dotted names): %s", + NameListToString(cref->fields)))); node = NULL; /* keep compiler quiet */ break; } @@ -515,7 +515,7 @@ transformParamRef(ParseState *pstate, ParamRef *pref) toppstate = toppstate->parentParseState; /* Check parameter number is in range */ - if (paramno <= 0) /* probably can't happen? */ + if (paramno <= 0) /* probably can't happen? */ ereport(ERROR, (errcode(ERRCODE_UNDEFINED_PARAMETER), errmsg("there is no parameter $%d", paramno))); @@ -563,9 +563,9 @@ transformAExprOp(ParseState *pstate, A_Expr *a) Node *result; /* - * Special-case "foo = NULL" and "NULL = foo" for compatibility - * with standards-broken products (like Microsoft's). Turn these - * into IS NULL exprs. + * Special-case "foo = NULL" and "NULL = foo" for compatibility with + * standards-broken products (like Microsoft's). Turn these into IS NULL + * exprs. */ if (Transform_null_equals && list_length(a->name) == 1 && @@ -588,10 +588,9 @@ transformAExprOp(ParseState *pstate, A_Expr *a) ((SubLink *) rexpr)->subLinkType == EXPR_SUBLINK) { /* - * Convert "row op subselect" into a MULTIEXPR sublink. - * Formerly the grammar did this, but now that a row construct - * is allowed anywhere in expressions, it's easier to do it - * here. + * Convert "row op subselect" into a MULTIEXPR sublink. Formerly the + * grammar did this, but now that a row construct is allowed anywhere + * in expressions, it's easier to do it here. */ SubLink *s = (SubLink *) rexpr; @@ -738,8 +737,8 @@ static Node * transformAExprOf(ParseState *pstate, A_Expr *a) { /* - * Checking an expression for match to type. Will result in a - * boolean constant node. + * Checking an expression for match to type. Will result in a boolean + * constant node. */ ListCell *telem; A_Const *n; @@ -758,8 +757,8 @@ transformAExprOf(ParseState *pstate, A_Expr *a) } /* - * Expect two forms: equals or not equals. Flip the sense of the - * result for not equals. + * Expect two forms: equals or not equals. Flip the sense of the result + * for not equals. */ if (strcmp(strVal(linitial(a->name)), "!=") == 0) matched = (!matched); @@ -779,12 +778,11 @@ transformFuncCall(ParseState *pstate, FuncCall *fn) ListCell *args; /* - * Transform the list of arguments. We use a shallow list copy - * and then transform-in-place to avoid O(N^2) behavior from - * repeated lappend's. + * Transform the list of arguments. We use a shallow list copy and then + * transform-in-place to avoid O(N^2) behavior from repeated lappend's. * - * XXX: repeated lappend() would no longer result in O(n^2) - * behavior; worth reconsidering this design? + * XXX: repeated lappend() would no longer result in O(n^2) behavior; worth + * reconsidering this design? */ targs = list_copy(fn->args); foreach(args, targs) @@ -826,11 +824,11 @@ transformCaseExpr(ParseState *pstate, CaseExpr *c) if (arg) { /* - * If test expression is an untyped literal, force it to text. - * We have to do something now because we won't be able to do - * this coercion on the placeholder. This is not as flexible - * as what was done in 7.4 and before, but it's good enough to - * handle the sort of silly coding commonly seen. + * If test expression is an untyped literal, force it to text. We have + * to do something now because we won't be able to do this coercion on + * the placeholder. This is not as flexible as what was done in 7.4 + * and before, but it's good enough to handle the sort of silly coding + * commonly seen. */ if (exprType(arg) == UNKNOWNOID) arg = coerce_to_common_type(pstate, arg, TEXTOID, "CASE"); @@ -891,9 +889,8 @@ transformCaseExpr(ParseState *pstate, CaseExpr *c) /* * Note: default result is considered the most significant type in - * determining preferred type. This is how the code worked before, - * but it seems a little bogus to me - * --- tgl + * determining preferred type. This is how the code worked before, but it + * seems a little bogus to me --- tgl */ typeids = lcons_oid(exprType((Node *) newc->defresult), typeids); @@ -947,8 +944,8 @@ transformSubLink(ParseState *pstate, SubLink *sublink) if (sublink->subLinkType == EXISTS_SUBLINK) { /* - * EXISTS needs no lefthand or combining operator. These - * fields should be NIL already, but make sure. + * EXISTS needs no lefthand or combining operator. These fields + * should be NIL already, but make sure. */ sublink->lefthand = NIL; sublink->operName = NIL; @@ -961,8 +958,8 @@ transformSubLink(ParseState *pstate, SubLink *sublink) ListCell *tlist_item = list_head(qtree->targetList); /* - * Make sure the subselect delivers a single column (ignoring - * resjunk targets). + * Make sure the subselect delivers a single column (ignoring resjunk + * targets). */ if (tlist_item == NULL || ((TargetEntry *) lfirst(tlist_item))->resjunk) @@ -978,9 +975,8 @@ transformSubLink(ParseState *pstate, SubLink *sublink) } /* - * EXPR and ARRAY need no lefthand or combining - * operator. These fields should be NIL already, but make - * sure. + * EXPR and ARRAY need no lefthand or combining operator. These fields + * should be NIL already, but make sure. */ sublink->lefthand = NIL; sublink->operName = NIL; @@ -1004,9 +1000,9 @@ transformSubLink(ParseState *pstate, SubLink *sublink) lfirst(l) = transformExpr(pstate, lfirst(l)); /* - * If the expression is "<> ALL" (with unqualified opname) - * then convert it to "NOT IN". This is a hack to improve - * efficiency of expressions output by pre-7.4 Postgres. + * If the expression is "<> ALL" (with unqualified opname) then + * convert it to "NOT IN". This is a hack to improve efficiency of + * expressions output by pre-7.4 Postgres. */ if (sublink->subLinkType == ALL_SUBLINK && list_length(op) == 1 && strcmp(opname, "<>") == 0) @@ -1035,10 +1031,10 @@ transformSubLink(ParseState *pstate, SubLink *sublink) /* * To build the list of combining operator OIDs, we must scan - * subquery's targetlist to find values that will be matched - * against lefthand values. We need to ignore resjunk - * targets, so doing the outer iteration over right_list is - * easier than doing it over left_list. + * subquery's targetlist to find values that will be matched against + * lefthand values. We need to ignore resjunk targets, so doing the + * outer iteration over right_list is easier than doing it over + * left_list. */ sublink->operOids = NIL; @@ -1061,9 +1057,8 @@ transformSubLink(ParseState *pstate, SubLink *sublink) ll_item = lnext(ll_item); /* - * It's OK to use oper() not compatible_oper() here, - * because make_subplan() will insert type coercion calls - * if needed. + * It's OK to use oper() not compatible_oper() here, because + * make_subplan() will insert type coercion calls if needed. */ optup = oper(op, exprType(lexpr), @@ -1074,9 +1069,9 @@ transformSubLink(ParseState *pstate, SubLink *sublink) if (opform->oprresult != BOOLOID) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("operator %s must return type boolean, not type %s", - opname, - format_type_be(opform->oprresult)), + errmsg("operator %s must return type boolean, not type %s", + opname, + format_type_be(opform->oprresult)), errhint("The operator of a quantified predicate subquery must return type boolean."))); if (get_func_retset(opform->oprcode)) @@ -1300,7 +1295,7 @@ transformBooleanTest(ParseState *pstate, BooleanTest *b) default: elog(ERROR, "unrecognized booltesttype: %d", (int) b->booltesttype); - clausename = NULL; /* keep compiler quiet */ + clausename = NULL; /* keep compiler quiet */ } b->arg = (Expr *) transformExpr(pstate, (Node *) b->arg); @@ -1385,10 +1380,10 @@ transformWholeRowRef(ParseState *pstate, char *schemaname, char *relname) default: /* - * RTE is a join or subselect. We represent this as a - * whole-row Var of RECORD type. (Note that in most cases the - * Var will be expanded to a RowExpr during planning, but that - * is not our concern here.) + * RTE is a join or subselect. We represent this as a whole-row + * Var of RECORD type. (Note that in most cases the Var will be + * expanded to a RowExpr during planning, but that is not our + * concern here.) */ result = (Node *) makeVar(vnum, InvalidAttrNumber, @@ -1469,7 +1464,7 @@ exprType(Node *expr) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("could not find array type for data type %s", - format_type_be(exprType((Node *) tent->expr))))); + format_type_be(exprType((Node *) tent->expr))))); } } else @@ -1482,10 +1477,9 @@ exprType(Node *expr) case T_SubPlan: { /* - * Although the parser does not ever deal with - * already-planned expression trees, we support SubPlan - * nodes in this routine for the convenience of - * ruleutils.c. + * Although the parser does not ever deal with already-planned + * expression trees, we support SubPlan nodes in this routine + * for the convenience of ruleutils.c. */ SubPlan *subplan = (SubPlan *) expr; @@ -1506,7 +1500,7 @@ exprType(Node *expr) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("could not find array type for data type %s", - format_type_be(exprType((Node *) tent->expr))))); + format_type_be(exprType((Node *) tent->expr))))); } } else @@ -1600,7 +1594,7 @@ exprTypmod(Node *expr) case BPCHAROID: if (!con->constisnull) { - int32 len = VARSIZE(DatumGetPointer(con->constvalue)) - VARHDRSZ; + int32 len = VARSIZE(DatumGetPointer(con->constvalue)) - VARHDRSZ; /* if multi-byte, take len and find # characters */ if (pg_database_encoding_max_length() > 1) @@ -1629,8 +1623,8 @@ exprTypmod(Node *expr) case T_CaseExpr: { /* - * If all the alternatives agree on type/typmod, return - * that typmod, else use -1 + * If all the alternatives agree on type/typmod, return that + * typmod, else use -1 */ CaseExpr *cexpr = (CaseExpr *) expr; Oid casetype = cexpr->casetype; @@ -1662,8 +1656,8 @@ exprTypmod(Node *expr) case T_CoalesceExpr: { /* - * If all the alternatives agree on type/typmod, return - * that typmod, else use -1 + * If all the alternatives agree on type/typmod, return that + * typmod, else use -1 */ CoalesceExpr *cexpr = (CoalesceExpr *) expr; Oid coalescetype = cexpr->coalescetype; @@ -1686,8 +1680,8 @@ exprTypmod(Node *expr) case T_MinMaxExpr: { /* - * If all the alternatives agree on type/typmod, return - * that typmod, else use -1 + * If all the alternatives agree on type/typmod, return that + * typmod, else use -1 */ MinMaxExpr *mexpr = (MinMaxExpr *) expr; Oid minmaxtype = mexpr->minmaxtype; @@ -1760,9 +1754,9 @@ exprIsLengthCoercion(Node *expr, int32 *coercedTypmod) return false; /* - * If it's not a two-argument or three-argument function with the - * second argument being an int4 constant, it can't have been created - * from a length coercion (it must be a type coercion, instead). + * If it's not a two-argument or three-argument function with the second + * argument being an int4 constant, it can't have been created from a + * length coercion (it must be a type coercion, instead). */ nargs = list_length(func->args); if (nargs < 2 || nargs > 3) @@ -1844,9 +1838,9 @@ make_row_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree) errmsg("unequal number of entries in row expression"))); /* - * XXX it's really wrong to generate a simple AND combination for < <= - * > >=. We probably need to invent a new runtime node type to handle - * those correctly. For the moment, though, keep on doing this ... + * XXX it's really wrong to generate a simple AND combination for < <= > + * >=. We probably need to invent a new runtime node type to handle those + * correctly. For the moment, though, keep on doing this ... */ oprname = strVal(llast(opname)); @@ -1862,8 +1856,8 @@ make_row_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("operator %s is not supported for row expressions", - oprname))); + errmsg("operator %s is not supported for row expressions", + oprname))); boolop = 0; /* keep compiler quiet */ } @@ -1957,7 +1951,7 @@ make_distinct_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree) if (((OpExpr *) result)->opresulttype != BOOLOID) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("IS DISTINCT FROM requires = operator to yield boolean"))); + errmsg("IS DISTINCT FROM requires = operator to yield boolean"))); /* * We rely on DistinctExpr and OpExpr being same struct diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index 88132bdbd58..a3a42326487 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.181 2005/06/22 15:19:43 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.182 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -74,10 +74,10 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, FuncDetailCode fdresult; /* - * Most of the rest of the parser just assumes that functions do not - * have more than FUNC_MAX_ARGS parameters. We have to test here to - * protect against array overruns, etc. Of course, this may not be a - * function, but the test doesn't hurt. + * Most of the rest of the parser just assumes that functions do not have + * more than FUNC_MAX_ARGS parameters. We have to test here to protect + * against array overruns, etc. Of course, this may not be a function, + * but the test doesn't hurt. */ if (list_length(fargs) > FUNC_MAX_ARGS) ereport(ERROR, @@ -88,11 +88,11 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, /* * Extract arg type info in preparation for function lookup. * - * If any arguments are Param markers of type VOID, we discard them - * from the parameter list. This is a hack to allow the JDBC driver - * to not have to distinguish "input" and "output" parameter symbols - * while parsing function-call constructs. We can't use foreach() - * because we may modify the list ... + * If any arguments are Param markers of type VOID, we discard them from the + * parameter list. This is a hack to allow the JDBC driver to not have to + * distinguish "input" and "output" parameter symbols while parsing + * function-call constructs. We can't use foreach() because we may modify + * the list ... */ nargs = 0; for (l = list_head(fargs); l != NULL; l = nextl) @@ -102,7 +102,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, nextl = lnext(l); - if (argtype == VOIDOID && IsA(arg, Param) && !is_column) + if (argtype == VOIDOID && IsA(arg, Param) &&!is_column) { fargs = list_delete_ptr(fargs, arg); continue; @@ -119,9 +119,9 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, /* * Check for column projection: if function has one argument, and that - * argument is of complex type, and function name is not qualified, - * then the "function call" could be a projection. We also check that - * there wasn't any aggregate decoration. + * argument is of complex type, and function name is not qualified, then + * the "function call" could be a projection. We also check that there + * wasn't any aggregate decoration. */ if (nargs == 1 && !agg_star && !agg_distinct && list_length(funcname) == 1) { @@ -136,8 +136,8 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, return retval; /* - * If ParseComplexProjection doesn't recognize it as a - * projection, just press on. + * If ParseComplexProjection doesn't recognize it as a projection, + * just press on. */ } } @@ -147,8 +147,8 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, * func_get_detail looks up the function in the catalogs, does * disambiguation for polymorphic functions, handles inheritance, and * returns the funcid and type and set or singleton status of the - * function's return value. it also returns the true argument types - * to the function. + * function's return value. it also returns the true argument types to + * the function. */ fdresult = func_get_detail(funcname, fargs, nargs, actual_arg_types, &funcid, &rettype, &retset, @@ -156,8 +156,8 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, if (fdresult == FUNCDETAIL_COERCION) { /* - * We can do it as a trivial coercion. coerce_type can handle - * these cases, so why duplicate code... + * We can do it as a trivial coercion. coerce_type can handle these + * cases, so why duplicate code... */ return coerce_type(pstate, linitial(fargs), actual_arg_types[0], rettype, -1, @@ -166,28 +166,28 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, else if (fdresult == FUNCDETAIL_NORMAL) { /* - * Normal function found; was there anything indicating it must be - * an aggregate? + * Normal function found; was there anything indicating it must be an + * aggregate? */ if (agg_star) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("%s(*) specified, but %s is not an aggregate function", - NameListToString(funcname), - NameListToString(funcname)))); + errmsg("%s(*) specified, but %s is not an aggregate function", + NameListToString(funcname), + NameListToString(funcname)))); if (agg_distinct) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("DISTINCT specified, but %s is not an aggregate function", - NameListToString(funcname)))); + errmsg("DISTINCT specified, but %s is not an aggregate function", + NameListToString(funcname)))); } else if (fdresult != FUNCDETAIL_AGGREGATE) { /* * Oops. Time to die. * - * If we are dealing with the attribute notation rel.function, give - * an error message that is appropriate for that case. + * If we are dealing with the attribute notation rel.function, give an + * error message that is appropriate for that case. */ if (is_column) { @@ -205,22 +205,22 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, errmsg("function %s is not unique", func_signature_string(funcname, nargs, actual_arg_types)), - errhint("Could not choose a best candidate function. " - "You may need to add explicit type casts."))); + errhint("Could not choose a best candidate function. " + "You may need to add explicit type casts."))); else ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("function %s does not exist", func_signature_string(funcname, nargs, actual_arg_types)), - errhint("No function matches the given name and argument types. " - "You may need to add explicit type casts."))); + errhint("No function matches the given name and argument types. " + "You may need to add explicit type casts."))); } /* - * enforce consistency with ANYARRAY and ANYELEMENT argument and - * return types, possibly adjusting return type or declared_arg_types - * (which will be used as the cast destination by make_fn_arguments) + * enforce consistency with ANYARRAY and ANYELEMENT argument and return + * types, possibly adjusting return type or declared_arg_types (which will + * be used as the cast destination by make_fn_arguments) */ rettype = enforce_generic_type_consistency(actual_arg_types, declared_arg_types, @@ -394,15 +394,14 @@ func_select_candidate(int nargs, FUNC_MAX_ARGS))); /* - * If any input types are domains, reduce them to their base types. - * This ensures that we will consider functions on the base type to be - * "exact matches" in the exact-match heuristic; it also makes it - * possible to do something useful with the type-category heuristics. - * Note that this makes it difficult, but not impossible, to use - * functions declared to take a domain as an input datatype. Such a - * function will be selected over the base-type function only if it is - * an exact match at all argument positions, and so was already chosen - * by our caller. + * If any input types are domains, reduce them to their base types. This + * ensures that we will consider functions on the base type to be "exact + * matches" in the exact-match heuristic; it also makes it possible to do + * something useful with the type-category heuristics. Note that this + * makes it difficult, but not impossible, to use functions declared to + * take a domain as an input datatype. Such a function will be selected + * over the base-type function only if it is an exact match at all + * argument positions, and so was already chosen by our caller. */ for (i = 0; i < nargs; i++) input_base_typeids[i] = getBaseType(input_typeids[i]); @@ -452,12 +451,11 @@ func_select_candidate(int nargs, return candidates; /* - * Still too many candidates? Now look for candidates which have - * either exact matches or preferred types at the args that will - * require coercion. (Restriction added in 7.4: preferred type must be - * of same category as input type; give no preference to - * cross-category conversions to preferred types.) Keep all - * candidates if none match. + * Still too many candidates? Now look for candidates which have either + * exact matches or preferred types at the args that will require + * coercion. (Restriction added in 7.4: preferred type must be of same + * category as input type; give no preference to cross-category + * conversions to preferred types.) Keep all candidates if none match. */ for (i = 0; i < nargs; i++) /* avoid multiple lookups */ slot_category[i] = TypeCategory(input_base_typeids[i]); @@ -502,30 +500,28 @@ func_select_candidate(int nargs, return candidates; /* - * Still too many candidates? Try assigning types for the unknown - * columns. + * Still too many candidates? Try assigning types for the unknown columns. * - * NOTE: for a binary operator with one unknown and one non-unknown - * input, we already tried the heuristic of looking for a candidate - * with the known input type on both sides (see binary_oper_exact()). - * That's essentially a special case of the general algorithm we try - * next. + * NOTE: for a binary operator with one unknown and one non-unknown input, we + * already tried the heuristic of looking for a candidate with the known + * input type on both sides (see binary_oper_exact()). That's essentially + * a special case of the general algorithm we try next. * - * We do this by examining each unknown argument position to see if we - * can determine a "type category" for it. If any candidate has an - * input datatype of STRING category, use STRING category (this bias - * towards STRING is appropriate since unknown-type literals look like - * strings). Otherwise, if all the candidates agree on the type - * category of this argument position, use that category. Otherwise, - * fail because we cannot determine a category. + * We do this by examining each unknown argument position to see if we can + * determine a "type category" for it. If any candidate has an input + * datatype of STRING category, use STRING category (this bias towards + * STRING is appropriate since unknown-type literals look like strings). + * Otherwise, if all the candidates agree on the type category of this + * argument position, use that category. Otherwise, fail because we + * cannot determine a category. * - * If we are able to determine a type category, also notice whether any - * of the candidates takes a preferred datatype within the category. + * If we are able to determine a type category, also notice whether any of + * the candidates takes a preferred datatype within the category. * - * Having completed this examination, remove candidates that accept the - * wrong category at any unknown position. Also, if at least one - * candidate accepted a preferred type at a position, remove - * candidates that accept non-preferred types. + * Having completed this examination, remove candidates that accept the wrong + * category at any unknown position. Also, if at least one candidate + * accepted a preferred type at a position, remove candidates that accept + * non-preferred types. * * If we are down to one candidate at the end, we win. */ @@ -573,8 +569,7 @@ func_select_candidate(int nargs, else { /* - * Remember conflict, but keep going (might find - * STRING) + * Remember conflict, but keep going (might find STRING) */ have_conflict = true; } @@ -687,8 +682,8 @@ func_get_detail(List *funcname, raw_candidates = FuncnameGetCandidates(funcname, nargs); /* - * Quickly check if there is an exact match to the input datatypes - * (there can be only one) + * Quickly check if there is an exact match to the input datatypes (there + * can be only one) */ for (best_candidate = raw_candidates; best_candidate != NULL; @@ -703,32 +698,30 @@ func_get_detail(List *funcname, /* * If we didn't find an exact match, next consider the possibility * that this is really a type-coercion request: a single-argument - * function call where the function name is a type name. If so, - * and if we can do the coercion trivially (no run-time function - * call needed), then go ahead and treat the "function call" as a - * coercion. This interpretation needs to be given higher - * priority than interpretations involving a type coercion - * followed by a function call, otherwise we can produce - * surprising results. For example, we want "text(varchar)" to be - * interpreted as a trivial coercion, not as "text(name(varchar))" - * which the code below this point is entirely capable of - * selecting. + * function call where the function name is a type name. If so, and + * if we can do the coercion trivially (no run-time function call + * needed), then go ahead and treat the "function call" as a coercion. + * This interpretation needs to be given higher priority than + * interpretations involving a type coercion followed by a function + * call, otherwise we can produce surprising results. For example, we + * want "text(varchar)" to be interpreted as a trivial coercion, not + * as "text(name(varchar))" which the code below this point is + * entirely capable of selecting. * - * "Trivial" coercions are ones that involve binary-compatible types - * and ones that are coercing a previously-unknown-type literal - * constant to a specific type. + * "Trivial" coercions are ones that involve binary-compatible types and + * ones that are coercing a previously-unknown-type literal constant + * to a specific type. * - * The reason we can restrict our check to binary-compatible - * coercions here is that we expect non-binary-compatible - * coercions to have an implementation function named after the - * target type. That function will be found by normal lookup if - * appropriate. + * The reason we can restrict our check to binary-compatible coercions + * here is that we expect non-binary-compatible coercions to have an + * implementation function named after the target type. That function + * will be found by normal lookup if appropriate. * - * NB: it's important that this code stays in sync with what - * coerce_type can do, because the caller will try to apply - * coerce_type if we return FUNCDETAIL_COERCION. If we return - * that result for something coerce_type can't handle, we'll cause - * infinite recursion between this module and coerce_type! + * NB: it's important that this code stays in sync with what coerce_type + * can do, because the caller will try to apply coerce_type if we + * return FUNCDETAIL_COERCION. If we return that result for something + * coerce_type can't handle, we'll cause infinite recursion between + * this module and coerce_type! */ if (nargs == 1 && fargs != NIL) { @@ -761,8 +754,7 @@ func_get_detail(List *funcname, } /* - * didn't find an exact match, so now try to match up - * candidates... + * didn't find an exact match, so now try to match up candidates... */ if (raw_candidates != NULL) { @@ -788,8 +780,8 @@ func_get_detail(List *funcname, current_candidates); /* - * If we were able to choose a best candidate, we're - * done. Otherwise, ambiguous function call. + * If we were able to choose a best candidate, we're done. + * Otherwise, ambiguous function call. */ if (!best_candidate) return FUNCDETAIL_MULTIPLE; @@ -853,11 +845,10 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId) inhrel = heap_open(InheritsRelationId, AccessShareLock); /* - * Use queue to do a breadth-first traversal of the inheritance graph - * from the relid supplied up to the root. Notice that we append to - * the queue inside the loop --- this is okay because the foreach() - * macro doesn't advance queue_item until the next loop iteration - * begins. + * Use queue to do a breadth-first traversal of the inheritance graph from + * the relid supplied up to the root. Notice that we append to the queue + * inside the loop --- this is okay because the foreach() macro doesn't + * advance queue_item until the next loop iteration begins. */ foreach(queue_item, queue) { @@ -872,9 +863,9 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId) /* * Okay, this is a not-yet-seen relid. Add it to the list of - * already-visited OIDs, then find all the types this relid - * inherits from and add them to the queue. The one exception is - * we don't add the original relation to 'visited'. + * already-visited OIDs, then find all the types this relid inherits + * from and add them to the queue. The one exception is we don't add + * the original relation to 'visited'. */ if (queue_item != list_head(queue)) visited = lappend_oid(visited, this_relid); @@ -889,7 +880,7 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId) while ((inhtup = heap_getnext(inhscan, ForwardScanDirection)) != NULL) { Form_pg_inherits inh = (Form_pg_inherits) GETSTRUCT(inhtup); - Oid inhparent = inh->inhparent; + Oid inhparent = inh->inhparent; /* If this is the target superclass, we're done */ if (get_rel_type_id(inhparent) == superclassTypeId) @@ -968,14 +959,14 @@ ParseComplexProjection(ParseState *pstate, char *funcname, Node *first_arg) int i; /* - * Special case for whole-row Vars so that we can resolve (foo.*).bar - * even when foo is a reference to a subselect, join, or RECORD - * function. A bonus is that we avoid generating an unnecessary - * FieldSelect; our result can omit the whole-row Var and just be a - * Var for the selected field. + * Special case for whole-row Vars so that we can resolve (foo.*).bar even + * when foo is a reference to a subselect, join, or RECORD function. A + * bonus is that we avoid generating an unnecessary FieldSelect; our + * result can omit the whole-row Var and just be a Var for the selected + * field. * - * This case could be handled by expandRecordVariable, but it's - * more efficient to do it this way when possible. + * This case could be handled by expandRecordVariable, but it's more + * efficient to do it this way when possible. */ if (IsA(first_arg, Var) && ((Var *) first_arg)->varattno == InvalidAttrNumber) @@ -992,9 +983,9 @@ ParseComplexProjection(ParseState *pstate, char *funcname, Node *first_arg) /* * Else do it the hard way with get_expr_result_type(). * - * If it's a Var of type RECORD, we have to work even harder: we have - * to find what the Var refers to, and pass that to get_expr_result_type. - * That task is handled by expandRecordVariable(). + * If it's a Var of type RECORD, we have to work even harder: we have to find + * what the Var refers to, and pass that to get_expr_result_type. That + * task is handled by expandRecordVariable(). */ if (IsA(first_arg, Var) && ((Var *) first_arg)->vartype == RECORDOID) @@ -1057,8 +1048,8 @@ unknown_attribute(ParseState *pstate, Node *relref, char *attname) else if (relTypeId == RECORDOID) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("could not identify column \"%s\" in record data type", - attname))); + errmsg("could not identify column \"%s\" in record data type", + attname))); else ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), @@ -1161,7 +1152,7 @@ find_aggregate_func(List *aggname, Oid basetype, bool noError) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("function %s(%s) is not an aggregate", - NameListToString(aggname), format_type_be(basetype)))); + NameListToString(aggname), format_type_be(basetype)))); } ReleaseSysCache(ftup); @@ -1198,7 +1189,7 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("function %s does not exist", - func_signature_string(funcname, nargs, argtypes)))); + func_signature_string(funcname, nargs, argtypes)))); return InvalidOid; } diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c index 20999f81ffe..f0900ec99cf 100644 --- a/src/backend/parser/parse_node.c +++ b/src/backend/parser/parse_node.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_node.c,v 1.89 2005/05/30 01:20:49 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_node.c,v 1.90 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -92,8 +92,8 @@ transformArrayType(Oid arrayType) if (elementType == InvalidOid) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("cannot subscript type %s because it is not an array", - format_type_be(arrayType)))); + errmsg("cannot subscript type %s because it is not an array", + format_type_be(arrayType)))); ReleaseSysCache(type_tuple_array); @@ -145,11 +145,11 @@ transformArraySubscripts(ParseState *pstate, /* * A list containing only single subscripts refers to a single array - * element. If any of the items are double subscripts (lower:upper), - * then the subscript expression means an array slice operation. In - * this case, we supply a default lower bound of 1 for any items that - * contain only a single subscript. We have to prescan the - * indirection list to see if there are any double subscripts. + * element. If any of the items are double subscripts (lower:upper), then + * the subscript expression means an array slice operation. In this case, + * we supply a default lower bound of 1 for any items that contain only a + * single subscript. We have to prescan the indirection list to see if + * there are any double subscripts. */ foreach(idx, indirection) { @@ -163,9 +163,9 @@ transformArraySubscripts(ParseState *pstate, } /* - * The type represented by the subscript expression is the element - * type if we are fetching a single element, but it is the same as the - * array type if we are fetching a slice or storing. + * The type represented by the subscript expression is the element type if + * we are fetching a single element, but it is the same as the array type + * if we are fetching a slice or storing. */ if (isSlice || assignFrom != NULL) resultType = arrayType; @@ -188,14 +188,14 @@ transformArraySubscripts(ParseState *pstate, subexpr = transformExpr(pstate, ai->lidx); /* If it's not int4 already, try to coerce */ subexpr = coerce_to_target_type(pstate, - subexpr, exprType(subexpr), + subexpr, exprType(subexpr), INT4OID, -1, COERCION_ASSIGNMENT, COERCE_IMPLICIT_CAST); if (subexpr == NULL) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("array subscript must have type integer"))); + errmsg("array subscript must have type integer"))); } else { @@ -224,8 +224,7 @@ transformArraySubscripts(ParseState *pstate, /* * If doing an array store, coerce the source value to the right type. - * (This should agree with the coercion done by - * updateTargetListEntry.) + * (This should agree with the coercion done by updateTargetListEntry.) */ if (assignFrom != NULL) { @@ -244,7 +243,7 @@ transformArraySubscripts(ParseState *pstate, " but expression is of type %s", format_type_be(typeneeded), format_type_be(typesource)), - errhint("You will need to rewrite or cast the expression."))); + errhint("You will need to rewrite or cast the expression."))); } /* @@ -308,7 +307,7 @@ make_const(Value *value) * It might actually fit in int32. Probably only INT_MIN can * occur, but we'll code the test generally just to be sure. */ - int32 val32 = (int32) val64; + int32 val32 = (int32) val64; if (val64 == (int64) val32) { @@ -324,7 +323,7 @@ make_const(Value *value) typeid = INT8OID; typelen = sizeof(int64); - typebyval = false; /* XXX might change someday */ + typebyval = false; /* XXX might change someday */ } } else @@ -341,6 +340,7 @@ make_const(Value *value) break; case T_String: + /* * We assume here that UNKNOWN's internal representation is the * same as CSTRING @@ -348,7 +348,7 @@ make_const(Value *value) val = CStringGetDatum(strVal(value)); typeid = UNKNOWNOID; /* will be coerced later */ - typelen = -2; /* cstring-style varwidth type */ + typelen = -2; /* cstring-style varwidth type */ typebyval = false; break; diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c index 4b615542c81..764f729529f 100644 --- a/src/backend/parser/parse_oper.c +++ b/src/backend/parser/parse_oper.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.81 2004/12/31 22:00:27 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.82 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -142,16 +142,16 @@ equality_oper(Oid argtype, bool noError) /* * Look for an "=" operator for the datatype. We require it to be an - * exact or binary-compatible match, since most callers are not - * prepared to cope with adding any run-time type coercion steps. + * exact or binary-compatible match, since most callers are not prepared + * to cope with adding any run-time type coercion steps. */ typentry = lookup_type_cache(argtype, TYPECACHE_EQ_OPR); oproid = typentry->eq_opr; /* - * If the datatype is an array, then we can use array_eq ... but only - * if there is a suitable equality operator for the element type. - * (This check is not in the raw typcache.c code ... should it be?) + * If the datatype is an array, then we can use array_eq ... but only if + * there is a suitable equality operator for the element type. (This check + * is not in the raw typcache.c code ... should it be?) */ if (oproid == ARRAY_EQ_OP) { @@ -182,8 +182,8 @@ equality_oper(Oid argtype, bool noError) if (!noError) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify an equality operator for type %s", - format_type_be(argtype)))); + errmsg("could not identify an equality operator for type %s", + format_type_be(argtype)))); return NULL; } @@ -200,22 +200,22 @@ ordering_oper(Oid argtype, bool noError) Operator optup; /* - * Look for a "<" operator for the datatype. We require it to be an - * exact or binary-compatible match, since most callers are not - * prepared to cope with adding any run-time type coercion steps. + * Look for a "<" operator for the datatype. We require it to be an exact + * or binary-compatible match, since most callers are not prepared to cope + * with adding any run-time type coercion steps. * * Note: the search algorithm used by typcache.c ensures that if a "<" * operator is returned, it will be consistent with the "=" operator - * returned by equality_oper. This is critical for sorting and - * grouping purposes. + * returned by equality_oper. This is critical for sorting and grouping + * purposes. */ typentry = lookup_type_cache(argtype, TYPECACHE_LT_OPR); oproid = typentry->lt_opr; /* - * If the datatype is an array, then we can use array_lt ... but only - * if there is a suitable less-than operator for the element type. - * (This check is not in the raw typcache.c code ... should it be?) + * If the datatype is an array, then we can use array_lt ... but only if + * there is a suitable less-than operator for the element type. (This + * check is not in the raw typcache.c code ... should it be?) */ if (oproid == ARRAY_LT_OP) { @@ -246,9 +246,9 @@ ordering_oper(Oid argtype, bool noError) if (!noError) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify an ordering operator for type %s", - format_type_be(argtype)), - errhint("Use an explicit ordering operator or modify the query."))); + errmsg("could not identify an ordering operator for type %s", + format_type_be(argtype)), + errhint("Use an explicit ordering operator or modify the query."))); return NULL; } @@ -265,22 +265,22 @@ reverse_ordering_oper(Oid argtype, bool noError) Operator optup; /* - * Look for a ">" operator for the datatype. We require it to be an - * exact or binary-compatible match, since most callers are not - * prepared to cope with adding any run-time type coercion steps. + * Look for a ">" operator for the datatype. We require it to be an exact + * or binary-compatible match, since most callers are not prepared to cope + * with adding any run-time type coercion steps. * * Note: the search algorithm used by typcache.c ensures that if a ">" * operator is returned, it will be consistent with the "=" operator - * returned by equality_oper. This is critical for sorting and - * grouping purposes. + * returned by equality_oper. This is critical for sorting and grouping + * purposes. */ typentry = lookup_type_cache(argtype, TYPECACHE_GT_OPR); oproid = typentry->gt_opr; /* - * If the datatype is an array, then we can use array_gt ... but only - * if there is a suitable greater-than operator for the element type. - * (This check is not in the raw typcache.c code ... should it be?) + * If the datatype is an array, then we can use array_gt ... but only if + * there is a suitable greater-than operator for the element type. (This + * check is not in the raw typcache.c code ... should it be?) */ if (oproid == ARRAY_GT_OP) { @@ -311,9 +311,9 @@ reverse_ordering_oper(Oid argtype, bool noError) if (!noError) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify an ordering operator for type %s", - format_type_be(argtype)), - errhint("Use an explicit ordering operator or modify the query."))); + errmsg("could not identify an ordering operator for type %s", + format_type_be(argtype)), + errhint("Use an explicit ordering operator or modify the query."))); return NULL; } @@ -528,8 +528,8 @@ oper(List *opname, Oid ltypeId, Oid rtypeId, bool noError) */ /* - * Unspecified type for one of the arguments? then use the - * other (XXX this is probably dead code?) + * Unspecified type for one of the arguments? then use the other + * (XXX this is probably dead code?) */ if (rtypeId == InvalidOid) rtypeId = ltypeId; @@ -654,9 +654,8 @@ right_oper(List *op, Oid arg, bool noError) if (!OidIsValid(operOid)) { /* - * We must run oper_select_candidate even if only one - * candidate, otherwise we may falsely return a - * non-type-compatible operator. + * We must run oper_select_candidate even if only one candidate, + * otherwise we may falsely return a non-type-compatible operator. */ fdresult = oper_select_candidate(1, &arg, clist, &operOid); } @@ -703,9 +702,9 @@ left_oper(List *op, Oid arg, bool noError) * First, quickly check to see if there is an exactly matching * operator (there can be only one such entry in the list). * - * The returned list has args in the form (0, oprright). Move the - * useful data into args[0] to keep oper_select_candidate simple. - * XXX we are assuming here that we may scribble on the list! + * The returned list has args in the form (0, oprright). Move the useful + * data into args[0] to keep oper_select_candidate simple. XXX we are + * assuming here that we may scribble on the list! */ FuncCandidateList clisti; @@ -722,9 +721,8 @@ left_oper(List *op, Oid arg, bool noError) if (!OidIsValid(operOid)) { /* - * We must run oper_select_candidate even if only one - * candidate, otherwise we may falsely return a - * non-type-compatible operator. + * We must run oper_select_candidate even if only one candidate, + * otherwise we may falsely return a non-type-compatible operator. */ fdresult = oper_select_candidate(1, &arg, clist, &operOid); } @@ -784,8 +782,8 @@ op_error(List *op, char oprkind, Oid arg1, Oid arg2, FuncDetailCode fdresult) (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("operator does not exist: %s", op_signature_string(op, oprkind, arg1, arg2)), - errhint("No operator matches the given name and argument type(s). " - "You may need to add explicit type casts."))); + errhint("No operator matches the given name and argument type(s). " + "You may need to add explicit type casts."))); } /* @@ -862,9 +860,9 @@ make_scalar_array_op(ParseState *pstate, List *opname, atypeId = exprType(rtree); /* - * The right-hand input of the operator will be the element type of - * the array. However, if we currently have just an untyped literal - * on the right, stay with that and hope we can resolve the operator. + * The right-hand input of the operator will be the element type of the + * array. However, if we currently have just an untyped literal on the + * right, stay with that and hope we can resolve the operator. */ if (atypeId == UNKNOWNOID) rtypeId = UNKNOWNOID; @@ -874,7 +872,7 @@ make_scalar_array_op(ParseState *pstate, List *opname, if (!OidIsValid(rtypeId)) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("op ANY/ALL (array) requires array on right side"))); + errmsg("op ANY/ALL (array) requires array on right side"))); } /* Now resolve the operator */ @@ -888,9 +886,9 @@ make_scalar_array_op(ParseState *pstate, List *opname, declared_arg_types[1] = opform->oprright; /* - * enforce consistency with ANYARRAY and ANYELEMENT argument and - * return types, possibly adjusting return type or declared_arg_types - * (which will be used as the cast destination by make_fn_arguments) + * enforce consistency with ANYARRAY and ANYELEMENT argument and return + * types, possibly adjusting return type or declared_arg_types (which will + * be used as the cast destination by make_fn_arguments) */ rettype = enforce_generic_type_consistency(actual_arg_types, declared_arg_types, @@ -903,11 +901,11 @@ make_scalar_array_op(ParseState *pstate, List *opname, if (rettype != BOOLOID) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("op ANY/ALL (array) requires operator to yield boolean"))); + errmsg("op ANY/ALL (array) requires operator to yield boolean"))); if (get_func_retset(opform->oprcode)) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("op ANY/ALL (array) requires operator not to return a set"))); + errmsg("op ANY/ALL (array) requires operator not to return a set"))); /* * Now switch back to the array type on the right, arranging for any @@ -985,9 +983,9 @@ make_op_expr(ParseState *pstate, Operator op, } /* - * enforce consistency with ANYARRAY and ANYELEMENT argument and - * return types, possibly adjusting return type or declared_arg_types - * (which will be used as the cast destination by make_fn_arguments) + * enforce consistency with ANYARRAY and ANYELEMENT argument and return + * types, possibly adjusting return type or declared_arg_types (which will + * be used as the cast destination by make_fn_arguments) */ rettype = enforce_generic_type_consistency(actual_arg_types, declared_arg_types, diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c index 196936bb094..61a0549ee0b 100644 --- a/src/backend/parser/parse_relation.c +++ b/src/backend/parser/parse_relation.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.114 2005/10/06 19:51:13 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.115 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,7 +35,7 @@ bool add_missing_from; static RangeTblEntry *scanNameSpaceForRefname(ParseState *pstate, - const char *refname); + const char *refname); static RangeTblEntry *scanNameSpaceForRelid(ParseState *pstate, Oid relid); static bool isLockedRel(ParseState *pstate, char *refname); static void expandRelation(Oid relid, Alias *eref, @@ -43,9 +43,9 @@ static void expandRelation(Oid relid, Alias *eref, bool include_dropped, List **colnames, List **colvars); static void expandTupleDesc(TupleDesc tupdesc, Alias *eref, - int rtindex, int sublevels_up, - bool include_dropped, - List **colnames, List **colvars); + int rtindex, int sublevels_up, + bool include_dropped, + List **colnames, List **colvars); static int specialAttNum(const char *attname); static void warnAutoRange(ParseState *pstate, RangeVar *relation); @@ -297,15 +297,14 @@ scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte, char *colname) * Scan the user column names (or aliases) for a match. Complain if * multiple matches. * - * Note: eref->colnames may include entries for dropped columns, but - * those will be empty strings that cannot match any legal SQL - * identifier, so we don't bother to test for that case here. + * Note: eref->colnames may include entries for dropped columns, but those + * will be empty strings that cannot match any legal SQL identifier, so we + * don't bother to test for that case here. * - * Should this somehow go wrong and we try to access a dropped column, - * we'll still catch it by virtue of the checks in - * get_rte_attribute_type(), which is called by make_var(). That - * routine has to do a cache lookup anyway, so the check there is - * cheap. + * Should this somehow go wrong and we try to access a dropped column, we'll + * still catch it by virtue of the checks in get_rte_attribute_type(), + * which is called by make_var(). That routine has to do a cache lookup + * anyway, so the check there is cheap. */ foreach(c, rte->eref->colnames) { @@ -385,8 +384,8 @@ colNameToVar(ParseState *pstate, char *colname, bool localonly) if (result) ereport(ERROR, (errcode(ERRCODE_AMBIGUOUS_COLUMN), - errmsg("column reference \"%s\" is ambiguous", - colname))); + errmsg("column reference \"%s\" is ambiguous", + colname))); result = newresult; } } @@ -502,7 +501,7 @@ buildRelationAliases(TupleDesc tupdesc, Alias *alias, Alias *eref) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), errmsg("table \"%s\" has %d columns available but %d columns specified", - eref->aliasname, maxattrs - numdropped, numaliases))); + eref->aliasname, maxattrs - numdropped, numaliases))); } /* @@ -531,8 +530,8 @@ buildScalarFunctionAlias(Node *funcexpr, char *funcname, if (list_length(alias->colnames) != 1) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), - errmsg("too many column aliases specified for function %s", - funcname))); + errmsg("too many column aliases specified for function %s", + funcname))); eref->colnames = copyObject(alias->colnames); return; } @@ -583,26 +582,26 @@ addRangeTableEntry(ParseState *pstate, rte->alias = alias; /* - * Get the rel's OID. This access also ensures that we have an - * up-to-date relcache entry for the rel. Since this is typically the - * first access to a rel in a statement, be careful to get the right - * access level depending on whether we're doing SELECT FOR UPDATE/SHARE. + * Get the rel's OID. This access also ensures that we have an up-to-date + * relcache entry for the rel. Since this is typically the first access + * to a rel in a statement, be careful to get the right access level + * depending on whether we're doing SELECT FOR UPDATE/SHARE. */ lockmode = isLockedRel(pstate, refname) ? RowShareLock : AccessShareLock; rel = heap_openrv(relation, lockmode); rte->relid = RelationGetRelid(rel); /* - * Build the list of effective column names using user-supplied - * aliases and/or actual column names. + * Build the list of effective column names using user-supplied aliases + * and/or actual column names. */ rte->eref = makeAlias(refname, NIL); buildRelationAliases(rel->rd_att, alias, rte->eref); /* - * Drop the rel refcount, but keep the access lock till end of - * transaction so that the table can't be deleted or have its schema - * modified underneath us. + * Drop the rel refcount, but keep the access lock till end of transaction + * so that the table can't be deleted or have its schema modified + * underneath us. */ heap_close(rel, NoLock); @@ -623,8 +622,8 @@ addRangeTableEntry(ParseState *pstate, rte->checkAsUser = InvalidOid; /* not set-uid by default, either */ /* - * Add completed RTE to pstate's range table list, but not to join - * list nor namespace --- caller must do that if appropriate. + * Add completed RTE to pstate's range table list, but not to join list + * nor namespace --- caller must do that if appropriate. */ if (pstate != NULL) pstate->p_rtable = lappend(pstate->p_rtable, rte); @@ -653,8 +652,8 @@ addRangeTableEntryForRelation(ParseState *pstate, rte->relid = RelationGetRelid(rel); /* - * Build the list of effective column names using user-supplied - * aliases and/or actual column names. + * Build the list of effective column names using user-supplied aliases + * and/or actual column names. */ rte->eref = makeAlias(refname, NIL); buildRelationAliases(rel->rd_att, alias, rte->eref); @@ -676,8 +675,8 @@ addRangeTableEntryForRelation(ParseState *pstate, rte->checkAsUser = InvalidOid; /* not set-uid by default, either */ /* - * Add completed RTE to pstate's range table list, but not to join - * list nor namespace --- caller must do that if appropriate. + * Add completed RTE to pstate's range table list, but not to join list + * nor namespace --- caller must do that if appropriate. */ if (pstate != NULL) pstate->p_rtable = lappend(pstate->p_rtable, rte); @@ -754,8 +753,8 @@ addRangeTableEntryForSubquery(ParseState *pstate, rte->checkAsUser = InvalidOid; /* - * Add completed RTE to pstate's range table list, but not to join - * list nor namespace --- caller must do that if appropriate. + * Add completed RTE to pstate's range table list, but not to join list + * nor namespace --- caller must do that if appropriate. */ if (pstate != NULL) pstate->p_rtable = lappend(pstate->p_rtable, rte); @@ -801,8 +800,8 @@ addRangeTableEntryForFunction(ParseState *pstate, &tupdesc); /* - * A coldeflist is required if the function returns RECORD and hasn't - * got a predetermined record type, and is prohibited otherwise. + * A coldeflist is required if the function returns RECORD and hasn't got + * a predetermined record type, and is prohibited otherwise. */ if (coldeflist != NIL) { @@ -848,8 +847,8 @@ addRangeTableEntryForFunction(ParseState *pstate, else ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("function \"%s\" in FROM has unsupported return type %s", - funcname, format_type_be(funcrettype)))); + errmsg("function \"%s\" in FROM has unsupported return type %s", + funcname, format_type_be(funcrettype)))); /*---------- * Flags: @@ -868,8 +867,8 @@ addRangeTableEntryForFunction(ParseState *pstate, rte->checkAsUser = InvalidOid; /* - * Add completed RTE to pstate's range table list, but not to join - * list nor namespace --- caller must do that if appropriate. + * Add completed RTE to pstate's range table list, but not to join list + * nor namespace --- caller must do that if appropriate. */ if (pstate != NULL) pstate->p_rtable = lappend(pstate->p_rtable, rte); @@ -907,7 +906,7 @@ addRangeTableEntryForJoin(ParseState *pstate, /* fill in any unspecified alias columns */ if (numaliases < list_length(colnames)) eref->colnames = list_concat(eref->colnames, - list_copy_tail(colnames, numaliases)); + list_copy_tail(colnames, numaliases)); rte->eref = eref; @@ -927,8 +926,8 @@ addRangeTableEntryForJoin(ParseState *pstate, rte->checkAsUser = InvalidOid; /* - * Add completed RTE to pstate's range table list, but not to join - * list nor namespace --- caller must do that if appropriate. + * Add completed RTE to pstate's range table list, but not to join list + * nor namespace --- caller must do that if appropriate. */ if (pstate != NULL) pstate->p_rtable = lappend(pstate->p_rtable, rte); @@ -983,7 +982,7 @@ addRTEtoQuery(ParseState *pstate, RangeTblEntry *rte, { if (addToJoinList) { - int rtindex = RTERangeTablePosn(pstate, rte, NULL); + int rtindex = RTERangeTablePosn(pstate, rte, NULL); RangeTblRef *rtr = makeNode(RangeTblRef); rtr->rtindex = rtindex; @@ -1111,7 +1110,7 @@ expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, /* Base data type, i.e. scalar */ if (colnames) *colnames = lappend(*colnames, - linitial(rte->eref->colnames)); + linitial(rte->eref->colnames)); if (colvars) { @@ -1184,11 +1183,11 @@ expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, /* * During ordinary parsing, there will never be any - * deleted columns in the join; but we have to check - * since this routine is also used by the rewriter, - * and joins found in stored rules might have join - * columns for since-deleted columns. This will be - * signaled by a NULL Const in the alias-vars list. + * deleted columns in the join; but we have to check since + * this routine is also used by the rewriter, and joins + * found in stored rules might have join columns for + * since-deleted columns. This will be signaled by a NULL + * Const in the alias-vars list. */ if (IsA(avar, Const)) { @@ -1274,8 +1273,8 @@ expandTupleDesc(TupleDesc tupdesc, Alias *eref, if (colvars) { /* - * can't use atttypid here, but it doesn't really - * matter what type the Const claims to be. + * can't use atttypid here, but it doesn't really matter + * what type the Const claims to be. */ *colvars = lappend(*colvars, makeNullConst(INT4OID)); } @@ -1342,8 +1341,7 @@ expandRelAttrs(ParseState *pstate, RangeTblEntry *rte, te_list = lappend(te_list, te); } - Assert(name == NULL && var == NULL); /* lists not the same - * length? */ + Assert(name == NULL && var == NULL); /* lists not the same length? */ return te_list; } @@ -1382,8 +1380,7 @@ get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum) return get_relid_attribute_name(rte->relid, attnum); /* - * Otherwise use the column name from eref. There should always be - * one. + * Otherwise use the column name from eref. There should always be one. */ if (attnum > 0 && attnum <= list_length(rte->eref->colnames)) return strVal(list_nth(rte->eref->colnames, attnum - 1)); @@ -1420,15 +1417,15 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum, att_tup = (Form_pg_attribute) GETSTRUCT(tp); /* - * If dropped column, pretend it ain't there. See notes - * in scanRTEForColumn. + * If dropped column, pretend it ain't there. See notes in + * scanRTEForColumn. */ if (att_tup->attisdropped) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("column \"%s\" of relation \"%s\" does not exist", - NameStr(att_tup->attname), - get_rel_name(rte->relid)))); + errmsg("column \"%s\" of relation \"%s\" does not exist", + NameStr(att_tup->attname), + get_rel_name(rte->relid)))); *vartype = att_tup->atttypid; *vartypmod = att_tup->atttypmod; ReleaseSysCache(tp); @@ -1468,15 +1465,15 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum, if (attnum < 1 || attnum > tupdesc->natts) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("column %d of relation \"%s\" does not exist", - attnum, - rte->eref->aliasname))); + errmsg("column %d of relation \"%s\" does not exist", + attnum, + rte->eref->aliasname))); att_tup = tupdesc->attrs[attnum - 1]; /* - * If dropped column, pretend it ain't there. See - * notes in scanRTEForColumn. + * If dropped column, pretend it ain't there. See notes + * in scanRTEForColumn. */ if (att_tup->attisdropped) ereport(ERROR, @@ -1510,8 +1507,7 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum, case RTE_JOIN: { /* - * Join RTE --- get type info from join RTE's alias - * variable + * Join RTE --- get type info from join RTE's alias variable */ Node *aliasvar; @@ -1540,8 +1536,7 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum) case RTE_RELATION: { /* - * Plain relation RTE --- get the attribute's catalog - * entry + * Plain relation RTE --- get the attribute's catalog entry */ HeapTuple tp; Form_pg_attribute att_tup; @@ -1565,12 +1560,11 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum) case RTE_JOIN: { /* - * A join RTE would not have dropped columns when - * constructed, but one in a stored rule might contain - * columns that were dropped from the underlying tables, - * if said columns are nowhere explicitly referenced in - * the rule. This will be signaled to us by a NULL Const - * in the joinaliasvars list. + * A join RTE would not have dropped columns when constructed, + * but one in a stored rule might contain columns that were + * dropped from the underlying tables, if said columns are + * nowhere explicitly referenced in the rule. This will be + * signaled to us by a NULL Const in the joinaliasvars list. */ Var *aliasvar; @@ -1766,8 +1760,8 @@ warnAutoRange(ParseState *pstate, RangeVar *relation) if (pstate->parentParseState != NULL) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_TABLE), - errmsg("missing FROM-clause entry in subquery for table \"%s\"", - relation->relname))); + errmsg("missing FROM-clause entry in subquery for table \"%s\"", + relation->relname))); else ereport(ERROR, (errcode(ERRCODE_UNDEFINED_TABLE), @@ -1785,7 +1779,7 @@ warnAutoRange(ParseState *pstate, RangeVar *relation) else ereport(NOTICE, (errcode(ERRCODE_UNDEFINED_TABLE), - errmsg("adding missing FROM-clause entry for table \"%s\"", - relation->relname))); + errmsg("adding missing FROM-clause entry for table \"%s\"", + relation->relname))); } } diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index 00185a05e12..88c29ebf1e4 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.137 2005/06/26 22:05:40 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.138 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,7 +32,7 @@ static void markTargetListOrigin(ParseState *pstate, TargetEntry *tle, - Var *var, int levelsup); + Var *var, int levelsup); static Node *transformAssignmentIndirection(ParseState *pstate, Node *basenode, const char *targetName, @@ -73,8 +73,8 @@ transformTargetEntry(ParseState *pstate, if (colname == NULL && !resjunk) { /* - * Generate a suitable column name for a column without any - * explicit 'AS ColumnName' clause. + * Generate a suitable column name for a column without any explicit + * 'AS ColumnName' clause. */ colname = FigureColname(node); } @@ -105,8 +105,8 @@ transformTargetList(ParseState *pstate, List *targetlist) /* * Check for "something.*". Depending on the complexity of the - * "something", the star could appear as the last name in - * ColumnRef, or as the last indirection item in A_Indirection. + * "something", the star could appear as the last name in ColumnRef, + * or as the last indirection item in A_Indirection. */ if (IsA(res->val, ColumnRef)) { @@ -130,7 +130,7 @@ transformTargetList(ParseState *pstate, List *targetlist) { /* It is something.*, expand into multiple items */ p_target = list_concat(p_target, - ExpandIndirectionStar(pstate, ind)); + ExpandIndirectionStar(pstate, ind)); continue; } } @@ -271,11 +271,11 @@ updateTargetListEntry(ParseState *pstate, /* * If the expression is a DEFAULT placeholder, insert the attribute's - * type/typmod into it so that exprType will report the right things. - * (We expect that the eventually substituted default expression will - * in fact have this type and typmod.) Also, reject trying to update - * a subfield or array element with DEFAULT, since there can't be any - * default for portions of a column. + * type/typmod into it so that exprType will report the right things. (We + * expect that the eventually substituted default expression will in fact + * have this type and typmod.) Also, reject trying to update a subfield + * or array element with DEFAULT, since there can't be any default for + * portions of a column. */ if (tle->expr && IsA(tle->expr, SetToDefault)) { @@ -288,7 +288,7 @@ updateTargetListEntry(ParseState *pstate, if (IsA(linitial(indirection), A_Indices)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot set an array element to DEFAULT"))); + errmsg("cannot set an array element to DEFAULT"))); else ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -301,9 +301,9 @@ updateTargetListEntry(ParseState *pstate, /* * If there is indirection on the target column, prepare an array or - * subfield assignment expression. This will generate a new column - * value that the source value has been inserted into, which can then - * be placed in the new tuple constructed by INSERT or UPDATE. + * subfield assignment expression. This will generate a new column value + * that the source value has been inserted into, which can then be placed + * in the new tuple constructed by INSERT or UPDATE. */ if (indirection) { @@ -312,9 +312,9 @@ updateTargetListEntry(ParseState *pstate, if (pstate->p_is_insert) { /* - * The command is INSERT INTO table (col.something) ... so - * there is not really a source value to work with. Insert a - * NULL constant as the source value. + * The command is INSERT INTO table (col.something) ... so there + * is not really a source value to work with. Insert a NULL + * constant as the source value. */ colVar = (Node *) makeNullConst(attrtype); } @@ -358,15 +358,14 @@ updateTargetListEntry(ParseState *pstate, colname, format_type_be(attrtype), format_type_be(type_id)), - errhint("You will need to rewrite or cast the expression."))); + errhint("You will need to rewrite or cast the expression."))); } /* * Set the resno to identify the target column --- the rewriter and - * planner depend on this. We also set the resname to identify the - * target column, but this is only for debugging purposes; it should - * not be relied on. (In particular, it might be out of date in a - * stored rule.) + * planner depend on this. We also set the resname to identify the target + * column, but this is only for debugging purposes; it should not be + * relied on. (In particular, it might be out of date in a stored rule.) */ tle->resno = (AttrNumber) attrno; tle->resname = colname; @@ -424,8 +423,8 @@ transformAssignmentIndirection(ParseState *pstate, /* * We have to split any field-selection operations apart from - * subscripting. Adjacent A_Indices nodes have to be treated as a - * single multidimensional subscript operation. + * subscripting. Adjacent A_Indices nodes have to be treated as a single + * multidimensional subscript operation. */ for_each_cell(i, indirection) { @@ -561,7 +560,7 @@ transformAssignmentIndirection(ParseState *pstate, targetName, format_type_be(targetTypeId), format_type_be(exprType(rhs))), - errhint("You will need to rewrite or cast the expression."))); + errhint("You will need to rewrite or cast the expression."))); else ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), @@ -570,7 +569,7 @@ transformAssignmentIndirection(ParseState *pstate, targetName, format_type_be(targetTypeId), format_type_be(exprType(rhs))), - errhint("You will need to rewrite or cast the expression."))); + errhint("You will need to rewrite or cast the expression."))); } return result; @@ -631,8 +630,8 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos) attrno = attnameAttNum(pstate->p_target_relation, name, false); /* - * Check for duplicates, but only of whole columns --- we - * allow INSERT INTO foo (col.subcol1, col.subcol2) + * Check for duplicates, but only of whole columns --- we allow + * INSERT INTO foo (col.subcol1, col.subcol2) */ if (col->indirection == NIL) { @@ -641,8 +640,8 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos) bms_is_member(attrno, partialcols)) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_COLUMN), - errmsg("column \"%s\" specified more than once", - name))); + errmsg("column \"%s\" specified more than once", + name))); wholecols = bms_add_member(wholecols, attrno); } else @@ -651,8 +650,8 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos) if (bms_is_member(attrno, wholecols)) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_COLUMN), - errmsg("column \"%s\" specified more than once", - name))); + errmsg("column \"%s\" specified more than once", + name))); partialcols = bms_add_member(partialcols, attrno); } @@ -727,8 +726,8 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref) default: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("improper qualified name (too many dotted names): %s", - NameListToString(fields)))); + errmsg("improper qualified name (too many dotted names): %s", + NameListToString(fields)))); schemaname = NULL; /* keep compiler quiet */ relname = NULL; break; @@ -765,12 +764,12 @@ ExpandAllTables(ParseState *pstate) if (!pstate->p_varnamespace) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("SELECT * with no tables specified is not valid"))); + errmsg("SELECT * with no tables specified is not valid"))); foreach(l, pstate->p_varnamespace) { RangeTblEntry *rte = (RangeTblEntry *) lfirst(l); - int rtindex = RTERangeTablePosn(pstate, rte, NULL); + int rtindex = RTERangeTablePosn(pstate, rte, NULL); target = list_concat(target, expandRelAttrs(pstate, rte, rtindex, 0)); @@ -804,14 +803,14 @@ ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind) /* * Verify it's a composite type, and get the tupdesc. We use - * get_expr_result_type() because that can handle references to - * functions returning anonymous record types. If that fails, - * use lookup_rowtype_tupdesc(), which will almost certainly fail - * as well, but it will give an appropriate error message. + * get_expr_result_type() because that can handle references to functions + * returning anonymous record types. If that fails, use + * lookup_rowtype_tupdesc(), which will almost certainly fail as well, but + * it will give an appropriate error message. * - * If it's a Var of type RECORD, we have to work even harder: we have - * to find what the Var refers to, and pass that to get_expr_result_type. - * That task is handled by expandRecordVariable(). + * If it's a Var of type RECORD, we have to work even harder: we have to find + * what the Var refers to, and pass that to get_expr_result_type. That + * task is handled by expandRecordVariable(). */ if (IsA(expr, Var) && ((Var *) expr)->vartype == RECORDOID) @@ -832,9 +831,9 @@ ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind) continue; /* - * If we got a whole-row Var from the rowtype reference, we can - * expand the fields as simple Vars. Otherwise we must generate - * multiple copies of the rowtype reference and do FieldSelects. + * If we got a whole-row Var from the rowtype reference, we can expand + * the fields as simple Vars. Otherwise we must generate multiple + * copies of the rowtype reference and do FieldSelects. */ if (IsA(expr, Var) && ((Var *) expr)->varattno == InvalidAttrNumber) @@ -874,7 +873,7 @@ ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind) * Get the tuple descriptor for a Var of type RECORD, if possible. * * Since no actual table or view column is allowed to have type RECORD, such - * a Var must refer to a JOIN or FUNCTION RTE or to a subquery output. We + * a Var must refer to a JOIN or FUNCTION RTE or to a subquery output. We * drill down to find the ultimate defining expression and attempt to infer * the tupdesc from it. We ereport if we can't determine the tupdesc. * @@ -934,6 +933,7 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup) { case RTE_RELATION: case RTE_SPECIAL: + /* * This case should not occur: a column of a table shouldn't have * type RECORD. Fall through and fail (most likely) at the @@ -954,7 +954,7 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup) { /* * Recurse into the sub-select to see what its Var refers - * to. We have to build an additional level of ParseState + * to. We have to build an additional level of ParseState * to keep in step with varlevelsup in the subselect. */ ParseState mypstate; @@ -978,18 +978,19 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup) /* else fall through to inspect the expression */ break; case RTE_FUNCTION: + /* - * We couldn't get here unless a function is declared with one - * of its result columns as RECORD, which is not allowed. + * We couldn't get here unless a function is declared with one of + * its result columns as RECORD, which is not allowed. */ break; } /* * We now have an expression we can't expand any more, so see if - * get_expr_result_type() can do anything with it. If not, pass - * to lookup_rowtype_tupdesc() which will probably fail, but will - * give an appropriate error message while failing. + * get_expr_result_type() can do anything with it. If not, pass to + * lookup_rowtype_tupdesc() which will probably fail, but will give an + * appropriate error message while failing. */ if (get_expr_result_type(expr, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE) tupleDesc = lookup_rowtype_tupdesc(exprType(expr), exprTypmod(expr)); @@ -1125,7 +1126,7 @@ FigureColnameInternal(Node *node, char **name) return 2; case T_MinMaxExpr: /* make greatest/least act like a regular function */ - switch (((MinMaxExpr*) node)->op) + switch (((MinMaxExpr *) node)->op) { case IS_GREATEST: *name = "greatest"; diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c index 008c1fe6a54..ec8dfef68d3 100644 --- a/src/backend/parser/parse_type.c +++ b/src/backend/parser/parse_type.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.76 2005/08/01 20:31:10 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.77 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,8 +59,8 @@ LookupTypeName(const TypeName *typename) case 1: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("improper %%TYPE reference (too few dotted names): %s", - NameListToString(typename->names)))); + errmsg("improper %%TYPE reference (too few dotted names): %s", + NameListToString(typename->names)))); break; case 2: rel->relname = strVal(linitial(typename->names)); @@ -91,8 +91,8 @@ LookupTypeName(const TypeName *typename) if (attnum == InvalidAttrNumber) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("column \"%s\" of relation \"%s\" does not exist", - field, rel->relname))); + errmsg("column \"%s\" of relation \"%s\" does not exist", + field, rel->relname))); restype = get_atttype(relid, attnum); /* this construct should never have an array indicator */ @@ -364,8 +364,8 @@ pts_error_callback(void *arg) /* * Currently we just suppress any syntax error position report, rather - * than transforming to an "internal query" error. It's unlikely that - * a type name is complex enough to need positioning. + * than transforming to an "internal query" error. It's unlikely that a + * type name is complex enough to need positioning. */ errposition(0); } @@ -406,8 +406,8 @@ parseTypeString(const char *str, Oid *type_id, int32 *typmod) error_context_stack = ptserrcontext.previous; /* - * Make sure we got back exactly what we expected and no more; - * paranoia is justified since the string might contain anything. + * Make sure we got back exactly what we expected and no more; paranoia is + * justified since the string might contain anything. */ if (list_length(raw_parsetree_list) != 1) goto fail; diff --git a/src/backend/parser/scansup.c b/src/backend/parser/scansup.c index cf588c1de8b..efa851ea0ba 100644 --- a/src/backend/parser/scansup.c +++ b/src/backend/parser/scansup.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/scansup.c,v 1.29 2004/12/31 22:00:27 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/parser/scansup.c,v 1.30 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,8 +53,8 @@ scanstr(const char *s) if (s[i] == '\'') { /* - * Note: if scanner is working right, unescaped quotes can - * only appear in pairs, so there should be another character. + * Note: if scanner is working right, unescaped quotes can only + * appear in pairs, so there should be another character. */ i++; newStr[j] = s[i]; @@ -135,13 +135,13 @@ downcase_truncate_identifier(const char *ident, int len, bool warn) result = palloc(len + 1); /* - * SQL99 specifies Unicode-aware case normalization, which we don't - * yet have the infrastructure for. Instead we use tolower() to - * provide a locale-aware translation. However, there are some - * locales where this is not right either (eg, Turkish may do strange - * things with 'i' and 'I'). Our current compromise is to use - * tolower() for characters with the high bit set, and use an - * ASCII-only downcasing for 7-bit characters. + * SQL99 specifies Unicode-aware case normalization, which we don't yet + * have the infrastructure for. Instead we use tolower() to provide a + * locale-aware translation. However, there are some locales where this + * is not right either (eg, Turkish may do strange things with 'i' and + * 'I'). Our current compromise is to use tolower() for characters with + * the high bit set, and use an ASCII-only downcasing for 7-bit + * characters. */ for (i = 0; i < len; i++) { @@ -179,8 +179,8 @@ truncate_identifier(char *ident, int len, bool warn) if (warn) ereport(NOTICE, (errcode(ERRCODE_NAME_TOO_LONG), - errmsg("identifier \"%s\" will be truncated to \"%.*s\"", - ident, len, ident))); + errmsg("identifier \"%s\" will be truncated to \"%.*s\"", + ident, len, ident))); ident[len] = '\0'; } } |