agora inbox for [email protected]  
help / color / mirror / Atom feed
From: Joshua D. Drake <[email protected]>
To: PostgreSQL-development <[email protected]>
Subject: pg_dump bug in 7.3.9 with sequences
Date: Wed, 02 Feb 2005 12:01:11 -0800
Message-ID: <[email protected]> (raw)

Hello,

Ran into this little gem with a customer today:

This works:

create table foo (foo int not null, bar text);
create sequence foo_seq;
alter table foo alter column foo set default nextval('foo_seq');

pg_dump will correctly dump the table:

CREATE TABLE foo (
    foo integer DEFAULT nextval('foo_seq'::text) NOT NULL,
    bar text
);


--
-- TOC entry 3 (OID 107565218)
-- Name: foo_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE foo_seq
    START 1
    INCREMENT 1
    MAXVALUE 9223372036854775807
    MINVALUE 1
    CACHE 1;

However if you do the following:

create table foo (foo serial not null, bar text);
create sequence foo_seq;
alter table foo alter column foo set default nextval('foo_seq');

pg_dump will give you the following:

CREATE TABLE foo (
    foo serial NOT NULL,
    bar text
);


--
-- TOC entry 3 (OID 107566148)
-- Name: foo_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE foo_seq
    START 1
    INCREMENT 1
    MAXVALUE 9223372036854775807
    MINVALUE 1
    CACHE 1;

Which is wrong because we want the column foo to use a default of foo_seq
not foo_foo_seq.

Sincerely,

Joshua D. Drake








-- 
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - [email protected] - http://www.commandprompt.com
PostgreSQL Replicator -- production quality replication for PostgreSQL



Attachments:

  [text/x-vcard] jd.vcf (285B, ../[email protected]/2-jd.vcf)
  download | inline:
begin:vcard
fn:Joshua Drake
n:Drake;Joshua
org:Command Prompt, Inc.
adr:;;PO Box 215 ;Cascade Locks;OR;97014;US
email;internet:[email protected]
title:Consultant
tel;work:503-667-4564
tel;fax:503-210-0334
x-mozilla-html:FALSE
url:http://www.commandprompt.com
version:2.1
end:vcard


view thread (15+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: pg_dump bug in 7.3.9 with sequences
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox