sequence in schema -- broken default

From: "Lee Harr" <missive(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: sequence in schema -- broken default
Date: 2004-01-23 15:38:54
Message-ID: BAY2-F51Oqbdv3Hhl65000185f7@hotmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message CDE 2004-01-23 15:51:02 business references for postgresql
Previous Message lnd 2004-01-23 09:45:40 Optimizing SQL: bind variables, prepared stms, histograms