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