]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Various fixes that allow the malloc() failure tests to pass again. (CVS 2963)
authordanielk1977 <danielk1977@noemail.net>
Tue, 17 Jan 2006 13:21:40 +0000 (13:21 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 17 Jan 2006 13:21:40 +0000 (13:21 +0000)
FossilOrigin-Name: 0505405fb9ae1068b7976718efbf2aabd07592d4

12 files changed:
manifest
manifest.uuid
src/alter.c
src/attach.c
src/date.c
src/func.c
src/main.c
src/prepare.c
src/sqliteInt.h
src/test1.c
src/vdbeapi.c
test/malloc.test

index 2fe290a82248060429a398c9d13fde38769cab57..1287d1401333ab28d6487591ec170aaa3723c911 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Test\ssuite\sfixes\sfor\sbuilds\sthat\sdefine\sOMIT\ssymbols.\s(CVS\s2962)
-D 2006-01-17T09:35:02
+C Various\sfixes\sthat\sallow\sthe\smalloc()\sfailure\stests\sto\spass\sagain.\s(CVS\s2963)
+D 2006-01-17T13:21:40
 F Makefile.in ab3ffd8d469cef4477257169b82810030a6bb967
 F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -30,25 +30,25 @@ F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
 F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
 F sqlite3.def f756049b1bf3e8442baf6862db393ca423225262
 F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
-F src/alter.c 4139c8f1d0f12b1759e767b1d09dd594e2b5ac1d
+F src/alter.c f1b66e9a6d606450d6e8fc23e2a96cd84666fdd3
 F src/analyze.c 7d2b7ab9a9c2fd6e55700f69064dfdd3e36d7a8a
-F src/attach.c d4b9d8bd71d72409720946355be41cafb6c09079
+F src/attach.c a447b4672a5125abc4ee27df10621abd84d18301
 F src/auth.c 9ae84d2d94eb96195e04515715e08e85963e96c2
 F src/btree.c fcf6aec3b6a6df8130213a45f7b543e0a025be9d
 F src/btree.h 5663c4f43e8521546ccebc8fc95acb013b8f3184
 F src/build.c 539b5c6e21aa633e480ff97706f331baef1a859a
 F src/callback.c ba3e6cc7a6beb562e7a66f92e26fabcb21aab1e2
 F src/complete.c df1681cef40dec33a286006981845f87b194e7a4
-F src/date.c 5f5850c6b5da68fdc47d124573715ba948c9d8e0
+F src/date.c 2f148728b53675266cd9e1a873fd702929d3f4ee
 F src/delete.c c7bd5708a629585e073ce34cf3b1fcb52c2fef38
 F src/experimental.c 50c1e3b34f752f4ac10c36f287db095c2b61766d
 F src/expr.c f885cfe73fb235635fba72e78bb858c64529771f
-F src/func.c be4c026c1d2401f14c3186611e1131a895a3ca6e
+F src/func.c 96b26601c092b7b43a13e440e3f988b32a385f6a
 F src/hash.c 8747cf51d12de46512880dfcf1b68b4e24072863
 F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84
 F src/insert.c a5595cf8d1d8ba087b676a63f1f7277ea44b5ac1
 F src/legacy.c 9bf7ee1b63c99aac6669533986a5240b16101458
-F src/main.c 39d073fb1f95f874ee0c98366e99005cf14742dd
+F src/main.c e934ce6ce3b7166ad98c2778160f865761196480
 F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
 F src/os.c 1d1a61cdf150e9f9520a3bc787c8465148ea2e78
 F src/os.h 9debc3d3ca4cdafde222a0ea74a4c8415aef4f22
@@ -63,17 +63,17 @@ F src/pager.c e84713f7196a81103cc8e2b55cebbaa1723c4926
 F src/pager.h e0acb095b3ad0bca48f2ab00c87346665643f64f
 F src/parse.y 83df51fea35f68f7e07384d75dce83d1ed30434c
 F src/pragma.c 4496cc77dc35824e1c978c3d1413b8a5a4c777d3
-F src/prepare.c 368f5c04755f03dc04353513e6afcebb8ca8d53f
+F src/prepare.c 84c3cbca337a49133554108d748864c5e13aef34
 F src/printf.c f47a2f4b5387cd2ebb12e9117a1a5d6bd9a2b812
 F src/random.c d40f8d356cecbd351ccfab6eaedd7ec1b54f5261
 F src/select.c 28d449c7762dd580aaba49a9c6c16e93ca951e49
 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
 F src/shell.c 66b073375efbdee19045e7e0cd38b85f9aff71da
 F src/sqlite.h.in 492580f7e3ff71eb43193eb7bb98e2d549889ce3
-F src/sqliteInt.h 730d071c5272726b5e507ef6d6dd14ccdb2744ae
+F src/sqliteInt.h 0d0c3b40827557597ba388b1ef782e28ea623d30
 F src/table.c 486dcfce532685b53b5a2b5da8bba0ded6fb2316
 F src/tclsqlite.c d650bea0248fc0a310ddc2cb94273a3a5021fddf
-F src/test1.c b138bf5943c3122093b605e2132cacb87f4ea037
+F src/test1.c 4dccd51f786f24d8f947f1028d840ab35f46d4de
 F src/test2.c ca74a1d8aeb7d9606e8f6b762c5daf85c1a3f92b
 F src/test3.c 9742aa146eb750cab81c1d5605286c3a0eb88054
 F src/test4.c 6633cb7b4a7429e938804a34f688d118c8b7f8e1
@@ -90,7 +90,7 @@ F src/vacuum.c 21a3c7f6f7be86bb1182fbc3df416ad702435b9e
 F src/vdbe.c 3db9bfc86e71dc0758524fb82cfcfd4c30e92716
 F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13
 F src/vdbeInt.h 5451cf71f229e366ac543607c0a17f36e5737ea9
-F src/vdbeapi.c cac3f5bfb8ab9864ce5cea35eaae3d0d2efdc8ac
+F src/vdbeapi.c 9cc9b7a0fc65c29c7d249c0101897ff27eedffe8
 F src/vdbeaux.c 723e0ec773aeec53e9448b2ac5b136677e64ece0
 F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
 F src/vdbemem.c dd08a0eea4868ac4a2d91fdec32424308b1db772
@@ -186,7 +186,7 @@ F test/lock.test 9b7afcb24f53d24da502abb33daaad2cd6d44107
 F test/lock2.test d83ba79d3c4fffdb5b926c7d8ca7a36c34288a55
 F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
 F test/main.test b12f01d49a5c805a33fa6c0ef168691f63056e79
-F test/malloc.test 6245418d1b6635a2095d9ed0f5e84e029990da06
+F test/malloc.test 34c2c0ce7f45bc5fe2f7f3c0b911e505af66e27f
 F test/malloc2.test e6e321db96d6c94cb18bf82ad7215070c41e624e
 F test/malloc3.test 265644c655497242f7c0a1bb5b36c8500a5fc27c
 F test/malloc4.test 2e29d155eb4b4808019ef47eeedfcbe9e09e0f05
@@ -341,7 +341,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P c058f483a52c8043178b6329aa5e58bedf0c8277
-R c86983ffa2db3b82ac2e0f38dbf58ee1
+P 3a54a33dcb7e765ee3773397407e8929a8cfe1a9
+R 675b739278e2c68c1d8f47ad7192ced7
 U danielk1977
-Z fc44b9175931850bbe296b28d7e15e37
+Z 76c8e3304de47e86266e4fd438942871
index 93038ca68a9a54fe6c5670ecb2253684ed4744ed..a90093758e6176cd01224cf2fe882dbe2ca4f5b0 100644 (file)
@@ -1 +1 @@
-3a54a33dcb7e765ee3773397407e8929a8cfe1a9
\ No newline at end of file
+0505405fb9ae1068b7976718efbf2aabd07592d4
\ No newline at end of file
index f1809f4c8f081d66609ae423922f41a7f261024d..378c1288bf94d0b33e9bc71876e78ab06e500f0f 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that used to generate VDBE code
 ** that implements the ALTER TABLE command.
 **
-** $Id: alter.c,v 1.16 2006/01/11 21:41:21 drh Exp $
+** $Id: alter.c,v 1.17 2006/01/17 13:21:40 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -162,7 +162,7 @@ void sqlite3AlterFunctions(sqlite3 *db){
   int i;
 
   for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){
-    sqlite3_create_function(db, aFuncs[i].zName, aFuncs[i].nArg,
+    sqlite3CreateFunc(db, aFuncs[i].zName, aFuncs[i].nArg,
         SQLITE_UTF8, 0, aFuncs[i].xFunc, 0, 0);
   }
 }
index 290596a95835e7b314899c8d568e9765d8e8b5c7..65628f5c80e606d4d369a03574f75944c8294816 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** This file contains code used to implement the ATTACH and DETACH commands.
 **
-** $Id: attach.c,v 1.46 2006/01/11 21:41:22 drh Exp $
+** $Id: attach.c,v 1.47 2006/01/17 13:21:40 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 
@@ -345,8 +345,8 @@ void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){
 */
 void sqlite3AttachFunctions(sqlite3 *db){
   static const int enc = SQLITE_UTF8;
-  sqlite3_create_function(db, "sqlite_attach", 3, enc, db, attachFunc, 0, 0);
-  sqlite3_create_function(db, "sqlite_detach", 1, enc, db, detachFunc, 0, 0);
+  sqlite3CreateFunc(db, "sqlite_attach", 3, enc, db, attachFunc, 0, 0);
+  sqlite3CreateFunc(db, "sqlite_detach", 1, enc, db, detachFunc, 0, 0);
 }
 
 /*
index dfb693c4c13073983e2df1bc7419d1462bd19b3f..bd62e209fb87fc2d9b1d4aa521728d367b44be01 100644 (file)
@@ -16,7 +16,7 @@
 ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
 ** All other code has file scope.
 **
-** $Id: date.c,v 1.51 2006/01/15 00:13:16 drh Exp $
+** $Id: date.c,v 1.52 2006/01/17 13:21:40 danielk1977 Exp $
 **
 ** NOTES:
 **
@@ -976,7 +976,7 @@ void sqlite3RegisterDateTimeFunctions(sqlite3 *db){
   int i;
 
   for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){
-    sqlite3_create_function(db, aFuncs[i].zName, aFuncs[i].nArg,
+    sqlite3CreateFunc(db, aFuncs[i].zName, aFuncs[i].nArg,
         SQLITE_UTF8, 0, aFuncs[i].xFunc, 0, 0);
   }
 #else
@@ -991,7 +991,7 @@ void sqlite3RegisterDateTimeFunctions(sqlite3 *db){
   int i;
 
   for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){
-    sqlite3_create_function(db, aFuncs[i].zName, 0, SQLITE_UTF8, 
+    sqlite3CreateFunc(db, aFuncs[i].zName, 0, SQLITE_UTF8, 
         aFuncs[i].zFormat, currentTimeFunc, 0, 0);
   }
 #endif
index 4198d61005f6781c2ed71d755a65f66b17c3b041..35caa6dcff5c9a65e4d1192b0ed8bba4dbf69860 100644 (file)
@@ -16,7 +16,7 @@
 ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
 ** All other code has file scope.
 **
-** $Id: func.c,v 1.116 2006/01/12 22:17:50 drh Exp $
+** $Id: func.c,v 1.117 2006/01/17 13:21:40 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -1024,7 +1024,7 @@ void sqlite3RegisterBuiltinFunctions(sqlite3 *db){
       case 1: pArg = db; break;
       case 2: pArg = (void *)(-1); break;
     }
-    sqlite3_create_function(db, aFuncs[i].zName, aFuncs[i].nArg,
+    sqlite3CreateFunc(db, aFuncs[i].zName, aFuncs[i].nArg,
         aFuncs[i].eTextRep, pArg, aFuncs[i].xFunc, 0, 0);
     if( aFuncs[i].needCollSeq ){
       FuncDef *pFunc = sqlite3FindFunction(db, aFuncs[i].zName, 
@@ -1046,7 +1046,7 @@ void sqlite3RegisterBuiltinFunctions(sqlite3 *db){
       case 1: pArg = db; break;
       case 2: pArg = (void *)(-1); break;
     }
-    sqlite3_create_function(db, aAggs[i].zName, aAggs[i].nArg, SQLITE_UTF8, 
+    sqlite3CreateFunc(db, aAggs[i].zName, aAggs[i].nArg, SQLITE_UTF8, 
         pArg, 0, aAggs[i].xStep, aAggs[i].xFinalize);
     if( aAggs[i].needCollSeq ){
       FuncDef *pFunc = sqlite3FindFunction( db, aAggs[i].zName,
@@ -1090,9 +1090,9 @@ void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive){
   }else{
     pInfo = (struct compareInfo*)&likeInfoNorm;
   }
-  sqlite3_create_function(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0);
-  sqlite3_create_function(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0);
-  sqlite3_create_function(db, "glob", 2, SQLITE_UTF8, 
+  sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0);
+  sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0);
+  sqlite3CreateFunc(db, "glob", 2, SQLITE_UTF8, 
       (struct compareInfo*)&globInfo, likeFunc, 0,0);
   setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE);
   setLikeOptFlag(db, "like", 
index 3ea1fc32c4ded891b6b2db4ad190462060504e91..6ceea4b44a536e57e49675836baf8b4b84ca2506 100644 (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.323 2006/01/11 21:41:22 drh Exp $
+** $Id: main.c,v 1.324 2006/01/17 13:21:40 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -386,9 +386,12 @@ void sqlite3_interrupt(sqlite3 *db){
 void sqlite3_free(char *p){ free(p); }
 
 /*
-** Create new user functions.
+** This function is exactly the same as sqlite3_create_function(), except
+** that it is designed to be called by internal code. The difference is
+** that if a malloc() fails in sqlite3_create_function(), an error code
+** is returned and the mallocFailed flag cleared. 
 */
-int sqlite3_create_function(
+int sqlite3CreateFunc(
   sqlite3 *db,
   const char *zFunctionName,
   int nArg,
@@ -425,10 +428,10 @@ int sqlite3_create_function(
     enc = SQLITE_UTF16NATIVE;
   }else if( enc==SQLITE_ANY ){
     int rc;
-    rc = sqlite3_create_function(db, zFunctionName, nArg, SQLITE_UTF8,
+    rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8,
          pUserData, xFunc, xStep, xFinal);
     if( rc!=SQLITE_OK ) return rc;
-    rc = sqlite3_create_function(db, zFunctionName, nArg, SQLITE_UTF16LE,
+    rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE,
         pUserData, xFunc, xStep, xFinal);
     if( rc!=SQLITE_OK ) return rc;
     enc = SQLITE_UTF16BE;
@@ -447,6 +450,7 @@ int sqlite3_create_function(
     if( db->activeVdbeCnt ){
       sqlite3Error(db, SQLITE_BUSY, 
         "Unable to delete/modify user-function due to active statements");
+      assert( !sqlite3ThreadDataReadOnly()->mallocFailed );
       return SQLITE_BUSY;
     }else{
       sqlite3ExpirePreparedStatements(db);
@@ -454,38 +458,65 @@ int sqlite3_create_function(
   }
 
   p = sqlite3FindFunction(db, zFunctionName, nName, nArg, enc, 1);
-  if( p==0 ) return SQLITE_NOMEM;
-  p->flags = 0;
-  p->xFunc = xFunc;
-  p->xStep = xStep;
-  p->xFinalize = xFinal;
-  p->pUserData = pUserData;
+  if( p ){
+    p->flags = 0;
+    p->xFunc = xFunc;
+    p->xStep = xStep;
+    p->xFinalize = xFinal;
+    p->pUserData = pUserData;
+  }
   return SQLITE_OK;
 }
+
+/*
+** Create new user functions.
+*/
+int sqlite3_create_function(
+  sqlite3 *db,
+  const char *zFunctionName,
+  int nArg,
+  int enc,
+  void *p,
+  void (*xFunc)(sqlite3_context*,int,sqlite3_value **),
+  void (*xStep)(sqlite3_context*,int,sqlite3_value **),
+  void (*xFinal)(sqlite3_context*)
+){
+  int rc;
+  assert( !sqlite3ThreadDataReadOnly()->mallocFailed );
+  rc = sqlite3CreateFunc(db, zFunctionName, nArg, enc, p, xFunc, xStep, xFinal);
+
+  if( sqlite3ThreadDataReadOnly()->mallocFailed ){
+    sqlite3MallocClearFailed();
+    rc = SQLITE_NOMEM;
+    sqlite3Error(db, SQLITE_NOMEM, 0);
+  }
+  return rc;
+}
+
 #ifndef SQLITE_OMIT_UTF16
 int sqlite3_create_function16(
   sqlite3 *db,
   const void *zFunctionName,
   int nArg,
   int eTextRep,
-  void *pUserData,
+  void *p,
   void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
   void (*xStep)(sqlite3_context*,int,sqlite3_value**),
   void (*xFinal)(sqlite3_context*)
 ){
   int rc;
   char *zFunc8;
+  assert( !sqlite3ThreadDataReadOnly()->mallocFailed );
 
-  if( sqlite3SafetyCheck(db) ){
-    return SQLITE_MISUSE;
-  }
   zFunc8 = sqlite3utf16to8(zFunctionName, -1);
-  if( !zFunc8 ){
-    return SQLITE_NOMEM;
-  }
-  rc = sqlite3_create_function(db, zFunc8, nArg, eTextRep, 
-      pUserData, xFunc, xStep, xFinal);
+  rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xFunc, xStep, xFinal);
   sqliteFree(zFunc8);
+
+  if( sqlite3ThreadDataReadOnly()->mallocFailed ){
+    sqlite3MallocClearFailed();
+    rc = SQLITE_NOMEM;
+    sqlite3Error(db, SQLITE_NOMEM, 0);
+  }
   return rc;
 }
 #endif
@@ -645,7 +676,7 @@ int sqlite3BtreeFactory(
 */
 const char *sqlite3_errmsg(sqlite3 *db){
   const char *z;
-  if( sqlite3ThreadDataReadOnly()->mallocFailed ){
+  if( !db || sqlite3ThreadDataReadOnly()->mallocFailed ){
     return sqlite3ErrStr(SQLITE_NOMEM);
   }
   if( sqlite3SafetyCheck(db) || db->errCode==SQLITE_MISUSE ){
@@ -741,15 +772,6 @@ static int openDatabase(
   sqlite3HashInit(&db->aFunc, SQLITE_HASH_STRING, 0);
   sqlite3HashInit(&db->aCollSeq, SQLITE_HASH_STRING, 0);
 
-#if 0
-  for(i=0; i<db->nDb; i++){
-    sqlite3HashInit(&db->aDb[i].tblHash, SQLITE_HASH_STRING, 0);
-    sqlite3HashInit(&db->aDb[i].idxHash, SQLITE_HASH_STRING, 0);
-    sqlite3HashInit(&db->aDb[i].trigHash, SQLITE_HASH_STRING, 0);
-    sqlite3HashInit(&db->aDb[i].aFKey, SQLITE_HASH_STRING, 1);
-  }
-#endif
   /* Add the default collation sequence BINARY. BINARY works for both UTF-8
   ** and UTF-16, so add a version for each to avoid any unnecessary
   ** conversions. The only error that can occur here is a malloc() failure.
@@ -806,8 +828,10 @@ static int openDatabase(
   ** database schema yet. This is delayed until the first time the database
   ** is accessed.
   */
-  sqlite3RegisterBuiltinFunctions(db);
-  sqlite3Error(db, SQLITE_OK, 0);
+  if( !sqlite3ThreadDataReadOnly()->mallocFailed ){
+    sqlite3RegisterBuiltinFunctions(db);
+    sqlite3Error(db, SQLITE_OK, 0);
+  }
   db->magic = SQLITE_MAGIC_OPEN;
 
 opendb_out:
index f68206fda76391f4402bd91a7e13bb1b9b4e9fc7..26dc155b111772f6c5f1b41a14b0efbfee81855f 100644 (file)
@@ -13,7 +13,7 @@
 ** interface, and routines that contribute to loading the database schema
 ** from disk.
 **
-** $Id: prepare.c,v 1.23 2006/01/16 11:29:20 danielk1977 Exp $
+** $Id: prepare.c,v 1.24 2006/01/17 13:21:40 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -608,6 +608,7 @@ int sqlite3_prepare16(
   }
   zSql8 = sqlite3utf16to8(zSql, nBytes);
   if( !zSql8 ){
+    sqlite3MallocClearFailed();
     sqlite3Error(db, SQLITE_NOMEM, 0);
     return SQLITE_NOMEM;
   }
index 7d4d0a8b343f532c698ce262e97807ddce945590..a338f7e4936249a7154b7a967beada635c30fdb4 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.469 2006/01/16 15:14:28 danielk1977 Exp $
+** @(#) $Id: sqliteInt.h,v 1.470 2006/01/17 13:21:40 danielk1977 Exp $
 */
 #ifndef _SQLITEINT_H_
 #define _SQLITEINT_H_
@@ -30,7 +30,7 @@
 ** option is set.  Thus NDEBUG becomes an opt-in rather than an opt-out
 ** feature.
 */
-#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
+#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) 
 # define NDEBUG 1
 #endif
 
@@ -1746,6 +1746,9 @@ void sqlite3SchemaFree(void *);
 Schema *sqlite3SchemaGet(Btree *);
 int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
 KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);
+int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *, 
+  void (*)(sqlite3_context*,int,sqlite3_value **),
+  void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*));
 
 #ifndef SQLITE_OMIT_SHARED_CACHE
   void sqlite3TableLock(Parse *, int, int, u8, const char *);
index 684e44d25047b0831489ebef91dd75aa3d63e5cb..2d6f2727ea7e56a51e6afd36ee6483989d3f1d49 100644 (file)
@@ -13,7 +13,7 @@
 ** is not included in the SQLite library.  It is used for automated
 ** testing of the SQLite library.
 **
-** $Id: test1.c,v 1.192 2006/01/16 15:32:23 danielk1977 Exp $
+** $Id: test1.c,v 1.193 2006/01/17 13:21:40 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -534,6 +534,11 @@ static int test_create_function(
   ** because it is not tested anywhere else. */
   if( rc==SQLITE_OK ){
     sqlite3_value *pVal;
+#ifdef SQLITE_MEMDEBUG
+    if( sqlite3_iMallocFail>0 ){
+      sqlite3_iMallocFail++;
+    }
+#endif 
     pVal = sqlite3ValueNew();
     sqlite3ValueSetStr(pVal, -1, "x_sqlite_exec", SQLITE_UTF8, SQLITE_STATIC);
     rc = sqlite3_create_function16(db, 
index bad4a3600a4ff3bf61feb6cfcb594a1e72380db2..2c3f9ae207d8435209bb1709330358c1408c8615 100644 (file)
@@ -631,12 +631,11 @@ static int bindText(
   }
   pVar = &p->aVar[i-1];
   rc = sqlite3VdbeMemSetStr(pVar, zData, nData, encoding, xDel);
-  if( rc ){
-    return rc;
-  }
   if( rc==SQLITE_OK && encoding!=0 ){
     rc = sqlite3VdbeChangeEncoding(pVar, ENC(p->db));
   }
+  sqlite3MallocClearFailed();
+  sqlite3Error(((Vdbe *)pStmt)->db, rc, 0);
   return rc;
 }
 
index 1ca17850cb76173bc617d5c812614e7d931bf1a4..726bc3297bd97349ae007259ee1614d413c5d9d9 100644 (file)
@@ -14,7 +14,7 @@
 # special feature is used to see what happens in the library if a malloc
 # were to really fail due to an out-of-memory situation.
 #
-# $Id: malloc.test,v 1.26 2006/01/06 14:32:20 drh Exp $
+# $Id: malloc.test,v 1.27 2006/01/17 13:21:40 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -63,12 +63,13 @@ proc do_malloc_test {tn args} {
       # system. Then open (empty database) "test.db" with the handle [db].
       # 
       sqlite_malloc_fail 0
-      catch {db close}
+      catch {db close} 
       catch {file delete -force test.db}
       catch {file delete -force test.db-journal}
       catch {file delete -force test2.db}
       catch {file delete -force test2.db-journal}
-      set ::DB [sqlite3 db test.db]
+      catch {sqlite3 db test.db} 
+      set ::DB [sqlite3_connection_pointer db]
 
       # Execute any -tclprep and -sqlprep scripts.
       #
@@ -318,7 +319,7 @@ do_malloc_test 9 -sqlprep {
 do_malloc_test 10 -sqlprep {
   CREATE TABLE abc(a, b, c);
 } -tclbody {
-  set ::DB [sqlite3 db2 test.db]
+  sqlite3 db2 test.db
   db2 eval {SELECT * FROM sqlite_master}
   db2 close
 }