Re: Compatible Dumps - Mailing list pgsql-general

From Richard Huxton
Subject Re: Compatible Dumps
Date
Msg-id 4227245A.2080309@archonet.com
Whole thread Raw
In response to Re: Compatible Dumps  (Jake Stride <nsuk@users.sourceforge.net>)
Responses Re: Compatible Dumps  (Greg Stark <gsstark@mit.edu>)
List pgsql-general
Jake Stride wrote:
> That helps a bit, but I still have the following issue:
>
> ERROR:  function pg_catalog.pg_get_serial_sequence("unknown", "unknown")
> does not exist
>
> Any ideas how to get around this?

Hmm - before 8.0 there wasn't an easy way to figure out the name of a
sequence attached to a column. This function is the easy way to do that,
but is (of course) not present in 7.x

Assuming your sequences all have default names, and are in the public
schema, you could write a simple function:

CREATE FUNCTION my_pg_get_serial_sequence(text,text) RETURNS text AS '
   SELECT ''public.'' || $1 || ''_'' || $2 || ''_seq'';
' LANGUAGE SQL;

Then a quick bit of sed/perl search & replace-ing and you're away.

This *will* break if the target table (1st param) is in a different
schema than public, or if you have non-default sequence names.
--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Jake Stride
Date:
Subject: Re: Compatible Dumps
Next
From: Tom Lane
Date:
Subject: Re: [Auth] "ident" method and LDAP user accounts