diff options
author | drh <drh@noemail.net> | 2016-09-16 11:53:10 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-09-16 11:53:10 +0000 |
commit | a0daa751f85d7150e8fe4b143253d6f771204d46 (patch) | |
tree | 709e24ab2cf7ae98e78d0a33252f5c6d4cfac1cb /src | |
parent | 760c8162fffd53f660adf4b3cdaf7aee7070d845 (diff) | |
download | sqlite-a0daa751f85d7150e8fe4b143253d6f771204d46.tar.gz sqlite-a0daa751f85d7150e8fe4b143253d6f771204d46.zip |
Fix SQLITE_OMIT_AUTHORIZATION so that it compiles cleanly.
FossilOrigin-Name: a3e3b3e1c57178ccd38fc7375ec1de8e8ae45372
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 2 | ||||
-rw-r--r-- | src/delete.c | 5 | ||||
-rw-r--r-- | src/insert.c | 7 | ||||
-rw-r--r-- | src/resolve.c | 19 | ||||
-rw-r--r-- | src/shell.c | 6 | ||||
-rw-r--r-- | src/trigger.c | 3 |
6 files changed, 23 insertions, 19 deletions
diff --git a/src/build.c b/src/build.c index ca4802cd0..3384e6db8 100644 --- a/src/build.c +++ b/src/build.c @@ -2141,7 +2141,9 @@ int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ int nErr = 0; /* Number of errors encountered */ int n; /* Temporarily holds the number of cursors assigned */ sqlite3 *db = pParse->db; /* Database connection for malloc errors */ +#ifndef SQLITE_OMIT_AUTHORIZATION sqlite3_xauth xAuth; /* Saved xAuth pointer */ +#endif assert( pTable ); diff --git a/src/delete.c b/src/delete.c index 3d9360e92..74ffd584a 100644 --- a/src/delete.c +++ b/src/delete.c @@ -212,7 +212,6 @@ void sqlite3DeleteFrom( ){ Vdbe *v; /* The virtual database engine */ Table *pTab; /* The table from which records will be deleted */ - const char *zDb; /* Name of database holding pTab */ int i; /* Loop counter */ WhereInfo *pWInfo; /* Information about the WHERE clause */ Index *pIdx; /* For looping over indices of the table */ @@ -289,8 +288,8 @@ void sqlite3DeleteFrom( } iDb = sqlite3SchemaToIndex(db, pTab->pSchema); assert( iDb<db->nDb ); - zDb = db->aDb[iDb].zDbSName; - rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb); + rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, + db->aDb[iDb].zDbSName); assert( rcauth==SQLITE_OK || rcauth==SQLITE_DENY || rcauth==SQLITE_IGNORE ); if( rcauth==SQLITE_DENY ){ goto delete_from_cleanup; diff --git a/src/insert.c b/src/insert.c index f7dec3ca2..9525d823b 100644 --- a/src/insert.c +++ b/src/insert.c @@ -485,7 +485,6 @@ void sqlite3Insert( sqlite3 *db; /* The main database structure */ Table *pTab; /* The table to insert into. aka TABLE */ 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 */ Vdbe *v; /* Generate code into this virtual machine */ 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 */ SelectDest dest; /* Destination for SELECT on rhs of INSERT */ 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 appendFlag = 0; /* True if the insert is likely to be an append */ u8 withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */ @@ -550,9 +548,8 @@ void sqlite3Insert( } iDb = sqlite3SchemaToIndex(db, pTab->pSchema); assert( iDb<db->nDb ); - pDb = &db->aDb[iDb]; - zDb = pDb->zDbSName; - if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, zDb) ){ + if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, + db->aDb[iDb].zDbSName) ){ goto insert_cleanup; } withoutRowid = !HasRowid(pTab); diff --git a/src/resolve.c b/src/resolve.c index a5cc06b91..2171533ef 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -646,7 +646,6 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ int no_such_func = 0; /* True if no such function exists */ int wrong_num_args = 0; /* True if wrong number of arguments */ 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 */ const char *zId; /* The function name. */ FuncDef *pDef; /* Information about the function */ @@ -690,15 +689,17 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ } } #ifndef SQLITE_OMIT_AUTHORIZATION - auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0); - if( auth!=SQLITE_OK ){ - if( auth==SQLITE_DENY ){ - sqlite3ErrorMsg(pParse, "not authorized to use function: %s", - pDef->zName); - pNC->nErr++; + { + int auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0,pDef->zName,0); + if( auth!=SQLITE_OK ){ + if( auth==SQLITE_DENY ){ + sqlite3ErrorMsg(pParse, "not authorized to use function: %s", + pDef->zName); + pNC->nErr++; + } + pExpr->op = TK_NULL; + return WRC_Prune; } - pExpr->op = TK_NULL; - return WRC_Prune; } #endif if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){ diff --git a/src/shell.c b/src/shell.c index e1a4089bb..9b5030bb3 100644 --- a/src/shell.c +++ b/src/shell.c @@ -896,6 +896,7 @@ static void interrupt_handler(int NotUsed){ } #endif +#ifndef SQLITE_OMIT_AUTHORIZATION /* ** When the ".auth ON" is set, the following authorizer callback is ** invoked. It always returns SQLITE_OK. @@ -940,6 +941,7 @@ static int shellAuth( raw_printf(p->out, "\n"); return SQLITE_OK; } +#endif /* @@ -2133,7 +2135,9 @@ static int run_schema_dump_query( ** Text of a help message */ static char zHelp[] = +#ifndef SQLITE_OMIT_AUTHORIZATION ".auth ON|OFF Show authorizer callbacks\n" +#endif ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" ".bail on|off Stop after hitting an error. 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]); c = azArg[0][0]; +#ifndef SQLITE_OMIT_AUTHORIZATION if( c=='a' && strncmp(azArg[0], "auth", n)==0 ){ if( nArg!=2 ){ 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); } }else +#endif if( (c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0) || (c=='s' && n>=3 && strncmp(azArg[0], "save", n)==0) diff --git a/src/trigger.c b/src/trigger.c index a1c16dd35..5c8056011 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -96,7 +96,6 @@ void sqlite3BeginTrigger( int iDb; /* The database to store the trigger in */ Token *pName; /* The unqualified db name */ 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( pName2!=0 ); @@ -209,10 +208,10 @@ void sqlite3BeginTrigger( " trigger on table: %S", pTableName, 0); goto trigger_cleanup; } - iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema); #ifndef SQLITE_OMIT_AUTHORIZATION { + int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema); int code = SQLITE_CREATE_TRIGGER; const char *zDb = db->aDb[iTabDb].zDbSName; const char *zDbTrig = isTemp ? db->aDb[1].zDbSName : zDb; |