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

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

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. 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
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 #***********************************************************************
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 } {ok} 108 } {ok}
109 } 109 }
110 # Ensure the data remaining in the table is what was expected. 110 # Ensure the data remaining in the table is what was expected.
111 foreach d $delete { 111 foreach d $delete {
112 set idx [lsearch $::tbl_data [make_str $d $ENTRY_LEN]] 112 set idx [lsearch $::tbl_data [make_str $d $ENTRY_LEN]]
113 set ::tbl_data [lreplace $::tbl_data $idx $idx] 113 set ::tbl_data [lreplace $::tbl_data $idx $idx]
114 } 114 }
115 do_test autovacuum-1.$tn.($delete).3 { 115 do_test autovacuum-1.$tn.($delete).3 {
116 execsql { 116 execsql {
117 select a from av1 117 select a from av1 order by rowid
118 } 118 }
119 } $::tbl_data 119 } $::tbl_data
120 } 120 }
121 121
122 # All rows have been deleted. Ensure the file has shrunk to 4 pages. 122 # All rows have been deleted. Ensure the file has shrunk to 4 pages.
123 do_test autovacuum-1.$tn.3 { 123 do_test autovacuum-1.$tn.3 {
124 file_pages 124 file_pages
125 } {4} 125 } {4}
126 } 126 }
127 127
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 } {1} 460 } {1}
461 do_test autovacuum-3.3 { 461 do_test autovacuum-3.3 {
462 execsql { 462 execsql {
463 PRAGMA auto_vacuum = 0; 463 PRAGMA auto_vacuum = 0;
464 PRAGMA auto_vacuum; 464 PRAGMA auto_vacuum;
465 } 465 }
466 } {1} 466 } {1}
467 467
468 do_test autovacuum-3.4 { 468 do_test autovacuum-3.4 {
469 db close 469 db close
470 file delete -force test.db 470 forcedelete test.db
471 sqlite3 db test.db 471 sqlite3 db test.db
472 execsql { 472 execsql {
473 PRAGMA auto_vacuum; 473 PRAGMA auto_vacuum;
474 } 474 }
475 } $AUTOVACUUM 475 } $AUTOVACUUM
476 do_test autovacuum-3.5 { 476 do_test autovacuum-3.5 {
477 execsql { 477 execsql {
478 CREATE TABLE av1(x); 478 CREATE TABLE av1(x);
479 PRAGMA auto_vacuum; 479 PRAGMA auto_vacuum;
480 } 480 }
(...skipping 14 matching lines...) Expand all
495 495
496 #----------------------------------------------------------------------- 496 #-----------------------------------------------------------------------
497 # Test that if a statement transaction around a CREATE INDEX statement is 497 # Test that if a statement transaction around a CREATE INDEX statement is
498 # rolled back no corruption occurs. 498 # rolled back no corruption occurs.
499 # 499 #
500 do_test autovacuum-4.0 { 500 do_test autovacuum-4.0 {
501 # The last round of tests may have left the db in non-autovacuum mode. 501 # The last round of tests may have left the db in non-autovacuum mode.
502 # Reset everything just in case. 502 # Reset everything just in case.
503 # 503 #
504 db close 504 db close
505 file delete -force test.db test.db-journal 505 forcedelete test.db test.db-journal
506 sqlite3 db test.db 506 sqlite3 db test.db
507 execsql { 507 execsql {
508 PRAGMA auto_vacuum = 1; 508 PRAGMA auto_vacuum = 1;
509 PRAGMA auto_vacuum; 509 PRAGMA auto_vacuum;
510 } 510 }
511 } {1} 511 } {1}
512 do_test autovacuum-4.1 { 512 do_test autovacuum-4.1 {
513 execsql { 513 execsql {
514 CREATE TABLE av1(a, b); 514 CREATE TABLE av1(a, b);
515 BEGIN; 515 BEGIN;
516 } 516 }
517 for {set i 0} {$i<100} {incr i} { 517 for {set i 0} {$i<100} {incr i} {
518 execsql "INSERT INTO av1 VALUES($i, '[string repeat X 200]');" 518 execsql "INSERT INTO av1 VALUES($i, '[string repeat X 200]');"
519 } 519 }
520 execsql "INSERT INTO av1 VALUES(99, '[string repeat X 200]');" 520 execsql "INSERT INTO av1 VALUES(99, '[string repeat X 200]');"
521 execsql { 521 execsql {
522 SELECT sum(a) FROM av1; 522 SELECT sum(a) FROM av1;
523 } 523 }
524 } {5049} 524 } {5049}
525 do_test autovacuum-4.2 { 525 do_test autovacuum-4.2 {
526 catchsql { 526 catchsql {
527 CREATE UNIQUE INDEX av1_i ON av1(a); 527 CREATE UNIQUE INDEX av1_i ON av1(a);
528 } 528 }
529 } {1 {indexed columns are not unique}} 529 } {1 {UNIQUE constraint failed: av1.a}}
530 do_test autovacuum-4.3 { 530 do_test autovacuum-4.3 {
531 execsql { 531 execsql {
532 SELECT sum(a) FROM av1; 532 SELECT sum(a) FROM av1;
533 } 533 }
534 } {5049} 534 } {5049}
535 do_test autovacuum-4.4 { 535 do_test autovacuum-4.4 {
536 execsql { 536 execsql {
537 COMMIT; 537 COMMIT;
538 } 538 }
539 } {} 539 } {}
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 592
593 } 593 }
594 594
595 #--------------------------------------------------------------------- 595 #---------------------------------------------------------------------
596 # Test cases autovacuum-7.X test the case where a page must be moved 596 # Test cases autovacuum-7.X test the case where a page must be moved
597 # and the destination location collides with at least one other 597 # and the destination location collides with at least one other
598 # entry in the page hash-table (internal to the pager.c module. 598 # entry in the page hash-table (internal to the pager.c module.
599 # 599 #
600 do_test autovacuum-7.1 { 600 do_test autovacuum-7.1 {
601 db close 601 db close
602 file delete -force test.db 602 forcedelete test.db
603 file delete -force test.db-journal 603 forcedelete test.db-journal
604 sqlite3 db test.db 604 sqlite3 db test.db
605 605
606 execsql { 606 execsql {
607 PRAGMA auto_vacuum=1; 607 PRAGMA auto_vacuum=1;
608 CREATE TABLE t1(a, b, PRIMARY KEY(a, b)); 608 CREATE TABLE t1(a, b, PRIMARY KEY(a, b));
609 INSERT INTO t1 VALUES(randstr(400,400),randstr(400,400)); 609 INSERT INTO t1 VALUES(randstr(400,400),randstr(400,400));
610 INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2 610 INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2
611 INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 4 611 INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 4
612 INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 8 612 INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 8
613 INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 16 613 INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 16
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 do_test autovacuum-9.4 { 689 do_test autovacuum-9.4 {
690 execsql { INSERT INTO t1 SELECT NULL, randstr(50,50) FROM t1 } 690 execsql { INSERT INTO t1 SELECT NULL, randstr(50,50) FROM t1 }
691 } {} 691 } {}
692 do_test autovacuum-9.5 { 692 do_test autovacuum-9.5 {
693 execsql { DELETE FROM t1 WHERE rowid > (SELECT max(a)/2 FROM t1) } 693 execsql { DELETE FROM t1 WHERE rowid > (SELECT max(a)/2 FROM t1) }
694 file size test.db 694 file size test.db
695 } $::sqlite_pending_byte 695 } $::sqlite_pending_byte
696 696
697 697
698 finish_test 698 finish_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698