pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix DEFAULT handling for multi-row INSERT rules.
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix DEFAULT handling for multi-row INSERT rules.
@ 2022-12-03 12:30  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Dean Rasheed @ 2022-12-03 12:30 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix DEFAULT handling for multi-row INSERT rules.

When updating a relation with a rule whose action performed an INSERT
from a multi-row VALUES list, the rewriter might skip processing the
VALUES list, and therefore fail to replace any DEFAULTs in it. This
would lead to an "unrecognized node type" error.

The reason was that RewriteQuery() assumed that a query doing an
INSERT from a multi-row VALUES list would necessarily only have one
item in its fromlist, pointing to the VALUES RTE to read from. That
assumption is correct for the original query, but not for product
queries produced for rule actions. In such cases, there may be
multiple items in the fromlist, possibly including multiple VALUES
RTEs.

What is required instead is for RewriteQuery() to skip any RTEs from
the product query's originating query, which might include one or more
already-processed VALUES RTEs. What's left should then include at most
one VALUES RTE (from the rule action) to be processed.

Patch by me. Thanks to Tom Lane for reviewing.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/CAEZATCV39OOW7LAR_Xq4i%2BLc1Byux%3DeK3Q%3DHD_pF1o9LBt%3DphA%40mail.gmail.com

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/33f600f0495ff3150e2bea1d676570179ab3e0cf

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c | 47 +++++++++++++++----
src/test/regress/expected/rules.out  | 91 ++++++++++++++++++++----------------
src/test/regress/sql/rules.sql       | 15 +++---
3 files changed, 99 insertions(+), 54 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix DEFAULT handling for multi-row INSERT rules.
@ 2022-12-03 12:30  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Dean Rasheed @ 2022-12-03 12:30 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix DEFAULT handling for multi-row INSERT rules.

When updating a relation with a rule whose action performed an INSERT
from a multi-row VALUES list, the rewriter might skip processing the
VALUES list, and therefore fail to replace any DEFAULTs in it. This
would lead to an "unrecognized node type" error.

The reason was that RewriteQuery() assumed that a query doing an
INSERT from a multi-row VALUES list would necessarily only have one
item in its fromlist, pointing to the VALUES RTE to read from. That
assumption is correct for the original query, but not for product
queries produced for rule actions. In such cases, there may be
multiple items in the fromlist, possibly including multiple VALUES
RTEs.

What is required instead is for RewriteQuery() to skip any RTEs from
the product query's originating query, which might include one or more
already-processed VALUES RTEs. What's left should then include at most
one VALUES RTE (from the rule action) to be processed.

Patch by me. Thanks to Tom Lane for reviewing.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/CAEZATCV39OOW7LAR_Xq4i%2BLc1Byux%3DeK3Q%3DHD_pF1o9LBt%3DphA%40mail.gmail.com

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2c7ed9f752924c038abffb46999a0f543139d797

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c | 47 +++++++++++++++----
src/test/regress/expected/rules.out  | 91 ++++++++++++++++++++----------------
src/test/regress/sql/rules.sql       | 15 +++---
3 files changed, 99 insertions(+), 54 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix DEFAULT handling for multi-row INSERT rules.
@ 2022-12-03 12:30  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Dean Rasheed @ 2022-12-03 12:30 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix DEFAULT handling for multi-row INSERT rules.

When updating a relation with a rule whose action performed an INSERT
from a multi-row VALUES list, the rewriter might skip processing the
VALUES list, and therefore fail to replace any DEFAULTs in it. This
would lead to an "unrecognized node type" error.

The reason was that RewriteQuery() assumed that a query doing an
INSERT from a multi-row VALUES list would necessarily only have one
item in its fromlist, pointing to the VALUES RTE to read from. That
assumption is correct for the original query, but not for product
queries produced for rule actions. In such cases, there may be
multiple items in the fromlist, possibly including multiple VALUES
RTEs.

What is required instead is for RewriteQuery() to skip any RTEs from
the product query's originating query, which might include one or more
already-processed VALUES RTEs. What's left should then include at most
one VALUES RTE (from the rule action) to be processed.

Patch by me. Thanks to Tom Lane for reviewing.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/CAEZATCV39OOW7LAR_Xq4i%2BLc1Byux%3DeK3Q%3DHD_pF1o9LBt%3DphA%40mail.gmail.com

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/30f9b03a08bde2c4235ef5f1812ae194b32fb7e3

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c | 47 +++++++++++++++----
src/test/regress/expected/rules.out  | 91 ++++++++++++++++++++----------------
src/test/regress/sql/rules.sql       | 15 +++---
3 files changed, 99 insertions(+), 54 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix DEFAULT handling for multi-row INSERT rules.
@ 2022-12-03 12:30  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Dean Rasheed @ 2022-12-03 12:30 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix DEFAULT handling for multi-row INSERT rules.

When updating a relation with a rule whose action performed an INSERT
from a multi-row VALUES list, the rewriter might skip processing the
VALUES list, and therefore fail to replace any DEFAULTs in it. This
would lead to an "unrecognized node type" error.

The reason was that RewriteQuery() assumed that a query doing an
INSERT from a multi-row VALUES list would necessarily only have one
item in its fromlist, pointing to the VALUES RTE to read from. That
assumption is correct for the original query, but not for product
queries produced for rule actions. In such cases, there may be
multiple items in the fromlist, possibly including multiple VALUES
RTEs.

What is required instead is for RewriteQuery() to skip any RTEs from
the product query's originating query, which might include one or more
already-processed VALUES RTEs. What's left should then include at most
one VALUES RTE (from the rule action) to be processed.

Patch by me. Thanks to Tom Lane for reviewing.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/CAEZATCV39OOW7LAR_Xq4i%2BLc1Byux%3DeK3Q%3DHD_pF1o9LBt%3DphA%40mail.gmail.com

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c67204db61fa9c4429b30ce031ef833748c8c69a

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c | 53 +++++++++++++++++----
src/test/regress/expected/rules.out  | 91 ++++++++++++++++++++----------------
src/test/regress/sql/rules.sql       | 15 +++---
3 files changed, 104 insertions(+), 55 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix DEFAULT handling for multi-row INSERT rules.
@ 2022-12-03 12:30  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Dean Rasheed @ 2022-12-03 12:30 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix DEFAULT handling for multi-row INSERT rules.

When updating a relation with a rule whose action performed an INSERT
from a multi-row VALUES list, the rewriter might skip processing the
VALUES list, and therefore fail to replace any DEFAULTs in it. This
would lead to an "unrecognized node type" error.

The reason was that RewriteQuery() assumed that a query doing an
INSERT from a multi-row VALUES list would necessarily only have one
item in its fromlist, pointing to the VALUES RTE to read from. That
assumption is correct for the original query, but not for product
queries produced for rule actions. In such cases, there may be
multiple items in the fromlist, possibly including multiple VALUES
RTEs.

What is required instead is for RewriteQuery() to skip any RTEs from
the product query's originating query, which might include one or more
already-processed VALUES RTEs. What's left should then include at most
one VALUES RTE (from the rule action) to be processed.

Patch by me. Thanks to Tom Lane for reviewing.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/CAEZATCV39OOW7LAR_Xq4i%2BLc1Byux%3DeK3Q%3DHD_pF1o9LBt%3DphA%40mail.gmail.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3bed881237b1b5694d525da7c8974e09198d445f

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c | 47 +++++++++++++++----
src/test/regress/expected/rules.out  | 91 ++++++++++++++++++++----------------
src/test/regress/sql/rules.sql       | 15 +++---
3 files changed, 99 insertions(+), 54 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix DEFAULT handling for multi-row INSERT rules.
@ 2022-12-03 12:30  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Dean Rasheed @ 2022-12-03 12:30 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix DEFAULT handling for multi-row INSERT rules.

When updating a relation with a rule whose action performed an INSERT
from a multi-row VALUES list, the rewriter might skip processing the
VALUES list, and therefore fail to replace any DEFAULTs in it. This
would lead to an "unrecognized node type" error.

The reason was that RewriteQuery() assumed that a query doing an
INSERT from a multi-row VALUES list would necessarily only have one
item in its fromlist, pointing to the VALUES RTE to read from. That
assumption is correct for the original query, but not for product
queries produced for rule actions. In such cases, there may be
multiple items in the fromlist, possibly including multiple VALUES
RTEs.

What is required instead is for RewriteQuery() to skip any RTEs from
the product query's originating query, which might include one or more
already-processed VALUES RTEs. What's left should then include at most
one VALUES RTE (from the rule action) to be processed.

Patch by me. Thanks to Tom Lane for reviewing.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/CAEZATCV39OOW7LAR_Xq4i%2BLc1Byux%3DeK3Q%3DHD_pF1o9LBt%3DphA%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2605643a3a9d789f3a5935810e874c00243d7576

Modified Files
--------------
src/backend/rewrite/rewriteHandler.c | 53 +++++++++++++++++----
src/test/regress/expected/rules.out  | 91 ++++++++++++++++++++----------------
src/test/regress/sql/rules.sql       | 15 +++---
3 files changed, 104 insertions(+), 55 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2022-12-03 12:30 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-12-03 12:30 pgsql: Fix DEFAULT handling for multi-row INSERT rules. Dean Rasheed <dean.a.rasheed@gmail.com>
2022-12-03 12:30 pgsql: Fix DEFAULT handling for multi-row INSERT rules. Dean Rasheed <dean.a.rasheed@gmail.com>
2022-12-03 12:30 pgsql: Fix DEFAULT handling for multi-row INSERT rules. Dean Rasheed <dean.a.rasheed@gmail.com>
2022-12-03 12:30 pgsql: Fix DEFAULT handling for multi-row INSERT rules. Dean Rasheed <dean.a.rasheed@gmail.com>
2022-12-03 12:30 pgsql: Fix DEFAULT handling for multi-row INSERT rules. Dean Rasheed <dean.a.rasheed@gmail.com>
2022-12-03 12:30 pgsql: Fix DEFAULT handling for multi-row INSERT rules. 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