diff options
| author | Tom Lane | 2004-10-07 18:38:51 +0000 |
|---|---|---|
| committer | Tom Lane | 2004-10-07 18:38:51 +0000 |
| commit | a8487e15ed91c10bdbba1096c6e941c6ecb8b11a (patch) | |
| tree | 03bad7b5e08fc0e7762b273685acc3902139dc9b /src/include | |
| parent | 6d46ea25f2131b34c1983a171e45041ba93390e0 (diff) | |
Fix problems with SQL functions returning rowtypes that have dropped
columns. The returned tuple needs to have appropriate NULL columns
inserted so that it actually matches the declared rowtype. It seemed
convenient to use a JunkFilter for this, so I made some cleanups and
simplifications in the JunkFilter code to allow it to support this
additional functionality. (That in turn exposed a latent bug in
nodeAppend.c, which is that it was returning a tuple slot whose
descriptor didn't match its data.) Also, move check_sql_fn_retval
out of pg_proc.c and into functions.c, where it seems to more naturally
belong.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/catalog/pg_proc.h | 7 | ||||
| -rw-r--r-- | src/include/executor/executor.h | 7 | ||||
| -rw-r--r-- | src/include/executor/functions.h | 8 | ||||
| -rw-r--r-- | src/include/nodes/execnodes.h | 15 |
4 files changed, 16 insertions, 21 deletions
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 8a525035fc0..b79909ad8c0 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.347 2004/10/04 22:49:55 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.348 2004/10/07 18:38:50 tgl Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -23,8 +23,6 @@ #ifndef PG_PROC_H #define PG_PROC_H -#include "nodes/pg_list.h" - /* ---------------- * postgres.h contains the system type definitions and the * CATALOG(), BOOTSTRAP and DATA() sugar words so this file @@ -3640,9 +3638,6 @@ extern Oid ProcedureCreate(const char *procedureName, const Oid *parameterTypes, const char *parameterNames[]); -extern bool check_sql_fn_retval(Oid rettype, char fn_typtype, - List *queryTreeList); - extern bool function_parse_error_transpose(const char *prosrc); #endif /* PG_PROC_H */ diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 7f894f26d8b..21d8335cfb1 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.113 2004/09/13 20:07:52 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.114 2004/10/07 18:38:51 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -85,8 +85,11 @@ extern TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable, /* * prototypes from functions in execJunk.c */ -extern JunkFilter *ExecInitJunkFilter(List *targetList, TupleDesc tupType, +extern JunkFilter *ExecInitJunkFilter(List *targetList, bool hasoid, TupleTableSlot *slot); +extern JunkFilter *ExecInitJunkFilterConversion(List *targetList, + TupleDesc cleanTupType, + TupleTableSlot *slot); extern bool ExecGetJunkAttribute(JunkFilter *junkfilter, TupleTableSlot *slot, char *attrName, Datum *value, bool *isNull); extern HeapTuple ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot); diff --git a/src/include/executor/functions.h b/src/include/executor/functions.h index 5701d62056e..5c20f47b101 100644 --- a/src/include/executor/functions.h +++ b/src/include/executor/functions.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/functions.h,v 1.22 2004/08/29 04:13:06 momjian Exp $ + * $PostgreSQL: pgsql/src/include/executor/functions.h,v 1.23 2004/10/07 18:38:51 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -15,7 +15,13 @@ #define FUNCTIONS_H #include "fmgr.h" +#include "nodes/execnodes.h" + extern Datum fmgr_sql(PG_FUNCTION_ARGS); +extern bool check_sql_fn_retval(Oid rettype, char fn_typtype, + List *queryTreeList, + JunkFilter **junkFilter); + #endif /* FUNCTIONS_H */ diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index b9782e3b6c1..07176952032 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.119 2004/08/29 05:06:57 momjian Exp $ + * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.120 2004/10/07 18:38:51 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -209,7 +209,7 @@ typedef struct ProjectionInfo * This class is used to store information regarding junk attributes. * A junk attribute is an attribute in a tuple that is needed only for * storing intermediate information in the executor, and does not belong - * in emitted tuples. For example, when we do an UPDATE query, + * in emitted tuples. For example, when we do an UPDATE query, * the planner adds a "junk" entry to the targetlist so that the tuples * returned to ExecutePlan() contain an extra attribute: the ctid of * the tuple to be updated. This is needed to do the update, but we @@ -218,12 +218,7 @@ typedef struct ProjectionInfo * real output tuple. * * targetList: the original target list (including junk attributes). - * length: the length of 'targetList'. - * tupType: the tuple descriptor for the "original" tuple - * (including the junk attributes). - * cleanTargetList: the "clean" target list (junk attributes removed). - * cleanLength: the length of 'cleanTargetList' - * cleanTupType: the tuple descriptor of the "clean" tuple (with + * cleanTupType: the tuple descriptor for the "clean" tuple (with * junk attributes removed). * cleanMap: A map with the correspondence between the non-junk * attribute numbers of the "original" tuple and the @@ -235,10 +230,6 @@ typedef struct JunkFilter { NodeTag type; List *jf_targetList; - int jf_length; - TupleDesc jf_tupType; - List *jf_cleanTargetList; - int jf_cleanLength; TupleDesc jf_cleanTupType; AttrNumber *jf_cleanMap; TupleTableSlot *jf_resultSlot; |
