1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-10 01:02:56 +03:00

Initial implementation of the sqlite3_file_control() interface.

Compiles and passes all historical tests but the new method is itself
untested. (CVS 4353)

FossilOrigin-Name: d3ab3e3911f10b17d0859a34f4f007c790a0cd82
This commit is contained in:
drh
2007-08-31 16:11:35 +00:00
parent 3570ad93d8
commit cc6bb3eaeb
13 changed files with 124 additions and 45 deletions

View File

@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.400 2007/08/30 20:09:48 drh Exp $
** $Id: main.c,v 1.401 2007/08/31 16:11:36 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -1432,3 +1432,36 @@ int sqlite3_extended_result_codes(sqlite3 *db, int onoff){
sqlite3_mutex_leave(db->mutex);
return SQLITE_OK;
}
/*
** Invoke the xFileControl method on a particular database.
*/
int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){
int rc = SQLITE_ERROR;
int iDb;
sqlite3_mutex_enter(db->mutex);
if( zDbName==0 ){
iDb = 0;
}else{
for(iDb=0; iDb<db->nDb; iDb++){
if( strcmp(db->aDb[iDb].zName, zDbName)==0 ) break;
}
}
if( iDb<db->nDb ){
Btree *pBtree = db->aDb[iDb].pBt;
if( pBtree ){
Pager *pPager;
sqlite3BtreeEnter(pBtree);
pPager = sqlite3BtreePager(pBtree);
if( pPager ){
sqlite3_file *fd = sqlite3PagerFile(pPager);
if( fd ){
rc = sqlite3OsFileControl(fd, op, pArg);
}
}
sqlite3BtreeLeave(pBtree);
}
}
sqlite3_mutex_leave(db->mutex);
return rc;
}