Back out the zero-terminator optimization introduced in check-in (4915).
Ticket #3056. (CVS 5015) FossilOrigin-Name: cce8deae2d556916e2817e0cb9748dceb162085d
This commit is contained in:
+12
-13
@@ -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 <i>including</i>
|
||||
@@ -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 <u>bytes</u>
|
||||
** 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]
|
||||
|
||||
+2
-2
@@ -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 <errno.h>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+4
-12
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user