From: dan Date: Tue, 15 Sep 2015 11:58:33 +0000 (+0000) Subject: Fix a problem with fts5 "ORDER BY rowid DESC" queries and large terms. X-Git-Tag: version-3.9.0~105 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=128ea696eac4dc6619820b0386f7fd226b96eeec;p=thirdparty%2Fsqlite.git Fix a problem with fts5 "ORDER BY rowid DESC" queries and large terms. FossilOrigin-Name: b26d8f79c62cb71b4c3ea5df9d0e09558bbbd794 --- diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index c9fb6207ec..adbf19530a 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -1657,7 +1657,12 @@ static void fts5SegIterReverseNewPage(Fts5Index *p, Fts5SegIter *pIter){ pIter->pSeg->iSegid, pIter->iLeafPgno )); if( pNew ){ - if( pIter->iLeafPgno==pIter->iTermLeafPgno ){ + /* iTermLeafOffset may be equal to szLeaf if the term is the last + ** thing on the page - i.e. the first rowid is on the following page. + ** In this case leaf pIter->pLeaf==0, this iterator is at EOF. */ + if( pIter->iLeafPgno==pIter->iTermLeafPgno + && pIter->iTermLeafOffsetszLeaf + ){ pIter->pLeaf = pNew; pIter->iLeafOffset = pIter->iTermLeafOffset; }else{ diff --git a/ext/fts5/test/fts5dlidx.test b/ext/fts5/test/fts5dlidx.test index 86fb8bb930..5a03c6989b 100644 --- a/ext/fts5/test/fts5dlidx.test +++ b/ext/fts5/test/fts5dlidx.test @@ -170,6 +170,14 @@ do_execsql_test 3.1 { INSERT INTO abc SELECT rnddoc() FROM abc; } + + +do_execsql_test 3.2 { + SELECT rowid FROM abc WHERE abc + MATCH 'IteratorpItercurrentlypointstothefirstrowidofadoclist' + ORDER BY rowid DESC; +} {16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1} + do_execsql_test 3.2 { INSERT INTO abc(abc) VALUES('integrity-check'); INSERT INTO abc(abc) VALUES('optimize'); diff --git a/ext/fts5/test/fts5rowid.test b/ext/fts5/test/fts5rowid.test index e9dffa5791..621934c0f2 100644 --- a/ext/fts5/test/fts5rowid.test +++ b/ext/fts5/test/fts5rowid.test @@ -91,6 +91,10 @@ do_execsql_test 2.6 { # SELECT count(fts5_decode(rowid, block)) FROM x1_data; #} $res +do_execsql_test 2.8 { + SELECT fts5_decode(fts5_rowid('segment', 1000, 1), X'AB') +} {corrupt} + #------------------------------------------------------------------------- # Tests with very large tokens. # diff --git a/manifest b/manifest index 1f1b10325e..af98c1d902 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\stest\scoverage\sof\sfts5_index.c. -D 2015-09-14T19:51:05.852 +C Fix\sa\sproblem\swith\sfts5\s"ORDER\sBY\srowid\sDESC"\squeries\sand\slarge\sterms. +D 2015-09-15T11:58:33.318 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in f85066ce844a28b671aaeeff320921cd0ce36239 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -112,7 +112,7 @@ F ext/fts5/fts5_buffer.c 64dcaf36a3ebda9e84b7c3b8788887ec325e12a4 F ext/fts5/fts5_config.c 57ee5fe71578cb494574fc0e6e51acb9a22a8695 F ext/fts5/fts5_expr.c 667faaf14a69a5683ac383acdc8d942cf32c3f93 F ext/fts5/fts5_hash.c 4bf4b99708848357b8a2b5819e509eb6d3df9246 -F ext/fts5/fts5_index.c fae675f4d60cfff93b31f85576fddb6ade7d344e +F ext/fts5/fts5_index.c 437c907fec8b72c08394cda73cee84afca700a00 F ext/fts5/fts5_main.c 3fa906f6c0177caf8f82862bc70f37b28bb3305c F ext/fts5/fts5_storage.c 120f7b143688b5b7710dacbd48cff211609b8059 F ext/fts5/fts5_tcl.c 6da58d6e8f42a93c4486b5ba9b187a7f995dee37 @@ -147,7 +147,7 @@ F ext/fts5/test/fts5content.test 9a952c95518a14182dc3b59e3c8fa71cda82a4e1 F ext/fts5/test/fts5corrupt.test c2ad090192708150d50d961278df10ae7a4b8b62 F ext/fts5/test/fts5corrupt2.test 26c0a39dd9ff73207e6229f83b50b21d37c7658c F ext/fts5/test/fts5corrupt3.test 618a965b4fd2859f9ddb72413c9828a23828704b -F ext/fts5/test/fts5dlidx.test 77259f6d8d671b486113b157bd30107ca9d6b0f6 +F ext/fts5/test/fts5dlidx.test ecba5e62ea8b26c33829961602069c546228046d F ext/fts5/test/fts5doclist.test 8edb5b57e5f144030ed74ec00ef6fa4294fed79b F ext/fts5/test/fts5ea.test b01e3a18cdfabbff8104a96a5242a06a68a998a0 F ext/fts5/test/fts5eb.test 3e5869af2008cbc4ad03a175a0b6f6e58134cd43 @@ -172,7 +172,7 @@ F ext/fts5/test/fts5prefix.test 552a462f0e8595676611f41643de217fb4ac2808 F ext/fts5/test/fts5rank.test 11dcebba31d822f7e99685b4ea2c2ae3ec0b16f1 F ext/fts5/test/fts5rebuild.test 03935f617ace91ed23a6099c7c74d905227ff29b F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17 -F ext/fts5/test/fts5rowid.test 3e3b66670ca65540fa321250ac12f890b17f9312 +F ext/fts5/test/fts5rowid.test 400384798349d658eaf06aefa1e364957d5d4821 F ext/fts5/test/fts5simple.test f629e24a35a9f31cfb16c9920e8c2316e3d93e94 F ext/fts5/test/fts5synonym.test cf88c0a56d5ea9591e3939ef1f6e294f7f2d0671 F ext/fts5/test/fts5tokenizer.test ea4df698b35cc427ebf2ba22829d0e28386d8c89 @@ -1387,7 +1387,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d2df93f26fc0cf6fe01acfeaf2946972e9d8cca2 -R a767de21459f1cfc9798aa9a41d99081 +P c1f76686cee3918b1be785a4071d68cb3afda0ef +R d67808eb365cc1292d83338a5a6fd99f U dan -Z 579f9e68a86182329093b3386940c228 +Z c8f43a4f5db97e6a86a8018a67cf6238 diff --git a/manifest.uuid b/manifest.uuid index 7a9c2af077..f00cc58580 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c1f76686cee3918b1be785a4071d68cb3afda0ef \ No newline at end of file +b26d8f79c62cb71b4c3ea5df9d0e09558bbbd794 \ No newline at end of file