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

Commitf8c10f6

Browse files
committed
Turn transaction_isolation into GUC enum
It was previously a string setting that was converted into an enum bycustom code, but using the GUC enum facility seems much simpler anddoesn't change any functionality, except that set transaction_isolation='default';no longer works, but that was never documented and doesn't work withany other transaction characteristics. (Note that this is not thesame as RESET or SET TO DEFAULT, which still work.)Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>Discussion:https://www.postgresql.org/message-id/457db615-e84c-4838-310e-43841eb806e5@iki.fi
1 parentb6b297d commitf8c10f6

File tree

3 files changed

+15
-71
lines changed

3 files changed

+15
-71
lines changed

‎src/backend/commands/variable.c

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -522,32 +522,9 @@ check_transaction_read_only(bool *newval, void **extra, GucSource source)
522522
* As in check_transaction_read_only, allow it if not inside a transaction.
523523
*/
524524
bool
525-
check_XactIsoLevel(char**newval,void**extra,GucSourcesource)
525+
check_XactIsoLevel(int*newval,void**extra,GucSourcesource)
526526
{
527-
intnewXactIsoLevel;
528-
529-
if (strcmp(*newval,"serializable")==0)
530-
{
531-
newXactIsoLevel=XACT_SERIALIZABLE;
532-
}
533-
elseif (strcmp(*newval,"repeatable read")==0)
534-
{
535-
newXactIsoLevel=XACT_REPEATABLE_READ;
536-
}
537-
elseif (strcmp(*newval,"read committed")==0)
538-
{
539-
newXactIsoLevel=XACT_READ_COMMITTED;
540-
}
541-
elseif (strcmp(*newval,"read uncommitted")==0)
542-
{
543-
newXactIsoLevel=XACT_READ_UNCOMMITTED;
544-
}
545-
elseif (strcmp(*newval,"default")==0)
546-
{
547-
newXactIsoLevel=DefaultXactIsoLevel;
548-
}
549-
else
550-
return false;
527+
intnewXactIsoLevel=*newval;
551528

552529
if (newXactIsoLevel!=XactIsoLevel&&IsTransactionState())
553530
{
@@ -574,39 +551,9 @@ check_XactIsoLevel(char **newval, void **extra, GucSource source)
574551
}
575552
}
576553

577-
*extra=malloc(sizeof(int));
578-
if (!*extra)
579-
return false;
580-
*((int*)*extra)=newXactIsoLevel;
581-
582554
return true;
583555
}
584556

585-
void
586-
assign_XactIsoLevel(constchar*newval,void*extra)
587-
{
588-
XactIsoLevel=*((int*)extra);
589-
}
590-
591-
constchar*
592-
show_XactIsoLevel(void)
593-
{
594-
/* We need this because we don't want to show "default". */
595-
switch (XactIsoLevel)
596-
{
597-
caseXACT_READ_UNCOMMITTED:
598-
return"read uncommitted";
599-
caseXACT_READ_COMMITTED:
600-
return"read committed";
601-
caseXACT_REPEATABLE_READ:
602-
return"repeatable read";
603-
caseXACT_SERIALIZABLE:
604-
return"serializable";
605-
default:
606-
return"bogus";
607-
}
608-
}
609-
610557
/*
611558
* SET TRANSACTION [NOT] DEFERRABLE
612559
*/

‎src/backend/utils/misc/guc.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ static intserver_version_num;
515515
staticchar*timezone_string;
516516
staticchar*log_timezone_string;
517517
staticchar*timezone_abbreviations_string;
518-
staticchar*XactIsoLevel_string;
519518
staticchar*data_directory;
520519
staticchar*session_authorization_string;
521520
staticintmax_function_args;
@@ -3618,17 +3617,6 @@ static struct config_string ConfigureNamesString[] =
36183617
check_timezone_abbreviations,assign_timezone_abbreviations,NULL
36193618
},
36203619

3621-
{
3622-
{"transaction_isolation",PGC_USERSET,CLIENT_CONN_STATEMENT,
3623-
gettext_noop("Sets the current transaction's isolation level."),
3624-
NULL,
3625-
GUC_NO_RESET_ALL |GUC_NOT_IN_SAMPLE |GUC_DISALLOW_IN_FILE
3626-
},
3627-
&XactIsoLevel_string,
3628-
"default",
3629-
check_XactIsoLevel,assign_XactIsoLevel,show_XactIsoLevel
3630-
},
3631-
36323620
{
36333621
{"unix_socket_group",PGC_POSTMASTER,CONN_AUTH_SETTINGS,
36343622
gettext_noop("Sets the owning group of the Unix-domain socket."),
@@ -3968,6 +3956,17 @@ static struct config_enum ConfigureNamesEnum[] =
39683956
NULL,NULL,NULL
39693957
},
39703958

3959+
{
3960+
{"transaction_isolation",PGC_USERSET,CLIENT_CONN_STATEMENT,
3961+
gettext_noop("Sets the current transaction's isolation level."),
3962+
NULL,
3963+
GUC_NO_RESET_ALL |GUC_NOT_IN_SAMPLE |GUC_DISALLOW_IN_FILE
3964+
},
3965+
&XactIsoLevel,
3966+
XACT_READ_COMMITTED,isolation_level_options,
3967+
check_XactIsoLevel,NULL,NULL
3968+
},
3969+
39713970
{
39723971
{"IntervalStyle",PGC_USERSET,CLIENT_CONN_LOCALE,
39733972
gettext_noop("Sets the display format for interval values."),
@@ -4776,7 +4775,7 @@ InitializeGUCOptions(void)
47764775
* Prevent any attempt to override the transaction modes from
47774776
* non-interactive sources.
47784777
*/
4779-
SetConfigOption("transaction_isolation","default",
4778+
SetConfigOption("transaction_isolation","read committed",
47804779
PGC_POSTMASTER,PGC_S_OVERRIDE);
47814780
SetConfigOption("transaction_read_only","no",
47824781
PGC_POSTMASTER,PGC_S_OVERRIDE);

‎src/include/commands/variable.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ extern bool check_log_timezone(char **newval, void **extra, GucSource source);
2222
externvoidassign_log_timezone(constchar*newval,void*extra);
2323
externconstchar*show_log_timezone(void);
2424
externboolcheck_transaction_read_only(bool*newval,void**extra,GucSourcesource);
25-
externboolcheck_XactIsoLevel(char**newval,void**extra,GucSourcesource);
26-
externvoidassign_XactIsoLevel(constchar*newval,void*extra);
27-
externconstchar*show_XactIsoLevel(void);
25+
externboolcheck_XactIsoLevel(int*newval,void**extra,GucSourcesource);
2826
externboolcheck_transaction_deferrable(bool*newval,void**extra,GucSourcesource);
2927
externboolcheck_random_seed(double*newval,void**extra,GucSourcesource);
3028
externvoidassign_random_seed(doublenewval,void*extra);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp