On Sat, May 21, 2016 at 5:03 PM, Peter Geoghegan <[email protected]> wrote: > On Sat, May 21, 2016 at 4:28 PM, <[email protected]> wrote: >> ERROR: XX000: unrecognized node type: 920 >> LOCATION: raw_expression_tree_walker, nodeFuncs.c:3410 >> >> I expected the query run successfully and return one row with 'a'. > > This is clearly a bug. > > 920 is IndexElem, which can appear in a raw parse tree in 9.5, due to > ON CONFLICT's use of inference reusing what was previously only used > for CREATE INDEX. (It does not make it into the post-parse analysis > tree, though).
Attached patch fixes this issue by adding the appropriate raw_expression_tree_walker handler. This isn't the first quasi-utility node to need such a handler, so the fix is simple. -- Peter Geoghegan
From 9610fb53586fccee1f6bb361607706e73d8a1cba Mon Sep 17 00:00:00 2001 From: Peter Geoghegan <[email protected]> Date: Mon, 23 May 2016 11:17:16 -0700 Subject: [PATCH] Add IndexElem to raw_expression_tree_walker() INSERT ... ON CONFLICT unique index inference reused IndexElem nodes within its raw parse tree. IndexElems were previously only used for CREATE INDEX. There was never an IndexElem handler within raw_expression_tree_walker(), presumably because of the assumption that IndexElem was used exclusively by utility statements, and as such required no handler. That assumption is now clearly obsolete. This can be shown easily by executing a statement with a WITH RECURSIVE CTE that contains INSERT ... ON CONFLICT ... RETURNING. Per bug #14153 from Thomas Alton. Backpatch to 9.5, where ON CONFLICT was added. --- src/backend/nodes/nodeFuncs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c index 7bc5be1..5e03efe 100644 --- a/src/backend/nodes/nodeFuncs.c +++ b/src/backend/nodes/nodeFuncs.c @@ -3370,6 +3370,18 @@ raw_expression_tree_walker(Node *node, /* for now, constraints are ignored */ } break; + case T_IndexElem: + { + IndexElem *indelem = (IndexElem *) node; + + if (walker(indelem->expr, context)) + return true; + if (walker(indelem->collation, context)) + return true; + if (walker(indelem->opclass, context)) + return true; + } + break; case T_GroupingSet: return walker(((GroupingSet *) node)->content, context); case T_LockingClause: -- 2.7.4
-- Sent via pgsql-hackers mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
