diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-10-06 17:39:26 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-10-06 17:39:26 +0000 |
| commit | bf461538e18b67ec05d89846fcf15fa9c0cb9a74 (patch) | |
| tree | 7603c4ac7537ccf8e0afd51fb992d5d07c0631c5 /src/backend/rewrite | |
| parent | e64bb65aff3f53b4f56b4a1ee549930b568cec99 (diff) | |
| download | postgresql-bf461538e18b67ec05d89846fcf15fa9c0cb9a74.tar.gz | |
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.
Diffstat (limited to 'src/backend/rewrite')
| -rw-r--r-- | src/backend/rewrite/rewriteManip.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/rewrite/rewriteManip.c b/src/backend/rewrite/rewriteManip.c index b5d82dd0e7..2a9645bf42 100644 --- a/src/backend/rewrite/rewriteManip.c +++ b/src/backend/rewrite/rewriteManip.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.114 2008/10/04 21:56:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.115 2008/10/06 17:39:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1057,18 +1057,20 @@ ResolveNew_mutator(Node *node, ResolveNew_context *context) { /* Must expand whole-tuple reference into RowExpr */ RowExpr *rowexpr; + List *colnames; List *fields; /* * If generating an expansion for a var of a named rowtype * (ie, this is a plain relation RTE), then we must include * dummy items for dropped columns. If the var is RECORD (ie, - * this is a JOIN), then omit dropped columns. + * this is a JOIN), then omit dropped columns. Either way, + * attach column names to the RowExpr for use of ruleutils.c. */ expandRTE(context->target_rte, this_varno, this_varlevelsup, var->location, (var->vartype != RECORDOID), - NULL, &fields); + &colnames, &fields); /* Adjust the generated per-field Vars... */ fields = (List *) ResolveNew_mutator((Node *) fields, context); @@ -1076,6 +1078,7 @@ ResolveNew_mutator(Node *node, ResolveNew_context *context) rowexpr->args = fields; rowexpr->row_typeid = var->vartype; rowexpr->row_format = COERCE_IMPLICIT_CAST; + rowexpr->colnames = colnames; rowexpr->location = -1; return (Node *) rowexpr; |
