Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb801e12

Browse files
committed
Improve regression test coverage for hash indexes.
On my system, this improves coverage for src/backend/access/hash from61.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
1 parent90d3da1 commitb801e12

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

‎src/test/regress/expected/hash_index.out

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,39 @@ SELECT h.seqno AS f20000
196196
-- WHERE x = 90;
197197
-- SELECT count(*) AS i988 FROM hash_ovfl_heap
198198
-- WHERE x = 1000;
199+
--
200+
-- Cause some overflow insert and splits.
201+
--
202+
CREATE TABLE hash_split_heap (keycol INT);
203+
CREATE INDEX hash_split_index on hash_split_heap USING HASH (keycol);
204+
WARNING: hash indexes are not WAL-logged and their use is discouraged
205+
INSERT INTO hash_split_heap SELECT 1 FROM generate_series(1, 70000) a;
206+
VACUUM FULL hash_split_heap;
207+
-- Let's do a backward scan.
208+
BEGIN;
209+
SET enable_seqscan = OFF;
210+
SET enable_bitmapscan = OFF;
211+
DECLARE c CURSOR FOR SELECT * from hash_split_heap WHERE keycol = 1;
212+
MOVE FORWARD ALL FROM c;
213+
MOVE BACKWARD 10000 FROM c;
214+
MOVE BACKWARD ALL FROM c;
215+
CLOSE c;
216+
END;
217+
-- DELETE, INSERT, REBUILD INDEX.
218+
DELETE FROM hash_split_heap WHERE keycol = 1;
219+
INSERT INTO hash_split_heap SELECT a/2 FROM generate_series(1, 50000) a;
220+
VACUUM hash_split_heap;
221+
REINDEX INDEX hash_split_index;
222+
-- Clean up.
223+
DROP TABLE hash_split_heap;
224+
-- Index on temp table.
225+
CREATE TEMP TABLE hash_temp_heap (x int, y int);
226+
INSERT INTO hash_temp_heap VALUES (1,1);
227+
CREATE INDEX hash_idx ON hash_temp_heap USING hash (x);
228+
DROP TABLE hash_temp_heap CASCADE;
229+
-- Float4 type.
230+
CREATE TABLE hash_heap_float4 (x float4, y int);
231+
INSERT INTO hash_heap_float4 VALUES (1.1,1);
232+
CREATE INDEX hash_idx ON hash_heap_float4 USING hash (x);
233+
WARNING: hash indexes are not WAL-logged and their use is discouraged
234+
DROP TABLE hash_heap_float4 CASCADE;

‎src/test/regress/sql/hash_index.sql

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,46 @@ SELECT h.seqno AS f20000
151151

152152
-- SELECT count(*) AS i988 FROM hash_ovfl_heap
153153
-- WHERE x = 1000;
154+
155+
--
156+
-- Cause some overflow insert and splits.
157+
--
158+
CREATETABLEhash_split_heap (keycolINT);
159+
CREATEINDEXhash_split_indexon hash_split_heap USING HASH (keycol);
160+
INSERT INTO hash_split_heapSELECT1FROM generate_series(1,70000) a;
161+
162+
VACUUM FULL hash_split_heap;
163+
164+
-- Let's do a backward scan.
165+
BEGIN;
166+
SET enable_seqscan= OFF;
167+
SET enable_bitmapscan= OFF;
168+
169+
DECLARE c CURSOR FORSELECT*from hash_split_heapWHERE keycol=1;
170+
MOVE FORWARD ALLFROM c;
171+
MOVE BACKWARD10000FROM c;
172+
MOVE BACKWARD ALLFROM c;
173+
CLOSE c;
174+
END;
175+
176+
-- DELETE, INSERT, REBUILD INDEX.
177+
DELETEFROM hash_split_heapWHERE keycol=1;
178+
INSERT INTO hash_split_heapSELECT a/2FROM generate_series(1,50000) a;
179+
180+
VACUUM hash_split_heap;
181+
REINDEX INDEX hash_split_index;
182+
183+
-- Clean up.
184+
DROPTABLE hash_split_heap;
185+
186+
-- Index on temp table.
187+
CREATE TEMP TABLE hash_temp_heap (xint, yint);
188+
INSERT INTO hash_temp_heapVALUES (1,1);
189+
CREATEINDEXhash_idxON hash_temp_heap USING hash (x);
190+
DROPTABLE hash_temp_heap CASCADE;
191+
192+
-- Float4 type.
193+
CREATETABLEhash_heap_float4 (x float4, yint);
194+
INSERT INTO hash_heap_float4VALUES (1.1,1);
195+
CREATEINDEXhash_idxON hash_heap_float4 USING hash (x);
196+
DROPTABLE hash_heap_float4 CASCADE;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp