1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Make sqlite3_count_changes() and total_changes() work with "DELETE FROM <table-name>". (CVS 5844)

FossilOrigin-Name: e68e4282adb9003aa297d033aeb5d9cadee215cd
This commit is contained in:
danielk1977
2008-10-27 13:59:33 +00:00
parent 9a02fb444c
commit c7af484b4b
8 changed files with 102 additions and 39 deletions

View File

@ -1,3 +1,4 @@
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
@ -19,6 +20,7 @@
# Note 3: changes() is not changed by a change to a view (since everything
# is done within instead of trigger context).
#
# $Id: laststmtchanges.test,v 1.7 2008/10/27 13:59:34 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -278,4 +280,52 @@ do_test laststmtchanges-5.5 {
} ;# ifcapable view
# ----------------------------------------------------------------------------
# 6.x - Test "DELETE FROM <table>" in the absence of triggers
#
do_test laststmtchanges-6.1 {
execsql {
CREATE TABLE t3(a, b, c);
INSERT INTO t3 VALUES(1, 2, 3);
INSERT INTO t3 VALUES(4, 5, 6);
}
} {}
do_test laststmtchanges-6.2 {
execsql {
BEGIN;
DELETE FROM t3;
SELECT changes();
}
} {2}
do_test laststmtchanges-6.3 {
execsql {
ROLLBACK;
BEGIN;
DELETE FROM t3 WHERE a IS NOT NULL;
SELECT changes();
}
} {2}
do_test laststmtchanges-6.4 {
execsql {
ROLLBACK;
CREATE INDEX t3_i1 ON t3(a);
BEGIN;
DELETE FROM t3;
SELECT changes();
}
} {2}
do_test laststmtchanges-6.5 {
execsql { ROLLBACK }
set nTotalChange [execsql {SELECT total_changes()}]
expr 0
} {0}
do_test laststmtchanges-6.6 {
execsql {
SELECT total_changes();
DELETE FROM t3;
SELECT total_changes();
}
} [list $nTotalChange [expr $nTotalChange+2]]
finish_test