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