postgresql/src/backend
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
..
access Revert "Add eager and lazy freezing strategies to VACUUM." 2023-01-25 22:22:27 -08:00
backup Improve TimestampDifferenceMilliseconds to cope with overflow sanely. 2023-01-26 17:09:12 -05:00
bootstrap Update copyright for 2023 2023-01-02 15:00:37 -05:00
catalog Allow REPLICA IDENTITY to be set on an index that's not (yet) valid. 2023-01-21 13:10:29 -05:00
commands Revert "Add eager and lazy freezing strategies to VACUUM." 2023-01-25 22:22:27 -08:00
executor Ensure that MERGE recomputes GENERATED expressions properly. 2023-01-30 10:04:57 +00:00
foreign Update copyright for 2023 2023-01-02 15:00:37 -05:00
jit Fix typos in comments, code and documentation 2023-01-03 16:26:14 +09:00
lib Fix ILIST_DEBUG build 2023-01-18 10:26:15 -08:00
libpq Support the same patterns for pg-user in pg_ident.conf as in pg_hba.conf 2023-01-20 11:21:55 +09:00
main Update copyright for 2023 2023-01-02 15:00:37 -05:00
nodes Move queryjumble.c code to src/backend/nodes/ 2023-01-21 11:48:37 +09:00
optimizer Allow parallel aggregate on string_agg and array_agg 2023-01-23 17:35:01 +13:00
parser Allow parallel aggregate on string_agg and array_agg 2023-01-23 17:35:01 +13:00
partitioning Update copyright for 2023 2023-01-02 15:00:37 -05:00
po Update copyright for 2023 2023-01-02 15:00:37 -05:00
port Update copyright for 2023 2023-01-02 15:00:37 -05:00
postmaster Remove unneeded volatile qualifiers from postmaster.c. 2023-01-28 15:06:23 +13:00
regex Update copyright for 2023 2023-01-02 15:00:37 -05:00
replication Rename GUC logical_decoding_mode to logical_replication_mode. 2023-01-30 08:02:08 +05:30
rewrite Get rid of the "new" and "old" entries in a view's rangetable. 2023-01-18 13:23:57 -05:00
snowball Update copyright for 2023 2023-01-02 15:00:37 -05:00
statistics Update copyright for 2023 2023-01-02 15:00:37 -05:00
storage Avoid type cheats for invalid dsa_handles and dshash_table_handles. 2023-01-25 11:48:38 -05:00
tcop Use WaitEventSet API for postmaster's event loop. 2023-01-12 16:32:20 +13:00
tsearch Fix ts_headline() to handle ORs and phrase queries more honestly. 2023-01-19 16:21:44 -05:00
utils Rename GUC logical_decoding_mode to logical_replication_mode. 2023-01-30 08:02:08 +05:30
.gitignore
Makefile Don't install postmaster symlink anymore 2023-01-26 11:33:01 +01:00
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
meson.build Update copyright for 2023 2023-01-02 15:00:37 -05:00
nls.mk NLS: Put list of available languages into LINGUAS files 2022-07-13 08:19:17 +02:00