# 2018 October 6 # # 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. # #************************************************************************* # set testdir [file dirname $argv0] source $testdir/tester.tcl # If SQLITE_OMIT_ALTERTABLE is defined, omit this file. ifcapable !altertable { finish_test return } set testprefix alterauth2 set ::auth [list] proc xAuth {type args} { lappend ::auth [concat $type [lrange $args 0 3]] if {$type=="SQLITE_READ" && [lindex $args 0] == "t2"} breakpoint return SQLITE_OK } db auth xAuth proc do_auth_test {tn sql authcode} { set script " set ::auth \[list\] execsql {$sql} lsort -unique \[set ::auth\] " set normal [list {*}$authcode] uplevel [list do_test $tn $script $normal] } do_execsql_test 1.0 { CREATE TABLE t1(a, b, c); CREATE VIEW v1 AS SELECT * FROM t1; CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN DELETE FROM t1 WHERE ab) } { {SQLITE_ALTER_TABLE main t2 {} {}} {SQLITE_FUNCTION {} sqlite_add_constraint {} {}} {SQLITE_FUNCTION {} sqlite_fail {} {}} {SQLITE_FUNCTION {} sqlite_find_constraint {} {}} {SQLITE_READ sqlite_master sql main {}} {SQLITE_READ sqlite_master tbl_name main {}} {SQLITE_READ sqlite_master type main {}} {SQLITE_READ t2 aaa main {}} {SQLITE_READ t2 b main {}} {SQLITE_SELECT {} {} {} {}} {SQLITE_UPDATE sqlite_master sql main {}} } do_auth_test 1.7 { ALTER TABLE t2 DROP CONSTRAINT abc; } { {SQLITE_ALTER_TABLE main t2 {} {}} {SQLITE_FUNCTION {} sqlite_drop_constraint {} {}} {SQLITE_READ sqlite_master sql main {}} {SQLITE_READ sqlite_master tbl_name main {}} {SQLITE_READ sqlite_master type main {}} {SQLITE_UPDATE sqlite_master sql main {}} } finish_test