diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-11-09 04:14:32 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-11-09 04:14:32 +0000 |
commit | 372e598c44a9f26cd30bbf96896813d0ef3557b2 (patch) | |
tree | 9562198da565ab3d382226ff2f5f71bd9327bf10 /src | |
parent | 9bbca2c0f09868bd627293b7a1dfc266315b8277 (diff) | |
download | postgresql-372e598c44a9f26cd30bbf96896813d0ef3557b2.tar.gz postgresql-372e598c44a9f26cd30bbf96896813d0ef3557b2.zip |
Arrange for CASE or UNION with only untyped literal constants as input
to resolve the unknown constants as type TEXT.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/parser/parse_coerce.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index ef13d67cf1c..f0d3427d17e 100644 --- a/src/backend/parser/parse_coerce.c +++ b/src/backend/parser/parse_coerce.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.47 2000/10/05 19:11:33 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.48 2000/11/09 04:14:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -374,6 +374,22 @@ select_common_type(List *typeids, const char *context) } } } + + /* + * If all the inputs were UNKNOWN type --- ie, unknown-type literals --- + * then resolve as type TEXT. This situation comes up with constructs + * like + * SELECT (CASE WHEN foo THEN 'bar' ELSE 'baz' END); + * SELECT 'foo' UNION SELECT 'bar'; + * It might seem desirable to leave the construct's output type as + * UNKNOWN, but that really doesn't work, because we'd probably end up + * needing a runtime coercion from UNKNOWN to something else, and we + * usually won't have it. We need to coerce the unknown literals while + * they are still literals, so a decision has to be made now. + */ + if (ptype == UNKNOWNOID) + ptype = TEXTOID; + return ptype; } |