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

Commit69f9410

Browse files
committed
Allow definition of lock mode for custom reloptions
Relation options can define a lock mode other than AccessExclusiveModesince47167b7, but modules defining custom relation options did notreally have a way to enforce that. Correct that by extending thecurrent API set so as modules can define a custom lock mode.Author: Michael PaquierReviewed-by: Kuntal GhoshDiscussion:https://postgr.es/m/20190920013831.GD1844@paquier.xyz
1 parent736b84e commit69f9410

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

‎contrib/bloom/blutils.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ _PG_init(void)
6060
/* Option for length of signature */
6161
add_int_reloption(bl_relopt_kind,"length",
6262
"Length of signature in bits",
63-
DEFAULT_BLOOM_LENGTH,1,MAX_BLOOM_LENGTH);
63+
DEFAULT_BLOOM_LENGTH,1,MAX_BLOOM_LENGTH,
64+
AccessExclusiveLock);
6465
bl_relopt_tab[0].optname="length";
6566
bl_relopt_tab[0].opttype=RELOPT_TYPE_INT;
6667
bl_relopt_tab[0].offset= offsetof(BloomOptions,bloomLength);
@@ -71,7 +72,8 @@ _PG_init(void)
7172
snprintf(buf,sizeof(buf),"col%d",i+1);
7273
add_int_reloption(bl_relopt_kind,buf,
7374
"Number of bits generated for each index column",
74-
DEFAULT_BLOOM_BITS,1,MAX_BLOOM_BITS);
75+
DEFAULT_BLOOM_BITS,1,MAX_BLOOM_BITS,
76+
AccessExclusiveLock);
7577
bl_relopt_tab[i+1].optname=MemoryContextStrdup(TopMemoryContext,
7678
buf);
7779
bl_relopt_tab[i+1].opttype=RELOPT_TYPE_INT;

‎src/backend/access/common/reloptions.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,8 @@ add_reloption(relopt_gen *newoption)
621621
*(for types other than string)
622622
*/
623623
staticrelopt_gen*
624-
allocate_reloption(bits32kinds,inttype,constchar*name,constchar*desc)
624+
allocate_reloption(bits32kinds,inttype,constchar*name,constchar*desc,
625+
LOCKMODElockmode)
625626
{
626627
MemoryContextoldcxt;
627628
size_tsize;
@@ -658,13 +659,7 @@ allocate_reloption(bits32 kinds, int type, const char *name, const char *desc)
658659
newoption->kinds=kinds;
659660
newoption->namelen=strlen(name);
660661
newoption->type=type;
661-
662-
/*
663-
* Set the default lock mode for this option. There is no actual way
664-
* for a module to enforce it when declaring a custom relation option,
665-
* so just use the highest level, which is safe for all cases.
666-
*/
667-
newoption->lockmode=AccessExclusiveLock;
662+
newoption->lockmode=lockmode;
668663

669664
MemoryContextSwitchTo(oldcxt);
670665

@@ -676,12 +671,13 @@ allocate_reloption(bits32 kinds, int type, const char *name, const char *desc)
676671
*Add a new boolean reloption
677672
*/
678673
void
679-
add_bool_reloption(bits32kinds,constchar*name,constchar*desc,booldefault_val)
674+
add_bool_reloption(bits32kinds,constchar*name,constchar*desc,
675+
booldefault_val,LOCKMODElockmode)
680676
{
681677
relopt_bool*newoption;
682678

683679
newoption= (relopt_bool*)allocate_reloption(kinds,RELOPT_TYPE_BOOL,
684-
name,desc);
680+
name,desc,lockmode);
685681
newoption->default_val=default_val;
686682

687683
add_reloption((relopt_gen*)newoption);
@@ -693,12 +689,12 @@ add_bool_reloption(bits32 kinds, const char *name, const char *desc, bool defaul
693689
*/
694690
void
695691
add_int_reloption(bits32kinds,constchar*name,constchar*desc,intdefault_val,
696-
intmin_val,intmax_val)
692+
intmin_val,intmax_val,LOCKMODElockmode)
697693
{
698694
relopt_int*newoption;
699695

700696
newoption= (relopt_int*)allocate_reloption(kinds,RELOPT_TYPE_INT,
701-
name,desc);
697+
name,desc,lockmode);
702698
newoption->default_val=default_val;
703699
newoption->min=min_val;
704700
newoption->max=max_val;
@@ -712,12 +708,12 @@ add_int_reloption(bits32 kinds, const char *name, const char *desc, int default_
712708
*/
713709
void
714710
add_real_reloption(bits32kinds,constchar*name,constchar*desc,doubledefault_val,
715-
doublemin_val,doublemax_val)
711+
doublemin_val,doublemax_val,LOCKMODElockmode)
716712
{
717713
relopt_real*newoption;
718714

719715
newoption= (relopt_real*)allocate_reloption(kinds,RELOPT_TYPE_REAL,
720-
name,desc);
716+
name,desc,lockmode);
721717
newoption->default_val=default_val;
722718
newoption->min=min_val;
723719
newoption->max=max_val;
@@ -736,7 +732,7 @@ add_real_reloption(bits32 kinds, const char *name, const char *desc, double defa
736732
*/
737733
void
738734
add_string_reloption(bits32kinds,constchar*name,constchar*desc,constchar*default_val,
739-
validate_string_reloptvalidator)
735+
validate_string_reloptvalidator,LOCKMODElockmode)
740736
{
741737
relopt_string*newoption;
742738

@@ -745,7 +741,7 @@ add_string_reloption(bits32 kinds, const char *name, const char *desc, const cha
745741
(validator) (default_val);
746742

747743
newoption= (relopt_string*)allocate_reloption(kinds,RELOPT_TYPE_STRING,
748-
name,desc);
744+
name,desc,lockmode);
749745
newoption->validate_cb=validator;
750746
if (default_val)
751747
{

‎src/include/access/reloptions.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,16 @@ typedef struct
247247

248248
externrelopt_kindadd_reloption_kind(void);
249249
externvoidadd_bool_reloption(bits32kinds,constchar*name,constchar*desc,
250-
booldefault_val);
250+
booldefault_val,LOCKMODElockmode);
251251
externvoidadd_int_reloption(bits32kinds,constchar*name,constchar*desc,
252-
intdefault_val,intmin_val,intmax_val);
252+
intdefault_val,intmin_val,intmax_val,
253+
LOCKMODElockmode);
253254
externvoidadd_real_reloption(bits32kinds,constchar*name,constchar*desc,
254-
doubledefault_val,doublemin_val,doublemax_val);
255+
doubledefault_val,doublemin_val,doublemax_val,
256+
LOCKMODElockmode);
255257
externvoidadd_string_reloption(bits32kinds,constchar*name,constchar*desc,
256-
constchar*default_val,validate_string_reloptvalidator);
258+
constchar*default_val,validate_string_reloptvalidator,
259+
LOCKMODElockmode);
257260

258261
externDatumtransformRelOptions(DatumoldOptions,List*defList,
259262
constchar*namspace,char*validnsps[],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp