2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A# 2004 Jan 14
2N/A#
2N/A# The author disclaims copyright to this source code. In place of
2N/A# a legal notice, here is a blessing:
2N/A#
2N/A# May you do good and not evil.
2N/A# May you find forgiveness for yourself and forgive others.
2N/A# May you share freely, never taking more than you give.
2N/A#
2N/A#***********************************************************************
2N/A# This file implements regression tests for TCL interface to the
2N/A# SQLite library.
2N/A#
2N/A# The focus of the tests in this file is the following interface:
2N/A#
2N/A# sqlite_commit_hook
2N/A#
2N/A# $Id: hook.test,v 1.3 2004/01/15 02:44:03 drh Exp $
2N/A
2N/Aset testdir [file dirname $argv0]
2N/Asource $testdir/tester.tcl
2N/A
2N/Ado_test hook-1.2 {
2N/A db commit_hook
2N/A} {}
2N/A
2N/A
2N/Ado_test hook-3.1 {
2N/A set commit_cnt 0
2N/A proc commit_hook {} {
2N/A incr ::commit_cnt
2N/A return 0
2N/A }
2N/A db commit_hook ::commit_hook
2N/A db commit_hook
2N/A} {::commit_hook}
2N/Ado_test hook-3.2 {
2N/A set commit_cnt
2N/A} {0}
2N/Ado_test hook-3.3 {
2N/A execsql {
2N/A CREATE TABLE t2(a,b);
2N/A }
2N/A set commit_cnt
2N/A} {1}
2N/Ado_test hook-3.4 {
2N/A execsql {
2N/A INSERT INTO t2 VALUES(1,2);
2N/A INSERT INTO t2 SELECT a+1, b+1 FROM t2;
2N/A INSERT INTO t2 SELECT a+2, b+2 FROM t2;
2N/A }
2N/A set commit_cnt
2N/A} {4}
2N/Ado_test hook-3.5 {
2N/A set commit_cnt {}
2N/A proc commit_hook {} {
2N/A set ::commit_cnt [execsql {SELECT * FROM t2}]
2N/A return 0
2N/A }
2N/A execsql {
2N/A INSERT INTO t2 VALUES(5,6);
2N/A }
2N/A set commit_cnt
2N/A} {1 2 2 3 3 4 4 5 5 6}
2N/Ado_test hook-3.6 {
2N/A set commit_cnt {}
2N/A proc commit_hook {} {
2N/A set ::commit_cnt [execsql {SELECT * FROM t2}]
2N/A return 1
2N/A }
2N/A catchsql {
2N/A INSERT INTO t2 VALUES(6,7);
2N/A }
2N/A} {1 {constraint failed}}
2N/Ado_test hook-3.7 {
2N/A set commit_cnt
2N/A} {1 2 2 3 3 4 4 5 5 6 6 7}
2N/Ado_test hook-3.8 {
2N/A execsql {SELECT * FROM t2}
2N/A} {1 2 2 3 3 4 4 5 5 6}
2N/A
2N/A
2N/Afinish_test