]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Changes in support of using a codec. (CVS 1844)
authordrh <drh@noemail.net>
Thu, 22 Jul 2004 02:40:37 +0000 (02:40 +0000)
committerdrh <drh@noemail.net>
Thu, 22 Jul 2004 02:40:37 +0000 (02:40 +0000)
FossilOrigin-Name: b77bec35742f07d79da3e85baee09a90c1494415

manifest
manifest.uuid
src/attach.c
src/btree.c
src/btree.h
src/shell.c
src/sqlite.h.in
src/tclsqlite.c

index 2d3a0bffd160b29022e88d84cd0247dd90c8da3e..24eb569b0071d416495d433f2b4887d4c9cfeea3 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Initial\simplementation\sof\svariable\spage\ssizes\sand\sthe\stemp_store\spragma.\s(CVS\s1843)
-D 2004-07-22T01:19:35
+C Changes\sin\ssupport\sof\susing\sa\scodec.\s(CVS\s1844)
+D 2004-07-22T02:40:38
 F Makefile.in 4a5e570a9e2d35b09c31b3cf01b78cea764ade4b
 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -25,10 +25,10 @@ F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
 F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
 F sqlite3.def 7610bb4092dcfa7db8fe6d9a92d3e51adce23566
 F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
-F src/attach.c 9e3fcd504aa5760b3d95f4a0bceca075ca1c96a7
+F src/attach.c 2e5d8eae9c08d15ee92ec0d831faeeda996d1a95
 F src/auth.c 60db23b98bb94c8b0178180faaf49dc116674217
-F src/btree.c 385dceb1ac0eb8bac6e60ad371c8c8ba809438d8
-F src/btree.h 02fd2c26b739f38e43493f52f381d9e7d688bb8e
+F src/btree.c 9f1727185200c5b9488f3e99a1bdb250f841c876
+F src/btree.h fab5e800b5d91a5700c0b344d711b98de6f7ad0e
 F src/build.c 3a1356286569266873d5d1c910e7797a3bfd5761
 F src/date.c e1bb384a7856c18dce9cadb0afbe6934ba5ddb00
 F src/delete.c e81545e546f6bc87d7508a93a09ca70695265af3
@@ -58,11 +58,11 @@ F src/pragma.c c8be18093f0492f9983406647808781ca0073d8b
 F src/printf.c 36090f6d7b4946539de97c1850675ce55ef66c16
 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
 F src/select.c aefda626660086addca4ce85c34aeef5d0f44c25
-F src/shell.c ebec5da57ea401f4886eefc790917b939d94d595
-F src/sqlite.h.in f43cde2bf8a92c09653358f30b2312424464ed37
+F src/shell.c 93c96c847228c02fb84bb381875d87ee71fbbeb4
+F src/sqlite.h.in 80de11cde2c9f78eff4dab0aad1eb5196d6e2a3f
 F src/sqliteInt.h 17ed61c040c1e47e1dd660daef3adda9ea9cb4fb
 F src/table.c 4521c278892f60e4d630788c0ea5cf4db1e75c49
-F src/tclsqlite.c 62848128011e59291902c6e5c6f910c05956fcbb
+F src/tclsqlite.c 8652b55cac11dc1025cd4a336180330ebade3cd7
 F src/test1.c 004885b49a7b5a594192f137c671135920f64c94
 F src/test2.c f4c2f3928f1998fd8cb75a81e33a60e025ea85d4
 F src/test3.c 8576bb977937265e2c1a4d3fab3793e1974153e8
@@ -237,7 +237,7 @@ F www/tclsqlite.tcl 06a86cba4d7fc88e2bcd633b57702d3d16abebb5
 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 166eb60614d958674469d6661c694aa5955ada7b
-R 870b048870db5bdcb9c6b07388f49a9f
+P 4cf6e9db757931aba2f300b7869305434d6f2d2b
+R 3e3f31107533fb8a64f00d1c99d78fca
 U drh
-Z f55d5698fe1367622b023c25ee34d112
+Z 4e21b294cde7a5a6cba9c0f4a48f1a9a
index 280984cb7afe5265ec07cbe708df19040108ed69..2a777fabef98c23042090d2659e766feed658b1b 100644 (file)
@@ -1 +1 @@
-4cf6e9db757931aba2f300b7869305434d6f2d2b
\ No newline at end of file
+b77bec35742f07d79da3e85baee09a90c1494415
\ No newline at end of file
index 1679abf598f915b6e5f11c8df5e27b8b37a11979..cd36936daffe5ec43e40c9eb72db0b45f24ce0c9 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** This file contains code used to implement the ATTACH and DETACH commands.
 **
-** $Id: attach.c,v 1.23 2004/07/22 01:19:35 drh Exp $
+** $Id: attach.c,v 1.24 2004/07/22 02:40:38 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -96,7 +96,6 @@ void sqlite3Attach(Parse *pParse, Token *pFilename, Token *pDbname, Token *pKey)
     extern int sqlite3CodecAttach(sqlite*, int, void*, int);
     char *zKey = 0;
     int nKey;
-    sqlite3BtreeSetPageSize(aNew->pBt, -1, 4);
     sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
     zKey = sqlite3NameFromToken(pKey);
     nKey = strlen(zKey);
index fcee691769416f44af920be27ef6e93cfa2b81a7..5790ddf78712172d8d61873801b88e365457dc45 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.178 2004/07/22 01:19:35 drh Exp $
+** $Id: btree.c,v 1.179 2004/07/22 02:40:38 drh Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** For a detailed discussion of BTrees, refer to
@@ -1124,6 +1124,9 @@ int sqlite3BtreeSetPageSize(Btree *pBt, int pageSize, int nReserve){
 int sqlite3BtreeGetPageSize(Btree *pBt){
   return pBt->pageSize;
 }
+int sqlite3BtreeGetReserve(Btree *pBt){
+  return pBt->pageSize - pBt->usableSize;
+}
 
 /*
 ** Get a reference to pPage1 of the database file.  This will
index 19261b232014cb5e82a31fa06a2e2ab63b579a08..6b08c953cd6e01cdbd4bd4da5d858ad8e7ba5e21 100644 (file)
@@ -13,7 +13,7 @@
 ** subsystem.  See comments in the source code for a detailed description
 ** of what each interface routine does.
 **
-** @(#) $Id: btree.h,v 1.56 2004/07/22 01:19:35 drh Exp $
+** @(#) $Id: btree.h,v 1.57 2004/07/22 02:40:38 drh Exp $
 */
 #ifndef _BTREE_H_
 #define _BTREE_H_
@@ -48,6 +48,7 @@ int sqlite3BtreeSetCacheSize(Btree*,int);
 int sqlite3BtreeSetSafetyLevel(Btree*,int);
 int sqlite3BtreeSetPageSize(Btree*,int,int);
 int sqlite3BtreeGetPageSize(Btree*);
+int sqlite3BtreeGetReserve(Btree*);
 int sqlite3BtreeBeginTrans(Btree*,int);
 int sqlite3BtreeCommit(Btree*);
 int sqlite3BtreeRollback(Btree*);
index 953a994ba1a6be793de5a027528778bee294e93f..164cb365018e82a838fcfb3dba74bdd974244d1c 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains code to implement the "sqlite" command line
 ** utility for accessing SQLite databases.
 **
-** $Id: shell.c,v 1.106 2004/06/30 08:20:16 danielk1977 Exp $
+** $Id: shell.c,v 1.107 2004/07/22 02:40:38 drh Exp $
 */
 #include <stdlib.h>
 #include <string.h>
@@ -633,13 +633,10 @@ static void process_input(struct callback_data *p, FILE *in);
 */
 static void open_db(struct callback_data *p){
   if( p->db==0 ){
-#ifdef SQLITE_HAS_CODEC
-    int n = p->zKey ? strlen(p->zKey) : 0;
-    db = p->db = sqlite3_open_encrypted(p->zDbFilename, p->zKey, n, 0, &zErrMsg);
-    assert(0); /* Encrypted databases are broken in SQLite 3 */
-#else
     sqlite3_open(p->zDbFilename, &p->db);
     db = p->db;
+#ifdef SQLITE_HAS_CODEC
+    sqlite3_key(p->db, p->zKey, p->zKey ? strlen(p->zKey) : 0);
 #endif
     sqlite3_create_function(db, "shellstatic", 0, SQLITE_UTF8, 0,
         shellstaticFunc, 0, 0);
@@ -925,7 +922,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
     }else{
       sqlite3_free(p->zKey);
       p->zKey = sqlite3_mprintf("%s", azArg[2]);
-      sqlite_rekey(p->db, p->zKey, strlen(p->zKey));
+      sqlite3_rekey(p->db, p->zKey, strlen(p->zKey));
     }
   }else
 #endif
index 20c8289041c08e56a39a549df1346c232dcc5512..632b5b7b20bdfb5c6968a7e1c178852112fd8cd2 100644 (file)
@@ -12,7 +12,7 @@
 ** This header file defines the interface that the SQLite library
 ** presents to client programs.
 **
-** @(#) $Id: sqlite.h.in,v 1.109 2004/07/21 15:21:36 drh Exp $
+** @(#) $Id: sqlite.h.in,v 1.110 2004/07/22 02:40:38 drh Exp $
 */
 #ifndef _SQLITE_H_
 #define _SQLITE_H_
@@ -1085,6 +1085,30 @@ int sqlite3_collation_needed16(
   void(*)(void*,sqlite3*,int eTextRep,const void*)
 );
 
+/*
+** Specify the key for an encrypted database.  This routine should be
+** called right after sqlite3_open().
+**
+** The code to implement this API is not available in the public release
+** of SQLite.
+*/
+int sqlite3_key(
+  sqlite3 *db,                   /* Database to be rekeyed */
+  const void *pKey, int nKey     /* The key */
+);
+
+/*
+** Change the key on an open database.  If the current database is not
+** encrypted, this routine will encrypt it.  If pNew==0 or nNew==0, the
+** database is decrypted.
+**
+** The code to implement this API is not available in the public release
+** of SQLite.
+*/
+int sqlite3_rekey(
+  sqlite3 *db,                   /* Database to be rekeyed */
+  const void *pKey, int nKey     /* The new key */
+);
 
 #ifdef __cplusplus
 }  /* End of the 'extern "C"' block */
index 7e9b463a0c0220b01d6b70ac40266dc3c90be571..b2953f9c3c6c21f1f2e09239f62c44a8a00db571 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** A TCL Interface to SQLite
 **
-** $Id: tclsqlite.c,v 1.95 2004/06/30 12:42:59 danielk1977 Exp $
+** $Id: tclsqlite.c,v 1.96 2004/07/22 02:40:39 drh Exp $
 */
 #ifndef NO_TCL     /* Omit this whole file if TCL is unavailable */
 
@@ -878,7 +878,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
     }
     pKey = Tcl_GetByteArrayFromObj(objv[2], &nKey);
 #ifdef SQLITE_HAS_CODEC
-    rc = sqlite_rekey(pDb->db, pKey, nKey);
+    rc = sqlite3_rekey(pDb->db, pKey, nKey);
     if( rc ){
       Tcl_AppendResult(interp, sqlite3ErrStr(rc), 0);
       rc = TCL_ERROR;
@@ -1048,15 +1048,14 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
   }
   memset(p, 0, sizeof(*p));
   zFile = Tcl_GetStringFromObj(objv[2], 0);
-#ifdef SQLITE_HAS_CODEC
-  p->db = sqlite3_open_encrypted(zFile, pKey, nKey, 0, &zErrMsg);
-#else
   sqlite3_open(zFile, &p->db);
   if( SQLITE_OK!=sqlite3_errcode(p->db) ){
     zErrMsg = strdup(sqlite3_errmsg(p->db));
     sqlite3_close(p->db);
     p->db = 0;
   }
+#ifdef SQLITE_HAS_CODEC
+  sqlite3_key(p->db, pKey, nKey);
 #endif
   if( p->db==0 ){
     Tcl_SetResult(interp, zErrMsg, TCL_VOLATILE);