AryaWu/sqlite
0
1# 2016 December 302#3# The author disclaims copyright to this source code. In place of4# 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. The12# focus of this file is testing OOM error handling within the built-in 13# group_concat() and string_agg() functions.14#15 16set testdir [file dirname $argv0]17source $testdir/tester.tcl18set testprefix gcfault19 20 21foreach {enc} {22 utf1623 utf824} {25 reset_db26 sqlite3_db_config_lookaside db 0 0 027 execsql "PRAGMA encoding = $enc"28 29 do_execsql_test 1.$enc.1 {30 CREATE TABLE s(i, s);31 INSERT INTO s VALUES(1, ',0123456789,');32 INSERT INTO s VALUES(2, X'2c303132333435363738392c');33 34 CREATE TABLE e(e);35 INSERT INTO e VALUES('v1'), ('v2');36 } {}37 38 do_faultsim_test 1.$enc.1 -faults oom* -body {39 execsql { SELECT group_concat(e, (SELECT s FROM s WHERE i=1)) FROM e }40 }41 42 do_faultsim_test 1.$enc.2 -faults oom-t* -body {43 execsql { SELECT string_agg(e, (SELECT s FROM s WHERE i=2)) FROM e }44 }45 46 do_faultsim_test 1.$enc.3 -faults oom-t* -prep {47 set ::STMT [sqlite3_prepare db {SELECT group_concat(e, ?) FROM e} -1 dummy]48 sqlite3_bind_text $::STMT 1 ",0123456789," 1249 } -body {50 while { "SQLITE_ROW"==[sqlite3_step $::STMT] } { }51 } -test {52 sqlite3_finalize $::STMT53 }54}55 56finish_test57 