From 12d2cef59da090a28a9a6e6162a8e38cb4a18875 Mon Sep 17 00:00:00 2001 From: "mithun.cy" Date: Thu, 4 Aug 2016 08:12:08 +0530 Subject: 1 diff --git a/src/test/regress/expected/concurrent_hash_index.out b/src/test/regress/expected/concurrent_hash_index.out new file mode 100644 index 0000000..c3b8036 --- /dev/null +++ b/src/test/regress/expected/concurrent_hash_index.out @@ -0,0 +1,79 @@ +-- +-- Cause some overflow insert and splits. +-- +CREATE TABLE con_hash_index_table (keycol INT); +CREATE INDEX con_hash_index on con_hash_index_table USING HASH (keycol); +WARNING: hash indexes are not WAL-logged and their use is discouraged +INSERT INTO con_hash_index_table VALUES (1); +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table LIMIT 32000; +VACUUM FULL con_hash_index_table; +-- +-- Lets do a backward scan. +-- +BEGIN; +SET enable_seqscan = OFF; +SET enable_bitmapscan = OFF; +CREATE FUNCTION declares_cursor(int) + RETURNS void + AS 'DECLARE c CURSOR FOR SELECT * from con_hash_index_table WHERE keycol = $1;' +LANGUAGE SQL; +SELECT declares_cursor(1); + declares_cursor +----------------- + +(1 row) + +MOVE FORWARD ALL FROM c; +MOVE BACKWARD 10000 FROM c; +MOVE BACKWARD ALL FROM c; +ROLLBACK; +-- +-- DELETE, INSERT, REBUILD INDEX. +-- +DELETE FROM con_hash_index_table WHERE keycol = 1; +INSERT INTO con_hash_index_table VALUES (1), (2); +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +VACUUM con_hash_index_table; +REINDEX INDEX con_hash_index; +-- +-- Clean Up. +-- +DROP TABLE con_hash_index_table; +-- +-- INDEX ON TEMP TABLE. +-- +CREATE TEMP TABLE hash_ovfl_temp_heap (x int, y int); +INSERT INTO hash_ovfl_temp_heap VALUES (1,1); +CREATE INDEX hash_idx ON hash_ovfl_temp_heap USING hash (x); +DROP TABLE hash_ovfl_temp_heap CASCADE; +-- +-- Float4 type. +-- +CREATE TABLE hash_ovfl_heap_float4 (x float4, y int); +INSERT INTO hash_ovfl_heap_float4 VALUES (1.1,1); +CREATE INDEX hash_idx ON hash_ovfl_heap_float4 USING hash (x); +WARNING: hash indexes are not WAL-logged and their use is discouraged +DROP TABLE hash_ovfl_heap_float4 CASCADE; diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule index 4ebad04..b7cf14a 100644 --- a/src/test/regress/parallel_schedule +++ b/src/test/regress/parallel_schedule @@ -79,7 +79,7 @@ ignore: random # ---------- # Another group of parallel tests # ---------- -test: select_into select_distinct select_distinct_on select_implicit select_having subselect union case join aggregates transactions random portals arrays btree_index hash_index update namespace prepared_xacts delete +test: select_into select_distinct select_distinct_on select_implicit select_having subselect union case join aggregates transactions random portals arrays btree_index hash_index concurrent_hash_index update namespace prepared_xacts delete # ---------- # Another group of parallel tests diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule index 5c7038d..f491423 100644 --- a/src/test/regress/serial_schedule +++ b/src/test/regress/serial_schedule @@ -96,6 +96,7 @@ test: portals test: arrays test: btree_index test: hash_index +test: concurrent_hash_index test: update test: delete test: namespace diff --git a/src/test/regress/sql/concurrent_hash_index.sql b/src/test/regress/sql/concurrent_hash_index.sql new file mode 100644 index 0000000..8f930d5 --- /dev/null +++ b/src/test/regress/sql/concurrent_hash_index.sql @@ -0,0 +1,80 @@ +-- +-- Cause some overflow insert and splits. +-- +CREATE TABLE con_hash_index_table (keycol INT); +CREATE INDEX con_hash_index on con_hash_index_table USING HASH (keycol); +INSERT INTO con_hash_index_table VALUES (1); +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table LIMIT 32000; + +VACUUM FULL con_hash_index_table; + +-- +-- Lets do a backward scan. +-- +BEGIN; +SET enable_seqscan = OFF; +SET enable_bitmapscan = OFF; +CREATE FUNCTION declares_cursor(int) + RETURNS void + AS 'DECLARE c CURSOR FOR SELECT * from con_hash_index_table WHERE keycol = $1;' +LANGUAGE SQL; + +SELECT declares_cursor(1); +MOVE FORWARD ALL FROM c; +MOVE BACKWARD 10000 FROM c; +MOVE BACKWARD ALL FROM c; +ROLLBACK; + +-- +-- DELETE, INSERT, REBUILD INDEX. +-- +DELETE FROM con_hash_index_table WHERE keycol = 1; +INSERT INTO con_hash_index_table VALUES (1), (2); +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; +INSERT INTO con_hash_index_table SELECT * from con_hash_index_table; + +VACUUM con_hash_index_table; +REINDEX INDEX con_hash_index; + +-- +-- Clean Up. +-- +DROP TABLE con_hash_index_table; + +-- +-- INDEX ON TEMP TABLE. +-- +CREATE TEMP TABLE hash_ovfl_temp_heap (x int, y int); +INSERT INTO hash_ovfl_temp_heap VALUES (1,1); +CREATE INDEX hash_idx ON hash_ovfl_temp_heap USING hash (x); +DROP TABLE hash_ovfl_temp_heap CASCADE; + +-- +-- Float4 type. +-- +CREATE TABLE hash_ovfl_heap_float4 (x float4, y int); +INSERT INTO hash_ovfl_heap_float4 VALUES (1.1,1); +CREATE INDEX hash_idx ON hash_ovfl_heap_float4 USING hash (x); +DROP TABLE hash_ovfl_heap_float4 CASCADE;