summaryrefslogtreecommitdiff
path: root/src/backend/nodes
diff options
context:
space:
mode:
authorPavan Deolasee2017-06-16 07:07:03 +0000
committerPavan Deolasee2017-06-16 07:07:03 +0000
commit0e9d70f6fbc88867960ec907e223201b638ec512 (patch)
treea161e64e819dd4876520a5c7af8b50c113b41d9b /src/backend/nodes
parent45bf5f09260f4db988b0479179682a7e97cebd9e (diff)
Handle NextValueExpr node correctly at various places.
read/out functions for this node type were missing. So implement those functions. In addition, the FQS code path was not recongnizing this new node type correctly. Fix that too. The ruleutils also missed ability to deparse this expression. For now we just emit a DEFAULT clause while deparsing NextValueExpr and assume that the remote node will do the necessary lookups to find the correct sequence and invoke nextval() on the sequence.
Diffstat (limited to 'src/backend/nodes')
-rw-r--r--src/backend/nodes/outfuncs.c19
-rw-r--r--src/backend/nodes/readfuncs.c23
2 files changed, 42 insertions, 0 deletions
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index b56b04a82f..1e1377f7b5 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -2533,6 +2533,22 @@ _outSQLValueFunction(StringInfo str, const SQLValueFunction *node)
}
static void
+_outNextValueExpr(StringInfo str, const NextValueExpr *node)
+{
+ WRITE_NODE_TYPE("NEXTVALUEEXPR");
+
+ if (portable_output)
+ {
+ WRITE_RELID_FIELD(seqid);
+ WRITE_TYPID_FIELD(typeId);
+ }
+ else
+ {
+ WRITE_OID_FIELD(seqid);
+ WRITE_OID_FIELD(typeId);
+ }
+}
+static void
_outXmlExpr(StringInfo str, const XmlExpr *node)
{
WRITE_NODE_TYPE("XMLEXPR");
@@ -4959,6 +4975,9 @@ outNode(StringInfo str, const void *obj)
case T_SQLValueFunction:
_outSQLValueFunction(str, obj);
break;
+ case T_NextValueExpr:
+ _outNextValueExpr(str, obj);
+ break;
case T_XmlExpr:
_outXmlExpr(str, obj);
break;
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c
index 935bb196f7..3219d00240 100644
--- a/src/backend/nodes/readfuncs.c
+++ b/src/backend/nodes/readfuncs.c
@@ -1668,6 +1668,27 @@ _readSQLValueFunction(void)
}
/*
+ * _readNextValueExpr
+ */
+static NextValueExpr *
+_readNextValueExpr(void)
+{
+ READ_LOCALS(NextValueExpr);
+
+ if (portable_input)
+ {
+ READ_RELID_FIELD(seqid);
+ READ_TYPID_FIELD(typeId);
+ }
+ else
+ {
+ READ_OID_FIELD(seqid);
+ READ_OID_FIELD(typeId);
+ }
+ READ_DONE();
+}
+
+/*
* _readXmlExpr
*/
static XmlExpr *
@@ -3888,6 +3909,8 @@ parseNodeString(void)
return_value = _readMinMaxExpr();
else if (MATCH("SQLVALUEFUNCTION", 16))
return_value = _readSQLValueFunction();
+ else if (MATCH("NEXTVALUEEXPR", 13))
+ return_value = _readNextValueExpr();
else if (MATCH("XMLEXPR", 7))
return_value = _readXmlExpr();
else if (MATCH("NULLTEST", 8))