summaryrefslogtreecommitdiff
path: root/src/backend/executor/execTuples.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-02-14 17:34:19 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2012-02-14 17:34:56 -0500
commit398f70ec070fe60151584eaa448f04708aa77892 (patch)
tree508ae6812ca581b5e39e11bb80206aa87e115046 /src/backend/executor/execTuples.c
parentc1d9df4fa227781b31be44a5a3024865a7f48049 (diff)
Preserve column names in the execution-time tupledesc for a RowExpr.
The hstore and json datatypes both have record-conversion functions that pay attention to column names in the composite values they're handed. We used to not worry about inserting correct field names into tuple descriptors generated at runtime, but given these examples it seems useful to do so. Observe the nicer-looking results in the regression tests whose results changed. catversion bump because there is a subtle change in requirements for stored rule parsetrees: RowExprs from ROW() constructs now have to include field names. Andrew Dunstan and Tom Lane
Diffstat (limited to 'src/backend/executor/execTuples.c')
-rw-r--r--src/backend/executor/execTuples.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c
index 3a9471e462f..e755e7c4f07 100644
--- a/src/backend/executor/execTuples.c
+++ b/src/backend/executor/execTuples.c
@@ -954,27 +954,28 @@ 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.
+ * Caller must also supply a list of field names (String nodes).
*/
TupleDesc
-ExecTypeFromExprList(List *exprList)
+ExecTypeFromExprList(List *exprList, List *namesList)
{
TupleDesc typeInfo;
- ListCell *l;
+ ListCell *le;
+ ListCell *ln;
int cur_resno = 1;
- char fldname[NAMEDATALEN];
+
+ Assert(list_length(exprList) == list_length(namesList));
typeInfo = CreateTemplateTupleDesc(list_length(exprList), false);
- foreach(l, exprList)
+ forboth(le, exprList, ln, namesList)
{
- Node *e = lfirst(l);
-
- sprintf(fldname, "f%d", cur_resno);
+ Node *e = lfirst(le);
+ char *n = strVal(lfirst(ln));
TupleDescInitEntry(typeInfo,
cur_resno,
- fldname,
+ n,
exprType(e),
exprTypmod(e),
0);