diff options
| author | Jeff Davis <jdavis@postgresql.org> | 2024-07-30 16:23:20 -0700 |
|---|---|---|
| committer | Jeff Davis <jdavis@postgresql.org> | 2024-07-30 16:23:20 -0700 |
| commit | 679c5084cf210c6e958276b657039e8ba0c077c0 (patch) | |
| tree | f8df313546b6fd447e8a9a480de5a3c4627d12c0 /src/backend/access | |
| parent | f822be39629cd24a8ad1f8f6aa444e0c9ae1eaad (diff) | |
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
Diffstat (limited to 'src/backend/access')
| -rw-r--r-- | src/backend/access/hash/hashfunc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c index ce8ee0ea2ef..c3a67b51afe 100644 --- a/src/backend/access/hash/hashfunc.c +++ b/src/backend/access/hash/hashfunc.c @@ -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"); /* |
