Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit84aa8ba

Browse files
committed
Issue a warning during the creation of hash indexes
1 parent5b26278 commit84aa8ba

File tree

6 files changed

+12
-0
lines changed

6 files changed

+12
-0
lines changed

‎src/backend/commands/indexcmds.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,10 @@ DefineIndex(Oid relationId,
489489
accessMethodId=HeapTupleGetOid(tuple);
490490
accessMethodForm= (Form_pg_am)GETSTRUCT(tuple);
491491

492+
if (strcmp(accessMethodName,"hash")==0)
493+
ereport(WARNING,
494+
(errmsg("hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys")));
495+
492496
if (stmt->unique&& !accessMethodForm->amcanunique)
493497
ereport(ERROR,
494498
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),

‎src/test/regress/expected/create_index.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,9 +2238,13 @@ DROP TABLE array_gin_test;
22382238
-- HASH
22392239
--
22402240
CREATE INDEX hash_i4_index ON hash_i4_heap USING hash (random int4_ops);
2241+
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
22412242
CREATE INDEX hash_name_index ON hash_name_heap USING hash (random name_ops);
2243+
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
22422244
CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops);
2245+
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
22432246
CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops);
2247+
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
22442248
-- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops);
22452249
--
22462250
-- Test functional index

‎src/test/regress/expected/enum.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ DROP INDEX enumtest_btree;
383383
-- Hash index / opclass with the = operator
384384
--
385385
CREATE INDEX enumtest_hash ON enumtest USING hash (col);
386+
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
386387
SELECT * FROM enumtest WHERE col = 'orange';
387388
col
388389
--------

‎src/test/regress/expected/macaddr.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ SELECT * FROM macaddr_data;
3939

4040
CREATE INDEX macaddr_data_btree ON macaddr_data USING btree (b);
4141
CREATE INDEX macaddr_data_hash ON macaddr_data USING hash (b);
42+
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
4243
SELECT a, b, trunc(b) FROM macaddr_data ORDER BY 2, 1;
4344
a | b | trunc
4445
----+-------------------+-------------------

‎src/test/regress/expected/replica_identity.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CREATE INDEX test_replica_identity_keyab ON test_replica_identity (keya, keyb);
1111
CREATE UNIQUE INDEX test_replica_identity_keyab_key ON test_replica_identity (keya, keyb);
1212
CREATE UNIQUE INDEX test_replica_identity_nonkey ON test_replica_identity (keya, nonkey);
1313
CREATE INDEX test_replica_identity_hash ON test_replica_identity USING hash (nonkey);
14+
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
1415
CREATE UNIQUE INDEX test_replica_identity_expr ON test_replica_identity (keya, keyb, (3));
1516
CREATE UNIQUE INDEX test_replica_identity_partial ON test_replica_identity (keya, keyb) WHERE keyb != '3';
1617
-- default is 'd'/DEFAULT for user created tables

‎src/test/regress/expected/uuid.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ SELECT COUNT(*) FROM guid1 WHERE guid_field >= '22222222-2222-2222-2222-22222222
114114
-- btree and hash index creation test
115115
CREATE INDEX guid1_btree ON guid1 USING BTREE (guid_field);
116116
CREATE INDEX guid1_hash ON guid1 USING HASH (guid_field);
117+
WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming standbys
117118
-- unique index test
118119
CREATE UNIQUE INDEX guid1_unique_BTREE ON guid1 USING BTREE (guid_field);
119120
-- should fail

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp