mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 10:03:03 +01:00
Avoid loosing decimal float precision, scale and/or sign info when sorting
This commit is contained in:
parent
0227ec9e3c
commit
0fc68ab8ea
@ -140,11 +140,17 @@ void make(unsigned int* key,
|
||||
unsigned dig = digits(pMax, coeff, exp);
|
||||
|
||||
// exponent bias and sign
|
||||
exp += (bias + 2);
|
||||
if (!dig)
|
||||
exp = 1;
|
||||
if (sign)
|
||||
exp = -exp;
|
||||
{
|
||||
exp = 0;
|
||||
sign = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
exp += (bias + 2);
|
||||
if (sign)
|
||||
exp = -exp;
|
||||
}
|
||||
*key++ = exp;
|
||||
|
||||
// convert to SLONG
|
||||
@ -171,9 +177,7 @@ void grab(unsigned int* key,
|
||||
sign = DECFLOAT_Sign;
|
||||
exp = -exp;
|
||||
}
|
||||
if (exp == 1)
|
||||
exp = 0;
|
||||
else
|
||||
if (exp != 0)
|
||||
exp -= (bias + 2);
|
||||
|
||||
// convert from SLONG
|
||||
|
@ -2453,7 +2453,8 @@ SortedStream* OPT_gen_sort(thread_db* tdbb, CompilerScratch* csb, const StreamLi
|
||||
fieldNode->getDesc(tdbb, csb, desc);
|
||||
|
||||
// International type text has a computed key
|
||||
if (IS_INTL_DATA(desc))
|
||||
// Different decimal float values sometimes have same keys
|
||||
if (IS_INTL_DATA(desc) || desc->isDecFloat())
|
||||
break;
|
||||
|
||||
--items;
|
||||
|
@ -339,7 +339,7 @@ void SortedStream::mapData(thread_db* tdbb, jrd_req* request, UCHAR* data) const
|
||||
// a sort key, there is a later nod_field in the item
|
||||
// list that contains the data to send back
|
||||
|
||||
if (IS_INTL_DATA(&item->desc) &&
|
||||
if ((IS_INTL_DATA(&item->desc) || item->desc.isDecFloat()) &&
|
||||
(ULONG)(IPTR) item->desc.dsc_address < m_map->keyLength)
|
||||
{
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user