aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2012-08-21 17:44:05 +0000
committerdrh <drh@noemail.net>2012-08-21 17:44:05 +0000
commit07893776089d93dc6b40270c6a5119554c26b97c (patch)
treefe176ba15965542814377f544c98a5f5cb54d66b /src
parent4dc3d73d6950660df19fc373ae440aea37a06a57 (diff)
downloadsqlite-07893776089d93dc6b40270c6a5119554c26b97c.tar.gz
sqlite-07893776089d93dc6b40270c6a5119554c26b97c.zip
Update the spellfix virtual table so that all OOM errors are reported out
to the application. FossilOrigin-Name: 573770f5a66fa4d708931b30350149eb739da607
Diffstat (limited to 'src')
-rw-r--r--src/test_spellfix.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/test_spellfix.c b/src/test_spellfix.c
index ec73b0b3c..68247fed0 100644
--- a/src/test_spellfix.c
+++ b/src/test_spellfix.c
@@ -2508,15 +2508,17 @@ static int spellfix1Filter(
*/
static int spellfix1Next(sqlite3_vtab_cursor *cur){
spellfix1_cursor *pCur = (spellfix1_cursor *)cur;
+ int rc = SQLITE_OK;
if( pCur->iRow < pCur->nRow ){
if( pCur->pFullScan ){
- int rc = sqlite3_step(pCur->pFullScan);
+ rc = sqlite3_step(pCur->pFullScan);
if( rc!=SQLITE_ROW ) pCur->iRow = pCur->nRow;
+ if( rc==SQLITE_ROW || rc==SQLITE_DONE ) rc = SQLITE_OK;
}else{
pCur->iRow++;
}
}
- return SQLITE_OK;
+ return rc;
}
/*
@@ -2773,25 +2775,35 @@ static sqlite3_module spellfix1Module = {
** Register the various functions and the virtual table.
*/
static int spellfix1Register(sqlite3 *db){
- int nErr = 0;
+ int rc = SQLITE_OK;
int i;
- nErr += sqlite3_create_function(db, "spellfix1_translit", 1, SQLITE_UTF8, 0,
+ rc = sqlite3_create_function(db, "spellfix1_translit", 1, SQLITE_UTF8, 0,
transliterateSqlFunc, 0, 0);
- nErr += sqlite3_create_function(db, "spellfix1_editdist", 2, SQLITE_UTF8, 0,
+ if( rc==SQLITE_OK ){
+ rc = sqlite3_create_function(db, "spellfix1_editdist", 2, SQLITE_UTF8, 0,
editdistSqlFunc, 0, 0);
- nErr += sqlite3_create_function(db, "spellfix1_phonehash", 1, SQLITE_UTF8, 0,
+ }
+ if( rc==SQLITE_OK ){
+ rc = sqlite3_create_function(db, "spellfix1_phonehash", 1, SQLITE_UTF8, 0,
phoneticHashSqlFunc, 0, 0);
- nErr += sqlite3_create_function(db, "spellfix1_scriptcode", 1, SQLITE_UTF8, 0,
+ }
+ if( rc==SQLITE_OK ){
+ rc = sqlite3_create_function(db, "spellfix1_scriptcode", 1, SQLITE_UTF8, 0,
scriptCodeSqlFunc, 0, 0);
- nErr += sqlite3_create_module(db, "spellfix1", &spellfix1Module, 0);
- nErr += editDist3Install(db);
+ }
+ if( rc==SQLITE_OK ){
+ rc = sqlite3_create_module(db, "spellfix1", &spellfix1Module, 0);
+ }
+ if( rc==SQLITE_OK ){
+ rc = editDist3Install(db);
+ }
/* Verify sanity of the translit[] table */
for(i=0; i<sizeof(translit)/sizeof(translit[0])-1; i++){
assert( translit[i].cFrom<translit[i+1].cFrom );
}
- return nErr ? SQLITE_ERROR : SQLITE_OK;
+ return rc;
}
#if SQLITE_CORE || defined(SQLITE_TEST)