From: drh Date: Wed, 16 Apr 2008 00:28:13 +0000 (+0000) Subject: Back out the zero-terminator optimization introduced in check-in (4915). X-Git-Tag: version-3.6.10~1162 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b08c2a72ea08ee59190c871da81ac69dabe3a2ce;p=thirdparty%2Fsqlite.git Back out the zero-terminator optimization introduced in check-in (4915). Ticket #3056. (CVS 5015) FossilOrigin-Name: cce8deae2d556916e2817e0cb9748dceb162085d --- diff --git a/manifest b/manifest index 5b8822c9a1..aa989d026a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Support\sUTF-8\sfilenames\son\sOS/2\sby\sconverting\sthem\sto\sand\sfrom\sthe\slocal\scodepage.\sTicket\s3052.\s(CVS\s5014) -D 2008-04-15T18:50:02 +C Back\sout\sthe\szero-terminator\soptimization\sintroduced\sin\scheck-in\s(4915).\nTicket\s#3056.\s(CVS\s5015) +D 2008-04-16T00:28:14 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in 25b3282a4ac39388632c2fb0e044ff494d490952 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -138,12 +138,12 @@ F src/random.c 2b2db2de4ab491f5a14d3480466f8f4b5a5db74a F src/select.c 5b8824a326a923876827fa8771c5e4e9e3a7faa1 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96 F src/shell.c be22ec05c8c4a43a95a6ad3b8068542200451e07 -F src/sqlite.h.in 824f823b341e9c979f82edebf710c87b74d1b7f5 +F src/sqlite.h.in bbb063e9055d1833a3fe3926ffc2ef555cfd1da1 F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3 F src/sqliteInt.h 625375d9327f0d79bf6f0f7864cc4a0543aec440 F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8 F src/table.c 2c48c575dd59b3a6c5c306bc55f51a9402cf429a -F src/tclsqlite.c c4892f48927cb3db19faeb448ea8abddfd4846a8 +F src/tclsqlite.c 2877726bf32f7d72ff057b37ed6c93485b667ea1 F src/test1.c 8d633bcf3cd3b805c3393d58b5c1011d49b9b550 F src/test2.c f0808cc643528b9620e4059ca9bda8346f526121 F src/test3.c c715b5a8a6415d7b2c67f97c394eef488b6f7e63 @@ -182,7 +182,7 @@ F src/vdbeapi.c 0e1b5a808bb0e556f2a975eb7d11fd3153e922bf F src/vdbeaux.c f7460fac0c61d90edb245c66b7ac35254868c8e5 F src/vdbeblob.c cc713c142c3d4952b380c98ee035f850830ddbdb F src/vdbefifo.c a30c237b2a3577e1415fb6e288cbb6b8ed1e5736 -F src/vdbemem.c 095e18f84b3171a5f2d71fa93a4bfc64220c1cfe +F src/vdbemem.c 237e61216381998ff71c6431e5e7bd03386f6225 F src/vtab.c f5e78bf73df3b0c1b53861109c1b2e0800b108cc F src/where.c a686f1e04f1ce5515a801fb3f3a358ef2cbb6ed2 F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617 @@ -630,7 +630,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P a12fa0252c1bc45a116d0123758ef639cc8e451b -R d8de72a548d7f4403c57ee71816098c3 -U pweilbacher -Z ca8f83b6ee28230fbc93d88b258246a7 +P cafa8ac2687890355a7faa751d71859eb0fadd01 +R 10d0ed716771909e41eeeb97e122c258 +U drh +Z bf5879aa4a093fef323324323481ba2a diff --git a/manifest.uuid b/manifest.uuid index 9f8444a80b..189cab89d7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cafa8ac2687890355a7faa751d71859eb0fadd01 \ No newline at end of file +cce8deae2d556916e2817e0cb9748dceb162085d \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index d66ff2c7e2..ca32a0652a 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -30,7 +30,7 @@ ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** -** @(#) $Id: sqlite.h.in,v 1.304 2008/04/10 17:14:07 drh Exp $ +** @(#) $Id: sqlite.h.in,v 1.305 2008/04/16 00:28:14 drh Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ @@ -2295,7 +2295,7 @@ int sqlite3_limit(sqlite3*, int id, int newVal); ** If nByte is non-negative, then it is the maximum number of ** bytes read from zSql. When nByte is non-negative, the ** zSql string ends at either the first '\000' or '\u0000' character or -** until the nByte-th byte, whichever comes first. If the caller knows +** the nByte-th byte, whichever comes first. If the caller knows ** that the supplied string is nul-terminated, then there is a small ** performance advantage to be had by passing an nByte parameter that ** is equal to the number of bytes in the input string including @@ -2365,7 +2365,7 @@ int sqlite3_limit(sqlite3*, int id, int newVal); ** read from zSql is read up to the first zero terminator. ** ** {F13014} If the nByte argument to [sqlite3_prepare_v2(db,zSql,nByte,...)] -** and its variants is non-negative, then nBytes bytes +** and its variants is non-negative, then at most nBytes bytes ** SQL text is read from zSql. ** ** {F13015} In [sqlite3_prepare_v2(db,zSql,N,P,pzTail)] and its variants @@ -2528,8 +2528,7 @@ typedef struct sqlite3_context sqlite3_context; ** In those ** routines that have a fourth argument, its value is the number of bytes ** in the parameter. To be clear: the value is the number of bytes -** in the value, not the number of characters. The number -** of bytes does not include the zero-terminator at the end of strings. +** in the value, not the number of characters. ** If the fourth parameter is negative, the length of the string is ** number of bytes up to the first zero terminator. ** @@ -4052,23 +4051,23 @@ typedef void (*sqlite3_destructor_type)(void*); ** ** {F16436} The [sqlite3_result_text(C,V,N,D)] interface changes the ** return value of function C to be the UTF8 string -** V up through the first zero or until N bytes are read if N -** is positive. +** V up the first zero if N is negative +** or the first N bytes of V if N is non-negative. ** ** {F16439} The [sqlite3_result_text16(C,V,N,D)] interface changes the ** return value of function C to be the UTF16 native byte order -** string V up through the first zero or until N bytes are read if N -** is positive. +** string V up to the first zero if N is +** negative or the first N bytes of V if N is non-negative. ** ** {F16442} The [sqlite3_result_text16be(C,V,N,D)] interface changes the ** return value of function C to be the UTF16 big-endian -** string V up through the first zero or until N bytes are read if N -** is positive. +** string V up to the first zero if N is +** is negative or the first N bytes or V if N is non-negative. ** ** {F16445} The [sqlite3_result_text16le(C,V,N,D)] interface changes the ** return value of function C to be the UTF16 little-endian -** string V up through the first zero or until N bytes are read if N -** is positive. +** string V up to the first zero if N is +** negative or the first N bytes of V if N is non-negative. ** ** {F16448} The [sqlite3_result_value(C,V)] interface changes the ** return value of function C to be [unprotected sqlite3_value] diff --git a/src/tclsqlite.c b/src/tclsqlite.c index d9a3fa44c5..4818d898f2 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -12,7 +12,7 @@ ** A TCL Interface to SQLite. Append this file to sqlite3.c and ** compile the whole thing to build a TCL-enabled version of SQLite. ** -** $Id: tclsqlite.c,v 1.215 2008/04/10 14:51:01 danielk1977 Exp $ +** $Id: tclsqlite.c,v 1.216 2008/04/16 00:28:14 drh Exp $ */ #include "tcl.h" #include @@ -1670,7 +1670,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ sqlite3_bind_int64(pStmt, i, v); }else{ data = (unsigned char *)Tcl_GetStringFromObj(pVar, &n); - sqlite3_bind_text(pStmt, i, (char *)data, n+1, SQLITE_STATIC); + sqlite3_bind_text(pStmt, i, (char *)data, n, SQLITE_STATIC); Tcl_IncrRefCount(pVar); apParm[nParm++] = pVar; } diff --git a/src/vdbemem.c b/src/vdbemem.c index c28c6778b8..43ba67db07 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -97,7 +97,7 @@ int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve){ if( preserve && pMem->z && pMem->zMalloc && pMem->z!=pMem->zMalloc ){ memcpy(pMem->zMalloc, pMem->z, pMem->n); } - if( pMem->xDel && pMem->flags&MEM_Dyn){ + if( pMem->flags&MEM_Dyn && pMem->xDel ){ pMem->xDel((void *)(pMem->z)); } @@ -252,7 +252,7 @@ int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){ ctx.pFunc = pFunc; ctx.isError = 0; pFunc->xFinalize(&ctx); - assert( !pMem->xDel || 0==(pMem->flags&MEM_Dyn) ); + assert( 0==(pMem->flags&MEM_Dyn) && !pMem->xDel ); sqlite3_free(pMem->zMalloc); *pMem = ctx.s; rc = (ctx.isError?SQLITE_ERROR:SQLITE_OK); @@ -271,7 +271,7 @@ void sqlite3VdbeMemReleaseExternal(Mem *p){ sqlite3VdbeMemFinalize(p, p->u.pDef); assert( (p->flags & MEM_Agg)==0 ); sqlite3VdbeMemRelease(p); - }else if( p->xDel && p->flags&MEM_Dyn ){ + }else if( p->flags&MEM_Dyn && p->xDel ){ p->xDel((void *)p->z); p->xDel = 0; } @@ -523,7 +523,7 @@ void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){ sqlite3VdbeMemReleaseExternal(pTo); memcpy(pTo, pFrom, MEMCELLSIZE); pTo->xDel = 0; - if( pFrom->xDel || pFrom->z==pFrom->zMalloc ){ + if( (pFrom->flags&MEM_Dyn)!=0 || pFrom->z==pFrom->zMalloc ){ pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem); assert( srcType==MEM_Ephem || srcType==MEM_Static ); pTo->flags |= srcType; @@ -605,14 +605,6 @@ int sqlite3VdbeMemSetStr( for(nByte=0; z[nByte] | z[nByte+1]; nByte+=2){} } flags |= MEM_Term; - }else if( enc==SQLITE_UTF8 && nByte>0 && z[nByte-1]=='\0' ){ - nByte--; - flags |= MEM_Term; -#ifndef SQLITE_OMIT_UTF16 - }else if( enc && nByte>1 && z[nByte-1]=='\0' && z[nByte-2]=='\0' ){ - nByte -= 2; - flags |= MEM_Term; -#endif } /* The following block sets the new values of Mem.z and Mem.xDel. It