mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
pgindent run for 9.4
This includes removing tabs after periods in C comments, which was applied to back branches, so this change should not effect backpatching.
This commit is contained in:
@ -79,7 +79,7 @@ static void transformLockingClause(ParseState *pstate, Query *qry,
|
||||
* Optionally, information about $n parameter types can be supplied.
|
||||
* References to $n indexes not defined by paramTypes[] are disallowed.
|
||||
*
|
||||
* The result is a Query node. Optimizable statements require considerable
|
||||
* The result is a Query node. Optimizable statements require considerable
|
||||
* transformation, while utility-type statements are simply hung off
|
||||
* a dummy CMD_UTILITY Query node.
|
||||
*/
|
||||
@ -457,7 +457,7 @@ 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
|
||||
* 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
|
||||
@ -642,7 +642,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
|
||||
* We must assign collations now because assign_query_collations
|
||||
* doesn't process rangetable entries. We just assign all the
|
||||
* collations independently in each row, and don't worry about
|
||||
* whether they are consistent vertically. The outer INSERT query
|
||||
* whether they are consistent vertically. The outer INSERT query
|
||||
* isn't going to care about the collations of the VALUES columns,
|
||||
* so it's not worth the effort to identify a common collation for
|
||||
* each one here. (But note this does have one user-visible
|
||||
@ -691,7 +691,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Process INSERT ... VALUES with a single VALUES sublist. We treat
|
||||
* Process INSERT ... VALUES with a single VALUES sublist. We treat
|
||||
* this case separately for efficiency. The sublist is just computed
|
||||
* directly as the Query's targetlist, with no VALUES RTE. So it
|
||||
* works just like a SELECT without any FROM.
|
||||
@ -789,7 +789,7 @@ transformInsertRow(ParseState *pstate, List *exprlist,
|
||||
* Check length of expr list. It must not have more expressions than
|
||||
* there are target columns. We allow fewer, but only if no explicit
|
||||
* columns list was given (the remaining columns are implicitly
|
||||
* defaulted). Note we must check this *after* transformation because
|
||||
* defaulted). Note we must check this *after* transformation because
|
||||
* that could expand '*' into multiple items.
|
||||
*/
|
||||
if (list_length(exprlist) > list_length(icolumns))
|
||||
@ -859,7 +859,7 @@ transformInsertRow(ParseState *pstate, List *exprlist,
|
||||
* return -1 if expression isn't a RowExpr or a Var referencing one.
|
||||
*
|
||||
* This is currently used only for hint purposes, so we aren't terribly
|
||||
* tense about recognizing all possible cases. The Var case is interesting
|
||||
* tense about recognizing all possible cases. The Var case is interesting
|
||||
* because that's what we'll get in the INSERT ... SELECT (...) case.
|
||||
*/
|
||||
static int
|
||||
@ -1191,7 +1191,7 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
|
||||
/*
|
||||
* Ordinarily there can't be any current-level Vars in the expression
|
||||
* lists, because the namespace was empty ... but if we're inside CREATE
|
||||
* RULE, then NEW/OLD references might appear. In that case we have to
|
||||
* RULE, then NEW/OLD references might appear. In that case we have to
|
||||
* mark the VALUES RTE as LATERAL.
|
||||
*/
|
||||
if (pstate->p_rtable != NIL &&
|
||||
@ -1234,11 +1234,11 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
|
||||
if (stmt->lockingClause)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s cannot be applied to VALUES",
|
||||
LCS_asString(((LockingClause *)
|
||||
linitial(stmt->lockingClause))->strength))));
|
||||
linitial(stmt->lockingClause))->strength))));
|
||||
|
||||
qry->rtable = pstate->p_rtable;
|
||||
qry->jointree = makeFromExpr(pstate->p_joinlist, NULL);
|
||||
@ -1329,8 +1329,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
|
||||
if (lockingClause)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT",
|
||||
LCS_asString(((LockingClause *)
|
||||
linitial(lockingClause))->strength))));
|
||||
@ -1413,7 +1413,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
|
||||
/*
|
||||
* As a first step towards supporting sort clauses that are expressions
|
||||
* using the output columns, generate a namespace entry that makes the
|
||||
* output columns visible. A Join RTE node is handy for this, since we
|
||||
* 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
|
||||
@ -1493,7 +1493,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
|
||||
* Recursively transform leaves and internal nodes of a set-op tree
|
||||
*
|
||||
* In addition to returning the transformed node, if targetlist isn't NULL
|
||||
* then we return a list of its non-resjunk TargetEntry nodes. For a leaf
|
||||
* then we return a list of its non-resjunk TargetEntry nodes. For a leaf
|
||||
* set-op node these are the actual targetlist entries; otherwise they are
|
||||
* dummy entries created to carry the type, typmod, collation, and location
|
||||
* (for error messages) of each output column of the set-op node. This info
|
||||
@ -1527,16 +1527,16 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt,
|
||||
if (stmt->lockingClause)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT",
|
||||
LCS_asString(((LockingClause *)
|
||||
linitial(stmt->lockingClause))->strength))));
|
||||
linitial(stmt->lockingClause))->strength))));
|
||||
|
||||
/*
|
||||
* If an internal node of a set-op tree has ORDER BY, LIMIT, FOR UPDATE,
|
||||
* or WITH clauses attached, we need to treat it like a leaf node to
|
||||
* generate an independent sub-Query tree. Otherwise, it can be
|
||||
* generate an independent sub-Query tree. Otherwise, it can be
|
||||
* represented by a SetOperationStmt node underneath the parent Query.
|
||||
*/
|
||||
if (stmt->op == SETOP_NONE)
|
||||
@ -1712,7 +1712,7 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt,
|
||||
rescoltypmod = -1;
|
||||
|
||||
/*
|
||||
* Verify the coercions are actually possible. If not, we'd fail
|
||||
* 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.
|
||||
*
|
||||
@ -1721,7 +1721,7 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt,
|
||||
* child query's semantics.
|
||||
*
|
||||
* If a child expression is an UNKNOWN-type Const or Param, we
|
||||
* want to replace it with the coerced expression. This can only
|
||||
* want to replace it with the coerced expression. This can only
|
||||
* happen when the child is a leaf set-op node. It's safe to
|
||||
* replace the expression because if the child query's semantics
|
||||
* depended on the type of this output column, it'd have already
|
||||
@ -2113,8 +2113,8 @@ transformDeclareCursorStmt(ParseState *pstate, DeclareCursorStmt *stmt)
|
||||
if (result->rowMarks != NIL && (stmt->options & CURSOR_OPT_HOLD))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("DECLARE CURSOR WITH HOLD ... %s is not supported",
|
||||
LCS_asString(((RowMarkClause *)
|
||||
linitial(result->rowMarks))->strength)),
|
||||
@ -2124,8 +2124,8 @@ transformDeclareCursorStmt(ParseState *pstate, DeclareCursorStmt *stmt)
|
||||
if (result->rowMarks != NIL && (stmt->options & CURSOR_OPT_SCROLL))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("DECLARE SCROLL CURSOR ... %s is not supported",
|
||||
LCS_asString(((RowMarkClause *)
|
||||
linitial(result->rowMarks))->strength)),
|
||||
@ -2135,8 +2135,8 @@ transformDeclareCursorStmt(ParseState *pstate, DeclareCursorStmt *stmt)
|
||||
if (result->rowMarks != NIL && (stmt->options & CURSOR_OPT_INSENSITIVE))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("DECLARE INSENSITIVE CURSOR ... %s is not supported",
|
||||
LCS_asString(((RowMarkClause *)
|
||||
linitial(result->rowMarks))->strength)),
|
||||
@ -2220,7 +2220,7 @@ transformCreateTableAsStmt(ParseState *pstate, CreateTableAsStmt *stmt)
|
||||
|
||||
/*
|
||||
* A materialized view would either need to save parameters for use in
|
||||
* maintaining/loading the data or prohibit them entirely. The latter
|
||||
* maintaining/loading the data or prohibit them entirely. The latter
|
||||
* seems safer and more sane.
|
||||
*/
|
||||
if (query_contains_extern_params(query))
|
||||
@ -2272,7 +2272,7 @@ LCS_asString(LockClauseStrength strength)
|
||||
case LCS_FORUPDATE:
|
||||
return "FOR UPDATE";
|
||||
}
|
||||
return "FOR some"; /* shouldn't happen */
|
||||
return "FOR some"; /* shouldn't happen */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2286,50 +2286,50 @@ CheckSelectLocking(Query *qry, LockClauseStrength strength)
|
||||
if (qry->setOperations)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT",
|
||||
LCS_asString(strength))));
|
||||
if (qry->distinctClause != NIL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s is not allowed with DISTINCT clause",
|
||||
LCS_asString(strength))));
|
||||
if (qry->groupClause != NIL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s is not allowed with GROUP BY clause",
|
||||
LCS_asString(strength))));
|
||||
if (qry->havingQual != NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s is not allowed with HAVING clause",
|
||||
LCS_asString(strength))));
|
||||
if (qry->hasAggs)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s is not allowed with aggregate functions",
|
||||
LCS_asString(strength))));
|
||||
if (qry->hasWindowFuncs)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s is not allowed with window functions",
|
||||
LCS_asString(strength))));
|
||||
if (expression_returns_set((Node *) qry->targetList))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s is not allowed with set-returning functions in the target list",
|
||||
LCS_asString(strength))));
|
||||
}
|
||||
@ -2407,8 +2407,8 @@ transformLockingClause(ParseState *pstate, Query *qry, LockingClause *lc,
|
||||
if (thisrel->catalogname || thisrel->schemaname)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s must specify unqualified relation names",
|
||||
LCS_asString(lc->strength)),
|
||||
parser_errposition(pstate, thisrel->location)));
|
||||
@ -2440,8 +2440,8 @@ transformLockingClause(ParseState *pstate, Query *qry, LockingClause *lc,
|
||||
case RTE_JOIN:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s cannot be applied to a join",
|
||||
LCS_asString(lc->strength)),
|
||||
parser_errposition(pstate, thisrel->location)));
|
||||
@ -2449,17 +2449,17 @@ transformLockingClause(ParseState *pstate, Query *qry, LockingClause *lc,
|
||||
case RTE_FUNCTION:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s cannot be applied to a function",
|
||||
LCS_asString(lc->strength)),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s cannot be applied to a function",
|
||||
LCS_asString(lc->strength)),
|
||||
parser_errposition(pstate, thisrel->location)));
|
||||
break;
|
||||
case RTE_VALUES:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s cannot be applied to VALUES",
|
||||
LCS_asString(lc->strength)),
|
||||
parser_errposition(pstate, thisrel->location)));
|
||||
@ -2467,10 +2467,10 @@ transformLockingClause(ParseState *pstate, Query *qry, LockingClause *lc,
|
||||
case RTE_CTE:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s cannot be applied to a WITH query",
|
||||
LCS_asString(lc->strength)),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("%s cannot be applied to a WITH query",
|
||||
LCS_asString(lc->strength)),
|
||||
parser_errposition(pstate, thisrel->location)));
|
||||
break;
|
||||
default:
|
||||
@ -2484,8 +2484,8 @@ transformLockingClause(ParseState *pstate, Query *qry, LockingClause *lc,
|
||||
if (rt == NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_TABLE),
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
/*------
|
||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||
errmsg("relation \"%s\" in %s clause not found in FROM clause",
|
||||
thisrel->relname,
|
||||
LCS_asString(lc->strength)),
|
||||
|
@ -52,7 +52,7 @@ ScanKeywordLookup(const char *text,
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* Apply an ASCII-only downcasing. We must not use tolower() since it may
|
||||
* 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++)
|
||||
|
@ -437,7 +437,7 @@ check_agg_arguments(ParseState *pstate,
|
||||
|
||||
/*
|
||||
* Now check for vars/aggs in the direct arguments, and throw error if
|
||||
* needed. Note that we allow a Var of the agg's semantic level, but not
|
||||
* needed. Note that we allow a Var of the agg's semantic level, but not
|
||||
* an Agg of that level. In principle such Aggs could probably be
|
||||
* supported, but it would create an ordering dependency among the
|
||||
* aggregates at execution time. Since the case appears neither to be
|
||||
@ -815,7 +815,7 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
|
||||
/*
|
||||
* 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
|
||||
* taken as equal. We can skip the expense of doing this if no rangetable
|
||||
* entries are RTE_JOIN kind. 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.
|
||||
@ -853,7 +853,7 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
|
||||
*
|
||||
* Note: because we check resjunk tlist elements as well as regular ones,
|
||||
* this will also find ungrouped variables that came from ORDER BY and
|
||||
* WINDOW clauses. For that matter, it's also going to examine the
|
||||
* WINDOW clauses. For that matter, it's also going to examine the
|
||||
* grouping expressions themselves --- but they'll all pass the test ...
|
||||
*/
|
||||
clause = (Node *) qry->targetList;
|
||||
@ -984,7 +984,7 @@ 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
|
||||
* 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))
|
||||
@ -1015,7 +1015,7 @@ check_ungrouped_columns_walker(Node *node,
|
||||
|
||||
/*
|
||||
* Check whether the Var is known functionally dependent on the GROUP
|
||||
* BY columns. If so, we can allow the Var to be used, because the
|
||||
* BY columns. If so, we can allow the Var to be used, because the
|
||||
* grouping is really a no-op for this table. However, this deduction
|
||||
* depends on one or more constraints of the table, so we have to add
|
||||
* those constraints to the query's constraintDeps list, because it's
|
||||
|
@ -149,7 +149,7 @@ transformFromClause(ParseState *pstate, List *frmList)
|
||||
*
|
||||
* If alsoSource is true, add the target to the query's joinlist and
|
||||
* namespace. For INSERT, we don't want the target to be joined to;
|
||||
* it's a destination of tuples, not a source. For UPDATE/DELETE,
|
||||
* it's a destination of tuples, not a source. For UPDATE/DELETE,
|
||||
* we do need to scan or join the target. (NOTE: we do not bother
|
||||
* to check for namespace conflict; we assume that the namespace was
|
||||
* initially empty in these cases.)
|
||||
@ -219,7 +219,7 @@ setTargetTable(ParseState *pstate, RangeVar *relation,
|
||||
* Simplify InhOption (yes/no/default) into boolean yes/no.
|
||||
*
|
||||
* The reason we do things this way is that we don't want to examine the
|
||||
* SQL_inheritance option flag until parse_analyze() is run. Otherwise,
|
||||
* SQL_inheritance option flag until parse_analyze() is run. Otherwise,
|
||||
* we'd do the wrong thing with query strings that intermix SET commands
|
||||
* with queries.
|
||||
*/
|
||||
@ -396,7 +396,7 @@ transformJoinOnClause(ParseState *pstate, JoinExpr *j, List *namespace)
|
||||
/*
|
||||
* The namespace that the join expression should see is just the two
|
||||
* subtrees of the JOIN plus any outer references from upper pstate
|
||||
* levels. Temporarily set this pstate's namespace accordingly. (We need
|
||||
* levels. Temporarily set this pstate's namespace accordingly. (We need
|
||||
* not check for refname conflicts, because transformFromClauseItem()
|
||||
* already did.) All namespace items are marked visible regardless of
|
||||
* LATERAL state.
|
||||
@ -490,7 +490,7 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r)
|
||||
pstate->p_expr_kind = EXPR_KIND_NONE;
|
||||
|
||||
/*
|
||||
* Check that we got something reasonable. Many of these conditions are
|
||||
* Check that we got something reasonable. Many of these conditions are
|
||||
* impossible given restrictions of the grammar, but check 'em anyway.
|
||||
*/
|
||||
if (!IsA(query, Query) ||
|
||||
@ -526,7 +526,7 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r)
|
||||
|
||||
/*
|
||||
* We make lateral_only names of this level visible, whether or not the
|
||||
* RangeFunction is explicitly marked LATERAL. This is needed for SQL
|
||||
* RangeFunction is explicitly marked LATERAL. This is needed for SQL
|
||||
* spec compliance in the case of UNNEST(), and seems useful on
|
||||
* convenience grounds for all functions in FROM.
|
||||
*
|
||||
@ -546,7 +546,7 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r)
|
||||
* node types.
|
||||
*
|
||||
* We have to get this info now, because FigureColname only works on raw
|
||||
* parsetrees. Actually deciding what to do with the names is left up to
|
||||
* parsetrees. Actually deciding what to do with the names is left up to
|
||||
* addRangeTableEntryForFunction.
|
||||
*
|
||||
* Likewise, collect column definition lists if there were any. But
|
||||
@ -570,7 +570,7 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r)
|
||||
* other ways of implementing the SQL-standard UNNEST() syntax.
|
||||
*
|
||||
* If there is any decoration (including a coldeflist), we don't
|
||||
* transform, which probably means a no-such-function error later. We
|
||||
* transform, which probably means a no-such-function error later. We
|
||||
* could alternatively throw an error right now, but that doesn't seem
|
||||
* tremendously helpful. If someone is using any such decoration,
|
||||
* then they're not using the SQL-standard syntax, and they're more
|
||||
@ -682,7 +682,7 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("WITH ORDINALITY cannot be used with a column definition list"),
|
||||
errhint("Put the column definition list inside ROWS FROM()."),
|
||||
errhint("Put the column definition list inside ROWS FROM()."),
|
||||
parser_errposition(pstate,
|
||||
exprLocation((Node *) r->coldeflist))));
|
||||
|
||||
@ -721,10 +721,10 @@ 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.)
|
||||
*
|
||||
* *namespace: receives a List of ParseNamespaceItems for the RTEs exposed
|
||||
* as table/column names by this item. (The lateral_only flags in these items
|
||||
* as table/column names by this item. (The lateral_only flags in these items
|
||||
* are indeterminate and should be explicitly set by the caller before use.)
|
||||
*/
|
||||
static Node *
|
||||
@ -837,7 +837,7 @@ transformFromClauseItem(ParseState *pstate, Node *n,
|
||||
* right side, by temporarily adding them to the pstate's namespace
|
||||
* list. Per SQL:2008, if the join type is not INNER or LEFT then the
|
||||
* left-side names must still be exposed, but it's an error to
|
||||
* reference them. (Stupid design, but that's what it says.) Hence,
|
||||
* reference them. (Stupid design, but that's what it says.) Hence,
|
||||
* we always push them into the namespace, but mark them as not
|
||||
* lateral_ok if the jointype is wrong.
|
||||
*
|
||||
@ -1101,7 +1101,7 @@ transformFromClauseItem(ParseState *pstate, Node *n,
|
||||
*
|
||||
* Note: if there are nested alias-less JOINs, the lower-level ones
|
||||
* will remain in the list although they have neither p_rel_visible
|
||||
* nor p_cols_visible set. We could delete such list items, but it's
|
||||
* nor p_cols_visible set. We could delete such list items, but it's
|
||||
* unclear that it's worth expending cycles to do so.
|
||||
*/
|
||||
if (j->alias != NULL)
|
||||
@ -1438,9 +1438,9 @@ checkTargetlistEntrySQL92(ParseState *pstate, TargetEntry *tle,
|
||||
*
|
||||
* 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
|
||||
@ -1458,7 +1458,7 @@ findTargetlistEntrySQL92(ParseState *pstate, Node *node, List **tlist,
|
||||
*
|
||||
* 1. Bare ColumnName (no qualifier or subscripts)
|
||||
* For a bare identifier, we search for a matching column name
|
||||
* in the existing target list. Multiple matches are an error
|
||||
* in the existing target list. Multiple matches are an error
|
||||
* unless they refer to identical values; for example,
|
||||
* we allow SELECT a, a FROM table ORDER BY a
|
||||
* but not SELECT a AS b, b FROM table ORDER BY b
|
||||
@ -1467,7 +1467,7 @@ findTargetlistEntrySQL92(ParseState *pstate, Node *node, List **tlist,
|
||||
* For GROUP BY, it is incorrect to match the grouping item against
|
||||
* targetlist entries: according to SQL92, an identifier in GROUP BY
|
||||
* is a reference to a column name exposed by FROM, not to a target
|
||||
* list column. However, many implementations (including pre-7.0
|
||||
* list column. However, many implementations (including pre-7.0
|
||||
* PostgreSQL) accept this anyway. So for GROUP BY, we look first
|
||||
* to see if the identifier matches any FROM column name, and only
|
||||
* try for a targetlist name if it doesn't. This ensures that we
|
||||
@ -1625,7 +1625,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.
|
||||
*/
|
||||
@ -1653,7 +1653,7 @@ findTargetlistEntrySQL99(ParseState *pstate, Node *node, List **tlist,
|
||||
|
||||
/*
|
||||
* 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
|
||||
* 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, exprKind,
|
||||
@ -1864,7 +1864,7 @@ transformWindowDefinitions(ParseState *pstate,
|
||||
* <window clause> syntax rule 10 and general rule 1. The frame
|
||||
* clause rule is especially bizarre because it makes "OVER foo"
|
||||
* different from "OVER (foo)", and requires the latter to throw an
|
||||
* error if foo has a nondefault frame clause. Well, ours not to
|
||||
* error if foo has a nondefault frame clause. Well, ours not to
|
||||
* reason why, but we do go out of our way to throw a useful error
|
||||
* message for such cases.
|
||||
*/
|
||||
@ -1967,7 +1967,7 @@ transformDistinctClause(ParseState *pstate,
|
||||
|
||||
/*
|
||||
* The distinctClause should consist of all ORDER BY items followed by all
|
||||
* other non-resjunk targetlist items. There must not be any resjunk
|
||||
* other non-resjunk targetlist items. There must not be any resjunk
|
||||
* ORDER BY items --- that would imply that we are sorting by a value that
|
||||
* isn't necessarily unique within a DISTINCT group, so the results
|
||||
* wouldn't be well-defined. This construction ensures we follow the rule
|
||||
@ -2023,7 +2023,7 @@ transformDistinctClause(ParseState *pstate,
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
is_agg ?
|
||||
errmsg("an aggregate with DISTINCT must have at least one argument") :
|
||||
errmsg("an aggregate with DISTINCT must have at least one argument") :
|
||||
errmsg("SELECT DISTINCT must have at least one column")));
|
||||
|
||||
return result;
|
||||
@ -2104,7 +2104,7 @@ transformDistinctOnClause(ParseState *pstate, List *distinctlist,
|
||||
|
||||
/*
|
||||
* Now add any remaining DISTINCT ON items, using default sort/group
|
||||
* semantics for their data types. (Note: this is pretty questionable; if
|
||||
* semantics for their data types. (Note: this is pretty questionable; if
|
||||
* the ORDER BY list doesn't include all the DISTINCT ON items and more
|
||||
* besides, you certainly aren't using DISTINCT ON in the intended way,
|
||||
* and you probably aren't going to get consistent results. It might be
|
||||
@ -2131,7 +2131,8 @@ transformDistinctOnClause(ParseState *pstate, List *distinctlist,
|
||||
}
|
||||
|
||||
/*
|
||||
* An empty result list is impossible here because of grammar restrictions.
|
||||
* An empty result list is impossible here because of grammar
|
||||
* restrictions.
|
||||
*/
|
||||
Assert(result != NIL);
|
||||
|
||||
|
@ -56,12 +56,12 @@ static bool typeIsOfTypedTable(Oid reltypeId, Oid reloftypeId);
|
||||
* Convert an expression to a target type and typmod.
|
||||
*
|
||||
* This is the general-purpose entry point for arbitrary type coercion
|
||||
* operations. Direct use of the component operations can_coerce_type,
|
||||
* operations. Direct use of the component operations can_coerce_type,
|
||||
* coerce_type, and coerce_type_typmod should be restricted to special
|
||||
* cases (eg, when the conversion is expected to succeed).
|
||||
*
|
||||
* Returns the possibly-transformed expression tree, or NULL if the type
|
||||
* conversion is not possible. (We do this, rather than ereport'ing directly,
|
||||
* conversion is not possible. (We do this, rather than ereport'ing directly,
|
||||
* so that callers can generate custom error messages indicating context.)
|
||||
*
|
||||
* pstate - parse state (can be NULL, see coerce_type)
|
||||
@ -145,7 +145,7 @@ coerce_to_target_type(ParseState *pstate, Node *expr, Oid exprtype,
|
||||
* already be properly coerced to the specified typmod.
|
||||
*
|
||||
* pstate is only used in the case that we are able to resolve the type of
|
||||
* a previously UNKNOWN Param. It is okay to pass pstate = NULL if the
|
||||
* a previously UNKNOWN Param. It is okay to pass pstate = NULL if the
|
||||
* caller does not want type information updated for Params.
|
||||
*
|
||||
* Note: this function must not modify the given expression tree, only add
|
||||
@ -175,7 +175,7 @@ coerce_type(ParseState *pstate, Node *node,
|
||||
*
|
||||
* Note: by returning the unmodified node here, we are saying that
|
||||
* it's OK to treat an UNKNOWN constant as a valid input for a
|
||||
* function accepting ANY, ANYELEMENT, or ANYNONARRAY. This should be
|
||||
* function accepting ANY, ANYELEMENT, or ANYNONARRAY. This should be
|
||||
* all right, since an UNKNOWN value is still a perfectly valid Datum.
|
||||
*
|
||||
* NB: we do NOT want a RelabelType here: the exposed type of the
|
||||
@ -250,7 +250,7 @@ coerce_type(ParseState *pstate, Node *node,
|
||||
|
||||
/*
|
||||
* If the target type is a domain, we want to call its base type's
|
||||
* input routine, not domain_in(). This is to avoid premature failure
|
||||
* input routine, not domain_in(). This is to avoid premature failure
|
||||
* when the domain applies a typmod: existing input routines follow
|
||||
* implicit-coercion semantics for length checks, which is not always
|
||||
* what we want here. The needed check will be applied properly
|
||||
@ -263,7 +263,7 @@ coerce_type(ParseState *pstate, Node *node,
|
||||
* For most types we pass typmod -1 to the input routine, 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. An exception
|
||||
* constraint will be applied later by our caller. An exception
|
||||
* however is the INTERVAL type, for which we *must* pass the typmod
|
||||
* or it won't be able to obey the bizarre SQL-spec input rules. (Ugly
|
||||
* as sin, but so is this part of the spec...)
|
||||
@ -343,7 +343,7 @@ coerce_type(ParseState *pstate, Node *node,
|
||||
{
|
||||
/*
|
||||
* If we have a COLLATE clause, we have to push the coercion
|
||||
* underneath the COLLATE. This is really ugly, but there is little
|
||||
* underneath the COLLATE. This is really ugly, but there is little
|
||||
* choice because the above hacks on Consts and Params wouldn't happen
|
||||
* otherwise. This kluge has consequences in coerce_to_target_type.
|
||||
*/
|
||||
@ -366,7 +366,7 @@ coerce_type(ParseState *pstate, Node *node,
|
||||
{
|
||||
/*
|
||||
* Generate an expression tree representing run-time application
|
||||
* of the conversion function. If we are dealing with a domain
|
||||
* 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.
|
||||
@ -402,7 +402,7 @@ coerce_type(ParseState *pstate, Node *node,
|
||||
* 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
|
||||
* that must be accounted for. If the destination is a domain
|
||||
* then we won't need a RelabelType node.
|
||||
*/
|
||||
result = coerce_to_domain(node, InvalidOid, -1, targetTypeId,
|
||||
@ -649,7 +649,7 @@ coerce_to_domain(Node *arg, Oid baseTypeId, int32 baseTypeMod, Oid typeId,
|
||||
}
|
||||
|
||||
/*
|
||||
* Now build the domain coercion node. This represents run-time checking
|
||||
* 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.
|
||||
*/
|
||||
@ -722,7 +722,7 @@ coerce_type_typmod(Node *node, Oid targetTypeId, int32 targetTypMod,
|
||||
* Mark a coercion node as IMPLICIT so it will never be displayed by
|
||||
* ruleutils.c. We use this when we generate a nest of coercion nodes
|
||||
* to implement what is logically one conversion; the inner nodes are
|
||||
* forced to IMPLICIT_CAST format. This does not change their semantics,
|
||||
* forced to IMPLICIT_CAST format. This does not change their semantics,
|
||||
* only display behavior.
|
||||
*
|
||||
* It is caller error to call this on something that doesn't have a
|
||||
@ -1181,7 +1181,7 @@ select_common_type(ParseState *pstate, List *exprs, const char *context,
|
||||
}
|
||||
|
||||
/*
|
||||
* Nope, so set up for the full algorithm. Note that at this point, lc
|
||||
* Nope, so set up for the full algorithm. Note that at this point, lc
|
||||
* points to the first list item with type different from pexpr's; we need
|
||||
* not re-examine any items the previous loop advanced over.
|
||||
*/
|
||||
@ -1476,7 +1476,7 @@ check_generic_type_consistency(Oid *actual_arg_types,
|
||||
*
|
||||
* If any polymorphic pseudotype is used in a function's arguments or
|
||||
* return type, we make sure the actual data types are consistent with
|
||||
* each other. The argument consistency rules are shown above for
|
||||
* each other. The argument consistency rules are shown above for
|
||||
* check_generic_type_consistency().
|
||||
*
|
||||
* If we have UNKNOWN input (ie, an untyped literal) for any polymorphic
|
||||
@ -1498,7 +1498,7 @@ check_generic_type_consistency(Oid *actual_arg_types,
|
||||
* impossible to determine the range type from the subtype alone.)
|
||||
* 4) If return type is ANYARRAY, but no argument is ANYARRAY or ANYELEMENT,
|
||||
* generate an error. Similarly, if return type is ANYRANGE, but no
|
||||
* argument is ANYRANGE, generate an error. (These conditions are
|
||||
* argument is ANYRANGE, generate an error. (These conditions are
|
||||
* prevented by CREATE FUNCTION and therefore are not expected here.)
|
||||
* 5) If return type is ANYELEMENT, and any argument is ANYELEMENT, use the
|
||||
* argument's actual type as the function's return type.
|
||||
@ -1508,7 +1508,7 @@ check_generic_type_consistency(Oid *actual_arg_types,
|
||||
* type or the range type's corresponding subtype (or both, in which case
|
||||
* they must match).
|
||||
* 7) If return type is ANYELEMENT, no argument is ANYELEMENT, ANYARRAY, or
|
||||
* ANYRANGE, generate an error. (This condition is prevented by CREATE
|
||||
* ANYRANGE, generate an error. (This condition is prevented by CREATE
|
||||
* FUNCTION and therefore is not expected here.)
|
||||
* 8) ANYENUM is treated the same as ANYELEMENT except that if it is used
|
||||
* (alone or in combination with plain ANYELEMENT), we add the extra
|
||||
@ -1525,14 +1525,14 @@ check_generic_type_consistency(Oid *actual_arg_types,
|
||||
*
|
||||
* When allow_poly is false, we are not expecting any of the actual_arg_types
|
||||
* to be polymorphic, and we should not return a polymorphic result type
|
||||
* either. When allow_poly is true, it is okay to have polymorphic "actual"
|
||||
* either. When allow_poly is true, it is okay to have polymorphic "actual"
|
||||
* arg types, and we can return ANYARRAY, ANYRANGE, or ANYELEMENT as the
|
||||
* result. (This case is currently used only to check compatibility of an
|
||||
* result. (This case is currently used only to check compatibility of an
|
||||
* aggregate's declaration with the underlying transfn.)
|
||||
*
|
||||
* A special case is that we could see ANYARRAY as an actual_arg_type even
|
||||
* when allow_poly is false (this is possible only because pg_statistic has
|
||||
* columns shown as anyarray in the catalogs). We allow this to match a
|
||||
* columns shown as anyarray in the catalogs). We allow this to match a
|
||||
* declared ANYARRAY argument, but only if there is no ANYELEMENT argument
|
||||
* or result (since we can't determine a specific element type to match to
|
||||
* ANYELEMENT). Note this means that functions taking ANYARRAY had better
|
||||
@ -1638,7 +1638,7 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
|
||||
|
||||
/*
|
||||
* Fast Track: if none of the arguments are polymorphic, return the
|
||||
* unmodified rettype. We assume it can't be polymorphic either.
|
||||
* unmodified rettype. We assume it can't be polymorphic either.
|
||||
*/
|
||||
if (!have_generics)
|
||||
return rettype;
|
||||
@ -1981,8 +1981,8 @@ IsPreferredType(TYPCATEGORY category, Oid type)
|
||||
* Check if srctype is binary-coercible to targettype.
|
||||
*
|
||||
* This notion allows us to cheat and directly exchange values without
|
||||
* going through the trouble of calling a conversion function. Note that
|
||||
* in general, this should only be an implementation shortcut. Before 7.4,
|
||||
* going through the trouble of calling a conversion function. Note that
|
||||
* in general, this should only be an implementation shortcut. Before 7.4,
|
||||
* this was also used as a heuristic for resolving overloaded functions and
|
||||
* operators, but that's basically a bad idea.
|
||||
*
|
||||
@ -1995,7 +1995,7 @@ IsPreferredType(TYPCATEGORY category, Oid type)
|
||||
* types.
|
||||
*
|
||||
* This function replaces IsBinaryCompatible(), which was an inherently
|
||||
* symmetric test. Since the pg_cast entries aren't necessarily symmetric,
|
||||
* symmetric test. Since the pg_cast entries aren't necessarily symmetric,
|
||||
* the order of the operands is now significant.
|
||||
*/
|
||||
bool
|
||||
@ -2181,7 +2181,7 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
|
||||
* 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, ArrayCoerceExpr isn't
|
||||
* purposes, but not this one. (Also, ArrayCoerceExpr isn't
|
||||
* guaranteed to produce an output that meets the restrictions of
|
||||
* these datatypes, such as being 1-dimensional.)
|
||||
*/
|
||||
|
@ -14,19 +14,19 @@
|
||||
* 1. The output collation of each expression node, or InvalidOid if it
|
||||
* returns a noncollatable data type. This can also be InvalidOid if the
|
||||
* result type is collatable but the collation is indeterminate.
|
||||
* 2. The collation to be used in executing each function. InvalidOid means
|
||||
* 2. The collation to be used in executing each function. InvalidOid means
|
||||
* that there are no collatable inputs or their collation is indeterminate.
|
||||
* This value is only stored in node types that might call collation-using
|
||||
* functions.
|
||||
*
|
||||
* You might think we could get away with storing only one collation per
|
||||
* node, but the two concepts really need to be kept distinct. Otherwise
|
||||
* node, but the two concepts really need to be kept distinct. Otherwise
|
||||
* it's too confusing when a function produces a collatable output type but
|
||||
* has no collatable inputs or produces noncollatable output from collatable
|
||||
* inputs.
|
||||
*
|
||||
* Cases with indeterminate collation might result in an error being thrown
|
||||
* at runtime. If we knew exactly which functions require collation
|
||||
* at runtime. If we knew exactly which functions require collation
|
||||
* information, we could throw those errors at parse time instead.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
|
||||
@ -245,7 +245,7 @@ select_common_collation(ParseState *pstate, List *exprs, bool none_ok)
|
||||
* Recursive guts of collation processing.
|
||||
*
|
||||
* Nodes with no children (eg, Vars, Consts, Params) must have been marked
|
||||
* when built. All upper-level nodes are marked here.
|
||||
* when built. All upper-level nodes are marked here.
|
||||
*
|
||||
* Note: if this is invoked directly on a List, it will attempt to infer a
|
||||
* common collation for all the list members. In particular, it will throw
|
||||
@ -448,7 +448,7 @@ assign_collations_walker(Node *node, assign_collations_context *context)
|
||||
|
||||
/*
|
||||
* TargetEntry can have only one child, and should bubble that
|
||||
* state up to its parent. We can't use the general-case code
|
||||
* state up to its parent. We can't use the general-case code
|
||||
* below because exprType and friends don't work on TargetEntry.
|
||||
*/
|
||||
collation = loccontext.collation;
|
||||
@ -463,7 +463,7 @@ assign_collations_walker(Node *node, assign_collations_context *context)
|
||||
* There are some cases where there might not be a failure, for
|
||||
* example if the planner chooses to use hash aggregation instead
|
||||
* of sorting for grouping; but it seems better to predictably
|
||||
* throw an error. (Compare transformSetOperationTree, which will
|
||||
* throw an error. (Compare transformSetOperationTree, which will
|
||||
* throw error for indeterminate collation of set-op columns, even
|
||||
* though the planner might be able to implement the set-op
|
||||
* without sorting.)
|
||||
@ -501,7 +501,7 @@ assign_collations_walker(Node *node, assign_collations_context *context)
|
||||
* SubLink. Act as though the Query returns its first output
|
||||
* column, which indeed is what it does for EXPR_SUBLINK and
|
||||
* ARRAY_SUBLINK cases. In the cases where the SubLink
|
||||
* returns boolean, this info will be ignored. Special case:
|
||||
* returns boolean, this info will be ignored. Special case:
|
||||
* in EXISTS, the Query might return no columns, in which case
|
||||
* we need do nothing.
|
||||
*
|
||||
@ -961,7 +961,7 @@ assign_hypothetical_collations(Aggref *aggref,
|
||||
|
||||
/*
|
||||
* Assign collations internally in this pair of expressions, then
|
||||
* choose a common collation for them. This should match
|
||||
* choose a common collation for them. This should match
|
||||
* select_common_collation(), but we can't use that function as-is
|
||||
* because we need access to the whole collation state so we can
|
||||
* bubble it up to the aggregate function's level.
|
||||
|
@ -181,7 +181,7 @@ transformWithClause(ParseState *pstate, WithClause *withClause)
|
||||
checkWellFormedRecursion(&cstate);
|
||||
|
||||
/*
|
||||
* Set up the ctenamespace for parse analysis. Per spec, all the WITH
|
||||
* Set up the ctenamespace for parse analysis. Per spec, all the WITH
|
||||
* items are visible to all others, so stuff them all in before parse
|
||||
* analysis. We build the list in safe processing order so that the
|
||||
* planner can process the queries in sequence.
|
||||
@ -207,7 +207,7 @@ transformWithClause(ParseState *pstate, WithClause *withClause)
|
||||
{
|
||||
/*
|
||||
* For non-recursive WITH, just analyze each CTE in sequence and then
|
||||
* add it to the ctenamespace. This corresponds to the spec's
|
||||
* add it to the ctenamespace. This corresponds to the spec's
|
||||
* definition of the scope of each WITH name. However, to allow error
|
||||
* reports to be aware of the possibility of an erroneous reference,
|
||||
* we maintain a list in p_future_ctes of the not-yet-visible CTEs.
|
||||
@ -245,7 +245,7 @@ analyzeCTE(ParseState *pstate, CommonTableExpr *cte)
|
||||
cte->ctequery = (Node *) query;
|
||||
|
||||
/*
|
||||
* Check that we got something reasonable. These first two cases should
|
||||
* Check that we got something reasonable. These first two cases should
|
||||
* be prevented by the grammar.
|
||||
*/
|
||||
if (!IsA(query, Query))
|
||||
@ -393,7 +393,7 @@ analyzeCTETargetList(ParseState *pstate, CommonTableExpr *cte, List *tlist)
|
||||
|
||||
/*
|
||||
* If the CTE is recursive, force the exposed column type of any
|
||||
* "unknown" column to "text". This corresponds to the fact that
|
||||
* "unknown" column to "text". This corresponds to the fact that
|
||||
* SELECT 'foo' UNION SELECT 'bar' will ultimately produce text. We
|
||||
* might see "unknown" as a result of an untyped literal in the
|
||||
* non-recursive term's select list, and if we don't convert to text
|
||||
|
@ -506,7 +506,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)
|
||||
@ -577,7 +577,7 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to find the name as a relation. Note that only
|
||||
* Try to find the name as a relation. Note that only
|
||||
* relations already entered into the rangetable will be
|
||||
* recognized.
|
||||
*
|
||||
@ -808,7 +808,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)
|
||||
@ -1108,7 +1108,7 @@ transformAExprIn(ParseState *pstate, A_Expr *a)
|
||||
* We try to generate a ScalarArrayOpExpr from IN/NOT IN, but this is only
|
||||
* possible if there is a suitable array type available. If not, we fall
|
||||
* back to a boolean condition tree with multiple copies of the lefthand
|
||||
* expression. Also, any IN-list items that contain Vars are handled as
|
||||
* expression. Also, any IN-list items that contain Vars are handled as
|
||||
* separate boolean conditions, because that gives the planner more scope
|
||||
* for optimization on such clauses.
|
||||
*
|
||||
@ -1139,7 +1139,7 @@ transformAExprIn(ParseState *pstate, A_Expr *a)
|
||||
Oid array_type;
|
||||
|
||||
/*
|
||||
* Try to select a common type for the array elements. Note that
|
||||
* Try to select a common type for the array elements. Note that
|
||||
* since the LHS' type is first in the list, it will be preferred when
|
||||
* there is doubt (eg, when all the RHS items are unknown literals).
|
||||
*
|
||||
@ -1254,8 +1254,8 @@ transformFuncCall(ParseState *pstate, FuncCall *fn)
|
||||
/*
|
||||
* When WITHIN GROUP is used, we treat its ORDER BY expressions as
|
||||
* additional arguments to the function, for purposes of function lookup
|
||||
* and argument type coercion. So, transform each such expression and add
|
||||
* them to the targs list. We don't explicitly mark where each argument
|
||||
* and argument type coercion. So, transform each such expression and add
|
||||
* them to the targs list. We don't explicitly mark where each argument
|
||||
* came from, but ParseFuncOrColumn can tell what's what by reference to
|
||||
* list_length(fn->agg_order).
|
||||
*/
|
||||
@ -1510,7 +1510,7 @@ transformSubLink(ParseState *pstate, SubLink *sublink)
|
||||
qtree = parse_sub_analyze(sublink->subselect, pstate, NULL, false);
|
||||
|
||||
/*
|
||||
* Check that we got something reasonable. Many of these conditions are
|
||||
* Check that we got something reasonable. Many of these conditions are
|
||||
* impossible given restrictions of the grammar, but check 'em anyway.
|
||||
*/
|
||||
if (!IsA(qtree, Query) ||
|
||||
@ -1925,7 +1925,7 @@ transformXmlExpr(ParseState *pstate, XmlExpr *x)
|
||||
newx->location = x->location;
|
||||
|
||||
/*
|
||||
* gram.y built the named args as a list of ResTarget. Transform each,
|
||||
* gram.y built the named args as a list of ResTarget. Transform each,
|
||||
* and break the names out as a separate list.
|
||||
*/
|
||||
newx->named_args = NIL;
|
||||
@ -2188,9 +2188,9 @@ transformWholeRowRef(ParseState *pstate, RangeTblEntry *rte, int location)
|
||||
vnum = RTERangeTablePosn(pstate, rte, &sublevels_up);
|
||||
|
||||
/*
|
||||
* Build the appropriate referencing node. Note that if the RTE is a
|
||||
* Build the appropriate referencing node. Note that if the RTE is a
|
||||
* function returning scalar, we create just a plain reference to the
|
||||
* function value, not a composite containing a single column. This is
|
||||
* function value, not a composite containing a single column. This is
|
||||
* pretty inconsistent at first sight, but it's what we've done
|
||||
* historically. One argument for it is that "rel" and "rel.*" mean the
|
||||
* same thing for composite relations, so why not for scalar functions...
|
||||
@ -2374,7 +2374,7 @@ make_row_comparison_op(ParseState *pstate, List *opname,
|
||||
|
||||
/*
|
||||
* Now we must determine which row comparison semantics (= <> < <= > >=)
|
||||
* apply to this set of operators. We look for btree opfamilies
|
||||
* apply to this set of operators. We look for btree opfamilies
|
||||
* containing the operators, and see which interpretations (strategy
|
||||
* numbers) exist for each operator.
|
||||
*/
|
||||
|
@ -104,7 +104,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
||||
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
@ -520,7 +520,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
||||
* If there are default arguments, we have to include their types in
|
||||
* actual_arg_types for the purpose of checking generic type consistency.
|
||||
* However, we do NOT put them into the generated parse node, because
|
||||
* their actual values might change before the query gets run. The
|
||||
* their actual values might change before the query gets run. The
|
||||
* planner has to insert the up-to-date values at plan time.
|
||||
*/
|
||||
nargsplusdefs = nargs;
|
||||
@ -653,7 +653,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
||||
|
||||
/*
|
||||
* Reject attempt to call a parameterless aggregate without (*)
|
||||
* syntax. This is mere pedantry but some folks insisted ...
|
||||
* syntax. This is mere pedantry but some folks insisted ...
|
||||
*/
|
||||
if (fargs == NIL && !agg_star && !agg_within_group)
|
||||
ereport(ERROR,
|
||||
@ -672,7 +672,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
||||
* We might want to support named arguments later, but disallow it for
|
||||
* now. We'd need to figure out the parsed representation (should the
|
||||
* NamedArgExprs go above or below the TargetEntry nodes?) and then
|
||||
* teach the planner to reorder the list properly. Or maybe we could
|
||||
* teach the planner to reorder the list properly. Or maybe we could
|
||||
* make transformAggregateCall do that? However, if you'd also like
|
||||
* to allow default arguments for aggregates, we'd need to do it in
|
||||
* planning to avoid semantic problems.
|
||||
@ -717,7 +717,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
||||
|
||||
/*
|
||||
* Reject attempt to call a parameterless aggregate without (*)
|
||||
* syntax. This is mere pedantry but some folks insisted ...
|
||||
* syntax. This is mere pedantry but some folks insisted ...
|
||||
*/
|
||||
if (wfunc->winagg && fargs == NIL && !agg_star)
|
||||
ereport(ERROR,
|
||||
@ -895,7 +895,7 @@ func_select_candidate(int nargs,
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
@ -1019,7 +1019,7 @@ func_select_candidate(int nargs,
|
||||
|
||||
/*
|
||||
* The next step examines each unknown argument position to see if we can
|
||||
* determine a "type category" for it. If any candidate has an input
|
||||
* 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
|
||||
@ -1030,7 +1030,7 @@ func_select_candidate(int nargs,
|
||||
* 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
|
||||
* 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 just one candidate remains, return
|
||||
* that one. However, if this rule turns out to reject all candidates,
|
||||
@ -1159,7 +1159,7 @@ func_select_candidate(int nargs,
|
||||
* type, and see if that gives us a unique match. If so, use that match.
|
||||
*
|
||||
* NOTE: for a binary operator with one unknown and one non-unknown input,
|
||||
* we already tried this heuristic in binary_oper_exact(). However, that
|
||||
* we already tried this heuristic in binary_oper_exact(). However, that
|
||||
* code only finds exact matches, whereas here we will handle matches that
|
||||
* involve coercion, polymorphic type resolution, etc.
|
||||
*/
|
||||
@ -1328,7 +1328,7 @@ func_get_detail(List *funcname,
|
||||
*
|
||||
* NB: it's important that this code does not exceed 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
|
||||
* 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!
|
||||
*/
|
||||
@ -1506,7 +1506,7 @@ 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
|
||||
@ -1751,7 +1751,7 @@ FuncNameAsType(List *funcname)
|
||||
* ParseComplexProjection -
|
||||
* handles function calls with a single argument that is of complex type.
|
||||
* If the function call is actually a column projection, return a suitably
|
||||
* transformed expression tree. If not, return NULL.
|
||||
* transformed expression tree. If not, return NULL.
|
||||
*/
|
||||
static Node *
|
||||
ParseComplexProjection(ParseState *pstate, char *funcname, Node *first_arg,
|
||||
@ -1825,7 +1825,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
|
||||
|
@ -99,8 +99,8 @@ free_parsestate(ParseState *pstate)
|
||||
* is a dummy (always 0, in fact).
|
||||
*
|
||||
* The locations stored in raw parsetrees are byte offsets into the source
|
||||
* string. We have to convert them to 1-based character indexes for reporting
|
||||
* to clients. (We do things this way to avoid unnecessary overhead in the
|
||||
* string. We have to convert them to 1-based character indexes for reporting
|
||||
* to clients. (We do things this way to avoid unnecessary overhead in the
|
||||
* normal non-error case: computing character indexes would be much more
|
||||
* expensive than storing token offsets.)
|
||||
*/
|
||||
@ -129,7 +129,7 @@ parser_errposition(ParseState *pstate, int location)
|
||||
* Sometimes the parser calls functions that aren't part of the parser
|
||||
* subsystem and can't reasonably be passed a ParseState; yet we would
|
||||
* like any errors thrown in those functions to be tagged with a parse
|
||||
* error location. Use this function to set up an error context stack
|
||||
* error location. Use this function to set up an error context stack
|
||||
* entry that will accomplish that. Usage pattern:
|
||||
*
|
||||
* declare a local variable "ParseCallbackState pcbstate"
|
||||
@ -221,7 +221,7 @@ transformArrayType(Oid *arrayType, int32 *arrayTypmod)
|
||||
* If the input is a domain, smash to base type, and extract the actual
|
||||
* typmod to be applied to the base type. Subscripting a domain is an
|
||||
* operation that necessarily works on the base array type, not the domain
|
||||
* itself. (Note that we provide no method whereby the creator of a
|
||||
* itself. (Note that we provide no method whereby the creator of a
|
||||
* domain over an array type could hide its ability to be subscripted.)
|
||||
*/
|
||||
*arrayType = getBaseTypeAndTypmod(*arrayType, arrayTypmod);
|
||||
@ -269,7 +269,7 @@ transformArrayType(Oid *arrayType, int32 *arrayTypmod)
|
||||
*
|
||||
* In an array assignment, we are given a destination array value plus a
|
||||
* source value that is to be assigned to a single element or a slice of
|
||||
* that array. We produce an expression that represents the new array value
|
||||
* that array. We produce an expression that represents the new array value
|
||||
* with the source data inserted into the right part of the array.
|
||||
*
|
||||
* For both cases, if the source array is of a domain-over-array type,
|
||||
|
@ -447,7 +447,7 @@ oper(ParseState *pstate, List *opname, Oid ltypeId, Oid rtypeId,
|
||||
*
|
||||
* This is tighter than oper() because it will not return an operator that
|
||||
* requires coercion of the input datatypes (but binary-compatible operators
|
||||
* are accepted). Otherwise, the semantics are the same.
|
||||
* are accepted). Otherwise, the semantics are the same.
|
||||
*/
|
||||
Operator
|
||||
compatible_oper(ParseState *pstate, List *op, Oid arg1, Oid arg2,
|
||||
@ -980,7 +980,7 @@ make_scalar_array_op(ParseState *pstate, List *opname,
|
||||
* mapping is pretty expensive to compute, especially for ambiguous operators;
|
||||
* this is mainly because there are a *lot* of instances of popular operator
|
||||
* names such as "=", and we have to check each one to see which is the
|
||||
* best match. So once we have identified the correct mapping, we save it
|
||||
* best match. So once we have identified the correct mapping, we save it
|
||||
* in a cache that need only be flushed on pg_operator or pg_cast change.
|
||||
* (pg_cast must be considered because changes in the set of implicit casts
|
||||
* affect the set of applicable operators for any given input datatype.)
|
||||
|
@ -256,7 +256,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
|
||||
|
@ -71,7 +71,7 @@ static bool isQueryUsingTempRelation_walker(Node *node, void *context);
|
||||
*
|
||||
* A qualified refname (schemaname != NULL) can only match a relation RTE
|
||||
* that (a) has no alias and (b) is for the same relation identified by
|
||||
* schemaname.refname. In this case we convert schemaname.refname to a
|
||||
* schemaname.refname. In this case we convert schemaname.refname to a
|
||||
* relation OID and search by relid, rather than by alias name. This is
|
||||
* peculiar, but it's what SQL says to do.
|
||||
*/
|
||||
@ -181,7 +181,7 @@ scanNameSpaceForRefname(ParseState *pstate, const char *refname, int location)
|
||||
|
||||
/*
|
||||
* Search the query's table namespace for a relation RTE matching the
|
||||
* given relation OID. Return the RTE if a unique match, or NULL
|
||||
* given relation OID. Return the RTE if a unique match, or NULL
|
||||
* if no match. Raise error if multiple matches.
|
||||
*
|
||||
* See the comments for refnameRangeTblEntry to understand why this
|
||||
@ -285,7 +285,7 @@ isFutureCTE(ParseState *pstate, const char *refname)
|
||||
*
|
||||
* This is different from refnameRangeTblEntry in that it considers every
|
||||
* entry in the ParseState's rangetable(s), not only those that are currently
|
||||
* visible in the p_namespace list(s). This behavior is invalid per the SQL
|
||||
* visible in the p_namespace list(s). This behavior is invalid per the SQL
|
||||
* spec, and it may give ambiguous results (there might be multiple equally
|
||||
* valid matches, but only one will be returned). This must be used ONLY
|
||||
* as a heuristic in giving suitable error messages. See errorMissingRTE.
|
||||
@ -308,8 +308,8 @@ searchRangeTableForRel(ParseState *pstate, RangeVar *relation)
|
||||
* relation.
|
||||
*
|
||||
* NB: It's not critical that RangeVarGetRelid return the correct answer
|
||||
* here in the face of concurrent DDL. If it doesn't, the worst case
|
||||
* scenario is a less-clear error message. Also, the tables involved in
|
||||
* here in the face of concurrent DDL. If it doesn't, the worst case
|
||||
* scenario is a less-clear error message. Also, the tables involved in
|
||||
* the query are already locked, which reduces the number of cases in
|
||||
* which surprising behavior can occur. So we do the name lookup
|
||||
* unlocked.
|
||||
@ -431,7 +431,7 @@ check_lateral_ref_ok(ParseState *pstate, ParseNamespaceItem *nsitem,
|
||||
|
||||
/*
|
||||
* given an RTE, return RT index (starting with 1) of the entry,
|
||||
* and optionally get its nesting depth (0 = current). If sublevels_up
|
||||
* and optionally get its nesting depth (0 = current). If sublevels_up
|
||||
* is NULL, only consider rels at the current nesting level.
|
||||
* Raises error if RTE not found.
|
||||
*/
|
||||
@ -585,11 +585,11 @@ scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte, char *colname,
|
||||
|
||||
/* In constraint check, no system column is allowed except tableOid */
|
||||
if (pstate->p_expr_kind == EXPR_KIND_CHECK_CONSTRAINT &&
|
||||
attnum < InvalidAttrNumber && attnum != TableOidAttributeNumber)
|
||||
attnum < InvalidAttrNumber && attnum != TableOidAttributeNumber)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("system column \"%s\" reference in check constraint is invalid",
|
||||
colname),
|
||||
colname),
|
||||
parser_errposition(pstate, location)));
|
||||
|
||||
if (attnum != InvalidAttrNumber)
|
||||
@ -673,7 +673,7 @@ colNameToVar(ParseState *pstate, char *colname, bool localonly,
|
||||
*
|
||||
* This is different from colNameToVar in that it considers every entry in
|
||||
* the ParseState's rangetable(s), not only those that are currently visible
|
||||
* in the p_namespace list(s). This behavior is invalid per the SQL spec,
|
||||
* in the p_namespace list(s). This behavior is invalid per the SQL spec,
|
||||
* and it may give ambiguous results (there might be multiple equally valid
|
||||
* matches, but only one will be returned). This must be used ONLY as a
|
||||
* heuristic in giving suitable error messages. See errorMissingColumn.
|
||||
@ -1016,7 +1016,7 @@ addRangeTableEntry(ParseState *pstate,
|
||||
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
@ -2580,7 +2580,7 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
|
||||
* Dropped attributes are only possible with functions that
|
||||
* return named composite types. In such a case we have to
|
||||
* look up the result type to see if it currently has this
|
||||
* column dropped. So first, loop over the funcs until we
|
||||
* column dropped. So first, loop over the funcs until we
|
||||
* find the one that covers the requested column.
|
||||
*/
|
||||
foreach(lc, rte->functions)
|
||||
@ -2811,7 +2811,7 @@ 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
|
||||
* rangetable. (Note: cases involving a bad schema name in the RangeVar
|
||||
* will throw error immediately here. That seems OK.)
|
||||
*/
|
||||
rte = searchRangeTableForRel(pstate, relation);
|
||||
@ -2865,7 +2865,7 @@ errorMissingColumn(ParseState *pstate,
|
||||
RangeTblEntry *rte;
|
||||
|
||||
/*
|
||||
* If relname was given, just play dumb and report it. (In practice, a
|
||||
* If relname was given, just play dumb and report it. (In practice, a
|
||||
* bad qualification name should end up at errorMissingRTE, not here, so
|
||||
* no need to work hard on this case.)
|
||||
*/
|
||||
|
@ -182,7 +182,7 @@ transformTargetList(ParseState *pstate, List *targetlist,
|
||||
* This is the identical transformation to transformTargetList, except that
|
||||
* the input list elements are bare expressions without ResTarget decoration,
|
||||
* and the output elements are likewise just expressions without TargetEntry
|
||||
* decoration. We use this for ROW() and VALUES() constructs.
|
||||
* decoration. We use this for ROW() and VALUES() constructs.
|
||||
*/
|
||||
List *
|
||||
transformExpressionList(ParseState *pstate, List *exprlist,
|
||||
@ -348,7 +348,7 @@ markTargetListOrigin(ParseState *pstate, TargetEntry *tle,
|
||||
|
||||
/*
|
||||
* transformAssignedExpr()
|
||||
* This is used in INSERT and UPDATE statements only. It prepares an
|
||||
* This is used in INSERT and UPDATE statements only. It prepares an
|
||||
* expression for assignment to a column of the target table.
|
||||
* This includes coercing the given value to the target column's type
|
||||
* (if necessary), and dealing with any subfield names or subscripts
|
||||
@ -367,7 +367,7 @@ markTargetListOrigin(ParseState *pstate, TargetEntry *tle,
|
||||
*
|
||||
* Note: location points at the target column name (SET target or INSERT
|
||||
* column name list entry), and must therefore be -1 in an INSERT that
|
||||
* omits the column name list. So we should usually prefer to use
|
||||
* omits the column name list. So we should usually prefer to use
|
||||
* exprLocation(expr) for errors that can happen in a default INSERT.
|
||||
*/
|
||||
Expr *
|
||||
@ -442,7 +442,7 @@ transformAssignedExpr(ParseState *pstate,
|
||||
|
||||
/*
|
||||
* If there is indirection on the target column, prepare an array or
|
||||
* subfield assignment expression. This will generate a new column value
|
||||
* 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.
|
||||
*/
|
||||
@ -550,7 +550,7 @@ updateTargetListEntry(ParseState *pstate,
|
||||
|
||||
/*
|
||||
* Set the resno to identify the target column --- the rewriter and
|
||||
* planner depend on this. We also set the resname to identify the target
|
||||
* 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.)
|
||||
*/
|
||||
@ -998,7 +998,7 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
@ -1017,7 +1017,7 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
|
||||
} 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)
|
||||
@ -1133,7 +1133,7 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
|
||||
* Transforms '*' (in the target list) into a list of targetlist entries.
|
||||
*
|
||||
* tlist entries are generated for each relation visible for unqualified
|
||||
* column name access. We do not consider qualified-name-only entries because
|
||||
* column name access. We do not consider qualified-name-only entries because
|
||||
* that would include input tables of aliasless JOINs, NEW/OLD pseudo-entries,
|
||||
* etc.
|
||||
*
|
||||
@ -1280,7 +1280,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
|
||||
@ -1362,7 +1362,7 @@ ExpandRowReference(ParseState *pstate, Node *expr,
|
||||
* 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.
|
||||
*
|
||||
@ -1445,7 +1445,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;
|
||||
@ -1519,7 +1519,7 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
|
||||
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
|
@ -35,7 +35,7 @@ static int32 typenameTypeMod(ParseState *pstate, const TypeName *typeName,
|
||||
/*
|
||||
* LookupTypeName
|
||||
* Given a TypeName object, lookup the pg_type syscache entry of the type.
|
||||
* Returns NULL if no such type can be found. If the type is found,
|
||||
* Returns NULL if no such type can be found. If the type is found,
|
||||
* the typmod value represented in the TypeName struct is computed and
|
||||
* stored into *typmod_p.
|
||||
*
|
||||
@ -48,7 +48,7 @@ static int32 typenameTypeMod(ParseState *pstate, const TypeName *typeName,
|
||||
*
|
||||
* typmod_p can be passed as NULL if the caller does not care to know the
|
||||
* typmod value, but the typmod decoration (if any) will be validated anyway,
|
||||
* except in the case where the type is not found. Note that if the type is
|
||||
* except in the case where the type is not found. Note that if the type is
|
||||
* found but is a shell, and there is typmod decoration, an error will be
|
||||
* thrown --- this is intentional.
|
||||
*
|
||||
@ -113,7 +113,7 @@ LookupTypeName(ParseState *pstate, const TypeName *typeName,
|
||||
* Look up the field.
|
||||
*
|
||||
* XXX: As no lock is taken here, this might fail in the presence of
|
||||
* concurrent DDL. But taking a lock would carry a performance
|
||||
* concurrent DDL. But taking a lock would carry a performance
|
||||
* penalty and would also require a permissions check.
|
||||
*/
|
||||
relid = RangeVarGetRelid(rel, NoLock, missing_ok);
|
||||
@ -625,7 +625,7 @@ typeTypeCollation(Type typ)
|
||||
|
||||
/*
|
||||
* Given a type structure and a string, returns the internal representation
|
||||
* of that string. The "string" can be NULL to perform conversion of a NULL
|
||||
* of that string. The "string" can be NULL to perform conversion of a NULL
|
||||
* (which might result in failure, if the input function rejects NULLs).
|
||||
*/
|
||||
Datum
|
||||
@ -649,7 +649,7 @@ stringTypeDatum(Type tp, char *string, int32 atttypmod)
|
||||
* instability in the input function is that comparison of Const nodes
|
||||
* relies on bytewise comparison of the datums, so if the input function
|
||||
* leaves garbage then subexpressions that should be identical may not get
|
||||
* recognized as such. See pgsql-hackers discussion of 2008-04-04.
|
||||
* recognized as such. See pgsql-hackers discussion of 2008-04-04.
|
||||
*/
|
||||
if (string && !typform->typbyval)
|
||||
{
|
||||
@ -696,7 +696,7 @@ 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
|
||||
* than transforming to an "internal query" error. It's unlikely that a
|
||||
* type name is complex enough to need positioning.
|
||||
*/
|
||||
errposition(0);
|
||||
@ -792,9 +792,9 @@ parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p,
|
||||
if (!missing_ok)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("type \"%s\" does not exist",
|
||||
errmsg("type \"%s\" does not exist",
|
||||
TypeNameToString(typeName)),
|
||||
parser_errposition(NULL, typeName->location)));
|
||||
parser_errposition(NULL, typeName->location)));
|
||||
*typeid_p = InvalidOid;
|
||||
}
|
||||
else
|
||||
@ -802,9 +802,9 @@ parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p,
|
||||
if (!((Form_pg_type) GETSTRUCT(tup))->typisdefined)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("type \"%s\" is only a shell",
|
||||
errmsg("type \"%s\" is only a shell",
|
||||
TypeNameToString(typeName)),
|
||||
parser_errposition(NULL, typeName->location)));
|
||||
parser_errposition(NULL, typeName->location)));
|
||||
*typeid_p = HeapTupleGetOid(tup);
|
||||
ReleaseSysCache(tup);
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
|
||||
stmt = (CreateStmt *) copyObject(stmt);
|
||||
|
||||
/*
|
||||
* Look up the creation namespace. This also checks permissions on the
|
||||
* Look up the creation namespace. This also checks permissions on the
|
||||
* target namespace, locks it against concurrent drops, checks for a
|
||||
* preexisting relation in that namespace with the same name, and updates
|
||||
* stmt->relation->relpersistence if the select namespace is temporary.
|
||||
@ -183,7 +183,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
|
||||
* If the target relation name isn't schema-qualified, make it so. This
|
||||
* prevents some corner cases in which added-on rewritten commands might
|
||||
* think they should apply to other relations that have the same name and
|
||||
* are earlier in the search path. But a local temp table is effectively
|
||||
* are earlier in the search path. But a local temp table is effectively
|
||||
* specified to be in pg_temp, so no need for anything extra in that case.
|
||||
*/
|
||||
if (stmt->relation->schemaname == NULL
|
||||
@ -672,7 +672,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
|
||||
if (cxt->isforeign)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("LIKE is not supported for creating foreign tables")));
|
||||
errmsg("LIKE is not supported for creating foreign tables")));
|
||||
|
||||
relation = relation_openrv(table_like_clause->relation, AccessShareLock);
|
||||
|
||||
@ -712,7 +712,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
|
||||
constr = tupleDesc->constr;
|
||||
|
||||
/*
|
||||
* Initialize column number map for map_variable_attnos(). We need this
|
||||
* Initialize column number map for map_variable_attnos(). We need this
|
||||
* since dropped columns in the source table aren't copied, so the new
|
||||
* table can have different column numbers.
|
||||
*/
|
||||
@ -927,7 +927,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
|
||||
|
||||
/*
|
||||
* Close the parent rel, but keep our AccessShareLock on it until xact
|
||||
* commit. That will prevent someone else from deleting or ALTERing the
|
||||
* commit. That will prevent someone else from deleting or ALTERing the
|
||||
* parent before the child is committed.
|
||||
*/
|
||||
heap_close(relation, NoLock);
|
||||
@ -1608,7 +1608,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
|
||||
parser_errposition(cxt->pstate, constraint->location)));
|
||||
|
||||
/*
|
||||
* Insist on it being a btree. That's the only kind that supports
|
||||
* Insist on it being a btree. That's the only kind that supports
|
||||
* uniqueness at the moment anyway; but we must have an index that
|
||||
* exactly matches what you'd get from plain ADD CONSTRAINT syntax,
|
||||
* else dump and reload will produce a different index (breaking
|
||||
@ -1635,7 +1635,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
|
||||
|
||||
/*
|
||||
* We shouldn't see attnum == 0 here, since we already rejected
|
||||
* expression indexes. If we do, SystemAttributeDefinition will
|
||||
* expression indexes. If we do, SystemAttributeDefinition will
|
||||
* throw an error.
|
||||
*/
|
||||
if (attnum > 0)
|
||||
@ -1649,7 +1649,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
|
||||
attname = pstrdup(NameStr(attform->attname));
|
||||
|
||||
/*
|
||||
* Insist on default opclass and sort options. While the index
|
||||
* Insist on default opclass and sort options. While the index
|
||||
* would still work as a constraint with non-default settings, it
|
||||
* might not provide exactly the same uniqueness semantics as
|
||||
* you'd get from a normally-created constraint; and there's also
|
||||
@ -1900,7 +1900,7 @@ transformFKConstraints(CreateStmtContext *cxt,
|
||||
* transformIndexStmt - parse analysis for CREATE INDEX and ALTER TABLE
|
||||
*
|
||||
* Note: this is a no-op for an index not using either index expressions or
|
||||
* a predicate expression. There are several code paths that create indexes
|
||||
* a predicate expression. There are several code paths that create indexes
|
||||
* without bothering to call this, because they know they don't have any
|
||||
* such expressions to deal with.
|
||||
*
|
||||
@ -2023,7 +2023,7 @@ transformRuleStmt(RuleStmt *stmt, const char *queryString,
|
||||
|
||||
/*
|
||||
* To avoid deadlock, make sure the first thing we do is grab
|
||||
* AccessExclusiveLock on the target relation. This will be needed by
|
||||
* AccessExclusiveLock on the target relation. This will be needed by
|
||||
* DefineQueryRewrite(), and we don't want to grab a lesser lock
|
||||
* beforehand.
|
||||
*/
|
||||
|
@ -65,7 +65,7 @@ raw_parser(const char *str)
|
||||
* Intermediate filter between parser and core lexer (core_yylex in scan.l).
|
||||
*
|
||||
* The filter is needed because in some cases the standard SQL grammar
|
||||
* requires more than one token lookahead. We reduce these cases to one-token
|
||||
* requires more than one token lookahead. We reduce these cases to one-token
|
||||
* lookahead by combining tokens here, in order to keep the grammar LALR(1).
|
||||
*
|
||||
* Using a filter is simpler than trying to recognize multiword tokens
|
||||
|
@ -132,7 +132,7 @@ downcase_truncate_identifier(const char *ident, int len, bool warn)
|
||||
{
|
||||
char *result;
|
||||
int i;
|
||||
bool enc_is_single_byte;
|
||||
bool enc_is_single_byte;
|
||||
|
||||
result = palloc(len + 1);
|
||||
enc_is_single_byte = pg_database_encoding_max_length() == 1;
|
||||
@ -143,8 +143,8 @@ downcase_truncate_identifier(const char *ident, int len, bool warn)
|
||||
* 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, as long as they aren't part of a multi-byte character,
|
||||
* and use an ASCII-only downcasing for 7-bit characters.
|
||||
* the high bit set, as long as they aren't part of a multi-byte
|
||||
* character, and use an ASCII-only downcasing for 7-bit characters.
|
||||
*/
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
|
Reference in New Issue
Block a user