[sf-perl] PostgreSQL DBD ---- repost: sorry, I had the wrong subject in my previous post

David Fetter david at fetter.org
Fri Apr 1 09:10:06 PST 2005


On Fri, Apr 01, 2005 at 08:03:56AM -0800, Shane Hill wrote:
> > >
> > > I tried both 'public' and my username and I get the same result.
> > > nada.
> > 
> > Does the above work for you?
> 
> it does not.  I created the exact same table that is in your example
> and used your script without editing it and voila!  I get "d00d!
> wtf?!?"  but no id.  wah.
> 
> my client is using 7.4.5 and does not want to go to 8.0.1.  I see that
> you used 8.0.1. Could this be the problem?  have you tried your script
> on a 7xx server?

I don't have a 7xx server handy, but your client *needs* to upgrade to
7.4.7 because of known crash/data loss bugs in previous versions in
the 7.4 series.  Oh, and 8x is very nice. :)

> I have not looked yet, but is there a way to retrieve the name of
> the sequence associated with the serial column in a table?  This way
> I could just hide the details of getting the seq name, call curr_val
> and maintain the clean data interface I have been using.

I dug this out of the system catalogs with the help of psql -E.  This
is probably why people like to use abstraction layers ;)

SELECT
  (string_to_array(d.adsrc, '\''))[2]
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_attribute a
    ON (
        c.relname = 'foo_tab'
    AND
        c.oid = a.attrelid
    )
JOIN pg_catalog.pg_attrdef d
    ON (
        d.adsrc LIKE 'nextval%'
    AND
        d.adrelid = a.attrelid
    AND
        d.adnum = a.attnum
    )
;

> thanks for your help, I really appreciate it.

Hope this does.  Oh, and try talking your client into upgrading to
8.0x :)

Cheers,
D
-- 
David Fetter david at fetter.org http://fetter.org/
phone: +1 510 893 6100   mobile: +1 415 235 3778

Remember to vote!


More information about the SanFrancisco-pm mailing list