]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Additional changes to reduce stack usage. The SQLITE_SMALL_STACK compile-time
authordrh <drh@noemail.net>
Wed, 3 Jun 2009 01:24:54 +0000 (01:24 +0000)
committerdrh <drh@noemail.net>
Wed, 3 Jun 2009 01:24:54 +0000 (01:24 +0000)
option is now available. (CVS 6708)

FossilOrigin-Name: baea79fd0cfeb860973846c3f2776776c87f0ae3

manifest
manifest.uuid
src/func.c
src/loadext.c
src/printf.c
src/where.c

index 86321a7ec5e228c6a112efcf951b0b3fb737bca3..aa53392a6178e2b9df64bc266a242ae1a49786e4 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Further\sreductions\sin\sthe\samount\sof\sstack\sspace\srequired.\s(CVS\s6707)
-D 2009-06-02T21:31:39
+C Additional\schanges\sto\sreduce\sstack\susage.\s\sThe\sSQLITE_SMALL_STACK\scompile-time\noption\sis\snow\savailable.\s(CVS\s6708)
+D 2009-06-03T01:24:54
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 8b8fb7823264331210cddf103831816c286ba446
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -116,7 +116,7 @@ F src/date.c ab5f7137656652a48434d64f96bdcdc823bb23b3
 F src/delete.c cb791855c7948cecc96def9d97989879ca26f257
 F src/expr.c 1d580a7b2e51092785cbbc1fb8d2ff84e93c76dc
 F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
-F src/func.c 9d7b47729c337c5e4b78d795922ed34eec4aef67
+F src/func.c 006875b8e94c5ee9a41915f197797703e3867365
 F src/global.c 448419c44ce0701104c2121b0e06919b44514c0c
 F src/hash.c ebcaa921ffd9d86f7ea5ae16a0a29d1c871130a7
 F src/hash.h 35b216c13343d0b4f87d9f21969ac55ad72174e1
@@ -124,7 +124,7 @@ F src/hwtime.h 4a1d45f4cae1f402ea19686acf24acf4f0cb53cb
 F src/insert.c 69ef88ce30d1f65315b57aba63b2d4e9bdca1090
 F src/journal.c e00df0c0da8413ab6e1bb7d7cab5665d4a9000d0
 F src/legacy.c 9a56cf126ceee332b56061bf16bd0fb4ff9e26c0
-F src/loadext.c a281f9890ce4f8f2b68967a124322c6ae98f1245
+F src/loadext.c 0e88a335665db0b2fb4cece3e49dcb65d832635a
 F src/main.c 1845bc74375dcd6c0f5f840c319c84a1f0e4f759
 F src/malloc.c 7b3b6423f5b355e5d649b91e16ef252d610bcf19
 F src/mem0.c f2f84062d1f35814d6535c9f9e33de3bfb3b132c
@@ -154,7 +154,7 @@ F src/pcache.h 9b927ccc5a538e31b4c3bc7eec4f976db42a1324
 F src/pcache1.c bed75f157283e7c666f323df0c874c6a2515f76e
 F src/pragma.c d4a6fd74fd1dba0f22c8930791f7fbbe80d2ef26
 F src/prepare.c 706efe9fb08b2f01c14c8077dce8ab8450c47cfb
-F src/printf.c 3f4dca207a88258d37af5a7a03e800a825fe6456
+F src/printf.c 508a1c59433353552b6553cba175eaa7331f8fc1
 F src/random.c 676b9d7ac820fe81e6fb2394ac8c10cff7f38628
 F src/resolve.c f86d3490cf93a12f8a451720defc622cbc79873a
 F src/rowset.c c64dafba1f9fd876836c8db8682966b9d197eb1f
@@ -212,7 +212,7 @@ F src/vdbeblob.c c25d7e7bc6d5917feeb17270bd275fa771f26e5c
 F src/vdbemem.c 05183d46094aa99b8f8350e5761b9369dbef35a8
 F src/vtab.c e2f4c92df7d06330b151448718c4724742ff444b
 F src/walker.c ec4b9742a4077ef80346e2f9aaf0f44c2d95087a
-F src/where.c 1a21128db4905a29c287086acd7962cbba1c6f7b
+F src/where.c 706e9f2fbb422f58bf6c6542b62eed2055794942
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
 F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45
@@ -732,7 +732,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P 6f2aab3f7be12710b703eda22b1d5c0e8f85f814
-R 5346d3235c7afe17cabab7c153640d73
+P 04bad9eb6dd8bf7cafc9f3918b676e95d5b1c984
+R 819b41a44ba4dfbb1c77a8f2c2ff7973
 U drh
-Z 6beea0badfe5d9c08fcc3df2f861a173
+Z 141e71b5f088c642002d589792c976a2
index ca7b8de85824ab6d8bc2fcaf909a305183f1773f..d5005de7b87d2ba34f3df3e99e76644dd27b800e 100644 (file)
@@ -1 +1 @@
-04bad9eb6dd8bf7cafc9f3918b676e95d5b1c984
\ No newline at end of file
+baea79fd0cfeb860973846c3f2776776c87f0ae3
\ No newline at end of file
index 893406cebf7e0e7225eddb46e8875f64c90d99d3..673b77e30ba6872685b08bfc025295e9c8857e5d 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.236 2009/05/28 01:00:55 drh Exp $
+** $Id: func.c,v 1.237 2009/06/03 01:24:54 drh Exp $
 */
 #include "sqliteInt.h"
 #include <stdlib.h>
@@ -247,7 +247,7 @@ static void substrFunc(
 static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
   int n = 0;
   double r;
-  char zBuf[500];  /* larger than the %f representation of the largest double */
+  char *zBuf;
   assert( argc==1 || argc==2 );
   if( argc==2 ){
     if( SQLITE_NULL==sqlite3_value_type(argv[1]) ) return;
@@ -257,9 +257,14 @@ static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
   }
   if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
   r = sqlite3_value_double(argv[0]);
-  sqlite3_snprintf(sizeof(zBuf),zBuf,"%.*f",n,r);
-  sqlite3AtoF(zBuf, &r);
-  sqlite3_result_double(context, r);
+  zBuf = sqlite3_mprintf("%.*f",n,r);
+  if( zBuf==0 ){
+    sqlite3_result_error_nomem(context);
+  }else{
+    sqlite3AtoF(zBuf, &r);
+    sqlite3_free(zBuf);
+    sqlite3_result_double(context, r);
+  }
 }
 #endif
 
index 0c1b5dd6acc614d48717e5ab64db242ef9baed92..1fa6aa39a1c1033d2f43fc9f0ec3dea7146e621f 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains code used to dynamically load extensions into
 ** the SQLite library.
 **
-** $Id: loadext.c,v 1.59 2009/05/20 02:40:46 drh Exp $
+** $Id: loadext.c,v 1.60 2009/06/03 01:24:54 drh Exp $
 */
 
 #ifndef SQLITE_CORE
@@ -354,6 +354,7 @@ static int sqlite3LoadExtension(
   int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
   char *zErrmsg = 0;
   void **aHandle;
+  const int nMsg = 300;
 
   if( pzErrMsg ) *pzErrMsg = 0;
 
@@ -377,12 +378,14 @@ static int sqlite3LoadExtension(
   handle = sqlite3OsDlOpen(pVfs, zFile);
   if( handle==0 ){
     if( pzErrMsg ){
-      char zErr[256];
-      zErr[sizeof(zErr)-1] = '\0';
-      sqlite3_snprintf(sizeof(zErr)-1, zErr, 
-          "unable to open shared library [%s]", zFile);
-      sqlite3OsDlError(pVfs, sizeof(zErr)-1, zErr);
-      *pzErrMsg = sqlite3DbStrDup(0, zErr);
+      zErrmsg = sqlite3StackAllocZero(db, nMsg);
+      if( zErrmsg ){
+        sqlite3_snprintf(nMsg, zErrmsg, 
+            "unable to open shared library [%s]", zFile);
+        sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
+        *pzErrMsg = sqlite3DbStrDup(0, zErrmsg);
+        sqlite3StackFree(db, zErrmsg);
+      }
     }
     return SQLITE_ERROR;
   }
@@ -390,12 +393,14 @@ static int sqlite3LoadExtension(
                    sqlite3OsDlSym(pVfs, handle, zProc);
   if( xInit==0 ){
     if( pzErrMsg ){
-      char zErr[256];
-      zErr[sizeof(zErr)-1] = '\0';
-      sqlite3_snprintf(sizeof(zErr)-1, zErr,
-          "no entry point [%s] in shared library [%s]", zProc,zFile);
-      sqlite3OsDlError(pVfs, sizeof(zErr)-1, zErr);
-      *pzErrMsg = sqlite3DbStrDup(0, zErr);
+      zErrmsg = sqlite3StackAllocZero(db, nMsg);
+      if( zErrmsg ){
+        sqlite3_snprintf(nMsg, zErrmsg,
+            "no entry point [%s] in shared library [%s]", zProc,zFile);
+        sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
+        *pzErrMsg = sqlite3DbStrDup(0, zErrmsg);
+        sqlite3StackFree(db, zErrmsg);
+      }
       sqlite3OsDlClose(pVfs, handle);
     }
     return SQLITE_ERROR;
index a2c79c5b581db385493097a6e5c32595849eaae0..d8d838693fcd44b6350360f4b2707019a0bbe233 100644 (file)
@@ -5,7 +5,7 @@
 ** an historical reference.  Most of the "enhancements" have been backed
 ** out so that the functionality is now the same as standard printf().
 **
-** $Id: printf.c,v 1.103 2009/05/04 20:20:16 drh Exp $
+** $Id: printf.c,v 1.104 2009/06/03 01:24:54 drh Exp $
 **
 **************************************************************************
 **
@@ -189,11 +189,14 @@ static void appendSpace(StrAccum *pAccum, int N){
 
 /*
 ** On machines with a small stack size, you can redefine the
-** SQLITE_PRINT_BUF_SIZE to be less than 350.  But beware - for
-** smaller values some %f conversions may go into an infinite loop.
+** SQLITE_PRINT_BUF_SIZE to be less than 350.
 */
 #ifndef SQLITE_PRINT_BUF_SIZE
-# define SQLITE_PRINT_BUF_SIZE 350
+# if defined(SQLITE_SMALL_STACK)
+#   define SQLITE_PRINT_BUF_SIZE 50
+# else
+#   define SQLITE_PRINT_BUF_SIZE 350
+# endif
 #endif
 #define etBUFSIZE SQLITE_PRINT_BUF_SIZE  /* Size of the output buffer */
 
index 48651ceb93cc6bb0c9a3429a57f50aedec6ca1ac..d0f0b01d6c26378e580ec511ad4b8768ac5423e2 100644 (file)
@@ -16,7 +16,7 @@
 ** so is applicable.  Because this module is responsible for selecting
 ** indices, you might also think of this module as the "query optimizer".
 **
-** $Id: where.c,v 1.399 2009/05/28 01:00:55 drh Exp $
+** $Id: where.c,v 1.400 2009/06/03 01:24:54 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -132,7 +132,11 @@ struct WhereClause {
   int nTerm;               /* Number of terms */
   int nSlot;               /* Number of entries in a[] */
   WhereTerm *a;            /* Each a[] describes a term of the WHERE cluase */
-  WhereTerm aStatic[4];    /* Initial static space for a[] */
+#if defined(SQLITE_SMALL_STACK)
+  WhereTerm aStatic[1];    /* Initial static space for a[] */
+#else
+  WhereTerm aStatic[8];    /* Initial static space for a[] */
+#endif
 };
 
 /*