Am Donnerstag, 6. März 2008 schrieb Tom Lane: > I attach a proposed patch against HEAD for this. It's a bit long > but most of the bulk is refactoring eqsel() to make it easy to use from > prefix_selectivity(). The intellectual content is just in the last > diff hunk.
Looking at the patch as committed here <http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/selfuncs.c.diff?r1=1.243;r2=1.244>, I am confused by one hunk: *************** prefix_selectivity(VariableStatData *var *** 4452,4468 **** * "x < greaterstr". *------- */ - cmpopr = get_opfamily_member(opfamily, vartype, vartype, - BTLessStrategyNumber); - if (cmpopr == InvalidOid) - elog(ERROR, "no < operator for opfamily %u", opfamily); - fmgr_info(get_opcode(cmpopr), &opproc); - greaterstrcon = make_greater_string(prefixcon, &opproc); if (greaterstrcon) { Selectivity topsel; topsel = ineq_histogram_selectivity(vardata, &opproc, false, greaterstrcon->constvalue, greaterstrcon->consttype); --- 4503,4519 ---- * "x < greaterstr". *------- */ greaterstrcon = make_greater_string(prefixcon, &opproc); if (greaterstrcon) { Selectivity topsel; + cmpopr = get_opfamily_member(opfamily, vartype, vartype, + BTLessStrategyNumber); + if (cmpopr == InvalidOid) + elog(ERROR, "no < operator for opfamily %u", opfamily); + fmgr_info(get_opcode(cmpopr), &opproc); + topsel = ineq_histogram_selectivity(vardata, &opproc, false, greaterstrcon->constvalue, greaterstrcon->consttype); make_greater_string() is documented as * The caller must provide the appropriate "less than" comparison function * for testing the strings. but using the new code flow it appears that opproc would still refer to the >= operator looked up earlier. The 8.1 code calls this variable ltproc because it didn't need the >= operator. Perhaps using two variables would also be clearer here. -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches