diff options
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/analyze.c | 49 | ||||
-rw-r--r-- | src/backend/parser/parse_agg.c | 26 | ||||
-rw-r--r-- | src/backend/parser/parse_clause.c | 24 | ||||
-rw-r--r-- | src/backend/parser/parse_coerce.c | 6 | ||||
-rw-r--r-- | src/backend/parser/parse_expr.c | 51 | ||||
-rw-r--r-- | src/backend/parser/parse_func.c | 65 | ||||
-rw-r--r-- | src/backend/parser/parse_oper.c | 7 | ||||
-rw-r--r-- | src/backend/parser/parse_param.c | 8 | ||||
-rw-r--r-- | src/backend/parser/parse_relation.c | 24 | ||||
-rw-r--r-- | src/backend/parser/parse_target.c | 75 | ||||
-rw-r--r-- | src/backend/parser/parse_utilcmd.c | 37 |
11 files changed, 188 insertions, 184 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 027cb972ee7..1576613bc1a 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -17,7 +17,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.401 2010/02/12 22:48:56 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.402 2010/02/26 02:00:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,7 +53,7 @@ static Query *transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt); static Node *transformSetOperationTree(ParseState *pstate, SelectStmt *stmt, bool isTopLevel, List **colInfo); static void determineRecursiveColTypes(ParseState *pstate, - Node *larg, List *lcolinfo); + Node *larg, List *lcolinfo); static void applyColumnNames(List *dst, List *src); static Query *transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt); static List *transformReturningList(ParseState *pstate, List *returningList); @@ -62,7 +62,7 @@ static Query *transformDeclareCursorStmt(ParseState *pstate, static Query *transformExplainStmt(ParseState *pstate, ExplainStmt *stmt); static void transformLockingClause(ParseState *pstate, Query *qry, - LockingClause *lc, bool pushedDown); + LockingClause *lc, bool pushedDown); /* @@ -823,14 +823,14 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt) qry->sortClause = transformSortClause(pstate, stmt->sortClause, &qry->targetList, - true /* fix unknowns */, - false /* allow SQL92 rules */); + true /* fix unknowns */ , + false /* allow SQL92 rules */ ); qry->groupClause = transformGroupClause(pstate, stmt->groupClause, &qry->targetList, qry->sortClause, - false /* allow SQL92 rules */); + false /* allow SQL92 rules */ ); if (stmt->distinctClause == NIL) { @@ -1040,8 +1040,8 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt) qry->sortClause = transformSortClause(pstate, stmt->sortClause, &qry->targetList, - true /* fix unknowns */, - false /* allow SQL92 rules */); + true /* fix unknowns */ , + false /* allow SQL92 rules */ ); qry->limitOffset = transformLimitClause(pstate, stmt->limitOffset, "OFFSET"); @@ -1294,8 +1294,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) qry->sortClause = transformSortClause(pstate, sortClause, &qry->targetList, - false /* no unknowns expected */, - false /* allow SQL92 rules */); + false /* no unknowns expected */ , + false /* allow SQL92 rules */ ); pstate->p_rtable = list_truncate(pstate->p_rtable, sv_rtable_length); pstate->p_relnamespace = sv_relnamespace; @@ -1494,8 +1494,8 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt, &lcolinfo); /* - * If we are processing a recursive union query, now is the time - * to examine the non-recursive term's output columns and mark the + * If we are processing a recursive union query, now is the time to + * examine the non-recursive term's output columns and mark the * containing CTE as having those result columns. We should do this * only at the topmost setop of the CTE, of course. */ @@ -1552,25 +1552,25 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt, rescoltypmod = -1; /* - * Verify the coercions are actually possible. If not, we'd - * fail later anyway, but we want to fail now while we have - * sufficient context to produce an error cursor position. + * Verify the coercions are actually possible. If not, we'd fail + * later anyway, but we want to fail now while we have sufficient + * context to produce an error cursor position. * * The if-tests might look wrong, but they are correct: we should * verify if the input is non-UNKNOWN *or* if it is an UNKNOWN * Const (to verify the literal is valid for the target data type) * or Param (to possibly resolve the Param's type). We should do * nothing if the input is say an UNKNOWN Var, which can happen in - * some cases. The planner is sometimes able to fold the Var to a + * some cases. The planner is sometimes able to fold the Var to a * constant before it has to coerce the type, so failing now would * just break cases that might work. */ if (lcoltype != UNKNOWNOID || - IsA(lcolnode, Const) || IsA(lcolnode, Param)) + IsA(lcolnode, Const) ||IsA(lcolnode, Param)) (void) coerce_to_common_type(pstate, lcolnode, rescoltype, context); if (rcoltype != UNKNOWNOID || - IsA(rcolnode, Const) || IsA(rcolnode, Param)) + IsA(rcolnode, Const) ||IsA(rcolnode, Param)) (void) coerce_to_common_type(pstate, rcolnode, rescoltype, context); @@ -1647,8 +1647,8 @@ determineRecursiveColTypes(ParseState *pstate, Node *larg, List *lcolinfo) Assert(leftmostQuery != NULL); /* - * Generate dummy targetlist using column names of leftmost select - * and dummy result expressions of the non-recursive term. + * Generate dummy targetlist using column names of leftmost select and + * dummy result expressions of the non-recursive term. */ targetList = NIL; left_tlist = list_head(leftmostQuery->targetList); @@ -2095,12 +2095,13 @@ transformLockingClause(ParseState *pstate, Query *qry, LockingClause *lc, case RTE_SUBQUERY: applyLockingClause(qry, i, lc->forUpdate, lc->noWait, pushedDown); + /* * FOR UPDATE/SHARE of subquery is propagated to all of - * subquery's rels, too. We could do this later (based - * on the marking of the subquery RTE) but it is convenient - * to have local knowledge in each query level about - * which rels need to be opened with RowShareLock. + * subquery's rels, too. We could do this later (based on + * the marking of the subquery RTE) but it is convenient + * to have local knowledge in each query level about which + * rels need to be opened with RowShareLock. */ transformLockingClause(pstate, rte->subquery, allrels, true); diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index e883e283e0b..d30d01261f7 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.91 2010/02/12 17:33:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.92 2010/02/26 02:00:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,7 +51,7 @@ static bool check_ungrouped_columns_walker(Node *node, * * Here we convert the args list into a targetlist by inserting TargetEntry * nodes, and then transform the aggorder and agg_distinct specifications to - * produce lists of SortGroupClause nodes. (That might also result in adding + * produce lists of SortGroupClause nodes. (That might also result in adding * resjunk expressions to the targetlist.) * * We must also determine which query level the aggregate actually belongs to, @@ -61,11 +61,11 @@ static bool check_ungrouped_columns_walker(Node *node, void transformAggregateCall(ParseState *pstate, Aggref *agg, bool agg_distinct) { - List *tlist; - List *torder; - List *tdistinct = NIL; - AttrNumber attno; - int save_next_resno; + List *tlist; + List *torder; + List *tdistinct = NIL; + AttrNumber attno; + int save_next_resno; int min_varlevel; ListCell *lc; @@ -77,7 +77,7 @@ transformAggregateCall(ParseState *pstate, Aggref *agg, bool agg_distinct) attno = 1; foreach(lc, agg->args) { - Expr *arg = (Expr *) lfirst(lc); + Expr *arg = (Expr *) lfirst(lc); TargetEntry *tle = makeTargetEntry(arg, attno++, NULL, false); tlist = lappend(tlist, tle); @@ -98,8 +98,8 @@ transformAggregateCall(ParseState *pstate, Aggref *agg, bool agg_distinct) torder = transformSortClause(pstate, agg->aggorder, &tlist, - true /* fix unknowns */, - true /* force SQL99 rules */); + true /* fix unknowns */ , + true /* force SQL99 rules */ ); /* * If we have DISTINCT, transform that to produce a distinctList. @@ -118,12 +118,12 @@ transformAggregateCall(ParseState *pstate, Aggref *agg, bool agg_distinct) if (!OidIsValid(sortcl->sortop)) { - Node *expr = get_sortgroupclause_expr(sortcl, tlist); + Node *expr = get_sortgroupclause_expr(sortcl, tlist); ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify an ordering operator for type %s", - format_type_be(exprType(expr))), + errmsg("could not identify an ordering operator for type %s", + format_type_be(exprType(expr))), errdetail("Aggregates with DISTINCT must be able to sort their inputs."), parser_errposition(pstate, exprLocation(expr)))); } diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index 54bb867631e..182181f3a60 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.197 2010/02/12 17:33:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.198 2010/02/26 02:00:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -73,7 +73,7 @@ static Node *transformFromClauseItem(ParseState *pstate, Node *n, static Node *buildMergedJoinVar(ParseState *pstate, JoinType jointype, Var *l_colvar, Var *r_colvar); static void checkExprIsVarFree(ParseState *pstate, Node *n, - const char *constructName); + const char *constructName); static TargetEntry *findTargetlistEntrySQL92(ParseState *pstate, Node *node, List **tlist, int clause); static TargetEntry *findTargetlistEntrySQL99(ParseState *pstate, Node *node, @@ -88,7 +88,7 @@ static List *addTargetToGroupList(ParseState *pstate, TargetEntry *tle, bool resolveUnknown); static WindowClause *findWindowClause(List *wclist, const char *name); static Node *transformFrameOffset(ParseState *pstate, int frameOptions, - Node *clause); + Node *clause); /* @@ -802,7 +802,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, ListCell *lx, *rx; - Assert(j->usingClause == NIL); /* shouldn't have USING() too */ + Assert(j->usingClause == NIL); /* shouldn't have USING() too */ foreach(lx, l_colnames) { @@ -1245,9 +1245,9 @@ checkExprIsVarFree(ParseState *pstate, Node *n, const char *constructName) * * This function supports the old SQL92 ORDER BY interpretation, where the * expression is an output column name or number. If we fail to find a - * match of that sort, we fall through to the SQL99 rules. For historical + * match of that sort, we fall through to the SQL99 rules. For historical * reasons, Postgres also allows this interpretation for GROUP BY, though - * the standard never did. However, for GROUP BY we prefer a SQL99 match. + * the standard never did. However, for GROUP BY we prefer a SQL99 match. * This function is *not* used for WINDOW definitions. * * node the ORDER BY, GROUP BY, or DISTINCT ON expression to be matched @@ -1421,7 +1421,7 @@ findTargetlistEntrySQL99(ParseState *pstate, Node *node, List **tlist) /* * Convert the untransformed node to a transformed expression, and search * for a match in the tlist. NOTE: it doesn't really matter whether there - * is more than one match. Also, we are willing to match an existing + * is more than one match. Also, we are willing to match an existing * resjunk target here, though the SQL92 cases above must ignore resjunk * targets. */ @@ -1617,13 +1617,13 @@ transformWindowDefinitions(ParseState *pstate, orderClause = transformSortClause(pstate, windef->orderClause, targetlist, - true /* fix unknowns */, - true /* force SQL99 rules */); + true /* fix unknowns */ , + true /* force SQL99 rules */ ); partitionClause = transformGroupClause(pstate, windef->partitionClause, targetlist, orderClause, - true /* force SQL99 rules */); + true /* force SQL99 rules */ ); /* * And prepare the new WindowClause. @@ -2220,8 +2220,8 @@ transformFrameOffset(ParseState *pstate, int frameOptions, Node *clause) else if (frameOptions & FRAMEOPTION_RANGE) { /* - * this needs a lot of thought to decide how to support in the - * context of Postgres' extensible datatype framework + * this needs a lot of thought to decide how to support in the context + * of Postgres' extensible datatype framework */ constructName = "RANGE"; /* error was already thrown by gram.y, this is just a backstop */ diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index 66ce032cee6..2000dfb93a9 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.180 2010/02/14 18:42:15 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.181 2010/02/26 02:00:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -263,8 +263,8 @@ coerce_type(ParseState *pstate, Node *node, pstate != NULL && pstate->p_coerce_param_hook != NULL) { /* - * Allow the CoerceParamHook to decide what happens. It can return - * a transformed node (very possibly the same Param node), or return + * Allow the CoerceParamHook to decide what happens. It can return a + * transformed node (very possibly the same Param node), or return * NULL to indicate we should proceed with normal coercion. */ result = (*pstate->p_coerce_param_hook) (pstate, diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index 72cb64a63d0..12c93e15f41 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.253 2010/01/02 16:57:49 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.254 2010/02/26 02:00:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,7 +61,7 @@ static Node *transformBooleanTest(ParseState *pstate, BooleanTest *b); static Node *transformCurrentOfExpr(ParseState *pstate, CurrentOfExpr *cexpr); static Node *transformColumnRef(ParseState *pstate, ColumnRef *cref); static Node *transformWholeRowRef(ParseState *pstate, RangeTblEntry *rte, - int location); + int location); static Node *transformIndirection(ParseState *pstate, Node *basenode, List *indirection); static Node *transformTypeCast(ParseState *pstate, TypeCast *tc); @@ -172,8 +172,8 @@ transformExpr(ParseState *pstate, Node *expr) * not a domain, transformTypeCast is a no-op. */ targetType = getBaseTypeAndTypmod(targetType, - &targetTypmod); - + &targetTypmod); + tc = copyObject(tc); tc->arg = transformArrayExpr(pstate, (A_ArrayExpr *) tc->arg, @@ -466,7 +466,8 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) char *colname = NULL; RangeTblEntry *rte; int levels_up; - enum { + enum + { CRERR_NO_COLUMN, CRERR_NO_RTE, CRERR_WRONG_DB, @@ -474,7 +475,7 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) } crerr = CRERR_NO_COLUMN; /* - * Give the PreParseColumnRefHook, if any, first shot. If it returns + * Give the PreParseColumnRefHook, if any, first shot. If it returns * non-null then that's all, folks. */ if (pstate->p_pre_columnref_hook != NULL) @@ -708,22 +709,22 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) break; } default: - crerr = CRERR_TOO_MANY; /* too many dotted names */ + crerr = CRERR_TOO_MANY; /* too many dotted names */ break; } /* * Now give the PostParseColumnRefHook, if any, a chance. We pass the * translation-so-far so that it can throw an error if it wishes in the - * case that it has a conflicting interpretation of the ColumnRef. - * (If it just translates anyway, we'll throw an error, because we can't - * undo whatever effects the preceding steps may have had on the pstate.) - * If it returns NULL, use the standard translation, or throw a suitable - * error if there is none. + * case that it has a conflicting interpretation of the ColumnRef. (If it + * just translates anyway, we'll throw an error, because we can't undo + * whatever effects the preceding steps may have had on the pstate.) If it + * returns NULL, use the standard translation, or throw a suitable error + * if there is none. */ if (pstate->p_post_columnref_hook != NULL) { - Node *hookresult; + Node *hookresult; hookresult = (*pstate->p_post_columnref_hook) (pstate, cref, node); if (node == NULL) @@ -765,15 +766,15 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) case CRERR_WRONG_DB: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cross-database references are not implemented: %s", - NameListToString(cref->fields)), + errmsg("cross-database references are not implemented: %s", + NameListToString(cref->fields)), parser_errposition(pstate, cref->location))); break; case CRERR_TOO_MANY: 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)), parser_errposition(pstate, cref->location))); break; } @@ -788,7 +789,7 @@ transformParamRef(ParseState *pstate, ParamRef *pref) Node *result; /* - * The core parser knows nothing about Params. If a hook is supplied, + * The core parser knows nothing about Params. If a hook is supplied, * call it. If not, or if the hook returns NULL, throw a generic error. */ if (pstate->p_paramref_hook != NULL) @@ -1972,10 +1973,10 @@ transformCurrentOfExpr(ParseState *pstate, CurrentOfExpr *cexpr) /* * Check to see if the cursor name matches a parameter of type REFCURSOR. - * If so, replace the raw name reference with a parameter reference. - * (This is a hack for the convenience of plpgsql.) + * If so, replace the raw name reference with a parameter reference. (This + * is a hack for the convenience of plpgsql.) */ - if (cexpr->cursor_name != NULL) /* in case already transformed */ + if (cexpr->cursor_name != NULL) /* in case already transformed */ { ColumnRef *cref = makeNode(ColumnRef); Node *node = NULL; @@ -1991,13 +1992,13 @@ transformCurrentOfExpr(ParseState *pstate, CurrentOfExpr *cexpr) node = (*pstate->p_post_columnref_hook) (pstate, cref, NULL); /* - * XXX Should we throw an error if we get a translation that isn't - * a refcursor Param? For now it seems best to silently ignore - * false matches. + * XXX Should we throw an error if we get a translation that isn't a + * refcursor Param? For now it seems best to silently ignore false + * matches. */ if (node != NULL && IsA(node, Param)) { - Param *p = (Param *) node; + Param *p = (Param *) node; if (p->paramkind == PARAM_EXTERN && p->paramtype == REFCURSOROID) diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index df34711af6e..dffc24c09e3 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.221 2010/02/14 18:42:15 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.222 2010/02/26 02:00:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -125,13 +125,13 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, * * We allow mixed notation (some named and some not), but only with all * the named parameters after all the unnamed ones. So the name list - * corresponds to the last N actual parameters and we don't need any - * extra bookkeeping to match things up. + * corresponds to the last N actual parameters and we don't need any extra + * bookkeeping to match things up. */ argnames = NIL; foreach(l, fargs) { - Node *arg = lfirst(l); + Node *arg = lfirst(l); if (IsA(arg, NamedArgExpr)) { @@ -144,8 +144,8 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, if (strcmp(na->name, (char *) lfirst(lc)) == 0) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("argument name \"%s\" used more than once", - na->name), + errmsg("argument name \"%s\" used more than once", + na->name), parser_errposition(pstate, na->location))); } argnames = lappend(argnames, na->name); @@ -155,7 +155,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, if (argnames != NIL) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("positional argument cannot follow named argument"), + errmsg("positional argument cannot follow named argument"), parser_errposition(pstate, exprLocation(arg)))); } } @@ -246,8 +246,8 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, if (agg_order != NIL) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("ORDER BY specified, but %s is not an aggregate function", - NameListToString(funcname)), + errmsg("ORDER BY specified, but %s is not an aggregate function", + NameListToString(funcname)), parser_errposition(pstate, location))); if (over) ereport(ERROR, @@ -262,8 +262,8 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, /* * Oops. Time to die. * - * If we are dealing with the attribute notation rel.function, - * let the caller handle failure. + * If we are dealing with the attribute notation rel.function, let the + * caller handle failure. */ if (is_column) return NULL; @@ -408,9 +408,9 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, /* * Currently it's not possible to define an aggregate with named - * arguments, so this case should be impossible. Check anyway - * because the planner and executor wouldn't cope with NamedArgExprs - * in an Aggref node. + * arguments, so this case should be impossible. Check anyway because + * the planner and executor wouldn't cope with NamedArgExprs in an + * Aggref node. */ if (argnames != NIL) ereport(ERROR, @@ -481,9 +481,9 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, parser_errposition(pstate, location))); /* - * We might want to support this later, but for now reject it - * because the planner and executor wouldn't cope with NamedArgExprs - * in a WindowFunc node. + * We might want to support this later, but for now reject it because + * the planner and executor wouldn't cope with NamedArgExprs in a + * WindowFunc node. */ if (argnames != NIL) ereport(ERROR, @@ -1075,10 +1075,9 @@ func_get_detail(List *funcname, return FUNCDETAIL_MULTIPLE; /* - * We disallow VARIADIC with named arguments unless the last - * argument (the one with VARIADIC attached) actually matched the - * variadic parameter. This is mere pedantry, really, but some - * folks insisted. + * We disallow VARIADIC with named arguments unless the last argument + * (the one with VARIADIC attached) actually matched the variadic + * parameter. This is mere pedantry, really, but some folks insisted. */ if (fargnames != NIL && !expand_variadic && nargs > 0 && best_candidate->argnumbers[nargs - 1] != nargs - 1) @@ -1142,17 +1141,17 @@ func_get_detail(List *funcname, { /* * This is a bit tricky in named notation, since the supplied - * arguments could replace any subset of the defaults. We + * arguments could replace any subset of the defaults. We * work by making a bitmapset of the argnumbers of defaulted * arguments, then scanning the defaults list and selecting * the needed items. (This assumes that defaulted arguments * should be supplied in their positional order.) */ - Bitmapset *defargnumbers; - int *firstdefarg; - List *newdefaults; - ListCell *lc; - int i; + Bitmapset *defargnumbers; + int *firstdefarg; + List *newdefaults; + ListCell *lc; + int i; defargnumbers = NULL; firstdefarg = &best_candidate->argnumbers[best_candidate->nargs - best_candidate->ndargs]; @@ -1174,8 +1173,8 @@ func_get_detail(List *funcname, else { /* - * Defaults for positional notation are lots easier; - * just remove any unwanted ones from the front. + * Defaults for positional notation are lots easier; just + * remove any unwanted ones from the front. */ int ndelete; @@ -1226,11 +1225,11 @@ make_fn_arguments(ParseState *pstate, /* types don't match? then force coercion using a function call... */ if (actual_arg_types[i] != declared_arg_types[i]) { - Node *node = (Node *) lfirst(current_fargs); + Node *node = (Node *) lfirst(current_fargs); /* - * If arg is a NamedArgExpr, coerce its input expr instead --- - * we want the NamedArgExpr to stay at the top level of the list. + * If arg is a NamedArgExpr, coerce its input expr instead --- we + * want the NamedArgExpr to stay at the top level of the list. */ if (IsA(node, NamedArgExpr)) { @@ -1364,7 +1363,7 @@ ParseComplexProjection(ParseState *pstate, char *funcname, Node *first_arg, * The result is something like "foo(integer)". * * If argnames isn't NIL, it is a list of C strings representing the actual - * arg names for the last N arguments. This must be considered part of the + * arg names for the last N arguments. This must be considered part of the * function signature too, when dealing with named-notation function calls. * * This is typically used in the construction of function-not-found error diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c index daa9e2341fa..f40f9af348e 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.112 2010/02/14 18:42:15 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.113 2010/02/26 02:00:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -229,11 +229,12 @@ get_sort_group_operators(Oid argtype, lt_opr = gt_opr = InvalidOid; } #else + /* * ... but for the moment we have to do this. This is because * anyarray has sorting but not hashing support. So, if the - * element type is only hashable, there is nothing we can do - * with the array type. + * element type is only hashable, there is nothing we can do with + * the array type. */ if (!OidIsValid(typentry->lt_opr) || !OidIsValid(typentry->eq_opr) || diff --git a/src/backend/parser/parse_param.c b/src/backend/parser/parse_param.c index b1282a14626..ba91028c891 100644 --- a/src/backend/parser/parse_param.c +++ b/src/backend/parser/parse_param.c @@ -17,7 +17,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_param.c,v 2.3 2010/01/13 01:17:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_param.c,v 2.4 2010/02/26 02:00:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,8 +53,8 @@ typedef struct VarParamState static Node *fixed_paramref_hook(ParseState *pstate, ParamRef *pref); static Node *variable_paramref_hook(ParseState *pstate, ParamRef *pref); static Node *variable_coerce_param_hook(ParseState *pstate, Param *param, - Oid targetTypeId, int32 targetTypeMod, - int location); + Oid targetTypeId, int32 targetTypeMod, + int location); static bool check_parameter_resolution_walker(Node *node, ParseState *pstate); @@ -245,7 +245,7 @@ variable_coerce_param_hook(ParseState *pstate, Param *param, * of parsing with parse_variable_parameters. * * Note: this code intentionally does not check that all parameter positions - * were used, nor that all got non-UNKNOWN types assigned. Caller of parser + * were used, nor that all got non-UNKNOWN types assigned. Caller of parser * should enforce that if it's important. */ void diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c index 34f2dc410bd..9fdcd83d75b 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.149 2010/02/14 18:42:15 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.150 2010/02/26 02:00:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -88,11 +88,11 @@ refnameRangeTblEntry(ParseState *pstate, /* * We can use LookupNamespaceNoError() here because we are only - * interested in finding existing RTEs. Checking USAGE permission - * on the schema is unnecessary since it would have already been - * checked when the RTE was made. Furthermore, we want to report - * "RTE not found", not "no permissions for schema", if the name - * happens to match a schema name the user hasn't got access to. + * interested in finding existing RTEs. Checking USAGE permission on + * the schema is unnecessary since it would have already been checked + * when the RTE was made. Furthermore, we want to report "RTE not + * found", not "no permissions for schema", if the name happens to + * match a schema name the user hasn't got access to. */ namespaceId = LookupNamespaceNoError(schemaname); if (!OidIsValid(relId)) @@ -2369,8 +2369,8 @@ errorMissingRTE(ParseState *pstate, RangeVar *relation) /* * Check to see if there are any potential matches in the query's - * rangetable. (Note: cases involving a bad schema name in the - * RangeVar will throw error immediately here. That seems OK.) + * rangetable. (Note: cases involving a bad schema name in the RangeVar + * will throw error immediately here. That seems OK.) */ rte = searchRangeTable(pstate, relation); @@ -2394,11 +2394,11 @@ errorMissingRTE(ParseState *pstate, RangeVar *relation) if (rte) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_TABLE), - errmsg("invalid reference to FROM-clause entry for table \"%s\"", - relation->relname), + errmsg("invalid reference to FROM-clause entry for table \"%s\"", + relation->relname), (badAlias ? - errhint("Perhaps you meant to reference the table alias \"%s\".", - badAlias) : + errhint("Perhaps you meant to reference the table alias \"%s\".", + badAlias) : errhint("There is an entry for table \"%s\", but it cannot be referenced from this part of the query.", rte->eref->aliasname)), parser_errposition(pstate, relation->location))); diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index dce6f4d01c9..7e04a947830 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.176 2010/01/02 16:57:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.177 2010/02/26 02:00:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,9 +49,9 @@ static List *ExpandAllTables(ParseState *pstate, int location); static List *ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind, bool targetlist); static List *ExpandSingleTable(ParseState *pstate, RangeTblEntry *rte, - int location, bool targetlist); + int location, bool targetlist); static List *ExpandRowReference(ParseState *pstate, Node *expr, - bool targetlist); + bool targetlist); static int FigureColnameInternal(Node *node, char **name); @@ -884,12 +884,12 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref, * * (e.g., SELECT emp.*, dname FROM emp, dept) * - * Note: this code is a lot like transformColumnRef; it's tempting - * to call that instead and then replace the resulting whole-row Var - * with a list of Vars. However, that would leave us with the - * RTE's selectedCols bitmap showing the whole row as needing - * select permission, as well as the individual columns. That would - * be incorrect (since columns added later shouldn't need select + * Note: this code is a lot like transformColumnRef; it's tempting to + * call that instead and then replace the resulting whole-row Var with + * a list of Vars. However, that would leave us with the RTE's + * selectedCols bitmap showing the whole row as needing select + * permission, as well as the individual columns. That would be + * incorrect (since columns added later shouldn't need select * permissions). We could try to remove the whole-row permission bit * after the fact, but duplicating code is less messy. */ @@ -897,14 +897,15 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref, char *relname = NULL; RangeTblEntry *rte = NULL; int levels_up; - enum { + enum + { CRSERR_NO_RTE, CRSERR_WRONG_DB, CRSERR_TOO_MANY } crserr = CRSERR_NO_RTE; /* - * Give the PreParseColumnRefHook, if any, first shot. If it returns + * Give the PreParseColumnRefHook, if any, first shot. If it returns * non-null then we should use that expression. */ if (pstate->p_pre_columnref_hook != NULL) @@ -932,35 +933,35 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref, &levels_up); break; case 4: - { - char *catname = strVal(linitial(fields)); - - /* - * We check the catalog name and then ignore it. - */ - if (strcmp(catname, get_database_name(MyDatabaseId)) != 0) { - crserr = CRSERR_WRONG_DB; + char *catname = strVal(linitial(fields)); + + /* + * We check the catalog name and then ignore it. + */ + if (strcmp(catname, get_database_name(MyDatabaseId)) != 0) + { + crserr = CRSERR_WRONG_DB; + break; + } + nspname = strVal(lsecond(fields)); + relname = strVal(lthird(fields)); + rte = refnameRangeTblEntry(pstate, nspname, relname, + cref->location, + &levels_up); break; } - nspname = strVal(lsecond(fields)); - relname = strVal(lthird(fields)); - rte = refnameRangeTblEntry(pstate, nspname, relname, - cref->location, - &levels_up); - break; - } default: crserr = CRSERR_TOO_MANY; break; } /* - * Now give the PostParseColumnRefHook, if any, a chance. - * We cheat a bit by passing the RangeTblEntry, not a Var, - * as the planned translation. (A single Var wouldn't be - * strictly correct anyway. This convention allows hooks - * that really care to know what is happening.) + * Now give the PostParseColumnRefHook, if any, a chance. We cheat a + * bit by passing the RangeTblEntry, not a Var, as the planned + * translation. (A single Var wouldn't be strictly correct anyway. + * This convention allows hooks that really care to know what is + * happening.) */ if (pstate->p_post_columnref_hook != NULL) { @@ -1111,9 +1112,9 @@ ExpandSingleTable(ParseState *pstate, RangeTblEntry *rte, NULL, &vars); /* - * Require read access to the table. This is normally redundant - * with the markVarForSelectPriv calls below, but not if the table - * has zero columns. + * Require read access to the table. This is normally redundant with + * the markVarForSelectPriv calls below, but not if the table has zero + * columns. */ rte->requiredPerms |= ACL_SELECT; @@ -1147,7 +1148,7 @@ ExpandRowReference(ParseState *pstate, Node *expr, /* * If the rowtype expression is a whole-row Var, we can expand the fields - * as simple Vars. Note: if the RTE is a relation, this case leaves us + * as simple Vars. Note: if the RTE is a relation, this case leaves us * with the RTE's selectedCols bitmap showing the whole row as needing * select permission, as well as the individual columns. However, we can * only get here for weird notations like (table.*).*, so it's not worth @@ -1165,8 +1166,8 @@ ExpandRowReference(ParseState *pstate, Node *expr, } /* - * Otherwise we have to do it the hard way. Our current implementation - * is to generate multiple copies of the expression and do FieldSelects. + * Otherwise we have to do it the hard way. Our current implementation is + * to generate multiple copies of the expression and do FieldSelects. * (This can be pretty inefficient if the expression involves nontrivial * computation :-(.) * diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 4a5a5725455..1657096c6d8 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -19,7 +19,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.39 2010/02/14 18:42:15 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.40 2010/02/26 02:00:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -106,7 +106,7 @@ static void transformTableConstraint(ParseState *pstate, static void transformInhRelation(ParseState *pstate, CreateStmtContext *cxt, InhRelation *inhrelation); static void transformOfType(ParseState *pstate, CreateStmtContext *cxt, - TypeName *ofTypename); + TypeName *ofTypename); static char *chooseIndexName(const RangeVar *relation, IndexStmt *index_stmt); static IndexStmt *generateClonedIndexStmt(CreateStmtContext *cxt, Relation parent_index, AttrNumber *attmap); @@ -186,7 +186,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString) cxt.pkey = NULL; cxt.hasoids = interpretOidsOption(stmt->options); - Assert(!stmt->ofTypename || !stmt->inhRelations); /* grammar enforces */ + Assert(!stmt->ofTypename || !stmt->inhRelations); /* grammar enforces */ if (stmt->ofTypename) transformOfType(pstate, &cxt, stmt->ofTypename); @@ -486,6 +486,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, break; case CONSTR_FOREIGN: + /* * Fill in the current attribute's name and throw it into the * list of FK constraints to be processed later. @@ -760,11 +761,11 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt, if (comment != NULL) { - CommentStmt *stmt; + CommentStmt *stmt; /* - * We have to assign the index a name now, so that we - * can reference it in CommentStmt. + * We have to assign the index a name now, so that we can + * reference it in CommentStmt. */ if (index_stmt->idxname == NULL) index_stmt->idxname = chooseIndexName(cxt->relation, @@ -811,7 +812,7 @@ transformOfType(ParseState *pstate, CreateStmtContext *cxt, TypeName *ofTypename tuple = typenameType(NULL, ofTypename, NULL); typ = (Form_pg_type) GETSTRUCT(tuple); ofTypeId = HeapTupleGetOid(tuple); - ofTypename->typeOid = ofTypeId; /* cached for later */ + ofTypename->typeOid = ofTypeId; /* cached for later */ if (typ->typtype != TYPTYPE_COMPOSITE) ereport(ERROR, @@ -823,7 +824,7 @@ transformOfType(ParseState *pstate, CreateStmtContext *cxt, TypeName *ofTypename for (i = 0; i < tupdesc->natts; i++) { Form_pg_attribute attr = tupdesc->attrs[i]; - ColumnDef *n = makeNode(ColumnDef); + ColumnDef *n = makeNode(ColumnDef); n->colname = pstrdup(NameStr(attr->attname)); n->typeName = makeTypeNameFromOid(attr->atttypid, attr->atttypmod); @@ -934,7 +935,7 @@ generateClonedIndexStmt(CreateStmtContext *cxt, Relation source_idx, */ if (index->primary || index->unique || idxrelrec->relhasexclusion) { - Oid constraintId = get_index_constraint(source_relid); + Oid constraintId = get_index_constraint(source_relid); if (OidIsValid(constraintId)) { @@ -942,7 +943,7 @@ generateClonedIndexStmt(CreateStmtContext *cxt, Relation source_idx, Form_pg_constraint conrec; ht_constr = SearchSysCache1(CONSTROID, - ObjectIdGetDatum(constraintId)); + ObjectIdGetDatum(constraintId)); if (!HeapTupleIsValid(ht_constr)) elog(ERROR, "cache lookup failed for constraint %u", constraintId); @@ -955,9 +956,9 @@ generateClonedIndexStmt(CreateStmtContext *cxt, Relation source_idx, /* If it's an exclusion constraint, we need the operator names */ if (idxrelrec->relhasexclusion) { - Datum *elems; - int nElems; - int i; + Datum *elems; + int nElems; + int i; Assert(conrec->contype == CONSTRAINT_EXCLUSION); /* Extract operator OIDs from the pg_constraint tuple */ @@ -1310,17 +1311,17 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt) index->concurrent = false; /* - * If it's an EXCLUDE constraint, the grammar returns a list of pairs - * of IndexElems and operator names. We have to break that apart into + * If it's an EXCLUDE constraint, the grammar returns a list of pairs of + * IndexElems and operator names. We have to break that apart into * separate lists. */ if (constraint->contype == CONSTR_EXCLUSION) { foreach(lc, constraint->exclusions) { - List *pair = (List *) lfirst(lc); - IndexElem *elem; - List *opname; + List *pair = (List *) lfirst(lc); + IndexElem *elem; + List *opname; Assert(list_length(pair) == 2); elem = (IndexElem *) linitial(pair); |