Thread: Question about transactions and pg_log

Question about transactions and pg_log

From
Martijn van Oosterhout
Date:
From what I currently understand, there is a pg_log file in the postgres
data directory which indicates the state of transactions (committed or
uncommitted).

So from this I infer that transaction IDs are unique across a whole database
installation?

The reason I ask is that I rename the directories within the data directory
to rename a database. (I need to switch two databases reasonably quickly).
If transaction IDs (and hence entries within pg_log) are not shared then the
results would be catastrophic probably.

Any ideas?
--
Martijn van Oosterhout

Re: Question about transactions and pg_log

From
Tom Lane
Date:
Martijn van Oosterhout <martijn@ecomtel.com.au> writes:
> From what I currently understand, there is a pg_log file in the postgres
> data directory which indicates the state of transactions (committed or
> uncommitted).
> So from this I infer that transaction IDs are unique across a whole database
> installation?

Correct, and correct.

> The reason I ask is that I rename the directories within the data directory
> to rename a database. (I need to switch two databases reasonably quickly).
> If transaction IDs (and hence entries within pg_log) are not shared then the
> results would be catastrophic probably.

This strikes me as pretty darn dangerous in any case.  You could maybe
get away with it if you shutdown the postmaster first, but if you don't,
then you *will* get screwed by buffering considerations (open disk
buffers in shared memory are out of sync with the disk files after you
do the swap).

In 7.1 I believe you can rename a database just by updating its row in
pg_database.  You'd probably be far safer to run a 7.1 beta release and
do that, than to try to do it by renaming directories in previous
releases.

            regards, tom lane