aboutsummaryrefslogtreecommitdiff
path: root/src/backend/rewrite/rewriteHandler.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-11-23 11:15:03 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2020-11-23 11:15:12 -0500
commitd36228a9fcdccd57a7dc332572eb9837c7c301e6 (patch)
tree6810f6bcd51f6538bbe7b1b564cdb476651b2f20 /src/backend/rewrite/rewriteHandler.c
parentfe051291550ab88267ce3104e9833925bf757393 (diff)
downloadpostgresql-d36228a9fcdccd57a7dc332572eb9837c7c301e6.tar.gz
postgresql-d36228a9fcdccd57a7dc332572eb9837c7c301e6.zip
Improve wording of two error messages related to generated columns.
Clarify that you can "insert" into a generated column as long as what you're inserting is a DEFAULT placeholder. Also, use ERRCODE_GENERATED_ALWAYS in place of ERRCODE_SYNTAX_ERROR; there doesn't seem to be any reason to use the less specific errcode. Discussion: https://postgr.es/m/9q0sgcr416t.fsf@gmx.us
Diffstat (limited to 'src/backend/rewrite/rewriteHandler.c')
-rw-r--r--src/backend/rewrite/rewriteHandler.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index 839583f8340..c25012f325b 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -861,7 +861,7 @@ rewriteTargetListIU(List *targetList,
if (!apply_default)
ereport(ERROR,
(errcode(ERRCODE_GENERATED_ALWAYS),
- errmsg("cannot insert into column \"%s\"",
+ errmsg("cannot insert a non-DEFAULT value into column \"%s\"",
NameStr(att_tup->attname)),
errdetail("Column \"%s\" is an identity column defined as GENERATED ALWAYS.",
NameStr(att_tup->attname)),
@@ -899,8 +899,8 @@ rewriteTargetListIU(List *targetList,
if (!apply_default)
ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("cannot insert into column \"%s\"",
+ (errcode(ERRCODE_GENERATED_ALWAYS),
+ errmsg("cannot insert a non-DEFAULT value into column \"%s\"",
NameStr(att_tup->attname)),
errdetail("Column \"%s\" is a generated column.",
NameStr(att_tup->attname))));
@@ -923,17 +923,20 @@ rewriteTargetListIU(List *targetList,
*/
if (commandType == CMD_UPDATE)
{
- if (att_tup->attidentity == ATTRIBUTE_IDENTITY_ALWAYS && new_tle && !apply_default)
+ if (att_tup->attidentity == ATTRIBUTE_IDENTITY_ALWAYS &&
+ new_tle && !apply_default)
ereport(ERROR,
(errcode(ERRCODE_GENERATED_ALWAYS),
- errmsg("column \"%s\" can only be updated to DEFAULT", NameStr(att_tup->attname)),
+ errmsg("column \"%s\" can only be updated to DEFAULT",
+ NameStr(att_tup->attname)),
errdetail("Column \"%s\" is an identity column defined as GENERATED ALWAYS.",
NameStr(att_tup->attname))));
if (att_tup->attgenerated && new_tle && !apply_default)
ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("column \"%s\" can only be updated to DEFAULT", NameStr(att_tup->attname)),
+ (errcode(ERRCODE_GENERATED_ALWAYS),
+ errmsg("column \"%s\" can only be updated to DEFAULT",
+ NameStr(att_tup->attname)),
errdetail("Column \"%s\" is a generated column.",
NameStr(att_tup->attname))));
}