Fix SQLITE_OMIT_AUTHORIZATION so that it compiles cleanly.

FossilOrigin-Name: a3e3b3e1c57178ccd38fc7375ec1de8e8ae45372
This commit is contained in:
drh 2016-09-16 11:53:10 +00:00
parent 760c8162ff
commit a0daa751f8
8 changed files with 35 additions and 31 deletions

View File

@ -1,5 +1,5 @@
C In\sthe\sshell,\smake\s".testcase"\sand\s".check"\savailable\sin\sall\sconfigurations,\nnot\sjust\sSQLITE_DEBUG.\s\sAll\stestcases\sto\sbe\snamed.\s\sShow\sthe\sresult\sof\seach\ntestcase\son\sstdout. C Fix\sSQLITE_OMIT_AUTHORIZATION\sso\sthat\sit\scompiles\scleanly.
D 2016-09-16T02:52:22.198 D 2016-09-16T11:53:10.715
F Makefile.in 6fd48ffcf7c2deea7499062d1f3747f986c19678 F Makefile.in 6fd48ffcf7c2deea7499062d1f3747f986c19678
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc e1aa788e84f926e42239ee167c53f785bedacacd F Makefile.msc e1aa788e84f926e42239ee167c53f785bedacacd
@ -332,13 +332,13 @@ F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73
F src/btree.c 2551bd3ecb8b8988fb8b23aabadfb214dbc38e46 F src/btree.c 2551bd3ecb8b8988fb8b23aabadfb214dbc38e46
F src/btree.h d05b2fcc290991a8a3d9ea1816ddd55a4359dcde F src/btree.h d05b2fcc290991a8a3d9ea1816ddd55a4359dcde
F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5
F src/build.c c2ccfcdd99e18894a8750e215b8d9c5398a3c073 F src/build.c 7438b6dae3022818100a79ebbad707b5c65f9344
F src/callback.c 2e76147783386374bf01b227f752c81ec872d730 F src/callback.c 2e76147783386374bf01b227f752c81ec872d730
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
F src/ctime.c e77f3dc297b4b65c96da78b4ae4272fdfae863d7 F src/ctime.c e77f3dc297b4b65c96da78b4ae4272fdfae863d7
F src/date.c 95c9a8d00767e7221a8e9a31f4e913fc8029bf6b F src/date.c 95c9a8d00767e7221a8e9a31f4e913fc8029bf6b
F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d
F src/delete.c 76c084f0265f4a3cd1ecf17eee112a94f1ccbc05 F src/delete.c e91a11e0e86a13ce1917ca5ad7cf14c37ba31e59
F src/expr.c c1de78269522de39f6ad877ab0810a5d48f91f34 F src/expr.c c1de78269522de39f6ad877ab0810a5d48f91f34
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c e2be0968c1adc679c87e467aa5b4f167588f38a8 F src/fkey.c e2be0968c1adc679c87e467aa5b4f167588f38a8
@ -348,7 +348,7 @@ F src/hash.c 55b5fb474100cee0b901edaf203e26c970940f36
F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4
F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
F src/insert.c 3edb5a1bda44df13531fedfcde5fbcc2fc04c222 F src/insert.c 427e96ff168b6b187a52c3d06b9f9e41f6ffb212
F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e
F src/loadext.c 5d6642d141c07d366e43d359e94ec9de47add41d F src/loadext.c 5d6642d141c07d366e43d359e94ec9de47add41d
F src/main.c 9821bb4d2399bc5a0b8a5dfc06bede2d1520255c F src/main.c 9821bb4d2399bc5a0b8a5dfc06bede2d1520255c
@ -384,10 +384,10 @@ F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c
F src/prepare.c 0fcf16eaacc90c1059055519a76b75b516a59a88 F src/prepare.c 0fcf16eaacc90c1059055519a76b75b516a59a88
F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1 F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1
F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
F src/resolve.c 24f40fd0c3475821d1ad762a3f2c3455cc839b42 F src/resolve.c 3c3cf0dc719cd2a32ab5c1e10c26481dd565492e
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
F src/select.c 244f9cc5e4662987cd2ef5c22d1b7027560f3425 F src/select.c 244f9cc5e4662987cd2ef5c22d1b7027560f3425
F src/shell.c 2c558e83e0961de364570182c0ff26395d7aaba0 F src/shell.c ae7058efb5084b4b9576dc5485bb3d2870b1974a
F src/sqlite.h.in 46ed821aeed0ba45559fb15597d9a400083154a2 F src/sqlite.h.in 46ed821aeed0ba45559fb15597d9a400083154a2
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae
@ -448,7 +448,7 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
F src/tokenize.c 78c8085bc7af1922aa687f0f4bbd716821330de5 F src/tokenize.c 78c8085bc7af1922aa687f0f4bbd716821330de5
F src/treeview.c f51b75a28b377adde9f79bc3deb6c7770bcf97c0 F src/treeview.c f51b75a28b377adde9f79bc3deb6c7770bcf97c0
F src/trigger.c 11e20b3b12c847b3b9055594c0f1631266bb53fc F src/trigger.c cae81f6c65c4977bc2cbd27d43bfee478710853c
F src/update.c 8179e699dbd45b92934fd02d3d8e3732e8da8802 F src/update.c 8179e699dbd45b92934fd02d3d8e3732e8da8802
F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c
F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d F src/util.c 810ec3f22e2d1b62e66c30fe3621ebdedd23584d
@ -1525,7 +1525,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 8e5c92039128a430e0509f4f06ea80ba39c35bda P 792afefa9c750910082fd102f1ccd10309759dfc
R 46d709a281b0ceda3453ac789078f257 R 8c1833647015caee904c1e0d3421d795
U drh U drh
Z 03a0324123b8a87d967c8d29c327e230 Z 8c6311e2ea32e5d653d9fa56ba1b62fa

View File

@ -1 +1 @@
792afefa9c750910082fd102f1ccd10309759dfc a3e3b3e1c57178ccd38fc7375ec1de8e8ae45372

View File

@ -2141,7 +2141,9 @@ int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
int nErr = 0; /* Number of errors encountered */ int nErr = 0; /* Number of errors encountered */
int n; /* Temporarily holds the number of cursors assigned */ int n; /* Temporarily holds the number of cursors assigned */
sqlite3 *db = pParse->db; /* Database connection for malloc errors */ sqlite3 *db = pParse->db; /* Database connection for malloc errors */
#ifndef SQLITE_OMIT_AUTHORIZATION
sqlite3_xauth xAuth; /* Saved xAuth pointer */ sqlite3_xauth xAuth; /* Saved xAuth pointer */
#endif
assert( pTable ); assert( pTable );

View File

@ -212,7 +212,6 @@ void sqlite3DeleteFrom(
){ ){
Vdbe *v; /* The virtual database engine */ Vdbe *v; /* The virtual database engine */
Table *pTab; /* The table from which records will be deleted */ Table *pTab; /* The table from which records will be deleted */
const char *zDb; /* Name of database holding pTab */
int i; /* Loop counter */ int i; /* Loop counter */
WhereInfo *pWInfo; /* Information about the WHERE clause */ WhereInfo *pWInfo; /* Information about the WHERE clause */
Index *pIdx; /* For looping over indices of the table */ Index *pIdx; /* For looping over indices of the table */
@ -289,8 +288,8 @@ void sqlite3DeleteFrom(
} }
iDb = sqlite3SchemaToIndex(db, pTab->pSchema); iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
assert( iDb<db->nDb ); assert( iDb<db->nDb );
zDb = db->aDb[iDb].zDbSName; rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0,
rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb); db->aDb[iDb].zDbSName);
assert( rcauth==SQLITE_OK || rcauth==SQLITE_DENY || rcauth==SQLITE_IGNORE ); assert( rcauth==SQLITE_OK || rcauth==SQLITE_DENY || rcauth==SQLITE_IGNORE );
if( rcauth==SQLITE_DENY ){ if( rcauth==SQLITE_DENY ){
goto delete_from_cleanup; goto delete_from_cleanup;

View File

@ -485,7 +485,6 @@ void sqlite3Insert(
sqlite3 *db; /* The main database structure */ sqlite3 *db; /* The main database structure */
Table *pTab; /* The table to insert into. aka TABLE */ Table *pTab; /* The table to insert into. aka TABLE */
char *zTab; /* Name of the table into which we are inserting */ char *zTab; /* Name of the table into which we are inserting */
const char *zDb; /* Name of the database holding this table */
int i, j, idx; /* Loop counters */ int i, j, idx; /* Loop counters */
Vdbe *v; /* Generate code into this virtual machine */ Vdbe *v; /* Generate code into this virtual machine */
Index *pIdx; /* For looping over indices of the table */ Index *pIdx; /* For looping over indices of the table */
@ -500,7 +499,6 @@ void sqlite3Insert(
int addrCont = 0; /* Top of insert loop. Label "C" in templates 3 and 4 */ int addrCont = 0; /* Top of insert loop. Label "C" in templates 3 and 4 */
SelectDest dest; /* Destination for SELECT on rhs of INSERT */ SelectDest dest; /* Destination for SELECT on rhs of INSERT */
int iDb; /* Index of database holding TABLE */ int iDb; /* Index of database holding TABLE */
Db *pDb; /* The database containing table being inserted into */
u8 useTempTable = 0; /* Store SELECT results in intermediate table */ u8 useTempTable = 0; /* Store SELECT results in intermediate table */
u8 appendFlag = 0; /* True if the insert is likely to be an append */ u8 appendFlag = 0; /* True if the insert is likely to be an append */
u8 withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */ u8 withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */
@ -550,9 +548,8 @@ void sqlite3Insert(
} }
iDb = sqlite3SchemaToIndex(db, pTab->pSchema); iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
assert( iDb<db->nDb ); assert( iDb<db->nDb );
pDb = &db->aDb[iDb]; if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0,
zDb = pDb->zDbSName; db->aDb[iDb].zDbSName) ){
if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, zDb) ){
goto insert_cleanup; goto insert_cleanup;
} }
withoutRowid = !HasRowid(pTab); withoutRowid = !HasRowid(pTab);

View File

@ -646,7 +646,6 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
int no_such_func = 0; /* True if no such function exists */ int no_such_func = 0; /* True if no such function exists */
int wrong_num_args = 0; /* True if wrong number of arguments */ int wrong_num_args = 0; /* True if wrong number of arguments */
int is_agg = 0; /* True if is an aggregate function */ int is_agg = 0; /* True if is an aggregate function */
int auth; /* Authorization to use the function */
int nId; /* Number of characters in function name */ int nId; /* Number of characters in function name */
const char *zId; /* The function name. */ const char *zId; /* The function name. */
FuncDef *pDef; /* Information about the function */ FuncDef *pDef; /* Information about the function */
@ -690,15 +689,17 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
} }
} }
#ifndef SQLITE_OMIT_AUTHORIZATION #ifndef SQLITE_OMIT_AUTHORIZATION
auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0); {
if( auth!=SQLITE_OK ){ int auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0,pDef->zName,0);
if( auth==SQLITE_DENY ){ if( auth!=SQLITE_OK ){
sqlite3ErrorMsg(pParse, "not authorized to use function: %s", if( auth==SQLITE_DENY ){
pDef->zName); sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
pNC->nErr++; pDef->zName);
pNC->nErr++;
}
pExpr->op = TK_NULL;
return WRC_Prune;
} }
pExpr->op = TK_NULL;
return WRC_Prune;
} }
#endif #endif
if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){ if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){

View File

@ -896,6 +896,7 @@ static void interrupt_handler(int NotUsed){
} }
#endif #endif
#ifndef SQLITE_OMIT_AUTHORIZATION
/* /*
** When the ".auth ON" is set, the following authorizer callback is ** When the ".auth ON" is set, the following authorizer callback is
** invoked. It always returns SQLITE_OK. ** invoked. It always returns SQLITE_OK.
@ -940,6 +941,7 @@ static int shellAuth(
raw_printf(p->out, "\n"); raw_printf(p->out, "\n");
return SQLITE_OK; return SQLITE_OK;
} }
#endif
/* /*
@ -2133,7 +2135,9 @@ static int run_schema_dump_query(
** Text of a help message ** Text of a help message
*/ */
static char zHelp[] = static char zHelp[] =
#ifndef SQLITE_OMIT_AUTHORIZATION
".auth ON|OFF Show authorizer callbacks\n" ".auth ON|OFF Show authorizer callbacks\n"
#endif
".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n"
".bail on|off Stop after hitting an error. Default OFF\n" ".bail on|off Stop after hitting an error. Default OFF\n"
".binary on|off Turn binary output on or off. Default OFF\n" ".binary on|off Turn binary output on or off. Default OFF\n"
@ -3250,6 +3254,7 @@ static int do_meta_command(char *zLine, ShellState *p){
n = strlen30(azArg[0]); n = strlen30(azArg[0]);
c = azArg[0][0]; c = azArg[0][0];
#ifndef SQLITE_OMIT_AUTHORIZATION
if( c=='a' && strncmp(azArg[0], "auth", n)==0 ){ if( c=='a' && strncmp(azArg[0], "auth", n)==0 ){
if( nArg!=2 ){ if( nArg!=2 ){
raw_printf(stderr, "Usage: .auth ON|OFF\n"); raw_printf(stderr, "Usage: .auth ON|OFF\n");
@ -3263,6 +3268,7 @@ static int do_meta_command(char *zLine, ShellState *p){
sqlite3_set_authorizer(p->db, 0, 0); sqlite3_set_authorizer(p->db, 0, 0);
} }
}else }else
#endif
if( (c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0) if( (c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0)
|| (c=='s' && n>=3 && strncmp(azArg[0], "save", n)==0) || (c=='s' && n>=3 && strncmp(azArg[0], "save", n)==0)

View File

@ -96,7 +96,6 @@ void sqlite3BeginTrigger(
int iDb; /* The database to store the trigger in */ int iDb; /* The database to store the trigger in */
Token *pName; /* The unqualified db name */ Token *pName; /* The unqualified db name */
DbFixer sFix; /* State vector for the DB fixer */ DbFixer sFix; /* State vector for the DB fixer */
int iTabDb; /* Index of the database holding pTab */
assert( pName1!=0 ); /* pName1->z might be NULL, but not pName1 itself */ assert( pName1!=0 ); /* pName1->z might be NULL, but not pName1 itself */
assert( pName2!=0 ); assert( pName2!=0 );
@ -209,10 +208,10 @@ void sqlite3BeginTrigger(
" trigger on table: %S", pTableName, 0); " trigger on table: %S", pTableName, 0);
goto trigger_cleanup; goto trigger_cleanup;
} }
iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);
#ifndef SQLITE_OMIT_AUTHORIZATION #ifndef SQLITE_OMIT_AUTHORIZATION
{ {
int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);
int code = SQLITE_CREATE_TRIGGER; int code = SQLITE_CREATE_TRIGGER;
const char *zDb = db->aDb[iTabDb].zDbSName; const char *zDb = db->aDb[iTabDb].zDbSName;
const char *zDbTrig = isTemp ? db->aDb[1].zDbSName : zDb; const char *zDbTrig = isTemp ? db->aDb[1].zDbSName : zDb;