1# 2005 Mar 16 2# 3# The author disclaims copyright to this source code. In place of 4# a legal notice, here is a blessing: 5# 6# May you do good and not evil. 7# May you find forgiveness for yourself and forgive others. 8# May you share freely, never taking more than you give. 9# 10#*********************************************************************** 11# This file implements regression tests for SQLite library. 12# 13# This file implements tests for miscellanous features that were 14# left out of other test files. 15# 16# $Id: misc5.test,v 1.3 2005/06/06 21:19:58 drh Exp $ 17 18set testdir [file dirname $argv0] 19source $testdir/tester.tcl 20 21# Build records using the MakeRecord opcode such that the size of the 22# header is at the transition point in the size of a varint. 23# 24# This test causes an assertion failure or a buffer overrun in version 25# 3.1.5 and earlier. 26# 27for {set i 120} {$i<140} {incr i} { 28 do_test misc5-1.$i { 29 catchsql {DROP TABLE t1} 30 set sql1 {CREATE TABLE t1} 31 set sql2 {INSERT INTO t1 VALUES} 32 set sep ( 33 for {set j 0} {$j<$i} {incr j} { 34 append sql1 ${sep}a$j 35 append sql2 ${sep}$j 36 set sep , 37 } 38 append sql1 {);} 39 append sql2 {);} 40 execsql $sql1$sql2 41 } {} 42} 43 44# Make sure large integers are stored correctly. 45# 46do_test misc5-2.1 { 47 execsql { 48 create table t2(x unique); 49 insert into t2 values(1); 50 insert or ignore into t2 select x*2 from t2; 51 insert or ignore into t2 select x*4 from t2; 52 insert or ignore into t2 select x*16 from t2; 53 insert or ignore into t2 select x*256 from t2; 54 insert or ignore into t2 select x*65536 from t2; 55 insert or ignore into t2 select x*2147483648 from t2; 56 insert or ignore into t2 select x-1 from t2; 57 insert or ignore into t2 select x+1 from t2; 58 insert or ignore into t2 select -x from t2; 59 select count(*) from t2; 60 } 61} 371 62do_test misc5-2.2 { 63 execsql { 64 select x from t2 order by x; 65 } 66} \ 67"-4611686018427387905\ 68-4611686018427387904\ 69-4611686018427387903\ 70-2305843009213693953\ 71-2305843009213693952\ 72-2305843009213693951\ 73-1152921504606846977\ 74-1152921504606846976\ 75-1152921504606846975\ 76-576460752303423489\ 77-576460752303423488\ 78-576460752303423487\ 79-288230376151711745\ 80-288230376151711744\ 81-288230376151711743\ 82-144115188075855873\ 83-144115188075855872\ 84-144115188075855871\ 85-72057594037927937\ 86-72057594037927936\ 87-72057594037927935\ 88-36028797018963969\ 89-36028797018963968\ 90-36028797018963967\ 91-18014398509481985\ 92-18014398509481984\ 93-18014398509481983\ 94-9007199254740993\ 95-9007199254740992\ 96-9007199254740991\ 97-4503599627370497\ 98-4503599627370496\ 99-4503599627370495\ 100-2251799813685249\ 101-2251799813685248\ 102-2251799813685247\ 103-1125899906842625\ 104-1125899906842624\ 105-1125899906842623\ 106-562949953421313\ 107-562949953421312\ 108-562949953421311\ 109-281474976710657\ 110-281474976710656\ 111-281474976710655\ 112-140737488355329\ 113-140737488355328\ 114-140737488355327\ 115-70368744177665\ 116-70368744177664\ 117-70368744177663\ 118-35184372088833\ 119-35184372088832\ 120-35184372088831\ 121-17592186044417\ 122-17592186044416\ 123-17592186044415\ 124-8796093022209\ 125-8796093022208\ 126-8796093022207\ 127-4398046511105\ 128-4398046511104\ 129-4398046511103\ 130-2199023255553\ 131-2199023255552\ 132-2199023255551\ 133-1099511627777\ 134-1099511627776\ 135-1099511627775\ 136-549755813889\ 137-549755813888\ 138-549755813887\ 139-274877906945\ 140-274877906944\ 141-274877906943\ 142-137438953473\ 143-137438953472\ 144-137438953471\ 145-68719476737\ 146-68719476736\ 147-68719476735\ 148-34359738369\ 149-34359738368\ 150-34359738367\ 151-17179869185\ 152-17179869184\ 153-17179869183\ 154-8589934593\ 155-8589934592\ 156-8589934591\ 157-4294967297\ 158-4294967296\ 159-4294967295\ 160-2147483649\ 161-2147483648\ 162-2147483647\ 163-1073741825\ 164-1073741824\ 165-1073741823\ 166-536870913\ 167-536870912\ 168-536870911\ 169-268435457\ 170-268435456\ 171-268435455\ 172-134217729\ 173-134217728\ 174-134217727\ 175-67108865\ 176-67108864\ 177-67108863\ 178-33554433\ 179-33554432\ 180-33554431\ 181-16777217\ 182-16777216\ 183-16777215\ 184-8388609\ 185-8388608\ 186-8388607\ 187-4194305\ 188-4194304\ 189-4194303\ 190-2097153\ 191-2097152\ 192-2097151\ 193-1048577\ 194-1048576\ 195-1048575\ 196-524289\ 197-524288\ 198-524287\ 199-262145\ 200-262144\ 201-262143\ 202-131073\ 203-131072\ 204-131071\ 205-65537\ 206-65536\ 207-65535\ 208-32769\ 209-32768\ 210-32767\ 211-16385\ 212-16384\ 213-16383\ 214-8193\ 215-8192\ 216-8191\ 217-4097\ 218-4096\ 219-4095\ 220-2049\ 221-2048\ 222-2047\ 223-1025\ 224-1024\ 225-1023\ 226-513\ 227-512\ 228-511\ 229-257\ 230-256\ 231-255\ 232-129\ 233-128\ 234-127\ 235-65\ 236-64\ 237-63\ 238-33\ 239-32\ 240-31\ 241-17\ 242-16\ 243-15\ 244-9\ 245-8\ 246-7\ 247-5\ 248-4\ 249-3\ 250-2\ 251-1\ 2520\ 2531\ 2542\ 2553\ 2564\ 2575\ 2587\ 2598\ 2609\ 26115\ 26216\ 26317\ 26431\ 26532\ 26633\ 26763\ 26864\ 26965\ 270127\ 271128\ 272129\ 273255\ 274256\ 275257\ 276511\ 277512\ 278513\ 2791023\ 2801024\ 2811025\ 2822047\ 2832048\ 2842049\ 2854095\ 2864096\ 2874097\ 2888191\ 2898192\ 2908193\ 29116383\ 29216384\ 29316385\ 29432767\ 29532768\ 29632769\ 29765535\ 29865536\ 29965537\ 300131071\ 301131072\ 302131073\ 303262143\ 304262144\ 305262145\ 306524287\ 307524288\ 308524289\ 3091048575\ 3101048576\ 3111048577\ 3122097151\ 3132097152\ 3142097153\ 3154194303\ 3164194304\ 3174194305\ 3188388607\ 3198388608\ 3208388609\ 32116777215\ 32216777216\ 32316777217\ 32433554431\ 32533554432\ 32633554433\ 32767108863\ 32867108864\ 32967108865\ 330134217727\ 331134217728\ 332134217729\ 333268435455\ 334268435456\ 335268435457\ 336536870911\ 337536870912\ 338536870913\ 3391073741823\ 3401073741824\ 3411073741825\ 3422147483647\ 3432147483648\ 3442147483649\ 3454294967295\ 3464294967296\ 3474294967297\ 3488589934591\ 3498589934592\ 3508589934593\ 35117179869183\ 35217179869184\ 35317179869185\ 35434359738367\ 35534359738368\ 35634359738369\ 35768719476735\ 35868719476736\ 35968719476737\ 360137438953471\ 361137438953472\ 362137438953473\ 363274877906943\ 364274877906944\ 365274877906945\ 366549755813887\ 367549755813888\ 368549755813889\ 3691099511627775\ 3701099511627776\ 3711099511627777\ 3722199023255551\ 3732199023255552\ 3742199023255553\ 3754398046511103\ 3764398046511104\ 3774398046511105\ 3788796093022207\ 3798796093022208\ 3808796093022209\ 38117592186044415\ 38217592186044416\ 38317592186044417\ 38435184372088831\ 38535184372088832\ 38635184372088833\ 38770368744177663\ 38870368744177664\ 38970368744177665\ 390140737488355327\ 391140737488355328\ 392140737488355329\ 393281474976710655\ 394281474976710656\ 395281474976710657\ 396562949953421311\ 397562949953421312\ 398562949953421313\ 3991125899906842623\ 4001125899906842624\ 4011125899906842625\ 4022251799813685247\ 4032251799813685248\ 4042251799813685249\ 4054503599627370495\ 4064503599627370496\ 4074503599627370497\ 4089007199254740991\ 4099007199254740992\ 4109007199254740993\ 41118014398509481983\ 41218014398509481984\ 41318014398509481985\ 41436028797018963967\ 41536028797018963968\ 41636028797018963969\ 41772057594037927935\ 41872057594037927936\ 41972057594037927937\ 420144115188075855871\ 421144115188075855872\ 422144115188075855873\ 423288230376151711743\ 424288230376151711744\ 425288230376151711745\ 426576460752303423487\ 427576460752303423488\ 428576460752303423489\ 4291152921504606846975\ 4301152921504606846976\ 4311152921504606846977\ 4322305843009213693951\ 4332305843009213693952\ 4342305843009213693953\ 4354611686018427387903\ 4364611686018427387904\ 4374611686018427387905" 438 439# Ticket #1210. Do proper reference counting of Table structures 440# so that deeply nested SELECT statements can be flattened correctly. 441# 442do_test misc5-3.1 { 443 execsql { 444 CREATE TABLE songs(songid, artist, timesplayed); 445 INSERT INTO songs VALUES(1,'one',1); 446 INSERT INTO songs VALUES(2,'one',2); 447 INSERT INTO songs VALUES(3,'two',3); 448 INSERT INTO songs VALUES(4,'three',5); 449 INSERT INTO songs VALUES(5,'one',7); 450 INSERT INTO songs VALUES(6,'two',11); 451 SELECT DISTINCT artist 452 FROM ( 453 SELECT DISTINCT artist 454 FROM songs 455 WHERE songid IN ( 456 SELECT songid 457 FROM songs 458 WHERE LOWER(artist) = ( 459 SELECT DISTINCT LOWER(artist) 460 FROM ( 461 SELECT DISTINCT artist,sum(timesplayed) AS total 462 FROM songs 463 GROUP BY LOWER(artist) 464 ORDER BY total DESC 465 LIMIT 10 466 ) 467 WHERE artist <> '' 468 ) 469 ) 470 ) 471 ORDER BY LOWER(artist) ASC; 472 } 473} {two} 474 475 476finish_test 477