Fix GetOperatorFromCompareType
Paul A Jungwirth <pj@illuminatedcomputing.com>
From: Paul A Jungwirth <pj@illuminatedcomputing.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-11-14T00:59:20Z
Lists: pgsql-hackers
Attachments
- v1-0001-Improve-comment-and-error-handling-in-GetOperator.patch (application/octet-stream)
Hi Hackers,
I found a few problems with GetOperatorFromCompareType and fixed them here.
First of all, the comment was out of date: we never return
InvalidStrategy; instead we ereport.
Second, we were potentially using uninitialized Oids to build error
messages (if get_opclass_opfamily_and_input_type failed). If that
function fails, we should just die. In fact since get_opclass_method
just succeeded, which makes the same lookup, how could it ever fail? I
don't think we need to try very hard to build a fancy message.
Failing right away simplifies the logic, because we only reach the
bottom of the function one way. And I think we can make things ever
clearer by inverting the conditional, so it acts like a guard, and we
can avoid some nesting.
Based on acbc9beaae.
Yours,
--
Paul ~{:-)
pj@illuminatedcomputing.com