Re: pg_dump - wrong order with inheritance - Mailing list pgsql-bugs

From pinker
Subject Re: pg_dump - wrong order with inheritance
Date
Msg-id 1448379287033-5874925.post@n5.nabble.com
Whole thread Raw
In response to Re: pg_dump - wrong order with inheritance  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pg_dump - wrong order with inheritance  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Tom Lane-2 wrote
> FWIW, the reason I'm doubtful of your wrong-dump-order diagnosis is
> that it's pretty hard to see how a not-null violation would arise
> that way.  The subsequent complaints may only be consequences of
> that one.

i've just prepared test case and did some debugging. It turned out that the
issue isn't dump order but wrong ddl generated by pg_dump.

<pre>
CREATE TABLE a00
(
  id   INTEGER NOT NULL,
  name TEXT    NOT NULL,
  CONSTRAINT a00_pkey PRIMARY KEY (id)
)
WITH (
OIDS =FALSE
);

CREATE TABLE a03
(
  id   INTEGER NOT NULL,
  name TEXT    NOT NULL,
  CONSTRAINT a03_pkey PRIMARY KEY (id)
)

WITH (
OIDS =FALSE
);

ALTER TABLE a03
INHERIT a00;

ALTER TABLE a03
ALTER COLUMN name DROP NOT NULL;

</pre>

and now:
pg_dump testdump | psql testdump02

<pre>
COPY 0
ERROR:  null value in column "name" violates not-null constraint
DETAIL:  Failing row contains (1, null).
CONTEXT:  COPY a03, line 1: "1  \N"
</pre>

so pg_dump is trying to create table a03 this way:
<pre>
CREATE TABLE a03 (
    id integer,
    name text
)
INHERITS (a00);
</pre>

and don't takes into account that column name has changed.





--
View this message in context: http://postgresql.nabble.com/pg-dump-wrong-order-with-inheritance-tp5874794p5874925.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Confusing error message with too-large file in pg_basebackup
Next
From: Tom Lane
Date:
Subject: Re: pg_dump - wrong order with inheritance