Failing-int8-with-sqlite3-gem is a project mainly written in RUBY and C, it's free.
Ruby test and native sample to demonstrate bignums corruption issue when using sqlite3 gem
= Ruby test and native sample to demonstrate bignums corruption issue when using sqlite3 gem
The issue is reproduced at Mac OSX 10.6 and 10.7. The issue is NOT reproduced at 32 bit ubuntu and 32 bit Windows 7.
== DESCRIPTION
Some bignums are got corrupted when binding them as parameters.
Suppose we have schema like:
CREATE TABLE "employees" ("token" integer(8), "name" varchar(20) NOT NULL)
When executing SQL like:
INSERT INTO Employees(name, token) VALUES('employee-1', 4907021672125087844)
The result will be as expected. Token's value will be: 4907021672125087844
When doing the same using parameters binding like:
db.execute "INSERT INTO Employees(name, token) VALUES('employee-1', ?)", [4907021672125087844]
Token's value will be: 4907021672125087744 (note last last three digits expected: 844, actual 744)
== Running tests
Ruby test is at: ruby/failing_int8_test.rb. You will find two tests there:
A very simple native C sample that uses parameters binding "sqlite3_bind_int64" is at native folder.
To run it:
The result will be as expected: 4907021672125087844. This proves that the issue is in the sqlite3 gem itself.