The following bug has been logged online:
Bug reference: 2588
Logged by: Evgeny Gridasov
Email address: eugrid@fpm.kubsu.ru
PostgreSQL version: 8.1.4-cvs
Operating system: linux debian
Description: rename table and dump bug
Details:
test=# create table tseq1(id serial);
NOTICE: CREATE TABLE will create implicit sequence "tseq1_id_seq" for
serial column "tseq1.id"
CREATE TABLE
test=# \d tseq1
Table "public.tseq1"
Column | Type | Modifiers
--------+---------+----------------------------------------------------
id | integer | not null default nextval('tseq1_id_seq'::regclass)
test=# alter table tseq1 rename to tseq2;
ALTER TABLE
test=# \d tseq2
Table "public.tseq2"
Column | Type | Modifiers
--------+---------+----------------------------------------------------
id | integer | not null default nextval('tseq1_id_seq'::regclass)
everything is ok.
now let's dump it:
eugene@deepcore:~$ pg_dump -t tseq2 -U postgres test
--
-- PostgreSQL database dump
--
SET client_encoding = 'UTF8';
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: tseq2; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE tseq2 (
id serial NOT NULL
);
ALTER TABLE public.tseq2 OWNER TO postgres;
--
-- Name: tseq1_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval(pg_catalog.pg_get_serial_sequence('tseq2', 'id'),
1, false);
--
-- Data for Name: tseq2; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY tseq2 (id) FROM stdin;
\.
--
-- PostgreSQL database dump complete
--
As you can see, dump contains sequence named tseq2_id_seq, but not
tseq1_id_seq as in real database.
Is it a pg_dump bug or 'ALTER TABLE xxx RENAME TO xxx' does not rename the
corresponding sequences?