Lists: | pgsql-bugs |
---|
From: | Noah Misch <noah(at)leadboat(dot)com> |
---|---|
To: | Amit Kapila <amit(dot)kapila(at)huawei(dot)com> |
Cc: | miroslav(dot)sulc(at)fordfrog(dot)com, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table |
Date: | 2012-07-15 21:23:44 |
Message-ID: | 20120715212344.GA7475@tornado.leadboat.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
On Mon, Jul 02, 2012 at 04:16:31PM +0530, Amit Kapila wrote:
> > From: pgsql-bugs-owner(at)postgresql(dot)org [mailto:pgsql-bugs-owner(at)postgresql(dot)org] On Behalf Of miroslav(dot)sulc(at)fordfrog(dot)com
> > Sent: Saturday, June 30, 2012 4:28 PM
> > test=# create table test_constraints (id int, val1 varchar, val2 int, unique
> > (val1, val2));
> > NOTICE: CREATE TABLE / UNIQUE will create implicit index
> > "test_constraints_val1_val2_key" for table "test_constraints"
> > CREATE TABLE
> > test=# create table test_constraints_inh () inherits (test_constraints);
> > CREATE TABLE
> > test=# alter table only test_constraints drop constraint
> > test_constraints_val1_val2_key;
> > ERROR: constraint "test_constraints_val1_val2_key" of relation
> > "test_constraints_inh" does not exist
> > postgresql tries to drop the constraint even from descendant table though
> > "only" is specified.
ONLY shouldn't be necessary, either.
> In function ATExecDropConstraint(), for the constarint "test_constraints_val1_val2_key" con->connoinherit is false,
> due to which it tries to drop the constrint from child table as well.
> I have checked that from function index_constraint_create() when it calls function CreateConstraintEntry(), the flag for noinherit passed is false.
> I think this is the reason of failure for the same.
Agreed. The other non-CHECK callers also get this wrong:
[local] regression=# select contype,connoinherit,count(*) from pg_constraint group by 1,2;
contype | connoinherit | count
---------+--------------+-------
p | f | 7
x | f | 2
c | f | 17
f | f | 5
One can construct similar bugs around dropping foreign key and exclusion
constraints. Though it may be irrelevant for command semantics, additionally
using connoinherit = 't' for contype = 't' (CONSTRAINT_TRIGGER) would
more-accurately represent the nature of those constraints.
Care to prepare a patch with a test case addition?
Thanks,
nm
From: | Amit Kapila <amit(dot)kapila(at)huawei(dot)com> |
---|---|
To: | "'Noah Misch'" <noah(at)leadboat(dot)com> |
Cc: | <miroslav(dot)sulc(at)fordfrog(dot)com>, <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table |
Date: | 2012-07-16 08:14:52 |
Message-ID: | 005c01cd632b$13e1c880$3ba55980$@kapila@huawei.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
From: Noah Misch [mailto:noah(at)leadboat(dot)com]
Sent: Monday, July 16, 2012 2:54 AM
> > From: pgsql-bugs-owner(at)postgresql(dot)org
[mailto:pgsql-bugs-owner(at)postgresql(dot)org] On Behalf Of
miroslav(dot)sulc(at)fordfrog(dot)com
> > Sent: Saturday, June 30, 2012 4:28 PM
> Care to prepare a patch with a test case addition?
Yes. I have started working.
With Regards,
Amit Kapila.
From: | Amit Kapila <amit(dot)kapila(at)huawei(dot)com> |
---|---|
To: | "'Noah Misch'" <noah(at)leadboat(dot)com> |
Cc: | <miroslav(dot)sulc(at)fordfrog(dot)com>, <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table |
Date: | 2012-07-16 11:19:46 |
Message-ID: | 006001cd6344$e879ba30$b96d2e90$@kapila@huawei.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
From: Noah Misch [mailto:noah(at)leadboat(dot)com]
Sent: Monday, July 16, 2012 2:54 AM
> One can construct similar bugs around dropping foreign key and exclusion
> constraints. Though it may be irrelevant for command semantics,
additionally
> using connoinherit = 't' for contype = 't' (CONSTRAINT_TRIGGER) would
> more-accurately represent the nature of those constraints.
Code Changes
----------------
I will make changes in following functions to ensure that connoinherit
should be appropriately set(pass the value as true).
a. index_constraint_create()
b. ATAddForeignKeyConstraint()
c. CreateTrigger().
Other places I have checked seems to be fine.
Test
--------
I will create testcases similar to mentioned in bug report for
a. unique key case, same as in bug-report
b. foreign key case
c. exclusion constraint case
> Care to prepare a patch with a test case addition?
Let me know if above is sufficient or shall I include anything more in
patch.
With Regards,
Amit Kapila.
From: | Noah Misch <noah(at)leadboat(dot)com> |
---|---|
To: | Amit Kapila <amit(dot)kapila(at)huawei(dot)com> |
Cc: | miroslav(dot)sulc(at)fordfrog(dot)com, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table |
Date: | 2012-07-16 15:12:01 |
Message-ID: | 20120716151201.GC7475@tornado.leadboat.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
On Mon, Jul 16, 2012 at 04:49:46PM +0530, Amit Kapila wrote:
> Code Changes
> ----------------
> I will make changes in following functions to ensure that connoinherit
> should be appropriately set(pass the value as true).
> a. index_constraint_create()
> b. ATAddForeignKeyConstraint()
> c. CreateTrigger().
>
> Other places I have checked seems to be fine.
Looks right.
> Test
> --------
> I will create testcases similar to mentioned in bug report for
> a. unique key case, same as in bug-report
Good.
> b. foreign key case
> c. exclusion constraint case
Test coverage for those is optional.
> > Care to prepare a patch with a test case addition?
> Let me know if above is sufficient or shall I include anything more in
> patch.
I can't think of anything else.
As a side question for the list, should we fix this differently in 9.2 to
avoid forcing an initdb for the next beta? Perhaps have
ATExecDropConstraint() only respect connoinherit for CONSTRAINT_CHECK?
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Noah Misch <noah(at)leadboat(dot)com> |
Cc: | Amit Kapila <amit(dot)kapila(at)huawei(dot)com>, miroslav(dot)sulc(at)fordfrog(dot)com, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table |
Date: | 2012-07-16 16:47:37 |
Message-ID: | 12717.1342457257@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
Noah Misch <noah(at)leadboat(dot)com> writes:
> As a side question for the list, should we fix this differently in 9.2 to
> avoid forcing an initdb for the next beta?
I'm confused, why would an initdb be involved?
regards, tom lane
From: | Noah Misch <noah(at)leadboat(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Amit Kapila <amit(dot)kapila(at)huawei(dot)com>, miroslav(dot)sulc(at)fordfrog(dot)com, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table |
Date: | 2012-07-16 16:53:53 |
Message-ID: | 20120716165353.GD7475@tornado.leadboat.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
On Mon, Jul 16, 2012 at 12:47:37PM -0400, Tom Lane wrote:
> Noah Misch <noah(at)leadboat(dot)com> writes:
> > As a side question for the list, should we fix this differently in 9.2 to
> > avoid forcing an initdb for the next beta?
>
> I'm confused, why would an initdb be involved?
pg_constraint.connoinherit is presently only correct for CHECK constraints.
It will take an initdb to update those values comprehensively.
From: | Amit kapila <amit(dot)kapila(at)huawei(dot)com> |
---|---|
To: | Noah Misch <noah(at)leadboat(dot)com> |
Cc: | "miroslav(dot)sulc(at)fordfrog(dot)com" <miroslav(dot)sulc(at)fordfrog(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table |
Date: | 2012-07-17 08:59:50 |
Message-ID: | 6C0B27F7206C9E4CA54AE035729E9C382851E5AB@szxeml509-mbs |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
> From: Noah Misch [noah(at)leadboat(dot)com]
> Sent: Monday, July 16, 2012 8:42 PM
> On Mon, Jul 16, 2012 at 04:49:46PM +0530, Amit Kapila wrote:
>> > Care to prepare a patch with a test case addition?
>> Let me know if above is sufficient or shall I include anything more in
>> patch.
> I can't think of anything else.
Patch is attached with this mail.
> As a side question for the list, should we fix this differently in 9.2 to
> avoid forcing an initdb for the next beta? Perhaps have
> ATExecDropConstraint() only respect connoinherit for CONSTRAINT_CHECK?
Let me know if anything needs to be done for this?
With Regards,
Amit Kapila.
Attachment | Content-Type | Size |
---|---|---|
defect_fix_6712.patch | text/plain | 8.7 KB |
From: | Noah Misch <noah(at)leadboat(dot)com> |
---|---|
To: | Amit kapila <amit(dot)kapila(at)huawei(dot)com> |
Cc: | "miroslav(dot)sulc(at)fordfrog(dot)com" <miroslav(dot)sulc(at)fordfrog(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table |
Date: | 2012-07-19 11:53:15 |
Message-ID: | 20120719115315.GB28236@tornado.leadboat.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
On Tue, Jul 17, 2012 at 08:59:50AM +0000, Amit kapila wrote:
> Patch is attached with this mail.
Thanks. This patch is ready for committer.
> +-- Test non-inheritable indices [UNIQUE, EXCLUDE] contraints
> +CREATE TABLE test_constraints (id int, val1 varchar, val2 int, UNIQUE(val1, val2));
> +CREATE TABLE test_constraints_inh () INHERITS (test_constraints);
> +\d+ test_constraints
> +ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key;
> +\d+ test_constraints
> +\d+ test_constraints_inh
To keep output terse, I would have omitted "\d" commands or retained only the
post-DROP "\d+ test_constraints". Granted, that's subjective.
From: | Amit Kapila <amit(dot)kapila(at)huawei(dot)com> |
---|---|
To: | "'Noah Misch'" <noah(at)leadboat(dot)com> |
Cc: | <miroslav(dot)sulc(at)fordfrog(dot)com>, <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table |
Date: | 2012-07-20 02:57:04 |
Message-ID: | 000f01cd6623$582cc530$08864f90$@kapila@huawei.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
From: Noah Misch [mailto:noah(at)leadboat(dot)com]
Sent: Thursday, July 19, 2012 5:23 PM
On Tue, Jul 17, 2012 at 08:59:50AM +0000, Amit kapila wrote:
>> Patch is attached with this mail.
> Thanks. This patch is ready for committer.
>> +-- Test non-inheritable indices [UNIQUE, EXCLUDE] contraints
>> +CREATE TABLE test_constraints (id int, val1 varchar, val2 int,
UNIQUE(val1, val2));
>> +CREATE TABLE test_constraints_inh () INHERITS (test_constraints);
>> +\d+ test_constraints
>> +ALTER TABLE ONLY test_constraints DROP CONSTRAINT
test_constraints_val1_val2_key;
>> +\d+ test_constraints
>> +\d+ test_constraints_inh
> To keep output terse, I would have omitted "\d" commands or retained only
the
> post-DROP "\d+ test_constraints". Granted, that's subjective.
Thanks for the review of patch.
With Regards,
Amit Kapila.
From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Amit Kapila <amit(dot)kapila(at)huawei(dot)com> |
Cc: | Noah Misch <noah(at)leadboat(dot)com>, miroslav(dot)sulc <miroslav(dot)sulc(at)fordfrog(dot)com>, Pg Bugs <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table |
Date: | 2012-07-20 12:57:43 |
Message-ID: | 1342788993-sup-6498@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
Excerpts from Amit Kapila's message of jue jul 19 22:57:04 -0400 2012:
> From: Noah Misch [mailto:noah(at)leadboat(dot)com]
> Sent: Thursday, July 19, 2012 5:23 PM
> On Tue, Jul 17, 2012 at 08:59:50AM +0000, Amit kapila wrote:
> >> Patch is attached with this mail.
>
> > Thanks. This patch is ready for committer.
Thanks, will see about it.
--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Noah Misch <noah(at)leadboat(dot)com> |
Cc: | Amit Kapila <amit(dot)kapila(at)huawei(dot)com>, miroslav(dot)sulc <miroslav(dot)sulc(at)fordfrog(dot)com>, Pg Bugs <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: Re: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table |
Date: | 2012-07-20 18:13:39 |
Message-ID: | 1342807915-sup-2496@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
Excerpts from Noah Misch's message of lun jul 16 11:12:01 -0400 2012:
> As a side question for the list, should we fix this differently in 9.2 to
> avoid forcing an initdb for the next beta? Perhaps have
> ATExecDropConstraint() only respect connoinherit for CONSTRAINT_CHECK?
My answer here was "yes", so the patch I just pushed to the 9.2 branch
contains such an override. I also included a catversion bump in HEAD
even though the catalog inconsistency is likly to be very minor.
Thanks.
--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support