Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9043ef3

Browse files
committed
Don't warn about creating temporary or unlogged hash indexes.
Warning people that no WAL-logging will be done doesn't make sense in this case. Michael Paquier
1 parent 91118f1 commit 9043ef3

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/backend/commands/indexcmds.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ DefineIndex(Oid relationId,
490490
accessMethodId = HeapTupleGetOid(tuple);
491491
accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
492492

493-
if (strcmp(accessMethodName, "hash") == 0)
493+
if (strcmp(accessMethodName, "hash") == 0 &&
494+
RelationNeedsWAL(rel))
494495
ereport(WARNING,
495496
(errmsg("hash indexes are not WAL-logged and their use is discouraged")));
496497

src/test/regress/expected/create_index.out

+3
Original file line numberDiff line numberDiff line change
@@ -2342,6 +2342,9 @@ CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops);
23422342
WARNING: hash indexes are not WAL-logged and their use is discouraged
23432343
CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops);
23442344
WARNING: hash indexes are not WAL-logged and their use is discouraged
2345+
CREATE UNLOGGED TABLE unlogged_hash_table (id int4);
2346+
CREATE INDEX unlogged_hash_index ON unlogged_hash_table USING hash (id int4_ops);
2347+
DROP TABLE unlogged_hash_table;
23452348
-- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops);
23462349
--
23472350
-- Test functional index

src/test/regress/sql/create_index.sql

+4
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,10 @@ CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops);
684684

685685
CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops);
686686

687+
CREATE UNLOGGED TABLE unlogged_hash_table (id int4);
688+
CREATE INDEX unlogged_hash_index ON unlogged_hash_table USING hash (id int4_ops);
689+
DROP TABLE unlogged_hash_table;
690+
687691
-- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops);
688692

689693

0 commit comments

Comments
 (0)