v1-0006-Turn-transaction_isolation-into-GUC-enum.patch
text/plain
Filename: v1-0006-Turn-transaction_isolation-into-GUC-enum.patch
Type: text/plain
Part: 5
Message:
chained transactions
Patch
Format: format-patch
Series: patch v1-0006
Subject: Turn transaction_isolation into GUC enum
| File | + | − |
|---|---|---|
| src/backend/commands/variable.c | 2 | 55 |
| src/backend/utils/misc/guc.c | 12 | 13 |
| src/include/commands/variable.h | 1 | 3 |
From 517bc6d9fefdee9135857d9562f644f2984ace32 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Sun, 18 Feb 2018 09:33:53 -0500
Subject: [PATCH v1 6/8] Turn transaction_isolation into GUC enum
XXX no idea why it was done the way it was, but this seems much simpler
and apparently doesn't change any functionality.
---
src/backend/commands/variable.c | 57 ++---------------------------------------
src/backend/utils/misc/guc.c | 25 +++++++++---------
src/include/commands/variable.h | 4 +--
3 files changed, 15 insertions(+), 71 deletions(-)
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 9a754dae3f..c2d7a5bebf 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -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.
*/
bool
-check_XactIsoLevel(char **newval, void **extra, GucSource source)
+check_XactIsoLevel(int *newval, void **extra, GucSource source)
{
- int newXactIsoLevel;
-
- 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;
+ int newXactIsoLevel = *newval;
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;
}
-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
*/
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 14dadf514e..aeb9bf4ed5 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -504,7 +504,6 @@ static int server_version_num;
static char *timezone_string;
static char *log_timezone_string;
static char *timezone_abbreviations_string;
-static char *XactIsoLevel_string;
static char *data_directory;
static char *session_authorization_string;
static int max_function_args;
@@ -3434,17 +3433,6 @@ static struct config_string ConfigureNamesString[] =
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,
gettext_noop("Sets the owning group of the Unix-domain socket."),
@@ -3748,6 +3736,17 @@ static struct config_enum ConfigureNamesEnum[] =
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,
gettext_noop("Sets the display format for interval values."),
@@ -4544,7 +4543,7 @@ InitializeGUCOptions(void)
* Prevent any attempt to override the transaction modes from
* non-interactive sources.
*/
- SetConfigOption("transaction_isolation", "default",
+ SetConfigOption("transaction_isolation", "read committed",
PGC_POSTMASTER, PGC_S_OVERRIDE);
SetConfigOption("transaction_read_only", "no",
PGC_POSTMASTER, PGC_S_OVERRIDE);
diff --git a/src/include/commands/variable.h b/src/include/commands/variable.h
index 4ea3b0209b..7373a3f99f 100644
--- a/src/include/commands/variable.h
+++ b/src/include/commands/variable.h
@@ -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 const char *show_log_timezone(void);
extern bool check_transaction_read_only(bool *newval, void **extra, GucSource source);
-extern bool check_XactIsoLevel(char **newval, void **extra, GucSource source);
-extern void assign_XactIsoLevel(const char *newval, void *extra);
-extern const char *show_XactIsoLevel(void);
+extern bool check_XactIsoLevel(int *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 void assign_random_seed(double newval, void *extra);
--
2.16.2