Commit 84aa8ba1 authored by Bruce Momjian's avatar Bruce Momjian

Issue a warning during the creation of hash indexes

parent 5b262788
...@@ -489,6 +489,10 @@ DefineIndex(Oid relationId, ...@@ -489,6 +489,10 @@ DefineIndex(Oid relationId,
accessMethodId = HeapTupleGetOid(tuple); accessMethodId = HeapTupleGetOid(tuple);
accessMethodForm = (Form_pg_am) GETSTRUCT(tuple); accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
if (strcmp(accessMethodName, "hash") == 0)
ereport(WARNING,
(errmsg("hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys")));
if (stmt->unique && !accessMethodForm->amcanunique) if (stmt->unique && !accessMethodForm->amcanunique)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
......
...@@ -2238,9 +2238,13 @@ DROP TABLE array_gin_test; ...@@ -2238,9 +2238,13 @@ DROP TABLE array_gin_test;
-- HASH -- HASH
-- --
CREATE INDEX hash_i4_index ON hash_i4_heap USING hash (random int4_ops); CREATE INDEX hash_i4_index ON hash_i4_heap USING hash (random int4_ops);
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
CREATE INDEX hash_name_index ON hash_name_heap USING hash (random name_ops); CREATE INDEX hash_name_index ON hash_name_heap USING hash (random name_ops);
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops); CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops);
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops); CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops);
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
-- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops); -- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops);
-- --
-- Test functional index -- Test functional index
......
...@@ -383,6 +383,7 @@ DROP INDEX enumtest_btree; ...@@ -383,6 +383,7 @@ DROP INDEX enumtest_btree;
-- Hash index / opclass with the = operator -- Hash index / opclass with the = operator
-- --
CREATE INDEX enumtest_hash ON enumtest USING hash (col); CREATE INDEX enumtest_hash ON enumtest USING hash (col);
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
SELECT * FROM enumtest WHERE col = 'orange'; SELECT * FROM enumtest WHERE col = 'orange';
col col
-------- --------
......
...@@ -39,6 +39,7 @@ SELECT * FROM macaddr_data; ...@@ -39,6 +39,7 @@ SELECT * FROM macaddr_data;
CREATE INDEX macaddr_data_btree ON macaddr_data USING btree (b); CREATE INDEX macaddr_data_btree ON macaddr_data USING btree (b);
CREATE INDEX macaddr_data_hash ON macaddr_data USING hash (b); CREATE INDEX macaddr_data_hash ON macaddr_data USING hash (b);
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
SELECT a, b, trunc(b) FROM macaddr_data ORDER BY 2, 1; SELECT a, b, trunc(b) FROM macaddr_data ORDER BY 2, 1;
a | b | trunc a | b | trunc
----+-------------------+------------------- ----+-------------------+-------------------
......
...@@ -11,6 +11,7 @@ CREATE INDEX test_replica_identity_keyab ON test_replica_identity (keya, keyb); ...@@ -11,6 +11,7 @@ CREATE INDEX test_replica_identity_keyab ON test_replica_identity (keya, keyb);
CREATE UNIQUE INDEX test_replica_identity_keyab_key ON test_replica_identity (keya, keyb); CREATE UNIQUE INDEX test_replica_identity_keyab_key ON test_replica_identity (keya, keyb);
CREATE UNIQUE INDEX test_replica_identity_nonkey ON test_replica_identity (keya, nonkey); CREATE UNIQUE INDEX test_replica_identity_nonkey ON test_replica_identity (keya, nonkey);
CREATE INDEX test_replica_identity_hash ON test_replica_identity USING hash (nonkey); CREATE INDEX test_replica_identity_hash ON test_replica_identity USING hash (nonkey);
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
CREATE UNIQUE INDEX test_replica_identity_expr ON test_replica_identity (keya, keyb, (3)); CREATE UNIQUE INDEX test_replica_identity_expr ON test_replica_identity (keya, keyb, (3));
CREATE UNIQUE INDEX test_replica_identity_partial ON test_replica_identity (keya, keyb) WHERE keyb != '3'; CREATE UNIQUE INDEX test_replica_identity_partial ON test_replica_identity (keya, keyb) WHERE keyb != '3';
-- default is 'd'/DEFAULT for user created tables -- default is 'd'/DEFAULT for user created tables
......
...@@ -114,6 +114,7 @@ SELECT COUNT(*) FROM guid1 WHERE guid_field >= '22222222-2222-2222-2222-22222222 ...@@ -114,6 +114,7 @@ SELECT COUNT(*) FROM guid1 WHERE guid_field >= '22222222-2222-2222-2222-22222222
-- btree and hash index creation test -- btree and hash index creation test
CREATE INDEX guid1_btree ON guid1 USING BTREE (guid_field); CREATE INDEX guid1_btree ON guid1 USING BTREE (guid_field);
CREATE INDEX guid1_hash ON guid1 USING HASH (guid_field); CREATE INDEX guid1_hash ON guid1 USING HASH (guid_field);
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
-- unique index test -- unique index test
CREATE UNIQUE INDEX guid1_unique_BTREE ON guid1 USING BTREE (guid_field); CREATE UNIQUE INDEX guid1_unique_BTREE ON guid1 USING BTREE (guid_field);
-- should fail -- should fail
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment