pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: hashtext: fix fragile code.
5+ messages / 1 participants
[nested] [flat]

* pgsql: hashtext: fix fragile code.
@ 2026-08-20 21:06  Jeff Davis <jdavis@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Jeff Davis @ 2026-08-20 21:06 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

hashtext: fix fragile code.

Previously, in the path for non-deterministic collations, the code
assumed that bsize==rsize. That assumption seems to be true for ICU,
and all non-deterministic collations are ICU, so it's not known to be
an actual bug.

The only known place where bsize may not equal rsize is in the libc
provider, where strxfrm() can return an upper bound of the size needed
to store the result. That means the initial call to determine the
buffer size (with dest==NULL, n==0) could return a larger number than
the actual call with an adequate dest buffer. That's OK, because libc
locales are always deterministic.

Commit 679c5084cf2 partially fixed the assumption, but missed this
part. Fix it, and add a more prominent documentation note.

Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Discussion: https://postgr.es/m/CABXr29Hb31nkj1g2Jmk+1BhAm=3ecGs_pWy4tU++j8CQBnbMxQ@mail.gmail.com
Backpatch-through: 16

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/aa655f88f71bc747083a4c7e04b6294ff6d19da6

Modified Files
--------------
src/backend/access/hash/hashfunc.c     |  4 ++--
src/backend/utils/adt/pg_locale.c      |  8 +++++---
src/backend/utils/adt/pg_locale_libc.c | 10 ++++++++++
src/backend/utils/adt/varchar.c        |  4 ++--
4 files changed, 19 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: hashtext: fix fragile code.
@ 2026-08-20 21:06  Jeff Davis <jdavis@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Jeff Davis @ 2026-08-20 21:06 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

hashtext: fix fragile code.

Previously, in the path for non-deterministic collations, the code
assumed that bsize==rsize. That assumption seems to be true for ICU,
and all non-deterministic collations are ICU, so it's not known to be
an actual bug.

The only known place where bsize may not equal rsize is in the libc
provider, where strxfrm() can return an upper bound of the size needed
to store the result. That means the initial call to determine the
buffer size (with dest==NULL, n==0) could return a larger number than
the actual call with an adequate dest buffer. That's OK, because libc
locales are always deterministic.

Commit 679c5084cf2 partially fixed the assumption, but missed this
part. Fix it, and add a more prominent documentation note.

Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Discussion: https://postgr.es/m/CABXr29Hb31nkj1g2Jmk+1BhAm=3ecGs_pWy4tU++j8CQBnbMxQ@mail.gmail.com
Backpatch-through: 16

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3849ce5b3094f6d679a4c474f0654eba5187b14d

Modified Files
--------------
src/backend/access/hash/hashfunc.c     |  4 ++--
src/backend/utils/adt/pg_locale.c      |  8 +++++---
src/backend/utils/adt/pg_locale_libc.c | 10 ++++++++++
src/backend/utils/adt/varchar.c        |  4 ++--
4 files changed, 19 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: hashtext: fix fragile code.
@ 2026-08-20 21:06  Jeff Davis <jdavis@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Jeff Davis @ 2026-08-20 21:06 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

hashtext: fix fragile code.

Previously, in the path for non-deterministic collations, the code
assumed that bsize==rsize. That assumption seems to be true for ICU,
and all non-deterministic collations are ICU, so it's not known to be
an actual bug.

The only known place where bsize may not equal rsize is in the libc
provider, where strxfrm() can return an upper bound of the size needed
to store the result. That means the initial call to determine the
buffer size (with dest==NULL, n==0) could return a larger number than
the actual call with an adequate dest buffer. That's OK, because libc
locales are always deterministic.

Commit 679c5084cf2 partially fixed the assumption, but missed this
part. Fix it, and add a more prominent documentation note.

Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Discussion: https://postgr.es/m/CABXr29Hb31nkj1g2Jmk+1BhAm=3ecGs_pWy4tU++j8CQBnbMxQ@mail.gmail.com
Backpatch-through: 16

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b3510700e994a525958dc98a33d320786312d19f

Modified Files
--------------
src/backend/access/hash/hashfunc.c     | 4 ++--
src/backend/utils/adt/pg_locale.c      | 8 +++++---
src/backend/utils/adt/pg_locale_libc.c | 5 +++++
src/backend/utils/adt/varchar.c        | 4 ++--
4 files changed, 14 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: hashtext: fix fragile code.
@ 2026-08-20 21:07  Jeff Davis <jdavis@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Jeff Davis @ 2026-08-20 21:07 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

hashtext: fix fragile code.

Previously, in the path for non-deterministic collations, the code
assumed that bsize==rsize. That assumption seems to be true for ICU,
and all non-deterministic collations are ICU, so it's not known to be
an actual bug.

The only known place where bsize may not equal rsize is in the libc
provider, where strxfrm() can return an upper bound of the size needed
to store the result. That means the initial call to determine the
buffer size (with dest==NULL, n==0) could return a larger number than
the actual call with an adequate dest buffer. That's OK, because libc
locales are always deterministic.

Commit 679c5084cf2 partially fixed the assumption, but missed this
part. Fix it, and add a more prominent documentation note.

Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Discussion: https://postgr.es/m/CABXr29Hb31nkj1g2Jmk+1BhAm=3ecGs_pWy4tU++j8CQBnbMxQ@mail.gmail.com
Backpatch-through: 16

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e2a44c77112c76113dad8dd6e99bddd91250f6c4

Modified Files
--------------
src/backend/access/hash/hashfunc.c |  4 ++--
src/backend/utils/adt/pg_locale.c  | 24 +++++++++++++++++++++---
src/backend/utils/adt/varchar.c    |  4 ++--
3 files changed, 25 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* pgsql: hashtext: fix fragile code.
@ 2026-08-20 21:07  Jeff Davis <jdavis@postgresql.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Jeff Davis @ 2026-08-20 21:07 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

hashtext: fix fragile code.

Previously, in the path for non-deterministic collations, the code
assumed that bsize==rsize. That assumption seems to be true for ICU,
and all non-deterministic collations are ICU, so it's not known to be
an actual bug.

The only known place where bsize may not equal rsize is in the libc
provider, where strxfrm() can return an upper bound of the size needed
to store the result. That means the initial call to determine the
buffer size (with dest==NULL, n==0) could return a larger number than
the actual call with an adequate dest buffer. That's OK, because libc
locales are always deterministic.

Commit 679c5084cf2 partially fixed the assumption, but missed this
part. Fix it, and add a more prominent documentation note.

Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Discussion: https://postgr.es/m/CABXr29Hb31nkj1g2Jmk+1BhAm=3ecGs_pWy4tU++j8CQBnbMxQ@mail.gmail.com
Backpatch-through: 16

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f61d6b0e1329841ef8bb0a337ac95700885fe772

Modified Files
--------------
src/backend/access/hash/hashfunc.c |  4 ++--
src/backend/utils/adt/pg_locale.c  | 24 +++++++++++++++++++++---
src/backend/utils/adt/varchar.c    |  4 ++--
3 files changed, 25 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2026-08-20 21:07 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-08-20 21:06 pgsql: hashtext: fix fragile code. Jeff Davis <jdavis@postgresql.org>
2026-08-20 21:06 pgsql: hashtext: fix fragile code. Jeff Davis <jdavis@postgresql.org>
2026-08-20 21:06 pgsql: hashtext: fix fragile code. Jeff Davis <jdavis@postgresql.org>
2026-08-20 21:07 pgsql: hashtext: fix fragile code. Jeff Davis <jdavis@postgresql.org>
2026-08-20 21:07 pgsql: hashtext: fix fragile code. Jeff Davis <jdavis@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox