aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2007-08-31 16:11:35 +0000
committerdrh <drh@noemail.net>2007-08-31 16:11:35 +0000
commitcc6bb3eaebcff254e9ddb4d0f204656cf78d107b (patch)
treea5f588f960c518cc14dbd2e5d55242ee2a499ed9 /src/main.c
parent3570ad93d8325611dc61a6f01d1c7ce0d7277c03 (diff)
downloadsqlite-cc6bb3eaebcff254e9ddb4d0f204656cf78d107b.tar.gz
sqlite-cc6bb3eaebcff254e9ddb4d0f204656cf78d107b.zip
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
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index eda460fd8..a6db28352 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;
+}