1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-16 15:02:33 +03:00

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
This commit is contained in:
Tom Lane
2012-02-14 17:34:19 -05:00
parent c1d9df4fa2
commit 398f70ec07
16 changed files with 158 additions and 100 deletions

View File

@@ -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
{