Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(842)

Side by Side Diff: third_party/sqlite/src/test/sort.test

Issue 949043002: Add //third_party/sqlite to dirs_to_snapshot, remove net_sql.patch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/test/softheap1.test ('k') | third_party/sqlite/src/test/sort2.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2001 September 15. 1 # 2001 September 15.
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 #
11 # This file implements regression tests for SQLite library. The 12 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing the CREATE TABLE statement. 13 # focus of this file is testing the sorter (code in vdbesort.c).
13 # 14 #
14 # $Id: sort.test,v 1.25 2005/11/14 22:29:06 drh Exp $
15 15
16 set testdir [file dirname $argv0] 16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl 17 source $testdir/tester.tcl
18 set testprefix sort
18 19
19 # Create a bunch of data to sort against 20 # Create a bunch of data to sort against
20 # 21 #
21 do_test sort-1.0 { 22 do_test sort-1.0 {
22 execsql { 23 execsql {
23 CREATE TABLE t1( 24 CREATE TABLE t1(
24 n int, 25 n int,
25 v varchar(10), 26 v varchar(10),
26 log int, 27 log int,
27 roman varchar(10), 28 roman varchar(10),
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 create table b (id integer primary key, aId integer, text); 458 create table b (id integer primary key, aId integer, text);
458 insert into a values (1); 459 insert into a values (1);
459 insert into b values (2, 1, 'xxx'); 460 insert into b values (2, 1, 'xxx');
460 insert into b values (1, 1, 'zzz'); 461 insert into b values (1, 1, 'zzz');
461 insert into b values (3, 1, 'yyy'); 462 insert into b values (3, 1, 'yyy');
462 select a.id, b.id, b.text from a join b on (a.id = b.aId) 463 select a.id, b.id, b.text from a join b on (a.id = b.aId)
463 order by a.id, b.text; 464 order by a.id, b.text;
464 } 465 }
465 } {1 2 xxx 1 3 yyy 1 1 zzz} 466 } {1 2 xxx 1 3 yyy 1 1 zzz}
466 467
468 #-------------------------------------------------------------------------
469 # Check that the sorter in vdbesort.c sorts in a stable fashion.
470 #
471 do_execsql_test sort-13.0 {
472 CREATE TABLE t10(a, b);
473 }
474 do_test sort-13.1 {
475 db transaction {
476 for {set i 0} {$i < 100000} {incr i} {
477 execsql { INSERT INTO t10 VALUES( $i/10, $i%10 ) }
478 }
479 }
480 } {}
481 do_execsql_test sort-13.2 {
482 SELECT a, b FROM t10 ORDER BY a;
483 } [db eval {SELECT a, b FROM t10 ORDER BY a, b}]
484 do_execsql_test sort-13.3 {
485 PRAGMA cache_size = 5;
486 SELECT a, b FROM t10 ORDER BY a;
487 } [db eval {SELECT a, b FROM t10 ORDER BY a, b}]
488
489 #-------------------------------------------------------------------------
490 # Sort some large ( > 4KiB) records.
491 #
492 proc cksum {x} {
493 set i1 1
494 set i2 2
495 binary scan $x c* L
496 foreach {a b} $L {
497 set i1 [expr (($i2<<3) + $a) & 0x7FFFFFFF]
498 set i2 [expr (($i1<<3) + $b) & 0x7FFFFFFF]
499 }
500 list $i1 $i2
501 }
502 db func cksum cksum
503
504 do_execsql_test sort-14.0 {
505 PRAGMA cache_size = 5;
506 CREATE TABLE t11(a, b);
507 INSERT INTO t11 VALUES(randomblob(5000), NULL);
508 INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --2
509 INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --3
510 INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --4
511 INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --5
512 INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --6
513 INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --7
514 INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --8
515 INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --9
516 UPDATE t11 SET b = cksum(a);
517 }
518
519 foreach {tn mmap_limit} {
520 1 0
521 2 1000000
522 } {
523 do_test sort-14.$tn {
524 sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $mmap_limit
525 set prev ""
526 db eval { SELECT * FROM t11 ORDER BY b } {
527 if {$b != [cksum $a]} {error "checksum failed"}
528 if {[string compare $b $prev] < 0} {error "sort failed"}
529 set prev $b
530 }
531 set {} {}
532 } {}
533 }
534
535 #-------------------------------------------------------------------------
536 #
537 foreach {tn mmap_limit nWorker tmpstore coremutex fakeheap softheaplimit} {
538 1 0 3 file true false 0
539 2 0 3 file true true 0
540 3 0 0 file true false 0
541 4 1000000 3 file true false 0
542 5 0 0 memory false true 0
543 6 0 0 file false true 1000000
544 7 0 0 file false true 10000
545 } {
546 db close
547 sqlite3_shutdown
548 if {$coremutex} {
549 sqlite3_config multithread
550 } else {
551 sqlite3_config singlethread
552 }
553 sqlite3_initialize
554 sorter_test_fakeheap $fakeheap
555 sqlite3_soft_heap_limit $softheaplimit
556
557 reset_db
558 sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $mmap_limit
559 execsql "PRAGMA temp_store = $tmpstore; PRAGMA threads = $nWorker"
560
561
562 set ten [string repeat X 10300]
563 set one [string repeat y 200]
564
565 if {$softheaplimit} {
566 execsql { PRAGMA cache_size = 20 };
567 } else {
568 execsql { PRAGMA cache_size = 5 };
569 }
570
571 do_execsql_test 15.$tn.1 {
572 WITH rr AS (
573 SELECT 4, $ten UNION ALL
574 SELECT 2, $one UNION ALL
575 SELECT 1, $ten UNION ALL
576 SELECT 3, $one
577 )
578 SELECT * FROM rr ORDER BY 1;
579 } [list 1 $ten 2 $one 3 $one 4 $ten]
580
581 do_execsql_test 15.$tn.2 {
582 CREATE TABLE t1(a);
583 INSERT INTO t1 VALUES(4);
584 INSERT INTO t1 VALUES(5);
585 INSERT INTO t1 VALUES(3);
586 INSERT INTO t1 VALUES(2);
587 INSERT INTO t1 VALUES(6);
588 INSERT INTO t1 VALUES(1);
589 CREATE INDEX i1 ON t1(a);
590 SELECT * FROM t1 ORDER BY a;
591 } {1 2 3 4 5 6}
592
593 do_execsql_test 15.$tn.3 {
594 WITH rr AS (
595 SELECT 4, $ten UNION ALL
596 SELECT 2, $one
597 )
598 SELECT * FROM rr ORDER BY 1;
599 } [list 2 $one 4 $ten]
600
601 sorter_test_fakeheap 0
602 }
603
604 db close
605 sqlite3_shutdown
606 set t(0) singlethread
607 set t(1) multithread
608 set t(2) serialized
609 sqlite3_config $t($sqlite_options(threadsafe))
610 sqlite3_initialize
611 sqlite3_soft_heap_limit 0
612
613 reset_db
614 do_catchsql_test 16.1 {
615 CREATE TABLE t1(a, b, c);
616 INSERT INTO t1 VALUES(1, 2, 3);
617 INSERT INTO t1 VALUES(1, NULL, 3);
618 INSERT INTO t1 VALUES(NULL, 2, 3);
619 INSERT INTO t1 VALUES(1, 2, NULL);
620 INSERT INTO t1 VALUES(4, 5, 6);
621 CREATE UNIQUE INDEX i1 ON t1(b, a, c);
622 } {0 {}}
623 reset_db
624 do_catchsql_test 16.2 {
625 CREATE TABLE t1(a, b, c);
626 INSERT INTO t1 VALUES(1, 2, 3);
627 INSERT INTO t1 VALUES(1, NULL, 3);
628 INSERT INTO t1 VALUES(1, 2, 3);
629 INSERT INTO t1 VALUES(1, 2, NULL);
630 INSERT INTO t1 VALUES(4, 5, 6);
631 CREATE UNIQUE INDEX i1 ON t1(b, a, c);
632 } {1 {UNIQUE constraint failed: t1.b, t1.a, t1.c}}
633
634 reset_db
635 do_execsql_test 17.1 {
636 SELECT * FROM sqlite_master ORDER BY sql;
637 } {}
638
467 finish_test 639 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/softheap1.test ('k') | third_party/sqlite/src/test/sort2.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698