simplify_function() mustn't try to evaluate functions that return
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 28 Jan 2004 00:05:25 +0000 (00:05 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
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 688e106f4eb3088da318714b29da36db4b8f12cd..d8809a5252dff21dbb94ce54fd25657259c0fa0a 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.154.2.1 2003/12/09 01:56:41 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.154.2.2 2004/01/28 00:05:25 tgl Exp $
  *
  * HISTORY
  *   AUTHOR            DATE            MAJOR EVENT
@@ -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.
     *