aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/variable.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2018-10-09 21:21:57 +0200
committerPeter Eisentraut <peter_e@gmx.net>2018-10-09 21:26:00 +0200
commitf8c10f616fa5081999ac48a0b6621057db806851 (patch)
tree043fb6016948bca317dea48bdc43bde2456a6628 /src/backend/commands/variable.c
parentb6b297d20df9f738be20a450f80bade535819220 (diff)
downloadpostgresql-f8c10f616fa5081999ac48a0b6621057db806851.tar.gz
postgresql-f8c10f616fa5081999ac48a0b6621057db806851.zip
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
Diffstat (limited to 'src/backend/commands/variable.c')
-rw-r--r--src/backend/commands/variable.c57
1 files changed, 2 insertions, 55 deletions
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 9a754dae3fd..c2d7a5bebf6 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
*/