> > If bt_index_check() and bt_index_parent_check() are to have this > functionality, shouldn't there be an option controlling it much as the > option (heapallindexed boolean) controls checking whether all entries in > the heap are indexed in the btree? It seems inconsistent to have an option > to avoid checking the heap for that, but not for this. Alternately, this > might even be better coded as its own function, named something like > bt_unique_index_check() perhaps. I hope Peter might advise? >
As for heap checking, my reasoning was that we can not check whether a unique constraint violated by the index, without checking heap tuple visibility. I.e. we can have many identical index entries without uniqueness violated if only one of them corresponds to a visible heap tuple. So heap checking included in my patch is _necessary_ for unique constraint checking, it should not have an option to be disabled, otherwise, the only answer we can get is that unique constraint MAY be violated and may not be, which is quite useless. If you meant something different, please elaborate. I can try to rewrite unique constraint checking to be done after all others check but I suppose it's the performance considerations are that made previous amcheck routines to do many checks simultaneously. I tried to stick to this practice. It's also not so elegant to duplicate much code to make uniqueness checks independently and the resulting patch will be much bigger and harder to review. Anyway, your and Peter's further considerations are always welcome. -- Best regards, Pavel Borisov Postgres Professional: http://postgrespro.com <http://www.postgrespro.com>