pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause
4+ messages / 3 participants
[nested] [flat]

* BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause
@ 2017-04-21 18:40 buschmann@nidsa.net
  2017-04-24 04:16 ` Re: BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
  0 siblings, 1 reply; 4+ messages in thread

From: buschmann@nidsa.net @ 2017-04-21 18:40 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      14629
Logged by:          Hans Buschmann
Email address:      buschmann@nidsa.net
PostgreSQL version: 9.6.2
Operating system:   Windows x64
Description:        


Given these both tables (orders_archiv inherits orders) on 9.6.2 Windows
x64
(cut/paste from psql)

xxxdb=# \d orders_archiv;
...
Check constraints:
    "ck_or_old" CHECK (or_season < 24) NO INHERIT
Inherits: orders


xxxdb=# \d orders
...
Check constraints:
    "ck_or_new" CHECK (or_season >= 24) NO INHERIT NOT VALID
Triggers:
    tr_orders_insert BEFORE INSERT ON orders FOR EACH ROW WHEN
(new.or_season < 24) EXECUTE PROCEDURE fn_orders_insert()
Number of child tables: 1 (Use \d+ to list them.)


When applying these commands to the parent table, the following errors are
returned:

xxxdb=# alter table orders validate constraint ck_or_new;
ERROR:  constraint "ck_or_new" of relation "orders_archiv" does not exist


xxxdb=# alter table only orders validate constraint ck_or_new;
ERROR:  constraint must be validated on child tables too

Background:
From our original partitioning of quite a lot of tables according to
xx_season columns (a season is a half year period) I dropped and recreated
the check constraintsin a not valid state.

At the end of the script to move the data from 2 seasons into the archiv
tables I tried to reenable the check constraints and encountered those two
errors.

It seems that I can circumvent these errors by recreating the constraints
without the not valid clause.

Do I miss something here ?

Hans Buschmann





-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause
  2017-04-21 18:40 BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause buschmann@nidsa.net
@ 2017-04-24 04:16 ` Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
  2017-04-27 00:16   ` Re: [BUGS] BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
  2017-04-28 19:00   ` Re: BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause Robert Haas <robertmhaas@gmail.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Amit Langote @ 2017-04-24 04:16 UTC (permalink / raw)
  To: buschmann@nidsa.net; pgsql-bugs

On 2017/04/22 3:40, buschmann@nidsa.net wrote:
> The following bug has been logged on the website:
> 
> Bug reference:      14629
> Logged by:          Hans Buschmann
> Email address:      buschmann@nidsa.net
> PostgreSQL version: 9.6.2
> Operating system:   Windows x64
> Description:        
> 
> 
> Given these both tables (orders_archiv inherits orders) on 9.6.2 Windows
> x64
> (cut/paste from psql)
> 
> xxxdb=# \d orders_archiv;
> ...
> Check constraints:
>     "ck_or_old" CHECK (or_season < 24) NO INHERIT
> Inherits: orders
> 
> 
> xxxdb=# \d orders
> ...
> Check constraints:
>     "ck_or_new" CHECK (or_season >= 24) NO INHERIT NOT VALID
> Triggers:
>     tr_orders_insert BEFORE INSERT ON orders FOR EACH ROW WHEN
> (new.or_season < 24) EXECUTE PROCEDURE fn_orders_insert()
> Number of child tables: 1 (Use \d+ to list them.)
> 
> 
> When applying these commands to the parent table, the following errors are
> returned:
> 
> xxxdb=# alter table orders validate constraint ck_or_new;
> ERROR:  constraint "ck_or_new" of relation "orders_archiv" does not exist
> 
> 
> xxxdb=# alter table only orders validate constraint ck_or_new;
> ERROR:  constraint must be validated on child tables too
> 
> Background:
> From our original partitioning of quite a lot of tables according to
> xx_season columns (a season is a half year period) I dropped and recreated
> the check constraintsin a not valid state.
> 
> At the end of the script to move the data from 2 seasons into the archiv
> tables I tried to reenable the check constraints and encountered those two
> errors.
> 
> It seems that I can circumvent these errors by recreating the constraints
> without the not valid clause.
> 
> Do I miss something here ?

Looks indeed like a bug to me.  Performing VALIDATE CONSTRAINT on what is
a non-inheritable constraint shouldn't look for that constraint in the
child tables.  Attached patch fixes that.  Should be applied in all of the
supported branches.

Thanks,
Amit

Attachments:

  [text/x-diff] 0001-Fix-VALIDATE-CONSTRAINT-to-consider-NO-INHERIT-attri.patch (0B, ../../2035f652-cc33-3607-45b3-a024fdc9d47f@lab.ntt.co.jp/2-0001-Fix-VALIDATE-CONSTRAINT-to-consider-NO-INHERIT-attri.patch)
  download

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [BUGS] BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause
  2017-04-21 18:40 BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause buschmann@nidsa.net
  2017-04-24 04:16 ` Re: BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
@ 2017-04-27 00:16   ` Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
  1 sibling, 0 replies; 4+ messages in thread

From: Amit Langote @ 2017-04-27 00:16 UTC (permalink / raw)
  To: buschmann@nidsa.net, pgsql-bugs@postgresql.org, Pg Hackers <pgsql-hackers@postgresql.org>

On 2017/04/24 13:16, Amit Langote wrote:
> On 2017/04/22 3:40, buschmann@nidsa.net wrote:
>> The following bug has been logged on the website:
>>
>> Bug reference:      14629
>> Logged by:          Hans Buschmann
>> Email address:      buschmann@nidsa.net
>> PostgreSQL version: 9.6.2
>> Operating system:   Windows x64
>> Description:        
>>
>>
>> Given these both tables (orders_archiv inherits orders) on 9.6.2 Windows
>> x64
>> (cut/paste from psql)
>>
>> xxxdb=# \d orders_archiv;
>> ...
>> Check constraints:
>>     "ck_or_old" CHECK (or_season < 24) NO INHERIT
>> Inherits: orders
>>
>>
>> xxxdb=# \d orders
>> ...
>> Check constraints:
>>     "ck_or_new" CHECK (or_season >= 24) NO INHERIT NOT VALID
>> Triggers:
>>     tr_orders_insert BEFORE INSERT ON orders FOR EACH ROW WHEN
>> (new.or_season < 24) EXECUTE PROCEDURE fn_orders_insert()
>> Number of child tables: 1 (Use \d+ to list them.)
>>
>>
>> When applying these commands to the parent table, the following errors are
>> returned:
>>
>> xxxdb=# alter table orders validate constraint ck_or_new;
>> ERROR:  constraint "ck_or_new" of relation "orders_archiv" does not exist
>>
>>
>> xxxdb=# alter table only orders validate constraint ck_or_new;
>> ERROR:  constraint must be validated on child tables too
>>
>> Background:
>> From our original partitioning of quite a lot of tables according to
>> xx_season columns (a season is a half year period) I dropped and recreated
>> the check constraintsin a not valid state.
>>
>> At the end of the script to move the data from 2 seasons into the archiv
>> tables I tried to reenable the check constraints and encountered those two
>> errors.
>>
>> It seems that I can circumvent these errors by recreating the constraints
>> without the not valid clause.
>>
>> Do I miss something here ?
> 
> Looks indeed like a bug to me.  Performing VALIDATE CONSTRAINT on what is
> a non-inheritable constraint shouldn't look for that constraint in the
> child tables.  Attached patch fixes that.  Should be applied in all of the
> supported branches.

Should have included -hackers when posting the patch.  Here it is again
for -hackers' perusal.

Thanks,
Amit

Attachments:

  [text/x-diff] 0001-Fix-VALIDATE-CONSTRAINT-to-consider-NO-INHERIT-attri.patch (0B, ../../183ee5e0-c2c9-fe41-8cb1-e8328a20194d@lab.ntt.co.jp/2-0001-Fix-VALIDATE-CONSTRAINT-to-consider-NO-INHERIT-attri.patch)
  download

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause
  2017-04-21 18:40 BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause buschmann@nidsa.net
  2017-04-24 04:16 ` Re: BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
@ 2017-04-28 19:00   ` Robert Haas <robertmhaas@gmail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Robert Haas @ 2017-04-28 19:00 UTC (permalink / raw)
  To: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>; +Cc: Hans Buschmann <buschmann@nidsa.net>; pgsql-bugs

On Mon, Apr 24, 2017 at 12:16 AM, Amit Langote
<Langote_Amit_f8@lab.ntt.co.jp> wrote:
> On 2017/04/22 3:40, buschmann@nidsa.net wrote:
>> The following bug has been logged on the website:
>>
>> Bug reference:      14629
>> Logged by:          Hans Buschmann
>> Email address:      buschmann@nidsa.net
>> PostgreSQL version: 9.6.2
>> Operating system:   Windows x64
>> Description:
>>
>>
>> Given these both tables (orders_archiv inherits orders) on 9.6.2 Windows
>> x64
>> (cut/paste from psql)
>>
>> xxxdb=# \d orders_archiv;
>> ...
>> Check constraints:
>>     "ck_or_old" CHECK (or_season < 24) NO INHERIT
>> Inherits: orders
>>
>>
>> xxxdb=# \d orders
>> ...
>> Check constraints:
>>     "ck_or_new" CHECK (or_season >= 24) NO INHERIT NOT VALID
>> Triggers:
>>     tr_orders_insert BEFORE INSERT ON orders FOR EACH ROW WHEN
>> (new.or_season < 24) EXECUTE PROCEDURE fn_orders_insert()
>> Number of child tables: 1 (Use \d+ to list them.)
>>
>>
>> When applying these commands to the parent table, the following errors are
>> returned:
>>
>> xxxdb=# alter table orders validate constraint ck_or_new;
>> ERROR:  constraint "ck_or_new" of relation "orders_archiv" does not exist
>>
>>
>> xxxdb=# alter table only orders validate constraint ck_or_new;
>> ERROR:  constraint must be validated on child tables too
>>
>> Background:
>> From our original partitioning of quite a lot of tables according to
>> xx_season columns (a season is a half year period) I dropped and recreated
>> the check constraintsin a not valid state.
>>
>> At the end of the script to move the data from 2 seasons into the archiv
>> tables I tried to reenable the check constraints and encountered those two
>> errors.
>>
>> It seems that I can circumvent these errors by recreating the constraints
>> without the not valid clause.
>>
>> Do I miss something here ?
>
> Looks indeed like a bug to me.  Performing VALIDATE CONSTRAINT on what is
> a non-inheritable constraint shouldn't look for that constraint in the
> child tables.  Attached patch fixes that.  Should be applied in all of the
> supported branches.

Done.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2017-04-28 19:00 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-04-21 18:40 BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause buschmann@nidsa.net
2017-04-24 04:16 ` Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
2017-04-27 00:16   ` Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
2017-04-28 19:00   ` Robert Haas <robertmhaas@gmail.com>

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