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

Side by Side Diff: third_party/sqlite/src/test/capi3c.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 # 2006 November 08 1 # 2006 November 08
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 set db2 [sqlite3_open /bogus/path/test.db {}] 162 set db2 [sqlite3_open /bogus/path/test.db {}]
163 } 163 }
164 sqlite3_errcode $db2 164 sqlite3_errcode $db2
165 } {SQLITE_CANTOPEN} 165 } {SQLITE_CANTOPEN}
166 do_test capi3c-3.4 { 166 do_test capi3c-3.4 {
167 sqlite3_errmsg $db2 167 sqlite3_errmsg $db2
168 } {unable to open database file} 168 } {unable to open database file}
169 do_test capi3c-3.5 { 169 do_test capi3c-3.5 {
170 sqlite3_close $db2 170 sqlite3_close $db2
171 } {SQLITE_OK} 171 } {SQLITE_OK}
172 do_test capi3c-3.6.1-misuse { 172 if {[clang_sanitize_address]==0} {
173 sqlite3_close $db2 173 do_test capi3c-3.6.1-misuse {
174 } {SQLITE_MISUSE} 174 sqlite3_close $db2
175 do_test capi3c-3.6.2-misuse { 175 } {SQLITE_MISUSE}
176 sqlite3_errmsg $db2 176 do_test capi3c-3.6.2-misuse {
177 } {library routine called out of sequence} 177 sqlite3_errmsg $db2
178 ifcapable {utf16} {
179 do_test capi3c-3.6.3-misuse {
180 utf8 [sqlite3_errmsg16 $db2]
181 } {library routine called out of sequence} 178 } {library routine called out of sequence}
179 ifcapable {utf16} {
180 do_test capi3c-3.6.3-misuse {
181 utf8 [sqlite3_errmsg16 $db2]
182 } {library routine called out of sequence}
183 }
182 } 184 }
183 185
184 # rename sqlite3_open "" 186 # rename sqlite3_open ""
185 # rename sqlite3_open_old sqlite3_open 187 # rename sqlite3_open_old sqlite3_open
186 188
187 ifcapable {utf16} { 189 ifcapable {utf16} {
188 do_test capi3c-4.1 { 190 do_test capi3c-4.1 {
189 set db2 [sqlite3_open16 [utf16 test.db] {}] 191 set db2 [sqlite3_open16 [utf16 test.db] {}]
190 sqlite3_errcode $db2 192 sqlite3_errcode $db2
191 } {SQLITE_OK} 193 } {SQLITE_OK}
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 db cache flush 622 db cache flush
621 sqlite3_close $DB 623 sqlite3_close $DB
622 } {SQLITE_BUSY} 624 } {SQLITE_BUSY}
623 do_test capi3c-6.2 { 625 do_test capi3c-6.2 {
624 sqlite3_step $STMT 626 sqlite3_step $STMT
625 } {SQLITE_ROW} 627 } {SQLITE_ROW}
626 check_data $STMT capi3c-6.3 {INTEGER} {1} {1.0} {1} 628 check_data $STMT capi3c-6.3 {INTEGER} {1} {1.0} {1}
627 do_test capi3c-6.3 { 629 do_test capi3c-6.3 {
628 sqlite3_finalize $STMT 630 sqlite3_finalize $STMT
629 } {SQLITE_OK} 631 } {SQLITE_OK}
630 do_test capi3c-6.4 { 632 if {[clang_sanitize_address]==0} {
631 db cache flush 633 do_test capi3c-6.4 {
632 sqlite3_close $DB 634 db cache flush
633 } {SQLITE_OK} 635 sqlite3_close $DB
634 do_test capi3c-6.99-misuse { 636 } {SQLITE_OK}
637 do_test capi3c-6.99-misuse {
638 db close
639 } {}
640 } else {
635 db close 641 db close
636 } {} 642 }
637 643
638 # This procedure sets the value of the file-format in file 'test.db' 644 # This procedure sets the value of the file-format in file 'test.db'
639 # to $newval. Also, the schema cookie is incremented. 645 # to $newval. Also, the schema cookie is incremented.
640 # 646 #
641 proc set_file_format {newval} { 647 proc set_file_format {newval} {
642 hexio_write test.db 44 [hexio_render_int32 $newval] 648 hexio_write test.db 44 [hexio_render_int32 $newval]
643 set schemacookie [hexio_get_int [hexio_read test.db 40 4]] 649 set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
644 incr schemacookie 650 incr schemacookie
645 hexio_write test.db 40 [hexio_render_int32 $schemacookie] 651 hexio_write test.db 40 [hexio_render_int32 $schemacookie]
646 return {} 652 return {}
(...skipping 16 matching lines...) Expand all
663 SELECT * FROM sqlite_master; 669 SELECT * FROM sqlite_master;
664 } 670 }
665 } {1 {unsupported file format}} 671 } {1 {unsupported file format}}
666 db close 672 db close
667 } 673 }
668 674
669 if {![sqlite3 -has-codec]} { 675 if {![sqlite3 -has-codec]} {
670 # Now test that the library correctly handles bogus entries in the 676 # Now test that the library correctly handles bogus entries in the
671 # sqlite_master table (schema corruption). 677 # sqlite_master table (schema corruption).
672 do_test capi3c-8.1 { 678 do_test capi3c-8.1 {
673 file delete -force test.db test.db-journal 679 forcedelete test.db test.db-journal
674 sqlite3 db test.db 680 sqlite3 db test.db
675 execsql { 681 execsql {
676 CREATE TABLE t1(a); 682 CREATE TABLE t1(a);
677 } 683 }
678 db close 684 db close
679 } {} 685 } {}
680 do_test capi3c-8.2 { 686 do_test capi3c-8.2 {
681 sqlite3 db test.db 687 sqlite3 db test.db
682 execsql { 688 execsql {
683 PRAGMA writable_schema=ON; 689 PRAGMA writable_schema=ON;
684 INSERT INTO sqlite_master VALUES(NULL,NULL,NULL,NULL,NULL); 690 INSERT INTO sqlite_master VALUES(NULL,NULL,NULL,NULL,NULL);
685 } 691 }
686 db close 692 db close
687 } {} 693 } {}
688 do_test capi3c-8.3 { 694 do_test capi3c-8.3 {
689 catch { sqlite3 db test.db } 695 catch { sqlite3 db test.db }
690 catchsql { 696 catchsql {
691 SELECT * FROM sqlite_master; 697 SELECT * FROM sqlite_master;
692 } 698 }
693 } {1 {malformed database schema (?)}} 699 } {1 {malformed database schema (?)}}
694 do_test capi3c-8.4 { 700 do_test capi3c-8.4 {
695 # Build a 5-field row record. The first field is a string 'table', and 701 # Build a 5-field row record. The first field is a string 'table', and
696 # subsequent fields are all NULL. 702 # subsequent fields are all NULL.
697 db close 703 db close
698 file delete -force test.db test.db-journal 704 forcedelete test.db test.db-journal
699 sqlite3 db test.db 705 sqlite3 db test.db
700 execsql { 706 execsql {
701 CREATE TABLE t1(a); 707 CREATE TABLE t1(a);
702 PRAGMA writable_schema=ON; 708 PRAGMA writable_schema=ON;
703 INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL); 709 INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL);
704 } 710 }
705 db close 711 db close
706 } {}; 712 } {};
707 do_test capi3c-8.5 { 713 do_test capi3c-8.5 {
708 catch { sqlite3 db test.db } 714 catch { sqlite3 db test.db }
709 catchsql { 715 catchsql {
710 SELECT * FROM sqlite_master; 716 SELECT * FROM sqlite_master;
711 } 717 }
712 } {1 {malformed database schema (?)}} 718 } {1 {malformed database schema (?)}}
713 db close 719 db close
714 } 720 }
715 file delete -force test.db 721 forcedelete test.db
716 file delete -force test.db-journal 722 forcedelete test.db-journal
717 723
718 724
719 # Test the english language string equivalents for sqlite error codes 725 # Test the english language string equivalents for sqlite error codes
720 set code2english [list \ 726 set code2english [list \
721 SQLITE_OK {not an error} \ 727 SQLITE_OK {not an error} \
722 SQLITE_ERROR {SQL logic error or missing database} \ 728 SQLITE_ERROR {SQL logic error or missing database} \
723 SQLITE_PERM {access permission denied} \ 729 SQLITE_PERM {access permission denied} \
724 SQLITE_ABORT {callback requested query abort} \ 730 SQLITE_ABORT {callback requested query abort} \
725 SQLITE_BUSY {database is locked} \ 731 SQLITE_BUSY {database is locked} \
726 SQLITE_LOCKED {database table is locked} \ 732 SQLITE_LOCKED {database table is locked} \
(...skipping 17 matching lines...) Expand all
744 unknownerror {unknown error} \ 750 unknownerror {unknown error} \
745 ] 751 ]
746 752
747 set test_number 1 753 set test_number 1
748 foreach {code english} $code2english { 754 foreach {code english} $code2english {
749 do_test capi3c-9.$test_number "sqlite3_test_errstr $code" $english 755 do_test capi3c-9.$test_number "sqlite3_test_errstr $code" $english
750 incr test_number 756 incr test_number
751 } 757 }
752 758
753 # Test the error message when a "real" out of memory occurs. 759 # Test the error message when a "real" out of memory occurs.
760 if { [permutation] != "nofaultsim" } {
754 ifcapable memdebug { 761 ifcapable memdebug {
755 do_test capi3c-10-1 { 762 do_test capi3c-10-1 {
756 sqlite3 db test.db 763 sqlite3 db test.db
757 set DB [sqlite3_connection_pointer db] 764 set DB [sqlite3_connection_pointer db]
758 sqlite3_memdebug_fail 0 765 sqlite3_memdebug_fail 0
759 catchsql { 766 catchsql {
760 select * from sqlite_master; 767 select * from sqlite_master;
761 } 768 }
762 } {1 {out of memory}} 769 } {1 {out of memory}}
763 do_test capi3c-10-2 { 770 do_test capi3c-10-2 {
764 sqlite3_errmsg $::DB 771 sqlite3_errmsg $::DB
765 } {out of memory} 772 } {out of memory}
766 ifcapable {utf16} { 773 ifcapable {utf16} {
767 do_test capi3c-10-3 { 774 do_test capi3c-10-3 {
768 utf8 [sqlite3_errmsg16 $::DB] 775 utf8 [sqlite3_errmsg16 $::DB]
769 } {out of memory} 776 } {out of memory}
770 } 777 }
771 db close 778 db close
772 sqlite3_memdebug_fail -1 779 sqlite3_memdebug_fail -1
773 } 780 }
781 }
774 782
775 # The following tests - capi3c-11.* - test that a COMMIT or ROLLBACK 783 # The following tests - capi3c-11.* - test that a COMMIT or ROLLBACK
776 # statement issued while there are still outstanding VMs that are part of 784 # statement issued while there are still outstanding VMs that are part of
777 # the transaction fails. 785 # the transaction fails.
778 sqlite3 db test.db 786 sqlite3 db test.db
779 set DB [sqlite3_connection_pointer db] 787 set DB [sqlite3_connection_pointer db]
780 sqlite_register_test_function $DB func 788 sqlite_register_test_function $DB func
781 do_test capi3c-11.1 { 789 do_test capi3c-11.1 {
782 execsql { 790 execsql {
783 BEGIN; 791 BEGIN;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 set STMT [sqlite3_prepare_v2 $DB "SELECT a FROM t2" -1 TAIL] 850 set STMT [sqlite3_prepare_v2 $DB "SELECT a FROM t2" -1 TAIL]
843 sqlite3_step $STMT 851 sqlite3_step $STMT
844 } {SQLITE_ROW} 852 } {SQLITE_ROW}
845 do_test capi3c-11.9.1 { 853 do_test capi3c-11.9.1 {
846 sqlite3_get_autocommit $DB 854 sqlite3_get_autocommit $DB
847 } 0 855 } 0
848 do_test capi3c-11.9.2 { 856 do_test capi3c-11.9.2 {
849 catchsql { 857 catchsql {
850 ROLLBACK; 858 ROLLBACK;
851 } 859 }
852 } {1 {cannot rollback transaction - SQL statements in progress}} 860 } {0 {}}
853 do_test capi3c-11.9.3 { 861 do_test capi3c-11.9.3 {
854 sqlite3_get_autocommit $DB 862 sqlite3_get_autocommit $DB
855 } 0 863 } 1
856 do_test capi3c-11.10 { 864 do_test capi3c-11.10 {
857 sqlite3_step $STMT 865 sqlite3_step $STMT
858 } {SQLITE_ROW} 866 } {SQLITE_ROW}
867 ifcapable !autoreset {
868 # If SQLITE_OMIT_AUTORESET is defined, then the statement must be
869 # reset() before it can be passed to step() again.
870 do_test capi3-11.11a { sqlite3_step $STMT } {SQLITE_MISUSE}
871 do_test capi3-11.11b { sqlite3_reset $STMT } {SQLITE_ABORT}
872 }
859 do_test capi3c-11.11 { 873 do_test capi3c-11.11 {
860 sqlite3_step $STMT 874 sqlite3_step $STMT
861 } {SQLITE_ROW} 875 } {SQLITE_DONE}
862 do_test capi3c-11.12 { 876 do_test capi3c-11.12 {
863 sqlite3_step $STMT 877 sqlite3_step $STMT
864 } {SQLITE_DONE} 878 sqlite3_step $STMT
879 } {SQLITE_ROW}
865 do_test capi3c-11.13 { 880 do_test capi3c-11.13 {
866 sqlite3_finalize $STMT 881 sqlite3_finalize $STMT
867 } {SQLITE_OK} 882 } {SQLITE_OK}
868 do_test capi3c-11.14 { 883 do_test capi3c-11.14 {
869 execsql { 884 execsql {
870 SELECT a FROM t2; 885 SELECT a FROM t2;
871 } 886 }
872 } {1 2 3} 887 } {1 2}
873 do_test capi3c-11.14.1 { 888 do_test capi3c-11.14.1 {
874 sqlite3_get_autocommit $DB 889 sqlite3_get_autocommit $DB
875 } 0 890 } 1
876 do_test capi3c-11.15 { 891 do_test capi3c-11.15 {
877 catchsql { 892 catchsql {
878 ROLLBACK; 893 ROLLBACK;
879 } 894 }
880 } {0 {}} 895 } {1 {cannot rollback - no transaction is active}}
881 do_test capi3c-11.15.1 { 896 do_test capi3c-11.15.1 {
882 sqlite3_get_autocommit $DB 897 sqlite3_get_autocommit $DB
883 } 1 898 } 1
884 do_test capi3c-11.16 { 899 do_test capi3c-11.16 {
885 execsql { 900 execsql {
886 SELECT a FROM t2; 901 SELECT a FROM t2;
887 } 902 }
888 } {1 2} 903 } {1 2}
889 904
890 # Sanity check on the definition of 'outstanding VM'. This means any VM 905 # Sanity check on the definition of 'outstanding VM'. This means any VM
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 decltype { 1369 decltype {
1355 SELECT (SELECT x FROM (SELECT c AS x)) 1370 SELECT (SELECT x FROM (SELECT c AS x))
1356 FROM (SELECT * FROM t5 ORDER BY c LIMIT 1) ORDER BY b 1371 FROM (SELECT * FROM t5 ORDER BY c LIMIT 1) ORDER BY b
1357 } 1372 }
1358 } {DATETIME} 1373 } {DATETIME}
1359 do_test capi3c-24.3 { 1374 do_test capi3c-24.3 {
1360 decltype {SELECT (SELECT x FROM (SELECT t5.a AS x)) FROM t5} 1375 decltype {SELECT (SELECT x FROM (SELECT t5.a AS x)) FROM t5}
1361 } {INTEGER} 1376 } {INTEGER}
1362 1377
1363 finish_test 1378 finish_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698