From 606ccc5e7e97914073f991b077712645e125d531 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 16 Jul 2016 16:25:43 -0400 Subject: [PATCH] Improve test case exercising the sorting path for hash index build. On second thought, we should probably do at least a minimal check that the constructed index is valid, since the big problem with the most recent breakage was not whether the sorting was correct but that the index had incorrect hash codes placed in it. --- src/test/regress/expected/create_index.out | 17 +++++++++++++++++ src/test/regress/sql/create_index.sql | 3 +++ 2 files changed, 20 insertions(+) diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out index 0be5cf2dbe..989ebe523c 100644 --- a/src/test/regress/expected/create_index.out +++ b/src/test/regress/expected/create_index.out @@ -2351,6 +2351,23 @@ DROP TABLE unlogged_hash_table; SET maintenance_work_mem = '1MB'; CREATE INDEX hash_tuplesort_idx ON tenk1 USING hash (stringu1 name_ops) WITH (fillfactor = 10); WARNING: hash indexes are not WAL-logged and their use is discouraged +EXPLAIN (COSTS OFF) +SELECT count(*) FROM tenk1 WHERE stringu1 = 'TVAAAA'; + QUERY PLAN +------------------------------------------------------- + Aggregate + -> Bitmap Heap Scan on tenk1 + Recheck Cond: (stringu1 = 'TVAAAA'::name) + -> Bitmap Index Scan on hash_tuplesort_idx + Index Cond: (stringu1 = 'TVAAAA'::name) +(5 rows) + +SELECT count(*) FROM tenk1 WHERE stringu1 = 'TVAAAA'; + count +------- + 14 +(1 row) + DROP INDEX hash_tuplesort_idx; RESET maintenance_work_mem; -- diff --git a/src/test/regress/sql/create_index.sql b/src/test/regress/sql/create_index.sql index 7e0bd84ff7..b0ba4e62a8 100644 --- a/src/test/regress/sql/create_index.sql +++ b/src/test/regress/sql/create_index.sql @@ -694,6 +694,9 @@ DROP TABLE unlogged_hash_table; -- maintenance_work_mem setting and fillfactor: SET maintenance_work_mem = '1MB'; CREATE INDEX hash_tuplesort_idx ON tenk1 USING hash (stringu1 name_ops) WITH (fillfactor = 10); +EXPLAIN (COSTS OFF) +SELECT count(*) FROM tenk1 WHERE stringu1 = 'TVAAAA'; +SELECT count(*) FROM tenk1 WHERE stringu1 = 'TVAAAA'; DROP INDEX hash_tuplesort_idx; RESET maintenance_work_mem;