worries about funny characters.
-->
+No-autocommit mode is available (set autocommit to off)
Substantial improvements in functionality for functions returning sets
Client libraries older than 6.3 no longer supported (version 0 protocol removed)
PREPARE statement allows caching query plans for interactive statements
+
+ AUTOCOMMIT (bool)
+
+ If set to true,
PostgreSQL will
+ automatically do a COMMIT> after each successful command
+ that is not inside an explicit transaction block (that is, unless a
+ BEGIN> with no matching COMMIT> has been
+ given).
+ If set to false,
PostgreSQL will commit
+ the effects of commands only on receiving an explicit
+ COMMIT> command. This mode can also be thought of as
+ implicitly issuing BEGIN> whenever a command is received
+ and
PostgreSQL is not already inside
+ a transaction block.
+ The default is true, for compatibility with historical
+
PostgreSQL behavior. But for maximum
+ compatibility with the SQL specification, set it to false.
+
+
+
+
AUSTRALIAN_TIMEZONES (bool)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.130 2002/08/06 02:36:33 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.131 2002/08/30 22:18:05 tgl Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
int DefaultXactIsoLevel = XACT_READ_COMMITTED;
int XactIsoLevel;
+bool autocommit = true;
+
int CommitDelay = 0; /* precommit delay in microseconds */
int CommitSiblings = 5; /* number of concurrent xacts needed to
* sleep */
+
+static bool suppressChain = false;
+
static void (*_RollbackFunc) (void *) = NULL;
static void *_RollbackData = NULL;
/* --------------------------------
* StartTransactionCommand
+ *
+ * preventChain, if true, forces autocommit behavior at the next
+ * CommitTransactionCommand call.
* --------------------------------
*/
void
-StartTransactionCommand(void)
+StartTransactionCommand(bool preventChain)
{
TransactionState s = CurrentTransactionState;
+ /*
+ * Remember if caller wants to prevent autocommit-off chaining.
+ * This is only allowed if not already in a transaction block.
+ */
+ suppressChain = preventChain;
+ if (preventChain && s->blockState != TBLOCK_DEFAULT)
+ elog(ERROR, "StartTransactionCommand: can't prevent chain");
+
switch (s->blockState)
{
/*
/* --------------------------------
* CommitTransactionCommand
+ *
+ * forceCommit = true forces autocommit behavior even when autocommit is off.
* --------------------------------
*/
void
-CommitTransactionCommand(void)
+CommitTransactionCommand(bool forceCommit)
{
TransactionState s = CurrentTransactionState;
switch (s->blockState)
{
/*
- * if we aren't in a transaction block, we just do our usual
- * transaction commit
+ * If we aren't in a transaction block, and we are doing
+ * autocommit, just do our usual transaction commit. But
+ * if we aren't doing autocommit, start a transaction block
+ * automatically by switching to INPROGRESS state. (We handle
+ * this choice here, and not earlier, so that an explicit BEGIN
+ * issued in autocommit-off mode won't issue strange warnings.)
+ *
+ * Autocommit mode is forced by either a true forceCommit parameter
+ * to me, or a true preventChain parameter to the preceding
+ * StartTransactionCommand call. This is needed so that commands
+ * like VACUUM can ensure that the right things happen.
*/
case TBLOCK_DEFAULT:
- CommitTransaction();
+ if (autocommit || forceCommit || suppressChain)
+ CommitTransaction();
+ else
+ {
+ BeginTransactionBlock();
+ Assert(s->blockState == TBLOCK_INPROGRESS);
+ /* This code must match the TBLOCK_INPROGRESS case below: */
+ CommandCounterIncrement();
+ MemoryContextResetAndDeleteChildren(TransactionCommandContext);
+ }
break;
/*
s->blockState = TBLOCK_BEGIN;
/*
- * do begin processing
+ * do begin processing. NOTE: if you put anything here, check that
+ * it behaves properly in both autocommit-on and autocommit-off modes.
+ * In the latter case we will already have done some work in the new
+ * transaction.
*/
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.50 2002/07/20 05:16:56 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.51 2002/08/30 22:18:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
static void
do_start()
{
- StartTransactionCommand();
+ StartTransactionCommand(true);
elog(DEBUG3, "start transaction");
}
static void
do_end()
{
- CommitTransactionCommand();
+ CommitTransactionCommand(true);
elog(DEBUG3, "commit transaction");
if (isatty(0))
{
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.138 2002/08/17 15:12:06 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.139 2002/08/30 22:18:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
SetProcessingMode(BootstrapProcessing);
/* clean up processing */
- StartTransactionCommand();
+ StartTransactionCommand(true);
cleanup();
/* not reached, here to make compiler happy */
}
if (boot_reldesc != NULL)
closerel(NULL);
- CommitTransactionCommand();
+ CommitTransactionCommand(true);
proc_exit(Warnings);
}
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.32 2002/08/29 00:17:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.33 2002/08/30 22:18:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
{
/* Need to ensure we have a usable transaction. */
AbortOutOfAnyTransaction();
- StartTransactionCommand();
+ StartTransactionCommand(true);
RemoveTempRelations(myTempNamespace);
- CommitTransactionCommand();
+ CommitTransactionCommand(true);
}
}
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.88 2002/08/05 03:29:16 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.89 2002/08/30 22:18:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*/
AbortOutOfAnyTransaction();
/* Now we can do the unlisten */
- StartTransactionCommand();
+ StartTransactionCommand(true);
Async_UnlistenAll();
- CommitTransactionCommand();
+ CommitTransactionCommand(true);
}
/*
notifyInterruptOccurred = 0;
- StartTransactionCommand();
+ StartTransactionCommand(true);
lRel = heap_openr(ListenerRelationName, AccessExclusiveLock);
tdesc = RelationGetDescr(lRel);
*/
heap_close(lRel, NoLock);
- CommitTransactionCommand();
+ CommitTransactionCommand(true);
/*
* Must flush the notify messages to ensure frontend gets them
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.85 2002/08/29 15:56:20 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.86 2002/08/30 22:18:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
heap_close(relationRelation, AccessShareLock);
/* Now reindex each rel in a separate transaction */
- CommitTransactionCommand();
+ CommitTransactionCommand(true);
for (i = 0; i < relcnt; i++)
{
- StartTransactionCommand();
+ StartTransactionCommand(true);
if (reindex_relation(relids[i], force))
elog(NOTICE, "relation %u was reindexed", relids[i]);
- CommitTransactionCommand();
+ CommitTransactionCommand(true);
}
- StartTransactionCommand();
+ /* Tell xact.c not to chain the upcoming commit */
+ StartTransactionCommand(true);
MemoryContextDelete(private_context);
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.234 2002/08/13 20:14:24 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.235 2002/08/30 22:18:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
}
/* matches the StartTransaction in PostgresMain() */
- CommitTransactionCommand();
+ CommitTransactionCommand(true);
}
/*
* return (else we leak memory while processing multiple tables).
*/
if (vacstmt->vacuum)
- StartTransactionCommand();
+ StartTransactionCommand(true);
else
old_context = MemoryContextSwitchTo(anl_context);
analyze_rel(relid, vacstmt);
if (vacstmt->vacuum)
- CommitTransactionCommand();
+ CommitTransactionCommand(true);
else
{
MemoryContextSwitchTo(old_context);
{
/* here, we are not in a transaction */
- /* matches the CommitTransaction in PostgresMain() */
- StartTransactionCommand();
+ /*
+ * This matches the CommitTransaction waiting for us in PostgresMain().
+ * We tell xact.c not to chain the upcoming commit, so that a VACUUM
+ * doesn't start a transaction block, even when autocommit is off.
+ */
+ StartTransactionCommand(true);
/*
* If we did a database-wide VACUUM, update the database's pg_database
Oid toast_relid;
/* Begin a transaction for vacuuming this relation */
- StartTransactionCommand();
+ StartTransactionCommand(true);
/*
* Check for user-requested abort. Note we want this to be inside a
ObjectIdGetDatum(relid),
0, 0, 0))
{
- CommitTransactionCommand();
+ CommitTransactionCommand(true);
return;
}
elog(WARNING, "Skipping \"%s\" --- only table or database owner can VACUUM it",
RelationGetRelationName(onerel));
relation_close(onerel, lmode);
- CommitTransactionCommand();
+ CommitTransactionCommand(true);
return;
}
elog(WARNING, "Skipping \"%s\" --- can not process indexes, views or special system tables",
RelationGetRelationName(onerel));
relation_close(onerel, lmode);
- CommitTransactionCommand();
+ CommitTransactionCommand(true);
return;
}
/*
* Complete the transaction and free all temporary memory used.
*/
- CommitTransactionCommand();
+ CommitTransactionCommand(true);
/*
* If the relation has a secondary toast rel, vacuum that too while we
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.286 2002/08/29 23:39:05 inoue Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.287 2002/08/30 22:18:06 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
start_xact_command(void)
{
elog(DEBUG1, "StartTransactionCommand");
- StartTransactionCommand();
+ StartTransactionCommand(false);
}
static void
/* Now commit the command */
elog(DEBUG1, "CommitTransactionCommand");
- CommitTransactionCommand();
+ CommitTransactionCommand(false);
#ifdef SHOW_MEMORY_STATS
/* Print mem stats at each commit for leak tracking */
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.286 $ $Date: 2002/08/29 23:39:05 $\n");
+ puts("$Revision: 1.287 $ $Date: 2002/08/30 22:18:06 $\n");
}
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.111 2002/08/29 21:02:12 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.112 2002/08/30 22:18:06 tgl Exp $
*
*
*-------------------------------------------------------------------------
/* start a new transaction here before access to db */
if (!bootstrap)
- StartTransactionCommand();
+ StartTransactionCommand(true);
/*
* It's now possible to do real access to the system catalogs.
/* close the transaction we started above */
if (!bootstrap)
- CommitTransactionCommand();
+ CommitTransactionCommand(true);
/*
* Check a normal user hasn't connected to a superuser reserved slot.
* command, configuration file, and command line options.
* See src/backend/utils/misc/README for more information.
*
- * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.88 2002/08/30 16:50:50 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.89 2002/08/30 22:18:07 tgl Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut
.
extern int AuthenticationTimeout;
extern int StatementTimeout;
extern int CheckPointTimeout;
+extern bool autocommit;
extern int CommitDelay;
extern int CommitSiblings;
extern bool FixBTree;
{ "db_user_namespace", PGC_SIGHUP }, &Db_user_namespace,
false, NULL, NULL
},
+ {
+ { "autocommit", PGC_USERSET }, &autocommit,
+ true, NULL, NULL
+ },
{
{ NULL, 0 }, NULL, false, NULL, NULL
#checkpoint_segments = 3 # in logfile segments, min 1, 16MB each
#checkpoint_timeout = 300 # range 30-3600, in seconds
#
-#wal_files = 0 # range 0-64
-#
#commit_delay = 0 # range 0-100000, in microseconds
#commit_siblings = 5 # range 1-1000
#
#
# Misc
#
+#autocommit = true
#dynamic_library_path = '$libdir'
#search_path = '$user,public'
#datestyle = 'iso, us'
*
* Copyright 2000-2002 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.59 2002/08/30 18:15:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.60 2002/08/30 22:18:07 tgl Exp $
*/
/*----------------------------------------------------------------------
"australian_timezones",
"password_encryption",
"transform_null_equals",
+ "autocommit",
"default_statistics_target",
"geqo_threshold",
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: xact.h,v 1.44 2002/06/20 20:29:43 momjian Exp $
+ * $Id: xact.h,v 1.45 2002/08/30 22:18:07 tgl Exp $
*
*-------------------------------------------------------------------------
*/
extern bool TransactionIdIsCurrentTransactionId(TransactionId xid);
extern bool CommandIdIsCurrentCommandId(CommandId cid);
extern void CommandCounterIncrement(void);
-extern void StartTransactionCommand(void);
-extern void CommitTransactionCommand(void);
+extern void StartTransactionCommand(bool preventChain);
+extern void CommitTransactionCommand(bool forceCommit);
extern void AbortCurrentTransaction(void);
extern void BeginTransactionBlock(void);
extern void EndTransactionBlock(void);