Correctly store large integers. Ticket #1212. (CVS 2445)

FossilOrigin-Name: 00e20690bb8cc6522c9c48f36f0c3336ae007827
This commit is contained in:
drh 2005-04-15 12:04:34 +00:00
parent c7e22ee254
commit b47d45ccbf
4 changed files with 408 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Added\stests\sto\sexercise\sdelete,\sinsert,\sand\supdate\striggers\son\sviews\s(tkt\s#1169)\s(CVS\s2444)
D 2005-04-08T19:48:28
C Correctly\s\sstore\slarge\sintegers.\s\sTicket\s#1212.\s(CVS\s2445)
D 2005-04-15T12:04:34
F Makefile.in 5c00d0037104de2a50ac7647a5f12769795957a3
F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -79,7 +79,7 @@ F src/vdbe.c d2574042c44baf6b1016c61e8072dec529ac748a
F src/vdbe.h 7f586cb6d6b57764e5aac1f87107d6a95ddce24c
F src/vdbeInt.h 4afaae2f4adcab54ad2a40dabb2e689fba7b1561
F src/vdbeapi.c 467caa6e6fb9247528b1c7ab9132ae1b4748e8ac
F src/vdbeaux.c 3efd3cffad110508d1a32c6fa546982007f86e9f
F src/vdbeaux.c b4d9b9a9d87254a279a88e3f91d0db048071c856
F src/vdbemem.c 4e853ce3151eaf7906150da85a1b3ce1fe5e8da8
F src/where.c c4b227458e8993decb515ed9a2fe2d4f5f8e3125
F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
@ -162,7 +162,7 @@ F test/misc1.test a4a36c19f05e4c8646efe7a0d7242ba645d07379
F test/misc2.test d51379cc670b850827cd37b7fc07c0f17736004e
F test/misc3.test 7bd937e2c62bcc6be71939faf068d506467b1e03
F test/misc4.test edd3e3adf5b6e3b995b29843565ca58dd602f9a7
F test/misc5.test 406d3f9523953a028307d076f2eb2687218cb46d
F test/misc5.test 5158e1be2c878af42b60f99d963001e4cae309fc
F test/misuse.test 1c7fee3c4c0cb4008717ecccf5c72281fac0008e
F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0
F test/null.test 69c62daf1630bf54c87bbc7ef2e22012e58d6da8
@ -278,7 +278,7 @@ F www/tclsqlite.tcl 425be741b8ae664f55cb1ef2371aab0a75109cf9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b
P 99fcd5561b539010b7e76cad7815bb2350541f00
R 054c025956c84db1eb39d1b4b642e446
U kwel
Z 31e4c308ce0684271311e37d6b50e03f
P 6cd19ddcba5fbea1be04b44699c911294618e948
R a7a67bb0e6e2a718d4c8bea2017ab2d0
U drh
Z cea3468783cfb264aa646a98028d300b

View File

@ -1 +1 @@
6cd19ddcba5fbea1be04b44699c911294618e948
00e20690bb8cc6522c9c48f36f0c3336ae007827

View File

@ -1605,7 +1605,7 @@ u32 sqlite3VdbeSerialType(Mem *pMem){
}
if( flags&MEM_Int ){
/* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */
# define MAX_6BYTE ((((i64)0x00010000)<<32)-1)
# define MAX_6BYTE ((((i64)0x00001000)<<32)-1)
i64 i = pMem->i;
u64 u = i<0 ? -i : i;
if( u<=127 ) return 1;

View File

@ -13,7 +13,7 @@
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc5.test,v 1.1 2005/03/17 03:15:40 drh Exp $
# $Id: misc5.test,v 1.2 2005/04/15 12:04:34 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -41,4 +41,401 @@ for {set i 120} {$i<140} {incr i} {
} {}
}
# Make sure large integers are stored correctly.
#
do_test misc5-2.1 {
execsql {
create table t2(x unique);
insert into t2 values(1);
insert or ignore into t2 select x*2 from t2;
insert or ignore into t2 select x*4 from t2;
insert or ignore into t2 select x*16 from t2;
insert or ignore into t2 select x*256 from t2;
insert or ignore into t2 select x*65536 from t2;
insert or ignore into t2 select x*2147483648 from t2;
insert or ignore into t2 select x-1 from t2;
insert or ignore into t2 select x+1 from t2;
insert or ignore into t2 select -x from t2;
select count(*) from t2;
}
} 371
do_test misc5-2.2 {
execsql {
select x from t2 order by x;
}
} \
"-4611686018427387905\
-4611686018427387904\
-4611686018427387903\
-2305843009213693953\
-2305843009213693952\
-2305843009213693951\
-1152921504606846977\
-1152921504606846976\
-1152921504606846975\
-576460752303423489\
-576460752303423488\
-576460752303423487\
-288230376151711745\
-288230376151711744\
-288230376151711743\
-144115188075855873\
-144115188075855872\
-144115188075855871\
-72057594037927937\
-72057594037927936\
-72057594037927935\
-36028797018963969\
-36028797018963968\
-36028797018963967\
-18014398509481985\
-18014398509481984\
-18014398509481983\
-9007199254740993\
-9007199254740992\
-9007199254740991\
-4503599627370497\
-4503599627370496\
-4503599627370495\
-2251799813685249\
-2251799813685248\
-2251799813685247\
-1125899906842625\
-1125899906842624\
-1125899906842623\
-562949953421313\
-562949953421312\
-562949953421311\
-281474976710657\
-281474976710656\
-281474976710655\
-140737488355329\
-140737488355328\
-140737488355327\
-70368744177665\
-70368744177664\
-70368744177663\
-35184372088833\
-35184372088832\
-35184372088831\
-17592186044417\
-17592186044416\
-17592186044415\
-8796093022209\
-8796093022208\
-8796093022207\
-4398046511105\
-4398046511104\
-4398046511103\
-2199023255553\
-2199023255552\
-2199023255551\
-1099511627777\
-1099511627776\
-1099511627775\
-549755813889\
-549755813888\
-549755813887\
-274877906945\
-274877906944\
-274877906943\
-137438953473\
-137438953472\
-137438953471\
-68719476737\
-68719476736\
-68719476735\
-34359738369\
-34359738368\
-34359738367\
-17179869185\
-17179869184\
-17179869183\
-8589934593\
-8589934592\
-8589934591\
-4294967297\
-4294967296\
-4294967295\
-2147483649\
-2147483648\
-2147483647\
-1073741825\
-1073741824\
-1073741823\
-536870913\
-536870912\
-536870911\
-268435457\
-268435456\
-268435455\
-134217729\
-134217728\
-134217727\
-67108865\
-67108864\
-67108863\
-33554433\
-33554432\
-33554431\
-16777217\
-16777216\
-16777215\
-8388609\
-8388608\
-8388607\
-4194305\
-4194304\
-4194303\
-2097153\
-2097152\
-2097151\
-1048577\
-1048576\
-1048575\
-524289\
-524288\
-524287\
-262145\
-262144\
-262143\
-131073\
-131072\
-131071\
-65537\
-65536\
-65535\
-32769\
-32768\
-32767\
-16385\
-16384\
-16383\
-8193\
-8192\
-8191\
-4097\
-4096\
-4095\
-2049\
-2048\
-2047\
-1025\
-1024\
-1023\
-513\
-512\
-511\
-257\
-256\
-255\
-129\
-128\
-127\
-65\
-64\
-63\
-33\
-32\
-31\
-17\
-16\
-15\
-9\
-8\
-7\
-5\
-4\
-3\
-2\
-1\
0\
1\
2\
3\
4\
5\
7\
8\
9\
15\
16\
17\
31\
32\
33\
63\
64\
65\
127\
128\
129\
255\
256\
257\
511\
512\
513\
1023\
1024\
1025\
2047\
2048\
2049\
4095\
4096\
4097\
8191\
8192\
8193\
16383\
16384\
16385\
32767\
32768\
32769\
65535\
65536\
65537\
131071\
131072\
131073\
262143\
262144\
262145\
524287\
524288\
524289\
1048575\
1048576\
1048577\
2097151\
2097152\
2097153\
4194303\
4194304\
4194305\
8388607\
8388608\
8388609\
16777215\
16777216\
16777217\
33554431\
33554432\
33554433\
67108863\
67108864\
67108865\
134217727\
134217728\
134217729\
268435455\
268435456\
268435457\
536870911\
536870912\
536870913\
1073741823\
1073741824\
1073741825\
2147483647\
2147483648\
2147483649\
4294967295\
4294967296\
4294967297\
8589934591\
8589934592\
8589934593\
17179869183\
17179869184\
17179869185\
34359738367\
34359738368\
34359738369\
68719476735\
68719476736\
68719476737\
137438953471\
137438953472\
137438953473\
274877906943\
274877906944\
274877906945\
549755813887\
549755813888\
549755813889\
1099511627775\
1099511627776\
1099511627777\
2199023255551\
2199023255552\
2199023255553\
4398046511103\
4398046511104\
4398046511105\
8796093022207\
8796093022208\
8796093022209\
17592186044415\
17592186044416\
17592186044417\
35184372088831\
35184372088832\
35184372088833\
70368744177663\
70368744177664\
70368744177665\
140737488355327\
140737488355328\
140737488355329\
281474976710655\
281474976710656\
281474976710657\
562949953421311\
562949953421312\
562949953421313\
1125899906842623\
1125899906842624\
1125899906842625\
2251799813685247\
2251799813685248\
2251799813685249\
4503599627370495\
4503599627370496\
4503599627370497\
9007199254740991\
9007199254740992\
9007199254740993\
18014398509481983\
18014398509481984\
18014398509481985\
36028797018963967\
36028797018963968\
36028797018963969\
72057594037927935\
72057594037927936\
72057594037927937\
144115188075855871\
144115188075855872\
144115188075855873\
288230376151711743\
288230376151711744\
288230376151711745\
576460752303423487\
576460752303423488\
576460752303423489\
1152921504606846975\
1152921504606846976\
1152921504606846977\
2305843009213693951\
2305843009213693952\
2305843009213693953\
4611686018427387903\
4611686018427387904\
4611686018427387905"
finish_test