From 6578c8c390e245ece2d1305f3d2c78168a0e7d30 Mon Sep 17 00:00:00 2001 From: Zizhuan Liu <44973863@qq.com> Date: Sat, 27 Jun 2026 10:04:15 +0800 Subject: [PATCH v2] If the domain is already in the target NULL or NOT NULL state, emit a safety notice and skip the add/set operation. --- src/backend/commands/typecmds.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index c4c3cdb5..7b8f9ed9 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -2799,6 +2799,10 @@ AlterDomainNotNull(List *names, bool notNull) /* Is the domain already set to the desired constraint? */ if (typTup->typnotnull == notNull) { + ereport(NOTICE, + (errmsg("Domain \"%s\" is already %s, skipping", + NameStr(typTup->typname), notNull ? "NOT NULL" : "NULL"))); + table_close(typrel, RowExclusiveLock); return address; } @@ -3033,6 +3037,10 @@ AlterDomainAddConstraint(List *names, Node *newConstraint, /* Is the domain already set NOT NULL? */ if (typTup->typnotnull) { + ereport(NOTICE, + (errmsg("Domain \"%s\" is already NOT NULL, skipping", + NameStr(typTup->typname)))); + table_close(typrel, RowExclusiveLock); return address; } -- 2.43.0