mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 19:23: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);
|
unsigned dig = digits(pMax, coeff, exp);
|
||||||
|
|
||||||
// exponent bias and sign
|
// exponent bias and sign
|
||||||
exp += (bias + 2);
|
|
||||||
if (!dig)
|
if (!dig)
|
||||||
exp = 1;
|
{
|
||||||
|
exp = 0;
|
||||||
|
sign = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exp += (bias + 2);
|
||||||
if (sign)
|
if (sign)
|
||||||
exp = -exp;
|
exp = -exp;
|
||||||
|
}
|
||||||
*key++ = exp;
|
*key++ = exp;
|
||||||
|
|
||||||
// convert to SLONG
|
// convert to SLONG
|
||||||
@ -171,9 +177,7 @@ void grab(unsigned int* key,
|
|||||||
sign = DECFLOAT_Sign;
|
sign = DECFLOAT_Sign;
|
||||||
exp = -exp;
|
exp = -exp;
|
||||||
}
|
}
|
||||||
if (exp == 1)
|
if (exp != 0)
|
||||||
exp = 0;
|
|
||||||
else
|
|
||||||
exp -= (bias + 2);
|
exp -= (bias + 2);
|
||||||
|
|
||||||
// convert from SLONG
|
// convert from SLONG
|
||||||
|
@ -2453,7 +2453,8 @@ SortedStream* OPT_gen_sort(thread_db* tdbb, CompilerScratch* csb, const StreamLi
|
|||||||
fieldNode->getDesc(tdbb, csb, desc);
|
fieldNode->getDesc(tdbb, csb, desc);
|
||||||
|
|
||||||
// International type text has a computed key
|
// 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;
|
break;
|
||||||
|
|
||||||
--items;
|
--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
|
// a sort key, there is a later nod_field in the item
|
||||||
// list that contains the data to send back
|
// 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)
|
(ULONG)(IPTR) item->desc.dsc_address < m_map->keyLength)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user