mirror of
https://github.com/postgres/postgres.git
synced 2025-05-20 05:13:53 +03:00
Remove unnecessary #ifdef USE_ICU and branch.
Now that the provider-independent API pg_strnxfrm() is available, we no longer need the special cases for ICU in hashfunc.c and varchar.c. Reviewed-by: Peter Eisentraut, Peter Geoghegan Discussion: https://postgr.es/m/a581136455c940d7bd0ff482d3a2bd51af25a94f.camel%40j-davis.com
This commit is contained in:
parent
6974a8f768
commit
e0b3074e89
@ -289,34 +289,27 @@ hashtext(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef USE_ICU
|
Size bsize, rsize;
|
||||||
if (mylocale->provider == COLLPROVIDER_ICU)
|
char *buf;
|
||||||
{
|
const char *keydata = VARDATA_ANY(key);
|
||||||
Size bsize, rsize;
|
size_t keylen = VARSIZE_ANY_EXHDR(key);
|
||||||
char *buf;
|
|
||||||
const char *keydata = VARDATA_ANY(key);
|
|
||||||
size_t keylen = VARSIZE_ANY_EXHDR(key);
|
|
||||||
|
|
||||||
bsize = pg_strnxfrm(NULL, 0, keydata, keylen, mylocale);
|
|
||||||
buf = palloc(bsize + 1);
|
|
||||||
|
|
||||||
rsize = pg_strnxfrm(buf, bsize + 1, keydata, keylen, mylocale);
|
bsize = pg_strnxfrm(NULL, 0, keydata, keylen, mylocale);
|
||||||
if (rsize != bsize)
|
buf = palloc(bsize + 1);
|
||||||
elog(ERROR, "pg_strnxfrm() returned unexpected result");
|
|
||||||
|
|
||||||
/*
|
rsize = pg_strnxfrm(buf, bsize + 1, keydata, keylen, mylocale);
|
||||||
* In principle, there's no reason to include the terminating NUL
|
if (rsize != bsize)
|
||||||
* character in the hash, but it was done before and the behavior
|
elog(ERROR, "pg_strnxfrm() returned unexpected result");
|
||||||
* must be preserved.
|
|
||||||
*/
|
|
||||||
result = hash_any((uint8_t *) buf, bsize + 1);
|
|
||||||
|
|
||||||
pfree(buf);
|
/*
|
||||||
}
|
* In principle, there's no reason to include the terminating NUL
|
||||||
else
|
* character in the hash, but it was done before and the behavior
|
||||||
#endif
|
* must be preserved.
|
||||||
/* shouldn't happen */
|
*/
|
||||||
elog(ERROR, "unsupported collprovider: %c", mylocale->provider);
|
result = hash_any((uint8_t *) buf, bsize + 1);
|
||||||
|
|
||||||
|
pfree(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Avoid leaking memory for toasted inputs */
|
/* Avoid leaking memory for toasted inputs */
|
||||||
@ -350,35 +343,27 @@ hashtextextended(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef USE_ICU
|
Size bsize, rsize;
|
||||||
if (mylocale->provider == COLLPROVIDER_ICU)
|
char *buf;
|
||||||
{
|
const char *keydata = VARDATA_ANY(key);
|
||||||
Size bsize, rsize;
|
size_t keylen = VARSIZE_ANY_EXHDR(key);
|
||||||
char *buf;
|
|
||||||
const char *keydata = VARDATA_ANY(key);
|
|
||||||
size_t keylen = VARSIZE_ANY_EXHDR(key);
|
|
||||||
|
|
||||||
bsize = pg_strnxfrm(NULL, 0, keydata, keylen, mylocale);
|
bsize = pg_strnxfrm(NULL, 0, keydata, keylen, mylocale);
|
||||||
buf = palloc(bsize + 1);
|
buf = palloc(bsize + 1);
|
||||||
|
|
||||||
rsize = pg_strnxfrm(buf, bsize + 1, keydata, keylen, mylocale);
|
rsize = pg_strnxfrm(buf, bsize + 1, keydata, keylen, mylocale);
|
||||||
if (rsize != bsize)
|
if (rsize != bsize)
|
||||||
elog(ERROR, "pg_strnxfrm() returned unexpected result");
|
elog(ERROR, "pg_strnxfrm() returned unexpected result");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In principle, there's no reason to include the terminating NUL
|
* In principle, there's no reason to include the terminating NUL
|
||||||
* character in the hash, but it was done before and the behavior
|
* character in the hash, but it was done before and the behavior
|
||||||
* must be preserved.
|
* must be preserved.
|
||||||
*/
|
*/
|
||||||
result = hash_any_extended((uint8_t *) buf, bsize + 1,
|
result = hash_any_extended((uint8_t *) buf, bsize + 1,
|
||||||
PG_GETARG_INT64(1));
|
PG_GETARG_INT64(1));
|
||||||
|
|
||||||
pfree(buf);
|
pfree(buf);
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
/* shouldn't happen */
|
|
||||||
elog(ERROR, "unsupported collprovider: %c", mylocale->provider);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_FREE_IF_COPY(key, 0);
|
PG_FREE_IF_COPY(key, 0);
|
||||||
|
@ -1021,32 +1021,24 @@ hashbpchar(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef USE_ICU
|
Size bsize, rsize;
|
||||||
if (mylocale->provider == COLLPROVIDER_ICU)
|
char *buf;
|
||||||
{
|
|
||||||
Size bsize, rsize;
|
|
||||||
char *buf;
|
|
||||||
|
|
||||||
bsize = pg_strnxfrm(NULL, 0, keydata, keylen, mylocale);
|
bsize = pg_strnxfrm(NULL, 0, keydata, keylen, mylocale);
|
||||||
buf = palloc(bsize + 1);
|
buf = palloc(bsize + 1);
|
||||||
|
|
||||||
rsize = pg_strnxfrm(buf, bsize + 1, keydata, keylen, mylocale);
|
rsize = pg_strnxfrm(buf, bsize + 1, keydata, keylen, mylocale);
|
||||||
if (rsize != bsize)
|
if (rsize != bsize)
|
||||||
elog(ERROR, "pg_strnxfrm() returned unexpected result");
|
elog(ERROR, "pg_strnxfrm() returned unexpected result");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In principle, there's no reason to include the terminating NUL
|
* In principle, there's no reason to include the terminating NUL
|
||||||
* character in the hash, but it was done before and the behavior
|
* character in the hash, but it was done before and the behavior
|
||||||
* must be preserved.
|
* must be preserved.
|
||||||
*/
|
*/
|
||||||
result = hash_any((uint8_t *) buf, bsize + 1);
|
result = hash_any((uint8_t *) buf, bsize + 1);
|
||||||
|
|
||||||
pfree(buf);
|
pfree(buf);
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
/* shouldn't happen */
|
|
||||||
elog(ERROR, "unsupported collprovider: %c", mylocale->provider);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Avoid leaking memory for toasted inputs */
|
/* Avoid leaking memory for toasted inputs */
|
||||||
@ -1084,33 +1076,25 @@ hashbpcharextended(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef USE_ICU
|
Size bsize, rsize;
|
||||||
if (mylocale->provider == COLLPROVIDER_ICU)
|
char *buf;
|
||||||
{
|
|
||||||
Size bsize, rsize;
|
|
||||||
char *buf;
|
|
||||||
|
|
||||||
bsize = pg_strnxfrm(NULL, 0, keydata, keylen, mylocale);
|
bsize = pg_strnxfrm(NULL, 0, keydata, keylen, mylocale);
|
||||||
buf = palloc(bsize + 1);
|
buf = palloc(bsize + 1);
|
||||||
|
|
||||||
rsize = pg_strnxfrm(buf, bsize + 1, keydata, keylen, mylocale);
|
rsize = pg_strnxfrm(buf, bsize + 1, keydata, keylen, mylocale);
|
||||||
if (rsize != bsize)
|
if (rsize != bsize)
|
||||||
elog(ERROR, "pg_strnxfrm() returned unexpected result");
|
elog(ERROR, "pg_strnxfrm() returned unexpected result");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In principle, there's no reason to include the terminating NUL
|
* In principle, there's no reason to include the terminating NUL
|
||||||
* character in the hash, but it was done before and the behavior
|
* character in the hash, but it was done before and the behavior
|
||||||
* must be preserved.
|
* must be preserved.
|
||||||
*/
|
*/
|
||||||
result = hash_any_extended((uint8_t *) buf, bsize + 1,
|
result = hash_any_extended((uint8_t *) buf, bsize + 1,
|
||||||
PG_GETARG_INT64(1));
|
PG_GETARG_INT64(1));
|
||||||
|
|
||||||
pfree(buf);
|
pfree(buf);
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
/* shouldn't happen */
|
|
||||||
elog(ERROR, "unsupported collprovider: %c", mylocale->provider);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_FREE_IF_COPY(key, 0);
|
PG_FREE_IF_COPY(key, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user