On Tue, Jun 23, 2015 at 9:06 AM, Jim Nasby <[email protected]> wrote:
> On 6/12/15 5:00 PM, Thom Brown wrote:
>>
>> On 18 October 2014 at 15:36, Bruce Momjian <[email protected]> wrote:
>>>
>>> On Fri, Oct 17, 2014 at 02:36:55PM -0400, Bruce Momjian wrote:
>>>>
>>>> On Fri, Oct 17, 2014 at 12:56:52PM -0400, Tom Lane wrote:
>>>>>
>>>>> David G Johnston <[email protected]> writes:
>>>>>>
>>>>>> The question is whether we explain the implications of not being
>>>>>> WAL-logged
>>>>>> in an error message or simply state the fact and let the documentation
>>>>>> explain the hazards - basically just output:
>>>>>> "hash indexes are not WAL-logged and their use is discouraged"
>>>>>
>>>>>
>>>>> +1.  The warning message is not the place to be trying to explain all
>>>>> the
>>>>> details.
>>>>
>>>>
>>>> OK, updated patch attached.
>>>
>>>
>>> Patch applied.
>>
>>
>> I only just noticed this item when I read the release notes.  Should
>> we bother warning when used on an unlogged table?
>
>
> Not really; but I think the bigger question at this point is if we want to
> change it this late in the game.

Changing it even during beta looks acceptable to me. I think that it
is mainly a matter to have a patch (here is one), and someone to push
it as everybody here seem to agree that for UNLOGGED tables this
warning has little sense.
-- 
Michael
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 7340a1f..49ad9d6 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -490,7 +490,8 @@ DefineIndex(Oid relationId,
 	accessMethodId = HeapTupleGetOid(tuple);
 	accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
 
-	if (strcmp(accessMethodName, "hash") == 0)
+	if (strcmp(accessMethodName, "hash") == 0 &&
+		rel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
 		ereport(WARNING,
 				(errmsg("hash indexes are not WAL-logged and their use is discouraged")));
 
diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out
index 5c2e67d..b72e65d 100644
--- a/src/test/regress/expected/create_index.out
+++ b/src/test/regress/expected/create_index.out
@@ -2342,6 +2342,9 @@ CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops);
 WARNING:  hash indexes are not WAL-logged and their use is discouraged
 CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops);
 WARNING:  hash indexes are not WAL-logged and their use is discouraged
+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 functional index
diff --git a/src/test/regress/sql/create_index.sql b/src/test/regress/sql/create_index.sql
index 67dd2f0..ff86953 100644
--- a/src/test/regress/sql/create_index.sql
+++ b/src/test/regress/sql/create_index.sql
@@ -684,6 +684,10 @@ CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops);
 
 CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops);
 
+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);
 
 
-- 
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to