diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:15:05 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:15:05 +0000 |
commit | 46651ce6fe013220ed397add242004d764fc0153 (patch) | |
tree | 6e5299f990f88e60174a1d3ae6e48eedd2688b2b /src/test/regress/sql/hs_primary_extremes.sql | |
parent | Initial commit. (diff) | |
download | postgresql-14-upstream.tar.xz postgresql-14-upstream.zip |
Adding upstream version 14.5.upstream/14.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/regress/sql/hs_primary_extremes.sql')
-rw-r--r-- | src/test/regress/sql/hs_primary_extremes.sql | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/test/regress/sql/hs_primary_extremes.sql b/src/test/regress/sql/hs_primary_extremes.sql new file mode 100644 index 0000000..2051e2e --- /dev/null +++ b/src/test/regress/sql/hs_primary_extremes.sql @@ -0,0 +1,73 @@ +-- +-- Hot Standby tests +-- +-- hs_primary_extremes.sql +-- + +drop table if exists hs_extreme; +create table hs_extreme (col1 integer); + +CREATE OR REPLACE FUNCTION hs_subxids (n integer) +RETURNS void +LANGUAGE plpgsql +AS $$ + BEGIN + IF n <= 0 THEN RETURN; END IF; + INSERT INTO hs_extreme VALUES (n); + PERFORM hs_subxids(n - 1); + RETURN; + EXCEPTION WHEN raise_exception THEN NULL; END; +$$; + +BEGIN; +SELECT hs_subxids(257); +ROLLBACK; +BEGIN; +SELECT hs_subxids(257); +COMMIT; + +set client_min_messages = 'warning'; + +CREATE OR REPLACE FUNCTION hs_locks_create (n integer) +RETURNS void +LANGUAGE plpgsql +AS $$ + BEGIN + IF n <= 0 THEN + CHECKPOINT; + RETURN; + END IF; + EXECUTE 'CREATE TABLE hs_locks_' || n::text || ' ()'; + PERFORM hs_locks_create(n - 1); + RETURN; + EXCEPTION WHEN raise_exception THEN NULL; END; +$$; + +CREATE OR REPLACE FUNCTION hs_locks_drop (n integer) +RETURNS void +LANGUAGE plpgsql +AS $$ + BEGIN + IF n <= 0 THEN + CHECKPOINT; + RETURN; + END IF; + EXECUTE 'DROP TABLE IF EXISTS hs_locks_' || n::text; + PERFORM hs_locks_drop(n - 1); + RETURN; + EXCEPTION WHEN raise_exception THEN NULL; END; +$$; + +BEGIN; +SELECT hs_locks_drop(257); +SELECT hs_locks_create(257); +SELECT count(*) > 257 FROM pg_locks; +ROLLBACK; +BEGIN; +SELECT hs_locks_drop(257); +SELECT hs_locks_create(257); +SELECT count(*) > 257 FROM pg_locks; +COMMIT; +SELECT hs_locks_drop(257); + +SELECT pg_switch_wal(); |