Re: Catalog domain not-null constraints

Поиск
Список
Период
Сортировка
От jian he
Тема Re: Catalog domain not-null constraints
Дата
Msg-id CACJufxGJdckC_nhU9QvkFHsqoweTL_hZDMjK0f4tqhmXjwxMOQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Catalog domain not-null constraints  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Список pgsql-hackers
wandering around the function AlterDomainNotNull,
the following code can fix the previous undesired behavior.
seems pretty simple, am I missing something?
based on v3-0001-Add-tests-for-domain-related-information-schema-v.patch
and v3-0002-Catalog-domain-not-null-constraints.patch

diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index 2f94e375..9069465a 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -2904,7 +2904,7 @@ AlterDomainAddConstraint(List *names, Node *newConstraint,
        Form_pg_type typTup;
        Constraint *constr;
        char       *ccbin;
-       ObjectAddress address;
+       ObjectAddress address = InvalidObjectAddress;

        /* Make a TypeName so we can use standard type lookup machinery */
        typename = makeTypeNameFromNameList(names);
@@ -3003,6 +3003,12 @@ AlterDomainAddConstraint(List *names, Node
*newConstraint,
        }
        else if (constr->contype == CONSTR_NOTNULL)
        {
+               /* Is the domain already set NOT NULL */
+               if (typTup->typnotnull)
+               {
+                       table_close(typrel, RowExclusiveLock);
+                       return address;
+               }
                domainAddNotNullConstraint(domainoid, typTup->typnamespace,
typTup->typbasetype, typTup->typtypmod,
constr, NameStr(typTup->typname), constrAddr);



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Shlok Kyal
Дата:
Сообщение: Re: speed up a logical replica setup
Следующее
От: Bertrand Drouvot
Дата:
Сообщение: Re: Injection points: some tools to wait and wake