diff options
| author | Tom Lane | 2016-07-16 19:30:15 +0000 |
|---|---|---|
| committer | Tom Lane | 2016-07-16 19:30:15 +0000 |
| commit | 9563d5b5e4c75e676d73a45546bd47b77c2bd739 (patch) | |
| tree | 59b0aacc876ef9710b3f7379d4fee5915f6bfedc /src/test | |
| parent | 278148907a971ec7fa4ffb24248103d8012155d2 (diff) | |
Add regression test case exercising the sorting path for hash index build.
We've broken this code path at least twice in the past, so it's prudent
to have a test case that covers it. To allow exercising the code path
without creating a very large (and slow to run) test case, redefine the
sort threshold to be bounded by maintenance_work_mem as well as the number
of available buffers. While at it, fix an ancient oversight that when
building a temp index, the number of available buffers is not NBuffers but
NLocBuffer. Also, if assertions are enabled, apply a direct test that the
sort actually does return the tuples in the expected order.
Peter Geoghegan
Patch: <CAM3SWZTBAo4hjbBd780+MrOKiKp_TMo1N3A0Rw9_im8gbD7fQA@mail.gmail.com>
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/create_index.out | 7 | ||||
| -rw-r--r-- | src/test/regress/sql/create_index.sql | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out index 97cc49e6235..0be5cf2dbea 100644 --- a/src/test/regress/expected/create_index.out +++ b/src/test/regress/expected/create_index.out @@ -2346,6 +2346,13 @@ CREATE UNLOGGED TABLE unlogged_hash_table (id int4); CREATE INDEX unlogged_hash_index ON unlogged_hash_table USING hash (id int4_ops); DROP TABLE unlogged_hash_table; -- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops); +-- Test hash index build tuplesorting. Force hash tuplesort using low +-- 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); +WARNING: hash indexes are not WAL-logged and their use is discouraged +DROP INDEX hash_tuplesort_idx; +RESET maintenance_work_mem; -- -- Test functional index -- diff --git a/src/test/regress/sql/create_index.sql b/src/test/regress/sql/create_index.sql index 7c582ea810e..7e0bd84ff7f 100644 --- a/src/test/regress/sql/create_index.sql +++ b/src/test/regress/sql/create_index.sql @@ -690,6 +690,13 @@ DROP TABLE unlogged_hash_table; -- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops); +-- Test hash index build tuplesorting. Force hash tuplesort using low +-- 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); +DROP INDEX hash_tuplesort_idx; +RESET maintenance_work_mem; + -- -- Test functional index |
