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 #***********************************************************************
12 # Test that the truncate optimization is disabled if the SQLITE_DELETE
13 # authorization callback returns SQLITE_IGNORE.
15 # $Id: auth3.test,v 1.2 2009/05/04 01:58:31 drh Exp $
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
21 # disable this test if the SQLITE_OMIT_AUTHORIZATION macro is
22 # defined during compilation.
23 if {[catch {db auth {}} msg]} {
28 # Disable the statement cache for these tests.
33 proc auth {code arg1 arg2 arg3 arg4 args} {
34 if {$code=="SQLITE_DELETE"} {
40 #--------------------------------------------------------------------------
41 # The following tests - auth3-1.* - test that return values of SQLITE_DENY,
42 # SQLITE_IGNORE, SQLITE_OK and <invalid> are correctly handled when returned
43 # by an SQLITE_DELETE authorization callback triggered by a
44 # "DELETE FROM <table-name>" statement.
48 CREATE TABLE t1(a,b,c);
49 INSERT INTO t1 VALUES(1, 2, 3);
50 INSERT INTO t1 VALUES(4, 5, 6);
54 set ::authcode SQLITE_DENY
55 catchsql { DELETE FROM t1 }
56 } {1 {not authorized}}
58 set ::authcode SQLITE_INVALID
59 catchsql { DELETE FROM t1 }
60 } {1 {authorizer malfunction}}
62 execsql { SELECT * FROM t1 }
65 set ::authcode SQLITE_IGNORE
72 set ::authcode SQLITE_OK
74 INSERT INTO t1 VALUES(1, 2, 3);
75 INSERT INTO t1 VALUES(4, 5, 6);
81 #--------------------------------------------------------------------------
82 # These tests - auth3-2.* - test that returning SQLITE_IGNORE really does
83 # disable the truncate optimization.
86 set ::authcode SQLITE_OK
88 INSERT INTO t1 VALUES(1, 2, 3);
89 INSERT INTO t1 VALUES(4, 5, 6);
91 set sqlite_search_count 0
95 set sqlite_search_count
99 set ::authcode SQLITE_IGNORE
101 INSERT INTO t1 VALUES(1, 2, 3);
102 INSERT INTO t1 VALUES(4, 5, 6);
104 set sqlite_search_count 0
108 set sqlite_search_count