Skip site navigation (1) Skip section navigation (2)

pg_dump bug in 7.3.9 with sequences

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_dump bug in 7.3.9 with sequences
Date: 2005-02-02 20:01:11
Message-ID: 42013187.7040806@commandprompt.com (view raw or flat)
Thread:
Lists: pgsql-hackers
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 - jd(at)commandprompt(dot)com - http://www.commandprompt.com
PostgreSQL Replicator -- production quality replication for PostgreSQL


Attachment: jd.vcf
Description: text/x-vcard (285 bytes)

Responses

pgsql-hackers by date

Next:From: Merlin MoncureDate: 2005-02-02 20:19:27
Subject: Re: [NOVICE] Last ID Problem
Previous:From: Greg StarkDate: 2005-02-02 19:35:24
Subject: Re: [NOVICE] Last ID Problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group