提交 9453514b 编写于 作者: H Heikki Linnakangas

Misc whitespace, formatting and comment changes, to reduce diff vs. upstream.

上级 81eb7d02
......@@ -89,10 +89,10 @@ static Datum ExecEvalScalarVarFast(ExprState *exprstate, ExprContext *econtext,
static Datum ExecEvalWholeRowVar(WholeRowVarExprState *wrvstate,
ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalWholeRowSlow(WholeRowVarExprState *wrvstate,
static Datum ExecEvalWholeRowFast(WholeRowVarExprState *wrvstate,
ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalWholeRowFast(WholeRowVarExprState *wrvstate,
static Datum ExecEvalWholeRowSlow(WholeRowVarExprState *wrvstate,
ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalConst(ExprState *exprstate, ExprContext *econtext,
......@@ -156,11 +156,11 @@ static Datum ExecEvalCoalesce(CoalesceExprState *coalesceExpr,
static Datum ExecEvalMinMax(MinMaxExprState *minmaxExpr,
ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalXml(XmlExprState *xmlExpr, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalNullIf(FuncExprState *nullIfExpr,
ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalXml(XmlExprState *xmlExpr, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalNullTest(NullTestState *nstate,
ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone);
......@@ -689,7 +689,6 @@ ExecEvalScalarVar(ExprState *exprstate, ExprContext *econtext,
if (isDone)
*isDone = ExprSingleResult;
Assert(econtext->ecxt_scantuple != NULL || econtext->ecxt_innertuple != NULL || econtext->ecxt_outertuple != NULL);
/*
* Get the input slot and attribute number we want
*
......@@ -746,6 +745,7 @@ ExecEvalScalarVar(ExprState *exprstate, ExprContext *econtext,
if (attnum > slot_tupdesc->natts) /* should never happen */
elog(ERROR, "attribute number %d exceeds number of columns %d",
attnum, slot_tupdesc->natts);
attr = slot_tupdesc->attrs[attnum - 1];
/* can't check type if dropped, since atttypid is probably 0 */
......@@ -1159,7 +1159,6 @@ ExecEvalParam(ExprState *exprstate, ExprContext *econtext,
ParamExecData *prm;
prm = &(econtext->ecxt_param_exec_vals[thisParamId]);
if (prm->execPlan != NULL)
{
/* Parameter not evaluated yet, so go do it */
......@@ -2848,10 +2847,10 @@ static void FastPathScalarArrayOp(ScalarArrayOpExpr *opexpr, ScalarArrayOpExprSt
* (for ANY and ALL respectively). Of course we short-circuit as soon as
* the result is known.
*/
static Datum
static Datum
ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate,
ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone)
ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone)
{
ScalarArrayOpExpr *opexpr = (ScalarArrayOpExpr *) sstate->fxprstate.xprstate.expr;
bool useOr = opexpr->useOr;
......@@ -2880,7 +2879,7 @@ ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate,
if (sstate->fxprstate.func.fn_oid == InvalidOid)
{
init_fcache(opexpr->opfuncid, &sstate->fxprstate,
econtext->ecxt_per_query_memory, true);
econtext->ecxt_per_query_memory, true);
Assert(!sstate->fxprstate.func.fn_retset);
}
......
......@@ -72,7 +72,8 @@ static void set_tablefunction_pathlist(PlannerInfo *root, RelOptInfo *rel,
RangeTblEntry *rte);
static void set_values_pathlist(PlannerInfo *root, RelOptInfo *rel,
RangeTblEntry *rte);
static void set_cte_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte);
static void set_cte_pathlist(PlannerInfo *root, RelOptInfo *rel,
RangeTblEntry *rte);
static RelOptInfo *make_rel_from_joinlist(PlannerInfo *root, List *joinlist);
static Query *push_down_restrict(PlannerInfo *root, RelOptInfo *rel,
RangeTblEntry *rte, Index rti, Query *subquery);
......
......@@ -254,8 +254,7 @@ create_subplan(PlannerInfo *root, Path *best_path)
case T_Motion:
plan = create_motion_plan(root, (CdbMotionPath *)best_path);
break;
default:
Assert(false);
default:
elog(ERROR, "unrecognized node type: %d",
(int) best_path->pathtype);
plan = NULL; /* keep compiler quiet */
......@@ -267,8 +266,7 @@ create_subplan(PlannerInfo *root, Path *best_path)
plan->dispatch = DISPATCH_PARALLEL;
return plan;
} /* create_subplan */
}
/*
* create_scan_plan
......@@ -726,6 +724,7 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path)
}
plan = make_append(subplans, false, tlist);
return (Plan *) plan;
}
......
......@@ -621,6 +621,7 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
return result;
}
/*--------------------
* subquery_planner
* Invokes the planner on a subquery. We recurse to here for each
......@@ -696,7 +697,7 @@ subquery_planner(PlannerGlobal *glob, Query *parse,
/* CDB: Stash current query level's relids before pulling up subqueries. */
root->currlevel_relids = get_relids_in_jointree((Node *)parse->jointree);
/*
/*
* Look for IN clauses at the top level of WHERE, and transform them into
* joins. Note that this step only handles IN clauses originally at top
* level of WHERE; if we pull up any subqueries in the next step, their
......@@ -949,7 +950,7 @@ subquery_planner(PlannerGlobal *glob, Query *parse,
* initPlan list and extParam/allParam sets for plan nodes, and attach the
* initPlans to the top plan node.
*/
if (list_length(glob->subplans) != num_old_subplans ||
if (list_length(glob->subplans) != num_old_subplans ||
root->query_level > 1)
{
Assert(root->parse == parse); /* GPDP isn't always careful about this. */
......@@ -2162,7 +2163,8 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
{
result_plan = (Plan *) make_sort_from_pathkeys(root,
result_plan,
sort_pathkeys, limit_tuples, false);
sort_pathkeys,
limit_tuples, false);
if (result_plan == NULL)
elog(ERROR, "could not find sort pathkeys in result target list");
current_pathkeys = sort_pathkeys;
......
......@@ -66,7 +66,7 @@ static void reduce_outer_joins_pass2(Node *jtnode,
Relids nonnullable_rels);
static void fix_in_clause_relids(List *in_info_list, int varno,
Relids subrelids);
static void fix_append_rel_relids(List *append_rel_list, Index varno,
static void fix_append_rel_relids(List *append_rel_list, int varno,
Relids subrelids);
static Node *find_jointree_node_for_rel(Node *jtnode, int relid);
......@@ -1215,7 +1215,7 @@ fix_in_clause_relids(List *in_info_list, int varno, Relids subrelids)
* We assume we may modify the AppendRelInfo nodes in-place.
*/
static void
fix_append_rel_relids(List *append_rel_list, Index varno, Relids subrelids)
fix_append_rel_relids(List *append_rel_list, int varno, Relids subrelids)
{
ListCell *l;
int subvarno = -1;
......
......@@ -1997,16 +1997,15 @@ eval_const_expressions_mutator(Node *node,
if (IsA(node, FuncExpr))
{
FuncExpr *expr = (FuncExpr *) node;
List *args;
Expr *simple;
FuncExpr *newexpr;
if (!context->transform_functions_returning_composite_values && type_is_rowtype(expr->funcresulttype))
{
return copyObject(expr);
}
List *args = NIL;
Expr *simple = NULL;
FuncExpr *newexpr = NULL;
/*
* Reduce constants in the FuncExpr's arguments. We know args is
* either NIL or a List node, so we can call expression_tree_mutator
......@@ -3238,15 +3237,15 @@ static List *
add_function_defaults(List *args, Oid result_type, HeapTuple func_tuple)
{
Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple);
Datum proargdefaults;
bool isnull;
char *str;
List *defaults;
int ndelete;
int nargs;
Oid actual_arg_types[FUNC_MAX_ARGS];
Oid declared_arg_types[FUNC_MAX_ARGS];
Oid rettype;
Datum proargdefaults;
bool isnull;
char *str;
List *defaults;
int ndelete;
int nargs;
Oid actual_arg_types[FUNC_MAX_ARGS];
Oid declared_arg_types[FUNC_MAX_ARGS];
Oid rettype;
ListCell *lc;
/* The error cases here shouldn't happen, but check anyway */
......
......@@ -367,12 +367,15 @@ analyze_requires_snapshot(Node *parseTree)
break;
case T_ExplainStmt:
/* yes, because it's analyzed just like SELECT */
/*
* We only need a snapshot in varparams case, but it doesn't seem
* worth complicating this function's API to distinguish that.
*/
result = true;
break;
default:
/* other utility statements don't have any active parse analysis */
/* utility statements don't have any active parse analysis */
result = false;
break;
}
......@@ -2843,6 +2846,7 @@ transformReturningList(ParseState *pstate, List *returningList)
}
#endif
/*
* transformDeclareCursorStmt -
* transform a DECLARE CURSOR Statement
......
......@@ -19,19 +19,13 @@
#include "catalog/catquery.h"
#include "access/heapam.h"
#include "catalog/heap.h"
#include "catalog/pg_am.h"
#include "catalog/pg_amop.h"
#include "catalog/pg_exttable.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_opclass.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "catalog/pg_window.h"
#include "commands/defrem.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/print.h" /* XXX: remove after debugging !! */
#include "optimizer/clauses.h"
#include "optimizer/tlist.h"
#include "optimizer/var.h"
......@@ -48,7 +42,6 @@
#include "rewrite/rewriteManip.h"
#include "utils/guc.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
#include "cdb/cdbvars.h"
#include "cdb/cdbpartition.h"
......
......@@ -1372,6 +1372,7 @@ coerce_to_specific_type(ParseState *pstate, Node *node,
return node;
}
/* select_common_type()
* Determine the common supertype of a list of input expression types.
* This is used for determining the output type of CASE and UNION
......
......@@ -6,11 +6,11 @@
*/
#include "postgres.h"
#include "parser/analyze.h"
#include "parser/parse_node.h"
#include "parser/parse_cte.h"
#include "parser/parse_expr.h"
#include "parser/parse_relation.h"
#include "parser/analyze.h"
#include "nodes/parsenodes.h"
#include "nodes/nodeFuncs.h"
......@@ -29,6 +29,8 @@ static void analyzeCTETargetList(ParseState *pstate, CommonTableExpr *cte, List
List *
transformWithClause(ParseState *pstate, WithClause *withClause)
{
ListCell *lc;
if (withClause == NULL)
return NULL;
......@@ -44,22 +46,19 @@ transformWithClause(ParseState *pstate, WithClause *withClause)
Assert(pstate->p_future_ctes == NIL);
/*
* Check if CTE list in the WITH clause contains duplicate query names.
* If so, error out.
* For either type of WITH, there must not be duplicate CTE names in the
* list. Check this right away so we needn't worry later.
*
* Also, initialize other variables in CommonTableExpr.
*/
ListCell *lc;
foreach (lc, withClause->ctes)
foreach(lc, withClause->ctes)
{
CommonTableExpr *cte = (CommonTableExpr *)lfirst(lc);
CommonTableExpr *cte = (CommonTableExpr *) lfirst(lc);
ListCell *rest;
ListCell *lc2;
for_each_cell (lc2, lnext(lc))
for_each_cell(rest, lnext(lc))
{
CommonTableExpr *cte2 = (CommonTableExpr *)lfirst(lc2);
Assert(cte != NULL && cte2 != NULL &&
cte->ctename != NULL && cte2->ctename != NULL);
CommonTableExpr *cte2 = (CommonTableExpr *) lfirst(rest);
if (strcmp(cte->ctename, cte2->ctename) == 0)
{
......@@ -69,7 +68,6 @@ transformWithClause(ParseState *pstate, WithClause *withClause)
cte2->ctename),
parser_errposition(pstate, cte2->location)));
}
}
cte->cterecursive = false;
......@@ -154,14 +152,16 @@ GetCTEForRTE(ParseState *pstate, RangeTblEntry *rte, int rtelevelsup)
static void
analyzeCTE(ParseState *pstate, CommonTableExpr *cte)
{
Query *query;
Assert(cte != NULL);
Assert(cte->ctequery != NULL);
Assert(!IsA(cte->ctequery, Query));
Query *query = parse_sub_analyze(cte->ctequery, pstate);
Assert(IsA(query, Query));
query = parse_sub_analyze(cte->ctequery, pstate);
cte->ctequery = (Node *) query;
cte->ctequery = (Node *)query;
Assert(IsA(query, Query));
/* Check if the query is what we expected. */
if (!IsA(query, Query))
......@@ -226,27 +226,29 @@ reportDuplicateNames(const char *queryName, List *names)
static void
analyzeCTETargetList(ParseState *pstate, CommonTableExpr *cte, List *tlist)
{
int numaliases;
int varattno;
ListCell *tlistitem;
/* Not done already ... */
Assert(cte->ctecolnames == NIL);
/*
* We need to determine column names, types, and typmods. The alias
* column names override anything coming from the query itself. (Note:
* the SQL spec says that the alias list must be empty or exactly as long
* as the output column set. Also, the alias can not have the same name.
* We report errors if this is not the case.)
*
* We need to determine column names and types. The alias column names
* override anything coming from the query itself. (Note: the SQL spec
* says that the alias list must be empty or exactly as long as the output
* column set. Also, the alias can not have the same name. We report
* errors if this is not the case.)
*/
cte->ctecolnames = copyObject(cte->aliascolnames);
cte->ctecoltypes = cte->ctecoltypmods = NIL;
int numaliases = list_length(cte->aliascolnames);
int varattno = 0;
ListCell *tlistitem;
numaliases = list_length(cte->aliascolnames);
varattno = 0;
foreach(tlistitem, tlist)
{
TargetEntry *te = (TargetEntry *) lfirst(tlistitem);
Oid coltype;
int32 coltypmod;
Oid coltype;
int32 coltypmod;
if (te->resjunk)
continue;
......@@ -254,6 +256,8 @@ analyzeCTETargetList(ParseState *pstate, CommonTableExpr *cte, List *tlist)
Assert(varattno == te->resno);
if (varattno > numaliases)
{
char *attrname;
if (numaliases > 0)
{
ereport(ERROR,
......@@ -261,8 +265,6 @@ analyzeCTETargetList(ParseState *pstate, CommonTableExpr *cte, List *tlist)
errmsg(ERRMSG_GP_WITH_COLUMNS_MISMATCH, cte->ctename),
parser_errposition(pstate, cte->location)));
}
char *attrname;
attrname = pstrdup(te->resname);
cte->ctecolnames = lappend(cte->ctecolnames, makeString(attrname));
......
......@@ -58,7 +58,7 @@ static Node *transformAExprIn(ParseState *pstate, A_Expr *a);
static Node *transformFuncCall(ParseState *pstate, FuncCall *fn);
static Node *transformSubLink(ParseState *pstate, SubLink *sublink);
static Node *transformArrayExpr(ParseState *pstate, A_ArrayExpr *a,
Oid array_type, Oid element_type, int32 typmod);
Oid array_type, Oid element_type, int32 typmod);
static Node *transformRowExpr(ParseState *pstate, RowExpr *r);
static Node *transformTableValueExpr(ParseState *pstate, TableValueExpr *t);
static Node *transformCoalesceExpr(ParseState *pstate, CoalesceExpr *c);
......@@ -112,11 +112,6 @@ static char *percentileFuncString(PercentileExpr *p, Oid *argtypes, int arglen,
* another, such as A_Const => Const; we just do nothing when handed
* a Const. More care is needed for node types that are used as both
* input and output of transformExpr; see SubLink for example.
*
* CDB: On return, pstate->breadcrumb.node points to the original 'expr' node.
* This is intended to provide a default cursor location in case an error is
* reported during further processing of the result, such as conversion to a
* target type.
*/
Node *
transformExpr(ParseState *pstate, Node *expr)
......@@ -163,10 +158,10 @@ transformExpr(ParseState *pstate, Node *expr)
break;
}
case T_A_ArrayExpr:
result = transformArrayExpr(pstate, (A_ArrayExpr *) expr,
InvalidOid, InvalidOid, -1);
break;
case T_A_ArrayExpr:
result = transformArrayExpr(pstate, (A_ArrayExpr *) expr,
InvalidOid, InvalidOid, -1);
break;
case T_TypeCast:
{
......@@ -174,19 +169,20 @@ transformExpr(ParseState *pstate, Node *expr)
Node *arg = NULL;
/*
* If the subject of the typecast is an ARRAY[] construct
* and the target type is an array type, we invoke
* transformArrayExpr() directly so that we can pass down
* the type information. This avoids some cases where
* transformArrayExpr() might not infer the correct type
*/
* If the subject of the typecast is an ARRAY[] construct and
* the target type is an array type, we invoke
* transformArrayExpr() directly so that we can pass down the
* type information. This avoids some cases where
* transformArrayExpr() might not infer the correct type.
*/
if (IsA(tc->arg, A_ArrayExpr))
{
Oid targetType;
Oid elementType;
int32 targetTypmod;
Oid targetType;
Oid elementType;
int32 targetTypmod;
targetType = typenameTypeId(pstate, tc->typname, &targetTypmod);
targetType = typenameTypeId(pstate, tc->typname,
&targetTypmod);
elementType = get_element_type(targetType);
if (OidIsValid(elementType))
......@@ -260,7 +256,6 @@ transformExpr(ParseState *pstate, Node *expr)
result = transformFuncCall(pstate, (FuncCall *) expr);
break;
case T_SubLink:
result = transformSubLink(pstate, (SubLink *) expr);
break;
......@@ -1527,7 +1522,6 @@ transformSubLink(ParseState *pstate, SubLink *sublink)
return result;
pstate->p_hasSubLinks = true;
qtree = parse_sub_analyze(sublink->subselect, pstate);
/*
......@@ -1651,9 +1645,16 @@ transformSubLink(ParseState *pstate, SubLink *sublink)
return result;
}
/*
* transformArrayExpr
*
* If the caller specifies the target type, the resulting array will
* be of exactly that type. Otherwise we try to infer a common type
* for the elements using select_common_type().
*/
static Node *
transformArrayExpr(ParseState *pstate, A_ArrayExpr *a,
Oid array_type, Oid element_type, int32 typmod)
Oid array_type, Oid element_type, int32 typmod)
{
ArrayExpr *newa = makeNode(ArrayExpr);
List *newelems = NIL;
......@@ -1669,7 +1670,7 @@ transformArrayExpr(ParseState *pstate, A_ArrayExpr *a,
* Assume that the array is one-dimensional unless we find an array-type
* element expression.
*/
newa->multidims = false;
newa->multidims = false;
foreach(element, a->elements)
{
Node *e = (Node *) lfirst(element);
......@@ -1683,10 +1684,10 @@ transformArrayExpr(ParseState *pstate, A_ArrayExpr *a,
if (IsA(e, A_ArrayExpr))
{
newe = transformArrayExpr(pstate,
(A_ArrayExpr *) e,
array_type,
element_type,
typmod);
(A_ArrayExpr *) e,
array_type,
element_type,
typmod);
newe_type = exprType(newe);
/* we certainly have an array here */
Assert(array_type == InvalidOid || array_type == newe_type);
......@@ -1768,7 +1769,6 @@ transformArrayExpr(ParseState *pstate, A_ArrayExpr *a,
* elements, then the elements are implicitly coerced to the common type.
* This is consistent with other uses of select_common_type().
*/
foreach(element, newelems)
{
Node *e = (Node *) lfirst(element);
......@@ -1781,8 +1781,8 @@ transformArrayExpr(ParseState *pstate, A_ArrayExpr *a,
coerce_type,
typmod,
COERCION_EXPLICIT,
COERCE_EXPLICIT_CAST,-1);
COERCE_EXPLICIT_CAST,
-1);
if (newe == NULL)
ereport(ERROR,
(errcode(ERRCODE_CANNOT_COERCE),
......@@ -2119,7 +2119,8 @@ transformXmlSerialize(ParseState *pstate, XmlSerialize *xs)
*/
result = coerce_to_target_type(pstate, (Node *) xexpr,
TEXTOID, targetType, targetTypmod,
COERCION_IMPLICIT, COERCE_IMPLICIT_CAST,
COERCION_IMPLICIT,
COERCE_IMPLICIT_CAST,
xexpr->location);
if (result == NULL)
ereport(ERROR,
......@@ -2242,7 +2243,8 @@ transformWholeRowRef(ParseState *pstate, char *schemaname, char *relname,
&sublevels_up);
if (rte == NULL)
rte = addImplicitRTE(pstate, makeRangeVar(schemaname, relname, location));
rte = addImplicitRTE(pstate,
makeRangeVar(schemaname, relname, location));
vnum = RTERangeTablePosn(pstate, rte, &sublevels_up);
......@@ -3449,7 +3451,8 @@ make_row_distinct_op(ParseState *pstate, List *opname,
result = cmp;
else
result = (Node *) makeBoolExpr(OR_EXPR,
list_make2(result, cmp), location);
list_make2(result, cmp),
location);
}
if (result == NULL)
......
......@@ -17,16 +17,12 @@
#include <ctype.h>
#include "access/genam.h"
#include "access/heapam.h"
#include "catalog/heap.h"
#include "catalog/namespace.h"
#include "catalog/pg_exttable.h"
#include "catalog/pg_proc_callback.h"
#include "catalog/pg_type.h"
#include "catalog/indexing.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/relation.h" /* CdbRelColumnInfo */
......@@ -36,12 +32,9 @@
#include "parser/parse_relation.h"
#include "parser/parse_type.h"
#include "parser/parse_coerce.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
#include "utils/array.h"
#include "utils/fmgroids.h"
/* GUC parameter */
......@@ -201,24 +194,20 @@ scanNameSpaceForRelid(ParseState *pstate, Oid relid, int location)
* rejects WITH lists containing duplicate CTE names.
*/
CommonTableExpr *
scanNameSpaceForCTE(ParseState *pstate,
const char *refname,
scanNameSpaceForCTE(ParseState *pstate, const char *refname,
Index *ctelevelsup)
{
Assert(refname != NULL);
Index levelsup;
Index levelsup;
for (levelsup = 0;
pstate != NULL;
pstate = pstate->parentParseState, levelsup++)
{
ListCell *lc;
ListCell *lc;
foreach(lc, pstate->p_ctenamespace)
{
CommonTableExpr *cte = (CommonTableExpr *) lfirst(lc);
Assert(cte != NULL && cte->ctename != NULL);
if (strcmp(cte->ctename, refname) == 0)
{
......@@ -227,7 +216,6 @@ scanNameSpaceForCTE(ParseState *pstate,
}
}
}
return NULL;
}
......@@ -266,16 +254,17 @@ isFutureCTE(ParseState *pstate, const char *refname)
* valid matches, but only one will be returned). This must be used ONLY
* as a heuristic in giving suitable error messages. See warnAutoRange.
*
* Notice that we consider both matches on actual relation name (or CTE) and matches
* on alias.
* Notice that we consider both matches on actual relation (or CTE) name
* and matches on alias.
*/
static RangeTblEntry *
searchRangeTable(ParseState *pstate, RangeVar *relation)
{
Oid relId = InvalidOid;
const char *refname = relation->relname;
Oid relId = InvalidOid;
CommonTableExpr *cte = NULL;
Index ctelevelsup = 0;
Index ctelevelsup = 0;
Index levelsup;
/*
* If it's an unqualified name, check for possible CTE matches. A CTE
......@@ -287,8 +276,10 @@ searchRangeTable(ParseState *pstate, RangeVar *relation)
if (!cte)
relId = RangeVarGetRelid(relation, true);
Index levelsup = 0;
while (pstate != NULL)
/* Now look for RTEs matching either the relation/CTE or the alias */
for (levelsup = 0;
pstate != NULL;
pstate = pstate->parentParseState, levelsup++)
{
ListCell *l;
......@@ -296,11 +287,10 @@ searchRangeTable(ParseState *pstate, RangeVar *relation)
{
RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
if (OidIsValid(relId) &&
rte->rtekind == RTE_RELATION &&
if (rte->rtekind == RTE_RELATION &&
OidIsValid(relId) &&
rte->relid == relId)
return rte;
if (rte->rtekind == RTE_CTE &&
cte != NULL &&
rte->ctelevelsup + levelsup == ctelevelsup &&
......@@ -312,9 +302,6 @@ searchRangeTable(ParseState *pstate, RangeVar *relation)
strcmp(rte->eref->aliasname, refname) == 0)
return rte;
}
pstate = pstate->parentParseState;
levelsup++;
}
return NULL;
}
......@@ -764,15 +751,15 @@ addRangeTableEntry(ParseState *pstate,
bool inh,
bool inFromCl)
{
RangeTblEntry *rte = makeNode(RangeTblEntry);
char *refname = alias ? alias->aliasname : relation->relname;
LOCKMODE lockmode = AccessShareLock;
bool nowait = false;
LockingClause *locking;
Relation rel;
ParseCallbackState pcbstate;
/*
RangeTblEntry *rte = makeNode(RangeTblEntry);
char *refname = alias ? alias->aliasname : relation->relname;
LOCKMODE lockmode = AccessShareLock;
bool nowait = false;
LockingClause *locking;
Relation rel;
ParseCallbackState pcbstate;
/*
* CDB: lock promotion around the locking clause is a little different
* from postgres to allow for required lock promotion for distributed
* tables.
......@@ -786,7 +773,7 @@ addRangeTableEntry(ParseState *pstate,
setup_parser_errposition_callback(&pcbstate, pstate, relation->location);
rel = parserOpenTable(pstate, relation, lockmode, nowait, NULL);
cancel_parser_errposition_callback(&pcbstate);
/*
* 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
......@@ -1373,6 +1360,11 @@ addRangeTableEntryForCTE(ParseState *pstate,
bool inFromCl)
{
RangeTblEntry *rte = makeNode(RangeTblEntry);
char *refname;
Alias *eref;
int numaliases;
int varattno;
ListCell *lc;
rte->rtekind = RTE_CTE;
rte->ctename = cte->ctename;
......@@ -1393,18 +1385,15 @@ addRangeTableEntryForCTE(ParseState *pstate,
rte->ctecoltypmods = cte->ctecoltypmods;
rte->alias = rangeVar->alias;
char *refname = rte->alias ? rte->alias->aliasname : cte->ctename;
Alias *eref;
refname = rte->alias ? rte->alias->aliasname : cte->ctename;
if (rte->alias)
eref = copyObject(rte->alias);
else
eref = makeAlias(refname, NIL);
int numaliases = list_length(eref->colnames);
numaliases = list_length(eref->colnames);
/* fill in any unspecified alias columns */
int varattno = 0;
ListCell *lc;
varattno = 0;
foreach(lc, cte->ctecolnames)
{
varattno++;
......@@ -2299,7 +2288,7 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
case RTE_SUBQUERY:
case RTE_VALUES:
case RTE_CTE:
/* Subselect and Values RTEs never have dropped columns */
/* Subselect, Values, CTE RTEs never have dropped columns */
result = false;
break;
case RTE_JOIN:
......
......@@ -1127,7 +1127,7 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
char *label = strVal(lfirst(lname));
Node *varnode = (Node *) lfirst(lvar);
TupleDescInitEntry(tupleDesc, (AttrNumber) i,
TupleDescInitEntry(tupleDesc, i,
label,
exprType(varnode),
exprTypmod(varnode),
......
......@@ -2461,7 +2461,6 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt,
}
}
/*
* transformIndexStmt - parse analysis for CREATE INDEX
*
......@@ -3521,6 +3520,10 @@ transformCreateSchemaStmt(CreateSchemaStmt *stmt)
return result;
}
/*
* setSchemaName
* Set or check schema name in an element of a CREATE SCHEMA command
*/
static void
setSchemaName(char *context_schema, char **stmt_schema_name)
{
......
......@@ -87,6 +87,7 @@ static bool IsForInput;
/* local state for LockBufferForCleanup */
static volatile BufferDesc *PinCountWaitBuf = NULL;
static Buffer ReadBuffer_common(SMgrRelation reln, bool isLocalBuf,
bool isTemp, BlockNumber blockNum, bool zeroPage,
BufferAccessStrategy strategy,
......@@ -101,11 +102,9 @@ static bool StartBufferIO(volatile BufferDesc *buf, bool forInput);
static void TerminateBufferIO(volatile BufferDesc *buf, bool clear_dirty,
int set_flag_bits);
static void buffer_write_error_callback(void *arg);
static volatile BufferDesc *BufferAlloc(SMgrRelation reln, BlockNumber blockNum,
BufferAccessStrategy strategy,
bool *foundPtr);
static void FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln);
static void AtProcExit_Buffers(int code, Datum arg);
......@@ -1215,7 +1214,6 @@ BufferSync(int flags)
/* Make sure we can handle the pin inside SyncOneBuffer */
ResourceOwnerEnlargeBuffers(CurrentResourceOwner);
/*
* Loop over all buffers, and mark the ones that need to be written with
* BM_CHECKPOINT_NEEDED. Count them as we go (num_to_write), so that we
......@@ -1664,7 +1662,7 @@ SyncOneBuffer(int buf_id, bool skip_recently_used)
return result;
}
/*
* Pin it, share-lock it, write it. (FlushBuffer will do nothing if the
* buffer is clean by the time we've locked it.)
......@@ -2116,12 +2114,12 @@ RelationTruncate(Relation rel, BlockNumber nblocks, bool markPersistentAsPhysica
* --------------------------------------------------------------------
*/
void
DropRelFileNodeBuffers(RelFileNode rnode, bool isLocalBuf,
DropRelFileNodeBuffers(RelFileNode rnode, bool istemp,
BlockNumber firstDelBlock)
{
int i;
if (isLocalBuf) /*CDB*/
if (istemp)
{
DropRelFileNodeLocalBuffers(rnode, firstDelBlock);
return;
......@@ -2401,7 +2399,6 @@ ReleaseBuffer(Buffer buffer)
UnpinBuffer(bufHdr, false);
}
/*
* UnlockReleaseBuffer -- release the content lock and pin on a buffer
*
......
......@@ -187,6 +187,7 @@ static int recursion_depth = 0; /* to detect actual recursion */
static char formatted_start_time[FORMATTED_TS_LEN];
static char formatted_log_time[FORMATTED_TS_LEN];
/* Macro for checking errordata_stack_depth is reasonable */
#define CHECK_STACK_DEPTH() \
do { \
......@@ -197,6 +198,7 @@ static char formatted_log_time[FORMATTED_TS_LEN];
} \
} while (0)
static void cdb_tidy_message(ErrorData *edata);
static void log_line_prefix(StringInfo buf);
static void send_message_to_server_log(ErrorData *edata);
......@@ -2424,7 +2426,7 @@ log_line_prefix(StringInfo buf)
if (MyProcPort)
{
const char *psdisp;
int displen;
int displen;
psdisp = get_ps_display(&displen);
appendBinaryStringInfo(buf, psdisp, displen);
......@@ -2698,7 +2700,7 @@ write_csvlog(ErrorData *edata)
psdisp = get_ps_display(&displen);
appendBinaryStringInfo(&msgbuf, psdisp, displen);
appendCSVLiteral(&buf, msgbuf.data);
pfree(msgbuf.data);
}
appendStringInfoChar(&buf, ',');
......@@ -3485,9 +3487,9 @@ write_message_to_server_log(int elevel,
static void
send_message_to_server_log(ErrorData *edata)
{
StringInfoData buf;
StringInfoData prefix;
int nc;
StringInfoData buf;
StringInfoData prefix;
int nc;
AssertImply(mainthread() != 0, mythread() == mainthread());
......
......@@ -560,7 +560,7 @@ static struct config_bool ConfigureNamesBool[] =
{"constraint_exclusion", PGC_USERSET, QUERY_TUNING_OTHER,
gettext_noop("Enables the planner to use constraints to optimize queries."),
gettext_noop("Child table scans will be skipped if their "
"constraints guarantee that no rows match the query."),
"constraints guarantee that no rows match the query."),
GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
},
&constraint_exclusion,
......@@ -1453,7 +1453,7 @@ static struct config_int ConfigureNamesInt[] =
{
{"max_prepared_transactions", PGC_POSTMASTER, RESOURCES,
gettext_noop("Sets the maximum number of simultaneously prepared transactions."),
NULL
NULL
},
&max_prepared_xacts,
50, 1, 1000, NULL, NULL
......@@ -1780,7 +1780,7 @@ static struct config_int ConfigureNamesInt[] =
GUC_NOT_IN_SAMPLE | GUC_NO_SHOW_ALL
},
&autovacuum_freeze_max_age,
200000000, 1000, 2000000000, NULL, NULL
200000000, 100000000, 2000000000, NULL, NULL
},
{
/* see max_connections */
......@@ -1977,7 +1977,7 @@ static struct config_real ConfigureNamesReal[] =
{
{"geqo_selection_bias", PGC_USERSET, DEFUNCT_OPTIONS,
gettext_noop("Unused. Syntax check only for PostgreSQL compatibility."),
NULL,
NULL,
GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
},
&defunct_double,
......@@ -2203,7 +2203,7 @@ static struct config_string ConfigureNamesString[] =
{"default_transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
gettext_noop("Sets the transaction isolation level of each new transaction."),
gettext_noop("Each SQL transaction has an isolation level, which "
"can be either \"read uncommitted\", \"read committed\", \"repeatable read\", or \"serializable\"."),
"can be either \"read uncommitted\", \"read committed\", \"repeatable read\", or \"serializable\".")
},
&default_iso_level_string,
"read committed", assign_defaultxactisolevel, NULL
......@@ -2644,7 +2644,7 @@ static struct config_string ConfigureNamesString[] =
&external_pid_file,
NULL, assign_canonical_path, NULL
},
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, NULL, NULL, NULL
......@@ -3504,7 +3504,7 @@ InitializeGUCOptions(void)
bool
SelectConfigFiles(const char *userDoption, const char *progname)
{
char *configdir = NULL;
char *configdir;
char *fname;
struct stat stat_buf;
......@@ -4384,9 +4384,9 @@ parse_int(const char *value, int *result, int flags, const char **hintmsg)
/*
* Try to parse value as a floating point constant in the usual
* format. If the value parsed okay return true, else false. If
* result is not NULL, return the semantic value there.
* Try to parse value as a floating point number in the usual format.
* If the string parses okay, return true, else false.
* If okay and result is not NULL, return the value in *result.
*/
static bool
parse_real(const char *value, double *result)
......@@ -5502,8 +5502,6 @@ ExtractSetVariableArgs(VariableSetStmt *stmt)
}
}
/*
* SetPGVariable - SET command exported as an easily-C-callable function.
*
......@@ -6798,6 +6796,7 @@ ParseLongOption(const char *string, char **name, char **value)
*cp = '_';
}
/*
* Handle options fetched from pg_database.datconfig, pg_authid.rolconfig,
* pg_proc.proconfig, etc. Caller must specify proper context/source/action.
......@@ -7088,6 +7087,7 @@ GUCArrayReset(ArrayType *array)
return newarray;
}
/*
* assign_hook and show_hook subroutines
*/
......
......@@ -44,6 +44,6 @@ extern Oid typeidTypeRelid(Oid type_id);
extern void parseTypeString(const char *str, Oid *type_id, int32 *typmod_p);
#define ISCOMPLEX(typid) (typeidTypeRelid(typid) != InvalidOid)
#define ISCOMPLEX(typeid) (typeidTypeRelid(typeid) != InvalidOid)
#endif /* PARSE_TYPE_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册