Re: [PATCH] Avoid collation lookup for "char" statistics

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Feng Wu <wufengwufengwufeng(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Avoid collation lookup for "char" statistics
Date: 2026-06-28 16:41:21
Message-ID: 1602936.1782664881@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Even where there is a histogram, it'd be unlikely for someone to
> issue a query that would hit this code, so the lack of prior
> reports isn't as surprising as I thought.

I had supposed that this was an old bug, but on attempting to
back-patch I found it wasn't broken before v18. So that's another
big reason for lack of prior reports. Commit 06421b084 replaced a
call to lc_collate_is_c(), which tolerated InvalidOid, with
pg_newlocale_from_collation() which doesn't.

Seeing this, I thought we'd be best off to put the test where
you had it but make it test for !OidIsValid(collid) rather than
hard-wiring typid == CHAROID. There probably aren't other cases
where we reach here with collid 0, but if there are, we want the
code to not fail, as it did not before.

Pushed with a test based on an inequality comparison (in HEAD
only, because there didn't seem to be a suitable test file in 18).

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rui Zhao 2026-06-28 16:44:31 Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements
Previous Message Tom Lane 2026-06-28 15:39:00 Re: [PATCH] Avoid collation lookup for "char" statistics