Fix GetOperatorFromCompareType

From: Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Fix GetOperatorFromCompareType
Date: 2025-11-14 00:59:20
Message-ID: CA+renyXOrjLacP_nhqEQUf2W+ZCoY2q5kpQCfG05vQVYzr8b9w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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(at)illuminatedcomputing(dot)com

Attachment Content-Type Size
v1-0001-Improve-comment-and-error-handling-in-GetOperator.patch application/octet-stream 4.2 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Quan Zongliang 2025-11-14 01:13:30 Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement
Previous Message Jacob Champion 2025-11-14 00:58:36 Re: Few untranslated error messages in OAuth