Re: [COMMITTERS] pgsql-server: Clean up generation of default

From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: Michael Glaesemann <grzm(at)myrealbox(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [COMMITTERS] pgsql-server: Clean up generation of default
Date: 2004-06-11 12:51:39
Message-ID: 40C9AADB.7010201@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

>>> 3. Or even create a pg_get_sequence() function:
>>> SELECT SETVAL(pg_get_sequence(schema.table, col), 17);
>>
>>
>> Actually, this is the best solution :)

OK, attached is a pg_get_serial_sequence(schema, table, column) function
. I have tested it with crazy names and it seems to be good. It works
like this:

SELECT setval(pg_get_serial_sequence('public', 'mytable', 'mycol'), 1,
false);

If someone approves it, i'll work on making it a built-in backend
function, and make pg_dump use it.

This will also be great for our app, since we would no longer have to
have hard-coded sequence names in our code. (For getting last sequence
val on oid-less tables)

Chris

Attachment Content-Type Size
pg_seq.txt text/plain 721 bytes

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2004-06-11 16:10:10 pgsql-server: Add URL about Win32 quoting behavior.
Previous Message Michael Glaesemann 2004-06-11 06:16:04 Re: [COMMITTERS] pgsql-server: Clean up generation of default

Browse pgsql-hackers by date

  From Date Subject
Next Message pgsql 2004-06-11 15:16:19 Re: Accelerating aggregates
Previous Message Darko Prenosil 2004-06-11 12:11:00 Another unpleasant surprise using inheritance