postgresql/src
Dean Rasheed 90f91bfbd7 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:22:52 +00:00
..
backend Fix DEFAULT-handling in multi-row VALUES lists for updatable views. 2019-02-20 08:22:52 +00:00
bin Translation updates 2019-02-11 14:15:25 +01:00
common Fix portability failure introduced in commits d2b0b60e7 et al. 2018-12-26 15:30:35 -05:00
include Stamp 9.5.16. 2019-02-11 16:22:57 -05:00
interfaces Fix omissions in ecpg/test/sql/.gitignore. 2019-02-18 21:24:38 -05:00
makefiles Move port-specific parts of with_temp_install to port makefile. 2019-02-04 19:00:18 +00:00
pl Translation updates 2019-02-11 14:15:25 +01:00
port Stamp 9.5.16. 2019-02-11 16:22:57 -05:00
template Yet further rethinking of build changes for macOS Mojave. 2018-11-02 18:54:00 -04:00
test Fix DEFAULT-handling in multi-row VALUES lists for updatable views. 2019-02-20 08:22:52 +00:00
timezone Update time zone data files to tzdata release 2018i. 2019-02-05 10:59:31 -05:00
tools Unify searchpath and do file logic in MSVC build scripts. 2019-02-06 07:55:10 -05:00
tutorial Remove no-longer-required function declarations. 2015-05-24 12:20:23 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
bcc32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Install TAP test infrastructure so it's available for extension testing. 2016-09-23 15:50:00 -04:00
Makefile.global.in Move port-specific parts of with_temp_install to port makefile. 2019-02-04 19:00:18 +00:00
Makefile.shlib Ensure static libraries have correct mod time even if ranlib messes it up. 2018-11-29 15:53:44 -05:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00
win32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00