Re: ILIKE '%' never matches a non-ASCII byte in single-byte C-ctype databases

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Greg Burd <greg(at)burd(dot)me>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: ILIKE '%' never matches a non-ASCII byte in single-byte C-ctype databases
Date: 2026-10-20 13:29:05
Message-ID: 78666013416210c1dcb6d277d75570f0e7c2f555.camel@j-davis.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 2026-10-18 at 15:30 +0000, Greg Burd wrote:
> Hi Hackers, Jeff,
>
> In v19, ILIKE in a database with a single-byte encoding and a C ctype
> never matches when '%' is followed by a byte >= 0x80:

Thank you for the report!

I attached a patch with a different approach though, which is to cast
the result of pg_ascii_tolower() so that GETCHAR() consistently returns
a 'char'. That addresses the real problem of commit 1e493158d3d, which
is that it unintentionally changed GETCHAR() from returning 'char' to
returning 'unsigned char' for MATCH_LOWER.

It passes the same test that you submitted, but I don't plan to commit
the tests with the change. We are missing coverage for non-UTF8
encodings, but if we're going to add tests for those, it should
probably be a whole suite rather than a one-off.

I plan to commit it very soon and backport to 19.

Regards,
Jeff Davis

Attachment Content-Type Size
v2j-0001-Fix-ILIKE-followed-by-a-non-ASCII-byte-in-single.patch text/x-patch 1.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nitin Jadhav 2026-10-20 13:37:22 Checkpoint progress reporting
Previous Message David G. Johnston 2026-10-20 13:26:29 Re: Extract text from XML, pay attention to XML Entities