simplify_function() mustn't try to evaluate functions that return
authorTom Lane <[email protected]>
Wed, 28 Jan 2004 00:05:25 +0000 (00:05 +0000)
committerTom Lane <[email protected]>
Wed, 28 Jan 2004 00:05:25 +0000 (00:05 +0000)
composite types, because TupleTableSlots aren't Datums and can't be
stored in Const nodes.  We can remove this restriction if we ever
adopt a cleaner runtime representation for whole-tuple results, but
at the moment it's broken.  Per example from Thomas Hallgren.

src/backend/optimizer/util/clauses.c

index 16c311a7e296b7ccda3fc0c290578475f29a6cb3..ff36afc6f29763c2ac639c7a2176124d901d6b06 100644 (file)
@@ -1655,6 +1655,7 @@ evaluate_function(Oid funcid, Oid result_type, List *args,
        bool            has_null_input = false;
        List       *arg;
        FuncExpr   *newexpr;
+       char            result_typtype;
 
        /*
         * Can't simplify if it returns a set.
@@ -1691,6 +1692,15 @@ evaluate_function(Oid funcid, Oid result_type, List *args,
                has_nonconst_input)
                return NULL;
 
+       /*
+        * Can't simplify functions returning composite types (mainly because
+        * datumCopy() doesn't cope; FIXME someday when we have a saner
+        * representation for whole-tuple results).
+        */
+       result_typtype = get_typtype(funcform->prorettype);
+       if (result_typtype == 'c')
+               return NULL;
+
        /*
         * OK, looks like we can simplify this operator/function.
         *