Re: What happens to transactions durring a pg_dump?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Jaime Casanova <systemguards(at)gmail(dot)com>, Chris Hoover <revoohc(at)gmail(dot)com>, Michael Fuhr <mike(at)fuhr(dot)org>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: What happens to transactions durring a pg_dump?
Date: 2006-01-22 00:50:42
Message-ID: 2754.1137891042@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Bruno Wolff III <bruno(at)wolff(dot)to> writes:
> I don't think that is precisely correct. I believe that the snapshot isn't
> set until the first query is made within the transaction.

Right. Specifically, any statement *other* than those enumerated in
PortalRunUtility() will set the snapshot. As of CVS tip (and for
several past releases IIRC), that code looks like:

/*
* Set snapshot if utility stmt needs one. Most reliable way to do this
* seems to be to enumerate those that do not need one; this is a short
* list. Transaction control, LOCK, and SET must *not* set a snapshot
* since they need to be executable at the start of a serializable
* transaction without freezing a snapshot. By extension we allow SHOW
* not to set a snapshot. The other stmts listed are just efficiency
* hacks. Beware of listing anything that can modify the database --- if,
* say, it has to update an index with expressions that invoke
* user-defined functions, then it had better have a snapshot.
*/
if (!(IsA(utilityStmt, TransactionStmt) ||
IsA(utilityStmt, LockStmt) ||
IsA(utilityStmt, VariableSetStmt) ||
IsA(utilityStmt, VariableShowStmt) ||
IsA(utilityStmt, VariableResetStmt) ||
IsA(utilityStmt, ConstraintsSetStmt) ||
/* efficiency hacks from here down */
IsA(utilityStmt, FetchStmt) ||
IsA(utilityStmt, ListenStmt) ||
IsA(utilityStmt, NotifyStmt) ||
IsA(utilityStmt, UnlistenStmt) ||
IsA(utilityStmt, CheckPointStmt)))
ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
else
ActiveSnapshot = NULL;

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Ciprian Hodorogea 2006-01-22 20:41:27 pg_dump - txt sql vs binary
Previous Message Bruno Wolff III 2006-01-22 00:25:19 Re: What happens to transactions durring a pg_dump?