Skip to content

Commit

Permalink
PG-1038 Add regression tests that causes PG crash
Browse files Browse the repository at this point in the history
  • Loading branch information
artemgavrilov committed Sep 19, 2024
1 parent da0a002 commit f3ca435
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions expected/tablespace.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO
26 changes: 26 additions & 0 deletions sql/tablespace.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
CREATE EXTENSION pg_tde;

SELECT * FROM pg_tde_principal_key_info();

SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per');
SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault');


CREATE TABLE test(num1 bigint, num2 double precision, t text);
INSERT INTO test(num1, num2, t)
SELECT round(random()*100), random(), 'text'
FROM generate_series(1, 10) s(i);
CREATE INDEX test_idx ON test(num1);

SET allow_in_place_tablespaces = true;
CREATE TABLESPACE test_tblspace LOCATION '';

ALTER TABLE test SET TABLESPACE test_tblspace;
ALTER TABLE test SET TABLESPACE pg_default;

REINDEX (TABLESPACE test_tblspace, CONCURRENTLY) TABLE test;
INSERT INTO test VALUES (10, 2);

DROP TABLE test;
DROP TABLESPACE test_tblspace;
DROP EXTENSION pg_tde;
3 changes: 3 additions & 0 deletions src/access/pg_tde_slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ PGTdeExecStoreBufferHeapTuple(Relation rel,
if (rel->rd_rel->relkind != RELKIND_TOASTVALUE)
{
RelKeyData *key = get_current_slot_relation_key(bslot, rel);

Assert(key != NULL);

slot_copytuple(bslot->decrypted_buffer, tuple);
PG_TDE_DECRYPT_TUPLE_EX(tuple, (HeapTuple)bslot->decrypted_buffer, key, "ExecStoreBuffer");
tuple->t_data = ((HeapTuple)bslot->decrypted_buffer)->t_data;
Expand Down

0 comments on commit f3ca435

Please sign in to comment.