sequence in schema -- broken default - Mailing list pgsql-general

From Lee Harr
Subject sequence in schema -- broken default
Date
Msg-id BAY2-F51Oqbdv3Hhl65000185f7@hotmail.com
Whole thread Raw
Responses Re: sequence in schema -- broken default  ("Joshua D. Drake" <jd@commandprompt.com>)
List pgsql-general
I must have a fundamental misunderstanding about using schema.

Before using schema, I usually have a file that has my database
definition, and I can play that file back in to a new database to
create a testing area or to create my production setup.

I think I want to use schema the same way.

My problem is using a sequence for a default value. I know that
if I use a serial instead, all of this will go away, but my design
already uses separate sequences, so I am hoping I will not need
to change it...

This illustrates the problem:


CREATE DATABASE d;
\c d

CREATE SCHEMA one;
SET search_path TO one;

CREATE SEQUENCE foo_seq;
CREATE TABLE foo(
    i integer
        DEFAULT nextval('foo_seq')
);


SET search_path TO public;

INSERT INTO foo VALUES (DEFAULT);



The problem is that the DEFAULT nextval(...  needs to qualify
the sequence with the schema, but I am not sure how to
determine the schema in my definition file.

Any hints?

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail


pgsql-general by date:

Previous
From:
Date:
Subject: Optimizing SQL: bind variables, prepared stms, histograms
Next
From: "Chris Boget"
Date:
Subject: Re: Touch row ?