Index: src/backend/tcop/postgres.c =================================================================== RCS file: /cvsroot/pgsql-server/src/backend/tcop/postgres.c,v retrieving revision 1.298 diff -c -c -r1.298 postgres.c *** src/backend/tcop/postgres.c 6 Oct 2002 03:56:03 -0000 1.298 --- src/backend/tcop/postgres.c 6 Oct 2002 04:28:54 -0000 *************** *** 76,81 **** --- 76,82 ---- CommandDest whereToSendOutput = Debug; extern int StatementTimeout; + extern bool autocommit; static bool dontExecute = false; *************** *** 122,128 **** static List *pg_parse_query(StringInfo query_string, Oid *typev, int nargs); static List *pg_analyze_and_rewrite(Node *parsetree); static void start_xact_command(void); ! static void finish_xact_command(void); static void SigHupHandler(SIGNAL_ARGS); static void FloatExceptionHandler(SIGNAL_ARGS); static const char *CreateCommandTag(Node *parsetree); --- 123,129 ---- static List *pg_parse_query(StringInfo query_string, Oid *typev, int nargs); static List *pg_analyze_and_rewrite(Node *parsetree); static void start_xact_command(void); ! static void finish_xact_command(bool forceCommit); static void SigHupHandler(SIGNAL_ARGS); static void FloatExceptionHandler(SIGNAL_ARGS); static const char *CreateCommandTag(Node *parsetree); *************** *** 806,812 **** */ if (isTransactionStmt) { ! finish_xact_command(); xact_started = false; } } /* end loop over queries generated from a --- 807,813 ---- */ if (isTransactionStmt) { ! finish_xact_command(false); xact_started = false; } } /* end loop over queries generated from a *************** *** 824,830 **** */ if (lnext(parsetree_item) == NIL && xact_started) { ! finish_xact_command(); xact_started = false; } --- 825,843 ---- */ 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); xact_started = false; } *************** *** 859,865 **** * will only happen if the querystring was empty.) */ if (xact_started) ! finish_xact_command(); if (save_Log_duration) { --- 872,878 ---- * will only happen if the querystring was empty.) */ if (xact_started) ! finish_xact_command(false); if (save_Log_duration) { *************** *** 888,894 **** } static void ! finish_xact_command(void) { /* Invoke IMMEDIATE constraint triggers */ DeferredTriggerEndQuery(); --- 901,907 ---- } static void ! finish_xact_command(bool forceCommit) { /* Invoke IMMEDIATE constraint triggers */ DeferredTriggerEndQuery(); *************** *** 896,902 **** /* Now commit the command */ elog(DEBUG1, "CommitTransactionCommand"); ! CommitTransactionCommand(false); #ifdef SHOW_MEMORY_STATS /* Print mem stats at each commit for leak tracking */ --- 909,915 ---- /* Now commit the command */ elog(DEBUG1, "CommitTransactionCommand"); ! CommitTransactionCommand(forceCommit); #ifdef SHOW_MEMORY_STATS /* Print mem stats at each commit for leak tracking */ *************** *** 1901,1907 **** } /* commit the function-invocation transaction */ ! finish_xact_command(); break; /* --- 1914,1920 ---- } /* commit the function-invocation transaction */ ! finish_xact_command(false); break; /*