postgresql/src/backend
Dean Rasheed 41531e42d3 Fix DEFAULT-handling in multi-row VALUES lists for updatable views.
INSERT ... VALUES for a single VALUES row is implemented differently
from a multi-row VALUES list, which causes inconsistent behaviour in
the way that DEFAULT items are handled. In particular, when inserting
into an auto-updatable view on top of a table with a column default, a
DEFAULT item in a single VALUES row gets correctly replaced with the
table column's default, but for a multi-row VALUES list it is replaced
with NULL.

Fix this by allowing rewriteValuesRTE() to leave DEFAULT items in the
VALUES list untouched if the target relation is an auto-updatable view
and has no column default, deferring DEFAULT-expansion until the query
against the base relation is rewritten. For all other types of target
relation, including tables and trigger- and rule-updatable views, we
must continue to replace DEFAULT items with NULL in the absence of a
column default.

This is somewhat complicated by the fact that if an auto-updatable
view has DO ALSO rules attached, the VALUES lists for the product
queries need to be handled differently from the original query, since
the product queries need to act like rule-updatable views whereas the
original query has auto-updatable view semantics.

Back-patch to all supported versions.

Reported by Roger Curley (bug #15623). Patch by Amit Langote and me.

Discussion: https://postgr.es/m/15623-5d67a46788ec8b7f@postgresql.org
2019-02-20 08:30:21 +00:00
..
access Avoid some unnecessary block reads in WAL reader 2019-02-18 09:52:02 +09:00
bootstrap Remove argument isprimary from index_build() 2019-01-24 07:57:09 +09:00
catalog Remove useless casts 2019-02-13 11:50:09 +01:00
commands Fix CREATE VIEW to allow zero-column views. 2019-02-17 12:37:31 -05:00
executor Remove line duplicated during conflict resolution. 2019-02-18 11:07:30 -08:00
foreign Update copyright for 2019 2019-01-02 12:44:25 -05:00
jit Renaming for new subscripting mechanism 2019-02-01 12:50:32 -03:00
lib Make use of compiler builtins and/or assembly for CLZ, CTZ, POPCNT. 2019-02-15 23:22:33 -05:00
libpq Get rid of another unconstify through API changes 2019-02-14 20:44:47 +01:00
main Replace @postgresql.org with @lists.postgresql.org for mailinglists 2019-01-19 19:06:35 +01:00
nodes Allow user control of CTE materialization, and change the default behavior. 2019-02-16 16:11:12 -05:00
optimizer Save PathTargets for distinct/ordered relations in root->upper_targets[]. 2019-02-18 16:13:46 +09:00
parser Allow user control of CTE materialization, and change the default behavior. 2019-02-16 16:11:12 -05:00
partitioning Refactor planner's header files. 2019-01-29 15:48:51 -05:00
po Translation updates 2018-06-25 12:37:18 +02:00
port Add shared_memory_type GUC. 2019-02-03 12:47:26 +01:00
postmaster Move max_wal_senders out of max_connections for connection slot handling 2019-02-12 10:07:56 +09:00
regex Update copyright for 2019 2019-01-02 12:44:25 -05:00
replication Mark correctly initial slot snapshots with MVCC type when built 2019-02-20 12:31:07 +09:00
rewrite Fix DEFAULT-handling in multi-row VALUES lists for updatable views. 2019-02-20 08:30:21 +00:00
snowball Update copyright for 2019 2019-01-02 12:44:25 -05:00
statistics Rename nodes/relation.h to nodes/pathnodes.h. 2019-01-29 16:49:25 -05:00
storage Fix race in dsm_unpin_segment() when handles are reused. 2019-02-18 09:58:29 +13:00
tcop More unconstify use 2019-02-13 11:50:16 +01:00
tsearch Update copyright for 2019 2019-01-02 12:44:25 -05:00
utils Mark correctly initial slot snapshots with MVCC type when built 2019-02-20 12:31:07 +09:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Ensure link commands list *.o files before LDFLAGS. 2019-01-02 13:57:54 -05:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Translation updates 2018-06-25 12:37:18 +02:00