]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Defer allocating memory space to hold the array of column values and
authordrh <drh@noemail.net>
Fri, 21 Mar 2008 18:01:14 +0000 (18:01 +0000)
committerdrh <drh@noemail.net>
Fri, 21 Mar 2008 18:01:14 +0000 (18:01 +0000)
names in sqlite3_exec() until there is a need to use the array.  In
the common case where there is no callback, this avoids a malloc() call. (CVS 4905)

FossilOrigin-Name: d8686abcdf9e566571033f2f137142f742df9357

manifest
manifest.uuid
src/legacy.c

index 566f4c5571e74771f1459a2ff680c012493d975a..5cfc9dc0b18880f0945080cf1348236a0a150256 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Better\sintegrate\sthe\snew\smalloc\srelated\sinstrumentation\swith\sthe\stest\sinfrastructure.\s(CVS\s4904)
-D 2008-03-21T17:29:38
+C Defer\sallocating\smemory\sspace\sto\shold\sthe\sarray\sof\scolumn\svalues\sand\nnames\sin\ssqlite3_exec()\suntil\sthere\sis\sa\sneed\sto\suse\sthe\sarray.\s\sIn\nthe\scommon\scase\swhere\sthere\sis\sno\scallback,\sthis\savoids\sa\smalloc()\scall.\s(CVS\s4905)
+D 2008-03-21T18:01:14
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in cf434ce8ca902e69126ae0f94fc9f7dc7428a5fa
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -102,7 +102,7 @@ F src/hash.c 53655c312280211444bfe23af6490a460aec2980
 F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53
 F src/insert.c 358c80592c20a61a8d5b4a127215b5e25de652f4
 F src/journal.c 807bed7a158979ac8d63953e1774e8d85bff65e2
-F src/legacy.c cb1939fdeb91ea88fb44fbd2768a10e14bc44650
+F src/legacy.c 8267890e6a0a71f13b680794520999c642299081
 F src/loadext.c f26b22f7c84153c9d5dbd7c240848823c6e6b6dc
 F src/main.c 7d22155e35094bc5d368202c3db8a3fc429548af
 F src/malloc.c 60e392a4c12c839517f9b0db7b995f825444fb35
@@ -624,7 +624,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 13e388cecf53d680a79ef29ff4e82e59de8f1264
-R d19f383f47ede81e505eee11623adac3
-U danielk1977
-Z 449e46ae1e15059fa7102c110d9acde5
+P d2140cae39dcced63e3ad5771e52d522ce587c96
+R 438a95b31cb1994f639e5613e5c3d839
+U drh
+Z 141fc6916bd71c55ee794d15ce44ae0c
index 565676bd535a8b99b64e5ab3178ea67a45e7c1f3..49185d8717bc5c0e1460ba3f22ea97aa2901fd73 100644 (file)
@@ -1 +1 @@
-d2140cae39dcced63e3ad5771e52d522ce587c96
\ No newline at end of file
+d8686abcdf9e566571033f2f137142f742df9357
\ No newline at end of file
index c1d1accd1ba33751dd33fe11d06b4c272978c684..6e4f4e4ced3bf50e4bae718d1134b23318c9b445 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: legacy.c,v 1.23 2008/02/13 18:25:27 danielk1977 Exp $
+** $Id: legacy.c,v 1.24 2008/03/21 18:01:14 drh Exp $
 */
 
 #include "sqliteInt.h"
@@ -65,12 +65,7 @@ int sqlite3_exec(
     }
 
     nCallback = 0;
-
     nCol = sqlite3_column_count(pStmt);
-    azCols = sqlite3DbMallocZero(db, 2*nCol*sizeof(const char *) + 1);
-    if( azCols==0 ){
-      goto exec_out;
-    }
 
     while( 1 ){
       int i;
@@ -80,6 +75,12 @@ int sqlite3_exec(
       if( xCallback && (SQLITE_ROW==rc || 
           (SQLITE_DONE==rc && !nCallback && db->flags&SQLITE_NullCallback)) ){
         if( 0==nCallback ){
+          if( azCols==0 ){
+            azCols = sqlite3DbMallocZero(db, 2*nCol*sizeof(const char*) + 1);
+            if( azCols==0 ){
+              goto exec_out;
+            }
+          }
           for(i=0; i<nCol; i++){
             azCols[i] = (char *)sqlite3_column_name(pStmt, i);
             if( !azCols[i] ){