Re: Is this a buggy behavior? - Mailing list pgsql-general

From Christophe Pettus
Subject Re: Is this a buggy behavior?
Date
Msg-id 879037EC-39F7-49E8-A6D7-0FFD3EC2BA0A@thebuild.com
Whole thread Raw
In response to Re: Is this a buggy behavior?  (Adrian Klaver <adrian.klaver@aklaver.com>)
Responses Re: Is this a buggy behavior?  (Thiemo Kellner <thiemo@gelassene-pferde.biz>)
List 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
columnis 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
explicitlysaid NULL.  It does see that the column in nullable, but that in itself isn't worth emitting a warning over,
sinceyou are explicitly telling it that now the column shouldn't be null.  It wouldn't make much more sense to emit a
warningthere than it would be in this situation: 

CREATE TABLE t (i int NULL);
ALTER TABLE t ALTER i SET NOT NULL;

--
Adrian Klaver
adrian.klaver@aklaver.com







pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Is this a buggy behavior?
Next
From: Thiemo Kellner
Date:
Subject: Re: Is this a buggy behavior?