Re: Is this a buggy behavior?

Поиск
Список
Период
Сортировка
От Thiemo Kellner
Тема Re: Is this a buggy behavior?
Дата
Msg-id 25bdf65d-7302-4e8d-bf9f-93752dbeec33@gelassene-pferde.biz
обсуждение исходный текст
Ответ на Re: Is this a buggy behavior?  (Christophe Pettus <xof@thebuild.com>)
Ответы Re: Is this a buggy behavior?
Re: Is this a buggy behavior?
Список pgsql-general

Am 24.03.2024 um 17:15 schrieb Christophe Pettus:
> I think the point is that it's not really doing anything "silently."  You are asking for a PRIMARY KEY constraint on
acolumn, 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.
 

But don't you also request the database to have the column being 
nullable? So, PG, at this point silently prioritises the request for the 
PK over the request of the nullability. Does it not?

> 
> 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.
 

How can that be forgotten? This information ends up in the data 
catalogue eventually!

> It does see that the column in nullable, but that in itself isn't worth emitting a warning over, since you are
explicitlytelling it that now the column shouldn't be null.
 

I would agree if you had two separate statements there, but in the 
example it were not two different statements but one single 
contradictory statement.

> 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;

Again, these are two separate statements.

Maybe an example can help.

You are describing the situation when one goes to a car salesman and 
orders a car painted in blue. The car gets manufactured and the salesman 
hands you over the key. Then you say to the salesman. Now, please, 
re-paint it in red.

The issue however arose, because the statement said. "Please order me a 
blue car painted in red." Hopefully, any single salesman should respond 
with something like. "Dear customer, all very well, but it contradictory 
to have a blue car painted in red. Do you want a red car or a blue one?"


Dunkel war's, der Mond schien helle,
Als ein Wagen blitze schnelle,
langsam um die runde Ecke fuhr…



В списке pgsql-general по дате отправления:

Предыдущее
От: Thiemo Kellner
Дата:
Сообщение: Re: Is this a buggy behavior?
Следующее
От: Christophe Pettus
Дата:
Сообщение: Re: Is this a buggy behavior?