aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execTuples.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-05-10 22:44:49 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-05-10 22:44:49 +0000
commit2f63232d30ca64a8f2684af855230f23a701d371 (patch)
treeb7a7707d1ec9edf368780cd3f4a23755527c5884 /src/backend/executor/execTuples.c
parent9a939886ac782cfee3cd5fdd1c58689163ed84be (diff)
downloadpostgresql-2f63232d30ca64a8f2684af855230f23a701d371.tar.gz
postgresql-2f63232d30ca64a8f2684af855230f23a701d371.zip
Promote row expressions to full-fledged citizens of the expression syntax,
rather than allowing them only in a few special cases as before. In particular you can now pass a ROW() construct to a function that accepts a rowtype parameter. Internal generation of RowExprs fixes a number of corner cases that used to not work very well, such as referencing the whole-row result of a JOIN or subquery. This represents a further step in the work I started a month or so back to make rowtype values into first-class citizens.
Diffstat (limited to 'src/backend/executor/execTuples.c')
-rw-r--r--src/backend/executor/execTuples.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c
index faf910b736f..725b8fea0ff 100644
--- a/src/backend/executor/execTuples.c
+++ b/src/backend/executor/execTuples.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.76 2004/04/01 21:28:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.77 2004/05/10 22:44:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -111,6 +111,7 @@
#include "access/heapam.h"
#include "catalog/pg_type.h"
#include "executor/executor.h"
+#include "parser/parse_expr.h"
#include "utils/lsyscache.h"
#include "utils/typcache.h"
@@ -118,6 +119,7 @@
static TupleDesc ExecTypeFromTLInternal(List *targetList,
bool hasoid, bool skipjunk);
+
/* ----------------------------------------------------------------
* tuple table create/delete functions
* ----------------------------------------------------------------
@@ -596,6 +598,38 @@ ExecTypeFromTLInternal(List *targetList, bool hasoid, bool skipjunk)
}
/*
+ * ExecTypeFromExprList - build a tuple descriptor from a list of Exprs
+ *
+ * Here we must make up an arbitrary set of field names.
+ */
+TupleDesc
+ExecTypeFromExprList(List *exprList)
+{
+ TupleDesc typeInfo;
+ List *l;
+ int cur_resno = 1;
+ char fldname[NAMEDATALEN];
+
+ typeInfo = CreateTemplateTupleDesc(length(exprList), false);
+
+ foreach(l, exprList)
+ {
+ Node *e = lfirst(l);
+
+ sprintf(fldname, "f%d", cur_resno);
+
+ TupleDescInitEntry(typeInfo,
+ cur_resno++,
+ fldname,
+ exprType(e),
+ exprTypmod(e),
+ 0);
+ }
+
+ return typeInfo;
+}
+
+/*
* BlessTupleDesc - make a completed tuple descriptor useful for SRFs
*
* Rowtype Datums returned by a function must contain valid type information.