Re: Use opresulttype instead of calling SearchSysCache1() in match_orclause_to_indexcol()

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Use opresulttype instead of calling SearchSysCache1() in match_orclause_to_indexcol()
Date: 2025-10-18 03:12:12
Message-ID: CAHewXN=z4E7btYvNA5AM32Kuzm8bfrh5D1tz10mz_y7nbB_vPg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> 于2025年9月20日周六 00:16写道:

> Tender Wang <tndrwang(at)gmail(dot)com> writes:
> > While working on another issue, I stepped into
> match_orclause_to_indexcol().
> > I found below codes:
>
> > /* Only the operator returning a boolean suit the transformation. */
> > if (get_op_rettype(opno) != BOOLOID)
> > break;
>
> I don't understand what purpose this check serves at all.
> We are looking at an arm of an OR clause, so it had better
> yield boolean.
>

Yeah, this check doesn't need any more. I removed this check in the
attached patch.

In match_index_to_operand(), the indexExpr has been ignored, so I removed
below check, too.
- if (IsA(indexExpr, RelabelType))
- indexExpr = (Node *) ((RelabelType *) indexExpr)->arg;

> If anything, this is actively wrong, because for example it'd
> reject a polymorphic operator that yields boolean in-context.
>
> In general, this code looks like a mess. There are a lot of
> Asserts that might be okay in development but probably should
> not have got committed, and the comments need work.
>

These assertions were removed by me, too.
I didn’t modify these code comments since English isn’t my native language,
and I’d appreciate your help with them.

--
Thanks,
Tender Wang

Attachment Content-Type Size
0001-Remove-some-asserts.patch application/octet-stream 2.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Philip Alger 2025-10-18 04:08:13 Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement
Previous Message Masahiko Sawada 2025-10-18 01:24:26 Re: Logical Replication of sequences