[bug+patch] Inserting DEFAULT into generated columns from VALUES RTE

From: Mikhail Titov <mlt(at)gmx(dot)us>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: [bug+patch] Inserting DEFAULT into generated columns from VALUES RTE
Date: 2020-08-13 04:30:50
Message-ID: 9q0sgcr416t.fsf@gmx.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


According to the docs[1], one may use DEFAULT keyword while inserting
into generated columns (stored and identity). However, currently it
works only for a single VALUES sublist with DEFAULT for a generated column
but not for the case when VALUES RTE is used. This is not being tested
and it is broken.

I am attaching two patches. One for tests and another one with the
proposed changes based on ideas from Andrew on IRC. So if all good there
goes the credit where credit is due. If patch is no good, then it is
likely my misunderstanding how to put words into code :-)

This is my only second patch to PostgreSQL (the first one was rejected)
so don't be too harsh :-) It may not be perfect but I am open for a
feedback and this is just to get the ball rolling and to let the
community know about this issue.

Before you ask why would I want to insert DEFAULTs ... well, there are
ORMs[2] that still need to be patched and current situation contradicts

[1] https://www.postgresql.org/docs/devel/ddl-generated-columns.html

[2] https://github.com/rails/rails/pull/39368#issuecomment-670351379


Attachment Content-Type Size
0001-Test-DEFAULT-in-VALUES-RTE-for-generated-columns.patch text/x-patch 3.4 KB
0002-Allow-DEFAULT-in-VALUES-RTE-for-generated-columns.patch text/x-patch 3.2 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-08-13 04:35:52 Re: posgres 12 bug (partitioned table)
Previous Message Noah Misch 2020-08-13 04:26:55 Re: run pgindent on a regular basis / scripted manner