Re: Using generate_series to create a unique ID in a query?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: depesz(at)depesz(dot)com
Cc: Sarah Dougherty <sdougherty(at)desc(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: Using generate_series to create a unique ID in a query?
Date: 2007-11-14 15:44:59
Message-ID: 24191.1195055099@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hubert depesz lubaczewski <depesz(at)depesz(dot)com> writes:
> On Wed, Nov 14, 2007 at 10:26:52AM -0500, Tom Lane wrote:
>> That's a fairly ugly/messy way of doing it. If you're going to need a C
>> function anyway, why not just do it directly? As in the attachment.

> actually you dont have to do it in c.
> alec pointed (in comments) that there already is statement_timestamp()
> function, so you can remove the c code, and use statement_timestamp()
> instead of get_statement_timestamp().

Using statement_timestamp that way at all is pretty horrid, because
it has approximately zip to do with the concept of a query. For
instance your approach would fail in a query used inside a function that
is called more than once in a user-issued command. Nor do I care for
the idea that the user should have to assign a distinct name to each
use of the function. Lastly, statement_timestamp isn't there at all
before 8.2 ...

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2007-11-14 16:12:11 Re: reserving space in a rec for future update
Previous Message hubert depesz lubaczewski 2007-11-14 15:36:44 Re: Using generate_series to create a unique ID in a query?