pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie @ 2019-02-20 08:37 Dean Rasheed <dean.a.rasheed@gmail.com> 0 siblings, 0 replies; 6+ messages in thread From: Dean Rasheed @ 2019-02-20 08:37 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/41531e42d34f4aca117d343b5e40f3f757dec5fe Modified Files -------------- src/backend/rewrite/rewriteHandler.c | 139 +++++++++++++++++++++-- src/test/regress/expected/updatable_views.out | 153 ++++++++++++++++++++++++++ src/test/regress/sql/updatable_views.sql | 88 +++++++++++++++ 3 files changed, 369 insertions(+), 11 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie @ 2019-02-20 08:37 Dean Rasheed <dean.a.rasheed@gmail.com> 0 siblings, 0 replies; 6+ messages in thread From: Dean Rasheed @ 2019-02-20 08:37 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/fbec6fa38ade6fd0c4c5c5984f723ba351a44e85 Modified Files -------------- src/backend/rewrite/rewriteHandler.c | 139 +++++++++++++++++++++-- src/test/regress/expected/updatable_views.out | 153 ++++++++++++++++++++++++++ src/test/regress/sql/updatable_views.sql | 88 +++++++++++++++ 3 files changed, 369 insertions(+), 11 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie @ 2019-02-20 08:37 Dean Rasheed <dean.a.rasheed@gmail.com> 0 siblings, 0 replies; 6+ messages in thread From: Dean Rasheed @ 2019-02-20 08:37 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/2b1971c0318bae45317386877621642cd5ce7849 Modified Files -------------- src/backend/rewrite/rewriteHandler.c | 139 +++++++++++++++++++++-- src/test/regress/expected/updatable_views.out | 153 ++++++++++++++++++++++++++ src/test/regress/sql/updatable_views.sql | 88 +++++++++++++++ 3 files changed, 369 insertions(+), 11 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie @ 2019-02-20 08:37 Dean Rasheed <dean.a.rasheed@gmail.com> 0 siblings, 0 replies; 6+ messages in thread From: Dean Rasheed @ 2019-02-20 08:37 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d31e421d7df17052c3b48363eeb50e5a736833bd Modified Files -------------- src/backend/rewrite/rewriteHandler.c | 139 +++++++++++++++++++++-- src/test/regress/expected/updatable_views.out | 153 ++++++++++++++++++++++++++ src/test/regress/sql/updatable_views.sql | 88 +++++++++++++++ 3 files changed, 369 insertions(+), 11 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie @ 2019-02-20 08:37 Dean Rasheed <dean.a.rasheed@gmail.com> 0 siblings, 0 replies; 6+ messages in thread From: Dean Rasheed @ 2019-02-20 08:37 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/90f91bfbd76f1ce0e4692f7c17813f5f226050f2 Modified Files -------------- src/backend/rewrite/rewriteHandler.c | 139 +++++++++++++++++++++-- src/test/regress/expected/updatable_views.out | 153 ++++++++++++++++++++++++++ src/test/regress/sql/updatable_views.sql | 88 +++++++++++++++ 3 files changed, 369 insertions(+), 11 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie @ 2019-02-20 08:37 Dean Rasheed <dean.a.rasheed@gmail.com> 0 siblings, 0 replies; 6+ messages in thread From: Dean Rasheed @ 2019-02-20 08:37 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL9_4_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/5a73edf050ed6740fc085cad05a2e7af9fb1f06e Modified Files -------------- src/backend/rewrite/rewriteHandler.c | 138 +++++++++++++++++++++-- src/test/regress/expected/updatable_views.out | 153 ++++++++++++++++++++++++++ src/test/regress/sql/updatable_views.sql | 88 +++++++++++++++ 3 files changed, 368 insertions(+), 11 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2019-02-20 08:37 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-02-20 08:37 pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie Dean Rasheed <dean.a.rasheed@gmail.com> 2019-02-20 08:37 pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie Dean Rasheed <dean.a.rasheed@gmail.com> 2019-02-20 08:37 pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie Dean Rasheed <dean.a.rasheed@gmail.com> 2019-02-20 08:37 pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie Dean Rasheed <dean.a.rasheed@gmail.com> 2019-02-20 08:37 pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie Dean Rasheed <dean.a.rasheed@gmail.com> 2019-02-20 08:37 pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie Dean Rasheed <dean.a.rasheed@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox