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