/ Check-in [ff45f9dd]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix another problem in fts5 caused by a corrupt schema record.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ff45f9dd69fe1e1c7875e5bb73ac3dde2a31746475d3765cda9233f8e06e26ca
User & Date: dan 2018-12-27 15:36:16
Context
2018-12-27
16:55
Modify the btree02.test module so that it does not depend on whether TCL interprets a value as a string or as an integer. check-in: d9e4f957 user: drh tags: trunk
15:36
Fix another problem in fts5 caused by a corrupt schema record. check-in: ff45f9dd user: dan tags: trunk
13:52
Fix the filename normalization in the dbtotxt utility program. check-in: 29a00a05 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to ext/fts5/fts5_index.c.

   856    856     if( piCookie ) *piCookie = sqlite3Fts5Get32(pData);
   857    857     i = 4;
   858    858   
   859    859     /* Read the total number of levels and segments from the start of the
   860    860     ** structure record.  */
   861    861     i += fts5GetVarint32(&pData[i], nLevel);
   862    862     i += fts5GetVarint32(&pData[i], nSegment);
          863  +  if( nLevel>FTS5_MAX_SEGMENT || nSegment>FTS5_MAX_SEGMENT ){
          864  +    return FTS5_CORRUPT;
          865  +  }
   863    866     nByte = (
   864    867         sizeof(Fts5Structure) +                    /* Main structure */
   865    868         sizeof(Fts5StructureLevel) * (nLevel-1)    /* aLevel[] array */
   866    869     );
   867    870     pRet = (Fts5Structure*)sqlite3Fts5MallocZero(&rc, nByte);
   868    871   
   869    872     if( pRet ){

Changes to ext/fts5/test/fts5corrupt3.test.

  1037   1037   |   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
  1038   1038   | end c17.db
  1039   1039   }]} {}
  1040   1040   
  1041   1041   do_catchsql_test 16.1 {
  1042   1042   INSERT INTO t1(t1) VALUES('integrity-check');
  1043   1043   } {1 {vtable constructor failed: t1}}
         1044  +
         1045  +#--------------------------------------------------------------------------
         1046  +reset_db
         1047  +do_test 17.0 {
         1048  +  sqlite3 db {}
         1049  +  db deserialize [decode_hexdb {
         1050  +| size 28672 pagesize 4096 filename c18.db
         1051  +| page 1 offset 0
         1052  +|      0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00   SQLite format 3.
         1053  +|     16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 07   .....@  ........
         1054  +|     32: 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00 00   ................
         1055  +|     48: 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00   ................
         1056  +|     96: 00 00 00 00 0d 00 00 00 07 0d d2 00 0f c4 0f 6d   ...............m
         1057  +|    112: 0f 02 0e ab 0e 4e 0d f6 0d d2 00 00 00 00 00 00   .....N..........
         1058  +|   3536: 00 00 22 07 06 17 11 11 01 31 74 61 62 6c 65 74   .........1tablet
         1059  +|   3552: 32 74 32 07 43 52 45 41 54 45 20 54 41 42 4c 45   2t2.CREATE TABLE
         1060  +|   3568: 20 74 32 28 78 29 56 06 06 17 1f 1f 01 7d 74 61    t2(x)V.......ta
         1061  +|   3584: 62 6c 65 74 31 5f 63 6f 6e 66 69 67 74 31 5f 63   blet1_configt1_c
         1062  +|   3600: 6f 6e 66 69 67 06 43 52 45 41 54 45 20 54 41 42   onfig.CREATE TAB
         1063  +|   3616: 4c 45 20 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b   LE 't1_config'(k
         1064  +|   3632: 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29    PRIMARY KEY, v)
         1065  +|   3648: 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5b 05    WITHOUT ROWID[.
         1066  +|   3664: 07 17 21 21 01 81 01 74 61 62 6c 65 74 31 5f 64   ..!!...tablet1_d
         1067  +|   3680: 6f 63 73 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65   ocsizet1_docsize
         1068  +|   3696: 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74   .CREATE TABLE 't
         1069  +|   3712: 31 5f 64 6f 63 73 69 7a 65 27 28 69 64 20 49 4e   1_docsize'(id IN
         1070  +|   3728: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45   TEGER PRIMARY KE
         1071  +|   3744: 59 2c 20 73 7a 20 42 4c 4f 42 29 55 04 06 17 21   Y, sz BLOB)U...!
         1072  +|   3760: 21 01 77 74 61 62 6c 65 74 31 5f 63 6f 6e 74 65   !.wtablet1_conte
         1073  +|   3776: 6e 74 74 31 5f 63 6f 6e 74 65 6e 74 04 43 52 45   ntt1_content.CRE
         1074  +|   3792: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 63 6f   ATE TABLE 't1_co
         1075  +|   3808: 6e 74 65 6e 74 27 28 69 64 20 49 4e 54 45 47 45   ntent'(id INTEGE
         1076  +|   3824: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 63   R PRIMARY KEY, c
         1077  +|   3840: 30 29 69 03 07 17 19 19 01 81 2d 74 61 62 6c 65   0)i.......-table
         1078  +|   3856: 74 31 5f 69 64 78 74 31 5f 69 64 78 03 43 52 45   t1_idxt1_idx.CRE
         1079  +|   3872: 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 69 64   ATE TABLE 't1_id
         1080  +|   3888: 78 27 28 73 65 67 69 64 2c 20 74 65 72 6d 2c 20   x'(segid, term, 
         1081  +|   3904: 70 67 6e 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45   pgno, PRIMARY KE
         1082  +|   3920: 59 28 73 65 67 69 64 2c 20 74 65 72 6d 29 29 20   Y(segid, term)) 
         1083  +|   3936: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 55 02 07   WITHOUT ROWIDU..
         1084  +|   3952: 17 1b 1b 01 81 01 74 61 62 6c 65 74 31 5f 64 61   ......tablet1_da
         1085  +|   3968: 74 61 74 31 5f 64 61 74 61 02 43 52 45 41 54 45   tat1_data.CREATE
         1086  +|   3984: 20 54 41 42 4c 45 20 27 74 31 5f 64 61 74 61 27    TABLE 't1_data'
         1087  +|   4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d   (id INTEGER PRIM
         1088  +|   4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42   ARY KEY, block B
         1089  +|   4032: 4c 4f 42 29 3a 01 06 17 11 11 08 63 74 61 62 6c   LOB):......ctabl
         1090  +|   4048: 65 74 31 74 31 43 52 45 41 54 45 20 56 49 52 54   et1t1CREATE VIRT
         1091  +|   4064: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49   UAL TABLE t1 USI
         1092  +|   4080: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29   NG fts5(content)
         1093  +| page 2 offset 4096
         1094  +|      0: 0d 00 00 00 03 0f bd 00 0f e8 0f ef 0f bd 00 00   ................
         1095  +|   4016: 00 00 00 00 00 00 00 00 00 00 00 00 00 24 84 80   .............$..
         1096  +|   4032: 80 80 80 01 03 00 4e 00 00 00 1e 06 30 61 62 61   ......N.....0aba
         1097  +|   4048: 63 6b 01 02 02 04 02 66 74 00 02 22 04 04 6e 64   ck.....ft.....nd
         1098  +|   4064: 6f 6e 03 02 02 04 0a 07 05 01 03 00 10 03 03 0f   on..............
         1099  +|   4080: 0a 03 00 24 00 00 0a aa aa aa aa aa aa aa aa aa   ...$............
         1100  +| page 3 offset 8192
         1101  +|      0: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa   ................
         1102  +|     16: aa aa aa aa aa aa aa aa 00 00 10 10 10 00 10 10   ................
         1103  +|     32: 10 10 a0 00 00 00 10 ff a0 00 ff 52 05 64 95 25   ...........R.d.%
         1104  +|     48: 45 54 14 c2 05 44 14 24 c4 52 07 43 12 05 55 34   ET...D.$.R.C..U4
         1105  +|     64: 94 e4 72 06 67 47 33 52 86 36 f6 e7 46 56 e7 42   ..r.gG3R.6..FV.B
         1106  +|     80: 90 d0 00 00 00 30 fb d0 00 fe 80 fe f0 fb 00 00   .....0..........
         1107  +|   4080: 00 00 00 00 00 00 00 00 00 00 05 04 09 0c 01 02   ................
         1108  +| page 4 offset 12288
         1109  +|      0: 0d 00 00 00 03 0f e0 00 0f f6 0f ec 0f e0 00 00   ................
         1110  +|   4064: 0a 03 03 00 1b 61 62 61 6e 64 6f 6e 08 02 03 00   .....abandon....
         1111  +|   4080: 17 61 62 61 66 74 08 01 03 00 17 61 62 61 63 6b   .abaft.....aback
         1112  +| page 5 offset 16384
         1113  +|      0: 0d 00 00 00 03 0f ee 00 0f fa 0f f4 0f ee 00 00   ................
         1114  +|   4064: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03   ................
         1115  +|   4080: 03 00 0e 01 04 02 03 00 0e 01 04 01 03 00 0e 01   ................
         1116  +| page 6 offset 20480
         1117  +|      0: 0a 00 00 00 01 0f f4 00 0f f4 00 00 00 00 00 00   ................
         1118  +|   4080: 00 00 00 00 0b 03 1b 01 76 65 72 73 69 6f 6e 04   ........version.
         1119  +| page 7 offset 24576
         1120  +|      0: 0d 00 00 00 03 0f d6 00 0f f4 0f e1 0f d6 00 00   ................
         1121  +|   4048: 00 00 00 00 00 00 09 03 02 1b 72 65 62 75 69 6c   ..........rebuil
         1122  +|   4064: 64 11 02 02 2b 69 6e 74 65 67 72 69 74 79 2d 63   d...+integrity-c
         1123  +|   4080: 68 65 63 6b 0a 01 02 1d 6f 70 74 69 6d 69 7a 65   heck....optimize
         1124  +| end c18.db
         1125  +}]} {}
         1126  +
         1127  +do_catchsql_test 17.1 {
         1128  +  SELECT * FROM t1 WHERE t1 MATCH 'abandon';
         1129  +} {1 {vtable constructor failed: t1}}
  1044   1130   
  1045   1131   sqlite3_fts5_may_be_corrupt 0
  1046   1132   finish_test
  1047   1133