Identity columns, DEFAULT keyword and multi-row inserts

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Identity columns, DEFAULT keyword and multi-row inserts
Дата
Msg-id ae6d3563-f3c9-ce42-1f2c-32934e844505@gmx.net
обсуждение исходный текст
Ответы RE: Identity columns, DEFAULT keyword and multi-row inserts  (Patrick FICHE <Patrick.Fiche@aqsacom.com>)
Re: Identity columns, DEFAULT keyword and multi-row inserts  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hello,

assume the following table:

    create table test 
    (
      id integer not null  generated always as identity,
      data integer not null 
    );

The following insert works fine:

    insert into test (id, data)
    values (default,1);


However, a multi-row insert like the following:

    insert into test (id, data)
    values 
      (default,1),
      (default,2);


fails with: 

    ERROR: cannot insert into column "id"
      Detail: Column "id" is an identity column defined as GENERATED ALWAYS.
      Hint: Use OVERRIDING SYSTEM VALUE to override.


My question is: 

* If DEFAULT is not allowed for identity columns, then why does the single-row insert work? 
* If DEFAULT _is_ allowed, then why does the multi-row insert fail? 

The above happens with Postgres 10,11 and 12

Regards
Thomas



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

Предыдущее
От: Rene Romero Benavides
Дата:
Сообщение: Re: Tuple concurrency issue in large objects
Следующее
От: Dan shmidt
Дата:
Сообщение: Logical Replication of Multiple Schema Versions