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
7676CommandDest whereToSendOutput = Debug ;
7777
7878extern int StatementTimeout ;
79- extern bool autocommit ;
8079
8180static bool dontExecute = false;
8281
@@ -620,15 +619,11 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
620619foreach (parsetree_item ,parsetree_list )
621620{
622621Node * parsetree = (Node * )lfirst (parsetree_item );
623- bool isTransactionStmt ;
624622const char * commandTag ;
625623char completionTag [COMPLETION_TAG_BUFSIZE ];
626624List * 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{
654649bool allowit = false;
655650
656- if (isTransactionStmt )
651+ if (IsA ( parsetree , TransactionStmt ) )
657652{
658653TransactionStmt * stmt = (TransactionStmt * )parsetree ;
659654
@@ -698,6 +693,7 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
698693foreach (querytree_item ,querytree_list )
699694{
700695Query * querytree = (Query * )lfirst (querytree_item );
696+ bool endTransactionBlock = false;
701697
702698/* Make sure we are in a transaction command */
703699if (!xact_started )
@@ -733,6 +729,13 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
733729IsA (utilityStmt ,ReindexStmt ))
734730SetQuerySnapshot ();
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+
736739if (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 )
809812CommandCounterIncrement ();
810813
811814/*
@@ -820,13 +823,13 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
820823MemoryContextResetAndDeleteChildren (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 );
830833xact_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 */
845848if (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);
860851xact_started = false;
861852}
862853
@@ -1733,7 +1724,7 @@ PostgresMain(int argc, char *argv[], const char *username)
17331724if (!IsUnderPostmaster )
17341725{
17351726puts ("\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/*