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