Search Postgresql Archives

Re: Is this a buggy behavior?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.klaver@xxxxxxxxxxx










[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux