| Index: third_party/sqlite/src/src/callback.c
|
| diff --git a/third_party/sqlite/src/src/callback.c b/third_party/sqlite/src/src/callback.c
|
| index 492e4206f98706f2f65791ae1ba1058a0c53a760..ce849085c22d2b41b315ce9810f3754239269a7d 100644
|
| --- a/third_party/sqlite/src/src/callback.c
|
| +++ b/third_party/sqlite/src/src/callback.c
|
| @@ -12,8 +12,6 @@
|
| **
|
| ** This file contains functions used to access the internal hash tables
|
| ** of user defined functions and collation sequences.
|
| -**
|
| -** $Id: callback.c,v 1.42 2009/06/17 00:35:31 drh Exp $
|
| */
|
|
|
| #include "sqliteInt.h"
|
| @@ -355,14 +353,19 @@ FuncDef *sqlite3FindFunction(
|
|
|
| /* If no match is found, search the built-in functions.
|
| **
|
| + ** If the SQLITE_PreferBuiltin flag is set, then search the built-in
|
| + ** functions even if a prior app-defined function was found. And give
|
| + ** priority to built-in functions.
|
| + **
|
| ** Except, if createFlag is true, that means that we are trying to
|
| - ** install a new function. Whatever FuncDef structure is returned will
|
| + ** install a new function. Whatever FuncDef structure is returned it will
|
| ** have fields overwritten with new information appropriate for the
|
| ** new function. But the FuncDefs for built-in functions are read-only.
|
| ** So we must not search for built-ins when creating a new function.
|
| */
|
| - if( !createFlag && !pBest ){
|
| + if( !createFlag && (pBest==0 || (db->flags & SQLITE_PreferBuiltin)!=0) ){
|
| FuncDefHash *pHash = &GLOBAL(FuncDefHash, sqlite3GlobalFunctions);
|
| + bestScore = 0;
|
| p = functionSearch(pHash, h, zName, nName);
|
| while( p ){
|
| int score = matchQuality(p, nArg, enc);
|
| @@ -397,12 +400,12 @@ FuncDef *sqlite3FindFunction(
|
| /*
|
| ** Free all resources held by the schema structure. The void* argument points
|
| ** at a Schema struct. This function does not call sqlite3DbFree(db, ) on the
|
| -** pointer itself, it just cleans up subsiduary resources (i.e. the contents
|
| +** pointer itself, it just cleans up subsidiary resources (i.e. the contents
|
| ** of the schema hash tables).
|
| **
|
| ** The Schema.cache_size variable is not cleared.
|
| */
|
| -void sqlite3SchemaFree(void *p){
|
| +void sqlite3SchemaClear(void *p){
|
| Hash temp1;
|
| Hash temp2;
|
| HashElem *pElem;
|
| @@ -419,12 +422,15 @@ void sqlite3SchemaFree(void *p){
|
| sqlite3HashInit(&pSchema->tblHash);
|
| for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){
|
| Table *pTab = sqliteHashData(pElem);
|
| - assert( pTab->dbMem==0 );
|
| - sqlite3DeleteTable(pTab);
|
| + sqlite3DeleteTable(0, pTab);
|
| }
|
| sqlite3HashClear(&temp1);
|
| + sqlite3HashClear(&pSchema->fkeyHash);
|
| pSchema->pSeqTab = 0;
|
| - pSchema->flags &= ~DB_SchemaLoaded;
|
| + if( pSchema->flags & DB_SchemaLoaded ){
|
| + pSchema->iGeneration++;
|
| + pSchema->flags &= ~DB_SchemaLoaded;
|
| + }
|
| }
|
|
|
| /*
|
| @@ -434,9 +440,9 @@ void sqlite3SchemaFree(void *p){
|
| Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){
|
| Schema * p;
|
| if( pBt ){
|
| - p = (Schema *)sqlite3BtreeSchema(pBt, sizeof(Schema), sqlite3SchemaFree);
|
| + p = (Schema *)sqlite3BtreeSchema(pBt, sizeof(Schema), sqlite3SchemaClear);
|
| }else{
|
| - p = (Schema *)sqlite3MallocZero(sizeof(Schema));
|
| + p = (Schema *)sqlite3DbMallocZero(0, sizeof(Schema));
|
| }
|
| if( !p ){
|
| db->mallocFailed = 1;
|
| @@ -444,6 +450,7 @@ Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){
|
| sqlite3HashInit(&p->tblHash);
|
| sqlite3HashInit(&p->idxHash);
|
| sqlite3HashInit(&p->trigHash);
|
| + sqlite3HashInit(&p->fkeyHash);
|
| p->enc = SQLITE_UTF8;
|
| }
|
| return p;
|
|
|