From bbd6eb5b958ef38f786089fd4a03d650d4b7220e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 19 Aug 2004 20:57:41 +0000 Subject: Repair some issues with column aliases and RowExpr construction in the presence of dropped columns. Document the already-presumed fact that eref aliases in relation RTEs are supposed to have entries for dropped columns; cause the user alias structs to have such entries too, so that there's always a one-to-one mapping to the underlying physical attnums. Adjust expandRTE() and related code to handle the case where a column that is part of a JOIN has been dropped. Generalize expandRTE()'s API so that it can be used in a couple of places that formerly rolled their own implementation of the same logic. Fix ruleutils.c to suppress display of aliases for columns that were dropped since the rule was made. --- src/backend/optimizer/util/var.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/backend/optimizer/util/var.c') diff --git a/src/backend/optimizer/util/var.c b/src/backend/optimizer/util/var.c index e46655e17db..94e0f15e289 100644 --- a/src/backend/optimizer/util/var.c +++ b/src/backend/optimizer/util/var.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/var.c,v 1.59 2004/06/01 04:47:46 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/var.c,v 1.60 2004/08/19 20:57:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -515,11 +515,19 @@ flatten_join_alias_vars_mutator(Node *node, /* Must expand whole-row reference */ RowExpr *rowexpr; List *fields = NIL; + AttrNumber attnum; ListCell *l; + attnum = 0; foreach(l, rte->joinaliasvars) { newvar = (Node *) lfirst(l); + attnum++; + /* Ignore dropped columns */ + if (get_rte_attribute_is_dropped(context->root->rtable, + var->varno, + attnum)) + continue; /* * If we are expanding an alias carried down from an upper * query, must adjust its varlevelsup fields. -- cgit v1.2.3