| OLD | NEW |
| 1 /* fts2 has a design flaw which can lead to database corruption (see | 1 /* fts2 has a design flaw which can lead to database corruption (see |
| 2 ** below). It is recommended not to use it any longer, instead use | 2 ** below). It is recommended not to use it any longer, instead use |
| 3 ** fts3 (or higher). If you believe that your use of fts2 is safe, | 3 ** fts3 (or higher). If you believe that your use of fts2 is safe, |
| 4 ** add -DSQLITE_ENABLE_BROKEN_FTS2=1 to your CFLAGS. | 4 ** add -DSQLITE_ENABLE_BROKEN_FTS2=1 to your CFLAGS. |
| 5 */ | 5 */ |
| 6 #if (!defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2)) \ | 6 #if (!defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2)) \ |
| 7 && !defined(SQLITE_ENABLE_BROKEN_FTS2) | 7 && !defined(SQLITE_ENABLE_BROKEN_FTS2) |
| 8 #error fts2 has a design flaw and has been deprecated. | 8 #error fts2 has a design flaw and has been deprecated. |
| 9 #endif | 9 #endif |
| 10 /* The flaw is that fts2 uses the content table's unaliased rowid as | 10 /* The flaw is that fts2 uses the content table's unaliased rowid as |
| (...skipping 1820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 /* CONTENT_EXISTS */ "select rowid from %_content limit 1", | 1831 /* CONTENT_EXISTS */ "select rowid from %_content limit 1", |
| 1832 | 1832 |
| 1833 /* BLOCK_INSERT */ "insert into %_segments values (?)", | 1833 /* BLOCK_INSERT */ "insert into %_segments values (?)", |
| 1834 /* BLOCK_SELECT */ "select block from %_segments where rowid = ?", | 1834 /* BLOCK_SELECT */ "select block from %_segments where rowid = ?", |
| 1835 /* BLOCK_DELETE */ "delete from %_segments where rowid between ? and ?", | 1835 /* BLOCK_DELETE */ "delete from %_segments where rowid between ? and ?", |
| 1836 /* BLOCK_DELETE_ALL */ "delete from %_segments", | 1836 /* BLOCK_DELETE_ALL */ "delete from %_segments", |
| 1837 | 1837 |
| 1838 /* SEGDIR_MAX_INDEX */ "select max(idx) from %_segdir where level = ?", | 1838 /* SEGDIR_MAX_INDEX */ "select max(idx) from %_segdir where level = ?", |
| 1839 /* SEGDIR_SET */ "insert into %_segdir values (?, ?, ?, ?, ?, ?)", | 1839 /* SEGDIR_SET */ "insert into %_segdir values (?, ?, ?, ?, ?, ?)", |
| 1840 /* SEGDIR_SELECT_LEVEL */ | 1840 /* SEGDIR_SELECT_LEVEL */ |
| 1841 "select start_block, leaves_end_block, root from %_segdir " | 1841 "select start_block, leaves_end_block, root, idx from %_segdir " |
| 1842 " where level = ? order by idx", | 1842 " where level = ? order by idx", |
| 1843 /* SEGDIR_SPAN */ | 1843 /* SEGDIR_SPAN */ |
| 1844 "select min(start_block), max(end_block) from %_segdir " | 1844 "select min(start_block), max(end_block) from %_segdir " |
| 1845 " where level = ? and start_block <> 0", | 1845 " where level = ? and start_block <> 0", |
| 1846 /* SEGDIR_DELETE */ "delete from %_segdir where level = ?", | 1846 /* SEGDIR_DELETE */ "delete from %_segdir where level = ?", |
| 1847 | 1847 |
| 1848 /* NOTE(shess): The first three results of the following two | 1848 /* NOTE(shess): The first three results of the following two |
| 1849 ** statements must match. | 1849 ** statements must match. |
| 1850 */ | 1850 */ |
| 1851 /* SEGDIR_SELECT_SEGMENT */ | 1851 /* SEGDIR_SELECT_SEGMENT */ |
| (...skipping 3428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5280 | 5280 |
| 5281 rc = sqlite3_bind_int(s, 1, iLevel); | 5281 rc = sqlite3_bind_int(s, 1, iLevel); |
| 5282 if( rc!=SQLITE_OK ) return rc; | 5282 if( rc!=SQLITE_OK ) return rc; |
| 5283 | 5283 |
| 5284 i = 0; | 5284 i = 0; |
| 5285 while( (rc = sqlite3_step(s))==SQLITE_ROW ){ | 5285 while( (rc = sqlite3_step(s))==SQLITE_ROW ){ |
| 5286 sqlite_int64 iStart = sqlite3_column_int64(s, 0); | 5286 sqlite_int64 iStart = sqlite3_column_int64(s, 0); |
| 5287 sqlite_int64 iEnd = sqlite3_column_int64(s, 1); | 5287 sqlite_int64 iEnd = sqlite3_column_int64(s, 1); |
| 5288 const char *pRootData = sqlite3_column_blob(s, 2); | 5288 const char *pRootData = sqlite3_column_blob(s, 2); |
| 5289 int nRootData = sqlite3_column_bytes(s, 2); | 5289 int nRootData = sqlite3_column_bytes(s, 2); |
| 5290 sqlite_int64 iIndex = sqlite3_column_int64(s, 3); |
| 5290 | 5291 |
| 5291 /* Corrupt if we get back different types than we stored. */ | 5292 /* Corrupt if we get back different types than we stored. */ |
| 5293 /* Also corrupt if the index is not sequential starting at 0. */ |
| 5292 if( sqlite3_column_type(s, 0)!=SQLITE_INTEGER || | 5294 if( sqlite3_column_type(s, 0)!=SQLITE_INTEGER || |
| 5293 sqlite3_column_type(s, 1)!=SQLITE_INTEGER || | 5295 sqlite3_column_type(s, 1)!=SQLITE_INTEGER || |
| 5294 sqlite3_column_type(s, 2)!=SQLITE_BLOB ){ | 5296 sqlite3_column_type(s, 2)!=SQLITE_BLOB || |
| 5297 i != iIndex){ |
| 5295 rc = SQLITE_CORRUPT_BKPT; | 5298 rc = SQLITE_CORRUPT_BKPT; |
| 5296 break; | 5299 break; |
| 5297 } | 5300 } |
| 5298 | 5301 |
| 5299 assert( i<MERGE_COUNT ); | 5302 assert( i<MERGE_COUNT ); |
| 5300 rc = leavesReaderInit(v, i, iStart, iEnd, pRootData, nRootData, | 5303 rc = leavesReaderInit(v, i, iStart, iEnd, pRootData, nRootData, |
| 5301 &pReaders[i]); | 5304 &pReaders[i]); |
| 5302 if( rc!=SQLITE_OK ) break; | 5305 if( rc!=SQLITE_OK ) break; |
| 5303 | 5306 |
| 5304 i++; | 5307 i++; |
| (...skipping 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6995 sqlite3 *db, | 6998 sqlite3 *db, |
| 6996 char **pzErrMsg, | 6999 char **pzErrMsg, |
| 6997 const sqlite3_api_routines *pApi | 7000 const sqlite3_api_routines *pApi |
| 6998 ){ | 7001 ){ |
| 6999 SQLITE_EXTENSION_INIT2(pApi) | 7002 SQLITE_EXTENSION_INIT2(pApi) |
| 7000 return sqlite3Fts2Init(db); | 7003 return sqlite3Fts2Init(db); |
| 7001 } | 7004 } |
| 7002 #endif | 7005 #endif |
| 7003 | 7006 |
| 7004 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */ | 7007 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */ |
| OLD | NEW |