1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-01 21:31:19 +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 9d198f4d3e
commit 403cbd2108
3 changed files with 18 additions and 10 deletions

View File

@@ -300,7 +300,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");
/*
@@ -354,7 +356,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");
/*