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

Commit19c4e86

Browse files
committed
Skip junk nodes when comparing UNION target list lengths.
1 parent585c967 commit19c4e86

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

‎src/backend/parser/parse_clause.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.33 1999/05/1717:03:32 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.34 1999/05/1718:22:18 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -767,8 +767,17 @@ transformUnionClause(List *unionClause, List *targetlist)
767767
Query*query= (Query*)lfirst(qlist_item);
768768
List*prev_target=targetlist;
769769
List*next_target;
770+
intprev_len=0,next_len=0;
770771

771-
if (length(targetlist)!=length(query->targetList))
772+
foreach(prev_target,targetlist)
773+
if (!((TargetEntry*)lfirst(prev_target))->resdom->resjunk)
774+
prev_len++;
775+
776+
foreach(next_target,query->targetList)
777+
if (!((TargetEntry*)lfirst(next_target))->resdom->resjunk)
778+
next_len++;
779+
780+
if (prev_len!=next_len)
772781
elog(ERROR,"Each UNION clause must have the same number of columns");
773782

774783
foreach(next_target,query->targetList)

‎src/backend/rewrite/rewriteHandler.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.42 1999/05/1717:03:38 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.43 1999/05/1718:22:19 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -2762,11 +2762,20 @@ QueryRewrite(Query *parsetree)
27622762
* attributes and the types are compatible */
27632763
voidcheck_targetlists_are_compatible(List*prev_target,List*current_target)
27642764
{
2765-
List*next_target;
2765+
List*tl,*next_target;
2766+
intprev_len=0,next_len=0;
2767+
2768+
foreach(tl,prev_target)
2769+
if (!((TargetEntry*)lfirst(tl))->resdom->resjunk)
2770+
prev_len++;
2771+
2772+
foreach(next_target,current_target)
2773+
if (!((TargetEntry*)lfirst(next_target))->resdom->resjunk)
2774+
next_len++;
27662775

2767-
if (length(prev_target)!=
2768-
length(current_target))
2769-
elog(ERROR,"Each UNION | EXCEPT | INTERSECT query must have the same number of columns.");
2776+
if (prev_len!=next_len)
2777+
elog(ERROR,"Each UNION | EXCEPT | INTERSECT query must have the same number of columns.");
2778+
27702779
foreach(next_target,current_target)
27712780
{
27722781
Oiditype;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp