pgsql: Add isolation test for TOAST value reuse during CLUSTER - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Add isolation test for TOAST value reuse during CLUSTER
Date
Msg-id E1unWs1-000GyW-0N@gemulon.postgresql.org
Whole thread Raw
Responses Re: pgsql: Add isolation test for TOAST value reuse during CLUSTER
List pgsql-committers
Add isolation test for TOAST value reuse during CLUSTER

This test exercises the corner case in toast_save_datum() where CLUSTER
operations encounter duplicated TOAST references, reusing the existing
TOAST data instead of creating redundant copies.

During table rewrites like CLUSTER, both live and recently-dead versions
of a row may reference the same TOAST value.  When copying the second or
later version of such a row, the system checks if a TOAST value already
exists in the new TOAST table using toastrel_valueid_exists().  If
found, toast_save_datum() sets data_todo = 0 so as redundant data is not
stored, ensuring only one copy of the TOAST value exists in the new
table.

The test relies on a combination of UPDATE, CLUSTER, and checks of the
TOAST values used before and after the relation rewrite, to make sure
that the same values are reused across the rewrite.

This is a continuation of 69f75d671475 to make sure that this corner
case keeps working should we mess with this area of the code.

Author: Nikhil Kumar Veldanda <veldanda.nikhilkumar17@gmail.com>
Discussion: https://postgr.es/m/CAFAfj_E+kw5P713S8_jZyVgQAGVFfzFiTUJPrgo-TTtJJoazQw@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
.../expected/cluster-toast-value-reuse.out         | 29 +++++++++
src/test/isolation/isolation_schedule              |  1 +
.../isolation/specs/cluster-toast-value-reuse.spec | 69 ++++++++++++++++++++++
3 files changed, 99 insertions(+)


pgsql-committers by date:

Previous
From: Masahiko Sawada
Date:
Subject: pgsql: Fix typos in comments.
Next
From: Etsuro Fujita
Date:
Subject: pgsql: Update obsolete comments in ResultRelInfo struct.