diff options
Diffstat (limited to 'src/auth.c')
-rw-r--r-- | src/auth.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/auth.c b/src/auth.c index 7627ee140..b24976e57 100644 --- a/src/auth.c +++ b/src/auth.c @@ -14,7 +14,7 @@ ** systems that do not need this facility may omit it by recompiling ** the library with -DSQLITE_OMIT_AUTHORIZATION=1 ** -** $Id: auth.c,v 1.22 2005/07/29 15:36:15 drh Exp $ +** $Id: auth.c,v 1.23 2006/01/05 11:34:34 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -112,10 +112,12 @@ void sqlite3AuthRead( int iSrc; /* Index in pTabList->a[] of table being read */ const char *zDBase; /* Name of database being accessed */ TriggerStack *pStack; /* The stack of current triggers */ + int iDb; /* The index of the database the expression refers to */ if( db->xAuth==0 ) return; if( pExpr->op==TK_AS ) return; assert( pExpr->op==TK_COLUMN ); + iDb = sqlite3SchemaToIndex(pParse->db, pExpr->pSchema); for(iSrc=0; pTabList && iSrc<pTabList->nSrc; iSrc++){ if( pExpr->iTable==pTabList->a[iSrc].iCursor ) break; } @@ -140,14 +142,14 @@ void sqlite3AuthRead( }else{ zCol = "ROWID"; } - assert( pExpr->iDb<db->nDb ); - zDBase = db->aDb[pExpr->iDb].zName; + assert( iDb<db->nDb ); + zDBase = db->aDb[iDb].zName; rc = db->xAuth(db->pAuthArg, SQLITE_READ, pTab->zName, zCol, zDBase, pParse->zAuthContext); if( rc==SQLITE_IGNORE ){ pExpr->op = TK_NULL; }else if( rc==SQLITE_DENY ){ - if( db->nDb>2 || pExpr->iDb!=0 ){ + if( db->nDb>2 || iDb!=0 ){ sqlite3ErrorMsg(pParse, "access to %s.%s.%s is prohibited", zDBase, pTab->zName, zCol); }else{ |