Fix and test the processing of sqlite3_result_error() withing aggregate
functions. Allow errors to come from the step function (a new capability). Ticket #1632. (CVS 2981) FossilOrigin-Name: fd4a6bb1ac94d085dda247799c0a5c64aaeec046
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
# 2006 January 20
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library.
|
||||
#
|
||||
# This file implements tests for calling sqlite3_result_error()
|
||||
# from within an aggregate function implementation.
|
||||
#
|
||||
# $Id: aggerror.test,v 1.1 2006/01/20 15:45:37 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
|
||||
# Add the x_count aggregate function to the database handle.
|
||||
# x_count will error out if its input is 40 or 41 or if its
|
||||
# final results is 42. Make sure that such errors are handled
|
||||
# appropriately.
|
||||
#
|
||||
do_test aggfunc-1.1 {
|
||||
set DB [sqlite3_connection_pointer db]
|
||||
sqlite3_create_aggregate $DB
|
||||
execsql {
|
||||
CREATE TABLE t1(a);
|
||||
INSERT INTO t1 VALUES(1);
|
||||
INSERT INTO t1 VALUES(2);
|
||||
INSERT INTO t1 SELECT a+2 FROM t1;
|
||||
INSERT INTO t1 SELECT a+4 FROM t1;
|
||||
INSERT INTO t1 SELECT a+8 FROM t1;
|
||||
INSERT INTO t1 SELECT a+16 FROM t1;
|
||||
INSERT INTO t1 SELECT a+32 FROM t1 ORDER BY a LIMIT 7;
|
||||
SELECT x_count(*) FROM t1;
|
||||
}
|
||||
} {39}
|
||||
do_test aggfunc-1.2 {
|
||||
execsql {
|
||||
INSERT INTO t1 VALUES(40);
|
||||
SELECT x_count(*) FROM t1;
|
||||
}
|
||||
} {40}
|
||||
do_test aggfunc-1.3 {
|
||||
catchsql {
|
||||
SELECT x_count(a) FROM t1;
|
||||
}
|
||||
} {1 {value of 40 handed to x_count}}
|
||||
do_test aggfunc-1.4 {
|
||||
execsql {
|
||||
UPDATE t1 SET a=41 WHERE a=40
|
||||
}
|
||||
catchsql {
|
||||
SELECT x_count(a) FROM t1;
|
||||
}
|
||||
} {1 abc}
|
||||
do_test aggfunc-1.5 {
|
||||
execsql {
|
||||
SELECT x_count(*) FROM t1
|
||||
}
|
||||
} 40
|
||||
do_test aggfunc-1.6 {
|
||||
execsql {
|
||||
INSERT INTO t1 VALUES(40);
|
||||
INSERT INTO t1 VALUES(42);
|
||||
}
|
||||
catchsql {
|
||||
SELECT x_count(*) FROM t1;
|
||||
}
|
||||
} {1 {x_count totals to 42}}
|
||||
|
||||
finish_test
|
||||
+2
-2
@@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing built-in functions.
|
||||
#
|
||||
# $Id: func.test,v 1.43 2006/01/03 00:33:50 drh Exp $
|
||||
# $Id: func.test,v 1.44 2006/01/20 15:45:37 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -467,7 +467,7 @@ do_test func-15.1 {
|
||||
catchsql {
|
||||
select test_error(NULL);
|
||||
}
|
||||
} {1 {user function error}}
|
||||
} {1 {}}
|
||||
|
||||
# Test the quote function for BLOB and NULL values.
|
||||
do_test func-16.1 {
|
||||
|
||||
Reference in New Issue
Block a user