Re: BUG #16913: GENERATED AS IDENTITY column nullability is affected by order of column properties

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #16913: GENERATED AS IDENTITY column nullability is affected by order of column properties
Дата
Msg-id 2194411.1621027120@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #16913: GENERATED AS IDENTITY column nullability is affected by order of column properties  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: BUG #16913: GENERATED AS IDENTITY column nullability is affected by order of column properties  (Shay Rojansky <roji@roji.org>)
Список pgsql-bugs
I wrote:
> GENERATED BY DEFAULT does create a NOT NULL constraint:
> ...
> so I think the patch is doing what it was intended to.  Whether GENERATED
> BY DEFAULT *should* be forcing NOT NULL is a separate question, but
> AFAIK it always has.

Ah, found it.  SQL:2016 11.4 <column definition> syntax rule 16 saith:

  If <identity column specification> ICS is specified, then:
  ...
  d) The <column constraint definition> NOT NULL NOT DEFERRABLE is implicit.

The <identity column specification> production includes both cases:

  <identity column specification> ::=
    GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY
        [ <left paren> <common sequence generator options> <right paren> ]

so the spec does clearly say that both alternatives force NOT NULL.

So, it was my error to write the release notes as though only
GENERATED ALWAYS is affected.  I'll go adjust that, though
it won't propagate to the website for another three months :-(

            regards, tom lane



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #16913: GENERATED AS IDENTITY column nullability is affected by order of column properties
Следующее
От: Peter Geoghegan
Дата:
Сообщение: Re: BUG #16833: postgresql 13.1 process crash every hour