]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Avoid collation lookup failure when considering a "char" column.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 28 Jun 2026 16:31:29 +0000 (12:31 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 28 Jun 2026 16:31:29 +0000 (12:31 -0400)
commitb574fec00f275e50ffe2c9780ec1f6398796c905
treedeec58e9211c206cb91673646eb0efdfc1525b60
parentd6ed87d19890b1cfa93d1f6e8957fa525834c0e2
Avoid collation lookup failure when considering a "char" column.

If a "char" column has a statistics histogram, scalarineqsel()
would fail with "cache lookup failed for collation 0".  Avoid
the failing lookup by acting as though the collation is "C".

Prior to commit 06421b084, this code didn't fail because
lc_collate_is_c() intentionally didn't spit up on InvalidOid.
It did act differently though: it would take the non-C-collation
code path and hence apply strxfrm using libc's prevailing locale.
But that seems like the wrong thing for a non-collatable comparison,
so let's not resurrect that aspect.

Author: Feng Wu <wufengwufengwufeng@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CACK3muq6s-O1Wc3w4dRL1Fe8YQ-Fz1zJbezeQwhuLgNxGNEFiA@mail.gmail.com
Backpatch-through: 18
src/backend/utils/adt/selfuncs.c
src/test/regress/expected/planner_est.out
src/test/regress/sql/planner_est.sql