[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-dev
Subject:    [sqlite-dev] About the gcc-decimal.patch
From:       Domingo Alvarez Duarte <mingodad () gmail ! com>
Date:       2011-12-17 19:32:11
Message-ID: CALCTSaj0dv8iS5LyyVKbFFQx77rEogNnbx1B83ux40nXk3MBMg () mail ! gmail ! com
[Download RAW message or body]

I did more tests and found that although the sqlite3 with _Decimal64
can't read the values correctly from databases writen by sqlite with
double, it works correctly with data writen by itself.

I generated a test sql data with this lua script:
-----
print("begin;")
print("create table test(i integer primary key, val float);")
for i=1, 1000000 do
	print("insert into test values(", i, ",", i/2.35 ,");")
end
print("commit;")
-----
it generates a 1,000,000 million rows table:
----
begin;
create table test(i integer primary key, val float);
insert into test values(	1	,	0.42553191489362	);
insert into test values(	2	,	0.85106382978723	);
...
commit;
---

Feeding this file on both sqlite with _Decimal64 and double succeded,
_Decimal64 took a bit more time.
executing several select on both gives aproximattely the same result
almost all the time when they diverge is at .0000**, so it's seems to
be expected and correct.

Then I feed this select on both:

select ((a-b)*c)=201 from( select .3 as a, .099 as b, 1000 as c);

With _Decimal64 I get true "1" as result while with double I get false
"0" as result, here the difference between working with binary and
decimal shows that _Decimal64 gives the expected results.

Dumping both 1,000,000 rows databases ande comparing then gives two
identical files.

So now I should discover why it's writing with a different format with
_Decimal64.

Also the executable size is as before with double 500KB with
_Decimal64 3MB, all tests was done on windows vista with gcc mingw
4.6.1.

The patch is very simple and allow standard sqlite build with double
or with decimal only by defining SQLITE_USE_DECIMAL.

I think this will be util to other people as well and I hope it can be
added to th official sqlite repository.

Again thanks for any comments/sugestions/critics !

P.S. the patch is awaiting the moderator to aprove it. Soon it will be here.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic