From 77ad4e41337978c1d8f58d5083f1f59df7e6b41d Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 14 Jan 2003 02:49:27 +0000 Subject: [PATCH] More tests of the sqlite_set_authorizer() API together with fixes for bugs that the new tests uncovered. (CVS 832) FossilOrigin-Name: cc2ae781ac186f9ee1afacdc9117087421955369 --- manifest | 20 +- manifest.uuid | 2 +- src/build.c | 18 +- src/expr.c | 3 +- src/sqlite.h.in | 16 +- src/trigger.c | 3 + test/auth.test | 1385 ++++++++++++++++++++++++++++++++++++++++++++++- 7 files changed, 1408 insertions(+), 39 deletions(-) diff --git a/manifest b/manifest index c4fedde7ad..15d1d859c5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sthe\sGLOB\swork\swrite\swith\supper-case\scharacters.\s\sTicket\s#226.\s(CVS\s831) -D 2003-01-14T00:44:09 +C More\stests\sof\sthe\ssqlite_set_authorizer()\sAPI\stogether\swith\sfixes\sfor\sbugs\nthat\sthe\snew\stests\suncovered.\s(CVS\s832) +D 2003-01-14T02:49:27 F Makefile.in 6606854b1512f185b8e8c779b8d7fc2750463d64 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -21,10 +21,10 @@ F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea F src/auth.c 9c2db0bc7707f2d2e227f47e3d557b41d44ade75 F src/btree.c 131b5903f66e148f0f9af0cedd1c6654932c4e04 F src/btree.h 17710339f7a8f46e3c7d6d0d4648ef19c584ffda -F src/build.c 94cd4ed1724b3e7304387b2caece75aff39d7f6e +F src/build.c e107e7b837e24472d36bdf90498ed3dd458c0a8d F src/delete.c cbd499f3f9297504c42e328af89bef1a2113d04c F src/encode.c 09d1fe8a2e97ff94cce496e2909e2ebc8947960b -F src/expr.c d8b319f25335443a415a639aec8e0edc64e3ab6c +F src/expr.c 19f315a6c274897275d15ad7f238f604d178d706 F src/func.c 90c583f0b91220f7cd411a2407deaf9327245d63 F src/hash.c 4fc39feb7b7711f6495ee9f2159559bedb043e1f F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8 @@ -41,7 +41,7 @@ F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe F src/select.c 5ce75c1381d8ec3b89ea4d7eb5171bc57785e610 F src/shell.c c9946847b81b8b7f32ad195498dafbc623c6874f F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e -F src/sqlite.h.in 9974a66d4caa4880fe44ebdc306f5f94c6a4d9c0 +F src/sqlite.h.in 7907095c144091a611faef89d771bc0ee4e3ab9d F src/sqliteInt.h bc986d4fc3d8285cec370eb5e305d5499f422a31 F src/table.c eed2098c9b577aa17f8abe89313a9c4413f57d63 F src/tclsqlite.c 9f2c00a92338c51171ded8943bd42d77f7e69e64 @@ -50,14 +50,14 @@ F src/test2.c 03f05e984c8e2f2badc44644d42baf72b249096b F src/test3.c c12ea7f1c3fbbd58904e81e6cb10ad424e6fc728 F src/threadtest.c d641a5219e718e18a1a80a50eb9bb549f451f42e F src/tokenize.c 7ac1c33e0149647c9eb5959c48992df6906d4809 -F src/trigger.c cb72a3374b21ed00a6dbd3c2c5aa27a7fa72625f +F src/trigger.c da142decd2808bc39e801f3bb1f161dbc2bd4005 F src/update.c f06afa9bf1f777d17702e0f6e33cf44c44bc4f75 F src/util.c e23f8ffc654923e18f8db2d8e0de97c166fca20f F src/vdbe.c e103bd5a154b1790dd344662dceb14566a51a879 F src/vdbe.h 754eba497cfe0c3e352b9c101ab2f811f10d0a55 F src/where.c 5bf7f1e1d756ab3d25a18b24bb42106cb8e14d18 F test/all.test 873d30e25a41b3aa48fec5633a7ec1816e107029 -F test/auth.test c0b3210b109f9cdde2a19c7af603a3f6c763dcf8 +F test/auth.test 30149de6b78099ba06429fb7d6cc4dfcc1f4985c F test/bigfile.test 1cd8256d4619c39bea48147d344f348823e78678 F test/bigrow.test 8ab252dba108f12ad64e337b0f2ff31a807ac578 F test/btree.test 10e75aec120ecefc0edc4c912a0980a43db1b6c2 @@ -154,7 +154,7 @@ F www/speed.tcl a20a792738475b68756ea7a19321600f23d1d803 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218 -P 45de93f913a18026a45de6254963dbcd1b0f1a19 -R 654c653343e049aa49525a5a6b2d7926 +P 7ea46e706485cc159f9d1c7e69efcdd048a0bb12 +R 8cc1847ed9c1943d64f094cc16cdac01 U drh -Z 1fd43382d8c6399496ef6b31baa93763 +Z a2b19b177fc9f731ee24f39a7d702049 diff --git a/manifest.uuid b/manifest.uuid index 5dd316fa42..41dc421dfc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7ea46e706485cc159f9d1c7e69efcdd048a0bb12 \ No newline at end of file +cc2ae781ac186f9ee1afacdc9117087421955369 \ No newline at end of file diff --git a/src/build.c b/src/build.c index 9b9cfaa42b..11365efd7c 100644 --- a/src/build.c +++ b/src/build.c @@ -25,7 +25,7 @@ ** ROLLBACK ** PRAGMA ** -** $Id: build.c,v 1.121 2003/01/13 23:27:32 drh Exp $ +** $Id: build.c,v 1.122 2003/01/14 02:49:27 drh Exp $ */ #include "sqliteInt.h" #include @@ -333,6 +333,7 @@ void sqliteStartTable( if( zName==0 ) return; #ifndef SQLITE_OMIT_AUTHORIZATION if( sqliteAuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0) ){ + sqliteFree(zName); return; } { @@ -351,6 +352,7 @@ void sqliteStartTable( } } if( sqliteAuthCheck(pParse, code, zName, 0) ){ + sqliteFree(zName); return; } } @@ -1122,6 +1124,9 @@ void sqliteDropTable(Parse *pParse, Token *pName, int isView){ if( sqliteAuthCheck(pParse, code, pTable->zName, 0) ){ return; } + if( sqliteAuthCheck(pParse, SQLITE_DELETE, pTable->zName, 0) ){ + return; + } } #endif if( pTable->readOnly ){ @@ -1702,7 +1707,7 @@ void sqliteDropIndex(Parse *pParse, Token *pName){ return; } if( pTab->isTemp ) code = SQLITE_DROP_TEMP_INDEX; - if( sqliteAuthCheck(pParse, code, pIndex->zName, 0) ){ + if( sqliteAuthCheck(pParse, code, pIndex->zName, pTab->zName) ){ return; } } @@ -1896,15 +1901,19 @@ void sqliteCopy( Vdbe *v; int addr, end; Index *pIdx; + char *zFile = 0; sqlite *db = pParse->db; + zTab = sqliteTableNameFromToken(pTableName); if( sqlite_malloc_failed || zTab==0 ) goto copy_cleanup; pTab = sqliteTableNameToTable(pParse, zTab); sqliteFree(zTab); if( pTab==0 ) goto copy_cleanup; - if( sqliteAuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0) - || sqliteAuthCheck(pParse, SQLITE_COPY, pTab->zName, 0) ){ + zFile = sqliteStrNDup(pFilename->z, pFilename->n); + sqliteDequote(zFile); + if( sqliteAuthCheck(pParse, SQLITE_INSERT, pTab->zName, zFile) + || sqliteAuthCheck(pParse, SQLITE_COPY, pTab->zName, zFile) ){ goto copy_cleanup; } v = sqliteGetVdbe(pParse); @@ -1964,6 +1973,7 @@ void sqliteCopy( } copy_cleanup: + sqliteFree(zFile); return; } diff --git a/src/expr.c b/src/expr.c index 5fcfd88339..e56d05e3f3 100644 --- a/src/expr.c +++ b/src/expr.c @@ -12,7 +12,7 @@ ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.84 2003/01/12 18:02:18 drh Exp $ +** $Id: expr.c,v 1.85 2003/01/14 02:49:28 drh Exp $ */ #include "sqliteInt.h" #include @@ -430,7 +430,6 @@ int sqliteExprResolveIds( case TK_ID: { int cnt = 0; /* Number of matches */ int i; /* Loop counter */ - int rc; /* Return code */ char *z; assert( pExpr->token.z ); z = sqliteStrNDup(pExpr->token.z, pExpr->token.n); diff --git a/src/sqlite.h.in b/src/sqlite.h.in index c31eb9faf4..410691b437 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -12,7 +12,7 @@ ** This header file defines the interface that the SQLite library ** presents to client programs. ** -** @(#) $Id: sqlite.h.in,v 1.37 2003/01/13 23:27:33 drh Exp $ +** @(#) $Id: sqlite.h.in,v 1.38 2003/01/14 02:49:28 drh Exp $ */ #ifndef _SQLITE_H_ #define _SQLITE_H_ @@ -521,23 +521,23 @@ int sqlite_set_authorizer( ** ** Arg-3 Arg-4 */ -#define SQLITE_COPY 0 /* Table Name NULL */ +#define SQLITE_COPY 0 /* Table Name File Name */ #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ #define SQLITE_CREATE_TABLE 2 /* Table Name NULL */ #define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */ #define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */ -#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name NULL */ +#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */ #define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */ -#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name NULL */ +#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */ #define SQLITE_CREATE_VIEW 8 /* View Name NULL */ #define SQLITE_DELETE 9 /* Table Name NULL */ -#define SQLITE_DROP_INDEX 10 /* Index Name NULL */ +#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */ #define SQLITE_DROP_TABLE 11 /* Table Name NULL */ -#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name NULL */ +#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */ #define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */ -#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name NULL */ +#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */ #define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */ -#define SQLITE_DROP_TRIGGER 16 /* Trigger Name NULL */ +#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */ #define SQLITE_DROP_VIEW 17 /* View Name NULL */ #define SQLITE_INSERT 18 /* Table Name NULL */ #define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */ diff --git a/src/trigger.c b/src/trigger.c index ce00c2b057..03032fe259 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -106,6 +106,9 @@ void sqliteCreateTrigger( if( sqliteAuthCheck(pParse, code, zName, tab->zName) ){ goto trigger_cleanup; } + if( sqliteAuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(tab->isTemp), 0)){ + goto trigger_cleanup; + } } #endif } diff --git a/test/auth.test b/test/auth.test index 25eee7f557..8f4e3f5052 100644 --- a/test/auth.test +++ b/test/auth.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script testing the sqlite_set_authorizer() API. # -# $Id: auth.test,v 1.2 2003/01/13 23:27:34 drh Exp $ +# $Id: auth.test,v 1.3 2003/01/14 02:49:28 drh Exp $ # set testdir [file dirname $argv0] @@ -23,8 +23,7 @@ do_test auth-1.1 { db close set ::DB [sqlite db test.db] proc auth {code arg1 arg2} { - if {$code=="SQLITE_INSERT" - && [string compare -nocase $arg1 sqlite_master]==0} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { return SQLITE_DENY } return SQLITE_OK @@ -35,23 +34,26 @@ do_test auth-1.1 { do_test auth-1.2 { execsql {SELECT name FROM sqlite_master} } {} -do_test auth-1.3 { +do_test auth-1.3.1 { proc auth {code arg1 arg2} { if {$code=="SQLITE_CREATE_TABLE"} { + set ::authargs [list $arg1 $arg2] return SQLITE_DENY } return SQLITE_OK } catchsql {CREATE TABLE t1(a,b,c)} } {1 {not authorized}} +do_test auth-1.3.2 { + set ::authargs +} {t1 {}} do_test auth-1.4 { execsql {SELECT name FROM sqlite_master} } {} do_test auth-1.5 { proc auth {code arg1 arg2} { - if {$code=="SQLITE_INSERT" - && [string compare -nocase $arg1 sqlite_temp_master]==0} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { return SQLITE_DENY } return SQLITE_OK @@ -61,23 +63,26 @@ do_test auth-1.5 { do_test auth-1.6 { execsql {SELECT name FROM sqlite_temp_master} } {} -do_test auth-1.7 { +do_test auth-1.7.1 { proc auth {code arg1 arg2} { if {$code=="SQLITE_CREATE_TEMP_TABLE"} { + set ::authargs [list $arg1 $arg2] return SQLITE_DENY } return SQLITE_OK } catchsql {CREATE TEMP TABLE t1(a,b,c)} } {1 {not authorized}} +do_test auth-1.7.2 { + set ::authargs +} {t1 {}} do_test auth-1.8 { execsql {SELECT name FROM sqlite_temp_master} } {} do_test auth-1.9 { proc auth {code arg1 arg2} { - if {$code=="SQLITE_INSERT" - && [string compare -nocase $arg1 sqlite_master]==0} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { return SQLITE_IGNORE } return SQLITE_OK @@ -90,6 +95,7 @@ do_test auth-1.10 { do_test auth-1.11 { proc auth {code arg1 arg2} { if {$code=="SQLITE_CREATE_TABLE"} { + set ::authargs [list $arg1 $arg2] return SQLITE_IGNORE } return SQLITE_OK @@ -101,8 +107,7 @@ do_test auth-1.12 { } {} do_test auth-1.13 { proc auth {code arg1 arg2} { - if {$code=="SQLITE_INSERT" - && [string compare -nocase $arg1 sqlite_temp_master]==0} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { return SQLITE_IGNORE } return SQLITE_OK @@ -115,6 +120,7 @@ do_test auth-1.14 { do_test auth-1.15 { proc auth {code arg1 arg2} { if {$code=="SQLITE_CREATE_TEMP_TABLE"} { + set ::authargs [list $arg1 $arg2] return SQLITE_IGNORE } return SQLITE_OK @@ -128,7 +134,8 @@ do_test auth-1.16 { do_test auth-1.17 { proc auth {code arg1 arg2} { if {$code=="SQLITE_CREATE_TABLE"} { - return SQLITE_DEBY + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY } return SQLITE_OK } @@ -137,20 +144,1370 @@ do_test auth-1.17 { do_test auth-1.18 { execsql {SELECT name FROM sqlite_temp_master} } {t1} -do_test auth-1.19 { +do_test auth-1.19.1 { + set ::authargs {} proc auth {code arg1 arg2} { if {$code=="SQLITE_CREATE_TEMP_TABLE"} { - return SQLITE_DEBY + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY } return SQLITE_OK } catchsql {CREATE TABLE t2(a,b,c)} } {0 {}} +do_test auth-1.19.2 { + set ::authargs +} {} do_test auth-1.20 { execsql {SELECT name FROM sqlite_master} } {t2} +do_test auth-1.21.1 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TABLE"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP TABLE t2} +} {1 {not authorized}} +do_test auth-1.21.2 { + set ::authargs +} {t2 {}} +do_test auth-1.22 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.23.1 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TABLE"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP TABLE t2} +} {0 {}} +do_test auth-1.23.2 { + set ::authargs +} {t2 {}} +do_test auth-1.24 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.25 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TEMP_TABLE"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP TABLE t1} +} {1 {not authorized}} +do_test auth-1.26 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} +do_test auth-1.27 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TEMP_TABLE"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP TABLE t1} +} {0 {}} +do_test auth-1.28 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} + +do_test auth-1.29 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="t2"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {INSERT INTO t2 VALUES(1,2,3)} +} {1 {not authorized}} +do_test auth-1.30 { + execsql {SELECT * FROM t2} +} {} +do_test auth-1.31 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="t2"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {INSERT INTO t2 VALUES(1,2,3)} +} {0 {}} +do_test auth-1.32 { + execsql {SELECT * FROM t2} +} {} +do_test auth-1.33 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="t1"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {INSERT INTO t2 VALUES(1,2,3)} +} {0 {}} +do_test auth-1.34 { + execsql {SELECT * FROM t2} +} {1 2 3} + +do_test auth-1.35 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {SELECT * FROM t2} +} {1 {access to t2.b is prohibited}} +do_test auth-1.36 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {SELECT * FROM t2} +} {0 {1 {} 3}} +do_test auth-1.37 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {SELECT * FROM t2 WHERE b=2} +} {0 {}} +do_test auth-1.38 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="a"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {SELECT * FROM t2 WHERE b=2} +} {0 {{} 2 3}} +do_test auth-1.39 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {SELECT * FROM t2 WHERE b IS NULL} +} {0 {1 {} 3}} +do_test auth-1.40 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {SELECT a,c FROM t2 WHERE b IS NULL} +} {1 {access to t2.b is prohibited}} + +do_test auth-1.41 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_UPDATE" && $arg1=="t2" && $arg2=="b"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {UPDATE t2 SET a=11} +} {0 {}} +do_test auth-1.42 { + execsql {SELECT * FROM t2} +} {11 2 3} +do_test auth-1.43 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_UPDATE" && $arg1=="t2" && $arg2=="b"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {UPDATE t2 SET b=22, c=33} +} {1 {not authorized}} +do_test auth-1.44 { + execsql {SELECT * FROM t2} +} {11 2 3} +do_test auth-1.45 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_UPDATE" && $arg1=="t2" && $arg2=="b"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {UPDATE t2 SET b=22, c=33} +} {0 {}} +do_test auth-1.46 { + execsql {SELECT * FROM t2} +} {11 2 33} + +do_test auth-1.47 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="t2"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DELETE FROM t2 WHERE a=11} +} {1 {not authorized}} +do_test auth-1.48 { + execsql {SELECT * FROM t2} +} {11 2 33} +do_test auth-1.49 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="t2"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DELETE FROM t2 WHERE a=11} +} {0 {}} +do_test auth-1.50 { + execsql {SELECT * FROM t2} +} {11 2 33} + +do_test auth-1.51 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_SELECT"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {SELECT * FROM t2} +} {1 {not authorized}} +do_test auth-1.52 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_SELECT"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {SELECT * FROM t2} +} {0 {}} +do_test auth-1.53 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_SELECT"} { + return SQLITE_OK + } + return SQLITE_OK + } + catchsql {SELECT * FROM t2} +} {0 {11 2 33}} + +set f [open data1.txt w] +puts $f "7:8:9" +close $f +do_test auth-1.54 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_COPY"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {COPY t2 FROM 'data1.txt' USING DELIMITERS ':'} +} {1 {not authorized}} +do_test auth-1.55 { + set ::authargs +} {t2 data1.txt} +do_test auth-1.56 { + execsql {SELECT * FROM t2} +} {11 2 33} +do_test auth-1.57 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_COPY"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {COPY t2 FROM 'data1.txt' USING DELIMITERS ':'} +} {0 {}} +do_test auth-1.58 { + set ::authargs +} {t2 data1.txt} +do_test auth-1.59 { + execsql {SELECT * FROM t2} +} {11 2 33} +do_test auth-1.60 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_COPY"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_OK + } + return SQLITE_OK + } + catchsql {COPY t2 FROM 'data1.txt' USING DELIMITERS ':'} +} {0 {}} +do_test auth-1.61 { + set ::authargs +} {t2 data1.txt} +do_test auth-1.62 { + execsql {SELECT * FROM t2} +} {11 2 33 7 8 9} + +do_test auth-1.63 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP TABLE t2} +} {1 {not authorized}} +do_test auth-1.64 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.65 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="t2"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP TABLE t2} +} {1 {not authorized}} +do_test auth-1.66 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.67 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP TABLE t1} +} {1 {not authorized}} +do_test auth-1.68 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} +do_test auth-1.69 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="t1"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP TABLE t1} +} {1 {not authorized}} +do_test auth-1.70 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} + +do_test auth-1.71 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP TABLE t2} +} {0 {}} +do_test auth-1.72 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.73 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="t2"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP TABLE t2} +} {0 {}} +do_test auth-1.74 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.75 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP TABLE t1} +} {0 {}} +do_test auth-1.76 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} +do_test auth-1.77 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="t1"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP TABLE t1} +} {0 {}} +do_test auth-1.78 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} + +do_test auth-1.79 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_VIEW"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2} +} {1 {not authorized}} +do_test auth-1.80 { + set ::authargs +} {v1 {}} +do_test auth-1.81 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.82 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_VIEW"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2} +} {0 {}} +do_test auth-1.83 { + set ::authargs +} {v1 {}} +do_test auth-1.84 { + execsql {SELECT name FROM sqlite_master} +} {t2} + +do_test auth-1.85 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_TEMP_VIEW"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2} +} {1 {not authorized}} +do_test auth-1.86 { + set ::authargs +} {v1 {}} +do_test auth-1.87 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} +do_test auth-1.88 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_TEMP_VIEW"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2} +} {0 {}} +do_test auth-1.89 { + set ::authargs +} {v1 {}} +do_test auth-1.90 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} + +do_test auth-1.91 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2} +} {1 {not authorized}} +do_test auth-1.92 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.93 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2} +} {0 {}} +do_test auth-1.94 { + execsql {SELECT name FROM sqlite_master} +} {t2} + +do_test auth-1.95 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2} +} {1 {not authorized}} +do_test auth-1.96 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} +do_test auth-1.97 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2} +} {0 {}} +do_test auth-1.98 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} + +do_test auth-1.99 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql { + CREATE VIEW v2 AS SELECT a+1,b+1 FROM t2; + DROP VIEW v2 + } +} {1 {not authorized}} +do_test auth-1.100 { + execsql {SELECT name FROM sqlite_master} +} {t2 v2} +do_test auth-1.101 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_VIEW"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP VIEW v2} +} {1 {not authorized}} +do_test auth-1.102 { + set ::authargs +} {v2 {}} +do_test auth-1.103 { + execsql {SELECT name FROM sqlite_master} +} {t2 v2} +do_test auth-1.104 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP VIEW v2} +} {0 {}} +do_test auth-1.105 { + execsql {SELECT name FROM sqlite_master} +} {t2 v2} +do_test auth-1.106 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_VIEW"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP VIEW v2} +} {0 {}} +do_test auth-1.107 { + set ::authargs +} {v2 {}} +do_test auth-1.108 { + execsql {SELECT name FROM sqlite_master} +} {t2 v2} +do_test auth-1.109 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_VIEW"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_OK + } + return SQLITE_OK + } + catchsql {DROP VIEW v2} +} {0 {}} +do_test auth-1.110 { + set ::authargs +} {v2 {}} +do_test auth-1.111 { + execsql {SELECT name FROM sqlite_master} +} {t2} + + +do_test auth-1.112 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql { + CREATE TEMP VIEW v1 AS SELECT a+1,b+1 FROM t1; + DROP VIEW v1 + } +} {1 {not authorized}} +do_test auth-1.113 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1 v1} +do_test auth-1.114 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TEMP_VIEW"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP VIEW v1} +} {1 {not authorized}} +do_test auth-1.115 { + set ::authargs +} {v1 {}} +do_test auth-1.116 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1 v1} +do_test auth-1.117 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP VIEW v1} +} {0 {}} +do_test auth-1.118 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1 v1} +do_test auth-1.119 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TEMP_VIEW"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP VIEW v1} +} {0 {}} +do_test auth-1.120 { + set ::authargs +} {v1 {}} +do_test auth-1.121 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1 v1} +do_test auth-1.122 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TEMP_VIEW"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_OK + } + return SQLITE_OK + } + catchsql {DROP VIEW v1} +} {0 {}} +do_test auth-1.123 { + set ::authargs +} {v1 {}} +do_test auth-1.124 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} + +do_test auth-1.125 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_TRIGGER"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql { + CREATE TRIGGER r2 DELETE on t2 BEGIN + SELECT NULL; + END; + } +} {1 {not authorized}} +do_test auth-1.126 { + set ::authargs +} {r2 t2} +do_test auth-1.127 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.128 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql { + CREATE TRIGGER r2 DELETE on t2 BEGIN + SELECT NULL; + END; + } +} {1 {not authorized}} +do_test auth-1.129 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.130 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_TRIGGER"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql { + CREATE TRIGGER r2 DELETE on t2 BEGIN + SELECT NULL; + END; + } +} {0 {}} +do_test auth-1.131 { + set ::authargs +} {r2 t2} +do_test auth-1.132 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.133 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql { + CREATE TRIGGER r2 DELETE on t2 BEGIN + SELECT NULL; + END; + } +} {0 {}} +do_test auth-1.134 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.135 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_TRIGGER"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_OK + } + return SQLITE_OK + } + catchsql { + CREATE TRIGGER r2 DELETE on t2 BEGIN + SELECT NULL; + END; + } +} {0 {}} +do_test auth-1.136 { + set ::authargs +} {r2 t2} +do_test auth-1.137 { + execsql {SELECT name FROM sqlite_master} +} {t2 r2} + +do_test auth-1.138 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_TEMP_TRIGGER"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql { + CREATE TRIGGER r1 DELETE on t1 BEGIN + SELECT NULL; + END; + } +} {1 {not authorized}} +do_test auth-1.139 { + set ::authargs +} {r1 t1} +do_test auth-1.140 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} +do_test auth-1.141 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql { + CREATE TRIGGER r1 DELETE on t1 BEGIN + SELECT NULL; + END; + } +} {1 {not authorized}} +do_test auth-1.142 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} +do_test auth-1.143 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_TEMP_TRIGGER"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql { + CREATE TRIGGER r1 DELETE on t1 BEGIN + SELECT NULL; + END; + } +} {0 {}} +do_test auth-1.144 { + set ::authargs +} {r1 t1} +do_test auth-1.145 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} +do_test auth-1.146 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql { + CREATE TRIGGER r1 DELETE on t1 BEGIN + SELECT NULL; + END; + } +} {0 {}} +do_test auth-1.147 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} +do_test auth-1.148 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_TEMP_TRIGGER"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_OK + } + return SQLITE_OK + } + catchsql { + CREATE TRIGGER r1 DELETE on t1 BEGIN + SELECT NULL; + END; + } +} {0 {}} +do_test auth-1.149 { + set ::authargs +} {r1 t1} +do_test auth-1.150 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1 r1} + +do_test auth-1.151 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP TRIGGER r2} +} {1 {not authorized}} +do_test auth-1.152 { + execsql {SELECT name FROM sqlite_master} +} {t2 r2} +do_test auth-1.153 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TRIGGER"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP TRIGGER r2} +} {1 {not authorized}} +do_test auth-1.154 { + set ::authargs +} {r2 t2} +do_test auth-1.155 { + execsql {SELECT name FROM sqlite_master} +} {t2 r2} +do_test auth-1.156 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP TRIGGER r2} +} {0 {}} +do_test auth-1.157 { + execsql {SELECT name FROM sqlite_master} +} {t2 r2} +do_test auth-1.158 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TRIGGER"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP TRIGGER r2} +} {0 {}} +do_test auth-1.159 { + set ::authargs +} {r2 t2} +do_test auth-1.160 { + execsql {SELECT name FROM sqlite_master} +} {t2 r2} +do_test auth-1.161 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TRIGGER"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_OK + } + return SQLITE_OK + } + catchsql {DROP TRIGGER r2} +} {0 {}} +do_test auth-1.162 { + set ::authargs +} {r2 t2} +do_test auth-1.163 { + execsql {SELECT name FROM sqlite_master} +} {t2} + +do_test auth-1.164 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP TRIGGER r1} +} {1 {not authorized}} +do_test auth-1.165 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1 r1} +do_test auth-1.166 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TEMP_TRIGGER"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP TRIGGER r1} +} {1 {not authorized}} +do_test auth-1.167 { + set ::authargs +} {r1 t1} +do_test auth-1.168 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1 r1} +do_test auth-1.169 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP TRIGGER r1} +} {0 {}} +do_test auth-1.170 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1 r1} +do_test auth-1.171 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TEMP_TRIGGER"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP TRIGGER r1} +} {0 {}} +do_test auth-1.172 { + set ::authargs +} {r1 t1} +do_test auth-1.173 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1 r1} +do_test auth-1.174 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TEMP_TRIGGER"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_OK + } + return SQLITE_OK + } + catchsql {DROP TRIGGER r1} +} {0 {}} +do_test auth-1.175 { + set ::authargs +} {r1 t1} +do_test auth-1.176 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} + +do_test auth-1.177 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_INDEX"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {CREATE INDEX i2 ON t2(a)} +} {1 {not authorized}} +do_test auth-1.178 { + set ::authargs +} {i2 t2} +do_test auth-1.179 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.180 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {CREATE INDEX i2 ON t2(a)} +} {1 {not authorized}} +do_test auth-1.181 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.182 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_INDEX"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {CREATE INDEX i2 ON t2(b)} +} {0 {}} +do_test auth-1.183 { + set ::authargs +} {i2 t2} +do_test auth-1.184 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.185 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {CREATE INDEX i2 ON t2(b)} +} {0 {}} +do_test auth-1.186 { + execsql {SELECT name FROM sqlite_master} +} {t2} +do_test auth-1.187 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_INDEX"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_OK + } + return SQLITE_OK + } + catchsql {CREATE INDEX i2 ON t2(a)} +} {0 {}} +do_test auth-1.188 { + set ::authargs +} {i2 t2} +do_test auth-1.189 { + execsql {SELECT name FROM sqlite_master} +} {t2 i2} + +do_test auth-1.190 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_TEMP_INDEX"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {CREATE INDEX i1 ON t1(a)} +} {1 {not authorized}} +do_test auth-1.191 { + set ::authargs +} {i1 t1} +do_test auth-1.192 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} +do_test auth-1.193 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {CREATE INDEX i1 ON t1(b)} +} {1 {not authorized}} +do_test auth-1.194 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} +do_test auth-1.195 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_TEMP_INDEX"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {CREATE INDEX i1 ON t1(b)} +} {0 {}} +do_test auth-1.196 { + set ::authargs +} {i1 t1} +do_test auth-1.197 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} +do_test auth-1.198 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {CREATE INDEX i1 ON t1(c)} +} {0 {}} +do_test auth-1.199 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} +do_test auth-1.200 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_CREATE_TEMP_INDEX"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_OK + } + return SQLITE_OK + } + catchsql {CREATE INDEX i1 ON t1(a)} +} {0 {}} +do_test auth-1.201 { + set ::authargs +} {i1 t1} +do_test auth-1.202 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1 i1} + +do_test auth-1.203 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP INDEX i2} +} {1 {not authorized}} +do_test auth-1.204 { + execsql {SELECT name FROM sqlite_master} +} {t2 i2} +do_test auth-1.205 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_INDEX"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP INDEX i2} +} {1 {not authorized}} +do_test auth-1.206 { + set ::authargs +} {i2 t2} +do_test auth-1.207 { + execsql {SELECT name FROM sqlite_master} +} {t2 i2} +do_test auth-1.208 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP INDEX i2} +} {0 {}} +do_test auth-1.209 { + execsql {SELECT name FROM sqlite_master} +} {t2 i2} +do_test auth-1.210 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_INDEX"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP INDEX i2} +} {0 {}} +do_test auth-1.211 { + set ::authargs +} {i2 t2} +do_test auth-1.212 { + execsql {SELECT name FROM sqlite_master} +} {t2 i2} +do_test auth-1.213 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_INDEX"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_OK + } + return SQLITE_OK + } + catchsql {DROP INDEX i2} +} {0 {}} +do_test auth-1.214 { + set ::authargs +} {i2 t2} +do_test auth-1.215 { + execsql {SELECT name FROM sqlite_master} +} {t2} + +do_test auth-1.216 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP INDEX i1} +} {1 {not authorized}} +do_test auth-1.217 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1 i1} +do_test auth-1.218 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TEMP_INDEX"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {DROP INDEX i1} +} {1 {not authorized}} +do_test auth-1.219 { + set ::authargs +} {i1 t1} +do_test auth-1.220 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1 i1} +do_test auth-1.221 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DELETE" && $arg1=="sqlite_temp_master"} { + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP INDEX i1} +} {0 {}} +do_test auth-1.222 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1 i1} +do_test auth-1.223 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TEMP_INDEX"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {DROP INDEX i1} +} {0 {}} +do_test auth-1.224 { + set ::authargs +} {i1 t1} +do_test auth-1.225 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1 i1} +do_test auth-1.226 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_DROP_TEMP_INDEX"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_OK + } + return SQLITE_OK + } + catchsql {DROP INDEX i1} +} {0 {}} +do_test auth-1.227 { + set ::authargs +} {i1 t1} +do_test auth-1.228 { + execsql {SELECT name FROM sqlite_temp_master} +} {t1} + +do_test auth-1.229 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_PRAGMA"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_DENY + } + return SQLITE_OK + } + catchsql {PRAGMA full_column_names=on} +} {1 {not authorized}} +do_test auth-1.230 { + set ::authargs +} {full_column_names on} +do_test auth-1.231 { + execsql2 {SELECT a FROM t2} +} {a 11 a 7} +do_test auth-1.232 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_PRAGMA"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_IGNORE + } + return SQLITE_OK + } + catchsql {PRAGMA full_column_names=on} +} {0 {}} +do_test auth-1.233 { + set ::authargs +} {full_column_names on} +do_test auth-1.234 { + execsql2 {SELECT a FROM t2} +} {a 11 a 7} +do_test auth-1.235 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_PRAGMA"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_OK + } + return SQLITE_OK + } + catchsql {PRAGMA full_column_names=on} +} {0 {}} +do_test auth-1.236 { + execsql2 {SELECT a FROM t2} +} {t2.a 11 t2.a 7} +do_test auth-1.237 { + proc auth {code arg1 arg2} { + if {$code=="SQLITE_PRAGMA"} { + set ::authargs [list $arg1 $arg2] + return SQLITE_OK + } + return SQLITE_OK + } + catchsql {PRAGMA full_column_names=OFF} +} {0 {}} +do_test auth-1.238 { + set ::authargs +} {full_column_names OFF} +do_test auth-1.239 { + execsql2 {SELECT a FROM t2} +} {a 11 a 7} } ;# End of the "if( db command exists )"