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 15set testdir [file dirname $argv0] 16source $testdir/tester.tcl 17 18load_static_extension db eval 19do_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'} 24do_execsql_test misc8-1.1 { 25 SELECT quote(eval('SELECT * FROM t1 ORDER BY a')); 26} {{'1 2 3 4 5 6'}} 27do_catchsql_test misc8-1.2 { 28 SELECT quote(eval('SELECT d FROM t1 ORDER BY a')); 29} {1 {no such column: d}} 30do_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} 34do_catchsql_test misc8-1.4 { 35 BEGIN; 36 INSERT INTO t1 VALUES(10,11,12); 37 SELECT coalesce(b, eval('ROLLBACK')) FROM t1 ORDER BY a; 38} {1 {abort due to ROLLBACK}} 39do_catchsql_test misc8-1.5 { 40 INSERT INTO t1 VALUES(10,11,12); 41 SELECT a, coalesce(b, eval('SELECT ''bam''')), c 42 FROM t1 43 ORDER BY rowid; 44} {0 {1 2 3 4 5 6 7 bam 9 10 11 12}} 45do_catchsql_test misc8-1.6 { 46 SELECT a, coalesce(b, eval('DELETE FROM t1; SELECT ''bam''')), c 47 FROM t1 48 ORDER BY rowid; 49} {0 {1 2 3 4 5 6 7 bam {}}} 50 51 52finish_test 53