/ Check-in [ddc2b7ec]
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 bugs in fts3 function matchinfo() when used with deferred tokens.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fts3-experimental
Files: files | file ages | folders
SHA1: ddc2b7ec2618b010c981ecfa05b3e53a9fac686f
User & Date: dan 2010-11-25 10:33:54
Context
2010-11-25
17:49
Add coverage tests (and associated fixes) for new matchinfo() code. check-in: 70495cec user: dan tags: fts3-experimental
10:33
Fix bugs in fts3 function matchinfo() when used with deferred tokens. check-in: ddc2b7ec user: dan tags: fts3-experimental
2010-11-24
19:26
Add code for the matchinfo 'longest common substring' feature. check-in: 71011a4f user: dan tags: fts3-experimental
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3_snippet.c.

1150
1151
1152
1153
1154
1155
1156


1157
1158
1159
1160
1161
1162
1163

1164
1165
1166
1167


1168

1169
1170
1171
1172
1173
1174
1175
        }
        sqlite3_reset(pSelectDocsize);
        break;
      }

      case FTS3_MATCHINFO_HITS: {
        Fts3Expr *pExpr = pCsr->pExpr;


        if( bGlobal ){
          if( pCsr->pDeferred ){
            rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc, 0);
          }
          (void)fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);
        }
        (void)fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo);

        break;
      }

      case FTS3_MATCHINFO_LCS:


        fts3MatchinfoLcs(pCsr, pInfo);

        break;

      default:
        assert( !"this cannot happen" );
    }

    pInfo->aMatchinfo += fts3MatchinfoSize(pInfo, zArg[i]);







>
>
|
|
|
|
|
|
|
>




>
>
|
>







1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
        }
        sqlite3_reset(pSelectDocsize);
        break;
      }

      case FTS3_MATCHINFO_HITS: {
        Fts3Expr *pExpr = pCsr->pExpr;
        rc = fts3ExprLoadDoclists(pCsr, 0, 0);
        if( rc==SQLITE_OK ){
          if( bGlobal ){
            if( pCsr->pDeferred ){
              rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc, 0);
            }
            (void)fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);
          }
          (void)fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo);
        }
        break;
      }

      case FTS3_MATCHINFO_LCS:
        rc = fts3ExprLoadDoclists(pCsr, 0, 0);
        if( rc==SQLITE_OK ){
          fts3MatchinfoLcs(pCsr, pInfo);
        }
        break;

      default:
        assert( !"this cannot happen" );
    }

    pInfo->aMatchinfo += fts3MatchinfoSize(pInfo, zArg[i]);

Changes to test/fts3matchinfo.test.

222
223
224
225
226
227
228

229
230



231
232
233
234
235
236
237
238
239
240




241
242
243
244
245
246
247

248
249
250
251

252

253
254
255
256
257
258
259
260
261
262
do_matchinfo_test 4.1.6 t4 {t4 MATCH 'd d'}     { s {{1 0} {0 1}} }

do_execsql_test 4.2.0 {
  CREATE VIRTUAL TABLE t5 USING fts4;
  INSERT INTO t5 VALUES('a a a a a');
  INSERT INTO t5 VALUES('a b a b a');
  INSERT INTO t5 VALUES('c b c b c');

}
do_matchinfo_test 4.2.1 t5 {t5 MATCH 'a a'}         { s {2 1} }



do_matchinfo_test 4.2.2 t5 {t5 MATCH 'a b'}         { s {2} }
do_matchinfo_test 4.2.3 t5 {t5 MATCH 'a b a'}       { s {3} }
do_matchinfo_test 4.2.4 t5 {t5 MATCH 'a a a'}       { s {3 1} }
do_matchinfo_test 4.2.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
do_matchinfo_test 4.2.6 t5 {t5 MATCH 'a OR b'}      { s {1 2 1} }

do_execsql_test 4.3.0 "INSERT INTO t5 VALUES('x y [string repeat {b } 50000]')";
do_execsql_test 4.3.0 "INSERT INTO t5 VALUES('x y [string repeat {x } 50000]')";

#do_matchinfo_test 4.3.1 t5 {t5 MATCH 'a a'}         { s {2 1} }




#do_matchinfo_test 4.3.2 t5 {t5 MATCH 'a b'}         { s {2} }
#do_matchinfo_test 4.3.3 t5 {t5 MATCH 'a b a'}       { s {3} }
#do_matchinfo_test 4.3.4 t5 {t5 MATCH 'a a a'}       { s {3 1} }
#do_matchinfo_test 4.3.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
#do_matchinfo_test 4.3.6 t5 {t5 MATCH 'a OR b'}      { s {1 2 1 1} }
#
#do_execsql_test 4.4.0 {

#  UPDATE t5_segments 
#  SET block = zeroblob(length(block)) 
#  WHERE length(block)>10000;
#}

#

#do_matchinfo_test 4.4.1 t5 {t5 MATCH 'a a'}         { s {2 1} }
#do_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'}         { s {2} }
#do_matchinfo_test 4.4.3 t5 {t5 MATCH 'a b a'}       { s {3} }
#do_matchinfo_test 4.4.4 t5 {t5 MATCH 'a a a'}       { s {3 1} }
#do_matchinfo_test 4.4.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
#do_matchinfo_test 4.4.6 t5 {t5 MATCH 'a OR b'}      { s {1 2 1 1} }


finish_test








>

|
>
>
>







<

|
>
>
>
>
|
|
|
|
|
|
|
>
|
|
|
<
>
|
>
|
|
|
|
|
<




222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241

242
243
244
245
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
do_matchinfo_test 4.1.6 t4 {t4 MATCH 'd d'}     { s {{1 0} {0 1}} }

do_execsql_test 4.2.0 {
  CREATE VIRTUAL TABLE t5 USING fts4;
  INSERT INTO t5 VALUES('a a a a a');
  INSERT INTO t5 VALUES('a b a b a');
  INSERT INTO t5 VALUES('c b c b c');
  INSERT INTO t5 VALUES('x x x x x');
}
do_matchinfo_test 4.2.1 t5 {t5 MATCH 'a a'}         { 
  x {{5 8 2   5 8 2} {3 8 2   3 8 2}}
  s {2 1} 
}
do_matchinfo_test 4.2.2 t5 {t5 MATCH 'a b'}         { s {2} }
do_matchinfo_test 4.2.3 t5 {t5 MATCH 'a b a'}       { s {3} }
do_matchinfo_test 4.2.4 t5 {t5 MATCH 'a a a'}       { s {3 1} }
do_matchinfo_test 4.2.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
do_matchinfo_test 4.2.6 t5 {t5 MATCH 'a OR b'}      { s {1 2 1} }

do_execsql_test 4.3.0 "INSERT INTO t5 VALUES('x y [string repeat {b } 50000]')";


do_matchinfo_test 4.3.1 t5 {t5 MATCH 'a a'} { 
  x {{5 8 2   5 5 5} {3 8 2   3 5 5}}
  s {2 1} 
}

do_matchinfo_test 4.3.2 t5 {t5 MATCH 'a b'}         { s {2} }
do_matchinfo_test 4.3.3 t5 {t5 MATCH 'a b a'}       { s {3} }
do_matchinfo_test 4.3.4 t5 {t5 MATCH 'a a a'}       { s {3 1} }
do_matchinfo_test 4.3.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
do_matchinfo_test 4.3.6 t5 {t5 MATCH 'a OR b'}      { s {1 2 1 1} }

do_execsql_test 4.4.0 {
  INSERT INTO t5(t5) VALUES('optimize');
  UPDATE t5_segments 
  SET block = zeroblob(length(block)) 
  WHERE length(block)>10000;

}

do_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'}         { s {2} }
do_matchinfo_test 4.4.1 t5 {t5 MATCH 'a a'}         { s {2 1} }
do_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'}         { s {2} }
do_matchinfo_test 4.4.3 t5 {t5 MATCH 'a b a'}       { s {3} }
do_matchinfo_test 4.4.4 t5 {t5 MATCH 'a a a'}       { s {3 1} }
do_matchinfo_test 4.4.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }



finish_test