3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
13 # This file implements tests for calling sqlite3_result_error()
14 # from within an aggregate function implementation.
16 # $Id: aggerror.test,v 1.3 2006/05/03 23:34:06 drh Exp $
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
22 # Add the x_count aggregate function to the database handle.
23 # x_count will error out if its input is 40 or 41 or if its
24 # final results is 42. Make sure that such errors are handled
27 do_test aggerror-1.1 {
28 set DB [sqlite3_connection_pointer db]
29 sqlite3_create_aggregate $DB
32 INSERT INTO t1 VALUES(1);
33 INSERT INTO t1 VALUES(2);
34 INSERT INTO t1 SELECT a+2 FROM t1;
35 INSERT INTO t1 SELECT a+4 FROM t1;
36 INSERT INTO t1 SELECT a+8 FROM t1;
37 INSERT INTO t1 SELECT a+16 FROM t1;
38 INSERT INTO t1 SELECT a+32 FROM t1 ORDER BY a LIMIT 7;
39 SELECT x_count(*) FROM t1;
42 do_test aggerror-1.2 {
44 INSERT INTO t1 VALUES(40);
45 SELECT x_count(*) FROM t1;
48 do_test aggerror-1.3 {
50 SELECT x_count(a) FROM t1;
52 } {1 {value of 40 handed to x_count}}
54 do_test aggerror-1.4 {
56 UPDATE t1 SET a=41 WHERE a=40
59 SELECT x_count(a) FROM t1;
63 do_test aggerror-1.5 {
65 SELECT x_count(*) FROM t1
68 do_test aggerror-1.6 {
70 INSERT INTO t1 VALUES(40);
71 INSERT INTO t1 VALUES(42);
74 SELECT x_count(*) FROM t1;
76 } {1 {x_count totals to 42}}