Re: "xmin" system column

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Eric B(dot) Ridge" <ebr(at)tcdi(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: "xmin" system column
Date: 2006-01-26 22:19:20
Message-ID: 24902.1138313960@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Eric B. Ridge" <ebr(at)tcdi(dot)com> writes:
> That's what I was afraid of. I've pondering making a "grouping"
> column that gets set to "xmin" via an UPDATE trigger. At least I'd
> have a constant value that would survive database dumps and reloads.

That will most assuredly NOT work. You will have XID conflicts if
you reload into a different instance of Postgres, or even within the
same instance once it's been running long enough to wrap XIDs around.

> I really need a way to create a unique identifier at the start of a
> top-level transaction, and be able to use it via triggers and/or
> column default values in that or its subtransactions.

The only thing I can see that would work for you is to nextval() some
sequence object at the start of each transaction, and then store its
currval() wherever you need it. As long as you store int8 not int4 or
xid values, this would be reasonably proof against wraparound issues.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2006-01-26 22:22:50 Re: "xmin" system column
Previous Message Bruce Momjian 2006-01-26 22:09:34 Re: [HACKERS] [GENERAL] [PATCH] Better way to check for getaddrinfo