diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-08-11 23:04:50 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-08-11 23:04:50 +0000 |
commit | 302f1a86dc1125f681b9a3b3509d1be7e33b0e4f (patch) | |
tree | 9d31b15b5e5dac59aee0ce26597306a491512c31 /src/backend/utils/cache | |
parent | 730b3a150238578505638ab2331bf569c89d8f7b (diff) | |
download | postgresql-302f1a86dc1125f681b9a3b3509d1be7e33b0e4f.tar.gz postgresql-302f1a86dc1125f681b9a3b3509d1be7e33b0e4f.zip |
Rewriter and planner should use only resno, not resname, to identify
target columns in INSERT and UPDATE targetlists. Don't rely on resname
to be accurate in ruleutils, either. This fixes bug reported by
Donald Fraser, in which renaming a column referenced in a rule did not
work very well.
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r-- | src/backend/utils/cache/lsyscache.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 0dfa0eb7c79..0faa097f349 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.105 2003/08/04 02:40:06 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.106 2003/08/11 23:04:49 tgl Exp $ * * NOTES * Eventually, the index information should go through here, too. @@ -180,11 +180,10 @@ get_op_hash_function(Oid opno) /* * get_attname - * * Given the relation id and the attribute number, * return the "attname" field from the attribute relation. * - * Note: returns a palloc'd copy of the string, or NULL if no such operator. + * Note: returns a palloc'd copy of the string, or NULL if no such attribute. */ char * get_attname(Oid relid, AttrNumber attnum) @@ -209,6 +208,24 @@ get_attname(Oid relid, AttrNumber attnum) } /* + * get_relid_attribute_name + * + * Same as above routine get_attname(), except that error + * is handled by elog() instead of returning NULL. + */ +char * +get_relid_attribute_name(Oid relid, AttrNumber attnum) +{ + char *attname; + + attname = get_attname(relid, attnum); + if (attname == NULL) + elog(ERROR, "cache lookup failed for attribute %d of relation %u", + attnum, relid); + return attname; +} + +/* * get_attnum * * Given the relation id and the attribute name, @@ -1443,7 +1460,7 @@ get_typtype(Oid typid) * get_typname * Returns the name of a given type. * - * Returns a palloc'd copy of the string, or NULL if no such relation. + * Returns a palloc'd copy of the string, or NULL if no such type. * * NOTE: since type name is not unique, be wary of code that uses this * for anything except preparing error messages. |