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

Side by Side Diff: third_party/sqlite/src/test/conflict.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 # 2002 January 29 1 # 2002 January 29
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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 8 IGNORE {INSERT OR REPLACE} 0 5 1 235 8 IGNORE {INSERT OR REPLACE} 0 5 1
236 9 FAIL {INSERT OR IGNORE} 0 {} 1 236 9 FAIL {INSERT OR IGNORE} 0 {} 1
237 10 ABORT {INSERT OR REPLACE} 0 5 1 237 10 ABORT {INSERT OR REPLACE} 0 5 1
238 11 ROLLBACK {INSERT OR IGNORE} 0 {} 1 238 11 ROLLBACK {INSERT OR IGNORE} 0 {} 1
239 12 {} {INSERT OR IGNORE} 0 {} 1 239 12 {} {INSERT OR IGNORE} 0 {} 1
240 13 {} {INSERT OR REPLACE} 0 5 1 240 13 {} {INSERT OR REPLACE} 0 5 1
241 14 {} {INSERT OR FAIL} 1 {} 1 241 14 {} {INSERT OR FAIL} 1 {} 1
242 15 {} {INSERT OR ABORT} 1 {} 1 242 15 {} {INSERT OR ABORT} 1 {} 1
243 16 {} {INSERT OR ROLLBACK} 1 {} {} 243 16 {} {INSERT OR ROLLBACK} 1 {} {}
244 } { 244 } {
245 if {$t0} {set t1 {t1.c may not be NULL}} 245 if {$t0} {set t1 {NOT NULL constraint failed: t1.c}}
246 do_test conflict-5.$i { 246 do_test conflict-5.$i {
247 if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"} 247 if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
248 set r0 [catch {execsql [subst { 248 set r0 [catch {execsql [subst {
249 DROP TABLE t1; 249 DROP TABLE t1;
250 CREATE TABLE t1(a,b,c NOT NULL $conf1 DEFAULT 5); 250 CREATE TABLE t1(a,b,c NOT NULL $conf1 DEFAULT 5);
251 DELETE FROM t2; 251 DELETE FROM t2;
252 BEGIN; 252 BEGIN;
253 INSERT INTO t2 VALUES(1); 253 INSERT INTO t2 VALUES(1);
254 $cmd INTO t1 VALUES(1,2,NULL); 254 $cmd INTO t1 VALUES(1,2,NULL);
255 }]} r1] 255 }]} r1]
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 8 IGNORE {UPDATE OR REPLACE} 0 {7 6 9} 1 0 0 299 8 IGNORE {UPDATE OR REPLACE} 0 {7 6 9} 1 0 0
300 9 FAIL {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0 300 9 FAIL {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0
301 10 ABORT {UPDATE OR REPLACE} 0 {7 6 9} 1 0 0 301 10 ABORT {UPDATE OR REPLACE} 0 {7 6 9} 1 0 0
302 11 ROLLBACK {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0 302 11 ROLLBACK {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0
303 12 {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0 303 12 {} {UPDATE OR IGNORE} 0 {6 7 3 9} 1 0 0
304 13 {} {UPDATE OR REPLACE} 0 {7 6 9} 1 0 0 304 13 {} {UPDATE OR REPLACE} 0 {7 6 9} 1 0 0
305 14 {} {UPDATE OR FAIL} 1 {6 7 3 4} 1 0 0 305 14 {} {UPDATE OR FAIL} 1 {6 7 3 4} 1 0 0
306 15 {} {UPDATE OR ABORT} 1 {1 2 3 4} 1 0 1 306 15 {} {UPDATE OR ABORT} 1 {1 2 3 4} 1 0 1
307 16 {} {UPDATE OR ROLLBACK} 1 {1 2 3 4} 0 0 0 307 16 {} {UPDATE OR ROLLBACK} 1 {1 2 3 4} 0 0 0
308 } { 308 } {
309 if {$t0} {set t1 {column a is not unique}} 309 if {$t0} {set t1 {UNIQUE constraint failed: t1.a}}
310 if {[info exists TEMP_STORE] && $TEMP_STORE==3} { 310 if {[info exists TEMP_STORE] && $TEMP_STORE==3} {
311 set t3 0 311 set t3 0
312 } else { 312 } else {
313 set t3 [expr {$t3+$t4}] 313 set t3 [expr {$t3+$t4}]
314 } 314 }
315 do_test conflict-6.$i { 315 do_test conflict-6.$i {
316 db close 316 db close
317 sqlite3 db test.db 317 sqlite3 db test.db
318 if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"} 318 if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"}
319 execsql {pragma temp_store=file} 319 execsql {pragma temp_store=file}
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 catchsql { 486 catchsql {
487 UPDATE t2 SET a=a+1 WHERE a=1; 487 UPDATE t2 SET a=a+1 WHERE a=1;
488 SELECT * FROM t2; 488 SELECT * FROM t2;
489 } 489 }
490 } {0 {1 1 1 1 1 2 2 2 2 2}} 490 } {0 {1 1 1 1 1 2 2 2 2 2}}
491 do_test conflict-9.5 { 491 do_test conflict-9.5 {
492 catchsql { 492 catchsql {
493 INSERT INTO t2 VALUES(3,1,3,3,3); 493 INSERT INTO t2 VALUES(3,1,3,3,3);
494 SELECT * FROM t2; 494 SELECT * FROM t2;
495 } 495 }
496 } {1 {column b is not unique}} 496 } {1 {UNIQUE constraint failed: t2.b}}
497 do_test conflict-9.6 { 497 do_test conflict-9.6 {
498 catchsql { 498 catchsql {
499 UPDATE t2 SET b=b+1 WHERE b=1; 499 UPDATE t2 SET b=b+1 WHERE b=1;
500 SELECT * FROM t2; 500 SELECT * FROM t2;
501 } 501 }
502 } {1 {column b is not unique}} 502 } {1 {UNIQUE constraint failed: t2.b}}
503 do_test conflict-9.7 { 503 do_test conflict-9.7 {
504 catchsql { 504 catchsql {
505 BEGIN; 505 BEGIN;
506 UPDATE t3 SET x=x+1; 506 UPDATE t3 SET x=x+1;
507 INSERT INTO t2 VALUES(3,1,3,3,3); 507 INSERT INTO t2 VALUES(3,1,3,3,3);
508 SELECT * FROM t2; 508 SELECT * FROM t2;
509 } 509 }
510 } {1 {column b is not unique}} 510 } {1 {UNIQUE constraint failed: t2.b}}
511 do_test conflict-9.8 { 511 do_test conflict-9.8 {
512 execsql {COMMIT} 512 execsql {COMMIT}
513 execsql {SELECT * FROM t3} 513 execsql {SELECT * FROM t3}
514 } {2} 514 } {2}
515 do_test conflict-9.9 { 515 do_test conflict-9.9 {
516 catchsql { 516 catchsql {
517 BEGIN; 517 BEGIN;
518 UPDATE t3 SET x=x+1; 518 UPDATE t3 SET x=x+1;
519 UPDATE t2 SET b=b+1 WHERE b=1; 519 UPDATE t2 SET b=b+1 WHERE b=1;
520 SELECT * FROM t2; 520 SELECT * FROM t2;
521 } 521 }
522 } {1 {column b is not unique}} 522 } {1 {UNIQUE constraint failed: t2.b}}
523 do_test conflict-9.10 { 523 do_test conflict-9.10 {
524 execsql {COMMIT} 524 execsql {COMMIT}
525 execsql {SELECT * FROM t3} 525 execsql {SELECT * FROM t3}
526 } {3} 526 } {3}
527 do_test conflict-9.11 { 527 do_test conflict-9.11 {
528 catchsql { 528 catchsql {
529 INSERT INTO t2 VALUES(3,3,3,1,3); 529 INSERT INTO t2 VALUES(3,3,3,1,3);
530 SELECT * FROM t2; 530 SELECT * FROM t2;
531 } 531 }
532 } {1 {column d is not unique}} 532 } {1 {UNIQUE constraint failed: t2.d}}
533 do_test conflict-9.12 { 533 do_test conflict-9.12 {
534 catchsql { 534 catchsql {
535 UPDATE t2 SET d=d+1 WHERE d=1; 535 UPDATE t2 SET d=d+1 WHERE d=1;
536 SELECT * FROM t2; 536 SELECT * FROM t2;
537 } 537 }
538 } {1 {column d is not unique}} 538 } {1 {UNIQUE constraint failed: t2.d}}
539 do_test conflict-9.13 { 539 do_test conflict-9.13 {
540 catchsql { 540 catchsql {
541 BEGIN; 541 BEGIN;
542 UPDATE t3 SET x=x+1; 542 UPDATE t3 SET x=x+1;
543 INSERT INTO t2 VALUES(3,3,3,1,3); 543 INSERT INTO t2 VALUES(3,3,3,1,3);
544 SELECT * FROM t2; 544 SELECT * FROM t2;
545 } 545 }
546 } {1 {column d is not unique}} 546 } {1 {UNIQUE constraint failed: t2.d}}
547 do_test conflict-9.14 { 547 do_test conflict-9.14 {
548 execsql {COMMIT} 548 execsql {COMMIT}
549 execsql {SELECT * FROM t3} 549 execsql {SELECT * FROM t3}
550 } {4} 550 } {4}
551 do_test conflict-9.15 { 551 do_test conflict-9.15 {
552 catchsql { 552 catchsql {
553 BEGIN; 553 BEGIN;
554 UPDATE t3 SET x=x+1; 554 UPDATE t3 SET x=x+1;
555 UPDATE t2 SET d=d+1 WHERE d=1; 555 UPDATE t2 SET d=d+1 WHERE d=1;
556 SELECT * FROM t2; 556 SELECT * FROM t2;
557 } 557 }
558 } {1 {column d is not unique}} 558 } {1 {UNIQUE constraint failed: t2.d}}
559 do_test conflict-9.16 { 559 do_test conflict-9.16 {
560 execsql {COMMIT} 560 execsql {COMMIT}
561 execsql {SELECT * FROM t3} 561 execsql {SELECT * FROM t3}
562 } {5} 562 } {5}
563 do_test conflict-9.17 { 563 do_test conflict-9.17 {
564 catchsql { 564 catchsql {
565 INSERT INTO t2 VALUES(3,3,3,3,1); 565 INSERT INTO t2 VALUES(3,3,3,3,1);
566 SELECT * FROM t2; 566 SELECT * FROM t2;
567 } 567 }
568 } {1 {column e is not unique}} 568 } {1 {UNIQUE constraint failed: t2.e}}
569 do_test conflict-9.18 { 569 do_test conflict-9.18 {
570 catchsql { 570 catchsql {
571 UPDATE t2 SET e=e+1 WHERE e=1; 571 UPDATE t2 SET e=e+1 WHERE e=1;
572 SELECT * FROM t2; 572 SELECT * FROM t2;
573 } 573 }
574 } {1 {column e is not unique}} 574 } {1 {UNIQUE constraint failed: t2.e}}
575 do_test conflict-9.19 { 575 do_test conflict-9.19 {
576 catchsql { 576 catchsql {
577 BEGIN; 577 BEGIN;
578 UPDATE t3 SET x=x+1; 578 UPDATE t3 SET x=x+1;
579 INSERT INTO t2 VALUES(3,3,3,3,1); 579 INSERT INTO t2 VALUES(3,3,3,3,1);
580 SELECT * FROM t2; 580 SELECT * FROM t2;
581 } 581 }
582 } {1 {column e is not unique}} 582 } {1 {UNIQUE constraint failed: t2.e}}
583 verify_ex_errcode conflict-9.21b SQLITE_CONSTRAINT_UNIQUE
583 do_test conflict-9.20 { 584 do_test conflict-9.20 {
584 catch {execsql {COMMIT}} 585 catch {execsql {COMMIT}}
585 execsql {SELECT * FROM t3} 586 execsql {SELECT * FROM t3}
586 } {5} 587 } {5}
587 do_test conflict-9.21 { 588 do_test conflict-9.21 {
588 catchsql { 589 catchsql {
589 BEGIN; 590 BEGIN;
590 UPDATE t3 SET x=x+1; 591 UPDATE t3 SET x=x+1;
591 UPDATE t2 SET e=e+1 WHERE e=1; 592 UPDATE t2 SET e=e+1 WHERE e=1;
592 SELECT * FROM t2; 593 SELECT * FROM t2;
593 } 594 }
594 } {1 {column e is not unique}} 595 } {1 {UNIQUE constraint failed: t2.e}}
596 verify_ex_errcode conflict-9.21b SQLITE_CONSTRAINT_UNIQUE
595 do_test conflict-9.22 { 597 do_test conflict-9.22 {
596 catch {execsql {COMMIT}} 598 catch {execsql {COMMIT}}
597 execsql {SELECT * FROM t3} 599 execsql {SELECT * FROM t3}
598 } {5} 600 } {5}
599 do_test conflict-9.23 { 601 do_test conflict-9.23 {
600 catchsql { 602 catchsql {
601 INSERT INTO t2 VALUES(3,3,1,3,3); 603 INSERT INTO t2 VALUES(3,3,1,3,3);
602 SELECT * FROM t2; 604 SELECT * FROM t2;
603 } 605 }
604 } {0 {2 2 2 2 2 3 3 1 3 3}} 606 } {0 {2 2 2 2 2 3 3 1 3 3}}
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 do_test conflict-12.2 { 775 do_test conflict-12.2 {
774 execsql { 776 execsql {
775 UPDATE OR IGNORE t5 SET a=a+1 WHERE a=1; 777 UPDATE OR IGNORE t5 SET a=a+1 WHERE a=1;
776 SELECT * FROM t5; 778 SELECT * FROM t5;
777 } 779 }
778 } {1 one 2 two} 780 } {1 one 2 two}
779 do_test conflict-12.3 { 781 do_test conflict-12.3 {
780 catchsql { 782 catchsql {
781 UPDATE t5 SET a=a+1 WHERE a=1; 783 UPDATE t5 SET a=a+1 WHERE a=1;
782 } 784 }
783 } {1 {PRIMARY KEY must be unique}} 785 } {1 {UNIQUE constraint failed: t5.a}}
786 verify_ex_errcode conflict-12.3b SQLITE_CONSTRAINT_PRIMARYKEY
784 do_test conflict-12.4 { 787 do_test conflict-12.4 {
785 execsql { 788 execsql {
786 UPDATE OR REPLACE t5 SET a=a+1 WHERE a=1; 789 UPDATE OR REPLACE t5 SET a=a+1 WHERE a=1;
787 SELECT * FROM t5; 790 SELECT * FROM t5;
788 } 791 }
789 } {2 one} 792 } {2 one}
793 do_test conflict-12.5 {
794 catchsql {
795 CREATE TABLE t5b(x);
796 INSERT INTO t5b(rowid, x) VALUES(1,10),(2,11);
797 UPDATE t5b SET rowid=rowid+1 WHERE x=10;
798 }
799 } {1 {UNIQUE constraint failed: t5b.rowid}}
800 verify_ex_errcode conflict-12.5b SQLITE_CONSTRAINT_ROWID
790 801
791 802
792 # Ticket [c38baa3d969eab7946dc50ba9d9b4f0057a19437] 803 # Ticket [c38baa3d969eab7946dc50ba9d9b4f0057a19437]
793 # REPLACE works like ABORT on a CHECK constraint. 804 # REPLACE works like ABORT on a CHECK constraint.
794 # 805 #
795 do_test conflict-13.1 { 806 do_test conflict-13.1 {
796 execsql { 807 execsql {
797 CREATE TABLE t13(a CHECK(a!=2)); 808 CREATE TABLE t13(a CHECK(a!=2));
798 BEGIN; 809 BEGIN;
799 REPLACE INTO t13 VALUES(1); 810 REPLACE INTO t13 VALUES(1);
800 } 811 }
801 catchsql { 812 catchsql {
802 REPLACE INTO t13 VALUES(2); 813 REPLACE INTO t13 VALUES(2);
803 } 814 }
804 } {1 {constraint failed}} 815 } {1 {CHECK constraint failed: t13}}
816 verify_ex_errcode conflict-13.1b SQLITE_CONSTRAINT_CHECK
805 do_test conflict-13.2 { 817 do_test conflict-13.2 {
806 execsql { 818 execsql {
807 REPLACE INTO t13 VALUES(3); 819 REPLACE INTO t13 VALUES(3);
808 COMMIT; 820 COMMIT;
809 SELECT * FROM t13; 821 SELECT * FROM t13;
810 } 822 }
811 } {1 3} 823 } {1 3}
812 824
813 825
814 finish_test 826 finish_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698