pgsql: Allow a multi-row INSERT to specify DEFAULTs for a generated col

Started by Tom Laneover 5 years ago3 messagescomitters
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

Allow a multi-row INSERT to specify DEFAULTs for a generated column.

One can say "INSERT INTO tab(generated_col) VALUES (DEFAULT)" and not
draw an error. But the equivalent case for a multi-row VALUES list
always threw an error, even if one properly said DEFAULT in each row.
Fix that. While here, improve the test cases for nearby logic about
OVERRIDING SYSTEM/USER values.

Dean Rasheed

Discussion: /messages/by-id/9q0sgcr416t.fsf@gmx.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/17958972fe3bb03454a4b53756b29d65dc285efa

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c | 242 ++++++++++++++++++++++++++++----
src/test/regress/expected/generated.out | 47 ++++++-
src/test/regress/expected/identity.out | 56 ++++++++
src/test/regress/sql/generated.sql | 21 ++-
src/test/regress/sql/identity.sql | 23 +++
5 files changed, 357 insertions(+), 32 deletions(-)

#2Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Tom Lane (#1)
Re: pgsql: Allow a multi-row INSERT to specify DEFAULTs for a generated col

On Sun, 2020-11-22 at 20:48 +0000, Tom Lane wrote:

Allow a multi-row INSERT to specify DEFAULTs for a generated column.

One can say "INSERT INTO tab(generated_col) VALUES (DEFAULT)" and not
draw an error. But the equivalent case for a multi-row VALUES list
always threw an error, even if one properly said DEFAULT in each row.
Fix that. While here, improve the test cases for nearby logic about
OVERRIDING SYSTEM/USER values.

Dean Rasheed

Discussion: /messages/by-id/9q0sgcr416t.fsf@gmx.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/17958972fe3bb03454a4b53756b29d65dc285efa

Shouldn't this be backpatched?
That seems like a clear bug to me; see this report on v11:
https://stackoverflow.com/q/68834080/6464308

Yours,
Laurenz Albe

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Laurenz Albe (#2)
Re: pgsql: Allow a multi-row INSERT to specify DEFAULTs for a generated col

Laurenz Albe <laurenz.albe@cybertec.at> writes:

On Sun, 2020-11-22 at 20:48 +0000, Tom Lane wrote:

Allow a multi-row INSERT to specify DEFAULTs for a generated column.

Shouldn't this be backpatched?
That seems like a clear bug to me; see this report on v11:
https://stackoverflow.com/q/68834080/6464308

/messages/by-id/CAEMmGb5BN_iRabOKO1_G6LkecxqLHrwFQ=cuN1bJC4HmUsjjLw@mail.gmail.com

regards, tom lane