1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/aggerror.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,78 @@
1.4 +# 2006 January 20
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +# This file implements regression tests for SQLite library.
1.15 +#
1.16 +# This file implements tests for calling sqlite3_result_error()
1.17 +# from within an aggregate function implementation.
1.18 +#
1.19 +# $Id: aggerror.test,v 1.3 2006/05/03 23:34:06 drh Exp $
1.20 +
1.21 +set testdir [file dirname $argv0]
1.22 +source $testdir/tester.tcl
1.23 +
1.24 +
1.25 +# Add the x_count aggregate function to the database handle.
1.26 +# x_count will error out if its input is 40 or 41 or if its
1.27 +# final results is 42. Make sure that such errors are handled
1.28 +# appropriately.
1.29 +#
1.30 +do_test aggerror-1.1 {
1.31 + set DB [sqlite3_connection_pointer db]
1.32 + sqlite3_create_aggregate $DB
1.33 + execsql {
1.34 + CREATE TABLE t1(a);
1.35 + INSERT INTO t1 VALUES(1);
1.36 + INSERT INTO t1 VALUES(2);
1.37 + INSERT INTO t1 SELECT a+2 FROM t1;
1.38 + INSERT INTO t1 SELECT a+4 FROM t1;
1.39 + INSERT INTO t1 SELECT a+8 FROM t1;
1.40 + INSERT INTO t1 SELECT a+16 FROM t1;
1.41 + INSERT INTO t1 SELECT a+32 FROM t1 ORDER BY a LIMIT 7;
1.42 + SELECT x_count(*) FROM t1;
1.43 + }
1.44 +} {39}
1.45 +do_test aggerror-1.2 {
1.46 + execsql {
1.47 + INSERT INTO t1 VALUES(40);
1.48 + SELECT x_count(*) FROM t1;
1.49 + }
1.50 +} {40}
1.51 +do_test aggerror-1.3 {
1.52 + catchsql {
1.53 + SELECT x_count(a) FROM t1;
1.54 + }
1.55 +} {1 {value of 40 handed to x_count}}
1.56 +ifcapable utf16 {
1.57 + do_test aggerror-1.4 {
1.58 + execsql {
1.59 + UPDATE t1 SET a=41 WHERE a=40
1.60 + }
1.61 + catchsql {
1.62 + SELECT x_count(a) FROM t1;
1.63 + }
1.64 + } {1 abc}
1.65 +}
1.66 +do_test aggerror-1.5 {
1.67 + execsql {
1.68 + SELECT x_count(*) FROM t1
1.69 + }
1.70 +} 40
1.71 +do_test aggerror-1.6 {
1.72 + execsql {
1.73 + INSERT INTO t1 VALUES(40);
1.74 + INSERT INTO t1 VALUES(42);
1.75 + }
1.76 + catchsql {
1.77 + SELECT x_count(*) FROM t1;
1.78 + }
1.79 +} {1 {x_count totals to 42}}
1.80 +
1.81 +finish_test