diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2024-01-20 17:54:14 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2024-01-20 17:54:14 -0500 |
commit | 58447e31890ace0d552a4bf693744bef3a5335e6 (patch) | |
tree | c170736fd48e1df283c1a6da796e2da70cb286df /src/backend/parser | |
parent | 075df6b2080b13e0a5adc88737b7c24417a873c1 (diff) | |
download | postgresql-58447e31890ace0d552a4bf693744bef3a5335e6.tar.gz postgresql-58447e31890ace0d552a4bf693744bef3a5335e6.zip |
Add hint about not qualifying UPDATE...SET target with relation name.
Target columns in UPDATE ... SET must not be qualified with the target
table; we disallow this because it'd create ambiguity about which name
is the column name in case of field-qualified names. However, newbies
have been seen to expect that they could qualify a target name just
like other names. The error message when they do is confusing:
"column "foo" of relation "foo" does not exist". To improve matters,
issue a HINT if the invalid name is qualified and matches the
relation's alias.
James Coleman (editorialized a bit by me)
Discussion: https://postgr.es/m/CAAaqYe8S2Qa060UV-YF5GoSd5PkEhLV94x-fEi3=TOtpaXCV+w@mail.gmail.com
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/analyze.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 06fc8ce98b5..dbdf6bf8964 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -2518,6 +2518,9 @@ transformUpdateTargetList(ParseState *pstate, List *origTlist) errmsg("column \"%s\" of relation \"%s\" does not exist", origTarget->name, RelationGetRelationName(pstate->p_target_relation)), + (origTarget->indirection != NIL && + strcmp(origTarget->name, pstate->p_target_nsitem->p_names->aliasname) == 0) ? + errhint("SET target columns cannot be qualified with the relation name.") : 0, parser_errposition(pstate, origTarget->location))); updateTargetListEntry(pstate, tle, origTarget->name, |