From: jan.dirk.zijlstra@redwood.com
To: pgsql-bugs@postgresql.org
Subject: BUG #13779: Inherited check constraint becomes non-inherited when related column is changed
Date: Thu, 19 Nov 2015 09:41:26 +0000
Message-ID: <20151119094126.2574.12966@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: 13779
Logged by: Jan Dirk Zijlstra
Email address: jan.dirk.zijlstra@redwood.com
PostgreSQL version: 9.4.5
Operating system: Linux
Description:
create table parenttable (a numeric, b numeric);
create table childtable () inherits (parenttable);
alter table parenttable add constraint parentconstraint_a check (a > 0);
alter table parenttable add constraint parentconstraint_b check (b > 0);
\d+ parenttable
\d+ childtable
select t.relname, c.conname, c.coninhcount, c.conislocal, c.connoinherit
from pg_constraint c, pg_class t where c.conname like 'parentconstraint%'
and c.conrelid = t.oid;
alter table parenttable alter column a set data type real ;
\d+ parenttable
\d+ childtable
select t.relname, c.conname, c.coninhcount, c.conislocal, c.connoinherit
from pg_constraint c, pg_class t where c.conname like 'parentconstraint%'
and c.conrelid = t.oid;
drop table childtable;
drop table parenttable;
When executing the commands above, you'll notice that you have in the end a
child table with a constraint which is not inherited anymore.
This gives issues, because
- you cannot drop the constraint on the parent table anymore.
( psql:tp.sql:86: ERROR: relation 23724254 has non-inherited constraint
"parentconstraint_a" )
- you can drop the constraint on the child table, but than you can again not
drop the constraint on the parent anymore.
(psql:tp.sql:90: ERROR: constraint "parentconstraint_a" of relation
"childtable" does not exist)
- you cannot uninherit the child
(psql:tp.sql:103: ERROR: relation 23724399 has non-inherited constraint
"parentconstraint_a")
To come out of this situation, I need to
- drop the local constraint on the child table
- drop the inheritance from the child table
- drop the local constraint on the parent table
- restore the inheritance on the child table
- create the constraint again on the parent table.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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: jan.dirk.zijlstra@redwood.com
Subject: Re: BUG #13779: Inherited check constraint becomes non-inherited when related column is changed
In-Reply-To: <20151119094126.2574.12966@wrigleys.postgresql.org>
References: <20151119094126.2574.12966@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