Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 84a6772

Browse files
committed
Fix handling of CREATE DOMAIN with GENERATED constraint syntax
Stuff like CREATE DOMAIN foo AS int CONSTRAINT cc GENERATED ALWAYS AS (2) STORED is not supported for domains, but the parser allows it, because it's the same syntax as for table constraints. But CreateDomain() did not explicitly handle all ConstrType values, so the above would get an internal error like ERROR: unrecognized constraint subtype: 4 Fix that by providing a user-facing error message for all ConstrType values. Also, remove the switch default case, so future additions to ConstrType are caught. Reported-by: Jian He <jian.universality@gmail.com> Discussion: https://www.postgresql.org/message-id/CACJufxF8fmM=Dbm4pDFuV_nKGz2-No0k4YifhrF3-rjXTWJM3w@mail.gmail.com
1 parent 1acf105 commit 84a6772

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/backend/commands/typecmds.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,10 +1011,14 @@ DefineDomain(CreateDomainStmt *stmt)
10111011
errmsg("specifying constraint deferrability not supported for domains")));
10121012
break;
10131013

1014-
default:
1015-
elog(ERROR, "unrecognized constraint subtype: %d",
1016-
(int) constr->contype);
1014+
case CONSTR_GENERATED:
1015+
case CONSTR_IDENTITY:
1016+
ereport(ERROR,
1017+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1018+
errmsg("specifying GENERATED not supported for domains")));
10171019
break;
1020+
1021+
/* no default, to let compiler warn about missing case */
10181022
}
10191023
}
10201024

0 commit comments

Comments
 (0)