diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/test_decoding/expected/stream.out | 19 | ||||
-rw-r--r-- | contrib/test_decoding/sql/stream.sql | 15 |
2 files changed, 34 insertions, 0 deletions
diff --git a/contrib/test_decoding/expected/stream.out b/contrib/test_decoding/expected/stream.out index 4ab2d47bf8d..a76f77601e2 100644 --- a/contrib/test_decoding/expected/stream.out +++ b/contrib/test_decoding/expected/stream.out @@ -109,6 +109,25 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL,NULL, 'incl committing streamed transaction (17 rows) +/* + * Test concurrent abort with toast data. When streaming the second insertion, we + * detect that the subtransaction was aborted, and reset the transaction while having + * the TOAST changes in memory, resulting in deallocating both decoded changes and + * TOAST reconstruction data. Memory usage counters must be updated correctly. + */ +BEGIN; +INSERT INTO stream_test SELECT repeat(string_agg(to_char(g.i, 'FM0000'), ''), 50) FROM generate_series(1, 500) g(i); +ALTER TABLE stream_test ADD COLUMN i INT; +SAVEPOINT s1; +INSERT INTO stream_test(data, i) SELECT repeat(string_agg(to_char(g.i, 'FM0000'), ''), 50), 1 FROM generate_series(1, 500) g(i); +ROLLBACK TO s1; +COMMIT; +SELECT count(*) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1'); + count +------- + 5 +(1 row) + DROP TABLE stream_test; SELECT pg_drop_replication_slot('regression_slot'); pg_drop_replication_slot diff --git a/contrib/test_decoding/sql/stream.sql b/contrib/test_decoding/sql/stream.sql index 4feec62972a..7f43f0c2ab7 100644 --- a/contrib/test_decoding/sql/stream.sql +++ b/contrib/test_decoding/sql/stream.sql @@ -44,5 +44,20 @@ toasted-123456789012345678901234567890123456789012345678901234567890123456789012 SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL,NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1'); +/* + * Test concurrent abort with toast data. When streaming the second insertion, we + * detect that the subtransaction was aborted, and reset the transaction while having + * the TOAST changes in memory, resulting in deallocating both decoded changes and + * TOAST reconstruction data. Memory usage counters must be updated correctly. + */ +BEGIN; +INSERT INTO stream_test SELECT repeat(string_agg(to_char(g.i, 'FM0000'), ''), 50) FROM generate_series(1, 500) g(i); +ALTER TABLE stream_test ADD COLUMN i INT; +SAVEPOINT s1; +INSERT INTO stream_test(data, i) SELECT repeat(string_agg(to_char(g.i, 'FM0000'), ''), 50), 1 FROM generate_series(1, 500) g(i); +ROLLBACK TO s1; +COMMIT; +SELECT count(*) FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'stream-changes', '1'); + DROP TABLE stream_test; SELECT pg_drop_replication_slot('regression_slot'); |