473,698 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with pg_dump and restoring sequences


Hi,

postgresql 7.4beta4 on linux
and postgresql 7.3.4 on linux

We have a database that we routinely backup using "pg_dump -a"
We have to do this (dump the data only) because of various characteristics of
the database (e.g. the dump file tries to create fks to tables that it hasn't
created yet if we export schema + data).

When we come to do a restore, the schema is created by running through our
*.sql files, and then we use psql to import the backed up data. However,
there is a problem with only 2 of the many sequences that psql tries to
restore:

here is a snippet of the lines that fail in the dump file:

-- start quote--
SET search_path = signal, pg_catalog;

--
-- TOC entry 2 (OID 169712)
-- Name: type_id_seq; Type: SEQUENCE SET; Schema: signal; Owner: martin
--
SELECT pg_catalog.setv al('type_id_seq ', 1, false);

--
-- TOC entry 3 (OID 169728)
-- Name: auto_id_seq; Type: SEQUENCE SET; Schema: signal; Owner: martin
--

SELECT pg_catalog.setv al('auto_id_seq ', 19, true); <------ FAILS
--
-- TOC entry 4 (OID 169745)
-- Name: instance_at_seq ; Type: SEQUENCE SET; Schema: signal; Owner: martin
--

SELECT pg_catalog.setv al('instance_at _seq', 41, true); <----- FAILS
-- end quote--

the failure messages are:
psql:db.backup: 42041: ERROR: relation "auto_id_se q" does not exist
psql:db.backup: 42049: ERROR: relation "instance_at_se q" does not exist

Now - to make it work all I have to do is edit the dump file and prepend the
schema name to the setval call for these 2 failing cases:

select pg_catalog.setv al('signal.auto _id_seq', 19, true); <----- WORKS

I initially thought that the schema name might have been the cause of the
problem, but changing it has no effect - so maybe it's the search path (but
notice that the first sequence [type_id_seq] works). I do create all tables
"without oids", maybe that's related?

It is most likely that the problem is with my code - but I can't see it. Here
is a \d of the two tables taken immediately before trying to import the data:

db=# \d signal.instance
Table "signal.instanc e"
Column | Type | Modifiers
---------+--------+----------------------------------------------------------
at | bigint | not null default nextval('signal .instance_at_se q'::text)
type_id | bigint | not null
f0 | text |
f1 | text |
f2 | text |
f3 | text |
f4 | text |
Indexes:
"instance_p key" primary key, btree ("at")
"instance_f 0" btree (f0)
"instance_type_ id" btree (type_id)
Foreign-key constraints:
"$1" FOREIGN KEY (type_id) REFERENCES signal."type"(i d)

db=# \d signal.auto
Table "signal.aut o"
Column | Type | Modifiers
-----------+---------+------------------------------------------------------
id | bigint | not null default nextval('signal .auto_id_seq':: text)
type_id | bigint | not null
schema | text | not null
relation | text | not null
fields | text |
criteria | text |
is_insert | boolean | not null default false
is_update | boolean | not null default false
is_delete | boolean | not null default false
Indexes:
"auto_pkey" primary key, btree (id)
Foreign-key constraints:
"$1" FOREIGN KEY (type_id) REFERENCES signal."type"(i d) ON DELETE CASCADE

also, both sequences do actually exist at this point :-)

What I do not understand is why it is only these 2 cases out of lots of
similar sequence setting that fail. I understand that I am probably not
providing enough information here for a diagnostic - this email is just to
test the water and see if anybody else has experienced similar problems.

I will start work on a test case to see if I can reproduce the behaviour with
a smaller input set. If so I'll post it - but I would be interested to hear
from anybody with similar experiences. At the moment this problem is
preventing us offering an "automatic backup and restore" :-(

TIA
Martin Hart
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #1
0 4874

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3754
by: Sam | last post by:
I'm having trouble restoring databases that have to lo type installed in /contrib/lo. The dump seems to work just fine, I get no errors when I execute the following command #pg_dump -Fc -o -b mydb > mydb_dump > CREATE DATABASE mydb_restore TEMPLATE template0
6
1707
by: Rajesh Kumar Mallah | last post by:
Hi, I face the following problem in transferring data from pgsql 7.3.4 to pgsql 7.4 RC1 . I am piping the output of pg_dumpall from 7.3 to 7.4 running on different port. The problem is there is a gist index on txtidx type on a non-public schema and when search_path does not include public the index cannot be created.
0
1443
by: Wind Wood | last post by:
Hello £¡ I can dump data from old dababase(Postgresql 6.5.3), but new problem came out when I restore the data to postgresql 7.4. It went out during the COPY command, if I do it in such command lines: 1. pg_dump news -f pgsql-database-news.sql #in old system with postgresql 6.5.3 2. su - postgres #in new system with postgresql 7.4 3. createdb -T template0 news 4. psql news < pgsql-database-news.sql ------
3
2700
by: mike | last post by:
I have just upgraded froom Fedora test1 to test2 which has upgraded postgres version from 7.4.2 to 7.4.5 (frrom rpm -q) I have used pg_dumpall to dump my database, the restore appeared to go OK, except there is no data in two of my tables (only these two) output from \d \d tb_invoice_header Table "public.tb_invoice_header" Column | Type
3
1898
by: Sean Shanny | last post by:
To all, We dumped our instance from a 7.4.2 instance compiled with a block size of 32k running on OSX 10.3.3 server.. We loaded this dump on Fedora 2.6.5-1.358smp running postgresql 7.4.2 compiled with the standard 8k blocks size. My problem is that all the sequences were reset to start a 1. :-( Did I do something wrong as this has never happened before? Also, can I simply figure out what the next value should be and manually...
1
3283
by: Ben-Nes Michael | last post by:
Hello Im getting strange errors when restoring data from pg_dump files: ERROR: duplicate key violates unique constraint "products_pkey" CONTEXT: COPY products, line 1: "98 Super Pak Ruby j&aacute;t&eacute;k J-0001 1502450E Szuper Pok&eacute;mon aj&aacute;nd&eacute;kcso..." ERROR: duplicate key violates unique constraint "attributes_pkey" CONTEXT: COPY attributes, line 1: "2 Width" ERROR: duplicate key violates...
6
11298
by: Soeren Gerlach | last post by:
Hi, some weeks ago I started to develop an application using Postgresql the first time. I'm running 7.4.3 on a Linux box with a plain 2.6.7 kernel, the storage is handled by 5 SATA disks, managed by a 3ware controller and using a xfs filesystem. The DB server is a 3 Ghz P4 with 4 Gig of Ram, so the machine is quite fast for most purposes I need it; the DB server is a pure DB server, theres no application running on it. I dump and...
1
1843
by: Plant Thomas | last post by:
Hi, I have a problem restoring a database from Postgresql 7.3 ( backup created with 'pg_dump -Ft -b > test.tar' ) to a new database on PostgreSQL 7.4.3 on Cygwin. I get the following error: pg_restore: executing SEQUENCE SET t_tab_kurs_template_id_seq pg_restore: could not execute query: ERROR: relation "t_tab_kur s_template_id_seq" does not exist pg_restore: *** aborted because of error
0
1227
by: Stefano Bonnin | last post by:
Hi, I'm a Postgis user, and I have a problem restoring data from 7.4 to 8.0..0beta2. I use the postgis_restore.pl script that comes with postgis distribution. I do the following for the dump: pg_dump -Fc mydb >mydb.sql and the script does the following restore operations: .... some commands ... open( PSQL, "| ./psql -a dbname") || die "Can't run psql\n";
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.