#define FTS3_MATCHINFO_LENGTH 'l' /* nCol values */
#define FTS3_MATCHINFO_LCS 's' /* nCol values */
#define FTS3_MATCHINFO_HITS 'x' /* 3*nCol*nPhrase values */
+#define FTS3_MATCHINFO_LHITS 'y' /* nCol*nPhrase values */
/*
** The default value for the second argument to matchinfo().
return rc;
}
+/*
+** fts3ExprIterate() callback used to gather information for the matchinfo
+** directive 'y'.
+*/
+static int fts3ExprLHitsCb(
+ Fts3Expr *pExpr, /* Phrase expression node */
+ int iPhrase, /* Phrase number */
+ void *pCtx /* Pointer to MatchInfo structure */
+){
+ MatchInfo *p = (MatchInfo *)pCtx;
+ Fts3Table *pTab = (Fts3Table *)p->pCursor->base.pVtab;
+ int rc = SQLITE_OK;
+ int iStart = iPhrase * p->nCol;
+ Fts3Expr *pEof; /* Ancestor node already at EOF */
+
+ /* This must be a phrase */
+ assert( pExpr->pPhrase );
+
+ /* Initialize all output integers to zero. */
+ memset(&p->aMatchinfo[iStart], 0, sizeof(u32) * p->nCol);
+
+ /* Check if this or any parent node is at EOF. If so, then all output
+ ** values are zero. */
+ for(pEof=pExpr; pEof && pEof->bEof==0; pEof=pEof->pParent);
+
+ if( pEof==0 && pExpr->iDocid==p->pCursor->iPrevId ){
+ Fts3Phrase *pPhrase = pExpr->pPhrase;
+ char *pIter = pPhrase->doclist.pList;
+ int iCol = 0;
+
+ while( 1 ){
+ int nHit = fts3ColumnlistCount(&pIter);
+ if( (pPhrase->iColumn>=pTab->nColumn || pPhrase->iColumn==iCol) ){
+ p->aMatchinfo[iStart + iCol] = (u32)nHit;
+ }
+ assert( *pIter==0x00 || *pIter==0x01 );
+ if( *pIter!=0x01 ) break;
+ pIter++;
+ pIter += fts3GetVarint32(pIter, &iCol);
+ }
+ }
+
+ return rc;
+}
+
static int fts3MatchinfoCheck(
Fts3Table *pTab,
char cArg,
|| (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)
|| (cArg==FTS3_MATCHINFO_LCS)
|| (cArg==FTS3_MATCHINFO_HITS)
+ || (cArg==FTS3_MATCHINFO_LHITS)
){
return SQLITE_OK;
}
nVal = pInfo->nCol;
break;
+ case FTS3_MATCHINFO_LHITS:
+ nVal = pInfo->nCol * pInfo->nPhrase;
+ break;
+
default:
assert( cArg==FTS3_MATCHINFO_HITS );
nVal = pInfo->nCol * pInfo->nPhrase * 3;
}
break;
+ case FTS3_MATCHINFO_LHITS:
+ (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLHitsCb, (void*)pInfo);
+ break;
+
default: {
Fts3Expr *pExpr;
assert( zArg[i]==FTS3_MATCHINFO_HITS );
-C Enhance\sthe\sfuzzershell\s--uniquecases\soption\sto\soutput\sresults\sin\sorder\sof\nincreasing\sruntime\sand\sto\sinclude\sthe\sruntime\sin\sthe\scomment\sseparator\sof\nthe\soutput.
-D 2015-05-01T20:34:47.283
+C Add\sthe\sexperimental\smatchinfo\s'y'\sflag\sto\sfts3/4.
+D 2015-05-02T09:44:15.512
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in e628c50e237251fc7e768bef14ee7e822ad69e69
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F ext/fts3/fts3_hash.h 39cf6874dc239d6b4e30479b1975fe5b22a3caaf
F ext/fts3/fts3_icu.c e319e108661147bcca8dd511cd562f33a1ba81b5
F ext/fts3/fts3_porter.c 3565faf04b626cddf85f03825e86056a4562c009
-F ext/fts3/fts3_snippet.c 0ce4ee2451b9f3603a1693ef9779bb0fb662a9fe
+F ext/fts3/fts3_snippet.c 40a96ba78e90aba7d7d6d014a18049bb218060fd
F ext/fts3/fts3_term.c 88c55a6fa1a51ab494e33dced0401a6c28791fd7
F ext/fts3/fts3_test.c 8a3a78c4458b2d7c631fcf4b152a5cd656fa7038
F ext/fts3/fts3_tokenize_vtab.c a27593ab19657166f6fa5ec073b678cc29a75860
F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641
F test/fts3join.test 53e66a0c21eb568580674a43b21c059acb26f499
F test/fts3malloc.test b0e4c133b8d61d4f6d112d8110f8320e9e453ef6
-F test/fts3matchinfo.test 58544fa4d254000fa4e7f494b0a832f7ba61d45e
+F test/fts3matchinfo.test 3e5f5ac2e0a8ba42eafd4c685f803ca48b4c3a83
F test/fts3near.test 7e3354d46f155a822b59c0e957fd2a70c1d7e905
F test/fts3prefix.test fa794eaab0bdae466494947b0b153d7844478ab2
F test/fts3prefix2.test e1f0a822ca661dced7f12ce392e14eaf65609dce
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P ab5523aafe4817232388d28ea99be0953e7dccf3
-R 4fd9e5d40fbea2385d9a56050bcd9320
-U drh
-Z 553d78dd29d30462935dd4f96d370f3a
+P 04630b989d8794b9ed2553f4d223de2b322437c5
+R 609861034508ca4e227e94341a24112e
+T *branch * fts3-matchinfo-y
+T *sym-fts3-matchinfo-y *
+T -sym-trunk *
+U dan
+Z 0627f347fc7cc3989ff7a94e2d2c43c4
-04630b989d8794b9ed2553f4d223de2b322437c5
\ No newline at end of file
+92941609af74044b3078e020324a37b04a0638b0
\ No newline at end of file
ORDER BY 1;
} {1 1 one 2 2 two 3 3 three}
+#---------------------------------------------------------------------------
+# Test the 'y' matchinfo flag
+#
+set sqlite_fts3_enable_parentheses 1
+reset_db
+do_execsql_test 11.0 {
+ CREATE VIRTUAL TABLE tt USING fts3(x, y);
+ INSERT INTO tt VALUES('c d a c d d', 'e a g b d a'); -- 1
+ INSERT INTO tt VALUES('c c g a e b', 'c g d g e c'); -- 2
+ INSERT INTO tt VALUES('b e f d e g', 'b a c b c g'); -- 3
+ INSERT INTO tt VALUES('a c f f g d', 'd b f d e g'); -- 4
+ INSERT INTO tt VALUES('g a c f c f', 'd g g b c c'); -- 5
+ INSERT INTO tt VALUES('g a c e b b', 'd b f b g g'); -- 6
+ INSERT INTO tt VALUES('f d a a f c', 'e e a d c f'); -- 7
+ INSERT INTO tt VALUES('a c b b g f', 'a b a e d f'); -- 8
+ INSERT INTO tt VALUES('b a f e c c', 'f d b b a b'); -- 9
+ INSERT INTO tt VALUES('f d c e a c', 'f a f a a f'); -- 10
+}
+
+db func mit mit
+foreach {tn expr res} {
+ 1 "a" {
+ 1 {1 2} 2 {1 0} 3 {0 1} 4 {1 0} 5 {1 0}
+ 6 {1 0} 7 {2 1} 8 {1 2} 9 {1 1} 10 {1 3}
+ }
+
+ 2 "b" {
+ 1 {0 1} 2 {1 0} 3 {1 2} 4 {0 1} 5 {0 1}
+ 6 {2 2} 8 {2 1} 9 {1 3}
+ }
+
+ 3 "y:a" {
+ 1 {0 2} 3 {0 1}
+ 7 {0 1} 8 {0 2} 9 {0 1} 10 {0 3}
+ }
+
+ 4 "x:a" {
+ 1 {1 0} 2 {1 0} 4 {1 0} 5 {1 0}
+ 6 {1 0} 7 {2 0} 8 {1 0} 9 {1 0} 10 {1 0}
+ }
+
+ 5 "a OR b" {
+ 1 {1 2 0 1} 2 {1 0 1 0} 3 {0 1 1 2} 4 {1 0 0 1} 5 {1 0 0 1}
+ 6 {1 0 2 2} 7 {2 1 0 0} 8 {1 2 2 1} 9 {1 1 1 3} 10 {1 3 0 0}
+ }
+
+ 6 "a AND b" {
+ 1 {1 2 0 1} 2 {1 0 1 0} 3 {0 1 1 2} 4 {1 0 0 1} 5 {1 0 0 1}
+ 6 {1 0 2 2} 8 {1 2 2 1} 9 {1 1 1 3}
+ }
+
+ 7 "a OR (a AND b)" {
+ 1 {1 2 1 2 0 1} 2 {1 0 1 0 1 0} 3 {0 1 0 1 1 2} 4 {1 0 1 0 0 1}
+ 5 {1 0 1 0 0 1} 6 {1 0 1 0 2 2} 7 {2 1 0 0 0 0} 8 {1 2 1 2 2 1}
+ 9 {1 1 1 1 1 3} 10 {1 3 0 0 0 0}
+ }
+
+} {
+ do_execsql_test 11.1.$tn {
+ SELECT rowid, mit(matchinfo(tt, 'y')) FROM tt WHERE tt MATCH $expr
+ } $res
+}
+set sqlite_fts3_enable_parentheses 0
finish_test