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/parser/parse_target.c | |
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/parser/parse_target.c')
-rw-r--r-- | src/backend/parser/parse_target.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index a525e8795f0..5d5ee56eb14 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.111 2003/08/11 20:46:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.112 2003/08/11 23:04:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -71,7 +71,7 @@ transformTargetEntry(ParseState *pstate, type_id = exprType(expr); type_mod = exprTypmod(expr); - if (colname == NULL) + if (colname == NULL && !resjunk) { /* * Generate a suitable column name for a column without any @@ -428,14 +428,19 @@ updateTargetListEntry(ParseState *pstate, /* * The result of the target expression should now match the - * destination column's type. Also, reset the resname and resno to - * identify the destination column --- rewriter and planner depend on - * that! + * destination column's type. */ resnode->restype = attrtype; resnode->restypmod = attrtypmod; - resnode->resname = colname; + /* + * Set the resno to identify the target column --- the rewriter and + * planner depend on this. We also set the resname to identify the + * target column, but this is only for debugging purposes; it should + * not be relied on. (In particular, it might be out of date in a + * stored rule.) + */ resnode->resno = (AttrNumber) attrno; + resnode->resname = colname; } |