mirror of https://github.com/citusdata/citus.git
Add basic read-only transaction tests
parent
f838c83809
commit
3d99cdfcc7
|
@ -22,6 +22,16 @@ SELECT avg(l_extendedprice) FROM lineitem;
|
||||||
38141.835375000000
|
38141.835375000000
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- Verify that we can do queries in read-only mode
|
||||||
|
BEGIN;
|
||||||
|
SET TRANSACTION READ ONLY;
|
||||||
|
SELECT count(*) FROM lineitem;
|
||||||
|
count
|
||||||
|
-------
|
||||||
|
12000
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
-- Verify temp tables which are used for final result aggregation don't persist.
|
-- Verify temp tables which are used for final result aggregation don't persist.
|
||||||
SELECT count(*) FROM pg_class WHERE relname LIKE 'pg_merge_job_%' AND relkind = 'r';
|
SELECT count(*) FROM pg_class WHERE relname LIKE 'pg_merge_job_%' AND relkind = 'r';
|
||||||
count
|
count
|
||||||
|
|
|
@ -2023,6 +2023,26 @@ DEBUG: Plan is router executable
|
||||||
41 | 1 | aznavour | 11814
|
41 | 1 | aznavour | 11814
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
|
END;
|
||||||
|
-- queries inside read-only transactions can be router plannable
|
||||||
|
BEGIN;
|
||||||
|
SET TRANSACTION READ ONLY;
|
||||||
|
SELECT *
|
||||||
|
FROM articles_hash
|
||||||
|
WHERE author_id = 1
|
||||||
|
ORDER BY id;
|
||||||
|
DEBUG: predicate pruning for shardId 840001
|
||||||
|
DEBUG: Creating router plan
|
||||||
|
DEBUG: Plan is router executable
|
||||||
|
id | author_id | title | word_count
|
||||||
|
----+-----------+--------------+------------
|
||||||
|
1 | 1 | arsenous | 9572
|
||||||
|
11 | 1 | alamo | 1347
|
||||||
|
21 | 1 | arcading | 5890
|
||||||
|
31 | 1 | athwartships | 7271
|
||||||
|
41 | 1 | aznavour | 11814
|
||||||
|
(5 rows)
|
||||||
|
|
||||||
END;
|
END;
|
||||||
-- cursor queries are router plannable
|
-- cursor queries are router plannable
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
|
@ -19,6 +19,12 @@ SELECT master_create_worker_shards('sharded_table', 2, 1);
|
||||||
COPY sharded_table TO STDOUT;
|
COPY sharded_table TO STDOUT;
|
||||||
COPY (SELECT COUNT(*) FROM sharded_table) TO STDOUT;
|
COPY (SELECT COUNT(*) FROM sharded_table) TO STDOUT;
|
||||||
0
|
0
|
||||||
|
BEGIN;
|
||||||
|
SET TRANSACTION READ ONLY;
|
||||||
|
COPY sharded_table TO STDOUT;
|
||||||
|
COPY (SELECT COUNT(*) FROM sharded_table) TO STDOUT;
|
||||||
|
0
|
||||||
|
COMMIT;
|
||||||
-- cursors may not involve distributed tables
|
-- cursors may not involve distributed tables
|
||||||
DECLARE all_sharded_rows CURSOR FOR SELECT * FROM sharded_table;
|
DECLARE all_sharded_rows CURSOR FOR SELECT * FROM sharded_table;
|
||||||
ERROR: DECLARE CURSOR can only be used in transaction blocks
|
ERROR: DECLARE CURSOR can only be used in transaction blocks
|
||||||
|
|
|
@ -15,5 +15,11 @@ SELECT sum(l_extendedprice) FROM lineitem;
|
||||||
|
|
||||||
SELECT avg(l_extendedprice) FROM lineitem;
|
SELECT avg(l_extendedprice) FROM lineitem;
|
||||||
|
|
||||||
|
-- Verify that we can do queries in read-only mode
|
||||||
|
BEGIN;
|
||||||
|
SET TRANSACTION READ ONLY;
|
||||||
|
SELECT count(*) FROM lineitem;
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
-- Verify temp tables which are used for final result aggregation don't persist.
|
-- Verify temp tables which are used for final result aggregation don't persist.
|
||||||
SELECT count(*) FROM pg_class WHERE relname LIKE 'pg_merge_job_%' AND relkind = 'r';
|
SELECT count(*) FROM pg_class WHERE relname LIKE 'pg_merge_job_%' AND relkind = 'r';
|
||||||
|
|
|
@ -906,6 +906,15 @@ SELECT *
|
||||||
ORDER BY id;
|
ORDER BY id;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
-- queries inside read-only transactions can be router plannable
|
||||||
|
BEGIN;
|
||||||
|
SET TRANSACTION READ ONLY;
|
||||||
|
SELECT *
|
||||||
|
FROM articles_hash
|
||||||
|
WHERE author_id = 1
|
||||||
|
ORDER BY id;
|
||||||
|
END;
|
||||||
|
|
||||||
-- cursor queries are router plannable
|
-- cursor queries are router plannable
|
||||||
BEGIN;
|
BEGIN;
|
||||||
DECLARE test_cursor CURSOR FOR
|
DECLARE test_cursor CURSOR FOR
|
||||||
|
|
|
@ -14,6 +14,12 @@ SELECT master_create_worker_shards('sharded_table', 2, 1);
|
||||||
COPY sharded_table TO STDOUT;
|
COPY sharded_table TO STDOUT;
|
||||||
COPY (SELECT COUNT(*) FROM sharded_table) TO STDOUT;
|
COPY (SELECT COUNT(*) FROM sharded_table) TO STDOUT;
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
SET TRANSACTION READ ONLY;
|
||||||
|
COPY sharded_table TO STDOUT;
|
||||||
|
COPY (SELECT COUNT(*) FROM sharded_table) TO STDOUT;
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
-- cursors may not involve distributed tables
|
-- cursors may not involve distributed tables
|
||||||
DECLARE all_sharded_rows CURSOR FOR SELECT * FROM sharded_table;
|
DECLARE all_sharded_rows CURSOR FOR SELECT * FROM sharded_table;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue