agora inbox for pgsql-committers@postgresql.orghelp / color / mirror / Atom feed
pgsql: catcache.c: use C_COLLATION_OID for texteqfast/texthashfast. 3+ messages / 1 participants [nested] [flat]
* pgsql: catcache.c: use C_COLLATION_OID for texteqfast/texthashfast. @ 2026-04-22 17:27 Jeff Davis <jdavis@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Jeff Davis @ 2026-04-22 17:27 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/dbf217c1c7c2744a18db489c255255e07cfbb110 Modified Files -------------- src/backend/utils/cache/catcache.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: catcache.c: use C_COLLATION_OID for texteqfast/texthashfast. @ 2026-04-22 17:27 Jeff Davis <jdavis@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Jeff Davis @ 2026-04-22 17:27 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/03c4f243e0a289cb56f639c80f5a265401d5a5ea Modified Files -------------- src/backend/utils/cache/catcache.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: catcache.c: use C_COLLATION_OID for texteqfast/texthashfast. @ 2026-04-22 17:27 Jeff Davis <jdavis@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Jeff Davis @ 2026-04-22 17:27 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9dda30dd3d4936e3d590fc319b08eaed41f1f748 Modified Files -------------- src/backend/utils/cache/catcache.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-04-22 17:27 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-04-22 17:27 pgsql: catcache.c: use C_COLLATION_OID for texteqfast/texthashfast. Jeff Davis <jdavis@postgresql.org> 2026-04-22 17:27 pgsql: catcache.c: use C_COLLATION_OID for texteqfast/texthashfast. Jeff Davis <jdavis@postgresql.org> 2026-04-22 17:27 pgsql: catcache.c: use C_COLLATION_OID for texteqfast/texthashfast. Jeff Davis <jdavis@postgresql.org>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox