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/misc8.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 / misc8.test` 158 lines ยท 4313 bytes Raw Blame History 1 # 2014-11-10 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 # The focus of this script is testing the "eval.c" loadable extension. 13 # 14 15 set testdir [file dirname $argv0] 16 source $testdir/tester.tcl 17 18 load_static_extension db eval 19 do_execsql_test misc8-1.0 { 20 CREATE TABLE t1(a,b,c); 21 INSERT INTO t1 VALUES(1,2,3),(4,5,6); 22 SELECT quote(eval('SELECT * FROM t1 ORDER BY a','-abc-')); 23 } {'1-abc-2-abc-3-abc-4-abc-5-abc-6'} 24 do_execsql_test misc8-1.1 { 25 SELECT quote(eval('SELECT * FROM t1 ORDER BY a')); 26 } {{'1 2 3 4 5 6'}} 27 do_catchsql_test misc8-1.2 { 28 SELECT quote(eval('SELECT d FROM t1 ORDER BY a')); 29 } {1 {no such column: d}} 30 do_execsql_test misc8-1.3 { 31 INSERT INTO t1 VALUES(7,null,9); 32 SELECT eval('SELECT * FROM t1 ORDER BY a',','); 33 } {1,2,3,4,5,6,7,,9} 34 do_catchsql_test misc8-1.4 { 35 BEGIN; 36 INSERT INTO t1 VALUES(10,11,12); 37 SELECT a, coalesce(b, eval('ROLLBACK; SELECT ''bam'';')), c 38 FROM t1 ORDER BY a; 39 } {0 {1 2 3 4 5 6 7 bam 9}} 40 do_catchsql_test misc8-1.5 { 41 INSERT INTO t1 VALUES(10,11,12); 42 SELECT a, coalesce(b, eval('SELECT ''bam''')), c 43 FROM t1 44 ORDER BY rowid; 45 } {0 {1 2 3 4 5 6 7 bam 9 10 11 12}} 46 do_catchsql_test misc8-1.6 { 47 SELECT a, coalesce(b, eval('DELETE FROM t1; SELECT ''bam''')), c 48 FROM t1 49 ORDER BY rowid; 50 } {0 {1 2 3 4 5 6 7 bam {}}} 51 do_catchsql_test misc8-1.7 { 52 INSERT INTO t1 VALUES(1,2,3),(4,5,6),(7,null,9); 53 BEGIN; 54 CREATE TABLE t2(x); 55 SELECT a, coalesce(b, eval('ROLLBACK; SELECT ''bam''')), c 56 FROM t1 57 ORDER BY rowid; 58 } {1 {abort due to ROLLBACK}} 59 60 do_catchsql_test misc8-1.8 { 61 PRAGMA empty_result_callbacks = 1; 62 SELECT eval('SELECT * FROM t1 WHERE 1 = 0;'); 63 } {0 {{}}} 64 65 # Bug 2026-07-29T06:29:11Z 66 # 67 do_execsql_test misc8-1.9 { 68 DROP TABLE IF EXISTS t1; 69 CREATE TABLE t1(x text); 70 INSERT INTO t1 VALUES('SELECT eval(x) FROM t1'); 71 } {} 72 do_catchsql_test misc8-1.10 { 73 SELECT eval(x) FROM t1; 74 } {1 {eval() nested too deep}} 75 76 reset_db 77 78 proc dbeval {sql} { db eval $sql } 79 db func eval dbeval 80 81 do_execsql_test misc8-2.1 { 82 CREATE TABLE t1(a INTEGER PRIMARY KEY, b INTEGER) WITHOUT ROWID; 83 CREATE TABLE t2(c INTEGER PRIMARY KEY, d INTEGER, x BLOB); 84 INSERT INTO t1 VALUES(0,0); 85 INSERT INTO t1 VALUES(10,10); 86 INSERT INTO t2 VALUES(1,1,zeroblob(200)); 87 INSERT INTO t2 VALUES(2,2,zeroblob(200)); 88 INSERT INTO t2 VALUES(3,3,zeroblob(200)); 89 INSERT INTO t2 VALUES(4,4,zeroblob(200)); 90 INSERT INTO t2 VALUES(5,5,zeroblob(200)); 91 INSERT INTO t2 VALUES(6,6,zeroblob(200)); 92 INSERT INTO t2 VALUES(7,7,zeroblob(200)); 93 INSERT INTO t2 VALUES(8,8,zeroblob(200)); 94 INSERT INTO t2 VALUES(9,9,zeroblob(200)); 95 INSERT INTO t2 VALUES(10,10,zeroblob(200)); 96 SELECT a, c, eval( 97 printf('DELETE FROM t2 WHERE c=%d AND %d>5', a+c, a+c) 98 ) FROM t1, t2; 99 } { 100 0 1 {} 10 1 {} 101 0 2 {} 10 2 {} 102 0 3 {} 10 3 {} 103 0 4 {} 10 4 {} 104 0 5 {} 10 5 {} 105 0 6 {} 10 {} {} 106 0 7 {} 10 {} {} 107 0 8 {} 10 {} {} 108 0 9 {} 10 {} {} 109 0 10 {} 10 {} {} 110 } 111 112 # 2016-02-26: An assertion fault found by the libFuzzer project 113 # 114 ifcapable allow_rowid_in_view { 115 set nosuch "1 {ambiguous column name: rowid}" 116 } else { 117 set nosuch "1 {no such column: rowid}" 118 } 119 do_catchsql_test misc8-3.0 { 120 SELECT * 121 FROM 122 ( 123 (SELECT 0 AS i) AS x1, 124 (SELECT 1) AS x2 125 ) AS x3, 126 (SELECT 6 AS j UNION ALL SELECT 7) AS x4 127 WHERE i