Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfb4c5d2

Browse files
committed
Code cleanup for assign_XactIsoLevel.
The new coding avoids a spurious debug message when a transactionthat has changed the isolation level has been rolled back. It alsoallows the property to be freely changed to the current value withina subtransaction.Kevin Grittner, with one small change by me.
1 parentcb38ab6 commitfb4c5d2

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

‎src/backend/commands/variable.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -546,27 +546,27 @@ show_log_timezone(void)
546546
/*
547547
* SET TRANSACTION ISOLATION LEVEL
548548
*/
549-
550549
constchar*
551550
assign_XactIsoLevel(constchar*value,booldoit,GucSourcesource)
552551
{
553-
if (FirstSnapshotSet)
552+
/* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
553+
if (source!=PGC_S_OVERRIDE)
554554
{
555-
ereport(GUC_complaint_elevel(source),
556-
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
557-
errmsg("SET TRANSACTION ISOLATION LEVEL must be called before any query")));
558-
/* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
559-
if (source!=PGC_S_OVERRIDE)
555+
if (FirstSnapshotSet)
556+
{
557+
ereport(GUC_complaint_elevel(source),
558+
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
559+
errmsg("SET TRANSACTION ISOLATION LEVEL must be called before any query")));
560560
returnNULL;
561-
}
562-
elseif (IsSubTransaction())
563-
{
564-
ereport(GUC_complaint_elevel(source),
565-
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
566-
errmsg("SET TRANSACTION ISOLATION LEVEL must not be called in a subtransaction")));
567-
/* source == PGC_S_OVERRIDE means do it anyway, eg at xact abort */
568-
if (source!=PGC_S_OVERRIDE)
561+
}
562+
/* We ignore a subtransaction setting it to the existing value. */
563+
if (IsSubTransaction()&&strcmp(value,XactIsoLevel_string)!=0)
564+
{
565+
ereport(GUC_complaint_elevel(source),
566+
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
567+
errmsg("SET TRANSACTION ISOLATION LEVEL must not be called in a subtransaction")));
569568
returnNULL;
569+
}
570570
}
571571

572572
if (strcmp(value,"serializable")==0)

‎src/backend/utils/misc/guc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,6 @@ static intserver_version_num;
425425
staticchar*timezone_string;
426426
staticchar*log_timezone_string;
427427
staticchar*timezone_abbreviations_string;
428-
staticchar*XactIsoLevel_string;
429428
staticchar*custom_variable_classes;
430429
staticintmax_function_args;
431430
staticintmax_index_keys;
@@ -440,6 +439,7 @@ static inteffective_io_concurrency;
440439
/* should be static, but commands/variable.c needs to get at these */
441440
char*role_string;
442441
char*session_authorization_string;
442+
char*XactIsoLevel_string;
443443

444444

445445
/*

‎src/include/utils/guc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ extern char *ConfigFileName;
201201
externchar*HbaFileName;
202202
externchar*IdentFileName;
203203
externchar*external_pid_file;
204+
externchar*XactIsoLevel_string;
204205

205206
externchar*application_name;
206207

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp