Re: ALTER DOMAIN ADD NOT NULL NOT VALID

Kirill Reshke <reshkekirill@gmail.com>

From: Kirill Reshke <reshkekirill@gmail.com>
To: jian he <jian.universality@gmail.com>
Cc: Quan Zongliang <quanzongliang@yeah.net>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-08-18T08:25:48Z
Lists: pgsql-hackers
On Mon, 18 Aug 2025 at 09:09, jian he <jian.universality@gmail.com> wrote:

> CREATE DOMAIN use ColConstraintElem.
> that's why we do not support syntax:
> ``create domain t1 as int not null not valid;``
>
> we also do not support column constraints NOT NULL NOT VALID.
> Like
> ``create table t(a int not null not valid);``
> will error out.
> so I guess it's fine to not support it?

Indeed.

> so currently I don't know how to support syntax
> ``create domain t1 as int not null not valid;``

Ok.

> I also found it's hard to psql-tab-complete for
>  'alter domain ... add constraint .. not null' with 'not valid'.

I am under the impression it is pretty trivial.
I mean, isn't this enough?

```
/* ALTER DOMAIN <sth> ADD CONSTRAINT <sth> NOT NULL */
else if (Matches("ALTER", "DOMAIN", MatchAny, "ADD", "CONSTRAINT",
MatchAny, "NOT", "NULL"))
COMPLETE_WITH("NOT VALID");
```

Anyway, this is purely optional and can be a separate topic.

I propose to focus on Alvaro's feedback for now.

-- 
Best regards,
Kirill Reshke



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Reduce lock level for ALTER DOMAIN ... VALIDATE CONSTRAINT