From: Pavan Deolasee Date: Fri, 18 Aug 2017 08:47:35 +0000 (+0530) Subject: Generate a DEFAULT clause for identity columns X-Git-Tag: XL_10_R1BETA1~173 X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=72fdde3af5005f5a88e3f216dcd830537acdc53f;p=postgres-xl.git Generate a DEFAULT clause for identity columns Recent changes in PG 10 generates a nextval() expression (there was no support for NextValExpr in ruleutils before that). But that fails on the datanode side because only DEFAULT values are accepted for identity columns, unless overridden. This patch restores the XL behaviour, thus helping the regression. --- diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index adc56bb7d3..347a481274 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -8893,6 +8893,22 @@ get_rule_expr(Node *node, deparse_context *context, } break; + case T_NextValueExpr: + { + /* + * This gets invoked by Fast Query Shipping code to deparse a + * query. It seems enough to just generate a "DEFAULT" clause + * and let the remote datanode handle finding the correct + * sequence for replica identity. + * + * XXX PG10MERGE: If we do see issues with this, it might be + * worthwhile to consider generating an expression such as, + * nextval('sequence_name'::regclass) + */ + appendStringInfoString(buf, "DEFAULT"); + } + break; + case T_XmlExpr: { XmlExpr *xexpr = (XmlExpr *) node; @@ -9176,22 +9192,6 @@ get_rule_expr(Node *node, deparse_context *context, } break; - case T_NextValueExpr: - { - NextValueExpr *nvexpr = (NextValueExpr *) node; - - /* - * This isn't exactly nextval(), but that seems close enough - * for EXPLAIN's purposes. - */ - appendStringInfoString(buf, "nextval("); - simple_quote_literal(buf, - generate_relation_name(nvexpr->seqid, - NIL)); - appendStringInfoChar(buf, ')'); - } - break; - case T_InferenceElem: { InferenceElem *iexpr = (InferenceElem *) node;