Fix network subset support with custom operator classes
Thread notes
1 note#bug
hackorum-bot#bug
@global #bug
Hi,
The planner support function for the inet << and <<= operators
rewrites the predicate into range clauses of the form
key >= network_scan_first(C) AND key <= network_scan_last(C)
which only works when opfamily is same as network_cmp_internal().
Since be1cc9aaf5b [0]https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=be1cc9aaf5b79f07bc0483a0c95366c77a844d0a this is actually not checked. [0]https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=be1cc9aaf5b79f07bc0483a0c95366c77a844d0a commit message
says that
To fix restore the opfamily == NETWORK_BTREE_FAM_OID check inside
match_network_subset.
A regression test with a masklen-ordered btree opclass over inet is
included as a separate patch. This case looks too narrow to spend CI
cycles on, OTOH this is real historical regression.
--
Best regards,
Kirill Reshke
Hi Kirill,
The family OID check also removes index bounds from a copy of the
standard inet opclass in a separate family. Could we instead follow
like_support.c: select the standard inet operators, then check
op_in_opfamily() for the target family?
With the reverse opclass from your test, explicitly writing the standard
= and <= bounds produces an Index Cond and returns the expected two
rows. That suggests we can fix the operator selection without losing
the generalization from be1cc9aaf5b.
I'd keep the test.
Thank you!
Best regards, Andrey Borodin.