Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add test cases to cover fts5 integrity-check code. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
1d018c35b9e81982df036f5e62a4a422 |
User & Date: | dan 2015-09-15 14:39:17.597 |
Context
2015-09-16
| ||
12:31 | Fix typo in fts5.h. (check-in: 07721c6c24 user: dan tags: trunk) | |
2015-09-15
| ||
19:16 | Merge enhancements from trunk. (check-in: fc4d1de8ae user: drh tags: begin-concurrent) | |
17:31 | Merge enhancements from trunk. (check-in: 66fe068326 user: drh tags: cursor-hints) | |
17:20 | Merge trunk enhancements into the apple-osx branch. (check-in: f12b8a0f79 user: drh tags: apple-osx) | |
15:55 | Merge the latest trunk enhancements with this branch. (check-in: b7469c44be user: dan tags: sessions) | |
14:39 | Add test cases to cover fts5 integrity-check code. (check-in: 1d018c35b9 user: dan tags: trunk) | |
13:42 | Reformat some code to make it easier to merge with sessions. No logic changes. (check-in: eade355faf user: drh tags: trunk) | |
Changes
Changes to ext/fts5/fts5_index.c.
︙ | ︙ | |||
4850 4851 4852 4853 4854 4855 4856 | for(i=iFirst; p->rc==SQLITE_OK && i<=iLast; i++){ Fts5Data *pLeaf = fts5DataRead(p, FTS5_SEGMENT_ROWID(pSeg->iSegid, i)); if( pLeaf ){ if( !fts5LeafIsTermless(pLeaf) ) p->rc = FTS5_CORRUPT; if( i>=iNoRowid && 0!=fts5LeafFirstRowidOff(pLeaf) ) p->rc = FTS5_CORRUPT; } fts5DataRelease(pLeaf); | < | 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 | for(i=iFirst; p->rc==SQLITE_OK && i<=iLast; i++){ Fts5Data *pLeaf = fts5DataRead(p, FTS5_SEGMENT_ROWID(pSeg->iSegid, i)); if( pLeaf ){ if( !fts5LeafIsTermless(pLeaf) ) p->rc = FTS5_CORRUPT; if( i>=iNoRowid && 0!=fts5LeafFirstRowidOff(pLeaf) ) p->rc = FTS5_CORRUPT; } fts5DataRelease(pLeaf); } } static void fts5IntegrityCheckPgidx(Fts5Index *p, Fts5Data *pLeaf){ int iTermOff = 0; int ii; |
︙ | ︙ | |||
4917 4918 4919 4920 4921 4922 4923 | int rc2; int iIdxPrevLeaf = pSeg->pgnoFirst-1; int iDlidxPrevLeaf = pSeg->pgnoLast; if( pSeg->pgnoFirst==0 ) return; fts5IndexPrepareStmt(p, &pStmt, sqlite3_mprintf( | | | 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 | int rc2; int iIdxPrevLeaf = pSeg->pgnoFirst-1; int iDlidxPrevLeaf = pSeg->pgnoLast; if( pSeg->pgnoFirst==0 ) return; fts5IndexPrepareStmt(p, &pStmt, sqlite3_mprintf( "SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d", pConfig->zDb, pConfig->zName, pSeg->iSegid )); /* Iterate through the b-tree hierarchy. */ while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ i64 iRow; /* Rowid for this leaf */ Fts5Data *pLeaf; /* Data for this leaf */ |
︙ | ︙ |
Changes to ext/fts5/test/fts5corrupt3.test.
︙ | ︙ | |||
150 151 152 153 154 155 156 | set doc "x[string repeat $rnd 20]" execsql { INSERT INTO t1(rowid, x) VALUES($i, $doc) } } } {} do_3_test 3.10 | < < | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | set doc "x[string repeat $rnd 20]" execsql { INSERT INTO t1(rowid, x) VALUES($i, $doc) } } } {} do_3_test 3.10 #------------------------------------------------------------------------- # Test that segments that end unexpectedly are identified as corruption. # reset_db do_test 4.0 { execsql { CREATE VIRTUAL TABLE t1 USING fts5(x); |
︙ | ︙ | |||
248 249 250 251 252 253 254 | } set {} {} } {} catch { db eval ROLLBACK } } } | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | } set {} {} } {} catch { db eval ROLLBACK } } } } #------------------------------------------------------------------------ # reset_db do_execsql_test 6.1.0 { CREATE VIRTUAL TABLE t1 USING fts5(a); INSERT INTO t1 VALUES('bbbbb ccccc'); SELECT quote(block) FROM t1_data WHERE rowid>100; } {X'000000180630626262626201020201056363636363010203040A'} do_execsql_test 6.1.1 { UPDATE t1_data SET block = X'000000180630626262626201020201056161616161010203040A' WHERE rowid>100; } do_catchsql_test 6.1.2 { INSERT INTO t1(t1) VALUES('integrity-check'); } {1 {database disk image is malformed}} #------- reset_db do_execsql_test 6.2.0 { CREATE VIRTUAL TABLE t1 USING fts5(a); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); INSERT INTO t1 VALUES('aa bb cc dd ee'); SELECT pgno, quote(term) FROM t1_idx; } {2 X'' 4 X'3064'} do_execsql_test 6.2.1 { UPDATE t1_idx SET term = X'3065' WHERE pgno=4; } do_catchsql_test 6.2.2 { INSERT INTO t1(t1) VALUES('integrity-check'); } {1 {database disk image is malformed}} #------- reset_db do_execsql_test 6.3.0 { CREATE VIRTUAL TABLE t1 USING fts5(a); INSERT INTO t1 VALUES('abc abcdef abcdefghi'); SELECT quote(block) FROM t1_data WHERE id>100; } {X'0000001C043061626301020204036465660102030703676869010204040808'} do_execsql_test 6.3.1 { BEGIN; UPDATE t1_data SET block = X'0000001C043061626301020204036465660102035003676869010204040808' ------------------------------------------^^--------------------- WHERE id>100; } do_catchsql_test 6.3.2 { INSERT INTO t1(t1) VALUES('integrity-check'); } {1 {database disk image is malformed}} do_execsql_test 6.3.3 { ROLLBACK; BEGIN; UPDATE t1_data SET block = X'0000001C043061626301020204036465660102030750676869010204040808' --------------------------------------------^^------------------- WHERE id>100; } do_catchsql_test 6.3.3 { INSERT INTO t1(t1) VALUES('integrity-check'); } {1 {database disk image is malformed}} do_execsql_test 6.3.4 { ROLLBACK; BEGIN; UPDATE t1_data SET block = X'0000001C043061626301020204036465660102030707676869010204040850' --------------------------------------------------------------^^- WHERE id>100; } do_catchsql_test 6.3.5 { INSERT INTO t1(t1) VALUES('integrity-check'); } {1 {database disk image is malformed}} do_execsql_test 6.3.6 { ROLLBACK; BEGIN; UPDATE t1_data SET block = X'0000001C503061626301020204036465660102030707676869010204040808' ----------^^----------------------------------------------------- WHERE id>100; } do_catchsql_test 6.3.5 { INSERT INTO t1(t1) VALUES('integrity-check'); } {1 {database disk image is malformed}} sqlite3_fts5_may_be_corrupt 0 finish_test |