Remove unused code and tighten existing code to make the library a little
smaller. (CVS 1168) FossilOrigin-Name: 34a6b7416c6c9bcdf301f5e7b072a0362a746105
This commit is contained in:
parent
143f3c45a7
commit
ba21256f98
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
|||||||
C Rework\sthe\sfix\sto\sticket\s#461\sso\sthat\swe\sdo\snot\shave\sto\sdo\sredundant\stests\nof\sWHERE\sclause\sterms\slooking\sfor\sNULLs.\s\sSee\salso\scheck-in\s(1103).\s(CVS\s1167)
|
C Remove\sunused\scode\sand\stighten\sexisting\scode\sto\smake\sthe\slibrary\sa\slittle\nsmaller.\s(CVS\s1168)
|
||||||
D 2004-01-07T20:37:52
|
D 2004-01-08T02:17:32
|
||||||
F Makefile.in 0515ff9218ad8d5a8f6220f0494b8ef94c67013b
|
F Makefile.in 0515ff9218ad8d5a8f6220f0494b8ef94c67013b
|
||||||
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
||||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||||
@ -28,13 +28,13 @@ F src/btree.h 9b7c09f1e64274d7bb74a57bbfc63778f67b1048
|
|||||||
F src/btree_rb.c e4084b6a12270674b0cd7034655f55e6a2639c78
|
F src/btree_rb.c e4084b6a12270674b0cd7034655f55e6a2639c78
|
||||||
F src/build.c a7493c433de5b552f9535d8fa7ed80aaf135491e
|
F src/build.c a7493c433de5b552f9535d8fa7ed80aaf135491e
|
||||||
F src/copy.c 9e47975ea96751c658bcf1a0c4f0bb7c6ee61e73
|
F src/copy.c 9e47975ea96751c658bcf1a0c4f0bb7c6ee61e73
|
||||||
F src/date.c eef0ccd9d0b1d9fe74ed2ae8e247578be3f49bc4
|
F src/date.c bb89fdb9c89e367b9a728c58cb96e4823974a2c1
|
||||||
F src/delete.c 0f81e6799c089487615d38e042a2de4d2d6192bc
|
F src/delete.c 0f81e6799c089487615d38e042a2de4d2d6192bc
|
||||||
F src/encode.c 25ea901a9cefb3d93774afa4a06b57cb58acf544
|
F src/encode.c 25ea901a9cefb3d93774afa4a06b57cb58acf544
|
||||||
F src/expr.c abb40922fa9995aca06f999ed35d2061d44650d6
|
F src/expr.c abb40922fa9995aca06f999ed35d2061d44650d6
|
||||||
F src/func.c 62cf8fae8147c0301d1c6a4a94fe0a78f7aa5b33
|
F src/func.c 62cf8fae8147c0301d1c6a4a94fe0a78f7aa5b33
|
||||||
F src/hash.c 058f077c1f36f266581aa16f907a3903abf64aa3
|
F src/hash.c 9b56ef3b291e25168f630d5643a4264ec011c70e
|
||||||
F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
|
F src/hash.h 3247573ab95b9dd90bcca0307a75d9a16da1ccc7
|
||||||
F src/insert.c 01f66866f35c986eab4a57373ca689a3255ef2df
|
F src/insert.c 01f66866f35c986eab4a57373ca689a3255ef2df
|
||||||
F src/main.c 3dd3cae00bade294011da5a3cf9ff660a610c545
|
F src/main.c 3dd3cae00bade294011da5a3cf9ff660a610c545
|
||||||
F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
|
F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
|
||||||
@ -58,7 +58,7 @@ F src/test2.c 5014337d8576b731cce5b5a14bec4f0daf432700
|
|||||||
F src/test3.c 30985ebdfaf3ee1462a9b0652d3efbdc8d9798f5
|
F src/test3.c 30985ebdfaf3ee1462a9b0652d3efbdc8d9798f5
|
||||||
F src/test4.c dcbbbb382626fd466a7c46907f74db35fc8bad64
|
F src/test4.c dcbbbb382626fd466a7c46907f74db35fc8bad64
|
||||||
F src/threadtest.c d641a5219e718e18a1a80a50eb9bb549f451f42e
|
F src/threadtest.c d641a5219e718e18a1a80a50eb9bb549f451f42e
|
||||||
F src/tokenize.c 5597df1fd76d6947e7da824856ac1910e2055729
|
F src/tokenize.c 8c95dcd2620b18dc0db1cdc97f9e111d11e55fe0
|
||||||
F src/trigger.c ce83e017b407d046e909d05373d7f8ee70f9f7f9
|
F src/trigger.c ce83e017b407d046e909d05373d7f8ee70f9f7f9
|
||||||
F src/update.c 24260b4fda00c9726d27699a0561d53c0dccc397
|
F src/update.c 24260b4fda00c9726d27699a0561d53c0dccc397
|
||||||
F src/util.c 64995b5949a5d377629ffd2598747bc771cade1e
|
F src/util.c 64995b5949a5d377629ffd2598747bc771cade1e
|
||||||
@ -179,7 +179,7 @@ F www/speed.tcl 2f6b1155b99d39adb185f900456d1d592c4832b3
|
|||||||
F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
|
F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
|
||||||
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
|
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
|
||||||
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
|
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
|
||||||
P 03636c94a542b1f90a3acfbe65a9c2976872073f
|
P 5fd581787e88173f0303f870fc956ec9285cca4e
|
||||||
R 747698ac4eca9128ab63b6b98ff5a6c2
|
R 42e0a61dd74faeac7023df4a5dc43247
|
||||||
U drh
|
U drh
|
||||||
Z af269badac40ad362e9b5738b29d6b42
|
Z 17125e9495da03df5ae68d60c6a8dbf2
|
||||||
|
@ -1 +1 @@
|
|||||||
5fd581787e88173f0303f870fc956ec9285cca4e
|
34a6b7416c6c9bcdf301f5e7b072a0362a746105
|
67
src/date.c
67
src/date.c
@ -16,7 +16,7 @@
|
|||||||
** sqliteRegisterDateTimeFunctions() found at the bottom of the file.
|
** sqliteRegisterDateTimeFunctions() found at the bottom of the file.
|
||||||
** All other code has file scope.
|
** All other code has file scope.
|
||||||
**
|
**
|
||||||
** $Id: date.c,v 1.7 2004/01/07 03:29:16 drh Exp $
|
** $Id: date.c,v 1.8 2004/01/08 02:17:32 drh Exp $
|
||||||
**
|
**
|
||||||
** NOTES:
|
** NOTES:
|
||||||
**
|
**
|
||||||
@ -221,7 +221,7 @@ static void computeJD(DateTime *p){
|
|||||||
M = p->M;
|
M = p->M;
|
||||||
D = p->D;
|
D = p->D;
|
||||||
}else{
|
}else{
|
||||||
Y = 2000;
|
Y = 2000; /* If no YMD specified, assume 2000-Jan-01 */
|
||||||
M = 1;
|
M = 1;
|
||||||
D = 1;
|
D = 1;
|
||||||
}
|
}
|
||||||
@ -368,6 +368,23 @@ static void computeHMS(DateTime *p){
|
|||||||
p->validHMS = 1;
|
p->validHMS = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Compute both YMD and HMS
|
||||||
|
*/
|
||||||
|
static void computeYMD_HMS(DateTime *p){
|
||||||
|
computeYMD(p);
|
||||||
|
computeHMS(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Clear the YMD and HMS and the TZ
|
||||||
|
*/
|
||||||
|
static void clearYMD_HMS_TZ(DateTime *p){
|
||||||
|
p->validYMD = 0;
|
||||||
|
p->validHMS = 0;
|
||||||
|
p->validTZ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Compute the difference (in days) between localtime and UTC (a.k.a. GMT)
|
** Compute the difference (in days) between localtime and UTC (a.k.a. GMT)
|
||||||
** for the time value p where p is in UTC.
|
** for the time value p where p is in UTC.
|
||||||
@ -376,9 +393,8 @@ static double localtimeOffset(DateTime *p){
|
|||||||
DateTime x, y;
|
DateTime x, y;
|
||||||
time_t t;
|
time_t t;
|
||||||
struct tm *pTm;
|
struct tm *pTm;
|
||||||
computeYMD(p);
|
|
||||||
computeHMS(p);
|
|
||||||
x = *p;
|
x = *p;
|
||||||
|
computeYMD_HMS(&x);
|
||||||
if( x.Y<1971 || x.Y>=2038 ){
|
if( x.Y<1971 || x.Y>=2038 ){
|
||||||
x.Y = 2000;
|
x.Y = 2000;
|
||||||
x.M = 1;
|
x.M = 1;
|
||||||
@ -408,9 +424,6 @@ static double localtimeOffset(DateTime *p){
|
|||||||
y.validJD = 0;
|
y.validJD = 0;
|
||||||
y.validTZ = 0;
|
y.validTZ = 0;
|
||||||
computeJD(&y);
|
computeJD(&y);
|
||||||
/* printf("x=%d-%02d-%02d %02d:%02d:%02d\n",x.Y,x.M,x.D,x.h,x.m,(int)x.s); */
|
|
||||||
/* printf("y=%d-%02d-%02d %02d:%02d:%02d\n",y.Y,y.M,y.D,y.h,y.m,(int)y.s); */
|
|
||||||
/* printf("diff=%.17g\n", y.rJD - x.rJD); */
|
|
||||||
return y.rJD - x.rJD;
|
return y.rJD - x.rJD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,9 +467,7 @@ static int parseModifier(const char *zMod, DateTime *p){
|
|||||||
if( strcmp(z, "localtime")==0 ){
|
if( strcmp(z, "localtime")==0 ){
|
||||||
computeJD(p);
|
computeJD(p);
|
||||||
p->rJD += localtimeOffset(p);
|
p->rJD += localtimeOffset(p);
|
||||||
p->validYMD = 0;
|
clearYMD_HMS_TZ(p);
|
||||||
p->validHMS = 0;
|
|
||||||
p->validTZ = 0;
|
|
||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -470,22 +481,15 @@ static int parseModifier(const char *zMod, DateTime *p){
|
|||||||
*/
|
*/
|
||||||
if( strcmp(z, "unixepoch")==0 && p->validJD ){
|
if( strcmp(z, "unixepoch")==0 && p->validJD ){
|
||||||
p->rJD = p->rJD/86400.0 + 2440587.5;
|
p->rJD = p->rJD/86400.0 + 2440587.5;
|
||||||
p->validYMD = 0;
|
clearYMD_HMS_TZ(p);
|
||||||
p->validHMS = 0;
|
|
||||||
p->validTZ = 0;
|
|
||||||
rc = 0;
|
rc = 0;
|
||||||
}else if( strcmp(z, "utc")==0 ){
|
}else if( strcmp(z, "utc")==0 ){
|
||||||
double c1;
|
double c1;
|
||||||
computeJD(p);
|
computeJD(p);
|
||||||
c1 = localtimeOffset(p);
|
c1 = localtimeOffset(p);
|
||||||
p->rJD -= c1;
|
p->rJD -= c1;
|
||||||
p->validYMD = 0;
|
clearYMD_HMS_TZ(p);
|
||||||
p->validHMS = 0;
|
|
||||||
p->validTZ = 0;
|
|
||||||
p->rJD += c1 - localtimeOffset(p);
|
p->rJD += c1 - localtimeOffset(p);
|
||||||
p->validYMD = 0;
|
|
||||||
p->validHMS = 0;
|
|
||||||
p->validTZ = 0;
|
|
||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -501,8 +505,7 @@ static int parseModifier(const char *zMod, DateTime *p){
|
|||||||
if( strncmp(z, "weekday ", 8)==0 && getValue(&z[8],&r)>0
|
if( strncmp(z, "weekday ", 8)==0 && getValue(&z[8],&r)>0
|
||||||
&& (n=r)==r && n>=0 && r<7 ){
|
&& (n=r)==r && n>=0 && r<7 ){
|
||||||
int Z;
|
int Z;
|
||||||
computeYMD(p);
|
computeYMD_HMS(p);
|
||||||
computeHMS(p);
|
|
||||||
p->validTZ = 0;
|
p->validTZ = 0;
|
||||||
p->validJD = 0;
|
p->validJD = 0;
|
||||||
computeJD(p);
|
computeJD(p);
|
||||||
@ -510,8 +513,7 @@ static int parseModifier(const char *zMod, DateTime *p){
|
|||||||
Z %= 7;
|
Z %= 7;
|
||||||
if( Z>n ) Z -= 7;
|
if( Z>n ) Z -= 7;
|
||||||
p->rJD += n - Z;
|
p->rJD += n - Z;
|
||||||
p->validYMD = 0;
|
clearYMD_HMS_TZ(p);
|
||||||
p->validHMS = 0;
|
|
||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -569,18 +571,14 @@ static int parseModifier(const char *zMod, DateTime *p){
|
|||||||
if( n==3 && strcmp(z,"day")==0 ){
|
if( n==3 && strcmp(z,"day")==0 ){
|
||||||
p->rJD += r;
|
p->rJD += r;
|
||||||
}else if( n==4 && strcmp(z,"hour")==0 ){
|
}else if( n==4 && strcmp(z,"hour")==0 ){
|
||||||
computeJD(p);
|
|
||||||
p->rJD += r/24.0;
|
p->rJD += r/24.0;
|
||||||
}else if( n==6 && strcmp(z,"minute")==0 ){
|
}else if( n==6 && strcmp(z,"minute")==0 ){
|
||||||
computeJD(p);
|
|
||||||
p->rJD += r/(24.0*60.0);
|
p->rJD += r/(24.0*60.0);
|
||||||
}else if( n==6 && strcmp(z,"second")==0 ){
|
}else if( n==6 && strcmp(z,"second")==0 ){
|
||||||
computeJD(p);
|
|
||||||
p->rJD += r/(24.0*60.0*60.0);
|
p->rJD += r/(24.0*60.0*60.0);
|
||||||
}else if( n==5 && strcmp(z,"month")==0 ){
|
}else if( n==5 && strcmp(z,"month")==0 ){
|
||||||
int x, y;
|
int x, y;
|
||||||
computeYMD(p);
|
computeYMD_HMS(p);
|
||||||
computeHMS(p);
|
|
||||||
p->M += r;
|
p->M += r;
|
||||||
x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
|
x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
|
||||||
p->Y += x;
|
p->Y += x;
|
||||||
@ -592,17 +590,14 @@ static int parseModifier(const char *zMod, DateTime *p){
|
|||||||
p->rJD += (r - y)*30.0;
|
p->rJD += (r - y)*30.0;
|
||||||
}
|
}
|
||||||
}else if( n==4 && strcmp(z,"year")==0 ){
|
}else if( n==4 && strcmp(z,"year")==0 ){
|
||||||
computeYMD(p);
|
computeYMD_HMS(p);
|
||||||
computeHMS(p);
|
|
||||||
p->Y += r;
|
p->Y += r;
|
||||||
p->validJD = 0;
|
p->validJD = 0;
|
||||||
computeJD(p);
|
computeJD(p);
|
||||||
}else{
|
}else{
|
||||||
rc = 1;
|
rc = 1;
|
||||||
}
|
}
|
||||||
p->validYMD = 0;
|
clearYMD_HMS_TZ(p);
|
||||||
p->validHMS = 0;
|
|
||||||
p->validTZ = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -656,8 +651,7 @@ static void datetimeFunc(sqlite_func *context, int argc, const char **argv){
|
|||||||
DateTime x;
|
DateTime x;
|
||||||
if( isDate(argc, argv, &x)==0 ){
|
if( isDate(argc, argv, &x)==0 ){
|
||||||
char zBuf[100];
|
char zBuf[100];
|
||||||
computeYMD(&x);
|
computeYMD_HMS(&x);
|
||||||
computeHMS(&x);
|
|
||||||
sprintf(zBuf, "%04d-%02d-%02d %02d:%02d:%02d",x.Y, x.M, x.D, x.h, x.m,
|
sprintf(zBuf, "%04d-%02d-%02d %02d:%02d:%02d",x.Y, x.M, x.D, x.h, x.m,
|
||||||
(int)(x.s));
|
(int)(x.s));
|
||||||
sqlite_set_result_string(context, zBuf, -1);
|
sqlite_set_result_string(context, zBuf, -1);
|
||||||
@ -760,8 +754,7 @@ static void strftimeFunc(sqlite_func *context, int argc, const char **argv){
|
|||||||
if( z==0 ) return;
|
if( z==0 ) return;
|
||||||
}
|
}
|
||||||
computeJD(&x);
|
computeJD(&x);
|
||||||
computeYMD(&x);
|
computeYMD_HMS(&x);
|
||||||
computeHMS(&x);
|
|
||||||
for(i=j=0; zFmt[i]; i++){
|
for(i=j=0; zFmt[i]; i++){
|
||||||
if( zFmt[i]!='%' ){
|
if( zFmt[i]!='%' ){
|
||||||
z[j++] = zFmt[i];
|
z[j++] = zFmt[i];
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
** This is the implementation of generic hash-tables
|
** This is the implementation of generic hash-tables
|
||||||
** used in SQLite.
|
** used in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: hash.c,v 1.10 2003/05/12 23:06:53 drh Exp $
|
** $Id: hash.c,v 1.11 2004/01/08 02:17:33 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -75,6 +75,7 @@ static int intCompare(const void *pKey1, int n1, const void *pKey2, int n2){
|
|||||||
return n2 - n1;
|
return n2 - n1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 /* NOT USED */
|
||||||
/*
|
/*
|
||||||
** Hash and comparison functions when the mode is SQLITE_HASH_POINTER
|
** Hash and comparison functions when the mode is SQLITE_HASH_POINTER
|
||||||
*/
|
*/
|
||||||
@ -87,6 +88,7 @@ static int ptrCompare(const void *pKey1, int n1, const void *pKey2, int n2){
|
|||||||
if( pKey1<pKey2 ) return -1;
|
if( pKey1<pKey2 ) return -1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Hash and comparison functions when the mode is SQLITE_HASH_STRING
|
** Hash and comparison functions when the mode is SQLITE_HASH_STRING
|
||||||
@ -130,7 +132,7 @@ static int binCompare(const void *pKey1, int n1, const void *pKey2, int n2){
|
|||||||
static int (*hashFunction(int keyClass))(const void*,int){
|
static int (*hashFunction(int keyClass))(const void*,int){
|
||||||
switch( keyClass ){
|
switch( keyClass ){
|
||||||
case SQLITE_HASH_INT: return &intHash;
|
case SQLITE_HASH_INT: return &intHash;
|
||||||
case SQLITE_HASH_POINTER: return &ptrHash;
|
/* case SQLITE_HASH_POINTER: return &ptrHash; // NOT USED */
|
||||||
case SQLITE_HASH_STRING: return &strHash;
|
case SQLITE_HASH_STRING: return &strHash;
|
||||||
case SQLITE_HASH_BINARY: return &binHash;;
|
case SQLITE_HASH_BINARY: return &binHash;;
|
||||||
default: break;
|
default: break;
|
||||||
@ -147,7 +149,7 @@ static int (*hashFunction(int keyClass))(const void*,int){
|
|||||||
static int (*compareFunction(int keyClass))(const void*,int,const void*,int){
|
static int (*compareFunction(int keyClass))(const void*,int,const void*,int){
|
||||||
switch( keyClass ){
|
switch( keyClass ){
|
||||||
case SQLITE_HASH_INT: return &intCompare;
|
case SQLITE_HASH_INT: return &intCompare;
|
||||||
case SQLITE_HASH_POINTER: return &ptrCompare;
|
/* case SQLITE_HASH_POINTER: return &ptrCompare; // NOT USED */
|
||||||
case SQLITE_HASH_STRING: return &strCompare;
|
case SQLITE_HASH_STRING: return &strCompare;
|
||||||
case SQLITE_HASH_BINARY: return &binCompare;
|
case SQLITE_HASH_BINARY: return &binCompare;
|
||||||
default: break;
|
default: break;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
** This is the header file for the generic hash-table implemenation
|
** This is the header file for the generic hash-table implemenation
|
||||||
** used in SQLite.
|
** used in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: hash.h,v 1.5 2002/06/08 23:25:09 drh Exp $
|
** $Id: hash.h,v 1.6 2004/01/08 02:17:33 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITE_HASH_H_
|
#ifndef _SQLITE_HASH_H_
|
||||||
#define _SQLITE_HASH_H_
|
#define _SQLITE_HASH_H_
|
||||||
@ -71,7 +71,7 @@ struct HashElem {
|
|||||||
** if the copyKey parameter to HashInit is 1.
|
** if the copyKey parameter to HashInit is 1.
|
||||||
*/
|
*/
|
||||||
#define SQLITE_HASH_INT 1
|
#define SQLITE_HASH_INT 1
|
||||||
#define SQLITE_HASH_POINTER 2
|
/* #define SQLITE_HASH_POINTER 2 // NOT USED */
|
||||||
#define SQLITE_HASH_STRING 3
|
#define SQLITE_HASH_STRING 3
|
||||||
#define SQLITE_HASH_BINARY 4
|
#define SQLITE_HASH_BINARY 4
|
||||||
|
|
||||||
|
248
src/tokenize.c
248
src/tokenize.c
@ -15,7 +15,7 @@
|
|||||||
** individual tokens and sends those tokens one-by-one over to the
|
** individual tokens and sends those tokens one-by-one over to the
|
||||||
** parser for analysis.
|
** parser for analysis.
|
||||||
**
|
**
|
||||||
** $Id: tokenize.c,v 1.66 2003/12/23 02:17:35 drh Exp $
|
** $Id: tokenize.c,v 1.67 2004/01/08 02:17:33 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
@ -29,122 +29,122 @@
|
|||||||
typedef struct Keyword Keyword;
|
typedef struct Keyword Keyword;
|
||||||
struct Keyword {
|
struct Keyword {
|
||||||
char *zName; /* The keyword name */
|
char *zName; /* The keyword name */
|
||||||
u16 len; /* Number of characters in the keyword */
|
u8 tokenType; /* Token value for this keyword */
|
||||||
u16 tokenType; /* The token value for this keyword */
|
u8 len; /* Length of this keyword */
|
||||||
Keyword *pNext; /* Next keyword with the same hash */
|
u8 iNext; /* Index in aKeywordTable[] of next with same hash */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** These are the keywords
|
** These are the keywords
|
||||||
*/
|
*/
|
||||||
static Keyword aKeywordTable[] = {
|
static Keyword aKeywordTable[] = {
|
||||||
{ "ABORT", 0, TK_ABORT, 0 },
|
{ "ABORT", TK_ABORT, },
|
||||||
{ "AFTER", 0, TK_AFTER, 0 },
|
{ "AFTER", TK_AFTER, },
|
||||||
{ "ALL", 0, TK_ALL, 0 },
|
{ "ALL", TK_ALL, },
|
||||||
{ "AND", 0, TK_AND, 0 },
|
{ "AND", TK_AND, },
|
||||||
{ "AS", 0, TK_AS, 0 },
|
{ "AS", TK_AS, },
|
||||||
{ "ASC", 0, TK_ASC, 0 },
|
{ "ASC", TK_ASC, },
|
||||||
{ "ATTACH", 0, TK_ATTACH, 0 },
|
{ "ATTACH", TK_ATTACH, },
|
||||||
{ "BEFORE", 0, TK_BEFORE, 0 },
|
{ "BEFORE", TK_BEFORE, },
|
||||||
{ "BEGIN", 0, TK_BEGIN, 0 },
|
{ "BEGIN", TK_BEGIN, },
|
||||||
{ "BETWEEN", 0, TK_BETWEEN, 0 },
|
{ "BETWEEN", TK_BETWEEN, },
|
||||||
{ "BY", 0, TK_BY, 0 },
|
{ "BY", TK_BY, },
|
||||||
{ "CASCADE", 0, TK_CASCADE, 0 },
|
{ "CASCADE", TK_CASCADE, },
|
||||||
{ "CASE", 0, TK_CASE, 0 },
|
{ "CASE", TK_CASE, },
|
||||||
{ "CHECK", 0, TK_CHECK, 0 },
|
{ "CHECK", TK_CHECK, },
|
||||||
{ "CLUSTER", 0, TK_CLUSTER, 0 },
|
{ "CLUSTER", TK_CLUSTER, },
|
||||||
{ "COLLATE", 0, TK_COLLATE, 0 },
|
{ "COLLATE", TK_COLLATE, },
|
||||||
{ "COMMIT", 0, TK_COMMIT, 0 },
|
{ "COMMIT", TK_COMMIT, },
|
||||||
{ "CONFLICT", 0, TK_CONFLICT, 0 },
|
{ "CONFLICT", TK_CONFLICT, },
|
||||||
{ "CONSTRAINT", 0, TK_CONSTRAINT, 0 },
|
{ "CONSTRAINT", TK_CONSTRAINT, },
|
||||||
{ "COPY", 0, TK_COPY, 0 },
|
{ "COPY", TK_COPY, },
|
||||||
{ "CREATE", 0, TK_CREATE, 0 },
|
{ "CREATE", TK_CREATE, },
|
||||||
{ "CROSS", 0, TK_JOIN_KW, 0 },
|
{ "CROSS", TK_JOIN_KW, },
|
||||||
{ "DATABASE", 0, TK_DATABASE, 0 },
|
{ "DATABASE", TK_DATABASE, },
|
||||||
{ "DEFAULT", 0, TK_DEFAULT, 0 },
|
{ "DEFAULT", TK_DEFAULT, },
|
||||||
{ "DEFERRED", 0, TK_DEFERRED, 0 },
|
{ "DEFERRED", TK_DEFERRED, },
|
||||||
{ "DEFERRABLE", 0, TK_DEFERRABLE, 0 },
|
{ "DEFERRABLE", TK_DEFERRABLE, },
|
||||||
{ "DELETE", 0, TK_DELETE, 0 },
|
{ "DELETE", TK_DELETE, },
|
||||||
{ "DELIMITERS", 0, TK_DELIMITERS, 0 },
|
{ "DELIMITERS", TK_DELIMITERS, },
|
||||||
{ "DESC", 0, TK_DESC, 0 },
|
{ "DESC", TK_DESC, },
|
||||||
{ "DETACH", 0, TK_DETACH, 0 },
|
{ "DETACH", TK_DETACH, },
|
||||||
{ "DISTINCT", 0, TK_DISTINCT, 0 },
|
{ "DISTINCT", TK_DISTINCT, },
|
||||||
{ "DROP", 0, TK_DROP, 0 },
|
{ "DROP", TK_DROP, },
|
||||||
{ "END", 0, TK_END, 0 },
|
{ "END", TK_END, },
|
||||||
{ "EACH", 0, TK_EACH, 0 },
|
{ "EACH", TK_EACH, },
|
||||||
{ "ELSE", 0, TK_ELSE, 0 },
|
{ "ELSE", TK_ELSE, },
|
||||||
{ "EXCEPT", 0, TK_EXCEPT, 0 },
|
{ "EXCEPT", TK_EXCEPT, },
|
||||||
{ "EXPLAIN", 0, TK_EXPLAIN, 0 },
|
{ "EXPLAIN", TK_EXPLAIN, },
|
||||||
{ "FAIL", 0, TK_FAIL, 0 },
|
{ "FAIL", TK_FAIL, },
|
||||||
{ "FOR", 0, TK_FOR, 0 },
|
{ "FOR", TK_FOR, },
|
||||||
{ "FOREIGN", 0, TK_FOREIGN, 0 },
|
{ "FOREIGN", TK_FOREIGN, },
|
||||||
{ "FROM", 0, TK_FROM, 0 },
|
{ "FROM", TK_FROM, },
|
||||||
{ "FULL", 0, TK_JOIN_KW, 0 },
|
{ "FULL", TK_JOIN_KW, },
|
||||||
{ "GLOB", 0, TK_GLOB, 0 },
|
{ "GLOB", TK_GLOB, },
|
||||||
{ "GROUP", 0, TK_GROUP, 0 },
|
{ "GROUP", TK_GROUP, },
|
||||||
{ "HAVING", 0, TK_HAVING, 0 },
|
{ "HAVING", TK_HAVING, },
|
||||||
{ "IGNORE", 0, TK_IGNORE, 0 },
|
{ "IGNORE", TK_IGNORE, },
|
||||||
{ "IMMEDIATE", 0, TK_IMMEDIATE, 0 },
|
{ "IMMEDIATE", TK_IMMEDIATE, },
|
||||||
{ "IN", 0, TK_IN, 0 },
|
{ "IN", TK_IN, },
|
||||||
{ "INDEX", 0, TK_INDEX, 0 },
|
{ "INDEX", TK_INDEX, },
|
||||||
{ "INITIALLY", 0, TK_INITIALLY, 0 },
|
{ "INITIALLY", TK_INITIALLY, },
|
||||||
{ "INNER", 0, TK_JOIN_KW, 0 },
|
{ "INNER", TK_JOIN_KW, },
|
||||||
{ "INSERT", 0, TK_INSERT, 0 },
|
{ "INSERT", TK_INSERT, },
|
||||||
{ "INSTEAD", 0, TK_INSTEAD, 0 },
|
{ "INSTEAD", TK_INSTEAD, },
|
||||||
{ "INTERSECT", 0, TK_INTERSECT, 0 },
|
{ "INTERSECT", TK_INTERSECT, },
|
||||||
{ "INTO", 0, TK_INTO, 0 },
|
{ "INTO", TK_INTO, },
|
||||||
{ "IS", 0, TK_IS, 0 },
|
{ "IS", TK_IS, },
|
||||||
{ "ISNULL", 0, TK_ISNULL, 0 },
|
{ "ISNULL", TK_ISNULL, },
|
||||||
{ "JOIN", 0, TK_JOIN, 0 },
|
{ "JOIN", TK_JOIN, },
|
||||||
{ "KEY", 0, TK_KEY, 0 },
|
{ "KEY", TK_KEY, },
|
||||||
{ "LEFT", 0, TK_JOIN_KW, 0 },
|
{ "LEFT", TK_JOIN_KW, },
|
||||||
{ "LIKE", 0, TK_LIKE, 0 },
|
{ "LIKE", TK_LIKE, },
|
||||||
{ "LIMIT", 0, TK_LIMIT, 0 },
|
{ "LIMIT", TK_LIMIT, },
|
||||||
{ "MATCH", 0, TK_MATCH, 0 },
|
{ "MATCH", TK_MATCH, },
|
||||||
{ "NATURAL", 0, TK_JOIN_KW, 0 },
|
{ "NATURAL", TK_JOIN_KW, },
|
||||||
{ "NOT", 0, TK_NOT, 0 },
|
{ "NOT", TK_NOT, },
|
||||||
{ "NOTNULL", 0, TK_NOTNULL, 0 },
|
{ "NOTNULL", TK_NOTNULL, },
|
||||||
{ "NULL", 0, TK_NULL, 0 },
|
{ "NULL", TK_NULL, },
|
||||||
{ "OF", 0, TK_OF, 0 },
|
{ "OF", TK_OF, },
|
||||||
{ "OFFSET", 0, TK_OFFSET, 0 },
|
{ "OFFSET", TK_OFFSET, },
|
||||||
{ "ON", 0, TK_ON, 0 },
|
{ "ON", TK_ON, },
|
||||||
{ "OR", 0, TK_OR, 0 },
|
{ "OR", TK_OR, },
|
||||||
{ "ORDER", 0, TK_ORDER, 0 },
|
{ "ORDER", TK_ORDER, },
|
||||||
{ "OUTER", 0, TK_JOIN_KW, 0 },
|
{ "OUTER", TK_JOIN_KW, },
|
||||||
{ "PRAGMA", 0, TK_PRAGMA, 0 },
|
{ "PRAGMA", TK_PRAGMA, },
|
||||||
{ "PRIMARY", 0, TK_PRIMARY, 0 },
|
{ "PRIMARY", TK_PRIMARY, },
|
||||||
{ "RAISE", 0, TK_RAISE, 0 },
|
{ "RAISE", TK_RAISE, },
|
||||||
{ "REFERENCES", 0, TK_REFERENCES, 0 },
|
{ "REFERENCES", TK_REFERENCES, },
|
||||||
{ "REPLACE", 0, TK_REPLACE, 0 },
|
{ "REPLACE", TK_REPLACE, },
|
||||||
{ "RESTRICT", 0, TK_RESTRICT, 0 },
|
{ "RESTRICT", TK_RESTRICT, },
|
||||||
{ "RIGHT", 0, TK_JOIN_KW, 0 },
|
{ "RIGHT", TK_JOIN_KW, },
|
||||||
{ "ROLLBACK", 0, TK_ROLLBACK, 0 },
|
{ "ROLLBACK", TK_ROLLBACK, },
|
||||||
{ "ROW", 0, TK_ROW, 0 },
|
{ "ROW", TK_ROW, },
|
||||||
{ "SELECT", 0, TK_SELECT, 0 },
|
{ "SELECT", TK_SELECT, },
|
||||||
{ "SET", 0, TK_SET, 0 },
|
{ "SET", TK_SET, },
|
||||||
{ "STATEMENT", 0, TK_STATEMENT, 0 },
|
{ "STATEMENT", TK_STATEMENT, },
|
||||||
{ "TABLE", 0, TK_TABLE, 0 },
|
{ "TABLE", TK_TABLE, },
|
||||||
{ "TEMP", 0, TK_TEMP, 0 },
|
{ "TEMP", TK_TEMP, },
|
||||||
{ "TEMPORARY", 0, TK_TEMP, 0 },
|
{ "TEMPORARY", TK_TEMP, },
|
||||||
{ "THEN", 0, TK_THEN, 0 },
|
{ "THEN", TK_THEN, },
|
||||||
{ "TRANSACTION", 0, TK_TRANSACTION, 0 },
|
{ "TRANSACTION", TK_TRANSACTION, },
|
||||||
{ "TRIGGER", 0, TK_TRIGGER, 0 },
|
{ "TRIGGER", TK_TRIGGER, },
|
||||||
{ "UNION", 0, TK_UNION, 0 },
|
{ "UNION", TK_UNION, },
|
||||||
{ "UNIQUE", 0, TK_UNIQUE, 0 },
|
{ "UNIQUE", TK_UNIQUE, },
|
||||||
{ "UPDATE", 0, TK_UPDATE, 0 },
|
{ "UPDATE", TK_UPDATE, },
|
||||||
{ "USING", 0, TK_USING, 0 },
|
{ "USING", TK_USING, },
|
||||||
{ "VACUUM", 0, TK_VACUUM, 0 },
|
{ "VACUUM", TK_VACUUM, },
|
||||||
{ "VALUES", 0, TK_VALUES, 0 },
|
{ "VALUES", TK_VALUES, },
|
||||||
{ "VIEW", 0, TK_VIEW, 0 },
|
{ "VIEW", TK_VIEW, },
|
||||||
{ "WHEN", 0, TK_WHEN, 0 },
|
{ "WHEN", TK_WHEN, },
|
||||||
{ "WHERE", 0, TK_WHERE, 0 },
|
{ "WHERE", TK_WHERE, },
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This is the hash table
|
** This is the hash table
|
||||||
*/
|
*/
|
||||||
#define KEY_HASH_SIZE 71
|
#define KEY_HASH_SIZE 101
|
||||||
static Keyword *apHashTable[KEY_HASH_SIZE];
|
static u8 aiHashTable[KEY_HASH_SIZE];
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -153,29 +153,29 @@ static Keyword *apHashTable[KEY_HASH_SIZE];
|
|||||||
** returned. If the input is not a keyword, TK_ID is returned.
|
** returned. If the input is not a keyword, TK_ID is returned.
|
||||||
*/
|
*/
|
||||||
int sqliteKeywordCode(const char *z, int n){
|
int sqliteKeywordCode(const char *z, int n){
|
||||||
int h;
|
int h, i;
|
||||||
Keyword *p;
|
Keyword *p;
|
||||||
static char needInit = 1;
|
static char needInit = 1;
|
||||||
if( needInit ){
|
if( needInit ){
|
||||||
/* Initialize the keyword hash table */
|
/* Initialize the keyword hash table */
|
||||||
sqliteOsEnterMutex();
|
sqliteOsEnterMutex();
|
||||||
if( needInit ){
|
if( needInit ){
|
||||||
int i;
|
int nk;
|
||||||
int n;
|
nk = sizeof(aKeywordTable)/sizeof(aKeywordTable[0]);
|
||||||
n = sizeof(aKeywordTable)/sizeof(aKeywordTable[0]);
|
for(i=0; i<nk; i++){
|
||||||
for(i=0; i<n; i++){
|
|
||||||
aKeywordTable[i].len = strlen(aKeywordTable[i].zName);
|
aKeywordTable[i].len = strlen(aKeywordTable[i].zName);
|
||||||
h = sqliteHashNoCase(aKeywordTable[i].zName, aKeywordTable[i].len);
|
h = sqliteHashNoCase(aKeywordTable[i].zName, aKeywordTable[i].len);
|
||||||
h %= KEY_HASH_SIZE;
|
h %= KEY_HASH_SIZE;
|
||||||
aKeywordTable[i].pNext = apHashTable[h];
|
aKeywordTable[i].iNext = aiHashTable[h];
|
||||||
apHashTable[h] = &aKeywordTable[i];
|
aiHashTable[h] = i+1;
|
||||||
}
|
}
|
||||||
needInit = 0;
|
needInit = 0;
|
||||||
}
|
}
|
||||||
sqliteOsLeaveMutex();
|
sqliteOsLeaveMutex();
|
||||||
}
|
}
|
||||||
h = sqliteHashNoCase(z, n) % KEY_HASH_SIZE;
|
h = sqliteHashNoCase(z, n) % KEY_HASH_SIZE;
|
||||||
for(p=apHashTable[h]; p; p=p->pNext){
|
for(i=aiHashTable[h]; i; i=p->iNext){
|
||||||
|
p = &aKeywordTable[i-1];
|
||||||
if( p->len==n && sqliteStrNICmp(p->zName, z, n)==0 ){
|
if( p->len==n && sqliteStrNICmp(p->zName, z, n)==0 ){
|
||||||
return p->tokenType;
|
return p->tokenType;
|
||||||
}
|
}
|
||||||
@ -185,8 +185,12 @@ int sqliteKeywordCode(const char *z, int n){
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** If X is a character that can be used in an identifier then
|
** If X is a character that can be used in an identifier and
|
||||||
** isIdChar[X] will be 1. Otherwise isIdChar[X] will be 0.
|
** X&0x80==0 then isIdChar[X] will be 1. If X&0x80==0x80 then
|
||||||
|
** X is always an identifier character. (Hence all UTF-8
|
||||||
|
** characters can be part of an identifier). isIdChar[X] will
|
||||||
|
** be 0 for every character in the lower 128 ASCII characters
|
||||||
|
** that cannot be used as part of an identifier.
|
||||||
**
|
**
|
||||||
** In this implementation, an identifier can be a string of
|
** In this implementation, an identifier can be a string of
|
||||||
** alphabetic characters, digits, and "_" plus any character
|
** alphabetic characters, digits, and "_" plus any character
|
||||||
@ -204,14 +208,6 @@ static const char isIdChar[] = {
|
|||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, /* 5x */
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, /* 5x */
|
||||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 6x */
|
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 6x */
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 7x */
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 7x */
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 8x */
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 9x */
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* Ax */
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* Bx */
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* Cx */
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* Dx */
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* Ex */
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* Fx */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -380,10 +376,10 @@ static int sqliteGetToken(const unsigned char *z, int *tokenType){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
if( !isIdChar[*z] ){
|
if( (*z&0x80)==0 && !isIdChar[*z] ){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for(i=1; isIdChar[z[i]]; i++){}
|
for(i=1; (z[i]&0x80)!=0 || isIdChar[z[i]]; i++){}
|
||||||
*tokenType = sqliteKeywordCode((char*)z, i);
|
*tokenType = sqliteKeywordCode((char*)z, i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user