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

Commit fbfa566

Browse files
committed
Fix lockmode initialization for custom relation options
The code was enforcing AccessExclusiveLock for all custom relation options, which is incorrect as the APIs allow a custom lock level to be set. While on it, fix a couple of inconsistencies in the tests and the README of dummy_index_am. Oversights in commit 773df88. Discussion: https://postgr.es/m/20190925234152.GA2115@paquier.xyz
1 parent 8190164 commit fbfa566

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

src/backend/access/common/reloptions.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -700,13 +700,6 @@ allocate_reloption(bits32 kinds, int type, const char *name, const char *desc,
700700
newoption->type = type;
701701
newoption->lockmode = lockmode;
702702

703-
/*
704-
* Set the default lock mode for this option. There is no actual way
705-
* for a module to enforce it when declaring a custom relation option,
706-
* so just use the highest level, which is safe for all cases.
707-
*/
708-
newoption->lockmode = AccessExclusiveLock;
709-
710703
MemoryContextSwitchTo(oldcxt);
711704

712705
return newoption;

src/test/modules/dummy_index_am/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ access method, whose code is kept a maximum simple.
66

77
This includes tests for all relation option types:
88
- boolean
9+
- enum
910
- integer
1011
- real
1112
- strings (with and without NULL as default)

src/test/modules/dummy_index_am/expected/reloptions.out

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ CREATE INDEX dummy_test_idx ON dummy_test_tab
2020
option_bool = false,
2121
option_int = 5,
2222
option_real = 3.1,
23+
option_enum = 'two',
2324
option_string_val = NULL,
2425
option_string_null = 'val');
2526
NOTICE: new option value for string parameter null
@@ -32,9 +33,10 @@ SELECT unnest(reloptions) FROM pg_class WHERE relname = 'dummy_test_idx';
3233
option_bool=false
3334
option_int=5
3435
option_real=3.1
36+
option_enum=two
3537
option_string_val=null
3638
option_string_null=val
37-
(5 rows)
39+
(6 rows)
3840

3941
-- ALTER INDEX .. SET
4042
ALTER INDEX dummy_test_idx SET (option_int = 10);

src/test/modules/dummy_index_am/sql/reloptions.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ CREATE INDEX dummy_test_idx ON dummy_test_tab
2020
option_bool = false,
2121
option_int = 5,
2222
option_real = 3.1,
23+
option_enum = 'two',
2324
option_string_val = NULL,
2425
option_string_null = 'val');
2526
-- Silence again validation checks for strings until the end of the test.

0 commit comments

Comments
 (0)