mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Improve regression test coverage for hash indexes.
On my system, this improves coverage for src/backend/access/hash from 61.3% of lines to 88.2% of lines, and from 83.5% of functions to 97.5% of functions, which is pretty good for 36 lines of tests. Mithun Cy, reviewing by Amit Kapila and Álvaro Herrera
This commit is contained in:
parent
90d3da11c9
commit
b801e12008
@ -196,3 +196,39 @@ SELECT h.seqno AS f20000
|
|||||||
-- WHERE x = 90;
|
-- WHERE x = 90;
|
||||||
-- SELECT count(*) AS i988 FROM hash_ovfl_heap
|
-- SELECT count(*) AS i988 FROM hash_ovfl_heap
|
||||||
-- WHERE x = 1000;
|
-- WHERE x = 1000;
|
||||||
|
--
|
||||||
|
-- Cause some overflow insert and splits.
|
||||||
|
--
|
||||||
|
CREATE TABLE hash_split_heap (keycol INT);
|
||||||
|
CREATE INDEX hash_split_index on hash_split_heap USING HASH (keycol);
|
||||||
|
WARNING: hash indexes are not WAL-logged and their use is discouraged
|
||||||
|
INSERT INTO hash_split_heap SELECT 1 FROM generate_series(1, 70000) a;
|
||||||
|
VACUUM FULL hash_split_heap;
|
||||||
|
-- Let's do a backward scan.
|
||||||
|
BEGIN;
|
||||||
|
SET enable_seqscan = OFF;
|
||||||
|
SET enable_bitmapscan = OFF;
|
||||||
|
DECLARE c CURSOR FOR SELECT * from hash_split_heap WHERE keycol = 1;
|
||||||
|
MOVE FORWARD ALL FROM c;
|
||||||
|
MOVE BACKWARD 10000 FROM c;
|
||||||
|
MOVE BACKWARD ALL FROM c;
|
||||||
|
CLOSE c;
|
||||||
|
END;
|
||||||
|
-- DELETE, INSERT, REBUILD INDEX.
|
||||||
|
DELETE FROM hash_split_heap WHERE keycol = 1;
|
||||||
|
INSERT INTO hash_split_heap SELECT a/2 FROM generate_series(1, 50000) a;
|
||||||
|
VACUUM hash_split_heap;
|
||||||
|
REINDEX INDEX hash_split_index;
|
||||||
|
-- Clean up.
|
||||||
|
DROP TABLE hash_split_heap;
|
||||||
|
-- Index on temp table.
|
||||||
|
CREATE TEMP TABLE hash_temp_heap (x int, y int);
|
||||||
|
INSERT INTO hash_temp_heap VALUES (1,1);
|
||||||
|
CREATE INDEX hash_idx ON hash_temp_heap USING hash (x);
|
||||||
|
DROP TABLE hash_temp_heap CASCADE;
|
||||||
|
-- Float4 type.
|
||||||
|
CREATE TABLE hash_heap_float4 (x float4, y int);
|
||||||
|
INSERT INTO hash_heap_float4 VALUES (1.1,1);
|
||||||
|
CREATE INDEX hash_idx ON hash_heap_float4 USING hash (x);
|
||||||
|
WARNING: hash indexes are not WAL-logged and their use is discouraged
|
||||||
|
DROP TABLE hash_heap_float4 CASCADE;
|
||||||
|
@ -151,3 +151,46 @@ SELECT h.seqno AS f20000
|
|||||||
|
|
||||||
-- SELECT count(*) AS i988 FROM hash_ovfl_heap
|
-- SELECT count(*) AS i988 FROM hash_ovfl_heap
|
||||||
-- WHERE x = 1000;
|
-- WHERE x = 1000;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Cause some overflow insert and splits.
|
||||||
|
--
|
||||||
|
CREATE TABLE hash_split_heap (keycol INT);
|
||||||
|
CREATE INDEX hash_split_index on hash_split_heap USING HASH (keycol);
|
||||||
|
INSERT INTO hash_split_heap SELECT 1 FROM generate_series(1, 70000) a;
|
||||||
|
|
||||||
|
VACUUM FULL hash_split_heap;
|
||||||
|
|
||||||
|
-- Let's do a backward scan.
|
||||||
|
BEGIN;
|
||||||
|
SET enable_seqscan = OFF;
|
||||||
|
SET enable_bitmapscan = OFF;
|
||||||
|
|
||||||
|
DECLARE c CURSOR FOR SELECT * from hash_split_heap WHERE keycol = 1;
|
||||||
|
MOVE FORWARD ALL FROM c;
|
||||||
|
MOVE BACKWARD 10000 FROM c;
|
||||||
|
MOVE BACKWARD ALL FROM c;
|
||||||
|
CLOSE c;
|
||||||
|
END;
|
||||||
|
|
||||||
|
-- DELETE, INSERT, REBUILD INDEX.
|
||||||
|
DELETE FROM hash_split_heap WHERE keycol = 1;
|
||||||
|
INSERT INTO hash_split_heap SELECT a/2 FROM generate_series(1, 50000) a;
|
||||||
|
|
||||||
|
VACUUM hash_split_heap;
|
||||||
|
REINDEX INDEX hash_split_index;
|
||||||
|
|
||||||
|
-- Clean up.
|
||||||
|
DROP TABLE hash_split_heap;
|
||||||
|
|
||||||
|
-- Index on temp table.
|
||||||
|
CREATE TEMP TABLE hash_temp_heap (x int, y int);
|
||||||
|
INSERT INTO hash_temp_heap VALUES (1,1);
|
||||||
|
CREATE INDEX hash_idx ON hash_temp_heap USING hash (x);
|
||||||
|
DROP TABLE hash_temp_heap CASCADE;
|
||||||
|
|
||||||
|
-- Float4 type.
|
||||||
|
CREATE TABLE hash_heap_float4 (x float4, y int);
|
||||||
|
INSERT INTO hash_heap_float4 VALUES (1.1,1);
|
||||||
|
CREATE INDEX hash_idx ON hash_heap_float4 USING hash (x);
|
||||||
|
DROP TABLE hash_heap_float4 CASCADE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user