Re: Query related to alter table ... attach partition - Mailing list pgsql-hackers

From Amit Langote
Subject Re: Query related to alter table ... attach partition
Date
Msg-id 052e8f89-1b5c-0fc3-21ed-8a28eb6e3967@lab.ntt.co.jp
Whole thread Raw
In response to Re: Query related to alter table ... attach partition  (Ashutosh Sharma <ashu.coek88@gmail.com>)
List pgsql-hackers
On 2018/01/23 15:55, Ashutosh Sharma wrote:
>> However, we don't make it fail because the table has a constraint that
>> contradicts the partition constraint.  Attach succeeds in the absence of
>> any violating rows and the end result is that the table/partition has
>> contradictory constraints (the existing constraint and the partition
>> constraint) and that simply means no rows can be inserted into the
>> table/partition.
>>
> 
> That's right. But, shouldn't a partition that not at all fall in the
> partition range be rejected when user tries to attach it. I feel we
> should at least try throwing a WARNING message for it. Thoughts?

I did have such thoughts back when writing the patch, but we decided
during the review that it wasn't worthwhile; see this email for example:

https://www.postgresql.org/message-id/CA%2BTgmoaQABrsLQK4ms_4NiyavyJGS-b6ZFkZBBNC%2B-P5DjJNFA%40mail.gmail.com

Or see this:

create table foo (a int check (a > 1 and a < 1));

The above command doesn't fail even if the check expression in it is
contradictory.  If we think that the attach command in question should
fail or issue WARNING, then the above command should too.

Thanks,
Amit



pgsql-hackers by date:

Previous
From: Haribabu Kommi
Date:
Subject: Re: Enhance pg_stat_wal_receiver view to display connected host
Next
From: Kyotaro HORIGUCHI
Date:
Subject: Re: Bug in Physical Replication Slots (at least 9.5)?