1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-10 01:02:56 +03:00

Move a few things around to make building without the parser easier. (CVS 2479)

FossilOrigin-Name: 5fadb464eb77b4b998d8555f83401769960ea904
This commit is contained in:
danielk1977
2005-05-24 12:01:00 +00:00
parent b71090fdfb
commit fd9a0a45a7
11 changed files with 239 additions and 209 deletions

View File

@@ -112,7 +112,7 @@ TCC += -DSQLITE_OMIT_CURSOR
# Object files for the SQLite library. # Object files for the SQLite library.
# #
LIBOBJ = alter.lo attach.lo auth.lo btree.lo build.lo date.lo \ LIBOBJ = alter.lo attach.lo auth.lo btree.lo build.lo callback.lo date.lo \
delete.lo expr.lo func.lo hash.lo insert.lo \ delete.lo expr.lo func.lo hash.lo insert.lo \
main.lo opcodes.lo os_unix.lo os_win.lo \ main.lo opcodes.lo os_unix.lo os_win.lo \
pager.lo parse.lo pragma.lo printf.lo random.lo \ pager.lo parse.lo pragma.lo printf.lo random.lo \
@@ -129,6 +129,7 @@ SRC = \
$(TOP)/src/btree.c \ $(TOP)/src/btree.c \
$(TOP)/src/btree.h \ $(TOP)/src/btree.h \
$(TOP)/src/build.c \ $(TOP)/src/build.c \
$(TOP)/src/callback.c \
$(TOP)/src/date.c \ $(TOP)/src/date.c \
$(TOP)/src/delete.c \ $(TOP)/src/delete.c \
$(TOP)/src/expr.c \ $(TOP)/src/expr.c \
@@ -292,6 +293,9 @@ config.h:
echo >>config.h echo >>config.h
rm -f temp.c temp rm -f temp.c temp
callback.lo: $(TOP)/src/callback.c $(HDR)
$(LTCOMPILE) -c $(TOP)/src/callback.c
date.lo: $(TOP)/src/date.c $(HDR) date.lo: $(TOP)/src/date.c $(HDR)
$(LTCOMPILE) -c $(TOP)/src/date.c $(LTCOMPILE) -c $(TOP)/src/date.c

View File

@@ -54,7 +54,7 @@ TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src
# Object files for the SQLite library. # Object files for the SQLite library.
# #
LIBOBJ+= alter.o attach.o auth.o btree.o build.o date.o delete.o \ LIBOBJ+= alter.o attach.o auth.o btree.o build.o callback.o date.o delete.o \
expr.o func.o hash.o insert.o \ expr.o func.o hash.o insert.o \
main.o opcodes.o os_unix.o os_win.o \ main.o opcodes.o os_unix.o os_win.o \
pager.o parse.o pragma.o printf.o random.o \ pager.o parse.o pragma.o printf.o random.o \
@@ -72,6 +72,7 @@ SRC = \
$(TOP)/src/btree.c \ $(TOP)/src/btree.c \
$(TOP)/src/btree.h \ $(TOP)/src/btree.h \
$(TOP)/src/build.c \ $(TOP)/src/build.c \
$(TOP)/src/callback.c \
$(TOP)/src/date.c \ $(TOP)/src/date.c \
$(TOP)/src/delete.c \ $(TOP)/src/delete.c \
$(TOP)/src/expr.c \ $(TOP)/src/expr.c \
@@ -227,6 +228,9 @@ config.h:
echo >>config.h echo >>config.h
rm -f temp.c temp rm -f temp.c temp
callback.o: $(TOP)/src/callback.c $(HDR)
$(TCCX) -c $(TOP)/src/callback.c
date.o: $(TOP)/src/date.c $(HDR) date.o: $(TOP)/src/date.c $(HDR)
$(TCCX) -c $(TOP)/src/date.c $(TCCX) -c $(TOP)/src/date.c

View File

@@ -1,6 +1,6 @@
C The\sREGEXP\soperator\sis\srecognized.\s\sIt\stries\sto\sinvoke\sa\sfunction\snamed\r\nregexp()\swhich\sdoes\snot\sexist\sin\sthe\snative\sbuild.\s\sBut\susers\swho\swant\sto\r\ncan\sadd\san\sappropriate\sregexp()\sfunction\susing\ssqlite3_create_function().\s(CVS\s2478) C Move\sa\sfew\sthings\saround\sto\smake\sbuilding\swithout\sthe\sparser\seasier.\s(CVS\s2479)
D 2005-05-23T17:26:51 D 2005-05-24T12:01:01
F Makefile.in 5c00d0037104de2a50ac7647a5f12769795957a3 F Makefile.in d9507f787ff6dbf650138ad5484cf24aa77884d3
F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7 F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F VERSION 44187d7938af15a89b7b2dcd0016ffe5ec84961f F VERSION 44187d7938af15a89b7b2dcd0016ffe5ec84961f
@@ -16,7 +16,7 @@ F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538
F doc/report1.txt a031aaf37b185e4fa540223cb516d3bccec7eeac F doc/report1.txt a031aaf37b185e4fa540223cb516d3bccec7eeac
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
F ltmain.sh f6b283068efa69f06eb8aa1fe4bddfdbdeb35826 F ltmain.sh f6b283068efa69f06eb8aa1fe4bddfdbdeb35826
F main.mk 3acc5ae52addd43fd1858fe99fca54a49bca6a56 F main.mk 4002b109f2e3a3d64f4ef24a3e0c5755fc42911e
F mkdll.sh 5ec23622515d5bf8969404e80cfb5e220ddf0512 F mkdll.sh 5ec23622515d5bf8969404e80cfb5e220ddf0512
F mkopcodec.awk bd46ad001c98dfbab07b1713cb8e692fa0e5415d F mkopcodec.awk bd46ad001c98dfbab07b1713cb8e692fa0e5415d
F mkopcodeh.awk 7563ad235670e864ead95cf672be3fe081450ae0 F mkopcodeh.awk 7563ad235670e864ead95cf672be3fe081450ae0
@@ -32,17 +32,18 @@ F src/attach.c 3615dbe960cbee4aa5ea300b8a213dad36527b0f
F src/auth.c 18c5a0befe20f3a58a41e3ddd78f372faeeefe1f F src/auth.c 18c5a0befe20f3a58a41e3ddd78f372faeeefe1f
F src/btree.c 85ee452bf378f297054aded9ea6eaed846fa4855 F src/btree.c 85ee452bf378f297054aded9ea6eaed846fa4855
F src/btree.h 41a71ce027db9ddee72cb43df2316bbe3a1d92af F src/btree.h 41a71ce027db9ddee72cb43df2316bbe3a1d92af
F src/build.c 6770abc63df9f3ed9f44c50411bb63692cb4589f F src/build.c 5d3cee156a3e010303db5615e335e7e23d82d5e1
F src/callback.c c80e399ec3ef01d9a667f87c79331648a4debb13
F src/date.c 2134ef4388256e8247405178df8a61bd60dc180a F src/date.c 2134ef4388256e8247405178df8a61bd60dc180a
F src/delete.c 75b53db21aa1879d3655bbbc208007db31d58a63 F src/delete.c 75b53db21aa1879d3655bbbc208007db31d58a63
F src/experimental.c 50c1e3b34f752f4ac10c36f287db095c2b61766d F src/experimental.c 50c1e3b34f752f4ac10c36f287db095c2b61766d
F src/expr.c d0fbb951fd260feb2e2028c5ec078e98daca5bb6 F src/expr.c 62cfa7d8b3debc85495e61df03930e7fdfc2a80c
F src/func.c d09df82e35ef988cd28a3ffd63cd772271b7def9 F src/func.c f208d71f741d47b63277530939f552815af8ce35
F src/hash.c 2b1b13f7400e179631c83a1be0c664608c8f021f F src/hash.c 2b1b13f7400e179631c83a1be0c664608c8f021f
F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84 F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84
F src/insert.c 34c25c33f51a43644a42cc091ac967b070c6b6d5 F src/insert.c 34c25c33f51a43644a42cc091ac967b070c6b6d5
F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b
F src/main.c 5d7299e050c1bd4d62b2d996387bd27b1dbf9c00 F src/main.c e7aae2fbc0b29aa4c3fb7639ca69e9cc32e6855f
F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070 F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
F src/os.h e5438be25cf96858787bf9b60fc7a2420e139ee3 F src/os.h e5438be25cf96858787bf9b60fc7a2420e139ee3
F src/os_common.h 0e7f428ba0a6c40a61bc56c4e96f493231301b73 F src/os_common.h 0e7f428ba0a6c40a61bc56c4e96f493231301b73
@@ -61,7 +62,7 @@ F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
F src/select.c 43cc2a76e3e00dabc59da82d0dcdef23cdba43a3 F src/select.c 43cc2a76e3e00dabc59da82d0dcdef23cdba43a3
F src/shell.c 25b3217d7c64e6497225439d261a253a23efff26 F src/shell.c 25b3217d7c64e6497225439d261a253a23efff26
F src/sqlite.h.in 3675e3ada207e09b9d52a0463561325df4ac26b5 F src/sqlite.h.in 3675e3ada207e09b9d52a0463561325df4ac26b5
F src/sqliteInt.h bb0bfc7f761c2f0136002a3a5456f11a1c1e3981 F src/sqliteInt.h a1f5cc21e7f615a50be484ff4916af0852a0e1a3
F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9 F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9
F src/tclsqlite.c af0f002d9d6ab4f7f32b9bee5b57665946e76ad9 F src/tclsqlite.c af0f002d9d6ab4f7f32b9bee5b57665946e76ad9
F src/test1.c 4ad7ffe5a74fd99d4f73f6fd28ba27f403b3adba F src/test1.c 4ad7ffe5a74fd99d4f73f6fd28ba27f403b3adba
@@ -74,7 +75,7 @@ F src/trigger.c 1a6d0c7c51b70bdc58d5068be72034071eff23ad
F src/update.c 04ea9dd784ccfeaf38a681b3edfe3b1c4edfdda7 F src/update.c 04ea9dd784ccfeaf38a681b3edfe3b1c4edfdda7
F src/utf.c bda5eb85039ef16f2d17004c1e18c96e1ab0a80c F src/utf.c bda5eb85039ef16f2d17004c1e18c96e1ab0a80c
F src/util.c ae41deda8b026e141a00938fcab8e4431578d6ea F src/util.c ae41deda8b026e141a00938fcab8e4431578d6ea
F src/vacuum.c f14521a8033350ce3dbe11ff9a25674b1d6298df F src/vacuum.c f4eb8facbfede77cac4d8c205a76a1a9b9b0d21d
F src/vdbe.c d2574042c44baf6b1016c61e8072dec529ac748a F src/vdbe.c d2574042c44baf6b1016c61e8072dec529ac748a
F src/vdbe.h 75e466d84d362b0c4498978a9d6b1e6bd32ecf3b F src/vdbe.h 75e466d84d362b0c4498978a9d6b1e6bd32ecf3b
F src/vdbeInt.h 4afaae2f4adcab54ad2a40dabb2e689fba7b1561 F src/vdbeInt.h 4afaae2f4adcab54ad2a40dabb2e689fba7b1561
@@ -279,7 +280,7 @@ F www/tclsqlite.tcl 425be741b8ae664f55cb1ef2371aab0a75109cf9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b
P ef4059e3afa1a61a9e59df00cdfedc57d8df9fec P 42a626ace126f730f33ecb6c41ac5679d6766a31
R 8996a199d8872550587b98a7437c931f R bfa075e2f7d191385c3e4fa4220d17e2
U drh U danielk1977
Z 797c50f3e25833784eb0ca0d6800d861 Z 75c5f4d08b7ca7a5578ff061978a62fb

View File

@@ -1 +1 @@
42a626ace126f730f33ecb6c41ac5679d6766a31 5fadb464eb77b4b998d8555f83401769960ea904

View File

@@ -22,7 +22,7 @@
** COMMIT ** COMMIT
** ROLLBACK ** ROLLBACK
** **
** $Id: build.c,v 1.320 2005/05/22 06:49:57 danielk1977 Exp $ ** $Id: build.c,v 1.321 2005/05/24 12:01:02 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -1077,76 +1077,6 @@ void sqlite3AddCollateType(Parse *pParse, const char *zType, int nType){
} }
} }
/*
** Locate and return an entry from the db.aCollSeq hash table. If the entry
** specified by zName and nName is not found and parameter 'create' is
** true, then create a new entry. Otherwise return NULL.
**
** Each pointer stored in the sqlite3.aCollSeq hash table contains an
** array of three CollSeq structures. The first is the collation sequence
** prefferred for UTF-8, the second UTF-16le, and the third UTF-16be.
**
** Stored immediately after the three collation sequences is a copy of
** the collation sequence name. A pointer to this string is stored in
** each collation sequence structure.
*/
static CollSeq * findCollSeqEntry(
sqlite3 *db,
const char *zName,
int nName,
int create
){
CollSeq *pColl;
if( nName<0 ) nName = strlen(zName);
pColl = sqlite3HashFind(&db->aCollSeq, zName, nName);
if( 0==pColl && create ){
pColl = sqliteMalloc( 3*sizeof(*pColl) + nName + 1 );
if( pColl ){
CollSeq *pDel = 0;
pColl[0].zName = (char*)&pColl[3];
pColl[0].enc = SQLITE_UTF8;
pColl[1].zName = (char*)&pColl[3];
pColl[1].enc = SQLITE_UTF16LE;
pColl[2].zName = (char*)&pColl[3];
pColl[2].enc = SQLITE_UTF16BE;
memcpy(pColl[0].zName, zName, nName);
pColl[0].zName[nName] = 0;
pDel = sqlite3HashInsert(&db->aCollSeq, pColl[0].zName, nName, pColl);
/* If a malloc() failure occured in sqlite3HashInsert(), it will
** return the pColl pointer to be deleted (because it wasn't added
** to the hash table).
*/
assert( !pDel || (sqlite3_malloc_failed && pDel==pColl) );
sqliteFree(pDel);
}
}
return pColl;
}
/*
** Parameter zName points to a UTF-8 encoded string nName bytes long.
** Return the CollSeq* pointer for the collation sequence named zName
** for the encoding 'enc' from the database 'db'.
**
** If the entry specified is not found and 'create' is true, then create a
** new entry. Otherwise return NULL.
*/
CollSeq *sqlite3FindCollSeq(
sqlite3 *db,
u8 enc,
const char *zName,
int nName,
int create
){
CollSeq *pColl = findCollSeqEntry(db, zName, nName, create);
assert( SQLITE_UTF8==1 && SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
assert( enc>=SQLITE_UTF8 && enc<=SQLITE_UTF16BE );
if( pColl ) pColl += enc-1;
return pColl;
}
/* /*
** Invoke the 'collation needed' callback to request a collation sequence ** Invoke the 'collation needed' callback to request a collation sequence
** in the database text encoding of name zName, length nName. ** in the database text encoding of name zName, length nName.
@@ -2911,19 +2841,6 @@ void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){
} }
} }
#ifndef SQLITE_OMIT_UTF16
/*
** Return the transient sqlite3_value object used for encoding conversions
** during SQL compilation.
*/
sqlite3_value *sqlite3GetTransientValue(sqlite3 *db){
if( !db->pValue ){
db->pValue = sqlite3ValueNew();
}
return db->pValue;
}
#endif
/* /*
** Check to see if pIndex uses the collating sequence pColl. Return ** Check to see if pIndex uses the collating sequence pColl. Return
** true if it does and false if it does not. ** true if it does and false if it does not.

190
src/callback.c Normal file
View File

@@ -0,0 +1,190 @@
/*
** 2005 May 23
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains functions used to access the internal hash tables
** of user defined functions and collation sequences.
**
** $Id: callback.c,v 1.1 2005/05/24 12:01:02 danielk1977 Exp $
*/
#include "sqliteInt.h"
/*
** Locate and return an entry from the db.aCollSeq hash table. If the entry
** specified by zName and nName is not found and parameter 'create' is
** true, then create a new entry. Otherwise return NULL.
**
** Each pointer stored in the sqlite3.aCollSeq hash table contains an
** array of three CollSeq structures. The first is the collation sequence
** prefferred for UTF-8, the second UTF-16le, and the third UTF-16be.
**
** Stored immediately after the three collation sequences is a copy of
** the collation sequence name. A pointer to this string is stored in
** each collation sequence structure.
*/
static CollSeq * findCollSeqEntry(
sqlite3 *db,
const char *zName,
int nName,
int create
){
CollSeq *pColl;
if( nName<0 ) nName = strlen(zName);
pColl = sqlite3HashFind(&db->aCollSeq, zName, nName);
if( 0==pColl && create ){
pColl = sqliteMalloc( 3*sizeof(*pColl) + nName + 1 );
if( pColl ){
CollSeq *pDel = 0;
pColl[0].zName = (char*)&pColl[3];
pColl[0].enc = SQLITE_UTF8;
pColl[1].zName = (char*)&pColl[3];
pColl[1].enc = SQLITE_UTF16LE;
pColl[2].zName = (char*)&pColl[3];
pColl[2].enc = SQLITE_UTF16BE;
memcpy(pColl[0].zName, zName, nName);
pColl[0].zName[nName] = 0;
pDel = sqlite3HashInsert(&db->aCollSeq, pColl[0].zName, nName, pColl);
/* If a malloc() failure occured in sqlite3HashInsert(), it will
** return the pColl pointer to be deleted (because it wasn't added
** to the hash table).
*/
assert( !pDel || (sqlite3_malloc_failed && pDel==pColl) );
sqliteFree(pDel);
}
}
return pColl;
}
/*
** Parameter zName points to a UTF-8 encoded string nName bytes long.
** Return the CollSeq* pointer for the collation sequence named zName
** for the encoding 'enc' from the database 'db'.
**
** If the entry specified is not found and 'create' is true, then create a
** new entry. Otherwise return NULL.
*/
CollSeq *sqlite3FindCollSeq(
sqlite3 *db,
u8 enc,
const char *zName,
int nName,
int create
){
CollSeq *pColl = findCollSeqEntry(db, zName, nName, create);
assert( SQLITE_UTF8==1 && SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
assert( enc>=SQLITE_UTF8 && enc<=SQLITE_UTF16BE );
if( pColl ) pColl += enc-1;
return pColl;
}
/*
** Locate a user function given a name, a number of arguments and a flag
** indicating whether the function prefers UTF-16 over UTF-8. Return a
** pointer to the FuncDef structure that defines that function, or return
** NULL if the function does not exist.
**
** If the createFlag argument is true, then a new (blank) FuncDef
** structure is created and liked into the "db" structure if a
** no matching function previously existed. When createFlag is true
** and the nArg parameter is -1, then only a function that accepts
** any number of arguments will be returned.
**
** If createFlag is false and nArg is -1, then the first valid
** function found is returned. A function is valid if either xFunc
** or xStep is non-zero.
**
** If createFlag is false, then a function with the required name and
** number of arguments may be returned even if the eTextRep flag does not
** match that requested.
*/
FuncDef *sqlite3FindFunction(
sqlite3 *db, /* An open database */
const char *zName, /* Name of the function. Not null-terminated */
int nName, /* Number of characters in the name */
int nArg, /* Number of arguments. -1 means any number */
u8 enc, /* Preferred text encoding */
int createFlag /* Create new entry if true and does not otherwise exist */
){
FuncDef *p; /* Iterator variable */
FuncDef *pFirst; /* First function with this name */
FuncDef *pBest = 0; /* Best match found so far */
int bestmatch = 0;
assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
if( nArg<-1 ) nArg = -1;
pFirst = (FuncDef*)sqlite3HashFind(&db->aFunc, zName, nName);
for(p=pFirst; p; p=p->pNext){
/* During the search for the best function definition, bestmatch is set
** as follows to indicate the quality of the match with the definition
** pointed to by pBest:
**
** 0: pBest is NULL. No match has been found.
** 1: A variable arguments function that prefers UTF-8 when a UTF-16
** encoding is requested, or vice versa.
** 2: A variable arguments function that uses UTF-16BE when UTF-16LE is
** requested, or vice versa.
** 3: A variable arguments function using the same text encoding.
** 4: A function with the exact number of arguments requested that
** prefers UTF-8 when a UTF-16 encoding is requested, or vice versa.
** 5: A function with the exact number of arguments requested that
** prefers UTF-16LE when UTF-16BE is requested, or vice versa.
** 6: An exact match.
**
** A larger value of 'matchqual' indicates a more desirable match.
*/
if( p->nArg==-1 || p->nArg==nArg || nArg==-1 ){
int match = 1; /* Quality of this match */
if( p->nArg==nArg || nArg==-1 ){
match = 4;
}
if( enc==p->iPrefEnc ){
match += 2;
}
else if( (enc==SQLITE_UTF16LE && p->iPrefEnc==SQLITE_UTF16BE) ||
(enc==SQLITE_UTF16BE && p->iPrefEnc==SQLITE_UTF16LE) ){
match += 1;
}
if( match>bestmatch ){
pBest = p;
bestmatch = match;
}
}
}
/* If the createFlag parameter is true, and the seach did not reveal an
** exact match for the name, number of arguments and encoding, then add a
** new entry to the hash table and return it.
*/
if( createFlag && bestmatch<6 &&
(pBest = sqliteMalloc(sizeof(*pBest)+nName+1)) ){
pBest->nArg = nArg;
pBest->pNext = pFirst;
pBest->zName = (char*)&pBest[1];
pBest->iPrefEnc = enc;
memcpy(pBest->zName, zName, nName);
pBest->zName[nName] = 0;
if( pBest==sqlite3HashInsert(&db->aFunc,pBest->zName,nName,(void*)pBest) ){
sqliteFree(pBest);
return 0;
}
}
if( pBest && (pBest->xStep || pBest->xFunc || createFlag) ){
return pBest;
}
return 0;
}

View File

@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and ** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite. ** for generating VDBE code that evaluates expressions in SQLite.
** **
** $Id: expr.c,v 1.200 2005/05/23 17:26:51 drh Exp $ ** $Id: expr.c,v 1.201 2005/05/24 12:01:02 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -2049,104 +2049,3 @@ int sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){
walkExprTree(pExpr, analyzeAggregate, pNC); walkExprTree(pExpr, analyzeAggregate, pNC);
return pNC->pParse->nErr - nErr; return pNC->pParse->nErr - nErr;
} }
/*
** Locate a user function given a name, a number of arguments and a flag
** indicating whether the function prefers UTF-16 over UTF-8. Return a
** pointer to the FuncDef structure that defines that function, or return
** NULL if the function does not exist.
**
** If the createFlag argument is true, then a new (blank) FuncDef
** structure is created and liked into the "db" structure if a
** no matching function previously existed. When createFlag is true
** and the nArg parameter is -1, then only a function that accepts
** any number of arguments will be returned.
**
** If createFlag is false and nArg is -1, then the first valid
** function found is returned. A function is valid if either xFunc
** or xStep is non-zero.
**
** If createFlag is false, then a function with the required name and
** number of arguments may be returned even if the eTextRep flag does not
** match that requested.
*/
FuncDef *sqlite3FindFunction(
sqlite3 *db, /* An open database */
const char *zName, /* Name of the function. Not null-terminated */
int nName, /* Number of characters in the name */
int nArg, /* Number of arguments. -1 means any number */
u8 enc, /* Preferred text encoding */
int createFlag /* Create new entry if true and does not otherwise exist */
){
FuncDef *p; /* Iterator variable */
FuncDef *pFirst; /* First function with this name */
FuncDef *pBest = 0; /* Best match found so far */
int bestmatch = 0;
assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
if( nArg<-1 ) nArg = -1;
pFirst = (FuncDef*)sqlite3HashFind(&db->aFunc, zName, nName);
for(p=pFirst; p; p=p->pNext){
/* During the search for the best function definition, bestmatch is set
** as follows to indicate the quality of the match with the definition
** pointed to by pBest:
**
** 0: pBest is NULL. No match has been found.
** 1: A variable arguments function that prefers UTF-8 when a UTF-16
** encoding is requested, or vice versa.
** 2: A variable arguments function that uses UTF-16BE when UTF-16LE is
** requested, or vice versa.
** 3: A variable arguments function using the same text encoding.
** 4: A function with the exact number of arguments requested that
** prefers UTF-8 when a UTF-16 encoding is requested, or vice versa.
** 5: A function with the exact number of arguments requested that
** prefers UTF-16LE when UTF-16BE is requested, or vice versa.
** 6: An exact match.
**
** A larger value of 'matchqual' indicates a more desirable match.
*/
if( p->nArg==-1 || p->nArg==nArg || nArg==-1 ){
int match = 1; /* Quality of this match */
if( p->nArg==nArg || nArg==-1 ){
match = 4;
}
if( enc==p->iPrefEnc ){
match += 2;
}
else if( (enc==SQLITE_UTF16LE && p->iPrefEnc==SQLITE_UTF16BE) ||
(enc==SQLITE_UTF16BE && p->iPrefEnc==SQLITE_UTF16LE) ){
match += 1;
}
if( match>bestmatch ){
pBest = p;
bestmatch = match;
}
}
}
/* If the createFlag parameter is true, and the seach did not reveal an
** exact match for the name, number of arguments and encoding, then add a
** new entry to the hash table and return it.
*/
if( createFlag && bestmatch<6 &&
(pBest = sqliteMalloc(sizeof(*pBest)+nName+1)) ){
pBest->nArg = nArg;
pBest->pNext = pFirst;
pBest->zName = (char*)&pBest[1];
pBest->iPrefEnc = enc;
memcpy(pBest->zName, zName, nName);
pBest->zName[nName] = 0;
if( pBest==sqlite3HashInsert(&db->aFunc,pBest->zName,nName,(void*)pBest) ){
sqliteFree(pBest);
return 0;
}
}
if( pBest && (pBest->xStep || pBest->xFunc || createFlag) ){
return pBest;
}
return 0;
}

View File

@@ -16,7 +16,7 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope. ** All other code has file scope.
** **
** $Id: func.c,v 1.97 2005/05/22 10:44:34 danielk1977 Exp $ ** $Id: func.c,v 1.98 2005/05/24 12:01:02 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -1037,7 +1037,6 @@ void sqlite3RegisterBuiltinFunctions(sqlite3 *db){
sqlite3RegisterDateTimeFunctions(db); sqlite3RegisterDateTimeFunctions(db);
#ifdef SQLITE_SSE #ifdef SQLITE_SSE
{ {
extern int sqlite3SseFunctions(sqlite3*);
sqlite3SseFunctions(db); sqlite3SseFunctions(db);
} }
#endif #endif

View File

@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be ** other files are for internal use by SQLite and should not be
** accessed by users of the library. ** accessed by users of the library.
** **
** $Id: main.c,v 1.288 2005/05/23 04:51:02 danielk1977 Exp $ ** $Id: main.c,v 1.289 2005/05/24 12:01:02 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "os.h" #include "os.h"
@@ -47,6 +47,19 @@ static void corruptSchema(InitData *pData, const char *zExtra){
} }
} }
#ifndef SQLITE_OMIT_UTF16
/*
** Return the transient sqlite3_value object used for encoding conversions
** during SQL compilation.
*/
sqlite3_value *sqlite3GetTransientValue(sqlite3 *db){
if( !db->pValue ){
db->pValue = sqlite3ValueNew();
}
return db->pValue;
}
#endif
/* /*
** This is the callback routine for the code that initializes the ** This is the callback routine for the code that initializes the
** database. See sqlite3Init() below for additional information. ** database. See sqlite3Init() below for additional information.

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** Internal interface definitions for SQLite. ** Internal interface definitions for SQLite.
** **
** @(#) $Id: sqliteInt.h,v 1.381 2005/05/23 04:51:02 danielk1977 Exp $ ** @(#) $Id: sqliteInt.h,v 1.382 2005/05/24 12:01:02 danielk1977 Exp $
*/ */
#ifndef _SQLITEINT_H_ #ifndef _SQLITEINT_H_
#define _SQLITEINT_H_ #define _SQLITEINT_H_
@@ -1578,4 +1578,8 @@ void sqlite3AlterFinishAddColumn(Parse *, Token *);
void sqlite3AlterBeginAddColumn(Parse *, SrcList *); void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
const char *sqlite3TestErrorName(int); const char *sqlite3TestErrorName(int);
#ifdef SQLITE_SSE
#include "sseInt.h"
#endif
#endif #endif

View File

@@ -14,7 +14,7 @@
** Most of the code in this file may be omitted by defining the ** Most of the code in this file may be omitted by defining the
** SQLITE_OMIT_VACUUM macro. ** SQLITE_OMIT_VACUUM macro.
** **
** $Id: vacuum.c,v 1.43 2005/05/23 13:00:58 danielk1977 Exp $ ** $Id: vacuum.c,v 1.44 2005/05/24 12:01:02 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "os.h" #include "os.h"
@@ -311,7 +311,6 @@ end_of_vacuum:
** in the sqlite_statements table after a successful VACUUM ** in the sqlite_statements table after a successful VACUUM
*/ */
if( rc==SQLITE_OK ){ if( rc==SQLITE_OK ){
extern int sqlite3RecompileStatements(sqlite3*);
rc = sqlite3RecompileStatements(db); rc = sqlite3RecompileStatements(db);
if( rc!=SQLITE_OK ){ if( rc!=SQLITE_OK ){
sqlite3SetString(pzErrMsg, sqlite3_errmsg(db), (char *)0); sqlite3SetString(pzErrMsg, sqlite3_errmsg(db), (char *)0);