pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix order of operations in ExecEvalFieldStoreDeForm(). 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix order of operations in ExecEvalFieldStoreDeForm(). @ 2023-06-29 14:20 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-06-29 14:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix order of operations in ExecEvalFieldStoreDeForm(). If the given composite datum is toasted out-of-line, DatumGetHeapTupleHeader will perform database accesses to detoast it. That can invalidate the result of get_cached_rowtype, as documented (perhaps not plainly enough) in that function's API spec; which leads to strange errors or crashes when we try to use the TupleDesc to read the tuple. In short then, trying to update a field of a composite column could fail intermittently if the overall column value is wide enough to require toasting. We can fix the bug at no cost by just changing the order of operations, since we don't need the TupleDesc until after detoasting. (Other callers of get_cached_rowtype appear to get this right already, so there's only one bug.) Note that the added regression test case reveals this bug reliably only with debug_discard_caches/CLOBBER_CACHE_ALWAYS. Per bug #17994 from Alexander Lakhin. Sadly, this patch does not fix the missing-values issue revealed in the bug discussion; we'll need some more work to cover that. Discussion: https://postgr.es/m/17994-5c7100b51b4790e9@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/43af714defa00145981eb542cb71647836b3efa4 Modified Files -------------- src/backend/executor/execExprInterp.c | 29 +++++++++++++++++------------ src/test/regress/expected/rowtypes.out | 9 +++++++++ src/test/regress/sql/rowtypes.sql | 5 +++++ 3 files changed, 31 insertions(+), 12 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix order of operations in ExecEvalFieldStoreDeForm(). @ 2023-06-29 14:20 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-06-29 14:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix order of operations in ExecEvalFieldStoreDeForm(). If the given composite datum is toasted out-of-line, DatumGetHeapTupleHeader will perform database accesses to detoast it. That can invalidate the result of get_cached_rowtype, as documented (perhaps not plainly enough) in that function's API spec; which leads to strange errors or crashes when we try to use the TupleDesc to read the tuple. In short then, trying to update a field of a composite column could fail intermittently if the overall column value is wide enough to require toasting. We can fix the bug at no cost by just changing the order of operations, since we don't need the TupleDesc until after detoasting. (Other callers of get_cached_rowtype appear to get this right already, so there's only one bug.) Note that the added regression test case reveals this bug reliably only with debug_discard_caches/CLOBBER_CACHE_ALWAYS. Per bug #17994 from Alexander Lakhin. Sadly, this patch does not fix the missing-values issue revealed in the bug discussion; we'll need some more work to cover that. Discussion: https://postgr.es/m/17994-5c7100b51b4790e9@postgresql.org Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/cc8cca3c2d6061295c72f19f81fdaa774a208bca Modified Files -------------- src/backend/executor/execExprInterp.c | 29 +++++++++++++++++------------ src/test/regress/expected/rowtypes.out | 9 +++++++++ src/test/regress/sql/rowtypes.sql | 5 +++++ 3 files changed, 31 insertions(+), 12 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix order of operations in ExecEvalFieldStoreDeForm(). @ 2023-06-29 14:20 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-06-29 14:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix order of operations in ExecEvalFieldStoreDeForm(). If the given composite datum is toasted out-of-line, DatumGetHeapTupleHeader will perform database accesses to detoast it. That can invalidate the result of get_cached_rowtype, as documented (perhaps not plainly enough) in that function's API spec; which leads to strange errors or crashes when we try to use the TupleDesc to read the tuple. In short then, trying to update a field of a composite column could fail intermittently if the overall column value is wide enough to require toasting. We can fix the bug at no cost by just changing the order of operations, since we don't need the TupleDesc until after detoasting. (Other callers of get_cached_rowtype appear to get this right already, so there's only one bug.) Note that the added regression test case reveals this bug reliably only with debug_discard_caches/CLOBBER_CACHE_ALWAYS. Per bug #17994 from Alexander Lakhin. Sadly, this patch does not fix the missing-values issue revealed in the bug discussion; we'll need some more work to cover that. Discussion: https://postgr.es/m/17994-5c7100b51b4790e9@postgresql.org Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0789b82a97924cec14f651f678eebc56c09da17f Modified Files -------------- src/backend/executor/execExprInterp.c | 29 +++++++++++++++++------------ src/test/regress/expected/rowtypes.out | 9 +++++++++ src/test/regress/sql/rowtypes.sql | 5 +++++ 3 files changed, 31 insertions(+), 12 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix order of operations in ExecEvalFieldStoreDeForm(). @ 2023-06-29 14:20 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-06-29 14:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix order of operations in ExecEvalFieldStoreDeForm(). If the given composite datum is toasted out-of-line, DatumGetHeapTupleHeader will perform database accesses to detoast it. That can invalidate the result of get_cached_rowtype, as documented (perhaps not plainly enough) in that function's API spec; which leads to strange errors or crashes when we try to use the TupleDesc to read the tuple. In short then, trying to update a field of a composite column could fail intermittently if the overall column value is wide enough to require toasting. We can fix the bug at no cost by just changing the order of operations, since we don't need the TupleDesc until after detoasting. (Other callers of get_cached_rowtype appear to get this right already, so there's only one bug.) Note that the added regression test case reveals this bug reliably only with debug_discard_caches/CLOBBER_CACHE_ALWAYS. Per bug #17994 from Alexander Lakhin. Sadly, this patch does not fix the missing-values issue revealed in the bug discussion; we'll need some more work to cover that. Discussion: https://postgr.es/m/17994-5c7100b51b4790e9@postgresql.org Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d0ab203bc192382053d3782062bef6872bdc0e53 Modified Files -------------- src/backend/executor/execExprInterp.c | 29 +++++++++++++++++------------ src/test/regress/expected/rowtypes.out | 9 +++++++++ src/test/regress/sql/rowtypes.sql | 5 +++++ 3 files changed, 31 insertions(+), 12 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix order of operations in ExecEvalFieldStoreDeForm(). @ 2023-06-29 14:20 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-06-29 14:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix order of operations in ExecEvalFieldStoreDeForm(). If the given composite datum is toasted out-of-line, DatumGetHeapTupleHeader will perform database accesses to detoast it. That can invalidate the result of get_cached_rowtype, as documented (perhaps not plainly enough) in that function's API spec; which leads to strange errors or crashes when we try to use the TupleDesc to read the tuple. In short then, trying to update a field of a composite column could fail intermittently if the overall column value is wide enough to require toasting. We can fix the bug at no cost by just changing the order of operations, since we don't need the TupleDesc until after detoasting. (Other callers of get_cached_rowtype appear to get this right already, so there's only one bug.) Note that the added regression test case reveals this bug reliably only with debug_discard_caches/CLOBBER_CACHE_ALWAYS. Per bug #17994 from Alexander Lakhin. Sadly, this patch does not fix the missing-values issue revealed in the bug discussion; we'll need some more work to cover that. Discussion: https://postgr.es/m/17994-5c7100b51b4790e9@postgresql.org Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/53b93e853ffed18cda1110db85f315671f40959b Modified Files -------------- src/backend/executor/execExprInterp.c | 29 +++++++++++++++++------------ src/test/regress/expected/rowtypes.out | 9 +++++++++ src/test/regress/sql/rowtypes.sql | 5 +++++ 3 files changed, 31 insertions(+), 12 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix order of operations in ExecEvalFieldStoreDeForm(). @ 2023-06-29 14:20 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2023-06-29 14:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix order of operations in ExecEvalFieldStoreDeForm(). If the given composite datum is toasted out-of-line, DatumGetHeapTupleHeader will perform database accesses to detoast it. That can invalidate the result of get_cached_rowtype, as documented (perhaps not plainly enough) in that function's API spec; which leads to strange errors or crashes when we try to use the TupleDesc to read the tuple. In short then, trying to update a field of a composite column could fail intermittently if the overall column value is wide enough to require toasting. We can fix the bug at no cost by just changing the order of operations, since we don't need the TupleDesc until after detoasting. (Other callers of get_cached_rowtype appear to get this right already, so there's only one bug.) Note that the added regression test case reveals this bug reliably only with debug_discard_caches/CLOBBER_CACHE_ALWAYS. Per bug #17994 from Alexander Lakhin. Sadly, this patch does not fix the missing-values issue revealed in the bug discussion; we'll need some more work to cover that. Discussion: https://postgr.es/m/17994-5c7100b51b4790e9@postgresql.org Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/7f11b7a9cf1882b3d1ce5ac73018127baf93b2d3 Modified Files -------------- src/backend/executor/execExprInterp.c | 29 +++++++++++++++++------------ src/test/regress/expected/rowtypes.out | 9 +++++++++ src/test/regress/sql/rowtypes.sql | 5 +++++ 3 files changed, 31 insertions(+), 12 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2023-06-29 14:20 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-06-29 14:20 pgsql: Fix order of operations in ExecEvalFieldStoreDeForm(). Tom Lane <tgl@sss.pgh.pa.us> 2023-06-29 14:20 pgsql: Fix order of operations in ExecEvalFieldStoreDeForm(). Tom Lane <tgl@sss.pgh.pa.us> 2023-06-29 14:20 pgsql: Fix order of operations in ExecEvalFieldStoreDeForm(). Tom Lane <tgl@sss.pgh.pa.us> 2023-06-29 14:20 pgsql: Fix order of operations in ExecEvalFieldStoreDeForm(). Tom Lane <tgl@sss.pgh.pa.us> 2023-06-29 14:20 pgsql: Fix order of operations in ExecEvalFieldStoreDeForm(). Tom Lane <tgl@sss.pgh.pa.us> 2023-06-29 14:20 pgsql: Fix order of operations in ExecEvalFieldStoreDeForm(). 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