Re: What happens to transactions durring a pg_dump? - Mailing list pgsql-admin

From Tom Lane
Subject Re: What happens to transactions durring a pg_dump?
Date
Msg-id 2754.1137891042@sss.pgh.pa.us
Whole thread Raw
In response to Re: What happens to transactions durring a pg_dump?  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-admin
Bruno Wolff III <bruno@wolff.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

pgsql-admin by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: PostgreSQL Lite Version
Next
From: "Ciprian Hodorogea"
Date:
Subject: pg_dump - txt sql vs binary