git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8190164)
Fix lockmode initialization for custom relation options
2019年9月27日 00:31:20 +0000 (09:31 +0900)
2019年9月27日 00:31:20 +0000 (09:31 +0900)
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


diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index 85627a05a35bf764bb5ffb9744be496a594b660b..b5072c00fe5dc1a10e93c416800aad4dfdec2086 100644 (file)
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -700,13 +700,6 @@ allocate_reloption(bits32 kinds, int type, const char *name, const char *desc,
newoption->type = type;
newoption->lockmode = lockmode;
- /*
- * Set the default lock mode for this option. There is no actual way
- * for a module to enforce it when declaring a custom relation option,
- * so just use the highest level, which is safe for all cases.
- */
- newoption->lockmode = AccessExclusiveLock;
-
MemoryContextSwitchTo(oldcxt);
return newoption;
diff --git a/src/test/modules/dummy_index_am/README b/src/test/modules/dummy_index_am/README
index 7bcdec56f3c35f9b059af65477c7969e19273e33..61510f02faea399eb6348f10b05e3e7e1e9b763a 100644 (file)
--- a/src/test/modules/dummy_index_am/README
+++ b/src/test/modules/dummy_index_am/README
@@ -6,6 +6,7 @@ access method, whose code is kept a maximum simple.
This includes tests for all relation option types:
- boolean
+- enum
- integer
- real
- strings (with and without NULL as default)
diff --git a/src/test/modules/dummy_index_am/expected/reloptions.out b/src/test/modules/dummy_index_am/expected/reloptions.out
index 99742f6fdc42f8fa0dbbeb3356aebd3b3c3a36a6..c873a80bb75d721a821a6eaf45a964e257a7490b 100644 (file)
--- a/src/test/modules/dummy_index_am/expected/reloptions.out
+++ b/src/test/modules/dummy_index_am/expected/reloptions.out
@@ -20,6 +20,7 @@ CREATE INDEX dummy_test_idx ON dummy_test_tab
option_bool = false,
option_int = 5,
option_real = 3.1,
+ option_enum = 'two',
option_string_val = NULL,
option_string_null = 'val');
NOTICE: new option value for string parameter null
@@ -32,9 +33,10 @@ SELECT unnest(reloptions) FROM pg_class WHERE relname = 'dummy_test_idx';
option_bool=false
option_int=5
option_real=3.1
+ option_enum=two
option_string_val=null
option_string_null=val
-(5 rows)
+(6 rows)
-- ALTER INDEX .. SET
ALTER INDEX dummy_test_idx SET (option_int = 10);
diff --git a/src/test/modules/dummy_index_am/sql/reloptions.sql b/src/test/modules/dummy_index_am/sql/reloptions.sql
index 0172cf094e6425db33546f10e264ba3843ea4464..6749d763e6aa4e43573a8e361029788753f6c97e 100644 (file)
--- a/src/test/modules/dummy_index_am/sql/reloptions.sql
+++ b/src/test/modules/dummy_index_am/sql/reloptions.sql
@@ -20,6 +20,7 @@ CREATE INDEX dummy_test_idx ON dummy_test_tab
option_bool = false,
option_int = 5,
option_real = 3.1,
+ option_enum = 'two',
option_string_val = NULL,
option_string_null = 'val');
-- Silence again validation checks for strings until the end of the test.
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /