88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.178 2000/10/07 00:58:18 tgl Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.179 2000/10/0704: 00:41 tgl Exp $
1212 *
1313 * NOTES
1414 * this is the "main" module of the postgres backend and
@@ -597,18 +597,17 @@ pg_plan_query(Query *querytree)
597597 *
598598 * Assumptions:
599599 *
600- * Caller is responsible for calling StartTransactionCommand() beforehand
601- * and CommitTransactionCommand() afterwards (if successful).
600+ * At call, we are not inside a transaction command.
602601 *
603- * The CurrentMemoryContextat entry references a context that is
602+ * The CurrentMemoryContextafter starting a transaction command must be
604603 * appropriate for execution of individual queries (typically this will be
605604 * TransactionCommandContext). Note that this routine resets that context
606605 * after each individual query, so don't store anything there that
607606 * must outlive the call!
608607 *
609608 * parse_context references a context suitable for holding the
610609 * parse/rewrite trees (typically this will be QueryContext).
611- * This context *must* be longer-lived than theCurrentMemoryContext !
610+ * This context *must* be longer-lived than thetransaction context !
612611 * In fact, if the query string might contain BEGIN/COMMIT commands,
613612 * parse_context had better outlive TopTransactionContext!
614613 *
@@ -635,7 +634,7 @@ pg_exec_query_string(char *query_string,/* string to execute */
635634 * query_string will be in this same command block, *unless* we find
636635 * a BEGIN/COMMIT/ABORT statement; we have to force a new xact command
637636 * after one of those, else bad things will happen in xact.c.
638- * (Note that this will possibly changeexecution memory context.)
637+ * (Note that this will possibly changecurrent memory context.)
639638 */
640639start_xact_command ();
641640xact_started = true;
@@ -837,11 +836,6 @@ pg_exec_query_string(char *query_string,/* string to execute */
837836if (!isTransactionStmt )
838837CommandCounterIncrement ();
839838
840- /*
841- * Invoke IMMEDIATE constraint triggers
842- */
843- DeferredTriggerEndQuery ();
844-
845839/*
846840 * Clear the execution context to recover temporary
847841 * memory used by the query. NOTE: if query string contains
@@ -888,12 +882,17 @@ start_xact_command(void)
888882static void
889883finish_xact_command (void )
890884{
885+ /* Invoke IMMEDIATE constraint triggers */
886+ DeferredTriggerEndQuery ();
887+
888+ /* Now commit the command */
891889if (DebugLvl >=1 )
892890elog (DEBUG ,"CommitTransactionCommand" );
893891set_ps_display ("commit" );/* XXX probably the wrong place to do this */
894892CommitTransactionCommand ();
893+
895894#ifdef SHOW_MEMORY_STATS
896- /*print mem stats at each commit for leak tracking */
895+ /*Print mem stats at each commit for leak tracking */
897896if (ShowStats )
898897MemoryContextStats (TopMemoryContext );
899898#endif
@@ -1614,7 +1613,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
16141613if (!IsUnderPostmaster )
16151614{
16161615puts ("\nPOSTGRES backend interactive interface " );
1617- puts ("$Revision: 1.178 $ $Date: 2000/10/07 00:58:18 $\n" );
1616+ puts ("$Revision: 1.179 $ $Date: 2000/10/0704: 00:41 $\n" );
16181617}
16191618
16201619/*