1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

pgindent run for 9.5

This commit is contained in:
Bruce Momjian
2015-05-23 21:35:49 -04:00
parent 225892552b
commit 807b9e0dff
414 changed files with 5810 additions and 5308 deletions

View File

@ -53,7 +53,7 @@ static Query *transformInsertStmt(ParseState *pstate, InsertStmt *stmt);
static List *transformInsertRow(ParseState *pstate, List *exprlist,
List *stmtcols, List *icolumns, List *attrnos);
static OnConflictExpr *transformOnConflictClause(ParseState *pstate,
OnConflictClause *onConflictClause);
OnConflictClause *onConflictClause);
static int count_rowexpr_columns(ParseState *pstate, Node *expr);
static Query *transformSelectStmt(ParseState *pstate, SelectStmt *stmt);
static Query *transformValuesClause(ParseState *pstate, SelectStmt *stmt);
@ -65,7 +65,7 @@ static void determineRecursiveColTypes(ParseState *pstate,
static Query *transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt);
static List *transformReturningList(ParseState *pstate, List *returningList);
static List *transformUpdateTargetList(ParseState *pstate,
List *targetList);
List *targetList);
static Query *transformDeclareCursorStmt(ParseState *pstate,
DeclareCursorStmt *stmt);
static Query *transformExplainStmt(ParseState *pstate,
@ -441,7 +441,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
}
isOnConflictUpdate = (stmt->onConflictClause &&
stmt->onConflictClause->action == ONCONFLICT_UPDATE);
stmt->onConflictClause->action == ONCONFLICT_UPDATE);
/*
* We have three cases to deal with: DEFAULT VALUES (selectStmt == NULL),
@ -882,7 +882,7 @@ transformOnConflictClause(ParseState *pstate,
RangeTblEntry *exclRte = NULL;
int exclRelIndex = 0;
List *exclRelTlist = NIL;
OnConflictExpr *result;
OnConflictExpr *result;
/* Process the arbiter clause, ON CONFLICT ON (...) */
transformOnConflictArbiter(pstate, onConflictClause, &arbiterElems,
@ -2059,10 +2059,10 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
static List *
transformUpdateTargetList(ParseState *pstate, List *origTlist)
{
List *tlist = NIL;
RangeTblEntry *target_rte;
ListCell *orig_tl;
ListCell *tl;
List *tlist = NIL;
RangeTblEntry *target_rte;
ListCell *orig_tl;
ListCell *tl;
tlist = transformTargetList(pstate, origTlist,
EXPR_KIND_UPDATE_SOURCE);

View File

@ -64,11 +64,11 @@ static void check_ungrouped_columns(Node *node, ParseState *pstate, Query *qry,
static bool check_ungrouped_columns_walker(Node *node,
check_ungrouped_columns_context *context);
static void finalize_grouping_exprs(Node *node, ParseState *pstate, Query *qry,
List *groupClauses, PlannerInfo *root,
bool have_non_var_grouping);
List *groupClauses, PlannerInfo *root,
bool have_non_var_grouping);
static bool finalize_grouping_exprs_walker(Node *node,
check_ungrouped_columns_context *context);
static void check_agglevels_and_constraints(ParseState *pstate,Node *expr);
static void check_agglevels_and_constraints(ParseState *pstate, Node *expr);
static List *expand_groupingset_node(GroupingSet *gs);
/*
@ -246,9 +246,9 @@ transformGroupingFunc(ParseState *pstate, GroupingFunc *p)
foreach(lc, args)
{
Node *current_result;
Node *current_result;
current_result = transformExpr(pstate, (Node*) lfirst(lc), pstate->p_expr_kind);
current_result = transformExpr(pstate, (Node *) lfirst(lc), pstate->p_expr_kind);
/* acceptability of expressions is checked later */
@ -284,7 +284,7 @@ check_agglevels_and_constraints(ParseState *pstate, Node *expr)
if (isAgg)
{
Aggref *agg = (Aggref *) expr;
Aggref *agg = (Aggref *) expr;
directargs = agg->aggdirectargs;
args = agg->args;
@ -335,7 +335,11 @@ check_agglevels_and_constraints(ParseState *pstate, Node *expr)
Assert(false); /* can't happen */
break;
case EXPR_KIND_OTHER:
/* Accept aggregate/grouping here; caller must throw error if wanted */
/*
* Accept aggregate/grouping here; caller must throw error if
* wanted
*/
break;
case EXPR_KIND_JOIN_ON:
case EXPR_KIND_JOIN_USING:
@ -348,7 +352,11 @@ check_agglevels_and_constraints(ParseState *pstate, Node *expr)
case EXPR_KIND_FROM_SUBSELECT:
/* Should only be possible in a LATERAL subquery */
Assert(pstate->p_lateral_active);
/* Aggregate/grouping scope rules make it worth being explicit here */
/*
* Aggregate/grouping scope rules make it worth being explicit
* here
*/
if (isAgg)
err = _("aggregate functions are not allowed in FROM clause of their own query level");
else
@ -932,7 +940,7 @@ transformWindowFuncCall(ParseState *pstate, WindowFunc *wfunc,
void
parseCheckAggregates(ParseState *pstate, Query *qry)
{
List *gset_common = NIL;
List *gset_common = NIL;
List *groupClauses = NIL;
List *groupClauseCommonVars = NIL;
bool have_non_var_grouping;
@ -956,7 +964,7 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
* The limit of 4096 is arbitrary and exists simply to avoid resource
* issues from pathological constructs.
*/
List *gsets = expand_grouping_sets(qry->groupingSets, 4096);
List *gsets = expand_grouping_sets(qry->groupingSets, 4096);
if (!gsets)
ereport(ERROR,
@ -964,8 +972,8 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
errmsg("too many grouping sets present (max 4096)"),
parser_errposition(pstate,
qry->groupClause
? exprLocation((Node *) qry->groupClause)
: exprLocation((Node *) qry->groupingSets))));
? exprLocation((Node *) qry->groupClause)
: exprLocation((Node *) qry->groupingSets))));
/*
* The intersection will often be empty, so help things along by
@ -985,9 +993,9 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
/*
* If there was only one grouping set in the expansion, AND if the
* groupClause is non-empty (meaning that the grouping set is not empty
* either), then we can ditch the grouping set and pretend we just had
* a normal GROUP BY.
* groupClause is non-empty (meaning that the grouping set is not
* empty either), then we can ditch the grouping set and pretend we
* just had a normal GROUP BY.
*/
if (list_length(gsets) == 1 && qry->groupClause)
qry->groupingSets = NIL;
@ -1012,13 +1020,13 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
* Build a list of the acceptable GROUP BY expressions for use by
* check_ungrouped_columns().
*
* We get the TLE, not just the expr, because GROUPING wants to know
* the sortgroupref.
* We get the TLE, not just the expr, because GROUPING wants to know the
* sortgroupref.
*/
foreach(l, qry->groupClause)
{
SortGroupClause *grpcl = (SortGroupClause *) lfirst(l);
TargetEntry *expr;
TargetEntry *expr;
expr = get_sortgroupclause_tle(grpcl, qry->targetList);
if (expr == NULL)
@ -1052,13 +1060,14 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
* scans. (Note we have to flatten aliases before this.)
*
* Track Vars that are included in all grouping sets separately in
* groupClauseCommonVars, since these are the only ones we can use to check
* for functional dependencies.
* groupClauseCommonVars, since these are the only ones we can use to
* check for functional dependencies.
*/
have_non_var_grouping = false;
foreach(l, groupClauses)
{
TargetEntry *tle = lfirst(l);
if (!IsA(tle->expr, Var))
{
have_non_var_grouping = true;
@ -1335,7 +1344,7 @@ check_ungrouped_columns_walker(Node *node,
/*
* finalize_grouping_exprs -
* Scan the given expression tree for GROUPING() and related calls,
* and validate and process their arguments.
* and validate and process their arguments.
*
* This is split out from check_ungrouped_columns above because it needs
* to modify the nodes (which it does in-place, not via a mutator) while
@ -1411,19 +1420,19 @@ finalize_grouping_exprs_walker(Node *node,
GroupingFunc *grp = (GroupingFunc *) node;
/*
* We only need to check GroupingFunc nodes at the exact level to which
* they belong, since they cannot mix levels in arguments.
* We only need to check GroupingFunc nodes at the exact level to
* which they belong, since they cannot mix levels in arguments.
*/
if ((int) grp->agglevelsup == context->sublevels_up)
{
ListCell *lc;
List *ref_list = NIL;
ListCell *lc;
List *ref_list = NIL;
foreach(lc, grp->args)
{
Node *expr = lfirst(lc);
Index ref = 0;
Node *expr = lfirst(lc);
Index ref = 0;
if (context->root)
expr = flatten_join_alias_vars(context->root, expr);
@ -1436,7 +1445,7 @@ finalize_grouping_exprs_walker(Node *node,
if (IsA(expr, Var))
{
Var *var = (Var *) expr;
Var *var = (Var *) expr;
if (var->varlevelsup == context->sublevels_up)
{
@ -1517,10 +1526,10 @@ finalize_grouping_exprs_walker(Node *node,
*
* For SET nodes, recursively expand contained CUBE and ROLLUP.
*/
static List*
static List *
expand_groupingset_node(GroupingSet *gs)
{
List * result = NIL;
List *result = NIL;
switch (gs->kind)
{
@ -1540,8 +1549,8 @@ expand_groupingset_node(GroupingSet *gs)
while (curgroup_size > 0)
{
List *current_result = NIL;
int i = curgroup_size;
List *current_result = NIL;
int i = curgroup_size;
foreach(lc, rollup_val)
{
@ -1568,10 +1577,10 @@ expand_groupingset_node(GroupingSet *gs)
case GROUPING_SET_CUBE:
{
List *cube_list = gs->content;
int number_bits = list_length(cube_list);
uint32 num_sets;
uint32 i;
List *cube_list = gs->content;
int number_bits = list_length(cube_list);
uint32 num_sets;
uint32 i;
/* parser should cap this much lower */
Assert(number_bits < 31);
@ -1580,9 +1589,9 @@ expand_groupingset_node(GroupingSet *gs)
for (i = 0; i < num_sets; i++)
{
List *current_result = NIL;
ListCell *lc;
uint32 mask = 1U;
List *current_result = NIL;
ListCell *lc;
uint32 mask = 1U;
foreach(lc, cube_list)
{
@ -1611,7 +1620,7 @@ expand_groupingset_node(GroupingSet *gs)
foreach(lc, gs->content)
{
List *current_result = expand_groupingset_node(lfirst(lc));
List *current_result = expand_groupingset_node(lfirst(lc));
result = list_concat(result, current_result);
}
@ -1625,8 +1634,9 @@ expand_groupingset_node(GroupingSet *gs)
static int
cmp_list_len_asc(const void *a, const void *b)
{
int la = list_length(*(List*const*)a);
int lb = list_length(*(List*const*)b);
int la = list_length(*(List *const *) a);
int lb = list_length(*(List *const *) b);
return (la > lb) ? 1 : (la == lb) ? 0 : -1;
}
@ -1641,7 +1651,7 @@ List *
expand_grouping_sets(List *groupingSets, int limit)
{
List *expanded_groups = NIL;
List *result = NIL;
List *result = NIL;
double numsets = 1;
ListCell *lc;
@ -1650,7 +1660,7 @@ expand_grouping_sets(List *groupingSets, int limit)
foreach(lc, groupingSets)
{
List *current_result = NIL;
List *current_result = NIL;
GroupingSet *gs = lfirst(lc);
current_result = expand_groupingset_node(gs);
@ -1666,9 +1676,9 @@ expand_grouping_sets(List *groupingSets, int limit)
}
/*
* Do cartesian product between sublists of expanded_groups.
* While at it, remove any duplicate elements from individual
* grouping sets (we must NOT change the number of sets though)
* Do cartesian product between sublists of expanded_groups. While at it,
* remove any duplicate elements from individual grouping sets (we must
* NOT change the number of sets though)
*/
foreach(lc, (List *) linitial(expanded_groups))
@ -1698,16 +1708,16 @@ expand_grouping_sets(List *groupingSets, int limit)
if (list_length(result) > 1)
{
int result_len = list_length(result);
List **buf = palloc(sizeof(List*) * result_len);
List **ptr = buf;
int result_len = list_length(result);
List **buf = palloc(sizeof(List *) * result_len);
List **ptr = buf;
foreach(lc, result)
{
*ptr++ = lfirst(lc);
}
qsort(buf, result_len, sizeof(List*), cmp_list_len_asc);
qsort(buf, result_len, sizeof(List *), cmp_list_len_asc);
result = NIL;
ptr = buf;

View File

@ -82,7 +82,7 @@ static TargetEntry *findTargetlistEntrySQL99(ParseState *pstate, Node *node,
List **tlist, ParseExprKind exprKind);
static int get_matching_location(int sortgroupref,
List *sortgrouprefs, List *exprs);
static List *resolve_unique_index_expr(ParseState *pstate, InferClause * infer,
static List *resolve_unique_index_expr(ParseState *pstate, InferClause *infer,
Relation heapRel);
static List *addTargetToGroupList(ParseState *pstate, TargetEntry *tle,
List *grouplist, List *targetlist, int location,
@ -426,14 +426,15 @@ transformJoinOnClause(ParseState *pstate, JoinExpr *j, List *namespace)
static RangeTblEntry *
transformTableSampleEntry(ParseState *pstate, RangeTableSample *rv)
{
RangeTblEntry *rte = NULL;
RangeTblEntry *rte = NULL;
CommonTableExpr *cte = NULL;
TableSampleClause *tablesample = NULL;
/* if relation has an unqualified name, it might be a CTE reference */
if (!rv->relation->schemaname)
{
Index levelsup;
Index levelsup;
cte = scanNameSpaceForCTE(pstate, rv->relation->relname, &levelsup);
}
@ -443,7 +444,7 @@ transformTableSampleEntry(ParseState *pstate, RangeTableSample *rv)
if (!rte ||
(rte->relkind != RELKIND_RELATION &&
rte->relkind != RELKIND_MATVIEW))
rte->relkind != RELKIND_MATVIEW))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("TABLESAMPLE clause can only be used on tables and materialized views"),
@ -1167,7 +1168,7 @@ transformFromClauseItem(ParseState *pstate, Node *n,
else if (IsA(n, RangeTableSample))
{
/* Tablesample reference */
RangeTableSample *rv = (RangeTableSample *) n;
RangeTableSample *rv = (RangeTableSample *) n;
RangeTblRef *rtr;
RangeTblEntry *rte = NULL;
int rtindex;
@ -1738,9 +1739,9 @@ findTargetlistEntrySQL99(ParseState *pstate, Node *node, List **tlist,
* CUBE or ROLLUP can be nested inside GROUPING SETS (but not the reverse),
* and we leave that alone if we find it. But if we see GROUPING SETS inside
* GROUPING SETS, we can flatten and normalize as follows:
* GROUPING SETS (a, (b,c), GROUPING SETS ((c,d),(e)), (f,g))
* GROUPING SETS (a, (b,c), GROUPING SETS ((c,d),(e)), (f,g))
* becomes
* GROUPING SETS ((a), (b,c), (c,d), (e), (f,g))
* GROUPING SETS ((a), (b,c), (c,d), (e), (f,g))
*
* This is per the spec's syntax transformations, but these are the only such
* transformations we do in parse analysis, so that queries retain the
@ -1750,12 +1751,12 @@ findTargetlistEntrySQL99(ParseState *pstate, Node *node, List **tlist,
*
* When we're done, the resulting list should contain only these possible
* elements:
* - an expression
* - a CUBE or ROLLUP with a list of expressions nested 2 deep
* - a GROUPING SET containing any of:
* - expression lists
* - empty grouping sets
* - CUBE or ROLLUP nodes with lists nested 2 deep
* - an expression
* - a CUBE or ROLLUP with a list of expressions nested 2 deep
* - a GROUPING SET containing any of:
* - expression lists
* - empty grouping sets
* - CUBE or ROLLUP nodes with lists nested 2 deep
* The return is a new list, but doesn't deep-copy the old nodes except for
* GroupingSet nodes.
*
@ -1775,7 +1776,8 @@ flatten_grouping_sets(Node *expr, bool toplevel, bool *hasGroupingSets)
{
case T_RowExpr:
{
RowExpr *r = (RowExpr *) expr;
RowExpr *r = (RowExpr *) expr;
if (r->row_format == COERCE_IMPLICIT_CAST)
return flatten_grouping_sets((Node *) r->args,
false, NULL);
@ -1792,7 +1794,8 @@ flatten_grouping_sets(Node *expr, bool toplevel, bool *hasGroupingSets)
/*
* at the top level, we skip over all empty grouping sets; the
* caller can supply the canonical GROUP BY () if nothing is left.
* caller can supply the canonical GROUP BY () if nothing is
* left.
*/
if (toplevel && gset->kind == GROUPING_SET_EMPTY)
@ -1800,15 +1803,15 @@ flatten_grouping_sets(Node *expr, bool toplevel, bool *hasGroupingSets)
foreach(l2, gset->content)
{
Node *n2 = flatten_grouping_sets(lfirst(l2), false, NULL);
Node *n2 = flatten_grouping_sets(lfirst(l2), false, NULL);
result_set = lappend(result_set, n2);
}
/*
* At top level, keep the grouping set node; but if we're in a nested
* grouping set, then we need to concat the flattened result into the
* outer list if it's simply nested.
* At top level, keep the grouping set node; but if we're in a
* nested grouping set, then we need to concat the flattened
* result into the outer list if it's simply nested.
*/
if (toplevel || (gset->kind != GROUPING_SET_SETS))
@ -1823,12 +1826,13 @@ flatten_grouping_sets(Node *expr, bool toplevel, bool *hasGroupingSets)
List *result = NIL;
ListCell *l;
foreach(l, (List *)expr)
foreach(l, (List *) expr)
{
Node *n = flatten_grouping_sets(lfirst(l), toplevel, hasGroupingSets);
Node *n = flatten_grouping_sets(lfirst(l), toplevel, hasGroupingSets);
if (n != (Node *) NIL)
{
if (IsA(n,List))
if (IsA(n, List))
result = list_concat(result, (List *) n);
else
result = lappend(result, n);
@ -1888,15 +1892,15 @@ transformGroupClauseExpr(List **flatresult, Bitmapset *seen_local,
* (Duplicates in grouping sets can affect the number of returned
* rows, so can't be dropped indiscriminately.)
*
* Since we don't care about anything except the sortgroupref,
* we can use a bitmapset rather than scanning lists.
* Since we don't care about anything except the sortgroupref, we can
* use a bitmapset rather than scanning lists.
*/
if (bms_is_member(tle->ressortgroupref,seen_local))
if (bms_is_member(tle->ressortgroupref, seen_local))
return 0;
/*
* If we're already in the flat clause list, we don't need
* to consider adding ourselves again.
* If we're already in the flat clause list, we don't need to consider
* adding ourselves again.
*/
found = targetIsInSortList(tle, InvalidOid, *flatresult);
if (found)
@ -1928,6 +1932,7 @@ transformGroupClauseExpr(List **flatresult, Bitmapset *seen_local,
if (sc->tleSortGroupRef == tle->ressortgroupref)
{
SortGroupClause *grpc = copyObject(sc);
if (!toplevel)
grpc->nulls_first = false;
*flatresult = lappend(*flatresult, grpc);
@ -1983,17 +1988,18 @@ transformGroupClauseList(List **flatresult,
foreach(gl, list)
{
Node *gexpr = (Node *) lfirst(gl);
Node *gexpr = (Node *) lfirst(gl);
Index ref = transformGroupClauseExpr(flatresult,
seen_local,
pstate,
gexpr,
targetlist,
sortClause,
exprKind,
useSQL99,
toplevel);
Index ref = transformGroupClauseExpr(flatresult,
seen_local,
pstate,
gexpr,
targetlist,
sortClause,
exprKind,
useSQL99,
toplevel);
if (ref > 0)
{
seen_local = bms_add_member(seen_local, ref);
@ -2036,14 +2042,14 @@ transformGroupingSet(List **flatresult,
foreach(gl, gset->content)
{
Node *n = lfirst(gl);
Node *n = lfirst(gl);
if (IsA(n, List))
{
List *l = transformGroupClauseList(flatresult,
pstate, (List *) n,
targetlist, sortClause,
exprKind, useSQL99, false);
List *l = transformGroupClauseList(flatresult,
pstate, (List *) n,
targetlist, sortClause,
exprKind, useSQL99, false);
content = lappend(content, makeGroupingSet(GROUPING_SET_SIMPLE,
l,
@ -2055,20 +2061,20 @@ transformGroupingSet(List **flatresult,
content = lappend(content, transformGroupingSet(flatresult,
pstate, gset2,
targetlist, sortClause,
exprKind, useSQL99, false));
targetlist, sortClause,
exprKind, useSQL99, false));
}
else
{
Index ref = transformGroupClauseExpr(flatresult,
NULL,
pstate,
n,
targetlist,
sortClause,
exprKind,
useSQL99,
false);
Index ref = transformGroupClauseExpr(flatresult,
NULL,
pstate,
n,
targetlist,
sortClause,
exprKind,
useSQL99,
false);
content = lappend(content, makeGroupingSet(GROUPING_SET_SIMPLE,
list_make1_int(ref),
@ -2121,7 +2127,7 @@ transformGroupingSet(List **flatresult,
*
* pstate ParseState
* grouplist clause to transform
* groupingSets reference to list to contain the grouping set tree
* groupingSets reference to list to contain the grouping set tree
* targetlist reference to TargetEntry list
* sortClause ORDER BY clause (SortGroupClause nodes)
* exprKind expression kind
@ -2136,34 +2142,34 @@ transformGroupClause(ParseState *pstate, List *grouplist, List **groupingSets,
List *flat_grouplist;
List *gsets = NIL;
ListCell *gl;
bool hasGroupingSets = false;
bool hasGroupingSets = false;
Bitmapset *seen_local = NULL;
/*
* Recursively flatten implicit RowExprs. (Technically this is only
* needed for GROUP BY, per the syntax rules for grouping sets, but
* we do it anyway.)
* Recursively flatten implicit RowExprs. (Technically this is only needed
* for GROUP BY, per the syntax rules for grouping sets, but we do it
* anyway.)
*/
flat_grouplist = (List *) flatten_grouping_sets((Node *) grouplist,
true,
&hasGroupingSets);
/*
* If the list is now empty, but hasGroupingSets is true, it's because
* we elided redundant empty grouping sets. Restore a single empty
* grouping set to leave a canonical form: GROUP BY ()
* If the list is now empty, but hasGroupingSets is true, it's because we
* elided redundant empty grouping sets. Restore a single empty grouping
* set to leave a canonical form: GROUP BY ()
*/
if (flat_grouplist == NIL && hasGroupingSets)
{
flat_grouplist = list_make1(makeGroupingSet(GROUPING_SET_EMPTY,
NIL,
exprLocation((Node *) grouplist)));
exprLocation((Node *) grouplist)));
}
foreach(gl, flat_grouplist)
{
Node *gexpr = (Node *) lfirst(gl);
Node *gexpr = (Node *) lfirst(gl);
if (IsA(gexpr, GroupingSet))
{
@ -2184,17 +2190,17 @@ transformGroupClause(ParseState *pstate, List *grouplist, List **groupingSets,
gsets = lappend(gsets,
transformGroupingSet(&result,
pstate, gset,
targetlist, sortClause,
exprKind, useSQL99, true));
targetlist, sortClause,
exprKind, useSQL99, true));
break;
}
}
else
{
Index ref = transformGroupClauseExpr(&result, seen_local,
pstate, gexpr,
targetlist, sortClause,
exprKind, useSQL99, true);
Index ref = transformGroupClauseExpr(&result, seen_local,
pstate, gexpr,
targetlist, sortClause,
exprKind, useSQL99, true);
if (ref > 0)
{
@ -2661,9 +2667,9 @@ resolve_unique_index_expr(ParseState *pstate, InferClause *infer,
foreach(l, infer->indexElems)
{
IndexElem *ielem = (IndexElem *) lfirst(l);
InferenceElem *pInfer = makeNode(InferenceElem);
Node *parse;
IndexElem *ielem = (IndexElem *) lfirst(l);
InferenceElem *pInfer = makeNode(InferenceElem);
Node *parse;
/*
* Raw grammar re-uses CREATE INDEX infrastructure for unique index
@ -2684,7 +2690,7 @@ resolve_unique_index_expr(ParseState *pstate, InferClause *infer,
if (ielem->nulls_ordering != SORTBY_NULLS_DEFAULT)
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("NULLS FIRST/LAST is not allowed in ON CONFLICT clause"),
errmsg("NULLS FIRST/LAST is not allowed in ON CONFLICT clause"),
parser_errposition(pstate,
exprLocation((Node *) infer))));
@ -2767,7 +2773,7 @@ transformOnConflictArbiter(ParseState *pstate,
errmsg("ON CONFLICT DO UPDATE requires inference specification or constraint name"),
errhint("For example, ON CONFLICT (<column>)."),
parser_errposition(pstate,
exprLocation((Node *) onConflictClause))));
exprLocation((Node *) onConflictClause))));
/*
* To simplify certain aspects of its design, speculative insertion into
@ -2776,9 +2782,9 @@ transformOnConflictArbiter(ParseState *pstate,
if (IsCatalogRelation(pstate->p_target_relation))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("ON CONFLICT not supported with system catalog tables"),
errmsg("ON CONFLICT not supported with system catalog tables"),
parser_errposition(pstate,
exprLocation((Node *) onConflictClause))));
exprLocation((Node *) onConflictClause))));
/* Same applies to table used by logical decoding as catalog table */
if (RelationIsUsedAsCatalogTable(pstate->p_target_relation))
@ -2787,7 +2793,7 @@ transformOnConflictArbiter(ParseState *pstate,
errmsg("ON CONFLICT not supported on table \"%s\" used as a catalog table",
RelationGetRelationName(pstate->p_target_relation)),
parser_errposition(pstate,
exprLocation((Node *) onConflictClause))));
exprLocation((Node *) onConflictClause))));
/* ON CONFLICT DO NOTHING does not require an inference clause */
if (infer)
@ -2795,9 +2801,8 @@ transformOnConflictArbiter(ParseState *pstate,
List *save_namespace;
/*
* While we process the arbiter expressions, accept only
* non-qualified references to the target table. Hide any other
* relations.
* While we process the arbiter expressions, accept only non-qualified
* references to the target table. Hide any other relations.
*/
save_namespace = pstate->p_namespace;
pstate->p_namespace = NIL;
@ -2806,7 +2811,7 @@ transformOnConflictArbiter(ParseState *pstate,
if (infer->indexElems)
*arbiterExpr = resolve_unique_index_expr(pstate, infer,
pstate->p_target_relation);
pstate->p_target_relation);
/*
* Handling inference WHERE clause (for partial unique index

View File

@ -778,14 +778,15 @@ TableSampleClause *
ParseTableSample(ParseState *pstate, char *samplemethod, Node *repeatable,
List *sampleargs, int location)
{
HeapTuple tuple;
HeapTuple tuple;
Form_pg_tablesample_method tsm;
Form_pg_proc procform;
TableSampleClause *tablesample;
List *fargs;
ListCell *larg;
int nargs, initnargs;
Oid init_arg_types[FUNC_MAX_ARGS];
List *fargs;
ListCell *larg;
int nargs,
initnargs;
Oid init_arg_types[FUNC_MAX_ARGS];
/* Load the tablesample method */
tuple = SearchSysCache1(TABLESAMPLEMETHODNAME, PointerGetDatum(samplemethod));
@ -817,7 +818,7 @@ ParseTableSample(ParseState *pstate, char *samplemethod, Node *repeatable,
tuple = SearchSysCache1(PROCOID,
ObjectIdGetDatum(tablesample->tsminit));
if (!HeapTupleIsValid(tuple)) /* should not happen */
if (!HeapTupleIsValid(tuple)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u",
tablesample->tsminit);
@ -826,15 +827,15 @@ ParseTableSample(ParseState *pstate, char *samplemethod, Node *repeatable,
Assert(initnargs >= 3);
/*
* First parameter is used to pass the SampleScanState, second is
* seed (REPEATABLE), skip the processing for them here, just assert
* that the types are correct.
* First parameter is used to pass the SampleScanState, second is seed
* (REPEATABLE), skip the processing for them here, just assert that the
* types are correct.
*/
Assert(procform->proargtypes.values[0] == INTERNALOID);
Assert(procform->proargtypes.values[1] == INT4OID);
initnargs -= 2;
memcpy(init_arg_types, procform->proargtypes.values + 2,
initnargs * sizeof(Oid));
initnargs * sizeof(Oid));
/* Now we are done with the catalog */
ReleaseSysCache(tuple);
@ -842,7 +843,7 @@ ParseTableSample(ParseState *pstate, char *samplemethod, Node *repeatable,
/* Process repeatable (seed) */
if (repeatable != NULL)
{
Node *arg = repeatable;
Node *arg = repeatable;
if (arg && IsA(arg, A_Const))
{
@ -851,7 +852,7 @@ ParseTableSample(ParseState *pstate, char *samplemethod, Node *repeatable,
if (con->val.type == T_Null)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("REPEATABLE clause must be NOT NULL numeric value"),
errmsg("REPEATABLE clause must be NOT NULL numeric value"),
parser_errposition(pstate, con->location)));
}
@ -867,21 +868,21 @@ ParseTableSample(ParseState *pstate, char *samplemethod, Node *repeatable,
if (list_length(sampleargs) != initnargs)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
errmsg_plural("tablesample method \"%s\" expects %d argument got %d",
"tablesample method \"%s\" expects %d arguments got %d",
initnargs,
samplemethod,
initnargs, list_length(sampleargs)),
parser_errposition(pstate, location)));
errmsg_plural("tablesample method \"%s\" expects %d argument got %d",
"tablesample method \"%s\" expects %d arguments got %d",
initnargs,
samplemethod,
initnargs, list_length(sampleargs)),
parser_errposition(pstate, location)));
/* Transform the arguments, typecasting them as needed. */
fargs = NIL;
nargs = 0;
foreach(larg, sampleargs)
{
Node *inarg = (Node *) lfirst(larg);
Node *arg = transformExpr(pstate, inarg, EXPR_KIND_FROM_FUNCTION);
Oid argtype = exprType(arg);
Node *inarg = (Node *) lfirst(larg);
Node *arg = transformExpr(pstate, inarg, EXPR_KIND_FROM_FUNCTION);
Oid argtype = exprType(arg);
if (argtype != init_arg_types[nargs])
{
@ -889,12 +890,12 @@ ParseTableSample(ParseState *pstate, char *samplemethod, Node *repeatable,
COERCION_IMPLICIT))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("wrong parameter %d for tablesample method \"%s\"",
nargs + 1, samplemethod),
errdetail("Expected type %s got %s.",
format_type_be(init_arg_types[nargs]),
format_type_be(argtype)),
parser_errposition(pstate, exprLocation(inarg))));
errmsg("wrong parameter %d for tablesample method \"%s\"",
nargs + 1, samplemethod),
errdetail("Expected type %s got %s.",
format_type_be(init_arg_types[nargs]),
format_type_be(argtype)),
parser_errposition(pstate, exprLocation(inarg))));
arg = coerce_type(pstate, arg, argtype, init_arg_types[nargs], -1,
COERCION_IMPLICIT, COERCE_IMPLICIT_CAST, -1);

View File

@ -530,8 +530,8 @@ updateFuzzyAttrMatchState(int fuzzy_rte_penalty,
FuzzyAttrMatchState *fuzzystate, RangeTblEntry *rte,
const char *actual, const char *match, int attnum)
{
int columndistance;
int matchlen;
int columndistance;
int matchlen;
/* Bail before computing the Levenshtein distance if there's no hope. */
if (fuzzy_rte_penalty > fuzzystate->distance)
@ -550,7 +550,7 @@ updateFuzzyAttrMatchState(int fuzzy_rte_penalty,
varstr_levenshtein_less_equal(actual, strlen(actual), match, matchlen,
1, 1, 1,
fuzzystate->distance + 1
- fuzzy_rte_penalty);
- fuzzy_rte_penalty);
/*
* If more than half the characters are different, don't treat it as a
@ -560,8 +560,8 @@ updateFuzzyAttrMatchState(int fuzzy_rte_penalty,
return;
/*
* From this point on, we can ignore the distinction between the
* RTE-name distance and the column-name distance.
* From this point on, we can ignore the distinction between the RTE-name
* distance and the column-name distance.
*/
columndistance += fuzzy_rte_penalty;
@ -581,11 +581,11 @@ updateFuzzyAttrMatchState(int fuzzy_rte_penalty,
else if (columndistance == fuzzystate->distance)
{
/*
* This match distance may equal a prior match within this same
* range table. When that happens, the prior match may also be
* given, but only if there is no more than two equally distant
* matches from the RTE (in turn, our caller will only accept
* two equally distant matches overall).
* This match distance may equal a prior match within this same range
* table. When that happens, the prior match may also be given, but
* only if there is no more than two equally distant matches from the
* RTE (in turn, our caller will only accept two equally distant
* matches overall).
*/
if (AttributeNumberIsValid(fuzzystate->second))
{
@ -606,9 +606,9 @@ updateFuzzyAttrMatchState(int fuzzy_rte_penalty,
else if (fuzzystate->distance <= MAX_FUZZY_DISTANCE)
{
/*
* Record as provisional first match (this can occasionally
* occur because previous lowest distance was "too low a
* bar", rather than being associated with a real match)
* Record as provisional first match (this can occasionally occur
* because previous lowest distance was "too low a bar", rather
* than being associated with a real match)
*/
fuzzystate->rfirst = rte;
fuzzystate->first = attnum;
@ -820,8 +820,8 @@ searchRangeTableForCol(ParseState *pstate, const char *alias, char *colname,
foreach(l, pstate->p_rtable)
{
RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
int fuzzy_rte_penalty = 0;
RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
int fuzzy_rte_penalty = 0;
/*
* Typically, it is not useful to look for matches within join
@ -851,7 +851,7 @@ searchRangeTableForCol(ParseState *pstate, const char *alias, char *colname,
*/
if (scanRTEForColumn(orig_pstate, rte, colname, location,
fuzzy_rte_penalty, fuzzystate)
&& fuzzy_rte_penalty == 0)
&& fuzzy_rte_penalty == 0)
{
fuzzystate->rfirst = rte;
fuzzystate->first = InvalidAttrNumber;
@ -3040,8 +3040,8 @@ void
errorMissingColumn(ParseState *pstate,
char *relname, char *colname, int location)
{
FuzzyAttrMatchState *state;
char *closestfirst = NULL;
FuzzyAttrMatchState *state;
char *closestfirst = NULL;
/*
* Search the entire rtable looking for possible matches. If we find one,
@ -3056,10 +3056,10 @@ errorMissingColumn(ParseState *pstate,
* Extract closest col string for best match, if any.
*
* Infer an exact match referenced despite not being visible from the fact
* that an attribute number was not present in state passed back -- this is
* what is reported when !closestfirst. There might also be an exact match
* that was qualified with an incorrect alias, in which case closestfirst
* will be set (so hint is the same as generic fuzzy case).
* that an attribute number was not present in state passed back -- this
* is what is reported when !closestfirst. There might also be an exact
* match that was qualified with an incorrect alias, in which case
* closestfirst will be set (so hint is the same as generic fuzzy case).
*/
if (state->rfirst && AttributeNumberIsValid(state->first))
closestfirst = strVal(list_nth(state->rfirst->eref->colnames,
@ -3074,19 +3074,19 @@ errorMissingColumn(ParseState *pstate,
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
relname ?
errmsg("column %s.%s does not exist", relname, colname):
errmsg("column %s.%s does not exist", relname, colname) :
errmsg("column \"%s\" does not exist", colname),
state->rfirst ? closestfirst ?
errhint("Perhaps you meant to reference the column \"%s\".\"%s\".",
state->rfirst->eref->aliasname, closestfirst):
errhint("Perhaps you meant to reference the column \"%s\".\"%s\".",
state->rfirst->eref->aliasname, closestfirst) :
errhint("There is a column named \"%s\" in table \"%s\", but it cannot be referenced from this part of the query.",
colname, state->rfirst->eref->aliasname): 0,
colname, state->rfirst->eref->aliasname) : 0,
parser_errposition(pstate, location)));
}
else
{
/* Handle case where there are two equally useful column hints */
char *closestsecond;
char *closestsecond;
closestsecond = strVal(list_nth(state->rsecond->eref->colnames,
state->second - 1));
@ -3094,7 +3094,7 @@ errorMissingColumn(ParseState *pstate,
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
relname ?
errmsg("column %s.%s does not exist", relname, colname):
errmsg("column %s.%s does not exist", relname, colname) :
errmsg("column \"%s\" does not exist", colname),
errhint("Perhaps you meant to reference the column \"%s\".\"%s\" or the column \"%s\".\"%s\".",
state->rfirst->eref->aliasname, closestfirst,

View File

@ -797,7 +797,7 @@ fail:
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("invalid type name \"%s\"", str)));
return NULL; /* keep compiler quiet */
return NULL; /* keep compiler quiet */
}
/*

View File

@ -1804,8 +1804,8 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("inherited relation \"%s\" is not a table or foreign table",
inh->relname)));
errmsg("inherited relation \"%s\" is not a table or foreign table",
inh->relname)));
for (count = 0; count < rel->rd_att->natts; count++)
{
Form_pg_attribute inhattr = rel->rd_att->attrs[count];
@ -2496,7 +2496,7 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
case AT_AlterColumnType:
{
ColumnDef *def = (ColumnDef *) cmd->def;
ColumnDef *def = (ColumnDef *) cmd->def;
/*
* For ALTER COLUMN TYPE, transform the USING clause if