postgresql/src
Jeff Davis dbf217c1c7 catcache.c: use C_COLLATION_OID for texteqfast/texthashfast.
The problem report was about setting GUCs in the startup packet for a
physical replication connection. Setting the GUC required an ACL
check, which performed a lookup on pg_parameter_acl.parname. The
catalog cache was hardwired to use DEFAULT_COLLATION_OID for
texteqfast() and texthashfast(), but the database default collation
was uninitialized because it's a physical walsender and never connects
to a database. In versions 18 and later, this resulted in a NULL
pointer dereference, while in version 17 it resulted in an ERROR.

As the comments stated, using DEFAULT_COLLATION_OID was arbitrary
anyway: if the collation actually mattered, it should have used the
column's actual collation. (In the catalog, some text columns are the
default collation and some are "C".)

Fix by using C_COLLATION_OID, which doesn't require any initialization
and is always available. When any deterministic collation will do,
it's best to consistently use the simplest and fastest one, so this is
a good idea anyway.

Another problem was raised in the thread, which this commit doesn't
fix (see second discussion link).

Reported-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/D18AD72A-5004-4EF8-AF80-10732AF677FA@yandex-team.ru
Discussion: https://postgr.es/m/4524ed61a015d3496fc008644dcb999bb31916a7.camel%40j-davis.com
Backpatch-through: 17
2026-04-22 10:22:44 -07:00
..
backend catcache.c: use C_COLLATION_OID for texteqfast/texthashfast. 2026-04-22 10:22:44 -07:00
bin pg_upgrade: Fix detection of invalid logical replication slots. 2026-04-22 09:59:46 -07:00
common Fix a set of typos and grammar issues across the tree 2026-04-21 14:46:22 +09:00
fe_utils Rework signal handler infrastructure to pass sender info as argument. 2026-04-15 07:30:34 -04:00
include Harmonize function parameter names for Postgres 19. 2026-04-22 12:47:19 -04:00
interfaces Fix a set of typos and grammar issues across the tree 2026-04-21 14:46:22 +09:00
makefiles Add CONCURRENTLY option to REPACK 2026-04-06 21:55:08 +02:00
pl Harmonize function parameter names for Postgres 19. 2026-04-22 12:47:19 -04:00
port Rework signal handler infrastructure to pass sender info as argument. 2026-04-15 07:30:34 -04:00
template Switch the semaphore API on Solaris to unnamed POSIX. 2026-03-14 14:10:32 -04:00
test Preserve extension dependencies on indexes during partition merge/split 2026-04-22 14:34:20 +03:00
timezone Harmonize function parameter names for Postgres 19. 2026-04-22 12:47:19 -04:00
tools Preserve extension dependencies on indexes during partition merge/split 2026-04-22 14:34:20 +03:00
tutorial Force standard_conforming_strings to always be ON. 2026-01-21 15:08:38 -05:00
.gitignore
DEVELOPERS
Makefile Add CONCURRENTLY option to REPACK 2026-04-06 21:55:08 +02:00
Makefile.global.in Update Unicode data to CLDR 48.2 2026-04-13 11:13:36 +02:00
Makefile.shlib Restore AIX support. 2026-02-23 13:34:22 -05:00
meson.build Update copyright for 2026 2026-01-01 13:24:10 -05:00
nls-global.mk Fix update-po for the PGXS case 2025-10-16 20:21:05 +02:00