Subject: | int64 fetching |
Date: | Thu, 9 Nov 2017 14:59:56 +0200 |
To: | bug-DBD-Firebird [...] rt.cpan.org |
From: | Vitaly Shyshkanov <vitvsh [...] gmail.com> |
Hello
I found problem in fetching int64 with negative value between -1..0 - minus
is loosing in this case. Problem is in this block
} else {
ISC_INT64 divisor, remainder;
divisor = scales[-var->sqlscale];
remainder = (i%divisor);
if (remainder < 0) remainder = -remainder;
snprintf(buf, sizeof(buf),
"%"DBD_IB_INT64f".%0*"DBD_IB_INT64f,
i/divisor, -var->sqlscale, remainder);
DBI_TRACE_imp_xxh(imp_sth, 3, (DBIc_LOGPIO(imp_sth),
"-------------->SQLINT64=%"DBD_IB_INT64f".%0*"DBD_IB_INT64f,i/divisor,
-var->sqlscale, remainder ));
}
I have -0.3 as numeric(15,5)
in this case i=-30000, divisor=100000, remainder=0
Result of division i/divisior is 0 (and in this place we lost minus)
Below is a possible solution of this issue
1441,1442c1441
< "%s%"DBD_IB_INT64f".%0*"DBD_IB_INT64f,
< i < 0 && !(i/divisor) ? "-" : "",
---
Show quoted text
> "%"DBD_IB_INT64f".%0*"DBD_IB_INT64f,