Fix UPDATE of GENERATED ALWAYS identity columns
authorPeter Eisentraut <peter_e@gmx.net>
Sat, 1 Jul 2017 03:44:17 +0000 (23:44 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Sat, 1 Jul 2017 03:44:17 +0000 (23:44 -0400)
The bug would previously prevent the update of any column in a table
with identity columns, rather than just the actual identity column.

Reported-by: zam6ak@gmail.com
Bug: #14718

src/backend/rewrite/rewriteHandler.c

index 622521630d703c90902da85c33102a1c7e9ec597..f3c75261951e8acfbc2990d4b6b837c3893c76b6 100644 (file)
@@ -827,7 +827,7 @@ rewriteTargetListIU(List *targetList,
 
        if (commandType == CMD_UPDATE)
        {
-           if (att_tup->attidentity == ATTRIBUTE_IDENTITY_ALWAYS && !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)),