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

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

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/src/test/auth2.test ('k') | third_party/sqlite/src/test/autoindex1.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 # 2004 November 12 1 # 2004 November 12
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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 db eval { 551 db eval {
552 CREATE TABLE t2(x INTEGER PRIMARY KEY AUTOINCREMENT, y); 552 CREATE TABLE t2(x INTEGER PRIMARY KEY AUTOINCREMENT, y);
553 INSERT INTO t2 VALUES(NULL, 1); 553 INSERT INTO t2 VALUES(NULL, 1);
554 CREATE TABLE t3(a INTEGER PRIMARY KEY AUTOINCREMENT, b); 554 CREATE TABLE t3(a INTEGER PRIMARY KEY AUTOINCREMENT, b);
555 INSERT INTO t3 SELECT * FROM t2 WHERE y>1; 555 INSERT INTO t3 SELECT * FROM t2 WHERE y>1;
556 556
557 SELECT * FROM sqlite_sequence WHERE name='t3'; 557 SELECT * FROM sqlite_sequence WHERE name='t3';
558 } 558 }
559 } {t3 0} 559 } {t3 0}
560 560
561 catchsql { pragma recursive_triggers = off } 561 ifcapable trigger {
562 catchsql { pragma recursive_triggers = off }
563
564 # Ticket #3928. Make sure that triggers to not make extra slots in
565 # the SQLITE_SEQUENCE table.
566 #
567 do_test autoinc-3928.1 {
568 db eval {
569 CREATE TABLE t3928(a INTEGER PRIMARY KEY AUTOINCREMENT, b);
570 CREATE TRIGGER t3928r1 BEFORE INSERT ON t3928 BEGIN
571 INSERT INTO t3928(b) VALUES('before1');
572 INSERT INTO t3928(b) VALUES('before2');
573 END;
574 CREATE TRIGGER t3928r2 AFTER INSERT ON t3928 BEGIN
575 INSERT INTO t3928(b) VALUES('after1');
576 INSERT INTO t3928(b) VALUES('after2');
577 END;
578 INSERT INTO t3928(b) VALUES('test');
579 SELECT * FROM t3928 ORDER BY a;
580 }
581 } {1 before1 2 after1 3 after2 4 before2 5 after1 6 after2 7 test 8 before1 9 before2 10 after1 11 before1 12 before2 13 after2}
582 do_test autoinc-3928.2 {
583 db eval {
584 SELECT * FROM sqlite_sequence WHERE name='t3928'
585 }
586 } {t3928 13}
562 587
563 # Ticket #3928. Make sure that triggers to not make extra slots in 588 do_test autoinc-3928.3 {
564 # the SQLITE_SEQUENCE table. 589 db eval {
565 # 590 DROP TRIGGER t3928r1;
566 do_test autoinc-3928.1 { 591 DROP TRIGGER t3928r2;
567 db eval { 592 CREATE TRIGGER t3928r3 BEFORE UPDATE ON t3928
568 CREATE TABLE t3928(a INTEGER PRIMARY KEY AUTOINCREMENT, b); 593 WHEN typeof(new.b)=='integer' BEGIN
569 CREATE TRIGGER t3928r1 BEFORE INSERT ON t3928 BEGIN 594 INSERT INTO t3928(b) VALUES('before-int-' || new.b);
570 INSERT INTO t3928(b) VALUES('before1'); 595 END;
571 INSERT INTO t3928(b) VALUES('before2'); 596 CREATE TRIGGER t3928r4 AFTER UPDATE ON t3928
572 END; 597 WHEN typeof(new.b)=='integer' BEGIN
573 CREATE TRIGGER t3928r2 AFTER INSERT ON t3928 BEGIN 598 INSERT INTO t3928(b) VALUES('after-int-' || new.b);
574 INSERT INTO t3928(b) VALUES('after1'); 599 END;
575 INSERT INTO t3928(b) VALUES('after2'); 600 DELETE FROM t3928 WHERE a!=1;
576 END; 601 UPDATE t3928 SET b=456 WHERE a=1;
577 INSERT INTO t3928(b) VALUES('test'); 602 SELECT * FROM t3928 ORDER BY a;
578 SELECT * FROM t3928 ORDER BY a; 603 }
579 } 604 } {1 456 14 before-int-456 15 after-int-456}
580 } {1 before1 2 after1 3 after2 4 before2 5 after1 6 after2 7 test 8 before1 9 be fore2 10 after1 11 before1 12 before2 13 after2} 605 do_test autoinc-3928.4 {
581 do_test autoinc-3928.2 { 606 db eval {
582 db eval { 607 SELECT * FROM sqlite_sequence WHERE name='t3928'
583 SELECT * FROM sqlite_sequence WHERE name='t3928' 608 }
584 } 609 } {t3928 15}
585 } {t3928 13} 610
611 do_test autoinc-3928.5 {
612 db eval {
613 CREATE TABLE t3928b(x);
614 INSERT INTO t3928b VALUES(100);
615 INSERT INTO t3928b VALUES(200);
616 INSERT INTO t3928b VALUES(300);
617 DELETE FROM t3928;
618 CREATE TABLE t3928c(y INTEGER PRIMARY KEY AUTOINCREMENT, z);
619 CREATE TRIGGER t3928br1 BEFORE DELETE ON t3928b BEGIN
620 INSERT INTO t3928(b) VALUES('before-del-'||old.x);
621 INSERT INTO t3928c(z) VALUES('before-del-'||old.x);
622 END;
623 CREATE TRIGGER t3928br2 AFTER DELETE ON t3928b BEGIN
624 INSERT INTO t3928(b) VALUES('after-del-'||old.x);
625 INSERT INTO t3928c(z) VALUES('after-del-'||old.x);
626 END;
627 DELETE FROM t3928b;
628 SELECT * FROM t3928 ORDER BY a;
629 }
630 } {16 before-del-100 17 after-del-100 18 before-del-200 19 after-del-200 20 be fore-del-300 21 after-del-300}
631 do_test autoinc-3928.6 {
632 db eval {
633 SELECT * FROM t3928c ORDER BY y;
634 }
635 } {1 before-del-100 2 after-del-100 3 before-del-200 4 after-del-200 5 before- del-300 6 after-del-300}
636 do_test autoinc-3928.7 {
637 db eval {
638 SELECT * FROM sqlite_sequence WHERE name LIKE 't3928%' ORDER BY name;
639 }
640 } {t3928 21 t3928c 6}
641
642 # Ticket [a696379c1f0886615541a48b35bd8181a80e88f8]
643 do_test autoinc-a69637.1 {
644 db eval {
645 CREATE TABLE ta69637_1(x INTEGER PRIMARY KEY AUTOINCREMENT, y);
646 CREATE TABLE ta69637_2(z);
647 CREATE TRIGGER ra69637_1 AFTER INSERT ON ta69637_2 BEGIN
648 INSERT INTO ta69637_1(y) VALUES(new.z+1);
649 END;
650 INSERT INTO ta69637_2 VALUES(123);
651 SELECT * FROM ta69637_1;
652 }
653 } {1 124}
654 do_test autoinc-a69637.2 {
655 db eval {
656 CREATE VIEW va69637_2 AS SELECT * FROM ta69637_2;
657 CREATE TRIGGER ra69637_2 INSTEAD OF INSERT ON va69637_2 BEGIN
658 INSERT INTO ta69637_1(y) VALUES(new.z+10000);
659 END;
660 INSERT INTO va69637_2 VALUES(123);
661 SELECT * FROM ta69637_1;
662 }
663 } {1 124 2 10123}
664 }
586 665
587 do_test autoinc-3928.3 {
588 db eval {
589 DROP TRIGGER t3928r1;
590 DROP TRIGGER t3928r2;
591 CREATE TRIGGER t3928r3 BEFORE UPDATE ON t3928
592 WHEN typeof(new.b)=='integer' BEGIN
593 INSERT INTO t3928(b) VALUES('before-int-' || new.b);
594 END;
595 CREATE TRIGGER t3928r4 AFTER UPDATE ON t3928
596 WHEN typeof(new.b)=='integer' BEGIN
597 INSERT INTO t3928(b) VALUES('after-int-' || new.b);
598 END;
599 DELETE FROM t3928 WHERE a!=1;
600 UPDATE t3928 SET b=456 WHERE a=1;
601 SELECT * FROM t3928 ORDER BY a;
602 }
603 } {1 456 14 before-int-456 15 after-int-456}
604 do_test autoinc-3928.4 {
605 db eval {
606 SELECT * FROM sqlite_sequence WHERE name='t3928'
607 }
608 } {t3928 15}
609 666
610 do_test autoinc-3928.5 {
611 db eval {
612 CREATE TABLE t3928b(x);
613 INSERT INTO t3928b VALUES(100);
614 INSERT INTO t3928b VALUES(200);
615 INSERT INTO t3928b VALUES(300);
616 DELETE FROM t3928;
617 CREATE TABLE t3928c(y INTEGER PRIMARY KEY AUTOINCREMENT, z);
618 CREATE TRIGGER t3928br1 BEFORE DELETE ON t3928b BEGIN
619 INSERT INTO t3928(b) VALUES('before-del-'||old.x);
620 INSERT INTO t3928c(z) VALUES('before-del-'||old.x);
621 END;
622 CREATE TRIGGER t3928br2 AFTER DELETE ON t3928b BEGIN
623 INSERT INTO t3928(b) VALUES('after-del-'||old.x);
624 INSERT INTO t3928c(z) VALUES('after-del-'||old.x);
625 END;
626 DELETE FROM t3928b;
627 SELECT * FROM t3928 ORDER BY a;
628 }
629 } {16 before-del-100 17 after-del-100 18 before-del-200 19 after-del-200 20 befo re-del-300 21 after-del-300}
630 do_test autoinc-3928.6 {
631 db eval {
632 SELECT * FROM t3928c ORDER BY y;
633 }
634 } {1 before-del-100 2 after-del-100 3 before-del-200 4 after-del-200 5 before-de l-300 6 after-del-300}
635 do_test autoinc-3928.7 {
636 db eval {
637 SELECT * FROM sqlite_sequence WHERE name LIKE 't3928%' ORDER BY name;
638 }
639 } {t3928 21 t3928c 6}
640 667
641 finish_test 668 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/auth2.test ('k') | third_party/sqlite/src/test/autoindex1.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698