aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifest18
-rw-r--r--manifest.uuid2
-rw-r--r--src/expr.c3
-rw-r--r--src/func.c57
-rw-r--r--src/utf.c31
-rw-r--r--src/util.c4
6 files changed, 77 insertions, 38 deletions
diff --git a/manifest b/manifest
index d81ead2f6..b45e3a6b6 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Enhance\suser\sfunction\sAPI\sto\ssupport\sassociation\sof\smeta-data\swith\sconstant\narguments\sand\sthe\sspecification\sof\stext\sencoding\spreference.\sThe\sLIKE\noperator\stakes\sadvantage\sof\sboth.\s(CVS\s1534)
-D 2004-06-06T09:44:04
+C Performance\simprovements\sfor\sLIKE.\sIt\sis\sstill\stoo\sslow\sthough.\s(CVS\s1535)
+D 2004-06-06T12:41:50
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -31,8 +31,8 @@ F src/build.c e12e602f06e37a0fbcb49af17cba68ad85e101b6
F src/date.c 8e6fa3173386fb29fdef012ee08a853c1e9908b2
F src/delete.c b30f08250c9ed53a25a13c7c04599c1e8753992d
F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37
-F src/expr.c f05a5594679fe5297d41578d2e0ffff827772906
-F src/func.c e873366ba5ad97926336fd05c3af22ca54ad3e74
+F src/expr.c 2b18dd4ed178e39989f22d75bf0e68ba6ed3923c
+F src/func.c 730741443e8de788de370e2b0d641df69d174697
F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f
F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
F src/insert.c 4268d9e3959cc845ea243fb4ec7507269404dad9
@@ -67,8 +67,8 @@ F src/test5.c 44178ce85c3afd2004ab4eeb5cfd7487116ce366
F src/tokenize.c 183c5d7da11affab5d70d903d33409c8c0ce6c5b
F src/trigger.c 04b2c310d0d056b213609cab6df5fff03d5eaf88
F src/update.c 259f06e7b22c684b2d3dda54a18185892d6e9573
-F src/utf.c 0e83deb064da62c202c1765e6194e938ca16d20f
-F src/util.c 026035fcb4d34cce0b541c4b8b0b058d93cb1da6
+F src/utf.c c2c8e445bfea724f3502609d6389fe66651f02ab
+F src/util.c 8b3680271111bcdf5b395916b08b9a6684e0e73d
F src/vacuum.c b921eb778842592e1fb48a9d4cef7e861103878f
F src/vdbe.c 392c6b02c525ea12dff403ba4ceb42b0afcb42f5
F src/vdbe.h 46f74444a213129bc4b5ce40124dd8ed613b0cde
@@ -215,7 +215,7 @@ F www/support.tcl 1801397edd271cc39a2aadd54e701184b5181248
F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 9e6cd9ec75f726ef85e60f593aaa895791315071
-R f098c036151f30238f65c2c50a0dd90e
+P 92337d8f79b9754cd61c73e7db2e792a1f482f50
+R fd9052eaad985197e4f082c9d9a0d480
U danielk1977
-Z 5b48605b31bccaed46d70ecdd5c38ae2
+Z a1980072adc559c578b2d7aa47186c8d
diff --git a/manifest.uuid b/manifest.uuid
index 5ebff6bb9..1a189a258 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-92337d8f79b9754cd61c73e7db2e792a1f482f50 \ No newline at end of file
+30b81507fc404355751705c6f9856c178249eff1 \ No newline at end of file
diff --git a/src/expr.c b/src/expr.c
index dd2a8cef3..36b421f53 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
-** $Id: expr.c,v 1.135 2004/06/06 09:44:04 danielk1977 Exp $
+** $Id: expr.c,v 1.136 2004/06/06 12:41:50 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -1752,6 +1752,7 @@ FuncDef *sqlite3FindFunction(
pBest->nArg = nArg;
pBest->pNext = pFirst;
pBest->zName = (char*)&pBest[1];
+ pBest->iPrefEnc = eTextRep;
memcpy(pBest->zName, zName, nName);
pBest->zName[nName] = 0;
sqlite3HashInsert(&db->aFunc, pBest->zName, nName, (void*)pBest);
diff --git a/src/func.c b/src/func.c
index e6cd5d0f7..bf4d6d4ae 100644
--- a/src/func.c
+++ b/src/func.c
@@ -16,7 +16,7 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
-** $Id: func.c,v 1.63 2004/06/06 09:44:04 danielk1977 Exp $
+** $Id: func.c,v 1.64 2004/06/06 12:41:50 danielk1977 Exp $
*/
#include <ctype.h>
#include <math.h>
@@ -418,7 +418,11 @@ LikePattern *compileLike(sqlite3_value *pPattern, u8 enc){
if( pc_state<0 ){
aState[n].failstate = -1;
}else if( pc_state==n ){
- aState[n].failstate = pc_state;
+ if( c ){
+ aState[n].failstate = pc_state;
+ }else{
+ aState[n].failstate = -2;
+ }
}else{
int k = pLike->aState[n-1].failstate;
while( k>pc_state && aState[k+1].val!=-1 && aState[k+1].val!=c ){
@@ -461,13 +465,13 @@ static void likeFunc(
int argc,
sqlite3_value **argv
){
- int s;
- int c;
- int nc;
+ register int c;
u8 enc;
int offset = 0;
const unsigned char *zString;
LikePattern *pLike = sqlite3_get_auxdata(context, 0);
+ struct LikeState *aState;
+ register struct LikeState *pState;
/* If either argument is NULL, the result is NULL */
if( sqlite3_value_type(argv[1])==SQLITE_NULL ||
@@ -479,6 +483,7 @@ static void likeFunc(
if( sqlite3_user_data(context) ){
enc = TEXT_Utf16;
zString = (const unsigned char *)sqlite3_value_text16(argv[1]);
+ assert(0);
}else{
enc = TEXT_Utf8;
zString = sqlite3_value_text(argv[1]);
@@ -493,33 +498,39 @@ static void likeFunc(
}
sqlite3_set_auxdata(context, 0, pLike, deleteLike);
}
+ aState = pLike->aState;
+ pState = aState;
- s = 0;
- nc = 1;
do {
- int val = pLike->aState[s].val;
- if( nc ) c = sqlite3ReadUniChar(zString, &offset, &enc, 1);
+ if( enc==TEXT_Utf8 ){
+ c = zString[offset++];
+ if( c&0x80 ){
+ offset--;
+ c = sqlite3ReadUniChar(zString, &offset, &enc, 1);
+ }
+ }else{
+ c = sqlite3ReadUniChar(zString, &offset, &enc, 1);
+ }
+
+skip_read:
#if defined(TRACE_LIKE) && !defined(NDEBUG)
printf("State=%d:(%d, %d) Input=%d\n",
- s, pLike->aState[s].val,
- pLike->aState[s].failstate, c);
+ (aState - pState), pState->val, pState->failstate, c);
#endif
- if( val==-1 || val==c ){
- s++;
- nc = 1;
+ if( pState->val==-1 || pState->val==c ){
+ pState++;
}else{
- if( pLike->aState[s].failstate==s ){
- nc = 1;
- }else{
- nc = 0;
- s = pLike->aState[s].failstate;
+ struct LikeState *pFailState = &aState[pState->failstate];
+ if( pState!=pFailState ){
+ pState = pFailState;
+ if( c && pState>=aState ) goto skip_read;
}
}
- }while( c && s>=0 );
+ }while( c && pState>=aState );
- if( s==pLike->nState ){
+ if( (pState-aState)==pLike->nState || (pState-aState)<-1 ){
sqlite3_result_int(context, 1);
}else{
sqlite3_result_int(context, 0);
@@ -916,8 +927,8 @@ void sqlite3RegisterBuiltinFunctions(sqlite *db){
case 1: pArg = db; break;
case 2: pArg = (void *)(-1); break;
}
- sqlite3_create_function(db, aFuncs[i].zName, aFuncs[i].nArg, 0, 0,
- pArg, aFuncs[i].xFunc, 0, 0);
+ sqlite3_create_function(db, aFuncs[i].zName, aFuncs[i].nArg,
+ aFuncs[i].eTextRep, 0, pArg, aFuncs[i].xFunc, 0, 0);
}
for(i=0; i<sizeof(aAggs)/sizeof(aAggs[0]); i++){
void *pArg = 0;
diff --git a/src/utf.c b/src/utf.c
index 4da418b6a..9d1884ba9 100644
--- a/src/utf.c
+++ b/src/utf.c
@@ -12,7 +12,7 @@
** This file contains routines used to translate between UTF-8,
** UTF-16, UTF-16BE, and UTF-16LE.
**
-** $Id: utf.c,v 1.17 2004/06/06 09:44:05 danielk1977 Exp $
+** $Id: utf.c,v 1.18 2004/06/06 12:41:50 danielk1977 Exp $
**
** Notes on UTF-8:
**
@@ -117,6 +117,34 @@ int sqlite3ReadUniChar(const char *zStr, int *pOffset, u8 *pEnc, int fold){
switch( *pEnc ){
case TEXT_Utf8: {
+
+#if 0
+ static const int initVal[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
+ 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
+ 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
+ 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
+ 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
+ 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
+ 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
+ 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
+ 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 0, 1, 2,
+ 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
+ 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 0, 1, 254,
+ 255,
+ };
+ ret = initVal[(unsigned char)zStr[(*pOffset)++]];
+ while( (0xc0&zStr[*pOffset])==0x80 ){
+ ret = (ret<<6) | (0x3f&(zStr[(*pOffset)++]));
+ }
+#endif
+
struct Utf8TblRow {
u8 b1_mask;
u8 b1_masked_val;
@@ -153,7 +181,6 @@ int sqlite3ReadUniChar(const char *zStr, int *pOffset, u8 *pEnc, int fold){
}
ret = (ret<<6) + (u32)(b&0x3F);
}
-
break;
}
diff --git a/src/util.c b/src/util.c
index 637782d38..bdfe54aa6 100644
--- a/src/util.c
+++ b/src/util.c
@@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
-** $Id: util.c,v 1.97 2004/06/06 09:44:05 danielk1977 Exp $
+** $Id: util.c,v 1.98 2004/06/06 12:41:50 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@@ -917,7 +917,7 @@ int sqlite3SortCompare(const char *a, const char *b){
** UCS character. This only works right if z points to a well-formed
** UTF-8 string.
*/
-static int sqlite3ReadUtf8(const unsigned char *z){
+int sqlite3ReadUtf8(const unsigned char *z){
int c;
static const int initVal[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,