On Thu, Aug 14, 2025 at 5:02 PM Kirill Reshke <reshkekir...@gmail.com> wrote: > > I have few observations. > One is whether we should now support CREATE DOMAIN ... NOT NULL NOT > VALID syntax? This could be a separate patch though. >
in gram.y: CreateDomainStmt: CREATE DOMAIN_P any_name opt_as Typename ColQualList { CreateDomainStmt *n = makeNode(CreateDomainStmt); n->domainname = $3; n->typeName = $5; SplitColQualList($6, &n->constraints, &n->collClause, yyscanner); $$ = (Node *) n; } ; ColConstraintElem: NOT NULL_P opt_no_inherit { Constraint *n = makeNode(Constraint); n->contype = CONSTR_NOTNULL; n->location = @1; n->is_no_inherit = $3; n->is_enforced = true; n->skip_validation = false; n->initially_valid = true; $$ = (Node *) n; } | NULL_P { Constraint *n = makeNode(Constraint); n->contype = CONSTR_NULL; n->location = @1; $$ = (Node *) n; } 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? opt_not_valid: NOT VALID { $$ = true; } | /* EMPTY */ { $$ = false; } ; ColConstraintElem: NOT NULL_P opt_no_inherit opt_not_valid { Constraint *n = makeNode(Constraint); n->contype = CONSTR_NOTNULL; n->location = @1; n->is_no_inherit = $3; n->is_enforced = true; // n->skip_validation = false; // n->initially_valid = true; n->skip_validation = $4; n->initially_valid = !n->skip_validation; $$ = (Node *) n; } the above change will produce error /usr/bin/bison -Wno-deprecated -o src/backend/parser/gram.c -d ../../Desktop/pg_src/src9/postgres/src/backend/parser/gram.y ../../Desktop/pg_src/src9/postgres/src/backend/parser/gram.y: error: shift/reduce conflicts: 1 found, 0 expected ../../Desktop/pg_src/src9/postgres/src/backend/parser/gram.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples so currently I don't know how to support syntax ``create domain t1 as int not null not valid;`` I also found it's hard to psql-tab-complete for 'alter domain ... add constraint .. not null' with 'not valid'.