From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | Kirill Reshke <reshkekirill(at)gmail(dot)com> |
Cc: | Quan Zongliang <quanzongliang(at)yeah(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: ALTER DOMAIN ADD NOT NULL NOT VALID |
Date: | 2025-08-18 04:09:12 |
Message-ID: | CACJufxGed1wksxnsb7_aLHYRctq4SUYYun+iDxW5PVcW=UvkrQ@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Aug 14, 2025 at 5:02 PM Kirill Reshke <reshkekirill(at)gmail(dot)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'.
From | Date | Subject | |
---|---|---|---|
Next Message | Zhijie Hou (Fujitsu) | 2025-08-18 04:20:12 | RE: Conflict detection for update_deleted in logical replication |
Previous Message | James Pang | 2025-08-18 03:12:57 | max_locks_per_transaction v18 |