mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
Turn transaction_isolation into GUC enum
It was previously a string setting that was converted into an enum by custom code, but using the GUC enum facility seems much simpler and doesn't change any functionality, except that set transaction_isolation='default'; no longer works, but that was never documented and doesn't work with any other transaction characteristics. (Note that this is not the same 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
This commit is contained in:
parent
b6b297d20d
commit
f8c10f616f
@ -522,32 +522,9 @@ check_transaction_read_only(bool *newval, void **extra, GucSource source)
|
|||||||
* As in check_transaction_read_only, allow it if not inside a transaction.
|
* As in check_transaction_read_only, allow it if not inside a transaction.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
check_XactIsoLevel(char **newval, void **extra, GucSource source)
|
check_XactIsoLevel(int *newval, void **extra, GucSource source)
|
||||||
{
|
{
|
||||||
int newXactIsoLevel;
|
int newXactIsoLevel = *newval;
|
||||||
|
|
||||||
if (strcmp(*newval, "serializable") == 0)
|
|
||||||
{
|
|
||||||
newXactIsoLevel = XACT_SERIALIZABLE;
|
|
||||||
}
|
|
||||||
else if (strcmp(*newval, "repeatable read") == 0)
|
|
||||||
{
|
|
||||||
newXactIsoLevel = XACT_REPEATABLE_READ;
|
|
||||||
}
|
|
||||||
else if (strcmp(*newval, "read committed") == 0)
|
|
||||||
{
|
|
||||||
newXactIsoLevel = XACT_READ_COMMITTED;
|
|
||||||
}
|
|
||||||
else if (strcmp(*newval, "read uncommitted") == 0)
|
|
||||||
{
|
|
||||||
newXactIsoLevel = XACT_READ_UNCOMMITTED;
|
|
||||||
}
|
|
||||||
else if (strcmp(*newval, "default") == 0)
|
|
||||||
{
|
|
||||||
newXactIsoLevel = DefaultXactIsoLevel;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (newXactIsoLevel != XactIsoLevel && IsTransactionState())
|
if (newXactIsoLevel != XactIsoLevel && IsTransactionState())
|
||||||
{
|
{
|
||||||
@ -574,39 +551,9 @@ check_XactIsoLevel(char **newval, void **extra, GucSource source)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*extra = malloc(sizeof(int));
|
|
||||||
if (!*extra)
|
|
||||||
return false;
|
|
||||||
*((int *) *extra) = newXactIsoLevel;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
assign_XactIsoLevel(const char *newval, void *extra)
|
|
||||||
{
|
|
||||||
XactIsoLevel = *((int *) extra);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *
|
|
||||||
show_XactIsoLevel(void)
|
|
||||||
{
|
|
||||||
/* We need this because we don't want to show "default". */
|
|
||||||
switch (XactIsoLevel)
|
|
||||||
{
|
|
||||||
case XACT_READ_UNCOMMITTED:
|
|
||||||
return "read uncommitted";
|
|
||||||
case XACT_READ_COMMITTED:
|
|
||||||
return "read committed";
|
|
||||||
case XACT_REPEATABLE_READ:
|
|
||||||
return "repeatable read";
|
|
||||||
case XACT_SERIALIZABLE:
|
|
||||||
return "serializable";
|
|
||||||
default:
|
|
||||||
return "bogus";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SET TRANSACTION [NOT] DEFERRABLE
|
* SET TRANSACTION [NOT] DEFERRABLE
|
||||||
*/
|
*/
|
||||||
|
@ -515,7 +515,6 @@ static int server_version_num;
|
|||||||
static char *timezone_string;
|
static char *timezone_string;
|
||||||
static char *log_timezone_string;
|
static char *log_timezone_string;
|
||||||
static char *timezone_abbreviations_string;
|
static char *timezone_abbreviations_string;
|
||||||
static char *XactIsoLevel_string;
|
|
||||||
static char *data_directory;
|
static char *data_directory;
|
||||||
static char *session_authorization_string;
|
static char *session_authorization_string;
|
||||||
static int max_function_args;
|
static int max_function_args;
|
||||||
@ -3618,17 +3617,6 @@ static struct config_string ConfigureNamesString[] =
|
|||||||
check_timezone_abbreviations, assign_timezone_abbreviations, NULL
|
check_timezone_abbreviations, assign_timezone_abbreviations, NULL
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
|
||||||
{"transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
|
|
||||||
gettext_noop("Sets the current transaction's isolation level."),
|
|
||||||
NULL,
|
|
||||||
GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
|
|
||||||
},
|
|
||||||
&XactIsoLevel_string,
|
|
||||||
"default",
|
|
||||||
check_XactIsoLevel, assign_XactIsoLevel, show_XactIsoLevel
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
{
|
||||||
{"unix_socket_group", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
|
{"unix_socket_group", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
|
||||||
gettext_noop("Sets the owning group of the Unix-domain socket."),
|
gettext_noop("Sets the owning group of the Unix-domain socket."),
|
||||||
@ -3968,6 +3956,17 @@ static struct config_enum ConfigureNamesEnum[] =
|
|||||||
NULL, NULL, NULL
|
NULL, NULL, NULL
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
{"transaction_isolation", PGC_USERSET, CLIENT_CONN_STATEMENT,
|
||||||
|
gettext_noop("Sets the current transaction's isolation level."),
|
||||||
|
NULL,
|
||||||
|
GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
|
||||||
|
},
|
||||||
|
&XactIsoLevel,
|
||||||
|
XACT_READ_COMMITTED, isolation_level_options,
|
||||||
|
check_XactIsoLevel, NULL, NULL
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
{"IntervalStyle", PGC_USERSET, CLIENT_CONN_LOCALE,
|
{"IntervalStyle", PGC_USERSET, CLIENT_CONN_LOCALE,
|
||||||
gettext_noop("Sets the display format for interval values."),
|
gettext_noop("Sets the display format for interval values."),
|
||||||
@ -4776,7 +4775,7 @@ InitializeGUCOptions(void)
|
|||||||
* Prevent any attempt to override the transaction modes from
|
* Prevent any attempt to override the transaction modes from
|
||||||
* non-interactive sources.
|
* non-interactive sources.
|
||||||
*/
|
*/
|
||||||
SetConfigOption("transaction_isolation", "default",
|
SetConfigOption("transaction_isolation", "read committed",
|
||||||
PGC_POSTMASTER, PGC_S_OVERRIDE);
|
PGC_POSTMASTER, PGC_S_OVERRIDE);
|
||||||
SetConfigOption("transaction_read_only", "no",
|
SetConfigOption("transaction_read_only", "no",
|
||||||
PGC_POSTMASTER, PGC_S_OVERRIDE);
|
PGC_POSTMASTER, PGC_S_OVERRIDE);
|
||||||
|
@ -22,9 +22,7 @@ extern bool check_log_timezone(char **newval, void **extra, GucSource source);
|
|||||||
extern void assign_log_timezone(const char *newval, void *extra);
|
extern void assign_log_timezone(const char *newval, void *extra);
|
||||||
extern const char *show_log_timezone(void);
|
extern const char *show_log_timezone(void);
|
||||||
extern bool check_transaction_read_only(bool *newval, void **extra, GucSource source);
|
extern bool check_transaction_read_only(bool *newval, void **extra, GucSource source);
|
||||||
extern bool check_XactIsoLevel(char **newval, void **extra, GucSource source);
|
extern bool check_XactIsoLevel(int *newval, void **extra, GucSource source);
|
||||||
extern void assign_XactIsoLevel(const char *newval, void *extra);
|
|
||||||
extern const char *show_XactIsoLevel(void);
|
|
||||||
extern bool check_transaction_deferrable(bool *newval, void **extra, GucSource source);
|
extern bool check_transaction_deferrable(bool *newval, void **extra, GucSource source);
|
||||||
extern bool check_random_seed(double *newval, void **extra, GucSource source);
|
extern bool check_random_seed(double *newval, void **extra, GucSource source);
|
||||||
extern void assign_random_seed(double newval, void *extra);
|
extern void assign_random_seed(double newval, void *extra);
|
||||||
|
Loading…
Reference in New Issue
Block a user