[bug+patch] Inserting DEFAULT into generated columns from VALUES RTE - Mailing list pgsql-hackers

From Mikhail Titov
Subject [bug+patch] Inserting DEFAULT into generated columns from VALUES RTE
Date
Msg-id 9q0sgcr416t.fsf@gmx.us
Whole thread Raw
Responses Re: [bug+patch] Inserting DEFAULT into generated columns from VALUES RTE
List pgsql-hackers
Hello!

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
documentation[1].

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

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

--
Mikhail

Attachment

pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: run pgindent on a regular basis / scripted manner
Next
From: Michael Paquier
Date:
Subject: REINDEX SCHEMA/DATABASE/SYSTEM weak with dropped relations