File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.47 2000/10/05 19:11:33 tgl Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.48 2000/11/09 04:14:32 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -374,6 +374,22 @@ select_common_type(List *typeids, const char *context)
374
374
}
375
375
}
376
376
}
377
+
378
+ /*
379
+ * If all the inputs were UNKNOWN type --- ie, unknown-type literals ---
380
+ * then resolve as type TEXT. This situation comes up with constructs
381
+ * like
382
+ * SELECT (CASE WHEN foo THEN 'bar' ELSE 'baz' END);
383
+ * SELECT 'foo' UNION SELECT 'bar';
384
+ * It might seem desirable to leave the construct's output type as
385
+ * UNKNOWN, but that really doesn't work, because we'd probably end up
386
+ * needing a runtime coercion from UNKNOWN to something else, and we
387
+ * usually won't have it. We need to coerce the unknown literals while
388
+ * they are still literals, so a decision has to be made now.
389
+ */
390
+ if (ptype == UNKNOWNOID )
391
+ ptype = TEXTOID ;
392
+
377
393
return ptype ;
378
394
}
379
395
You can’t perform that action at this time.
0 commit comments