pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: degtyaryov@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #12946: pg_dump/pg_restore not restore data for inherit tables
Date: Thu, 02 Apr 2015 12:36:44 +0000
Message-ID: <20150402123644.2573.95526@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      12946
Logged by:          Dmitriy
Email address:      degtyaryov@gmail.com
PostgreSQL version: 9.4.1
Operating system:   Fedora 21
Description:        

Hello.

There was an incident.

I perform
1. pg_dump	- succesful
2. dropdb	- succesful
3. createdb	- succesful
4. pg_restore	- failure

It was so.

# case 1
$ sudo su - postgres
$ createdb -O test -e -E UTF-8 test_inherits
CREATE DATABASE test_inherits OWNER test ENCODING 'UTF-8';
$ psql -U test -d test_inherits
test_inherits=> create table t1(a integer not null, b integer);
CREATE TABLE
test_inherits=> create table t2(a integer, b integer) inherits (t1);
CREATE TABLE
test_inherits=> insert into t1(a,b) values(null,1);
ERROR:  null value in column "a" violates not-null constraint
DETAIL:  Failing row contains (null, 1).
test_inherits=> insert into t2(a,b) values(null,1);
INSERT 0 1
test_inherits=> \q
$ pg_dump -U test -d test_inherits -F c > test.sql
$ dropdb test_inherits
$ createdb -O test -e -E UTF-8 test_inherits
CREATE DATABASE test_inherits OWNER test ENCODING 'UTF-8';
$ pg_restore -d test_inherits -F c test.sql
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 2912; 0 37803 TABLE DATA t2
test
pg_restore: [archiver (db)] COPY failed for table "t2": ERROR:  null value
in column "a" violates not-null constraint
DETAIL:  Failing row contains (null, 1).
CONTEXT:  COPY t2, line 1: "\N  1"
WARNING: errors ignored on restore: 1
$ dropdb test_inherits

# case 2
$ sudo su - postgres
$ createdb -O test -e -E UTF-8 test_inherits
CREATE DATABASE test_inherits OWNER test ENCODING 'UTF-8';
$ psql -U test -d test_inherits
test_inherits=> create table t1(a integer not null, b integer);
CREATE TABLE
test_inherits=> create table t2() inherits (t1);
CREATE TABLE
test_inherits=> alter table t2 alter column a drop not null;
ALTER TABLE
test_inherits=> insert into t1(a,b) values(null,1);
ERROR:  null value in column "a" violates not-null constraint
DETAIL:  Failing row contains (null, 1).
test_inherits=> insert into t2(a,b) values(null,1);
INSERT 0 1
test_inherits=> \q
$ pg_dump -U test -d test_inherits -F c > test.sql
$ dropdb test_inherits
$ createdb -O test -e -E UTF-8 test_inherits
CREATE DATABASE test_inherits OWNER test ENCODING 'UTF-8';
$ pg_restore -d test_inherits -F c test.sql
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 2912; 0 37803 TABLE DATA t2
test
pg_restore: [archiver (db)] COPY failed for table "t2": ERROR:  null value
in column "a" violates not-null constraint
DETAIL:  Failing row contains (null, 1).
CONTEXT:  COPY t2, line 1: "\N  1"
WARNING: errors ignored on restore: 1
$ dropdb test_inherits

# case 3
$ createdb -O test -e -E UTF-8 test_inherits
CREATE DATABASE test_inherits OWNER test ENCODING 'UTF-8';
$ psql -U test -d test_inherits
test_inherits=> create table t1(a integer not null, b integer);
CREATE TABLE
test_inherits=> create table t2(a integer not null, b integer);
CREATE TABLE
test_inherits=> alter table t2 inherit t1;
ALTER TABLE
test_inherits=> alter table t2 alter column a drop not null;
ALTER TABLE
test_inherits=> insert into t1(a,b) values(null,1);
ERROR:  null value in column "a" violates not-null constraint
DETAIL:  Failing row contains (null, 1).
test_inherits=> insert into t2(a,b) values(null,1);
INSERT 0 1
$ pg_dump -U test -d test_inherits > test.sql
$ dropdb test_inherits
$ createdb -O test -e -E UTF-8 test_inherits
CREATE DATABASE test_inherits OWNER test ENCODING 'UTF-8';
$ pg_restore -d test_inherits -F c test.sql
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 2912; 0 37803 TABLE DATA t2
test
pg_restore: [archiver (db)] COPY failed for table "t2": ERROR:  null value
in column "a" violates not-null constraint
DETAIL:  Failing row contains (null, 1).
CONTEXT:  COPY t2, line 1: "\N  1"
WARNING: errors ignored on restore: 1
$ dropdb test_inherits




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



view thread (4+ messages)  latest in thread

Message-ID: <20150402123644.2573.95526@wrigleys.postgresql.org>
Permalink:  ../20150402123644.2573.95526@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20150402123644.2573.95526@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: degtyaryov@gmail.com
  Subject: Re: BUG #12946: pg_dump/pg_restore not restore data for inherit tables
  In-Reply-To: <20150402123644.2573.95526@wrigleys.postgresql.org>
  References: <20150402123644.2573.95526@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox