|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.236 2007/02/22 22:00:24 tgl Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.237 2007/03/06 22:45:16 tgl Exp $ |
12 | 12 | *
|
13 | 13 | * HISTORY
|
14 | 14 | * AUTHOR DATE MAJOR EVENT
|
@@ -1976,6 +1976,7 @@ eval_const_expressions_mutator(Node *node,
|
1976 | 1976 | newrelabel->arg = (Expr *) arg;
|
1977 | 1977 | newrelabel->resulttype = relabel->resulttype;
|
1978 | 1978 | newrelabel->resulttypmod = relabel->resulttypmod;
|
| 1979 | + newrelabel->relabelformat = relabel->relabelformat; |
1979 | 1980 | return (Node *) newrelabel;
|
1980 | 1981 | }
|
1981 | 1982 | }
|
@@ -2929,7 +2930,8 @@ inline_function(Oid funcid, Oid result_type, List *args,
|
2929 | 2930 | * no rewriting was needed; that's probably not important, but let's be
|
2930 | 2931 | * careful.
|
2931 | 2932 | */
|
2932 |
| - (void) check_sql_fn_retval(funcid, result_type, querytree_list, NULL); |
| 2933 | + if (check_sql_fn_retval(funcid, result_type, querytree_list, NULL)) |
| 2934 | + goto fail; /* reject whole-tuple-result cases */ |
2933 | 2935 |
|
2934 | 2936 | /*
|
2935 | 2937 | * Additional validity checks on the expression. It mustn't return a set,
|
@@ -3014,6 +3016,21 @@ inline_function(Oid funcid, Oid result_type, List *args,
|
3014 | 3016 |
|
3015 | 3017 | MemoryContextDelete(mycxt);
|
3016 | 3018 |
|
| 3019 | + /* |
| 3020 | + * Since check_sql_fn_retval allows binary-compatibility cases, the |
| 3021 | + * expression we now have might return some type that's only binary |
| 3022 | + * compatible with the original expression result type. To avoid |
| 3023 | + * confusing matters, insert a RelabelType in such cases. |
| 3024 | + */ |
| 3025 | + if (exprType(newexpr) != funcform->prorettype) |
| 3026 | + { |
| 3027 | + Assert(IsBinaryCoercible(exprType(newexpr), funcform->prorettype)); |
| 3028 | + newexpr = (Node *) makeRelabelType((Expr *) newexpr, |
| 3029 | + funcform->prorettype, |
| 3030 | + -1, |
| 3031 | + COERCE_IMPLICIT_CAST); |
| 3032 | + } |
| 3033 | + |
3017 | 3034 | /*
|
3018 | 3035 | * Recursively try to simplify the modified expression. Here we must add
|
3019 | 3036 | * the current function to the context list of active functions.
|
|
0 commit comments