diff options
| author | Tom Lane | 2012-02-14 22:34:19 +0000 |
|---|---|---|
| committer | Tom Lane | 2012-02-14 22:34:56 +0000 |
| commit | 398f70ec070fe60151584eaa448f04708aa77892 (patch) | |
| tree | 508ae6812ca581b5e39e11bb80206aa87e115046 /src/include | |
| parent | c1d9df4fa227781b31be44a5a3024865a7f48049 (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/include')
| -rw-r--r-- | src/include/catalog/catversion.h | 2 | ||||
| -rw-r--r-- | src/include/executor/executor.h | 2 | ||||
| -rw-r--r-- | src/include/nodes/primnodes.h | 14 | ||||
| -rw-r--r-- | src/include/optimizer/prep.h | 3 |
4 files changed, 13 insertions, 8 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index d7aabb9e4e8..7a54a74757e 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 201202131 +#define CATALOG_VERSION_NO 201202141 #endif diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 9a74541d148..7f276695712 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -256,7 +256,7 @@ extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate, TupleDesc tupType); extern TupleDesc ExecTypeFromTL(List *targetList, bool hasoid); extern TupleDesc ExecCleanTypeFromTL(List *targetList, bool hasoid); -extern TupleDesc ExecTypeFromExprList(List *exprList); +extern TupleDesc ExecTypeFromExprList(List *exprList, List *namesList); extern void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg); typedef struct TupOutputState diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index 261e7a08dd3..50831eebf8c 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -846,11 +846,15 @@ typedef struct ArrayExpr * than vice versa.) It is important not to assume that length(args) is * the same as the number of columns logically present in the rowtype. * - * colnames is NIL in a RowExpr built from an ordinary ROW() expression. - * It is provided in cases where we expand a whole-row Var into a RowExpr, - * to retain the column alias names of the RTE that the Var referenced - * (which would otherwise be very difficult to extract from the parsetree). - * Like the args list, it is one-for-one with physical fields of the rowtype. + * colnames provides field names in cases where the names can't easily be + * obtained otherwise. Names *must* be provided if row_typeid is RECORDOID. + * If row_typeid identifies a known composite type, colnames can be NIL to + * indicate the type's cataloged field names apply. Note that colnames can + * be non-NIL even for a composite type, and typically is when the RowExpr + * was created by expanding a whole-row Var. This is so that we can retain + * the column alias names of the RTE that the Var referenced (which would + * otherwise be very difficult to extract from the parsetree). Like the + * args list, colnames is one-for-one with physical fields of the rowtype. */ typedef struct RowExpr { diff --git a/src/include/optimizer/prep.h b/src/include/optimizer/prep.h index 2ea3ed1e11d..fb03acc2b44 100644 --- a/src/include/optimizer/prep.h +++ b/src/include/optimizer/prep.h @@ -52,6 +52,7 @@ extern Plan *plan_set_operations(PlannerInfo *root, double tuple_fraction, extern void expand_inherited_tables(PlannerInfo *root); -extern Node *adjust_appendrel_attrs(Node *node, AppendRelInfo *appinfo); +extern Node *adjust_appendrel_attrs(PlannerInfo *root, Node *node, + AppendRelInfo *appinfo); #endif /* PREP_H */ |
