pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Yet further fixes for multi-row VALUES lists for updatable views 7+ messages / 1 participants [nested] [flat]
* pgsql: Yet further fixes for multi-row VALUES lists for updatable views @ 2022-10-11 22:24 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2022-10-11 22:24 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Yet further fixes for multi-row VALUES lists for updatable views. DEFAULT markers appearing in an INSERT on an updatable view could be mis-processed if they were in a multi-row VALUES clause. This would lead to strange errors such as "cache lookup failed for type NNNN", or in older branches even to crashes. The cause is that commit 41531e42d tried to re-use rewriteValuesRTE() to remove any SetToDefault nodes (that hadn't previously been replaced by the view's own default values) appearing in "product" queries, that is DO ALSO queries. That's fundamentally wrong because the DO ALSO queries might not even be INSERTs; and even if they are, their targetlists don't necessarily match the view's column list, so that almost all the logic in rewriteValuesRTE() is inapplicable. What we want is a narrow focus on replacing any such nodes with NULL constants. (That is, in this context we are interpreting the defaults as being strictly those of the view itself; and we already replaced any that aren't NULL.) We could add still more !force_nulls tests to further lobotomize rewriteValuesRTE(); but it seems cleaner to split out this case to a new function, restoring rewriteValuesRTE() to the charter it had before. Per bug #17633 from jiye_sw. Patch by me, but thanks to Richard Guo and Japin Li for initial investigation. Back-patch to all supported branches, as the previous fix was. Discussion: https://postgr.es/m/17633-98cc85e1fa91e905@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/b8f2687fdc410371bbfa579ab7c4fd4b7a5ed1cb Modified Files -------------- src/backend/rewrite/rewriteHandler.c | 87 ++++++++++++++++++--------- src/test/regress/expected/updatable_views.out | 22 +++++++ src/test/regress/sql/updatable_views.sql | 17 ++++++ 3 files changed, 98 insertions(+), 28 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Yet further fixes for multi-row VALUES lists for updatable views @ 2022-10-11 22:24 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2022-10-11 22:24 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Yet further fixes for multi-row VALUES lists for updatable views. DEFAULT markers appearing in an INSERT on an updatable view could be mis-processed if they were in a multi-row VALUES clause. This would lead to strange errors such as "cache lookup failed for type NNNN", or in older branches even to crashes. The cause is that commit 41531e42d tried to re-use rewriteValuesRTE() to remove any SetToDefault nodes (that hadn't previously been replaced by the view's own default values) appearing in "product" queries, that is DO ALSO queries. That's fundamentally wrong because the DO ALSO queries might not even be INSERTs; and even if they are, their targetlists don't necessarily match the view's column list, so that almost all the logic in rewriteValuesRTE() is inapplicable. What we want is a narrow focus on replacing any such nodes with NULL constants. (That is, in this context we are interpreting the defaults as being strictly those of the view itself; and we already replaced any that aren't NULL.) We could add still more !force_nulls tests to further lobotomize rewriteValuesRTE(); but it seems cleaner to split out this case to a new function, restoring rewriteValuesRTE() to the charter it had before. Per bug #17633 from jiye_sw. Patch by me, but thanks to Richard Guo and Japin Li for initial investigation. Back-patch to all supported branches, as the previous fix was. Discussion: https://postgr.es/m/17633-98cc85e1fa91e905@postgresql.org Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/07ce6769824c4081208122ae3c1b38812e4715ed Modified Files -------------- src/backend/rewrite/rewriteHandler.c | 87 ++++++++++++++++++--------- src/test/regress/expected/updatable_views.out | 22 +++++++ src/test/regress/sql/updatable_views.sql | 17 ++++++ 3 files changed, 98 insertions(+), 28 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Yet further fixes for multi-row VALUES lists for updatable views @ 2022-10-11 22:24 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2022-10-11 22:24 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Yet further fixes for multi-row VALUES lists for updatable views. DEFAULT markers appearing in an INSERT on an updatable view could be mis-processed if they were in a multi-row VALUES clause. This would lead to strange errors such as "cache lookup failed for type NNNN", or in older branches even to crashes. The cause is that commit 41531e42d tried to re-use rewriteValuesRTE() to remove any SetToDefault nodes (that hadn't previously been replaced by the view's own default values) appearing in "product" queries, that is DO ALSO queries. That's fundamentally wrong because the DO ALSO queries might not even be INSERTs; and even if they are, their targetlists don't necessarily match the view's column list, so that almost all the logic in rewriteValuesRTE() is inapplicable. What we want is a narrow focus on replacing any such nodes with NULL constants. (That is, in this context we are interpreting the defaults as being strictly those of the view itself; and we already replaced any that aren't NULL.) We could add still more !force_nulls tests to further lobotomize rewriteValuesRTE(); but it seems cleaner to split out this case to a new function, restoring rewriteValuesRTE() to the charter it had before. Per bug #17633 from jiye_sw. Patch by me, but thanks to Richard Guo and Japin Li for initial investigation. Back-patch to all supported branches, as the previous fix was. Discussion: https://postgr.es/m/17633-98cc85e1fa91e905@postgresql.org Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3162bd95cad3bf9ad89b9c7c8e50716cb513d46f Modified Files -------------- src/backend/rewrite/rewriteHandler.c | 87 ++++++++++++++++++--------- src/test/regress/expected/updatable_views.out | 22 +++++++ src/test/regress/sql/updatable_views.sql | 17 ++++++ 3 files changed, 98 insertions(+), 28 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Yet further fixes for multi-row VALUES lists for updatable views @ 2022-10-11 22:24 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2022-10-11 22:24 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Yet further fixes for multi-row VALUES lists for updatable views. DEFAULT markers appearing in an INSERT on an updatable view could be mis-processed if they were in a multi-row VALUES clause. This would lead to strange errors such as "cache lookup failed for type NNNN", or in older branches even to crashes. The cause is that commit 41531e42d tried to re-use rewriteValuesRTE() to remove any SetToDefault nodes (that hadn't previously been replaced by the view's own default values) appearing in "product" queries, that is DO ALSO queries. That's fundamentally wrong because the DO ALSO queries might not even be INSERTs; and even if they are, their targetlists don't necessarily match the view's column list, so that almost all the logic in rewriteValuesRTE() is inapplicable. What we want is a narrow focus on replacing any such nodes with NULL constants. (That is, in this context we are interpreting the defaults as being strictly those of the view itself; and we already replaced any that aren't NULL.) We could add still more !force_nulls tests to further lobotomize rewriteValuesRTE(); but it seems cleaner to split out this case to a new function, restoring rewriteValuesRTE() to the charter it had before. Per bug #17633 from jiye_sw. Patch by me, but thanks to Richard Guo and Japin Li for initial investigation. Back-patch to all supported branches, as the previous fix was. Discussion: https://postgr.es/m/17633-98cc85e1fa91e905@postgresql.org Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/21e042b0bd47d8564f7178f72114d707cb1ceba8 Modified Files -------------- src/backend/rewrite/rewriteHandler.c | 84 ++++++++++++++++++--------- src/test/regress/expected/updatable_views.out | 22 +++++++ src/test/regress/sql/updatable_views.sql | 17 ++++++ 3 files changed, 97 insertions(+), 26 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Yet further fixes for multi-row VALUES lists for updatable views @ 2022-10-11 22:24 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2022-10-11 22:24 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Yet further fixes for multi-row VALUES lists for updatable views. DEFAULT markers appearing in an INSERT on an updatable view could be mis-processed if they were in a multi-row VALUES clause. This would lead to strange errors such as "cache lookup failed for type NNNN", or in older branches even to crashes. The cause is that commit 41531e42d tried to re-use rewriteValuesRTE() to remove any SetToDefault nodes (that hadn't previously been replaced by the view's own default values) appearing in "product" queries, that is DO ALSO queries. That's fundamentally wrong because the DO ALSO queries might not even be INSERTs; and even if they are, their targetlists don't necessarily match the view's column list, so that almost all the logic in rewriteValuesRTE() is inapplicable. What we want is a narrow focus on replacing any such nodes with NULL constants. (That is, in this context we are interpreting the defaults as being strictly those of the view itself; and we already replaced any that aren't NULL.) We could add still more !force_nulls tests to further lobotomize rewriteValuesRTE(); but it seems cleaner to split out this case to a new function, restoring rewriteValuesRTE() to the charter it had before. Per bug #17633 from jiye_sw. Patch by me, but thanks to Richard Guo and Japin Li for initial investigation. Back-patch to all supported branches, as the previous fix was. Discussion: https://postgr.es/m/17633-98cc85e1fa91e905@postgresql.org Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/abc510fa2a34eba00406e9ce330b77e1d9c4ccdf Modified Files -------------- src/backend/rewrite/rewriteHandler.c | 84 ++++++++++++++++++--------- src/test/regress/expected/updatable_views.out | 22 +++++++ src/test/regress/sql/updatable_views.sql | 17 ++++++ 3 files changed, 97 insertions(+), 26 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Yet further fixes for multi-row VALUES lists for updatable views @ 2022-10-11 22:24 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2022-10-11 22:24 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Yet further fixes for multi-row VALUES lists for updatable views. DEFAULT markers appearing in an INSERT on an updatable view could be mis-processed if they were in a multi-row VALUES clause. This would lead to strange errors such as "cache lookup failed for type NNNN", or in older branches even to crashes. The cause is that commit 41531e42d tried to re-use rewriteValuesRTE() to remove any SetToDefault nodes (that hadn't previously been replaced by the view's own default values) appearing in "product" queries, that is DO ALSO queries. That's fundamentally wrong because the DO ALSO queries might not even be INSERTs; and even if they are, their targetlists don't necessarily match the view's column list, so that almost all the logic in rewriteValuesRTE() is inapplicable. What we want is a narrow focus on replacing any such nodes with NULL constants. (That is, in this context we are interpreting the defaults as being strictly those of the view itself; and we already replaced any that aren't NULL.) We could add still more !force_nulls tests to further lobotomize rewriteValuesRTE(); but it seems cleaner to split out this case to a new function, restoring rewriteValuesRTE() to the charter it had before. Per bug #17633 from jiye_sw. Patch by me, but thanks to Richard Guo and Japin Li for initial investigation. Back-patch to all supported branches, as the previous fix was. Discussion: https://postgr.es/m/17633-98cc85e1fa91e905@postgresql.org Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/addde9bc6caf2563f01ecea1ff01e22c328da1ad Modified Files -------------- src/backend/rewrite/rewriteHandler.c | 84 ++++++++++++++++++--------- src/test/regress/expected/updatable_views.out | 22 +++++++ src/test/regress/sql/updatable_views.sql | 17 ++++++ 3 files changed, 97 insertions(+), 26 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Yet further fixes for multi-row VALUES lists for updatable views @ 2022-10-11 22:24 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2022-10-11 22:24 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Yet further fixes for multi-row VALUES lists for updatable views. DEFAULT markers appearing in an INSERT on an updatable view could be mis-processed if they were in a multi-row VALUES clause. This would lead to strange errors such as "cache lookup failed for type NNNN", or in older branches even to crashes. The cause is that commit 41531e42d tried to re-use rewriteValuesRTE() to remove any SetToDefault nodes (that hadn't previously been replaced by the view's own default values) appearing in "product" queries, that is DO ALSO queries. That's fundamentally wrong because the DO ALSO queries might not even be INSERTs; and even if they are, their targetlists don't necessarily match the view's column list, so that almost all the logic in rewriteValuesRTE() is inapplicable. What we want is a narrow focus on replacing any such nodes with NULL constants. (That is, in this context we are interpreting the defaults as being strictly those of the view itself; and we already replaced any that aren't NULL.) We could add still more !force_nulls tests to further lobotomize rewriteValuesRTE(); but it seems cleaner to split out this case to a new function, restoring rewriteValuesRTE() to the charter it had before. Per bug #17633 from jiye_sw. Patch by me, but thanks to Richard Guo and Japin Li for initial investigation. Back-patch to all supported branches, as the previous fix was. Discussion: https://postgr.es/m/17633-98cc85e1fa91e905@postgresql.org Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/23e2a06acf0435c1337e0a1e1d473e35eced7d6d Modified Files -------------- src/backend/rewrite/rewriteHandler.c | 84 ++++++++++++++++++--------- src/test/regress/expected/updatable_views.out | 22 +++++++ src/test/regress/sql/updatable_views.sql | 17 ++++++ 3 files changed, 97 insertions(+), 26 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2022-10-11 22:24 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-10-11 22:24 pgsql: Yet further fixes for multi-row VALUES lists for updatable views Tom Lane <tgl@sss.pgh.pa.us> 2022-10-11 22:24 pgsql: Yet further fixes for multi-row VALUES lists for updatable views Tom Lane <tgl@sss.pgh.pa.us> 2022-10-11 22:24 pgsql: Yet further fixes for multi-row VALUES lists for updatable views Tom Lane <tgl@sss.pgh.pa.us> 2022-10-11 22:24 pgsql: Yet further fixes for multi-row VALUES lists for updatable views Tom Lane <tgl@sss.pgh.pa.us> 2022-10-11 22:24 pgsql: Yet further fixes for multi-row VALUES lists for updatable views Tom Lane <tgl@sss.pgh.pa.us> 2022-10-11 22:24 pgsql: Yet further fixes for multi-row VALUES lists for updatable views Tom Lane <tgl@sss.pgh.pa.us> 2022-10-11 22:24 pgsql: Yet further fixes for multi-row VALUES lists for updatable views Tom Lane <tgl@sss.pgh.pa.us>
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