postgresql/src
Dean Rasheed fe9e658f4d Ensure that MERGE recomputes GENERATED expressions properly.
This fixes a bug that, under some circumstances, would cause MERGE to
fail to properly recompute expressions for GENERATED STORED columns.

Formerly, ExecInitModifyTable() did not call ExecInitStoredGenerated()
for a MERGE command, which meant that the generated expressions
information was not computed until later, when the first merge action
was executed. However, if the first merge action to execute was an
UPDATE, then ExecInitStoredGenerated() could decide to skip some some
generated columns, if the columns on which they depended were not
updated, which was a problem if the MERGE also contained an INSERT
action, for which no generated columns should be skipped.

So fix by having ExecInitModifyTable() call ExecInitStoredGenerated()
for MERGE, and assume that it isn't safe to skip any generated columns
in a MERGE. Possibly that could be relaxed, by allowing some generated
columns to be skipped for a MERGE without an INSERT action, but it's
not clear that it's worth the effort.

Noticed while investigating bug #17759. Back-patch to v15, where MERGE
was added.

Dean Rasheed, reviewed by Tom Lane.

Discussion:
  https://postgr.es/m/17759-e76d9bece1b5421c%40postgresql.org
  https://postgr.es/m/CAEZATCXb_ezoMCcL0tzKwRGA1x0oeE%3DawTaysRfTPq%2B3wNJn8g%40mail.gmail.com
2023-01-30 10:04:57 +00:00
..
backend Ensure that MERGE recomputes GENERATED expressions properly. 2023-01-30 10:04:57 +00:00
bin Fix behavior with pg_restore -l and compressed dumps 2023-01-27 10:19:50 +09:00
common Use appendStringInfoSpaces in more places 2023-01-20 13:07:24 +13:00
fe_utils Refactor code for restoring files via shell commands 2023-01-18 11:15:48 +09:00
include Rename GUC logical_decoding_mode to logical_replication_mode. 2023-01-30 08:02:08 +05:30
interfaces Update copyright for 2023 2023-01-02 15:00:37 -05:00
makefiles Update copyright for 2023 2023-01-02 15:00:37 -05:00
pl plpython: Stop undefining _POSIX_C_SOURCE, _XOPEN_SOURCE 2023-01-25 09:59:26 -08:00
port Remove gratuitous references to postmaster program 2023-01-26 10:48:32 +01:00
template Use unnamed POSIX semaphores on Cygwin. 2023-01-06 10:33:28 +13:00
test Ensure that MERGE recomputes GENERATED expressions properly. 2023-01-30 10:04:57 +00:00
timezone Update copyright for 2023 2023-01-02 15:00:37 -05:00
tools Rename GUC logical_decoding_mode to logical_replication_mode. 2023-01-30 08:02:08 +05:30
tutorial Update copyright for 2023 2023-01-02 15:00:37 -05:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in autoconf: Move export_dynamic determination to configure 2022-12-06 18:55:28 -08:00
Makefile.shlib autoconf: Rely on ar supporting index creation 2022-10-07 11:53:39 -07:00
meson.build Update copyright for 2023 2023-01-02 15:00:37 -05:00
nls-global.mk Fix for make unportability 2022-07-13 09:15:01 +02:00