<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.144 2002/10/09 04:59:38 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.145 2002/10/13 16:55:05 tgl Exp $
-->
<Chapter Id="runtime">
<command>BEGIN</> with no matching <command>COMMIT</> has been
given).
If set to false, <productname>PostgreSQL</productname> will
- commit the commands only when receiving an explicit
+ commit only upon receiving an explicit
<command>COMMIT</> command. This mode can also be thought of as
implicitly issuing <command>BEGIN</> whenever a command is
received that is not already inside a transaction block. The
</para>
<note>
<para>
- With <varname>autocommit</> set to false, <command>SET</>,
+ Even with <varname>autocommit</> set to false, <command>SET</>,
<command>SHOW</>, and <command>RESET</> do not start new
transaction blocks. They are run in their own transactions.
- Once another command is issued, multi-statement transaction
- behavior begins and any <command>SET</>, <command>SHOW</>, or
+ Once another command is issued, a transaction block
+ begins and any <command>SET</>, <command>SHOW</>, or
<command>RESET</> commands are considered to be part of the
transaction, i.e. they are committed or rolled back depending
- on the completion status of the transaction. To have
- <command>SET</>, <command>SHOW</>, and <command>RESET</>
- commands at the start of a transaction, use <command>BEGIN</>
+ on the completion status of the transaction. To execute a
+ <command>SET</>, <command>SHOW</>, or <command>RESET</>
+ command at the start of a transaction block, use <command>BEGIN</>
first.
</para>
</note>
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.300 2002/10/09 04:59:38 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.301 2002/10/13 16:55:05 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
CommandDest whereToSendOutput = Debug;
extern int StatementTimeout;
-extern bool autocommit;
static bool dontExecute = false;
foreach(parsetree_item, parsetree_list)
{
Node *parsetree = (Node *) lfirst(parsetree_item);
- bool isTransactionStmt;
const char *commandTag;
char completionTag[COMPLETION_TAG_BUFSIZE];
List *querytree_list,
*querytree_item;
- /* Transaction control statements need some special handling */
- isTransactionStmt = IsA(parsetree, TransactionStmt);
-
/*
* First we set the command-completion tag to the main query (as
* opposed to each of the others that may be generated by analyze
{
bool allowit = false;
- if (isTransactionStmt)
+ if (IsA(parsetree, TransactionStmt))
{
TransactionStmt *stmt = (TransactionStmt *) parsetree;
foreach(querytree_item, querytree_list)
{
Query *querytree = (Query *) lfirst(querytree_item);
+ bool endTransactionBlock = false;
/* Make sure we are in a transaction command */
if (!xact_started)
IsA(utilityStmt, ReindexStmt))
SetQuerySnapshot();
+ /* end transaction block if transaction or variable stmt */
+ if (IsA(utilityStmt, TransactionStmt) ||
+ IsA(utilityStmt, VariableSetStmt) ||
+ IsA(utilityStmt, VariableShowStmt) ||
+ IsA(utilityStmt, VariableResetStmt))
+ endTransactionBlock = true;
+
if (querytree->originalQuery)
{
/* utility statement can override default tag string */
* visible to subsequent ones. In particular we'd better do
* so before checking constraints.
*/
- if (!isTransactionStmt)
+ if (!endTransactionBlock)
CommandCounterIncrement();
/*
MemoryContextResetAndDeleteChildren(CurrentMemoryContext);
/*
- * If this was a transaction control statement, commit it and
- * arrange to start a new xact command for the next command
- * (if any).
+ * If this was a transaction control statement or a variable
+ * set/show/reset statement, commit it and arrange to start a
+ * new xact command for the next command (if any).
*/
- if (isTransactionStmt)
+ if (endTransactionBlock)
{
- finish_xact_command(false);
+ finish_xact_command(true);
xact_started = false;
}
} /* end loop over queries generated from a
*/
if (lnext(parsetree_item) == NIL && xact_started)
{
- /*
- * Don't allow SET/SHOW/RESET to start a new transaction
- * with autocommit off. We do this by forcing a COMMIT
- * when these commands start a transaction.
- */
- if (autocommit ||
- IsTransactionState() ||
- (strcmp(commandTag, "SET") != 0 &&
- strcmp(commandTag, "SHOW") != 0 &&
- strcmp(commandTag, "RESET") != 0))
- finish_xact_command(false);
- else
- finish_xact_command(true);
+ finish_xact_command(false);
xact_started = false;
}
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.300 $ $Date: 2002/10/09 04:59:38 $\n");
+ puts("$Revision: 1.301 $ $Date: 2002/10/13 16:55:05 $\n");
}
/*