sl@0: # 2006 January 20 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # This file implements regression tests for SQLite library. sl@0: # sl@0: # This file implements tests for calling sqlite3_result_error() sl@0: # from within an aggregate function implementation. sl@0: # sl@0: # $Id: aggerror.test,v 1.3 2006/05/03 23:34:06 drh Exp $ sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: sl@0: # Add the x_count aggregate function to the database handle. sl@0: # x_count will error out if its input is 40 or 41 or if its sl@0: # final results is 42. Make sure that such errors are handled sl@0: # appropriately. sl@0: # sl@0: do_test aggerror-1.1 { sl@0: set DB [sqlite3_connection_pointer db] sl@0: sqlite3_create_aggregate $DB sl@0: execsql { sl@0: CREATE TABLE t1(a); sl@0: INSERT INTO t1 VALUES(1); sl@0: INSERT INTO t1 VALUES(2); sl@0: INSERT INTO t1 SELECT a+2 FROM t1; sl@0: INSERT INTO t1 SELECT a+4 FROM t1; sl@0: INSERT INTO t1 SELECT a+8 FROM t1; sl@0: INSERT INTO t1 SELECT a+16 FROM t1; sl@0: INSERT INTO t1 SELECT a+32 FROM t1 ORDER BY a LIMIT 7; sl@0: SELECT x_count(*) FROM t1; sl@0: } sl@0: } {39} sl@0: do_test aggerror-1.2 { sl@0: execsql { sl@0: INSERT INTO t1 VALUES(40); sl@0: SELECT x_count(*) FROM t1; sl@0: } sl@0: } {40} sl@0: do_test aggerror-1.3 { sl@0: catchsql { sl@0: SELECT x_count(a) FROM t1; sl@0: } sl@0: } {1 {value of 40 handed to x_count}} sl@0: ifcapable utf16 { sl@0: do_test aggerror-1.4 { sl@0: execsql { sl@0: UPDATE t1 SET a=41 WHERE a=40 sl@0: } sl@0: catchsql { sl@0: SELECT x_count(a) FROM t1; sl@0: } sl@0: } {1 abc} sl@0: } sl@0: do_test aggerror-1.5 { sl@0: execsql { sl@0: SELECT x_count(*) FROM t1 sl@0: } sl@0: } 40 sl@0: do_test aggerror-1.6 { sl@0: execsql { sl@0: INSERT INTO t1 VALUES(40); sl@0: INSERT INTO t1 VALUES(42); sl@0: } sl@0: catchsql { sl@0: SELECT x_count(*) FROM t1; sl@0: } sl@0: } {1 {x_count totals to 42}} sl@0: sl@0: finish_test