aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-07-14 15:25:43 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2017-07-14 15:25:43 -0400
commitdecb08ebdf07f2fea4b6bb43380366ef5defbafb (patch)
tree8df1e4ed94f556acbf1cdf99a7344f8dda474f27 /src/include
parentc95275fc202c231e867d2f0a00e8d18621b67f0d (diff)
downloadpostgresql-decb08ebdf07f2fea4b6bb43380366ef5defbafb.tar.gz
postgresql-decb08ebdf07f2fea4b6bb43380366ef5defbafb.zip
Code review for NextValueExpr expression node type.
Add missing infrastructure for this node type, notably in ruleutils.c where its lack could demonstrably cause EXPLAIN to fail. Add outfuncs/readfuncs support. (outfuncs support is useful today for debugging purposes. The readfuncs support may never be needed, since at present it would only matter for parallel query and NextValueExpr should never appear in a parallelizable query; but it seems like a bad idea to have a primnode type that isn't fully supported here.) Teach planner infrastructure that NextValueExpr is a volatile, parallel-unsafe, non-leaky expression node with cost cpu_operator_cost. Given its limited scope of usage, there *might* be no live bug today from the lack of that knowledge, but it's certainly going to bite us on the rear someday. Teach pg_stat_statements about the new node type, too. While at it, also teach cost_qual_eval() that MinMaxExpr, SQLValueFunction, XmlExpr, and CoerceToDomain should be charged as cpu_operator_cost. Failing to do this for SQLValueFunction was an oversight in my commit 0bb51aa96. The others are longer-standing oversights, but no time like the present to fix them. (In principle, CoerceToDomain could have cost much higher than this, but it doesn't presently seem worth trying to examine the domain's constraints here.) Modify execExprInterp.c to execute NextValueExpr as an out-of-line function; it seems quite unlikely to me that it's worth insisting that it be inlined in all expression eval methods. Besides, providing the out-of-line function doesn't stop anyone from inlining if they want to. Adjust some places where NextValueExpr support had been inserted with the aid of a dartboard rather than keeping it in the same order as elsewhere. Discussion: https://postgr.es/m/23862.1499981661@sss.pgh.pa.us
Diffstat (limited to 'src/include')
-rw-r--r--src/include/executor/execExpr.h3
-rw-r--r--src/include/nodes/nodes.h2
-rw-r--r--src/include/nodes/primnodes.h28
3 files changed, 17 insertions, 16 deletions
diff --git a/src/include/executor/execExpr.h b/src/include/executor/execExpr.h
index 7a65339f01a..8ee0496e010 100644
--- a/src/include/executor/execExpr.h
+++ b/src/include/executor/execExpr.h
@@ -362,7 +362,7 @@ typedef struct ExprEvalStep
SQLValueFunction *svf;
} sqlvaluefunction;
- /* for EEOP_NEXTVALUEXPR */
+ /* for EEOP_NEXTVALUEEXPR */
struct
{
Oid seqid;
@@ -615,6 +615,7 @@ extern void ExecEvalParamExtern(ExprState *state, ExprEvalStep *op,
ExprContext *econtext);
extern void ExecEvalSQLValueFunction(ExprState *state, ExprEvalStep *op);
extern void ExecEvalCurrentOfExpr(ExprState *state, ExprEvalStep *op);
+extern void ExecEvalNextValueExpr(ExprState *state, ExprEvalStep *op);
extern void ExecEvalRowNull(ExprState *state, ExprEvalStep *op,
ExprContext *econtext);
extern void ExecEvalRowNotNull(ExprState *state, ExprEvalStep *op,
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 01527399b80..27bd4f3363e 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -183,6 +183,7 @@ typedef enum NodeTag
T_CoerceToDomainValue,
T_SetToDefault,
T_CurrentOfExpr,
+ T_NextValueExpr,
T_InferenceElem,
T_TargetEntry,
T_RangeTblRef,
@@ -190,7 +191,6 @@ typedef enum NodeTag
T_FromExpr,
T_OnConflictExpr,
T_IntoClause,
- T_NextValueExpr,
/*
* TAGS FOR EXPRESSION STATE NODES (execnodes.h)
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index 38015ed5405..8c536a8d38d 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -1280,6 +1280,20 @@ typedef struct CurrentOfExpr
} CurrentOfExpr;
/*
+ * NextValueExpr - get next value from sequence
+ *
+ * This has the same effect as calling the nextval() function, but it does not
+ * check permissions on the sequence. This is used for identity columns,
+ * where the sequence is an implicit dependency without its own permissions.
+ */
+typedef struct NextValueExpr
+{
+ Expr xpr;
+ Oid seqid;
+ Oid typeId;
+} NextValueExpr;
+
+/*
* InferenceElem - an element of a unique index inference specification
*
* This mostly matches the structure of IndexElems, but having a dedicated
@@ -1294,20 +1308,6 @@ typedef struct InferenceElem
Oid inferopclass; /* OID of att opclass, or InvalidOid */
} InferenceElem;
-/*
- * NextValueExpr - get next value from sequence
- *
- * This has the same effect as calling the nextval() function, but it does not
- * check permissions on the sequence. This is used for identity columns,
- * where the sequence is an implicit dependency without its own permissions.
- */
-typedef struct NextValueExpr
-{
- Expr xpr;
- Oid seqid;
- Oid typeId;
-} NextValueExpr;
-
/*--------------------
* TargetEntry -
* a target entry (used in query target lists)