pg_dump fails to include sequences, leads to restore fail in any version - Mailing list pgsql-hackers
From | Jeffrey Baker |
---|---|
Subject | pg_dump fails to include sequences, leads to restore fail in any version |
Date | |
Msg-id | fd145f7d0806170953n380b6cadvfe14d6ca384da647@mail.gmail.com Whole thread Raw |
Responses |
Re: pg_dump fails to include sequences, leads to restore fail in any version
|
List | pgsql-hackers |
It is impossible to dump (with pg_dump -Ocx) and restore (with psql) a database which contains sequences in any of 8.1, 8.2,or 8.3:<br /><br />[...]<br /><br />--<br />-- Name: transaction_transaction_id_seq; Type: SEQUENCE SET; Schema: mercado;Owner: prod<br /> --<br /><br />SELECT pg_catalog.setval(pg_catalog.pg_get_serial_sequence('transaction_backup','transaction_id'), 6736138, true);<br /><br /><br/>--<br />-- Name: transaction; Type: TABLE; Schema: mercado; Owner: prod; Tablespace: <br /> --<br /><br />CREATE TABLE"transaction" (<br /> transaction_id integer DEFAULT nextval('transaction_transaction_id_seq'::regclass) NOT NULL,<br/> buyer_account_id integer,<br /> seller_account_id integer,<br /> date date,<br /> item_id integer,<br/> source text<br />);<br /><br />[...]<br /><br />2008-06-16 19:26:41 PDT ERROR: relation "transaction_transaction_id_seq"does not exist<br /><br />Why? Because pg_dump mysteriously omits all sequences:<br /><br/>think=# \d transaction_transaction_id_seq <br />Sequence "mercado.transaction_transaction_id_seq"<br /> Column | Type <br />---------------+---------<br /> sequence_name | name<br /> last_value | bigint<br /> increment_by | bigint<br /> max_value | bigint<br /> min_value | bigint<br /> cache_value | bigint<br /> log_cnt | bigint<br /> is_cycled | boolean<br /> is_called | boolean<br /><br />think=# \ds<br /> List of relations<br /> Schema | Name | Type | Owner <br />---------+------------------------------------+----------+-------<br/> mercado | account_account_id_seq | sequence| prod<br /> mercado | account_stat_account_stat_id_seq | sequence | prod<br /> mercado | category_category_id_seq | sequence | prod<br /> mercado | category_stat_category_stat_id_seq | sequence | prod<br/> mercado | country_country_id_seq | sequence | prod<br /> mercado | country_stat_country_stat_id_seq | sequence | prod<br /> mercado | dict_dict_id_seq | sequence | prod<br/> mercado | expire_icon_expire_icon_id_seq | sequence | prod<br /> mercado | expire_time_expire_time_id_seq | sequence | prod<br /> mercado | fx_fx_id_seq | sequence | prod<br/> mercado | icon_icon_id_seq | sequence | prod<br /> mercado | item_icon_item_icon_id_seq | sequence | prod<br /> mercado | item_item_id_seq | sequence | prod<br/> mercado | item_stat_item_stat_id_seq | sequence | prod<br /> mercado | transaction_transaction_id_seq | sequence | prod<br />(15 rows)<br /><br />postgres@think:~$ pg_dump -s -n mercado think| grep CREATE\ SEQUENCE<br />postgres@think:~$ <br /><br />Therefore when the restore is attempted, the table usingthe sequence as default value cannot be created.<br />
pgsql-hackers by date: