aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-03-15 10:46:13 -0400
committerRobert Haas <rhaas@postgresql.org>2017-03-15 10:53:07 -0400
commit42bdaebf161841c8e248b197b7319779b8730323 (patch)
tree6f08b62aec2446985bbe4641163fa703b4de41f4
parentd8f356e1bd3382308b32eed01394879e20eb5158 (diff)
downloadpostgresql-42bdaebf161841c8e248b197b7319779b8730323.tar.gz
postgresql-42bdaebf161841c8e248b197b7319779b8730323.zip
Add a regression test for snapshot too old with hash indexes.
Amit Kapila, but I changed the comment not to be a copy-and-paste of an existing one, and instead referred to it. Discussion: http://postgr.es/m/CAA4eK1K0UJswCRf81WwJFO4H=+ZvbmKTNhAps-NkdmHRsq1GnQ@mail.gmail.com
-rw-r--r--src/test/modules/snapshot_too_old/Makefile2
-rw-r--r--src/test/modules/snapshot_too_old/expected/sto_using_hash_index.out15
-rw-r--r--src/test/modules/snapshot_too_old/specs/sto_using_hash_index.spec31
3 files changed, 47 insertions, 1 deletions
diff --git a/src/test/modules/snapshot_too_old/Makefile b/src/test/modules/snapshot_too_old/Makefile
index a72bfad43a0..b6d998f3207 100644
--- a/src/test/modules/snapshot_too_old/Makefile
+++ b/src/test/modules/snapshot_too_old/Makefile
@@ -4,7 +4,7 @@
# we have to clean those result files explicitly
EXTRA_CLEAN = $(pg_regress_clean_files)
-ISOLATIONCHECKS=sto_using_cursor sto_using_select
+ISOLATIONCHECKS=sto_using_cursor sto_using_select sto_using_hash_index
ifdef USE_PGXS
PG_CONFIG = pg_config
diff --git a/src/test/modules/snapshot_too_old/expected/sto_using_hash_index.out b/src/test/modules/snapshot_too_old/expected/sto_using_hash_index.out
new file mode 100644
index 00000000000..bf940547904
--- /dev/null
+++ b/src/test/modules/snapshot_too_old/expected/sto_using_hash_index.out
@@ -0,0 +1,15 @@
+Parsed test spec with 2 sessions
+
+starting permutation: noseq s1f1 s2sleep s2u s1f2
+step noseq: SET enable_seqscan = false;
+step s1f1: SELECT c FROM sto1 where c = 1000;
+c
+
+1000
+step s2sleep: SELECT setting, pg_sleep(6) FROM pg_settings WHERE name = 'old_snapshot_threshold';
+setting pg_sleep
+
+0
+step s2u: UPDATE sto1 SET c = 1001 WHERE c = 1000;
+step s1f2: SELECT c FROM sto1 where c = 1001;
+ERROR: snapshot too old
diff --git a/src/test/modules/snapshot_too_old/specs/sto_using_hash_index.spec b/src/test/modules/snapshot_too_old/specs/sto_using_hash_index.spec
new file mode 100644
index 00000000000..33d91ff8523
--- /dev/null
+++ b/src/test/modules/snapshot_too_old/specs/sto_using_hash_index.spec
@@ -0,0 +1,31 @@
+# This test is like sto_using_select, except that we test access via a
+# hash index.
+
+setup
+{
+ CREATE TABLE sto1 (c int NOT NULL);
+ INSERT INTO sto1 SELECT generate_series(1, 1000);
+ CREATE INDEX idx_sto1 ON sto1 USING HASH (c);
+}
+setup
+{
+ VACUUM ANALYZE sto1;
+}
+
+teardown
+{
+ DROP TABLE sto1;
+}
+
+session "s1"
+setup { BEGIN ISOLATION LEVEL REPEATABLE READ; }
+step "noseq" { SET enable_seqscan = false; }
+step "s1f1" { SELECT c FROM sto1 where c = 1000; }
+step "s1f2" { SELECT c FROM sto1 where c = 1001; }
+teardown { ROLLBACK; }
+
+session "s2"
+step "s2sleep" { SELECT setting, pg_sleep(6) FROM pg_settings WHERE name = 'old_snapshot_threshold'; }
+step "s2u" { UPDATE sto1 SET c = 1001 WHERE c = 1000; }
+
+permutation "noseq" "s1f1" "s2sleep" "s2u" "s1f2"