restore-deadlock.sh

text/plain

Filename: restore-deadlock.sh
Type: text/plain
Part: 0
Message: Re: not null constraints, again
psql postgres <<EOF
CREATE DATABASE src;
\c src

CREATE TABLE parent1 (
    id integer PRIMARY KEY,
    b text
)
PARTITION BY LIST (id);

CREATE TABLE c11 PARTITION OF parent1 FOR VALUES IN (1);
CREATE TABLE c12 PARTITION OF parent1 FOR VALUES IN (2);

CREATE TABLE parent2 (
    id integer PRIMARY KEY,
    ref integer REFERENCES parent1,
    b text
)
PARTITION BY LIST (id);

CREATE TABLE c21 PARTITION OF parent2 FOR VALUES IN (1);
CREATE TABLE c22 PARTITION OF parent2 FOR VALUES IN (2);

INSERT INTO parent1 VALUES(1, 'foo');
INSERT INTO parent2 VALUES(2, 1, 'bar');
EOF

pg_dump src -f src.dump -Fc
createdb target
pg_restore src.dump -d target -j10