mirror of
https://github.com/postgres/postgres.git
synced 2025-11-16 15:02:33 +03:00
When expanding a whole-row Var into a RowExpr during ResolveNew(), attach
the column alias names of the RTE referenced by the Var to the RowExpr. This is needed to allow ruleutils.c to correctly deparse FieldSelect nodes referencing such a construct. Per my recent bug report. Adding a field to RowExpr forces initdb (because of stored rules changes) so this solution is not back-patchable; which is unfortunate because 8.2 and 8.3 have this issue. But it only affects EXPLAIN for some pretty odd corner cases, so we can probably live without a solution for the back branches.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.142 2008/10/04 21:56:55 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.143 2008/10/06 17:39:26 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -740,6 +740,12 @@ typedef struct ArrayExpr
|
||||
* not RECORD types, since those are built from the RowExpr itself rather
|
||||
* 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.
|
||||
*/
|
||||
typedef struct RowExpr
|
||||
{
|
||||
@@ -754,6 +760,7 @@ typedef struct RowExpr
|
||||
* parsetrees. We must assume typmod -1 for a RowExpr node.
|
||||
*/
|
||||
CoercionForm row_format; /* how to display this node */
|
||||
List *colnames; /* list of String, or NIL */
|
||||
int location; /* token location, or -1 if unknown */
|
||||
} RowExpr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user