diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-12-01 00:53:18 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-12-01 00:53:18 -0500 |
commit | 225f0aa3dfef55554cbe2e6da73df5e41b9eec18 (patch) | |
tree | d56a67413567230eeb8166a2666ed22cfe9b4d7e /src/backend/optimizer/util/clauses.c | |
parent | c0b5fac7010fa3468577d3a90ee8783639500fed (diff) | |
download | postgresql-225f0aa3dfef55554cbe2e6da73df5e41b9eec18.tar.gz postgresql-225f0aa3dfef55554cbe2e6da73df5e41b9eec18.zip |
Prevent inlining a SQL function with multiple OUT parameters.
There were corner cases in which the planner would attempt to inline such
a function, which would result in a failure at runtime due to loss of
information about exactly what the result record type is. Fix by disabling
inlining when the function's recorded result type is RECORD. There might
be some sub-cases where inlining could still be allowed, but this is a
simple and backpatchable fix, so leave refinements for another day.
Per bug #5777 from Nate Carson.
Back-patch to all supported branches. 8.1 happens to avoid a core-dump
here, but it still does the wrong thing.
Diffstat (limited to 'src/backend/optimizer/util/clauses.c')
-rw-r--r-- | src/backend/optimizer/util/clauses.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index de2e66b0f16..80dfaad736f 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -3677,6 +3677,10 @@ evaluate_function(Oid funcid, Oid result_type, int32 result_typmod, List *args, * We must also beware of changing the volatility or strictness status of * functions by inlining them. * + * Also, at the moment we can't inline functions returning RECORD. This + * doesn't work in the general case because it discards information such + * as OUT-parameter declarations. + * * Returns a simplified expression if successful, or NULL if cannot * simplify the function. */ @@ -3709,6 +3713,7 @@ inline_function(Oid funcid, Oid result_type, List *args, if (funcform->prolang != SQLlanguageId || funcform->prosecdef || funcform->proretset || + funcform->prorettype == RECORDOID || !heap_attisnull(func_tuple, Anum_pg_proc_proconfig) || funcform->pronargs != list_length(args)) return NULL; |