aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/variable.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2011-01-21 21:49:19 -0500
committerRobert Haas <rhaas@postgresql.org>2011-01-21 21:49:19 -0500
commitfb4c5d2798730f60b102d775f22fb53c26a6445d (patch)
treee56a80a66e9daea3b07dba95d81d6bc1f4df647d /src/backend/commands/variable.c
parentcb38ab6d3b89eccb75b3337f8723cfc283fb77fb (diff)
downloadpostgresql-fb4c5d2798730f60b102d775f22fb53c26a6445d.tar.gz
postgresql-fb4c5d2798730f60b102d775f22fb53c26a6445d.zip
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.
Diffstat (limited to 'src/backend/commands/variable.c')
-rw-r--r--src/backend/commands/variable.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 848685f2e8a..1e9bdc3f218 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -546,27 +546,27 @@ show_log_timezone(void)
/*
* SET TRANSACTION ISOLATION LEVEL
*/
-
const char *
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),
- (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
- errmsg("SET TRANSACTION ISOLATION LEVEL must be called before any query")));
- /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
- if (source != PGC_S_OVERRIDE)
+ if (FirstSnapshotSet)
+ {
+ ereport(GUC_complaint_elevel(source),
+ (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
+ errmsg("SET TRANSACTION ISOLATION LEVEL must be called before any query")));
return NULL;
- }
- else if (IsSubTransaction())
- {
- ereport(GUC_complaint_elevel(source),
- (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
- errmsg("SET TRANSACTION ISOLATION LEVEL must not be called in a subtransaction")));
- /* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
- if (source != PGC_S_OVERRIDE)
+ }
+ /* 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),
+ errmsg("SET TRANSACTION ISOLATION LEVEL must not be called in a subtransaction")));
return NULL;
+ }
}
if (strcmp(value, "serializable") == 0)