summaryrefslogtreecommitdiff
path: root/src/backend/optimizer
diff options
context:
space:
mode:
authorPavan Deolasee2017-08-18 05:43:32 +0000
committerPavan Deolasee2017-08-18 05:43:32 +0000
commiteea51611515116fd3eff1ab795c9f2fdcf6a08cc (patch)
tree4d3e9eab417d94912201967edc679854d3ad9267 /src/backend/optimizer
parent0b69492af7186538d831823a6fce3b64616be197 (diff)
parent21d304dfedb4f26d0d6587d9ac39b1b5c499bb55 (diff)
Merge commit '21d304dfedb4f26d0d6587d9ac39b1b5c499bb55'
This is the merge-base of PostgreSQL's master branch and REL_10_STABLE branch. This should be the last merge from PG's master branch into XL 10 branch. Subsequent merges must happen from REL_10_STABLE branch
Diffstat (limited to 'src/backend/optimizer')
-rw-r--r--src/backend/optimizer/geqo/geqo_cx.c2
-rw-r--r--src/backend/optimizer/geqo/geqo_ox1.c2
-rw-r--r--src/backend/optimizer/geqo/geqo_ox2.c2
-rw-r--r--src/backend/optimizer/geqo/geqo_px.c2
-rw-r--r--src/backend/optimizer/geqo/geqo_recombination.c2
-rw-r--r--src/backend/optimizer/path/costsize.c9
-rw-r--r--src/backend/optimizer/path/indxpath.c4
-rw-r--r--src/backend/optimizer/path/pathkeys.c4
-rw-r--r--src/backend/optimizer/plan/createplan.c14
-rw-r--r--src/backend/optimizer/util/clauses.c23
10 files changed, 49 insertions, 15 deletions
diff --git a/src/backend/optimizer/geqo/geqo_cx.c b/src/backend/optimizer/geqo/geqo_cx.c
index d05327d8ab..a54690884a 100644
--- a/src/backend/optimizer/geqo/geqo_cx.c
+++ b/src/backend/optimizer/geqo/geqo_cx.c
@@ -46,7 +46,7 @@
*/
int
cx(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring,
- int num_gene, City *city_table)
+ int num_gene, City * city_table)
{
int i,
start_pos,
diff --git a/src/backend/optimizer/geqo/geqo_ox1.c b/src/backend/optimizer/geqo/geqo_ox1.c
index 53dacb811f..10d2d0a33a 100644
--- a/src/backend/optimizer/geqo/geqo_ox1.c
+++ b/src/backend/optimizer/geqo/geqo_ox1.c
@@ -45,7 +45,7 @@
*/
void
ox1(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene,
- City *city_table)
+ City * city_table)
{
int left,
right,
diff --git a/src/backend/optimizer/geqo/geqo_ox2.c b/src/backend/optimizer/geqo/geqo_ox2.c
index 8d5baa9826..72b9b0fb87 100644
--- a/src/backend/optimizer/geqo/geqo_ox2.c
+++ b/src/backend/optimizer/geqo/geqo_ox2.c
@@ -44,7 +44,7 @@
* position crossover
*/
void
-ox2(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene, City *city_table)
+ox2(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene, City * city_table)
{
int k,
j,
diff --git a/src/backend/optimizer/geqo/geqo_px.c b/src/backend/optimizer/geqo/geqo_px.c
index 2e7748c5aa..ad5ad3f1e5 100644
--- a/src/backend/optimizer/geqo/geqo_px.c
+++ b/src/backend/optimizer/geqo/geqo_px.c
@@ -45,7 +45,7 @@
*/
void
px(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene,
- City *city_table)
+ City * city_table)
{
int num_positions;
int i,
diff --git a/src/backend/optimizer/geqo/geqo_recombination.c b/src/backend/optimizer/geqo/geqo_recombination.c
index eb6ab42808..a5d3e47ad1 100644
--- a/src/backend/optimizer/geqo/geqo_recombination.c
+++ b/src/backend/optimizer/geqo/geqo_recombination.c
@@ -84,7 +84,7 @@ alloc_city_table(PlannerInfo *root, int num_gene)
* deallocate memory of city table
*/
void
-free_city_table(PlannerInfo *root, City *city_table)
+free_city_table(PlannerInfo *root, City * city_table)
{
pfree(city_table);
}
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
index b752aed3c6..d780386ee7 100644
--- a/src/backend/optimizer/path/costsize.c
+++ b/src/backend/optimizer/path/costsize.c
@@ -3642,6 +3642,15 @@ cost_qual_eval_walker(Node *node, cost_qual_eval_context *context)
cpu_operator_cost;
}
}
+ else if (IsA(node, MinMaxExpr) ||
+ IsA(node, SQLValueFunction) ||
+ IsA(node, XmlExpr) ||
+ IsA(node, CoerceToDomain) ||
+ IsA(node, NextValueExpr))
+ {
+ /* Treat all these as having cost 1 */
+ context->total.per_tuple += cpu_operator_cost;
+ }
else if (IsA(node, CurrentOfExpr))
{
/* Report high cost to prevent selection of anything but TID scan */
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c
index dedb9f521d..f35380391a 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -3978,13 +3978,13 @@ adjust_rowcompare_for_index(RowCompareExpr *clause,
expr_op = get_opfamily_member(opfam, lefttype, righttype,
op_strategy);
if (!OidIsValid(expr_op)) /* should not happen */
- elog(ERROR, "could not find member %d(%u,%u) of opfamily %u",
+ elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
op_strategy, lefttype, righttype, opfam);
if (!var_on_left)
{
expr_op = get_commutator(expr_op);
if (!OidIsValid(expr_op)) /* should not happen */
- elog(ERROR, "could not find commutator of member %d(%u,%u) of opfamily %u",
+ elog(ERROR, "could not find commutator of operator %d(%u,%u) of opfamily %u",
op_strategy, lefttype, righttype, opfam);
}
new_ops = lappend_oid(new_ops, expr_op);
diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c
index 37cfa098d4..9d83a5ca62 100644
--- a/src/backend/optimizer/path/pathkeys.c
+++ b/src/backend/optimizer/path/pathkeys.c
@@ -197,8 +197,8 @@ make_pathkey_from_sortinfo(PlannerInfo *root,
opcintype,
BTEqualStrategyNumber);
if (!OidIsValid(equality_op)) /* shouldn't happen */
- elog(ERROR, "could not find equality operator for opfamily %u",
- opfamily);
+ elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
+ BTEqualStrategyNumber, opcintype, opcintype, opfamily);
opfamilies = get_mergejoin_opfamilies(equality_op);
if (!opfamilies) /* certainly should find some */
elog(ERROR, "could not find opfamilies for equality operator %u",
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index 842c7f8c69..ce9b5d7d3a 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -2914,7 +2914,8 @@ create_indexscan_plan(PlannerInfo *root,
exprtype,
pathkey->pk_strategy);
if (!OidIsValid(sortop))
- elog(ERROR, "failed to find sort operator for ORDER BY expression");
+ elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
+ pathkey->pk_strategy, exprtype, exprtype, pathkey->pk_opfamily);
indexorderbyops = lappend_oid(indexorderbyops, sortop);
}
}
@@ -6454,7 +6455,7 @@ prepare_sort_from_pathkeys(Plan *lefttree, List *pathkeys,
pk_datatype,
pathkey->pk_strategy);
if (!OidIsValid(sortop)) /* should not happen */
- elog(ERROR, "could not find member %d(%u,%u) of opfamily %u",
+ elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
pathkey->pk_strategy, pk_datatype, pk_datatype,
pathkey->pk_opfamily);
@@ -6959,7 +6960,7 @@ make_unique_from_pathkeys(Plan *lefttree, List *pathkeys, int numCols)
pk_datatype,
BTEqualStrategyNumber);
if (!OidIsValid(eqop)) /* should not happen */
- elog(ERROR, "could not find member %d(%u,%u) of opfamily %u",
+ elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
BTEqualStrategyNumber, pk_datatype, pk_datatype,
pathkey->pk_opfamily);
@@ -7310,8 +7311,10 @@ make_modifytable(PlannerInfo *root,
}
/*
- * If the target foreign table has any row-level triggers, we can't
- * modify the foreign table directly.
+ * Try to modify the foreign table directly if (1) the FDW provides
+ * callback functions needed for that, (2) there are no row-level
+ * triggers on the foreign table, and (3) there are no WITH CHECK
+ * OPTIONs from parent views.
*/
direct_modify = false;
if (fdwroutine != NULL &&
@@ -7319,6 +7322,7 @@ make_modifytable(PlannerInfo *root,
fdwroutine->BeginDirectModify != NULL &&
fdwroutine->IterateDirectModify != NULL &&
fdwroutine->EndDirectModify != NULL &&
+ withCheckOptionLists == NIL &&
!has_row_triggers(root, rti, operation))
direct_modify = fdwroutine->PlanDirectModify(root, node, rti, i);
if (direct_modify)
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index 8961ed88a8..8b4425dcf9 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -902,6 +902,12 @@ contain_mutable_functions_walker(Node *node, void *context)
return true;
}
+ if (IsA(node, NextValueExpr))
+ {
+ /* NextValueExpr is volatile */
+ return true;
+ }
+
/*
* It should be safe to treat MinMaxExpr as immutable, because it will
* depend on a non-cross-type btree comparison function, and those should
@@ -969,6 +975,12 @@ contain_volatile_functions_walker(Node *node, void *context)
context))
return true;
+ if (IsA(node, NextValueExpr))
+ {
+ /* NextValueExpr is volatile */
+ return true;
+ }
+
/*
* See notes in contain_mutable_functions_walker about why we treat
* MinMaxExpr, XmlExpr, and CoerceToDomain as immutable, while
@@ -1019,6 +1031,8 @@ contain_volatile_functions_not_nextval_walker(Node *node, void *context)
* See notes in contain_mutable_functions_walker about why we treat
* MinMaxExpr, XmlExpr, and CoerceToDomain as immutable, while
* SQLValueFunction is stable. Hence, none of them are of interest here.
+ * Also, since we're intentionally ignoring nextval(), presumably we
+ * should ignore NextValueExpr.
*/
/* Recurse to check arguments */
@@ -1146,7 +1160,7 @@ max_parallel_hazard_walker(Node *node, max_parallel_hazard_context *context)
* contain a parallel-unsafe function; but useful constraints probably
* never would have such, and assuming they do would cripple use of
* parallel query in the presence of domain types.) SQLValueFunction
- * should be safe in all cases.
+ * should be safe in all cases. NextValueExpr is parallel-unsafe.
*/
if (IsA(node, CoerceToDomain))
{
@@ -1154,6 +1168,12 @@ max_parallel_hazard_walker(Node *node, max_parallel_hazard_context *context)
return true;
}
+ if (IsA(node, NextValueExpr))
+ {
+ if (max_parallel_hazard_test(PROPARALLEL_UNSAFE, context))
+ return true;
+ }
+
/*
* As a notational convenience for callers, look through RestrictInfo.
*/
@@ -1495,6 +1515,7 @@ contain_leaked_vars_walker(Node *node, void *context)
case T_SQLValueFunction:
case T_NullTest:
case T_BooleanTest:
+ case T_NextValueExpr:
case T_List:
/*