mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
Prevent creation of duplicate not-null constraints for domains
This was previously harmless, but now that we create pg_constraint rows for those, duplicates are not welcome anymore. Backpatch to 18. Co-authored-by: jian he <jian.universality@gmail.com> Co-authored-by: Álvaro Herrera <alvherre@kurilemu.de> Discussion: https://postgr.es/m/CACJufxFSC0mcQ82bSk58sO-WJY4P-o4N6RD2M0D=DD_u_6EzdQ@mail.gmail.com
This commit is contained in:
@@ -939,11 +939,19 @@ DefineDomain(ParseState *pstate, CreateDomainStmt *stmt)
|
||||
break;
|
||||
|
||||
case CONSTR_NOTNULL:
|
||||
if (nullDefined && !typNotNull)
|
||||
if (nullDefined)
|
||||
{
|
||||
if (!typNotNull)
|
||||
ereport(ERROR,
|
||||
errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting NULL/NOT NULL constraints"),
|
||||
parser_errposition(pstate, constr->location));
|
||||
|
||||
ereport(ERROR,
|
||||
errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting NULL/NOT NULL constraints"),
|
||||
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("redundant NOT NULL constraint definition"),
|
||||
parser_errposition(pstate, constr->location));
|
||||
}
|
||||
if (constr->is_no_inherit)
|
||||
ereport(ERROR,
|
||||
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
|
||||
Reference in New Issue
Block a user