Обсуждение: BUG #2588: rename table and dump bug

Поиск
Список
Период
Сортировка

BUG #2588: rename table and dump bug

От
"Evgeny Gridasov"
Дата:
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?

Re: BUG #2588: rename table and dump bug

От
Tom Lane
Дата:
"Evgeny Gridasov" <eugrid@fpm.kubsu.ru> writes:
> Is it a pg_dump bug or 'ALTER TABLE xxx RENAME TO xxx'  does not rename the
> corresponding sequences?

ALTER TABLE doesn't (and shouldn't IMHO) rename the sequence.  See
http://archives.postgresql.org/pgsql-hackers/2006-08/msg01250.php

            regards, tom lane

Re: BUG #2588: rename table and dump bug

От
Evgeny Gridasov
Дата:
So why then when I rename a table, pg_dump prints out the renamed table and renamed sequence,
but the database has only table renamed and the original sequence??

The reason I'm asking this is because after some table renaming I've got:
in database: table1 with sequence1, table2 with sequence2
in a dump: table1 with sequence2, table2 with sequence1

On Fri, 25 Aug 2006 09:24:54 -0400
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> "Evgeny Gridasov" <eugrid@fpm.kubsu.ru> writes:
> > Is it a pg_dump bug or 'ALTER TABLE xxx RENAME TO xxx'  does not rename the
> > corresponding sequences?
>
> ALTER TABLE doesn't (and shouldn't IMHO) rename the sequence.  See
> http://archives.postgresql.org/pgsql-hackers/2006-08/msg01250.php
>
>             regards, tom lane
>


--
Evgeny Gridasov
Software Engineer
I-Free, Russia