(linux/Centos 5.2, postgres 84beta1, but also 8.3)

Hello,

I ran into a bug in pg_restore, where it silently omits
to restore a constraint (here a primary key):


(this is 8.4 beta 1, but the same occurs in 8.3)

  echo "
    drop table if exists public.j;
    create table public.j (jnr integer NOT NULL primary key);
  " | psql -d test ;

  psql -d test -c "\d+ public.j"

  pg_dump -F c -f ./public_j.dump -t j test

  psql -d test -c "drop table if exists public.j; "

  pg_restore -v -c -d test -t j ./public_j.dump


The above will give the following output:

DROP TABLE
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "j_pkey" for 
table "j"
CREATE TABLE
                   Table "public.j"
 Column |  Type   | Modifiers | Storage | Description
--------+---------+-----------+---------+-------------
 jnr    | integer | not null  | plain   |
Indexes:
    "j_pkey" PRIMARY KEY, btree (jnr)
Has OIDs: no

DROP TABLE
pg_restore: connecting to database for restore
pg_restore: dropping TABLE j
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 1490; 1259 17135 TABLE j 
rijkers
pg_restore: [archiver (db)] could not execute query: ERROR:  table "j" does not 
exist
    Command was:
DROP TABLE public.j;
pg_restore: creating TABLE j
pg_restore: restoring data for table "j"
pg_restore: setting owner and privileges for TABLE j
WARNING: errors ignored on restore: 1
                   Table "public.j"
 Column |  Type   | Modifiers | Storage | Description
--------+---------+-----------+---------+-------------
 jnr    | integer | not null  | plain   |
Has OIDs: no



Result: table j gets restored, but without pk.

Although it can be easily worked around, I think this should have behaved 
differently.  It should
have given an error about not restoring the primary key.  ( Maybe it would even 
be preferrable if
it refused to do this incomplete restore).


thanks,

Erik Rijkers






-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to