mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-02-02 08:40:39 +01:00
Misc.
This commit is contained in:
parent
c19f51302f
commit
bf284274f4
@ -179,4 +179,3 @@ DECFLOAT (FB 4.0)
|
||||
but poor precision) or scaled integers (good support for further processing and
|
||||
required precision but range of values is very limited). When using is a tool like
|
||||
generic purporse GUI client choice of CHAR binding is OK in most cases.
|
||||
|
||||
|
@ -1629,8 +1629,10 @@ void put_data(burp_rel* relation)
|
||||
// msg 26 datatype %ld not understood
|
||||
break;
|
||||
}
|
||||
|
||||
if (alignment)
|
||||
offset = FB_ALIGN(offset, alignment);
|
||||
|
||||
field->fld_offset = offset;
|
||||
field->fld_parameter = count++;
|
||||
offset += length;
|
||||
|
@ -136,34 +136,34 @@ ULONG CAN_encode_decode(burp_rel* relation, lstring* buffer, UCHAR* data, bool_t
|
||||
break;
|
||||
|
||||
case dtype_short:
|
||||
if (!xdr_short(xdrs, (SSHORT *) p))
|
||||
if (!xdr_short(xdrs, (SSHORT*) p))
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case dtype_long:
|
||||
case dtype_sql_time:
|
||||
case dtype_sql_date:
|
||||
if (!xdr_long(xdrs, (SLONG *) p))
|
||||
if (!xdr_long(xdrs, (SLONG*) p))
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case dtype_real:
|
||||
if (!xdr_float(xdrs, (float *) p))
|
||||
if (!xdr_float(xdrs, (float*) p))
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case dtype_double:
|
||||
if (!xdr_double(xdrs, (double *) p))
|
||||
if (!xdr_double(xdrs, (double*) p))
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case dtype_dec64:
|
||||
if (!xdr_dec64(xdrs, (Firebird::Decimal64 *) p))
|
||||
if (!xdr_dec64(xdrs, (Firebird::Decimal64*) p))
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case dtype_dec128:
|
||||
if (!xdr_dec128(xdrs, (Firebird::Decimal128 *) p))
|
||||
if (!xdr_dec128(xdrs, (Firebird::Decimal128*) p))
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
|
||||
~DecimalContext() NOEXCEPT_ARG(false)
|
||||
{
|
||||
// Typically excptions should better be not thrown from destructors.
|
||||
// Typically exceptions should better be not thrown from destructors.
|
||||
// But in our case there should never be any exception raised inside
|
||||
// Decimal64/128 functions - C library never throw, i.e. dtor will
|
||||
// be never called due to exception processing.
|
||||
@ -121,11 +121,13 @@ unsigned digits(const unsigned pMax, unsigned char* const coeff, int& exp)
|
||||
}
|
||||
|
||||
i = pMax - i;
|
||||
|
||||
while (!coeff[i - 1])
|
||||
{
|
||||
fb_assert(i > 0);
|
||||
--i;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@ -152,11 +154,13 @@ void make(ULONG* key,
|
||||
if (sign)
|
||||
exp = -exp;
|
||||
}
|
||||
|
||||
*key++ = exp;
|
||||
|
||||
// convert to SLONG
|
||||
fb_assert(pMax / 9 < decSize / sizeof(int));
|
||||
memset(key, 0, decSize);
|
||||
|
||||
for (unsigned i = 0; i < pMax; ++i)
|
||||
{
|
||||
unsigned c = i / 9;
|
||||
@ -178,6 +182,7 @@ void grab(ULONG* key,
|
||||
sign = DECFLOAT_Sign;
|
||||
exp = -exp;
|
||||
}
|
||||
|
||||
if (exp != 0)
|
||||
exp -= (bias + 2);
|
||||
|
||||
@ -187,6 +192,7 @@ void grab(ULONG* key,
|
||||
int c = i / 9;
|
||||
bcd[i] = key[c] % 10;
|
||||
key[c] /= 10;
|
||||
|
||||
if (sign)
|
||||
bcd[i] = 9 - bcd[i];
|
||||
}
|
||||
@ -202,6 +208,7 @@ void grab(ULONG* key,
|
||||
memset(bcd, 0, pMax - 1 - i);
|
||||
exp += (pMax - 1 - i);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -239,6 +246,7 @@ Decimal64 Decimal64::set(SINT64 value, DecimalStatus decSt, int scale)
|
||||
DecimalContext context(this, decSt);
|
||||
decDoubleFromString(&dec, s, &context);
|
||||
}
|
||||
|
||||
setScale(decSt, -scale);
|
||||
|
||||
return *this;
|
||||
@ -265,16 +273,19 @@ Decimal64 Decimal64::set(double value, DecimalStatus decSt)
|
||||
void Decimal64::toString(DecimalStatus decSt, unsigned length, char* to) const
|
||||
{
|
||||
DecimalContext context(this, decSt);
|
||||
|
||||
if (length)
|
||||
{
|
||||
--length;
|
||||
char s[DECDOUBLE_String];
|
||||
memset(s, 0, sizeof(s));
|
||||
decDoubleToString(&dec, s);
|
||||
|
||||
if (strlen(s) > length)
|
||||
decContextSetStatus(&context, DEC_Invalid_operation);
|
||||
else
|
||||
length = strlen(s);
|
||||
|
||||
memcpy(to, s, length + 1);
|
||||
}
|
||||
else
|
||||
@ -326,7 +337,7 @@ int Decimal64::compare(DecimalStatus decSt, Decimal64 tgt) const
|
||||
|
||||
bool Decimal64::isInf() const
|
||||
{
|
||||
switch(decDoubleClass(&dec))
|
||||
switch (decDoubleClass(&dec))
|
||||
{
|
||||
case DEC_CLASS_NEG_INF:
|
||||
case DEC_CLASS_POS_INF:
|
||||
@ -338,7 +349,7 @@ bool Decimal64::isInf() const
|
||||
|
||||
bool Decimal64::isNan() const
|
||||
{
|
||||
switch(decDoubleClass(&dec))
|
||||
switch (decDoubleClass(&dec))
|
||||
{
|
||||
case DEC_CLASS_SNAN:
|
||||
case DEC_CLASS_QNAN:
|
||||
@ -468,6 +479,7 @@ Decimal128 Decimal128::set(SINT64 value, DecimalStatus decSt, int scale)
|
||||
decQuadFromUInt32(&down, low);
|
||||
decQuadFMA(&dec, &up, &pow2_32, &down, &context);
|
||||
}
|
||||
|
||||
setScale(decSt, -scale);
|
||||
|
||||
return *this;
|
||||
@ -509,16 +521,19 @@ int Decimal128::toInteger(DecimalStatus decSt, int scale) const
|
||||
void Decimal128::toString(DecimalStatus decSt, unsigned length, char* to) const
|
||||
{
|
||||
DecimalContext context(this, decSt);
|
||||
|
||||
if (length)
|
||||
{
|
||||
--length;
|
||||
char s[DECQUAD_String];
|
||||
memset(s, 0, sizeof(s));
|
||||
decQuadToString(&dec, s);
|
||||
|
||||
if (strlen(s) > length)
|
||||
decContextSetStatus(&context, DEC_Invalid_operation);
|
||||
else
|
||||
length = strlen(s);
|
||||
|
||||
memcpy(to, s, length + 1);
|
||||
}
|
||||
else
|
||||
@ -535,6 +550,7 @@ void Decimal128::toString(string& to) const
|
||||
double Decimal128::toDouble(DecimalStatus decSt) const
|
||||
{
|
||||
DecimalContext context(this, decSt);
|
||||
|
||||
if (compare(decSt, dmin) < 0 || compare(decSt, dmax) > 0)
|
||||
decContextSetStatus(&context, DEC_Overflow);
|
||||
else
|
||||
@ -544,6 +560,7 @@ double Decimal128::toDouble(DecimalStatus decSt) const
|
||||
decQuadToString(&dec, s);
|
||||
return atof(s);
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@ -565,6 +582,7 @@ SINT64 Decimal128::toInt64(DecimalStatus decSt, int scale) const
|
||||
unsigned char coeff[DECQUAD_Pmax];
|
||||
int sign = decQuadGetCoefficient(&wrk.dec, coeff);
|
||||
SINT64 rc = 0;
|
||||
|
||||
for (int i = 0; i < DECQUAD_Pmax; ++i)
|
||||
{
|
||||
rc *= 10;
|
||||
@ -573,6 +591,7 @@ SINT64 Decimal128::toInt64(DecimalStatus decSt, int scale) const
|
||||
else
|
||||
rc += coeff[i];
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -184,4 +184,4 @@ public:
|
||||
} // namespace Firebird
|
||||
|
||||
|
||||
#endif // FB_DYNAMIC_STRINGS
|
||||
#endif // FB_DECIMAL_FLOAT
|
||||
|
@ -608,7 +608,7 @@ extern "C" int remove(const char* path);
|
||||
#define NOEXCEPT_ARG(X) noexcept((X))
|
||||
#else
|
||||
#define NOEXCEPT
|
||||
#define NOEXCEPT_ARG(X)
|
||||
#define NOEXCEPT_ARG(X)
|
||||
#endif
|
||||
|
||||
/* alignment macros */
|
||||
|
@ -309,13 +309,13 @@ static void decimal_float_to_text(const dsc* from, dsc* to, DecimalStatus decSt,
|
||||
{
|
||||
Decimal128 d;
|
||||
if (from->dsc_dtype == dtype_dec64)
|
||||
d = *((Decimal64*)from->dsc_address);
|
||||
d = *((Decimal64*) from->dsc_address);
|
||||
else
|
||||
d = *((Decimal128*)from->dsc_address);
|
||||
d = *((Decimal128*) from->dsc_address);
|
||||
|
||||
d.toString(decSt, sizeof(temp), temp);
|
||||
}
|
||||
catch(const Exception& ex)
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
// reraise using function passed in callbacks
|
||||
Arg::StatusVector v(ex);
|
||||
@ -1277,6 +1277,7 @@ double CVT_get_double(const dsc* desc, DecimalStatus decSt, ErrorFunction err, b
|
||||
*getNumericOverflow = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_numeric_out_of_range));
|
||||
}
|
||||
}
|
||||
@ -1317,6 +1318,7 @@ double CVT_get_double(const dsc* desc, DecimalStatus decSt, ErrorFunction err, b
|
||||
*getNumericOverflow = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_numeric_out_of_range));
|
||||
}
|
||||
|
||||
@ -1339,6 +1341,7 @@ double CVT_get_double(const dsc* desc, DecimalStatus decSt, ErrorFunction err, b
|
||||
*getNumericOverflow = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_numeric_out_of_range));
|
||||
}
|
||||
}
|
||||
@ -2097,6 +2100,7 @@ void CVT_make_null_string(const dsc* desc,
|
||||
fb_assert(temp);
|
||||
|
||||
USHORT len = CVT_make_string(desc, to_interp, address, temp, --length, decSt, err);
|
||||
|
||||
if (*address != temp->vary_string)
|
||||
{
|
||||
if (len > length)
|
||||
@ -2104,6 +2108,7 @@ void CVT_make_null_string(const dsc* desc,
|
||||
memcpy(temp->vary_string, *address, len);
|
||||
temp->vary_length = len;
|
||||
}
|
||||
|
||||
fb_assert(temp->vary_length == len);
|
||||
temp->vary_string[len] = 0;
|
||||
}
|
||||
@ -2589,7 +2594,7 @@ Decimal64 CVT_get_dec64(const dsc* desc, DecimalStatus decSt, ErrorFunction err)
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(const Exception& ex)
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
// reraise using passed error function
|
||||
Arg::StatusVector v(ex);
|
||||
@ -2673,7 +2678,7 @@ Decimal128 CVT_get_dec128(const dsc* desc, DecimalStatus decSt, ErrorFunction er
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(const Exception& ex)
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
// reraise using passed error function
|
||||
Arg::StatusVector v(ex);
|
||||
|
@ -343,7 +343,6 @@ bool_t xdr_double(XDR* xdrs, double* ip)
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool_t xdr_dec64(XDR* xdrs, Firebird::Decimal64* ip)
|
||||
{
|
||||
return xdr_hyper(xdrs, ip->getBytes());
|
||||
|
@ -1879,7 +1879,6 @@ void RegrAggNode::aggInit(thread_db* tdbb, jrd_req* request) const
|
||||
impure_value_ex* impure = request->getImpure<impure_value_ex>(impureOffset);
|
||||
RegrImpure* impure2 = request->getImpure<RegrImpure>(impure2Offset);
|
||||
|
||||
|
||||
if (nodFlags & FLAG_DECFLOAT)
|
||||
{
|
||||
impure->make_decimal128(CDecimal128(0));
|
||||
|
@ -8039,7 +8039,7 @@ const TextCode* getCodeByText(const MetaName& text, const TextCode* textCode, un
|
||||
|
||||
|
||||
SetRoundNode::SetRoundNode(MemoryPool& pool, Firebird::MetaName* name)
|
||||
: SessionManagementNode(pool)
|
||||
: SessionManagementNode(pool)
|
||||
{
|
||||
fb_assert(name);
|
||||
const TextCode* mode = getCodeByText(*name, roundModes, FB_RMODE_OFFSET);
|
||||
|
@ -591,6 +591,7 @@ using namespace Firebird;
|
||||
%token <metaNamePtr> REGR_SYY
|
||||
|
||||
// tokens added for Firebird 4.0
|
||||
|
||||
%token <metaNamePtr> BINARY
|
||||
%token <metaNamePtr> BIND
|
||||
%token <metaNamePtr> COMPARE_DECFLOAT
|
||||
|
Loading…
Reference in New Issue
Block a user