diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2013-12-02 20:28:45 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2013-12-02 20:28:45 -0500 |
commit | 7ab321404c4f721a22e86f36f68fe5e94f65e54d (patch) | |
tree | 2fcb4cb9c2385cbdaab934a6c32be389b960f904 /src/backend/parser/parse_collate.c | |
parent | 02bb4bbc66ce2ce7ebfcb27a8a9e002ed9cadd2a (diff) | |
download | postgresql-7ab321404c4f721a22e86f36f68fe5e94f65e54d.tar.gz postgresql-7ab321404c4f721a22e86f36f68fe5e94f65e54d.zip |
Fix crash in assign_collations_walker for EXISTS with empty SELECT list.
We (I think I, actually) forgot about this corner case while coding
collation resolution. Per bug #8648 from Arjen Nienhuis.
Diffstat (limited to 'src/backend/parser/parse_collate.c')
-rw-r--r-- | src/backend/parser/parse_collate.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backend/parser/parse_collate.c b/src/backend/parser/parse_collate.c index fe57c596183..c02f98acc71 100644 --- a/src/backend/parser/parse_collate.c +++ b/src/backend/parser/parse_collate.c @@ -484,16 +484,22 @@ assign_collations_walker(Node *node, assign_collations_context *context) * SubLink. Act as though the Query returns its first output * column, which indeed is what it does for EXPR_SUBLINK and * ARRAY_SUBLINK cases. In the cases where the SubLink - * returns boolean, this info will be ignored. + * returns boolean, this info will be ignored. Special case: + * in EXISTS, the Query might return no columns, in which case + * we need do nothing. * * We needn't recurse, since the Query is already processed. */ Query *qtree = (Query *) node; TargetEntry *tent; + if (qtree->targetList == NIL) + return false; tent = (TargetEntry *) linitial(qtree->targetList); Assert(IsA(tent, TargetEntry)); - Assert(!tent->resjunk); + if (tent->resjunk) + return false; + collation = exprCollation((Node *) tent->expr); /* collation doesn't change if it's converted to array */ strength = COLLATE_IMPLICIT; |