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 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this file is the authorisation callback and virtual tables.
14 # $Id: vtab3.test,v 1.3 2008/07/12 14:52:21 drh Exp $
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
19 ifcapable !vtab||!auth {
26 set ::auth_filter [list SQLITE_READ SQLITE_UPDATE SQLITE_SELECT SQLITE_PRAGMA]
28 proc auth {code arg1 arg2 arg3 arg4 args} {
29 if {[lsearch $::auth_filter $code]>-1} {
32 lappend ::auth_log $code $arg1 $arg2 $arg3 $arg4
34 if {$::auth_fail == 0} {
42 CREATE TABLE elephant(
53 register_echo_module [sqlite3_connection_pointer db]
56 CREATE VIRTUAL TABLE pachyderm USING echo(elephant);
60 SQLITE_INSERT sqlite_master {} main {} \
61 SQLITE_CREATE_VTABLE pachyderm echo main {} \
71 SQLITE_DELETE sqlite_master {} main {} \
72 SQLITE_DROP_VTABLE pachyderm echo main {} \
73 SQLITE_DELETE pachyderm {} main {} \
74 SQLITE_DELETE sqlite_master {} main {} \
80 CREATE VIRTUAL TABLE pachyderm USING echo(elephant);
82 } {1 {not authorized}}
85 SELECT name FROM sqlite_master WHERE type = 'table';
92 CREATE VIRTUAL TABLE pachyderm USING echo(elephant);
94 } {1 {not authorized}}
97 SELECT name FROM sqlite_master WHERE type = 'table';
104 CREATE VIRTUAL TABLE pachyderm USING echo(elephant);
109 SELECT name FROM sqlite_master WHERE type = 'table';
111 } {elephant pachyderm}
113 foreach i [list 1 2 3 4] {
115 do_test vtab3-1.7.$i.1 {
117 execsql {DROP TABLE pachyderm;}
119 if {$msg eq "authorization denied"} {set msg "not authorized"}
121 } {1 {not authorized}}
122 do_test vtab3-1.7.$i.2 {
124 SELECT name FROM sqlite_master WHERE type = 'table';
126 } {elephant pachyderm}
128 do_test vtab3-1.8.1 {
131 DROP TABLE pachyderm;
134 do_test vtab3-1.8.2 {
136 SELECT name FROM sqlite_master WHERE type = 'table';