Re: "xmin" system column

From: "Eric B(dot) Ridge" <ebr(at)tcdi(dot)com>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: "xmin" system column
Date: 2006-01-26 23:37:53
Message-ID: 4710D15A-3EF0-4559-A061-27ABB1594BA3@tcdi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Jan 26, 2006, at 5:22 PM, Michael Fuhr wrote:
> I suppose a sequence is out of the question? Too easy to get it
> wrong?

Well, I just wanted to avoid embedding this idea into my
application. Would rather Postgres take care of it for me.

> Not in the standard installation, but I think a C function that
> returns GetTopTransactionId() should work. It's trivial to write
> and examples have been posted before; search the archives.

Hmm. I also see GetCurrentTransactionStartTimestamp() in xact.h.
That could work as a mostly-unique identifier. Its value could
survive dumps (assuming clock is set correctly!) and a little wrapper
around it could be used by triggers or by default column values.

Futher reading in xact.c says:
/*
* This is the value of now(), ie, the transaction start time.
* This does not change as we enter and exit subtransactions, so we
don't
* keep it inside the TransactionState stack.
*/
static TimestampTz xactStartTimestamp;

<long pause>

hahaha, *blush*. I could just use "now()", right? pg8.1 docs say
that now()/CURRENT_TIMESTAMP "return the start time of the current
transaction; their values do not change during the transaction". I
could use a composite of (now(), GetTopTransctionId()) to assume
batch uniqueness.

eric

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bob Pawley 2006-01-26 23:50:11 Re: Arrays
Previous Message vishal saberwal 2006-01-26 23:19:41 Re: SYNTAX ERROR at or near SQLSTATE