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

Commitd060e07

Browse files
committed
Repair brain fade in commitb181a91.
The split between which things need to happen in the C-locale case andwhich needed to happen in the locale-aware case was a few bricks shortof a load. Try to fix that.
1 parent59367fd commitd060e07

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,12 +1998,12 @@ bttext_abbrev_convert(Datum original, SortSupport ssup)
19981998
{
19991999
TextSortSupport*tss= (TextSortSupport*)ssup->ssup_extra;
20002000
text*authoritative=DatumGetTextPP(original);
2001+
char*authoritative_data=VARDATA_ANY(authoritative);
20012002

20022003
/* working state */
20032004
Datumres;
20042005
char*pres;
20052006
intlen;
2006-
Sizebsize;
20072007
uint32hash;
20082008

20092009
/*
@@ -2017,14 +2017,16 @@ bttext_abbrev_convert(Datum original, SortSupport ssup)
20172017

20182018
/*
20192019
* If we're using the C collation, use memcmp(), rather than strxfrm(),
2020-
* toabbreviated keys. The full comparator for the C locale is always
2020+
* toabbreviate keys. The full comparator for the C locale is always
20212021
* memcmp(), and we can't risk having this give a different answer.
20222022
* Besides, this should be faster, too.
20232023
*/
20242024
if (tss->collate_c)
2025-
memcpy(pres,VARDATA_ANY(authoritative),Min(len,sizeof(Datum)));
2025+
memcpy(pres,authoritative_data,Min(len,sizeof(Datum)));
20262026
else
20272027
{
2028+
Sizebsize;
2029+
20282030
/*
20292031
* We're not using the C collation, so fall back on strxfrm.
20302032
*/
@@ -2067,6 +2069,14 @@ bttext_abbrev_convert(Datum original, SortSupport ssup)
20672069
Min(tss->buflen2*2,MaxAllocSize));
20682070
tss->buf2=palloc(tss->buflen2);
20692071
}
2072+
2073+
/*
2074+
* Every Datum byte is always compared. This is safe because the
2075+
* strxfrm() blob is itself NUL terminated, leaving no danger of
2076+
* misinterpreting any NUL bytes not intended to be interpreted as
2077+
* logically representing termination.
2078+
*/
2079+
memcpy(pres,tss->buf2,Min(sizeof(Datum),bsize));
20702080
}
20712081

20722082
/*
@@ -2080,15 +2090,14 @@ bttext_abbrev_convert(Datum original, SortSupport ssup)
20802090
* in order to compensate for cases where differences are past
20812091
* CACHE_LINE_SIZE bytes, so as to limit the overhead of hashing.
20822092
*/
2083-
hash=hash_any((unsignedchar*)tss->buf1,Min(len,PG_CACHE_LINE_SIZE));
2093+
hash=hash_any((unsignedchar*)authoritative_data,
2094+
Min(len,PG_CACHE_LINE_SIZE));
20842095

20852096
if (len>PG_CACHE_LINE_SIZE)
20862097
hash ^=DatumGetUInt32(hash_uint32((uint32)len));
20872098

20882099
addHyperLogLog(&tss->full_card,hash);
20892100

2090-
memcpy(pres,tss->buf2,Min(sizeof(Datum),bsize));
2091-
20922101
/* Hash abbreviated key */
20932102
#ifSIZEOF_DATUM==8
20942103
{
@@ -2105,12 +2114,6 @@ bttext_abbrev_convert(Datum original, SortSupport ssup)
21052114

21062115
addHyperLogLog(&tss->abbr_card,hash);
21072116

2108-
/*
2109-
* Every Datum byte is always compared. This is safe because the strxfrm()
2110-
* blob is itself NUL terminated, leaving no danger of misinterpreting any
2111-
* NUL bytes not intended to be interpreted as logically representing
2112-
* termination.
2113-
*/
21142117
returnres;
21152118
}
21162119

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp