8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 16:03:02 +01:00

Fixed CORE-1774 - Problem with collate ES_ES_CI_AI

This commit is contained in:
asfernandes 2008-03-09 16:02:12 +00:00
parent 4505e0a611
commit 628ad701c1
3 changed files with 59 additions and 7 deletions

View File

@ -38,7 +38,7 @@ static inline bool FAMILY2(TEXTTYPE cache,
const SortOrderTblEntry* NoCaseOrderTbl,
const BYTE* ToUpperConversionTbl,
const BYTE* ToLowerConversionTbl,
const CompressPair* CompressTbl,
const CompressPair* compressTbl,
const ExpandChar* ExpansionTbl,
const ASCII* POSIX,
USHORT attributes,
@ -63,11 +63,52 @@ static inline bool FAMILY2(TEXTTYPE cache,
cache->texttype_impl->texttype_collation_table = (const BYTE*) NoCaseOrderTbl;
cache->texttype_impl->texttype_toupper_table = ToUpperConversionTbl;
cache->texttype_impl->texttype_tolower_table = ToLowerConversionTbl;
cache->texttype_impl->texttype_compress_table = (const BYTE*) CompressTbl;
cache->texttype_impl->texttype_compress_table = (const BYTE*) compressTbl;
cache->texttype_impl->texttype_expand_table = (const BYTE*) ExpansionTbl;
cache->texttype_impl->texttype_flags = ((flags) & REVERSE) ? TEXTTYPE_reverse_secondary : 0;
cache->texttype_impl->texttype_bytes_per_key = 0;
int maxPrimary = 0;
int minPrimary = INT_MAX;
int maxIgnore = 0;
while (compressTbl->CharPair[0])
{
if (compressTbl->NoCaseWeight.Primary > maxPrimary)
maxPrimary = compressTbl->NoCaseWeight.Primary;
if (compressTbl->NoCaseWeight.Primary < minPrimary)
minPrimary = compressTbl->NoCaseWeight.Primary;
++compressTbl;
}
for (int ch = 0; ch <= 255; ++ch)
{
const SortOrderTblEntry* coll =
&((const SortOrderTblEntry*)cache->texttype_impl->texttype_collation_table)[ch];
if (coll->IsExpand && coll->IsCompress)
{
if (coll->Primary > maxIgnore)
maxIgnore = coll->Primary;
}
else if (!(coll->IsExpand || coll->IsCompress))
{
if (coll->Primary > maxPrimary)
maxPrimary = coll->Primary;
if (coll->Primary < minPrimary)
minPrimary = coll->Primary;
}
}
if (maxIgnore > 0 && maxPrimary + maxIgnore - 1 <= 255)
{
cache->texttype_impl->ignore_sum = minPrimary - 1;
cache->texttype_impl->primary_sum = maxIgnore - 1;
}
return true;
}

View File

@ -686,20 +686,27 @@ ULONG LC_NARROW_canonical(TEXTTYPE obj, ULONG srcLen, const UCHAR* src, ULONG ds
const SortOrderTblEntry* coll =
&((const SortOrderTblEntry*)obj->texttype_impl->texttype_collation_table)[*src];
USHORT primary = coll->Primary;
if (coll->IsExpand && coll->IsCompress)
primary += obj->texttype_impl->ignore_sum;
else
primary += obj->texttype_impl->primary_sum;
if ((obj->texttype_impl->texttype_flags & (TEXTTYPE_secondary_insensitive | TEXTTYPE_tertiary_insensitive)) == 0)
{
put(dst, (USHORT) ((coll->Primary << 8) | (coll->Secondary << 4) | coll->Tertiary));
put(dst, (USHORT) ((primary << 8) | (coll->Secondary << 4) | coll->Tertiary));
}
else if ((obj->texttype_impl->texttype_flags & TEXTTYPE_secondary_insensitive) == 0)
{
put(dst, (USHORT) ((coll->Primary << 8) | coll->Secondary));
put(dst, (USHORT) ((primary << 8) | coll->Secondary));
}
else if ((obj->texttype_impl->texttype_flags & TEXTTYPE_tertiary_insensitive) == 0)
{
put(dst, (USHORT) ((coll->Primary << 8) | coll->Tertiary));
put(dst, (USHORT) ((primary << 8) | coll->Tertiary));
}
else
*dst++ = coll->Primary;
*dst++ = primary;
}
return src - inbuff;

View File

@ -38,7 +38,9 @@ struct TextTypeImpl
texttype_expand_table(NULL),
texttype_compress_table(NULL),
texttype_toupper_table(NULL),
texttype_tolower_table(NULL)
texttype_tolower_table(NULL),
ignore_sum(0),
primary_sum(0)
{
}
@ -49,6 +51,8 @@ struct TextTypeImpl
const BYTE* texttype_compress_table;
const BYTE* texttype_toupper_table;
const BYTE* texttype_tolower_table;
int ignore_sum;
int primary_sum;
};
USHORT LC_NARROW_key_length(TEXTTYPE obj, USHORT inLen);