aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2015-10-30 16:50:00 +0000
committerdrh <drh@noemail.net>2015-10-30 16:50:00 +0000
commitd286b9fb7d38fc3b48e89e50bc379e9cb2c1d260 (patch)
tree0a0c50d4383a6c85f3426a60ec1899c6b984893f /src/main.c
parent5db990147917f9dc8b13f2d2f6240d28c8df9212 (diff)
parentb457764d01a88021b70e9e13ec1e7f70ea8cb175 (diff)
downloadsqlite-d286b9fb7d38fc3b48e89e50bc379e9cb2c1d260.tar.gz
sqlite-d286b9fb7d38fc3b48e89e50bc379e9cb2c1d260.zip
Merge all the latest enhancements from trunk.
FossilOrigin-Name: 395a153ff7b3c7a72f3d02b6fe76d72383f4e480
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index f41ea3b65..9d0b47874 100644
--- a/src/main.c
+++ b/src/main.c
@@ -741,6 +741,36 @@ int sqlite3_db_release_memory(sqlite3 *db){
}
/*
+** Flush any dirty pages in the pager-cache for any attached database
+** to disk.
+*/
+int sqlite3_db_cacheflush(sqlite3 *db){
+ int i;
+ int rc = SQLITE_OK;
+ int bSeenBusy = 0;
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
+#endif
+ sqlite3_mutex_enter(db->mutex);
+ sqlite3BtreeEnterAll(db);
+ for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
+ Btree *pBt = db->aDb[i].pBt;
+ if( pBt && sqlite3BtreeIsInTrans(pBt) ){
+ Pager *pPager = sqlite3BtreePager(pBt);
+ rc = sqlite3PagerFlush(pPager);
+ if( rc==SQLITE_BUSY ){
+ bSeenBusy = 1;
+ rc = SQLITE_OK;
+ }
+ }
+ }
+ sqlite3BtreeLeaveAll(db);
+ sqlite3_mutex_leave(db->mutex);
+ return ((rc==SQLITE_OK && bSeenBusy) ? SQLITE_BUSY : rc);
+}
+
+/*
** Configuration settings for an individual database connection
*/
int sqlite3_db_config(sqlite3 *db, int op, ...){
@@ -2976,6 +3006,21 @@ opendb_out:
sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0);
}
#endif
+#if defined(SQLITE_HAS_CODEC)
+ if( rc==SQLITE_OK ){
+ const char *zHexKey = sqlite3_uri_parameter(zOpen, "hexkey");
+ if( zHexKey && zHexKey[0] ){
+ u8 iByte;
+ int i;
+ char zKey[40];
+ for(i=0, iByte=0; i<sizeof(zKey)*2 && sqlite3Isxdigit(zHexKey[i]); i++){
+ iByte = (iByte<<4) + sqlite3HexToInt(zHexKey[i]);
+ if( (i&1)!=0 ) zKey[i/2] = iByte;
+ }
+ sqlite3_key_v2(db, 0, zKey, i/2);
+ }
+ }
+#endif
return rc & 0xff;
}