Skip site navigation (1) Skip section navigation (2)

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

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
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 06:16:04
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-committerspgsql-hackers
On Jun 11, 2004, at 1:02 PM, Christopher Kings-Lynne wrote:

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

John Hansen and I worked this up. It works, though it's not 
schema-aware, afaict.

create or replace function last_val(
     text     -- tablename
     , text   -- colname
     ) returns bigint
     language 'sql' as '
     select currval(
             split_part(adsrc,\'\'\'\',2) as seq
         from pg_class
         join pg_attribute on (pg_class.oid = pg_attribute.attrelid)
         join pg_attrdef
             on (pg_attrdef.adnum = pg_attribute.attnum
             and pg_attrdef.adrelid = pg_attribute.attrelid)
         where pg_class.relname = $1
             and pg_attribute.attname = $2)

Might be a starting point.

Michael Glaesemann
grzm myrealbox com

In response to


pgsql-hackers by date

Next:From: Alvaro HerreraDate: 2004-06-11 07:07:58
Subject: Re: Nested transactions and tuple header info
Previous:From: Tom LaneDate: 2004-06-11 05:28:35
Subject: Re: More vacuum.c refactoring

pgsql-committers by date

Next:From: Christopher Kings-LynneDate: 2004-06-11 12:51:39
Subject: Re: [COMMITTERS] pgsql-server: Clean up generation of default
Previous:From: Bruce MomjianDate: 2004-06-11 04:17:25
Subject: pgsql-server: Another fix for Win32 START.

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group