PMM-1035 Fix toast slice fetching with offset (#282)

pull/209/head
Artem Gavrilov 1 year ago committed by GitHub
parent 419753082c
commit 137a49847e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 23
      expected/toast_extended_storage.out
  2. 11
      sql/toast_extended_storage.sql
  3. 2
      src16/access/pg_tdetoast.c
  4. 2
      src17/access/pg_tdetoast.c

@ -77,4 +77,27 @@ UPDATE indtoasttest SET cnt = cnt +1, f1 = f1||'' RETURNING substring(indtoastte
UPDATE indtoasttest SET f2 = '+'||f2||'-' ;
DROP TABLE indtoasttest;
-- Test substr with toasted externalized bytea values
CREATE TABLE toasttest(t bytea STORAGE EXTERNAL) using tde_heap_basic;
INSERT INTO toasttest VALUES (decode(repeat('1234567890',10000), 'escape'));
SET bytea_output = 'escape';
SELECT substring(t, 1, 10) FROM toasttest;
substring
------------
1234567890
(1 row)
SELECT substring(t, 50001, 10) FROM toasttest;
substring
------------
1234567890
(1 row)
SELECT substring(t, 99991) FROM toasttest;
substring
------------
1234567890
(1 row)
DROP TABLE toasttest;
DROP EXTENSION pg_tde;

@ -35,4 +35,15 @@ UPDATE indtoasttest SET f2 = '+'||f2||'-' ;
DROP TABLE indtoasttest;
-- Test substr with toasted externalized bytea values
CREATE TABLE toasttest(t bytea STORAGE EXTERNAL) using tde_heap_basic;
INSERT INTO toasttest VALUES (decode(repeat('1234567890',10000), 'escape'));
SET bytea_output = 'escape';
SELECT substring(t, 1, 10) FROM toasttest;
SELECT substring(t, 50001, 10) FROM toasttest;
SELECT substring(t, 99991) FROM toasttest;
DROP TABLE toasttest;
DROP EXTENSION pg_tde;

@ -812,7 +812,7 @@ tdeheap_fetch_toast_slice(Relation toastrel, Oid valueid, int32 attrsize,
}
/* Decrypt the data chunk by chunk here */
PG_TDE_DECRYPT_DATA(iv_prefix, (curchunk * TOAST_MAX_CHUNK_SIZE - sliceoffset) + encrypt_offset,
PG_TDE_DECRYPT_DATA(iv_prefix, (curchunk * TOAST_MAX_CHUNK_SIZE) + encrypt_offset,
chunkdata + chcpystrt,
(chcpyend - chcpystrt) + 1,
decrypted_data, key);

@ -812,7 +812,7 @@ tdeheap_fetch_toast_slice(Relation toastrel, Oid valueid, int32 attrsize,
}
/* Decrypt the data chunk by chunk here */
PG_TDE_DECRYPT_DATA(iv_prefix, (curchunk * TOAST_MAX_CHUNK_SIZE - sliceoffset) + encrypt_offset,
PG_TDE_DECRYPT_DATA(iv_prefix, (curchunk * TOAST_MAX_CHUNK_SIZE) + encrypt_offset,
chunkdata + chcpystrt,
(chcpyend - chcpystrt) + 1,
decrypted_data, key);

Loading…
Cancel
Save