mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +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:
@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.406 2008/10/04 21:56:53 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.407 2008/10/06 17:39:25 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1257,6 +1257,7 @@ _copyRowExpr(RowExpr *from)
|
||||
COPY_NODE_FIELD(args);
|
||||
COPY_SCALAR_FIELD(row_typeid);
|
||||
COPY_SCALAR_FIELD(row_format);
|
||||
COPY_NODE_FIELD(colnames);
|
||||
COPY_LOCATION_FIELD(location);
|
||||
|
||||
return newnode;
|
||||
|
@ -22,7 +22,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.332 2008/10/04 21:56:53 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.333 2008/10/06 17:39:26 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -511,6 +511,7 @@ _equalRowExpr(RowExpr *a, RowExpr *b)
|
||||
b->row_format != COERCE_DONTCARE)
|
||||
return false;
|
||||
|
||||
COMPARE_NODE_FIELD(colnames);
|
||||
COMPARE_LOCATION_FIELD(location);
|
||||
|
||||
return true;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/nodeFuncs.c,v 1.33 2008/10/04 21:56:53 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/nodeFuncs.c,v 1.34 2008/10/06 17:39:26 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1172,6 +1172,7 @@ expression_tree_walker(Node *node,
|
||||
case T_ArrayExpr:
|
||||
return walker(((ArrayExpr *) node)->elements, context);
|
||||
case T_RowExpr:
|
||||
/* Assume colnames isn't interesting */
|
||||
return walker(((RowExpr *) node)->args, context);
|
||||
case T_RowCompareExpr:
|
||||
{
|
||||
@ -1735,6 +1736,7 @@ expression_tree_mutator(Node *node,
|
||||
|
||||
FLATCOPY(newnode, rowexpr, RowExpr);
|
||||
MUTATE(newnode->args, rowexpr->args, List *);
|
||||
/* Assume colnames needn't be duplicated */
|
||||
return (Node *) newnode;
|
||||
}
|
||||
break;
|
||||
@ -2174,6 +2176,7 @@ raw_expression_tree_walker(Node *node, bool (*walker) (), void *context)
|
||||
}
|
||||
break;
|
||||
case T_RowExpr:
|
||||
/* Assume colnames isn't interesting */
|
||||
return walker(((RowExpr *) node)->args, context);
|
||||
case T_CoalesceExpr:
|
||||
return walker(((CoalesceExpr *) node)->args, context);
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.340 2008/10/04 21:56:53 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.341 2008/10/06 17:39:26 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Every node type that can appear in stored rules' parsetrees *must*
|
||||
@ -1037,6 +1037,7 @@ _outRowExpr(StringInfo str, RowExpr *node)
|
||||
WRITE_NODE_FIELD(args);
|
||||
WRITE_OID_FIELD(row_typeid);
|
||||
WRITE_ENUM_FIELD(row_format, CoercionForm);
|
||||
WRITE_NODE_FIELD(colnames);
|
||||
WRITE_LOCATION_FIELD(location);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.215 2008/10/04 21:56:53 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.216 2008/10/06 17:39:26 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Path and Plan nodes do not have any readfuncs support, because we
|
||||
@ -744,6 +744,7 @@ _readRowExpr(void)
|
||||
READ_NODE_FIELD(args);
|
||||
READ_OID_FIELD(row_typeid);
|
||||
READ_ENUM_FIELD(row_format, CoercionForm);
|
||||
READ_NODE_FIELD(colnames);
|
||||
READ_LOCATION_FIELD(location);
|
||||
|
||||
READ_DONE();
|
||||
|
Reference in New Issue
Block a user