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.
This commit is contained in:
Tom Lane 2016-07-16 16:25:43 -04:00
parent 9563d5b5e4
commit 606ccc5e7e
2 changed files with 20 additions and 0 deletions

View File

@ -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;
--

View File

@ -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;