|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.178 2004/12/31 22:00:27 pgsql Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.179 2005/01/12 17:32:36 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -646,17 +646,30 @@ transformExpr(ParseState *pstate, Node *expr)
|
646 | 646 |
|
647 | 647 | /* transform the test expression, if any */
|
648 | 648 | arg = transformExpr(pstate, (Node *) c->arg);
|
649 |
| - newc->arg = (Expr *) arg; |
| 649 | + |
650 | 650 | /* generate placeholder for test expression */
|
651 | 651 | if (arg)
|
652 | 652 | {
|
| 653 | + /* |
| 654 | + * If test expression is an untyped literal, force it to |
| 655 | + * text. We have to do something now because we won't be |
| 656 | + * able to do this coercion on the placeholder. This is |
| 657 | + * not as flexible as what was done in 7.4 and before, |
| 658 | + * but it's good enough to handle the sort of silly |
| 659 | + * coding commonly seen. |
| 660 | + */ |
| 661 | + if (exprType(arg) == UNKNOWNOID) |
| 662 | + arg = coerce_to_common_type(pstate, arg, |
| 663 | + TEXTOID, "CASE"); |
653 | 664 | placeholder = makeNode(CaseTestExpr);
|
654 | 665 | placeholder->typeId = exprType(arg);
|
655 | 666 | placeholder->typeMod = exprTypmod(arg);
|
656 | 667 | }
|
657 | 668 | else
|
658 | 669 | placeholder = NULL;
|
659 | 670 |
|
| 671 | + newc->arg = (Expr *) arg; |
| 672 | + |
660 | 673 | /* transform the list of arguments */
|
661 | 674 | newargs = NIL;
|
662 | 675 | typeids = NIL;
|
|
0 commit comments