Numerics bigger than 32-bit and sqlite as 64-bit TCL extension

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Numerics bigger than 32-bit and sqlite as 64-bit TCL extension

Rafał Ponikwia
Hi,
I'm using sqlite3 TCL extension from Teapot (version 64-bit). When I try
to insert number bigger than signed 32-bit it inserts wrong number to
database.
Same code run with 32-bit version works fine.

Example in TCL console illustrating this issue:

% info patchlevel
8.6.4
% package require sqlite3
3.8.10.2
% set l1 [expr {2 ** 31 - 1}]
2147483647
% set l2 2147483649
2147483649
% set l3 [expr {$l1 + 2}]
2147483649
% ::tcl::unsupported::representation $l1
value is a int with a refcount of 3, object pointer at 00000000006CEB10,
internal representation 000000007FFFFFFF:0000000000000000, string
representation "2147483647"
% ::tcl::unsupported::representation $l2
value is a pure string with a refcount of 4, object pointer at
00000000006CE930, string representation "2147483649"
% ::tcl::unsupported::representation $l3
value is a wideInt with a refcount of 2, object pointer at
00000000006CF2F0, internal representation
0000000080000001:0000000000000000, string representation "2147483649"
% sqlite3 db C:/tmp/test.sqlite
% db eval {
     CREATE TABLE test (num NUMERIC);
     INSERT INTO test (num) VALUES ($l1), ($l2), ($l3);
     SELECT * FROM test;
}
2147483647 2147483649 -2147483647

Regards,
RP.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Numerics bigger than 32-bit and sqlite as 64-bit TCL extension

Richard Hipp-3
On 7/28/15, Rafał Ponikwia <[hidden email]> wrote:

> Hi,
> I'm using sqlite3 TCL extension from Teapot (version 64-bit). When I try
> to insert number bigger than signed 32-bit it inserts wrong number to
> database.
>> % db eval {
>      CREATE TABLE test (num NUMERIC);
>      INSERT INTO test (num) VALUES ($l1), ($l2), ($l3);
>      SELECT * FROM test;
> }
> 2147483647 2147483649 -2147483647
>

I get the correct answer (2147483647 2147483649 2147483649) when I try
this on 64-bit Ubuntu.
--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Numerics bigger than 32-bit and sqlite as 64-bit TCL extension

Rafał Ponikwia
On 28.07.2015 18:52, Richard Hipp wrote:
> I get the correct answer (2147483647 2147483649 2147483649) when I try
> this on 64-bit Ubuntu.
Yes, I've just tested it on Debian x64 and it works too, but I noticed
that $l3 is stored as int, not as wideInt like on Windows:
% ::tcl::unsupported::representation $l3
value is a int with a refcount of 2, object pointer at 0x1776e40,
internal representation 0x80000001:(nil), string representation "2147483649"
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Numerics bigger than 32-bit and sqlite as 64-bit TCL extension

Jan Nijtmans
In reply to this post by Richard Hipp-3
2015-07-28 11:52 GMT-05:00 Richard Hipp <[hidden email]>:
> On 7/28/15, Rafał Ponikwia <[hidden email]> wrote:
>> Hi,
>> I'm using sqlite3 TCL extension from Teapot (version 64-bit). When I try
>> to insert number bigger than signed 32-bit it inserts wrong number to
>> database.
>> % sqlite3 db C:/tmp/test.sqlite
>> % db eval {
      CREATE TABLE test (num NUMERIC);
      INSERT INTO test (num) VALUES ($l1), ($l2), ($l3);
      SELECT * FROM test;
 }
>> 2147483647 2147483649 -2147483647
>>
>
> I get the correct answer (2147483647 2147483649 2147483649) when I try
> this on 64-bit Ubuntu.

Tried this on both cygwin64 and mingw-w64 (64-bit), getting the same
correct answer in both environments. e.g.:
    >tclsh86
    % set tcl_platform(pointerSize)
    8
    % package require sqlite3
    3.8.11.1
    % info loaded
    {C:/cygwin64/lib/sqlite3.8.11.1/sqlite38111.dll Sqlite3}
    % set l1 [expr {2 ** 31 - 1}]
    2147483647
    % set l2 2147483649
    2147483649
    % set l3 [expr {$l1 + 2}]
    2147483649
    % sqlite3 db test.sqlite
    % db eval {
          CREATE TABLE test (num NUMERIC);
          INSERT INTO test (num) VALUES ($l1), ($l2), ($l3);
          SELECT * FROM test;
     }
    2147483647 2147483649 2147483649
    %

@Andreas: could this be a compiler issue?

Regards,
        Jan Nijtmans
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Numerics bigger than 32-bit and sqlite as 64-bit TCL extension

Andreas Kupries-2
On Tue, Aug 4, 2015 at 12:34 PM, Jan Nijtmans <[hidden email]> wrote:

> 2015-07-28 11:52 GMT-05:00 Richard Hipp <[hidden email]>:
>> On 7/28/15, Rafał Ponikwia <[hidden email]> wrote:
>>> Hi,
>>> I'm using sqlite3 TCL extension from Teapot (version 64-bit). When I try
>>> to insert number bigger than signed 32-bit it inserts wrong number to
>>> database.
>>> % sqlite3 db C:/tmp/test.sqlite
>>> % db eval {
>       CREATE TABLE test (num NUMERIC);
>       INSERT INTO test (num) VALUES ($l1), ($l2), ($l3);
>       SELECT * FROM test;
>  }
>>> 2147483647 2147483649 -2147483647
>>>
>>
>> I get the correct answer (2147483647 2147483649 2147483649) when I try
>> this on 64-bit Ubuntu.
>
> Tried this on both cygwin64 and mingw-w64 (64-bit), getting the same
> correct answer in both environments. e.g.:
>     >tclsh86
>     % set tcl_platform(pointerSize)
>     8
>     % package require sqlite3
>     3.8.11.1
>     % info loaded
>     {C:/cygwin64/lib/sqlite3.8.11.1/sqlite38111.dll Sqlite3}
>     % set l1 [expr {2 ** 31 - 1}]
>     2147483647
>     % set l2 2147483649
>     2147483649
>     % set l3 [expr {$l1 + 2}]
>     2147483649
>     % sqlite3 db test.sqlite
>     % db eval {
>           CREATE TABLE test (num NUMERIC);
>           INSERT INTO test (num) VALUES ($l1), ($l2), ($l3);
>           SELECT * FROM test;
>      }
>     2147483647 2147483649 2147483649
>     %
>
> @Andreas: could this be a compiler issue?

Maybe !?
For the record, we (AS) are using the MS Platform SDK cl.exe for the
64bit build of ActiveTcl, sqlite, etc.

>
> Regards,
>         Jan Nijtmans



--
% Tcl'2015 Oct 19-23 = http://www.tcl.tk/community/tcl2015/cfp.html
% EuroTcl'15 June 20-21 = http://www.eurotcl.tcl3d.org/
Andreas Kupries
Senior Tcl Developer
Code to Cloud: Smarter, Safer, Faster™
F: 778.786.1133
[hidden email], http://www.activestate.com
Learn about Stackato for Private PaaS: http://www.activestate.com/stackato
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users