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

Commitad4ce7a

Browse files
committed
Make SET really not start a transaction.
1 parent5261bf9 commitad4ce7a

File tree

5 files changed

+40
-41
lines changed

5 files changed

+40
-41
lines changed

‎doc/src/sgml/ref/reset.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/reset.sgml,v 1.16 2002/10/09 04:59:38 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/reset.sgml,v 1.17 2002/10/13 16:55:05 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -68,7 +68,7 @@ SET <replaceable class="parameter">variable</replaceable> TO DEFAULT
6868
</para>
6969

7070
<para>
71-
See the <command>SHOW</> manual page for details on the transaction
71+
See the <command>SET</> manual page for details on the transaction
7272
behavior of <command>RESET</>.
7373
</para>
7474

‎doc/src/sgml/ref/set.sgml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.67 2002/10/09 16:27:48 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.68 2002/10/13 16:55:05 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -109,9 +109,10 @@ SET [ SESSION | LOCAL ] TIME ZONE { <replaceable class="PARAMETER">timezone</rep
109109
</para>
110110

111111
<para>
112-
With <literal>autocommit</> set to <literal>off</>, <command>SET</>
112+
Even with <literal>autocommit</> set to <literal>off</>, <command>SET</>
113113
does not start a new transaction block. See the
114-
<literal>autocommit</> section of the documentation for details.
114+
<literal>autocommit</> section of the <citetitle>Administrator's
115+
Guide</citetitle> for details.
115116
</para>
116117

117118
<para>

‎doc/src/sgml/ref/show.sgml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/show.sgml,v 1.21 2002/09/01 01:59:48 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/show.sgml,v 1.22 2002/10/13 16:55:05 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -60,6 +60,13 @@ SHOW ALL
6060
command-line flag when starting the
6161
<application>postmaster</application>.
6262
</para>
63+
64+
<para>
65+
Even with <literal>autocommit</> set to <literal>off</>, <command>SHOW</>
66+
does not start a new transaction block. See the
67+
<literal>autocommit</> section of the <citetitle>Administrator's
68+
Guide</citetitle> for details.
69+
</para>
6370
</refsect1>
6471

6572
<refsect1>

‎doc/src/sgml/runtime.sgml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.144 2002/10/09 04:59:38 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.145 2002/10/13 16:55:05 tgl Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -1236,7 +1236,7 @@ env PGOPTIONS='-c geqo=off' psql
12361236
<command>BEGIN</> with no matching <command>COMMIT</> has been
12371237
given).
12381238
If set to false, <productname>PostgreSQL</productname> will
1239-
committhe commandsonlywhen receiving an explicit
1239+
commit onlyupon receiving an explicit
12401240
<command>COMMIT</> command. This mode can also be thought of as
12411241
implicitly issuing <command>BEGIN</> whenever a command is
12421242
received that is not already inside a transaction block. The
@@ -1247,16 +1247,16 @@ env PGOPTIONS='-c geqo=off' psql
12471247
</para>
12481248
<note>
12491249
<para>
1250-
With <varname>autocommit</> set to false, <command>SET</>,
1250+
Even with <varname>autocommit</> set to false, <command>SET</>,
12511251
<command>SHOW</>, and <command>RESET</> do not start new
12521252
transaction blocks. They are run in their own transactions.
1253-
Once another command is issued,multi-statement transaction
1254-
behaviorbegins and any <command>SET</>, <command>SHOW</>, or
1253+
Once another command is issued,a transaction block
1254+
begins and any <command>SET</>, <command>SHOW</>, or
12551255
<command>RESET</> commands are considered to be part of the
12561256
transaction, i.e. they are committed or rolled back depending
1257-
on the completion status of the transaction. Tohave
1258-
<command>SET</>, <command>SHOW</>,and <command>RESET</>
1259-
commands at the start of a transaction, use <command>BEGIN</>
1257+
on the completion status of the transaction. Toexecute a
1258+
<command>SET</>, <command>SHOW</>,or <command>RESET</>
1259+
command at the start of a transaction block, use <command>BEGIN</>
12601260
first.
12611261
</para>
12621262
</note>

‎src/backend/tcop/postgres.c

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.300 2002/10/09 04:59:38 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.301 2002/10/13 16:55:05 tgl Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -76,7 +76,6 @@ char *debug_query_string; /* for pgmonitor and
7676
CommandDestwhereToSendOutput=Debug;
7777

7878
externintStatementTimeout;
79-
externboolautocommit;
8079

8180
staticbooldontExecute= false;
8281

@@ -620,15 +619,11 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
620619
foreach(parsetree_item,parsetree_list)
621620
{
622621
Node*parsetree= (Node*)lfirst(parsetree_item);
623-
boolisTransactionStmt;
624622
constchar*commandTag;
625623
charcompletionTag[COMPLETION_TAG_BUFSIZE];
626624
List*querytree_list,
627625
*querytree_item;
628626

629-
/* Transaction control statements need some special handling */
630-
isTransactionStmt=IsA(parsetree,TransactionStmt);
631-
632627
/*
633628
* First we set the command-completion tag to the main query (as
634629
* opposed to each of the others that may be generated by analyze
@@ -653,7 +648,7 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
653648
{
654649
boolallowit= false;
655650

656-
if (isTransactionStmt)
651+
if (IsA(parsetree,TransactionStmt))
657652
{
658653
TransactionStmt*stmt= (TransactionStmt*)parsetree;
659654

@@ -698,6 +693,7 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
698693
foreach(querytree_item,querytree_list)
699694
{
700695
Query*querytree= (Query*)lfirst(querytree_item);
696+
boolendTransactionBlock= false;
701697

702698
/* Make sure we are in a transaction command */
703699
if (!xact_started)
@@ -733,6 +729,13 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
733729
IsA(utilityStmt,ReindexStmt))
734730
SetQuerySnapshot();
735731

732+
/* end transaction block if transaction or variable stmt */
733+
if (IsA(utilityStmt,TransactionStmt)||
734+
IsA(utilityStmt,VariableSetStmt)||
735+
IsA(utilityStmt,VariableShowStmt)||
736+
IsA(utilityStmt,VariableResetStmt))
737+
endTransactionBlock= true;
738+
736739
if (querytree->originalQuery)
737740
{
738741
/* utility statement can override default tag string */
@@ -805,7 +808,7 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
805808
* visible to subsequent ones.In particular we'd better do
806809
* so before checking constraints.
807810
*/
808-
if (!isTransactionStmt)
811+
if (!endTransactionBlock)
809812
CommandCounterIncrement();
810813

811814
/*
@@ -820,13 +823,13 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
820823
MemoryContextResetAndDeleteChildren(CurrentMemoryContext);
821824

822825
/*
823-
* If this was a transaction control statement, commit it and
824-
*arrange to start a new xact command for the next command
825-
* (if any).
826+
* If this was a transaction control statement or a variable
827+
*set/show/reset statement, commit it and arrange to start a
828+
*new xact command for the next command(if any).
826829
*/
827-
if (isTransactionStmt)
830+
if (endTransactionBlock)
828831
{
829-
finish_xact_command(false);
832+
finish_xact_command(true);
830833
xact_started= false;
831834
}
832835
}/* end loop over queries generated from a
@@ -844,19 +847,7 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
844847
*/
845848
if (lnext(parsetree_item)==NIL&&xact_started)
846849
{
847-
/*
848-
*Don't allow SET/SHOW/RESET to start a new transaction
849-
*with autocommit off. We do this by forcing a COMMIT
850-
*when these commands start a transaction.
851-
*/
852-
if (autocommit||
853-
IsTransactionState()||
854-
(strcmp(commandTag,"SET")!=0&&
855-
strcmp(commandTag,"SHOW")!=0&&
856-
strcmp(commandTag,"RESET")!=0))
857-
finish_xact_command(false);
858-
else
859-
finish_xact_command(true);
850+
finish_xact_command(false);
860851
xact_started= false;
861852
}
862853

@@ -1733,7 +1724,7 @@ PostgresMain(int argc, char *argv[], const char *username)
17331724
if (!IsUnderPostmaster)
17341725
{
17351726
puts("\nPOSTGRES backend interactive interface ");
1736-
puts("$Revision: 1.300 $ $Date: 2002/10/09 04:59:38 $\n");
1727+
puts("$Revision: 1.301 $ $Date: 2002/10/13 16:55:05 $\n");
17371728
}
17381729

17391730
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp