Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbd29bc4

Browse files
committed
Disallow UNION/INTERSECT/EXCEPT over no columns.
Since 9.4, we've allowed the syntax "select union select" and variantsof that. However, the planner wasn't expecting a no-column set operationand ended up treating the set operation as if it were UNION ALL.Pre-v10, there seem to be some executor issues that would need to befixed to support such cases, and it doesn't really seem worth expendingmuch effort on. Just disallow it, instead.Per report from Victor Yegorov.Discussion:https://postgr.es/m/CAGnEbojGJrRSOgJwNGM7JSJZpVAf8xXcVPbVrGdhbVEHZ-BUMw@mail.gmail.com
1 parent23b6341 commitbd29bc4

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

‎src/backend/optimizer/prep/prepunion.c‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,13 @@ generate_nonunion_path(SetOperationStmt *op, PlannerInfo *root,
697697
/* Identify the grouping semantics */
698698
groupList=generate_setop_grouplist(op,tlist);
699699

700-
/* punt if nothing to group on (can this happen?) */
700+
/* punt if nothing to group on (not worth fixing in back branches) */
701701
if (groupList==NIL)
702-
returnpath;
702+
ereport(ERROR,
703+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
704+
/* translator: %s is UNION, INTERSECT, or EXCEPT */
705+
errmsg("%s over no columns is not supported",
706+
(op->op==SETOP_INTERSECT) ?"INTERSECT" :"EXCEPT")));
703707

704708
/*
705709
* Estimate number of distinct groups that we'll need hashtable entries
@@ -850,9 +854,12 @@ make_union_unique(SetOperationStmt *op, Path *path, List *tlist,
850854
/* Identify the grouping semantics */
851855
groupList=generate_setop_grouplist(op,tlist);
852856

853-
/* punt if nothing to group on (can this happen?) */
857+
/* punt if nothing to group on (not worth fixing in back branches) */
854858
if (groupList==NIL)
855-
returnpath;
859+
ereport(ERROR,
860+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
861+
/* translator: %s is UNION, INTERSECT, or EXCEPT */
862+
errmsg("%s over no columns is not supported","UNION")));
856863

857864
/*
858865
* XXX for the moment, take the number of distinct groups as equal to the

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp