From: drh Date: Thu, 12 Jan 2006 17:20:50 +0000 (+0000) Subject: Cache the encoding value inside VdbeExec. (CVS 2927) X-Git-Tag: version-3.6.10~3240 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8079a0d3f5307e773503489f5325d7590168aada;p=thirdparty%2Fsqlite.git Cache the encoding value inside VdbeExec. (CVS 2927) FossilOrigin-Name: 6d2a816ede8d17b993a21e418cf25edd103334de --- diff --git a/manifest b/manifest index 074516701f..79c6b43cff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\sperformance\simprovements\sin\ssqlite3BtreeMoveto.\s(CVS\s2926) -D 2006-01-12T15:01:16 +C Cache\sthe\sencoding\svalue\sinside\sVdbeExec.\s(CVS\s2927) +D 2006-01-12T17:20:51 F Makefile.in ab3ffd8d469cef4477257169b82810030a6bb967 F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -70,7 +70,7 @@ F src/select.c 7b19d350cb2a18ae4a59d6b87049aa2ce9c671ae F src/server.c e425729aa7ff374637033a38ba9fd9938c432244 F src/shell.c 66b073375efbdee19045e7e0cd38b85f9aff71da F src/sqlite.h.in 492580f7e3ff71eb43193eb7bb98e2d549889ce3 -F src/sqliteInt.h 95ece9c9a85bd612c7f56a3dc779d27b867289ab +F src/sqliteInt.h e6f12c4a7393018715d4ffb71666f6799df44917 F src/table.c 486dcfce532685b53b5a2b5da8bba0ded6fb2316 F src/tclsqlite.c d650bea0248fc0a310ddc2cb94273a3a5021fddf F src/test1.c 30ed0d4d594db0bb2beb98be7024cde1fe686f14 @@ -87,7 +87,7 @@ F src/update.c 261d75c702c2852d1a64274d7c414485e6f2d177 F src/utf.c b7bffac4260177ae7f83c01d025fe0f5ed70ce71 F src/util.c 1d751152ab36d2756deec68e576366f58b73968f F src/vacuum.c cd56995ecea281b3ac306ef88128ebc8a2117f84 -F src/vdbe.c 6312ac70c72b84e99d20689a1541648f929ea6a9 +F src/vdbe.c 59df15f96354ddd051212499e0cf4a3392c522c1 F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13 F src/vdbeInt.h 5451cf71f229e366ac543607c0a17f36e5737ea9 F src/vdbeapi.c afd3837cea0dec93dcb4724d073c84fa0da68e23 @@ -340,7 +340,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P 4e4a650484a39cac43386d8488ff42a8a0cc2820 -R 63e4ec5fcdbe24706473fb0fb3b733b3 +P 52b3be96b6e96994ec6fbcc67bf355cd05f61730 +R 8bdfbd15a8d8938ee4f80c68a38b1586 U drh -Z 40fe45935ac29375621feef17be8ca40 +Z 3f3ad41a9cf994a2b1925bbc43878693 diff --git a/manifest.uuid b/manifest.uuid index 939aadb8ac..3add36476f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -52b3be96b6e96994ec6fbcc67bf355cd05f61730 \ No newline at end of file +6d2a816ede8d17b993a21e418cf25edd103334de \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 5977c98305..7c8e4e44cc 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.465 2006/01/12 12:43:36 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.466 2006/01/12 17:20:51 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -401,9 +401,9 @@ struct Schema { Hash aFKey; /* Foreign keys indexed by to-table */ Table *pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */ u8 file_format; /* Schema format version for this file */ + u8 enc; /* Text encoding used by this database */ u16 flags; /* Flags associated with this schema */ int cache_size; /* Number of pages to use in the cache */ - u8 enc; /* Text encoding used by this database */ }; /* diff --git a/src/vdbe.c b/src/vdbe.c index f3bc377bd0..9962933ba3 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.524 2006/01/12 01:25:18 drh Exp $ +** $Id: vdbe.c,v 1.525 2006/01/12 17:20:51 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -379,6 +379,7 @@ int sqlite3VdbeExec( Op *pOp; /* Current operation */ int rc = SQLITE_OK; /* Value to return */ sqlite3 *db = p->db; /* The database */ + u8 encoding = ENC(db); /* The database encoding */ Mem *pTos; /* Top entry in the operand stack */ #ifdef VDBE_PROFILE unsigned long long start; /* CPU clock count at start of opcode */ @@ -642,7 +643,7 @@ case OP_Real: { /* same as TK_FLOAT, */ pTos->enc = SQLITE_UTF8; pTos->r = sqlite3VdbeRealValue(pTos); pTos->flags |= MEM_Real; - sqlite3VdbeChangeEncoding(pTos, ENC(db)); + sqlite3VdbeChangeEncoding(pTos, encoding); break; } @@ -658,10 +659,10 @@ case OP_String8: { /* same as TK_STRING */ pOp->p1 = strlen(pOp->p3); #ifndef SQLITE_OMIT_UTF16 - if( ENC(db)!=SQLITE_UTF8 ){ + if( encoding!=SQLITE_UTF8 ){ pTos++; sqlite3VdbeMemSetStr(pTos, pOp->p3, -1, SQLITE_UTF8, SQLITE_STATIC); - if( SQLITE_OK!=sqlite3VdbeChangeEncoding(pTos, ENC(db)) ) goto no_mem; + if( SQLITE_OK!=sqlite3VdbeChangeEncoding(pTos, encoding) ) goto no_mem; if( SQLITE_OK!=sqlite3VdbeMemDynamicify(pTos) ) goto no_mem; pTos->flags &= ~(MEM_Dyn); pTos->flags |= MEM_Static; @@ -687,7 +688,7 @@ case OP_String: { pTos->flags = MEM_Str|MEM_Static|MEM_Term; pTos->z = pOp->p3; pTos->n = pOp->p1; - pTos->enc = ENC(db); + pTos->enc = encoding; break; } @@ -891,7 +892,7 @@ case OP_Callback: { /* no-push */ */ for(; pMem<=pTos; pMem++ ){ sqlite3VdbeMemNulTerminate(pMem); - storeTypeInfo(pMem, ENC(db)); + storeTypeInfo(pMem, encoding); } /* Set up the statement structure so that it will pop the current @@ -933,7 +934,7 @@ case OP_Concat: { /* same as TK_CONCAT */ nByte = -1; break; } - Stringify(pTerm, ENC(db)); + Stringify(pTerm, encoding); nByte += pTerm->n; } @@ -972,7 +973,7 @@ case OP_Concat: { /* same as TK_CONCAT */ pTos->n = j; pTos->flags = MEM_Str|MEM_Dyn|MEM_Term; pTos->xDel = 0; - pTos->enc = ENC(db); + pTos->enc = encoding; pTos->z = zNew; } break; @@ -1146,7 +1147,7 @@ case OP_Function: { pArg = &pTos[1-n]; for(i=0; ip3type==P3_FUNCDEF || pOp->p3type==P3_VDBEFUNC ); @@ -1184,7 +1185,7 @@ case OP_Function: { } /* Copy the result of the function to the top of the stack */ - sqlite3VdbeChangeEncoding(&ctx.s, ENC(db)); + sqlite3VdbeChangeEncoding(&ctx.s, encoding); pTos++; pTos->flags = 0; sqlite3VdbeMemMove(pTos, &ctx.s); @@ -1195,7 +1196,7 @@ case OP_Function: { sqlite3SetString(&p->zErrMsg, "user function error", (char*)0); }else{ sqlite3SetString(&p->zErrMsg, sqlite3_value_text(pTos), (char*)0); - sqlite3VdbeChangeEncoding(pTos, ENC(db)); + sqlite3VdbeChangeEncoding(pTos, encoding); } rc = SQLITE_ERROR; } @@ -1288,7 +1289,7 @@ case OP_AddImm: { /* no-push */ case OP_ForceInt: { /* no-push */ i64 v; assert( pTos>=p->aStack ); - applyAffinity(pTos, SQLITE_AFF_NUMERIC, ENC(db)); + applyAffinity(pTos, SQLITE_AFF_NUMERIC, encoding); if( (pTos->flags & (MEM_Int|MEM_Real))==0 ){ Release(pTos); pTos--; @@ -1323,7 +1324,7 @@ case OP_ForceInt: { /* no-push */ */ case OP_MustBeInt: { /* no-push */ assert( pTos>=p->aStack ); - applyAffinity(pTos, SQLITE_AFF_NUMERIC, ENC(db)); + applyAffinity(pTos, SQLITE_AFF_NUMERIC, encoding); if( (pTos->flags & MEM_Int)==0 ){ if( pOp->p2==0 ){ rc = SQLITE_MISMATCH; @@ -1371,7 +1372,7 @@ case OP_ToText: { /* same as TK_TO_TEXT, no-push */ if( pTos->flags & MEM_Null ) break; assert( MEM_Str==(MEM_Blob>>3) ); pTos->flags |= (pTos->flags&MEM_Blob)>>3; - applyAffinity(pTos, SQLITE_AFF_TEXT, ENC(db)); + applyAffinity(pTos, SQLITE_AFF_TEXT, encoding); assert( pTos->flags & MEM_Str ); pTos->flags &= ~(MEM_Int|MEM_Real|MEM_Blob); break; @@ -1390,7 +1391,7 @@ case OP_ToBlob: { /* same as TK_TO_BLOB, no-push */ assert( pTos>=p->aStack ); if( pTos->flags & MEM_Null ) break; if( (pTos->flags & MEM_Blob)==0 ){ - applyAffinity(pTos, SQLITE_AFF_TEXT, ENC(db)); + applyAffinity(pTos, SQLITE_AFF_TEXT, encoding); assert( pTos->flags & MEM_Str ); pTos->flags |= MEM_Blob; } @@ -1571,8 +1572,8 @@ case OP_Ge: { /* same as TK_GE, no-push */ affinity = pOp->p1 & 0xFF; if( affinity ){ - applyAffinity(pNos, affinity, ENC(db)); - applyAffinity(pTos, affinity, ENC(db)); + applyAffinity(pNos, affinity, encoding); + applyAffinity(pTos, affinity, encoding); } assert( pOp->p3type==P3_COLLSEQ || pOp->p3==0 ); @@ -2072,7 +2073,7 @@ case OP_Column: { zData = sMem.z; } sqlite3VdbeSerialGet((u8*)zData, aType[p2], pTos); - pTos->enc = ENC(db); + pTos->enc = encoding; }else{ if( pOp->p3type==P3_MEM ){ sqlite3VdbeMemShallowCopy(pTos, (Mem *)(pOp->p3), MEM_Static); @@ -2196,7 +2197,7 @@ case OP_MakeRecord: { */ for(pRec=pData0; pRec<=pTos; pRec++){ if( zAffinity ){ - applyAffinity(pRec, zAffinity[pRec-pData0], ENC(db)); + applyAffinity(pRec, zAffinity[pRec-pData0], encoding); } if( pRec->flags&MEM_Null ){ containsNull = 1; @@ -2807,7 +2808,7 @@ case OP_MoveGt: { /* no-push */ pC->rowidIsValid = res==0; }else{ assert( pTos->flags & MEM_Blob ); - /* Stringify(pTos, ENC(db)); */ + /* Stringify(pTos, encoding); */ rc = sqlite3BtreeMoveto(pC->pCursor, pTos->z, pTos->n, &res); if( rc!=SQLITE_OK ){ goto abort_due_to_error; @@ -2912,7 +2913,7 @@ case OP_Found: { /* no-push */ if( (pC = p->apCsr[i])->pCursor!=0 ){ int res, rx; assert( pC->isTable==0 ); - Stringify(pTos, ENC(db)); + Stringify(pTos, encoding); rx = sqlite3BtreeMoveto(pC->pCursor, pTos->z, pTos->n, &res); alreadyExists = rx==SQLITE_OK && res==0; pC->deferredMoveto = 0; @@ -2979,7 +2980,7 @@ case OP_IsUnique: { /* no-push */ /* Make sure K is a string and make zKey point to K */ - Stringify(pNos, ENC(db)); + Stringify(pNos, encoding); zKey = pNos->z; nKey = pNos->n; @@ -3810,7 +3811,7 @@ case OP_IdxGE: { /* no-push */ int res, rc; assert( pTos->flags & MEM_Blob ); /* Created using OP_Make*Key */ - Stringify(pTos, ENC(db)); + Stringify(pTos, encoding); assert( pC->deferredMoveto==0 ); *pC->pIncrKey = pOp->p3!=0; assert( pOp->p3==0 || pOp->opcode!=OP_IdxGT ); @@ -4139,7 +4140,7 @@ case OP_IntegrityCk: { pTos->xDel = 0; } pTos->enc = SQLITE_UTF8; - sqlite3VdbeChangeEncoding(pTos, ENC(db)); + sqlite3VdbeChangeEncoding(pTos, encoding); sqliteFree(aRoot); break; } @@ -4415,7 +4416,7 @@ case OP_AggStep: { /* no-push */ assert( apVal || n==0 ); for(i=0; ip3; assert( pOp->p1>=0 && pOp->p1nMem ); @@ -4560,7 +4561,7 @@ default: { #ifndef NDEBUG /* Sanity checking on the top element of the stack */ if( pTos>=p->aStack ){ - sqlite3VdbeMemSanity(pTos, ENC(db)); + sqlite3VdbeMemSanity(pTos, encoding); } assert( pc>=-1 && pcnOp ); #ifdef SQLITE_DEBUG