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

From Pavel Stehule
Subject Re: [bug+patch] Inserting DEFAULT into generated columns from VALUES RTE
Date
Msg-id CAFj8pRC4Y2V3B0HjiPNcpwMfgd2Pj4bTJQJHtZuG=g2Nx5Puiw@mail.gmail.com
Whole thread Raw
In response to [bug+patch] Inserting DEFAULT into generated columns from VALUES RTE  (Mikhail Titov <mlt@gmx.us>)
List pgsql-hackers
Hi

čt 13. 8. 2020 v 6:31 odesílatel Mikhail Titov <mlt@gmx.us> napsal:
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].

please, assign your patch to commitfest application


Regards

Pavel


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

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

--
Mikhail

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Parallel query hangs after a smart shutdown is issued
Next
From: Tom Lane
Date:
Subject: Re: run pgindent on a regular basis / scripted manner