From: | Дмитрий Дегтярёв <degtyaryov(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #12946: pg_dump/pg_restore not restore data for inherit tables |
Date: | 2015-04-02 14:54:28 |
Message-ID: | CAFcrtwGu0+aOx4QbWE5iAtOfUZH6BGoX6+-5O4FhKzNPU+GfGg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
I'm sorry I made a mistake in the first case (# case 1)
Should be so:
test_inherits=> create table t1(a integer not null, b integer);
CREATE TABLE
test_inherits=> create table t2(a integer, b integer) inherits (t1);
NOTICE: merging column "a" with inherited definition
NOTICE: merging column "b" with inherited definition
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);
ERROR: null value in column "a" violates not-null constraint
DETAIL: Failing row contains (null, 1).
The problem with case 2 and case 3.
However, in accordance with the documentation
http://www.postgresql.org/docs/9.4/static/ddl-inherit.html(quote: "It must
also include check constraints with the same names and check expressions as
those of the parent."),
alter table t2 alter column a drop not null;
the result must be a error.
2015-04-02 18:49 GMT+05:00 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> degtyaryov(at)gmail(dot)com writes:
> > $ 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
>
> [ scratches head... ] When I do that, it refuses to insert into t2
> either:
>
> regression=# create table t1(a integer not null, b integer);
> CREATE TABLE
> regression=# create table t2(a integer, b integer) inherits (t1);
> NOTICE: merging column "a" with inherited definition
> NOTICE: merging column "b" with inherited definition
> CREATE TABLE
> regression=# insert into t1(a,b) values(null,1);
> ERROR: null value in column "a" violates not-null constraint
> DETAIL: Failing row contains (null, 1).
> regression=# insert into t2(a,b) values(null,1);
> ERROR: null value in column "a" violates not-null constraint
> DETAIL: Failing row contains (null, 1).
>
> This is the behavior I would expect, and I see it in all active
> branches. Have you modified the code around column inheritance?
>
> regards, tom lane
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2015-04-02 15:37:05 | Re: BUG #12946: pg_dump/pg_restore not restore data for inherit tables |
Previous Message | Tom Lane | 2015-04-02 13:49:50 | Re: BUG #12946: pg_dump/pg_restore not restore data for inherit tables |