From: | Christophe Pettus <xof(at)thebuild(dot)com> |
---|---|
To: | Thiemo Kellner <thiemo(at)gelassene-pferde(dot)biz> |
Cc: | "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Is this a buggy behavior? |
Date: | 2024-03-24 16:15:55 |
Message-ID: | 879037EC-39F7-49E8-A6D7-0FFD3EC2BA0A@thebuild.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 3/24/24 08:28, Thiemo Kellner wrote:
> Sure, my example has lots more side effect than silently do the right thing.
I think the point is that it's not really doing anything "silently." You are asking for a PRIMARY KEY constraint on a column, and it's giving it to you. One of the effects (not even really a side-effect) of that request is that the column is then declared NOT NULL.
The reason it doesn't give you a warning is that by the time it would be in a position to, it's forgotten that you explicitly said NULL. It does see that the column in nullable, but that in itself isn't worth emitting a warning over, since you are explicitly telling it that now the column shouldn't be null. It wouldn't make much more sense to emit a warning there than it would be in this situation:
CREATE TABLE t (i int NULL);
ALTER TABLE t ALTER i SET NOT NULL;
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Thiemo Kellner | 2024-03-24 16:15:58 | Re: Is this a buggy behavior? |
Previous Message | Adrian Klaver | 2024-03-24 16:08:18 | Re: Is this a buggy behavior? |