Could we add another function to access method interface which would validate opclass? Am could validate this way not only strategies, but also supporting functions. For instance, in GIN, we now require opclass to specify at least one of consistent and triconsistent. ISTM I would be nice to let the access method check such conditions. Also, we would be able to check opclass correction on its creation. Now one can create opclass with missing support functions which doesn't work. In the SQL-level we can create function which validates opclass using this new method. This function can be used in regression tests.
Should I try to implement such new access method function, say 'amvalidate'?
Makes sense to me to do that, should be probably optional though.
Attached patch is implementing this. It doesn't pretend to be fully correct implementation, but it should be enough for proof the concept.
In this patch access method exposes another function: amvalidate. It takes data structure representing opclass and throws error if it finds it invalid.
This method is used on new opclass definition (alter operator family etc. are not yet implemented but planned). Also, there is SQL function validate_opclass(oid) which is used in regression tests.