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

Commit9fdbbdc

Browse files
author
Thomas G. Lockhart
committed
Fix for UNION selects with constant NULL expressions; e.g.
SELECT 1 UNION SELECT NULL;
1 parent3733bd4 commit9fdbbdc

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

‎src/backend/parser/parse_clause.c

Lines changed: 21 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.20 1998/07/09 14:34:05 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.21 1998/07/14 03:51:42 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -472,7 +472,25 @@ transformUnionClause(List *unionClause, List *targetlist)
472472
Oidotype;
473473
otype= ((TargetEntry*)lfirst(prev_target))->resdom->restype;
474474
itype= ((TargetEntry*)lfirst(next_target))->resdom->restype;
475-
if (itype!=otype)
475+
476+
#ifdefPARSEDEBUG
477+
printf("transformUnionClause: types are %d -> %d\n",itype,otype);
478+
#endif
479+
480+
/* one or both is a NULL column? then don't convert... */
481+
if (otype==InvalidOid)
482+
{
483+
/* propagate a known type forward, if available */
484+
if (itype!=InvalidOid)
485+
{
486+
((TargetEntry*)lfirst(prev_target))->resdom->restype=itype;
487+
}
488+
}
489+
elseif (itype==InvalidOid)
490+
{
491+
}
492+
/* they don't match in type? then convert... */
493+
elseif (itype!=otype)
476494
{
477495
Node*expr;
478496

@@ -488,6 +506,7 @@ transformUnionClause(List *unionClause, List *targetlist)
488506
((TargetEntry*)lfirst(next_target))->expr=expr;
489507
((TargetEntry*)lfirst(next_target))->resdom->restype=otype;
490508
}
509+
491510
/* both are UNKNOWN? then evaluate as text... */
492511
elseif (itype==UNKNOWNOID)
493512
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp