-
Tom Lane authored
Generally, if the comparison operators for a datatype or pair of datatypes are leakproof, the corresponding btree comparison support function can be considered so as well. But we had not originally worried about marking support functions as leakproof, reasoning that they'd not likely be used in queries so the marking wouldn't matter. It turns out there's at least one place where it does matter: calc_arraycontsel() finds the target datatype's default btree comparison function and tries to use that to estimate selectivity, but it will be blocked in some cases if the function isn't leakproof. This leads to unnecessarily poor selectivity estimates and bad plans, as seen in bug #15251. Hence, run around and apply proleakproof markings where the corresponding btree comparison operators are leakproof. (I did eyeball each function to verify that it wasn't doing anything surprising, too.) This isn't a full solution to bug #15251, and it's not back-patchable because of the need for a catversion bump. A more useful response probably is to consider whether we can check permissions on the parent table instead of the child. However, this change will help in some cases where that won't, and it's easy enough to do in HEAD, so let's do so. Discussion: https://postgr.es/m/3876.1531261875@sss.pgh.pa.us
39a96512