Commit fb4c5d27 authored by Robert Haas's avatar Robert Haas

Code cleanup for assign_XactIsoLevel.

The new coding avoids a spurious debug message when a transaction
that has changed the isolation level has been rolled back.  It also
allows the property to be freely changed to the current value within
a subtransaction.

Kevin Grittner, with one small change by me.
parent cb38ab6d
...@@ -546,27 +546,27 @@ show_log_timezone(void) ...@@ -546,27 +546,27 @@ show_log_timezone(void)
/* /*
* SET TRANSACTION ISOLATION LEVEL * SET TRANSACTION ISOLATION LEVEL
*/ */
const char * const char *
assign_XactIsoLevel(const char *value, bool doit, GucSource source) assign_XactIsoLevel(const char *value, bool doit, GucSource source)
{ {
if (FirstSnapshotSet) /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
if (source != PGC_S_OVERRIDE)
{ {
ereport(GUC_complaint_elevel(source), if (FirstSnapshotSet)
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), {
errmsg("SET TRANSACTION ISOLATION LEVEL must be called before any query"))); ereport(GUC_complaint_elevel(source),
/* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */ (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
if (source != PGC_S_OVERRIDE) errmsg("SET TRANSACTION ISOLATION LEVEL must be called before any query")));
return NULL; return NULL;
} }
else if (IsSubTransaction()) /* We ignore a subtransaction setting it to the existing value. */
{ if (IsSubTransaction() && strcmp(value, XactIsoLevel_string) != 0)
ereport(GUC_complaint_elevel(source), {
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), ereport(GUC_complaint_elevel(source),
errmsg("SET TRANSACTION ISOLATION LEVEL must not be called in a subtransaction"))); (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
/* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */ errmsg("SET TRANSACTION ISOLATION LEVEL must not be called in a subtransaction")));
if (source != PGC_S_OVERRIDE)
return NULL; return NULL;
}
} }
if (strcmp(value, "serializable") == 0) if (strcmp(value, "serializable") == 0)
......
...@@ -425,7 +425,6 @@ static int server_version_num; ...@@ -425,7 +425,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 *custom_variable_classes; static char *custom_variable_classes;
static int max_function_args; static int max_function_args;
static int max_index_keys; static int max_index_keys;
...@@ -440,6 +439,7 @@ static int effective_io_concurrency; ...@@ -440,6 +439,7 @@ static int effective_io_concurrency;
/* should be static, but commands/variable.c needs to get at these */ /* should be static, but commands/variable.c needs to get at these */
char *role_string; char *role_string;
char *session_authorization_string; char *session_authorization_string;
char *XactIsoLevel_string;
/* /*
......
...@@ -201,6 +201,7 @@ extern char *ConfigFileName; ...@@ -201,6 +201,7 @@ extern char *ConfigFileName;
extern char *HbaFileName; extern char *HbaFileName;
extern char *IdentFileName; extern char *IdentFileName;
extern char *external_pid_file; extern char *external_pid_file;
extern char *XactIsoLevel_string;
extern char *application_name; extern char *application_name;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment