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

Commita84e90b

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 parent195516c commita84e90b

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -594,12 +594,13 @@ generate_nonunion_plan(SetOperationStmt *op, PlannerInfo *root,
594594
/* Identify the grouping semantics */
595595
groupList=generate_setop_grouplist(op,tlist);
596596

597-
/* punt if nothing to group on (can this happen?) */
597+
/* punt if nothing to group on (not worth fixing in back branches) */
598598
if (groupList==NIL)
599-
{
600-
*sortClauses=NIL;
601-
returnplan;
602-
}
599+
ereport(ERROR,
600+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
601+
/* translator: %s is UNION, INTERSECT, or EXCEPT */
602+
errmsg("%s over no columns is not supported",
603+
(op->op==SETOP_INTERSECT) ?"INTERSECT" :"EXCEPT")));
603604

604605
/*
605606
* Estimate number of distinct groups that we'll need hashtable entries
@@ -738,12 +739,12 @@ make_union_unique(SetOperationStmt *op, Plan *plan,
738739
/* Identify the grouping semantics */
739740
groupList=generate_setop_grouplist(op,plan->targetlist);
740741

741-
/* punt if nothing to group on (can this happen?) */
742+
/* punt if nothing to group on (not worth fixing in back branches) */
742743
if (groupList==NIL)
743-
{
744-
*sortClauses=NIL;
745-
returnplan;
746-
}
744+
ereport(ERROR,
745+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
746+
/* translator: %s is UNION, INTERSECT, or EXCEPT */
747+
errmsg("%s over no columns is not supported","UNION")));
747748

748749
/*
749750
* XXX for the moment, take the number of distinct groups as equal to the

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp