From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
Cc: | Tender Wang <tndrwang(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Can't find not null constraint, but \d+ shows that |
Date: | 2024-04-10 15:03:30 |
Message-ID: | CACJufxGsOXB7tyO7Z9pdujXF5ehthBszNz5V=HLZGdp+9TwzRQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Apr 10, 2024 at 7:01 PM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>
> On 2024-Apr-10, jian he wrote:
>
> > another related bug, in master.
> >
> > drop table if exists notnull_tbl1;
> > CREATE TABLE notnull_tbl1 (c0 int not null, c1 int);
> > ALTER TABLE notnull_tbl1 ADD CONSTRAINT Q PRIMARY KEY(c0, c1);
> > \d+ notnull_tbl1
> > ALTER TABLE notnull_tbl1 ALTER c0 DROP NOT NULL;
> > ALTER TABLE notnull_tbl1 ALTER c1 DROP NOT NULL;
> >
> > "ALTER TABLE notnull_tbl1 ALTER c0 DROP NOT NULL;"
> > should fail?
>
> No, this should not fail, and it is working correctly in master. You
> can drop the not-null constraint, but the column will still be
> non-nullable, because the primary key still exists. If you drop the
> primary key later, then the column becomes nullable. This is by design.
>
now I got it. the second time, it will fail.
it should be the expected behavior.
per commit:
https://git.postgresql.org/cgit/postgresql.git/commit/?id=14dd0f27d7cd56ffae9ecdbe324965073d01a9ff
In the function dropconstraint_internal, I changed "foreach" to
"foreach_int" in some places,
and other minor cosmetic changes within the function
dropconstraint_internal only.
Since I saw your changes in dropconstraint_internal, I posted here.
I will review your latest patch later.
Attachment | Content-Type | Size |
---|---|---|
v1-0001-minor-coesmetuic-refactor-in-dropconstraint_inter.patch | application/x-patch | 2.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-04-10 15:09:55 | Re: Issue with the PRNG used by Postgres |
Previous Message | Nathan Bossart | 2024-04-10 15:00:34 | Re: Allow non-superuser to cancel superuser tasks. |