Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YdeMu-0002qw-3c for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Apr 2015 12:37:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YdeMt-00048s-68 for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Apr 2015 12:37:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YdeMs-00048V-GZ for pgsql-bugs@postgresql.org; Thu, 02 Apr 2015 12:37:06 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YdeMo-0000Ig-KL for pgsql-bugs@postgresql.org; Thu, 02 Apr 2015 12:37:05 +0000 MIME-Version: 1.0 Subject: BUG #12946: pg_dump/pg_restore not restore data for inherit tables To: pgsql-bugs@postgresql.org From: degtyaryov@gmail.com Date: Thu, 02 Apr 2015 12:36:44 +0000 Message-ID: <20150402123644.2573.95526@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.3 (/) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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