Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;
int bDesc = ((idxNum & FTS5_ORDER_DESC) ? 1 : 0);
int rc = SQLITE_OK;
+ char **pzErrmsg = pTab->pConfig->pzErrmsg;
+
+ assert( pzErrmsg==0 || pzErrmsg==&pTab->base.zErrMsg );
+ pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg;
assert( nVal<=2 );
assert( pCsr->pStmt==0 );
}
}
+ pTab->pConfig->pzErrmsg = pzErrmsg;
return rc;
}
/* A transaction must be open when this is called. */
assert( pTab->ts.eState==1 );
+ assert( pTab->pConfig->pzErrmsg==0 );
+ pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg;
+
/* A delete specifies a single argument - the rowid of the row to remove.
** Update and insert operations pass:
**
if( pConfig->eContent!=FTS5_CONTENT_NORMAL
&& 0==sqlite3_stricmp("delete", z)
){
- return fts5SpecialDelete(pTab, apVal, pRowid);
+ rc = fts5SpecialDelete(pTab, apVal, pRowid);
}else{
- return fts5SpecialInsert(pTab, pCmd, apVal[2 + pConfig->nCol + 1]);
+ rc = fts5SpecialInsert(pTab, pCmd, apVal[2 + pConfig->nCol + 1]);
}
+ goto update_method_out;
}
}
rc = sqlite3Fts5StorageInsert(pTab->pStorage, apVal, eConflict, pRowid);
}
+ update_method_out:
+ pTab->pConfig->pzErrmsg = 0;
return rc;
}
int rc;
Fts5Table *pTab = (Fts5Table*)pVtab;
fts5CheckTransactionState(pTab, FTS5_SYNC, 0);
+ pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg;
fts5TripCursors(pTab);
rc = sqlite3Fts5StorageSync(pTab->pStorage, 1);
+ pTab->pConfig->pzErrmsg = 0;
return rc;
}
**
** zContentExprlist:
**
+** pzErrmsg:
+** This exists in order to allow the fts5_index.c module to return a
+** decent error message if it encounters a file-format version it does
+** not understand.
+**
*/
struct Fts5Config {
sqlite3 *db; /* Database handle */
int nCrisisMerge; /* Maximum allowed segments per level */
char *zRank; /* Name of rank function */
char *zRankArgs; /* Arguments to rank function */
+
+ /* If non-NULL, points to sqlite3_vtab.base.zErrmsg. Often NULL. */
+ char **pzErrmsg;
};
/* Current expected value of %_config table 'version' field */
}
if( rc==SQLITE_OK && iVersion!=FTS5_CURRENT_VERSION ){
- rc = sqlite3Fts5Corrupt();
+ rc = SQLITE_ERROR;
+ if( pConfig->pzErrmsg ){
+ assert( 0==*pConfig->pzErrmsg );
+ *pConfig->pzErrmsg = sqlite3_mprintf(
+ "invalid fts5 file format (found %d, expected %d) - run 'rebuild'",
+ iVersion, FTS5_CURRENT_VERSION
+ );
+ }
}
if( rc==SQLITE_OK ){
--- /dev/null
+# 2015 Apr 24
+#
+# 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.
+#
+#***********************************************************************
+#
+# The tests in this file focus on testing that unrecognized file-format
+# versions are detected and reported.
+#
+
+source [file join [file dirname [info script]] fts5_common.tcl]
+set testprefix fts5version
+
+
+do_execsql_test 1.1 {
+ CREATE VIRTUAL TABLE t1 USING fts5(one);
+ INSERT INTO t1 VALUES('a b c d');
+} {}
+
+do_execsql_test 1.2 {
+ SELECT * FROM t1_config WHERE k='version'
+} {version 1}
+
+do_execsql_test 1.3 {
+ SELECT rowid FROM t1 WHERE t1 MATCH 'a';
+} {1}
+
+do_execsql_test 1.4 {
+ UPDATE t1_config set v=2 WHERE k='version';
+}
+
+do_test 1.5 {
+ db close
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH 'a' }
+} {1 {invalid fts5 file format (found 2, expected 1) - run 'rebuild'}}
+
+breakpoint
+do_test 1.6 {
+ db close
+ sqlite3 db test.db
+ catchsql { INSERT INTO t1 VALUES('x y z') }
+} {1 {invalid fts5 file format (found 2, expected 1) - run 'rebuild'}}
+
+do_test 1.7 {
+ execsql { DELETE FROM t1_config WHERE k='version' }
+ db close
+ sqlite3 db test.db
+ catchsql { SELECT * FROM t1 WHERE t1 MATCH 'a' }
+} {1 {invalid fts5 file format (found 0, expected 1) - run 'rebuild'}}
+
+
+finish_test
+
-C Change\sto\sstoring\sall\skeys\sin\sa\ssingle\smerge-tree\sstructure\sinstead\sof\sone\smain\sstructure\sand\sa\sseparate\sone\sfor\seach\sprefix\sindex.\sThis\sis\sa\sfile-format\schange.\sAlso\sintroduce\sa\smechanism\sfor\smanaging\sfile-format\schanges.
-D 2015-05-07T19:29:46.763
+C Improve\sthe\serror\smessage\sreturned\sby\sFTS5\sif\sit\sencounters\san\sunknown\sfile\sformat.
+D 2015-05-08T09:21:05.416
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 31b38b9da2e4b36f54a013bd71a5c3f6e45ca78f
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7
F ext/fts3/unicode/mkunicode.tcl 159c1194da0bc72f51b3c2eb71022568006dc5ad
F ext/fts5/extract_api_docs.tcl 55a6d648d516f35d9a1e580ac00de27154e1904a
-F ext/fts5/fts5.c 62b2657320aac309d7bcf2bfb855f8d4c216ae15
+F ext/fts5/fts5.c 7f58ea9ba1e72038137963719c5b5335f499cecd
F ext/fts5/fts5.h 24a2cc35b5e76eec57b37ba48c12d9d2cb522b3a
-F ext/fts5/fts5Int.h 94b1800ea50e52ce19365744174c65e6fc8b87e0
+F ext/fts5/fts5Int.h be8ac04ce40705aa088c3d2509cadad0f98085fa
F ext/fts5/fts5_aux.c d53f00f31ad615ca4f139dd8751f9041afa00971
F ext/fts5/fts5_buffer.c 70b971e13503566f1e257941c60817ba0920a16b
-F ext/fts5/fts5_config.c 7a8b4665239a4f3001a4ecbc77573c42d2694161
+F ext/fts5/fts5_config.c 05811f0bd80c396afcf3ceea68da16149a9a3258
F ext/fts5/fts5_expr.c 3fe1170453d6a322d2de8a3fd0aed3edff7b8b09
F ext/fts5/fts5_hash.c 54dd25348a46ea62ea96322c572e08cd1fb37304
F ext/fts5/fts5_index.c aa8d73d043417740c07861beb78c86103a6a9d90
F ext/fts5/test/fts5unicode.test 79b3e34eb29ce4929628aa514a40cb467fdabe4d
F ext/fts5/test/fts5unicode2.test 64a5267fd6082fcb46439892ebd0cbaa5c38acee
F ext/fts5/test/fts5unindexed.test f388605341a476b6ab622b4c267cd168f59a5944
+F ext/fts5/test/fts5version.test 1c902eaa7359336293ac45c7a34616527513e9fb
F ext/fts5/tool/loadfts5.tcl 8a8f10d7d2d0d77f622e0a84cc0824c158c34a52
F ext/fts5/tool/showfts5.tcl 921f33b30c3189deefd2b2cc81f951638544aaf1
F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P c4456dc5f5f8f45f04e3bbae53b6bcc209fc27d5
-R d535b9198036ecff3827ebadb9a9b6f4
+P a684b5e2d9d52cf4700e7e5f9dd547a2ba54e8e9
+R ee87a64da50ec14a005ebb86ec227c20
U dan
-Z 02d7c47a9ec4004e437813912cd05f33
+Z 8aaf7ae5929104d0a1ed12733f883e2b
-a684b5e2d9d52cf4700e7e5f9dd547a2ba54e8e9
\ No newline at end of file
+f369caec145f311bb136cf7af144e2695badcb9b
\ No newline at end of file