Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite0b3074

Browse files
committed
Remove unnecessary #ifdef USE_ICU and branch.
Now that the provider-independent API pg_strnxfrm() is available, weno longer need the special cases for ICU in hashfunc.c and varchar.c.Reviewed-by: Peter Eisentraut, Peter GeogheganDiscussion:https://postgr.es/m/a581136455c940d7bd0ff482d3a2bd51af25a94f.camel%40j-davis.com
1 parent6974a8f commite0b3074

File tree

2 files changed

+71
-102
lines changed

2 files changed

+71
-102
lines changed

‎src/backend/access/hash/hashfunc.c

Lines changed: 42 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -289,34 +289,27 @@ hashtext(PG_FUNCTION_ARGS)
289289
}
290290
else
291291
{
292-
#ifdefUSE_ICU
293-
if (mylocale->provider==COLLPROVIDER_ICU)
294-
{
295-
Sizebsize,rsize;
296-
char*buf;
297-
constchar*keydata=VARDATA_ANY(key);
298-
size_tkeylen=VARSIZE_ANY_EXHDR(key);
299-
300-
bsize=pg_strnxfrm(NULL,0,keydata,keylen,mylocale);
301-
buf=palloc(bsize+1);
302-
303-
rsize=pg_strnxfrm(buf,bsize+1,keydata,keylen,mylocale);
304-
if (rsize!=bsize)
305-
elog(ERROR,"pg_strnxfrm() returned unexpected result");
306-
307-
/*
308-
* In principle, there's no reason to include the terminating NUL
309-
* character in the hash, but it was done before and the behavior
310-
* must be preserved.
311-
*/
312-
result=hash_any((uint8_t*)buf,bsize+1);
313-
314-
pfree(buf);
315-
}
316-
else
317-
#endif
318-
/* shouldn't happen */
319-
elog(ERROR,"unsupported collprovider: %c",mylocale->provider);
292+
Sizebsize,rsize;
293+
char*buf;
294+
constchar*keydata=VARDATA_ANY(key);
295+
size_tkeylen=VARSIZE_ANY_EXHDR(key);
296+
297+
298+
bsize=pg_strnxfrm(NULL,0,keydata,keylen,mylocale);
299+
buf=palloc(bsize+1);
300+
301+
rsize=pg_strnxfrm(buf,bsize+1,keydata,keylen,mylocale);
302+
if (rsize!=bsize)
303+
elog(ERROR,"pg_strnxfrm() returned unexpected result");
304+
305+
/*
306+
* In principle, there's no reason to include the terminating NUL
307+
* character in the hash, but it was done before and the behavior
308+
* must be preserved.
309+
*/
310+
result=hash_any((uint8_t*)buf,bsize+1);
311+
312+
pfree(buf);
320313
}
321314

322315
/* Avoid leaking memory for toasted inputs */
@@ -350,35 +343,27 @@ hashtextextended(PG_FUNCTION_ARGS)
350343
}
351344
else
352345
{
353-
#ifdefUSE_ICU
354-
if (mylocale->provider==COLLPROVIDER_ICU)
355-
{
356-
Sizebsize,rsize;
357-
char*buf;
358-
constchar*keydata=VARDATA_ANY(key);
359-
size_tkeylen=VARSIZE_ANY_EXHDR(key);
360-
361-
bsize=pg_strnxfrm(NULL,0,keydata,keylen,mylocale);
362-
buf=palloc(bsize+1);
363-
364-
rsize=pg_strnxfrm(buf,bsize+1,keydata,keylen,mylocale);
365-
if (rsize!=bsize)
366-
elog(ERROR,"pg_strnxfrm() returned unexpected result");
367-
368-
/*
369-
* In principle, there's no reason to include the terminating NUL
370-
* character in the hash, but it was done before and the behavior
371-
* must be preserved.
372-
*/
373-
result=hash_any_extended((uint8_t*)buf,bsize+1,
374-
PG_GETARG_INT64(1));
375-
376-
pfree(buf);
377-
}
378-
else
379-
#endif
380-
/* shouldn't happen */
381-
elog(ERROR,"unsupported collprovider: %c",mylocale->provider);
346+
Sizebsize,rsize;
347+
char*buf;
348+
constchar*keydata=VARDATA_ANY(key);
349+
size_tkeylen=VARSIZE_ANY_EXHDR(key);
350+
351+
bsize=pg_strnxfrm(NULL,0,keydata,keylen,mylocale);
352+
buf=palloc(bsize+1);
353+
354+
rsize=pg_strnxfrm(buf,bsize+1,keydata,keylen,mylocale);
355+
if (rsize!=bsize)
356+
elog(ERROR,"pg_strnxfrm() returned unexpected result");
357+
358+
/*
359+
* In principle, there's no reason to include the terminating NUL
360+
* character in the hash, but it was done before and the behavior
361+
* must be preserved.
362+
*/
363+
result=hash_any_extended((uint8_t*)buf,bsize+1,
364+
PG_GETARG_INT64(1));
365+
366+
pfree(buf);
382367
}
383368

384369
PG_FREE_IF_COPY(key,0);

‎src/backend/utils/adt/varchar.c

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,32 +1021,24 @@ hashbpchar(PG_FUNCTION_ARGS)
10211021
}
10221022
else
10231023
{
1024-
#ifdefUSE_ICU
1025-
if (mylocale->provider==COLLPROVIDER_ICU)
1026-
{
1027-
Sizebsize,rsize;
1028-
char*buf;
1024+
Sizebsize,rsize;
1025+
char*buf;
10291026

1030-
bsize=pg_strnxfrm(NULL,0,keydata,keylen,mylocale);
1031-
buf=palloc(bsize+1);
1027+
bsize=pg_strnxfrm(NULL,0,keydata,keylen,mylocale);
1028+
buf=palloc(bsize+1);
10321029

1033-
rsize=pg_strnxfrm(buf,bsize+1,keydata,keylen,mylocale);
1034-
if (rsize!=bsize)
1035-
elog(ERROR,"pg_strnxfrm() returned unexpected result");
1030+
rsize=pg_strnxfrm(buf,bsize+1,keydata,keylen,mylocale);
1031+
if (rsize!=bsize)
1032+
elog(ERROR,"pg_strnxfrm() returned unexpected result");
10361033

1037-
/*
1038-
* In principle, there's no reason to include the terminating NUL
1039-
* character in the hash, but it was done before and the behavior
1040-
* must be preserved.
1041-
*/
1042-
result=hash_any((uint8_t*)buf,bsize+1);
1034+
/*
1035+
* In principle, there's no reason to include the terminating NUL
1036+
* character in the hash, but it was done before and the behavior
1037+
* must be preserved.
1038+
*/
1039+
result=hash_any((uint8_t*)buf,bsize+1);
10431040

1044-
pfree(buf);
1045-
}
1046-
else
1047-
#endif
1048-
/* shouldn't happen */
1049-
elog(ERROR,"unsupported collprovider: %c",mylocale->provider);
1041+
pfree(buf);
10501042
}
10511043

10521044
/* Avoid leaking memory for toasted inputs */
@@ -1084,33 +1076,25 @@ hashbpcharextended(PG_FUNCTION_ARGS)
10841076
}
10851077
else
10861078
{
1087-
#ifdefUSE_ICU
1088-
if (mylocale->provider==COLLPROVIDER_ICU)
1089-
{
1090-
Sizebsize,rsize;
1091-
char*buf;
1079+
Sizebsize,rsize;
1080+
char*buf;
10921081

1093-
bsize=pg_strnxfrm(NULL,0,keydata,keylen,mylocale);
1094-
buf=palloc(bsize+1);
1082+
bsize=pg_strnxfrm(NULL,0,keydata,keylen,mylocale);
1083+
buf=palloc(bsize+1);
10951084

1096-
rsize=pg_strnxfrm(buf,bsize+1,keydata,keylen,mylocale);
1097-
if (rsize!=bsize)
1098-
elog(ERROR,"pg_strnxfrm() returned unexpected result");
1085+
rsize=pg_strnxfrm(buf,bsize+1,keydata,keylen,mylocale);
1086+
if (rsize!=bsize)
1087+
elog(ERROR,"pg_strnxfrm() returned unexpected result");
10991088

1100-
/*
1101-
* In principle, there's no reason to include the terminating NUL
1102-
* character in the hash, but it was done before and the behavior
1103-
* must be preserved.
1104-
*/
1105-
result=hash_any_extended((uint8_t*)buf,bsize+1,
1106-
PG_GETARG_INT64(1));
1089+
/*
1090+
* In principle, there's no reason to include the terminating NUL
1091+
* character in the hash, but it was done before and the behavior
1092+
* must be preserved.
1093+
*/
1094+
result=hash_any_extended((uint8_t*)buf,bsize+1,
1095+
PG_GETARG_INT64(1));
11071096

1108-
pfree(buf);
1109-
}
1110-
else
1111-
#endif
1112-
/* shouldn't happen */
1113-
elog(ERROR,"unsupported collprovider: %c",mylocale->provider);
1097+
pfree(buf);
11141098
}
11151099

11161100
PG_FREE_IF_COPY(key,0);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp