1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Relax check for return value from second call of pg_strnxfrm().

strxfrm() is not guaranteed to return the exact number of bytes needed
to store the result; it may return a higher value.

Discussion: https://postgr.es/m/32f85d88d1f64395abfe5a10dd97a62a4d3474ce.camel@j-davis.com
Reviewed-by: Heikki Linnakangas
Backpatch-through: 16
This commit is contained in:
Jeff Davis
2024-07-30 16:23:20 -07:00
parent f822be3962
commit 679c5084cf
3 changed files with 18 additions and 10 deletions

View File

@@ -298,7 +298,9 @@ hashtext(PG_FUNCTION_ARGS)
buf = palloc(bsize + 1);
rsize = pg_strnxfrm(buf, bsize + 1, keydata, keylen, mylocale);
if (rsize != bsize)
/* the second call may return a smaller value than the first */
if (rsize > bsize)
elog(ERROR, "pg_strnxfrm() returned unexpected result");
/*
@@ -352,7 +354,9 @@ hashtextextended(PG_FUNCTION_ARGS)
buf = palloc(bsize + 1);
rsize = pg_strnxfrm(buf, bsize + 1, keydata, keylen, mylocale);
if (rsize != bsize)
/* the second call may return a smaller value than the first */
if (rsize > bsize)
elog(ERROR, "pg_strnxfrm() returned unexpected result");
/*