1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

Use variable aliases, if supplied, rather than real column names in

complaints about ungrouped variables.  This is for consistency with
behavior elsewhere, notably the fact that the relname is reported as
an alias in these same complaints.  Also, it'll work with subselect-
in-FROM where old code didn't.
This commit is contained in:
Tom Lane
2000-09-25 18:14:55 +00:00
parent 164caa3951
commit 8bdc2bf030
6 changed files with 62 additions and 58 deletions

View File

@ -3,7 +3,7 @@
* back to source text
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.62 2000/09/18 20:14:23 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.63 2000/09/25 18:14:54 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@ -110,7 +110,6 @@ static bool tleIsArrayAssign(TargetEntry *tle);
static char *quote_identifier(char *ident);
static char *get_relation_name(Oid relid);
static char *get_relid_attribute_name(Oid relid, AttrNumber attnum);
static char *get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum);
#define only_marker(rte) ((rte)->inh ? "" : "ONLY ")
@ -2020,33 +2019,3 @@ get_relid_attribute_name(Oid relid, AttrNumber attnum)
attnum, relid);
return attname;
}
/* ----------
* get_rte_attribute_name
* Get an attribute name from a RangeTblEntry
*
* This is unlike get_relid_attribute_name() because we use aliases if
* available.
* ----------
*/
static char *
get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
{
/*
* If there is an alias, use it
*/
if (attnum > 0 && attnum <= length(rte->eref->attrs))
return strVal(nth(attnum-1, rte->eref->attrs));
/*
* Can get here for a system attribute (which never has an alias),
* or if alias name list is too short (which probably can't happen
* anymore). Neither of these cases is valid for a subselect RTE.
*/
if (rte->relid == InvalidOid)
elog(ERROR, "Invalid attnum %d for rangetable entry %s",
attnum, rte->eref->relname);
/*
* Use the real name of the table's column
*/
return get_relid_attribute_name(rte->relid, attnum);
}