Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/without_rowid7.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / without_rowid7.test` 123 lines ยท 3131 bytes Raw Blame History 1 # 2019 July 17 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 6 # May you do good and not evil. 7 # May you find forgiveness for yourself and forgive others. 8 # May you share freely, never taking more than you give. 9 # 10 #************************************************************************* 11 # This file implements regression tests for SQLite library. 12 # 13 14 set testdir [file dirname $argv0] 15 source $testdir/tester.tcl 16 set testprefix without_rowid7 17 18 proc do_execsql_test_if_vtab {tn sql {res {}}} { 19 ifcapable vtab { uplevel [list do_execsql_test $tn $sql $res] } 20 } 21 22 do_execsql_test 1.0 { 23 CREATE TABLE t1(a, b COLLATE nocase, PRIMARY KEY(a, a, b)) WITHOUT ROWID; 24 } 25 26 do_catchsql_test 1.1 { 27 INSERT INTO t1 VALUES(1, 'one'), (1, 'ONE'); 28 } {1 {UNIQUE constraint failed: t1.a, t1.b}} 29 30 31 do_execsql_test 2.0 { 32 CREATE TABLE t2(a, b, PRIMARY KEY(a COLLATE nocase, a)) WITHOUT ROWID; 33 } 34 35 do_execsql_test 2.1 { 36 INSERT INTO t2 VALUES(1, 'one'); 37 SELECT b FROM t2; 38 } {one} 39 40 do_execsql_test 2.2a { 41 PRAGMA index_info(t2); 42 } {0 0 a 1 0 a} 43 do_execsql_test_if_vtab 2.2b { 44 SELECT *, '|' FROM pragma_index_info('t2'); 45 } {0 0 a | 1 0 a |} 46 do_execsql_test 2.3a { 47 PRAGMA index_xinfo(t2); 48 } {0 0 a 0 nocase 1 1 0 a 0 BINARY 1 2 1 b 0 BINARY 0} 49 do_execsql_test_if_vtab 2.3b { 50 SELECT *, '|' FROM pragma_index_xinfo('t2'); 51 } {0 0 a 0 nocase 1 | 1 0 a 0 BINARY 1 | 2 1 b 0 BINARY 0 |} 52 53 do_execsql_test 2.4 { 54 CREATE TABLE t3(a, b, PRIMARY KEY(a COLLATE nocase, a)); 55 PRAGMA index_info(t3); 56 } {} 57 58 #------------------------------------------------------------------------- 59 reset_db 60 db collate mysort mysort 61 db collate mysort2 mysort 62 proc mysort {a b} { string compare $a $b } 63 do_execsql_test 3.0 { 64 CREATE TABLE t1( 65 a PRIMARY KEY COLLATE mysort, b COLLATE mysort2 66 ) WITHOUT ROWID; 67 INSERT INTO t1 VALUES(1, 2); 68 } 69 70 db close 71 sqlite3 db test.db 72 73 do_catchsql_test 3.1.1 { 74 SELECT * FROM t1 WHERE a=1; 75 } {1 {no such collation sequence: mysort}} 76 do_test 3.1.2 { 77 sqlite3_extended_errcode db 78 } {SQLITE_ERROR_MISSING_COLLSEQ} 79 80 db collate mysort mysort 81 82 do_catchsql_test 3.2.1 { 83 CREATE UNIQUE INDEX i1 ON t1(b); 84 } {1 {no such collation sequence: mysort2}} 85 do_test 3.2.2 { 86 sqlite3_extended_errcode db 87 } {SQLITE_ERROR_MISSING_COLLSEQ} 88 89 db close 90 sqlite3 db test.db 91 92 do_catchsql_test 3.3.1 { 93 CREATE UNIQUE INDEX i1 ON t1(1); 94 } {1 {no such collation sequence: mysort}} 95 do_test 3.3.2 { 96 sqlite3_extended_errcode db 97 } {SQLITE_ERROR_MISSING_COLLSEQ} 98 99 do_test 3.4.1 { 100 list [catch { 101 sqlite3_prepare_v3 db "CREATE UNIQUE INDEX i1 ON t1(1)" -1 0 102 } msg] $msg 103 } {1 {(1) no such collation sequence: mysort}} 104 do_test 3.4.2 { 105 sqlite3_extended_errcode db 106 } {SQLITE_ERROR_MISSING_COLLSEQ} 107 108 sqlite3_extended_result_codes db 1 109 110 do_test 3.5.1 { 111 list [catch { 112 sqlite3_prepare_v3 db "CREATE UNIQUE INDEX i1 ON t1(1)" -1 0 113 } msg] $msg 114 } {1 {(257) no such collation sequence: mysort}} 115 do_test 3.5.2 { 116 sqlite3_extended_errcode db 117 } {SQLITE_ERROR_MISSING_COLLSEQ} 118 119 do_catchsql_test 3.6 { 120 SELECT * FROM t1 WHERE a=1; 121 } {1 {no such collation sequence: mysort}} 122 123 finish_test