aboutsummaryrefslogtreecommitdiff
path: root/src/callback.c
diff options
context:
space:
mode:
authormistachkin <mistachkin@noemail.net>2018-10-29 17:53:23 +0000
committermistachkin <mistachkin@noemail.net>2018-10-29 17:53:23 +0000
commit8bee11a41ef9a90f8c9046db725dcf962700127c (patch)
treebf451e5b6610a94dc20ae737b96411cceabecf31 /src/callback.c
parentdbe7d37ae8e69a1e5252dca2c83badb471ff1310 (diff)
downloadsqlite-8bee11a41ef9a90f8c9046db725dcf962700127c.tar.gz
sqlite-8bee11a41ef9a90f8c9046db725dcf962700127c.zip
Add the sqlite3_normalized_sql() API.
FossilOrigin-Name: 592b66e8058dd03a056a036e2606247c9efdb06d15eebe9bcc455f7f55e30ae6
Diffstat (limited to 'src/callback.c')
-rw-r--r--src/callback.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/callback.c b/src/callback.c
index a629b6825..faf6d520c 100644
--- a/src/callback.c
+++ b/src/callback.c
@@ -295,6 +295,21 @@ static FuncDef *functionSearch(
}
return 0;
}
+#ifdef SQLITE_ENABLE_NORMALIZE
+FuncDef *sqlite3FunctionSearchN(
+ int h, /* Hash of the name */
+ const char *zFunc, /* Name of function */
+ int nFunc /* Length of the name */
+){
+ FuncDef *p;
+ for(p=sqlite3BuiltinFunctions.a[h]; p; p=p->u.pHash){
+ if( sqlite3StrNICmp(p->zName, zFunc, nFunc)==0 ){
+ return p;
+ }
+ }
+ return 0;
+}
+#endif /* SQLITE_ENABLE_NORMALIZE */
/*
** Insert a new FuncDef into a FuncDefHash hash table.
@@ -308,7 +323,7 @@ void sqlite3InsertBuiltinFuncs(
FuncDef *pOther;
const char *zName = aDef[i].zName;
int nName = sqlite3Strlen30(zName);
- int h = (zName[0] + nName) % SQLITE_FUNC_HASH_SZ;
+ int h = SQLITE_FUNC_HASH(zName[0], nName);
assert( zName[0]>='a' && zName[0]<='z' );
pOther = functionSearch(h, zName);
if( pOther ){
@@ -387,7 +402,7 @@ FuncDef *sqlite3FindFunction(
*/
if( !createFlag && (pBest==0 || (db->mDbFlags & DBFLAG_PreferBuiltin)!=0) ){
bestScore = 0;
- h = (sqlite3UpperToLower[(u8)zName[0]] + nName) % SQLITE_FUNC_HASH_SZ;
+ h = SQLITE_FUNC_HASH(sqlite3UpperToLower[(u8)zName[0]], nName);
p = functionSearch(h, zName);
while( p ){
int score = matchQuality(p, nArg, enc);