1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Fix overzealous fts2 assertions WRT rowid 0 or lower. Only check that

docids are ascending if there was a prior docid set for the doclist,
ignore the initial docid of 0. (CVS 4026)

FossilOrigin-Name: ed3a131f1d3fe51d1e79bdfe1bfafa55f825afa9
This commit is contained in:
shess
2007-05-21 21:59:18 +00:00
parent a408adc5cb
commit 8a7de08a8b
4 changed files with 43 additions and 13 deletions

View File

@ -716,12 +716,18 @@ typedef struct DLWriter {
DocListType iType;
DataBuffer *b;
sqlite_int64 iPrevDocid;
#ifndef NDEBUG
int has_iPrevDocid;
#endif
} DLWriter;
static void dlwInit(DLWriter *pWriter, DocListType iType, DataBuffer *b){
pWriter->b = b;
pWriter->iType = iType;
pWriter->iPrevDocid = 0;
#ifndef NDEBUG
pWriter->has_iPrevDocid = 0;
#endif
}
static void dlwDestroy(DLWriter *pWriter){
SCRAMBLE(pWriter);
@ -780,11 +786,15 @@ static void dlwAdd(DLWriter *pWriter, sqlite_int64 iDocid){
char c[VARINT_MAX];
int n = putVarint(c, iDocid-pWriter->iPrevDocid);
assert( pWriter->iPrevDocid<iDocid );
/* Docids must ascend. */
assert( !pWriter->has_iPrevDocid || iDocid>pWriter->iPrevDocid );
assert( pWriter->iType==DL_DOCIDS );
dataBufferAppend(pWriter->b, c, n);
pWriter->iPrevDocid = iDocid;
#ifndef NDEBUG
pWriter->has_iPrevDocid = 1;
#endif
}
/*******************************************************************/
@ -961,10 +971,14 @@ static void plwInit(PLWriter *pWriter, DLWriter *dlw, sqlite_int64 iDocid){
pWriter->dlw = dlw;
assert( iDocid>pWriter->dlw->iPrevDocid );
/* Docids must ascend. */
assert( !pWriter->dlw->has_iPrevDocid || iDocid>pWriter->dlw->iPrevDocid );
n = putVarint(c, iDocid-pWriter->dlw->iPrevDocid);
dataBufferAppend(pWriter->dlw->b, c, n);
pWriter->dlw->iPrevDocid = iDocid;
#ifndef NDEBUG
pWriter->dlw->has_iPrevDocid = 1;
#endif
pWriter->iColumn = 0;
pWriter->iPos = 0;

View File

@ -1,5 +1,5 @@
C Add\sthe\slarger\sSQLite\sicon\sto\sthe\srepository.\s(CVS\s4025)
D 2007-05-19T11:50:36
C Fix\soverzealous\sfts2\sassertions\sWRT\srowid\s0\sor\slower.\s\sOnly\scheck\sthat\ndocids\sare\sascending\sif\sthere\swas\sa\sprior\sdocid\sset\sfor\sthe\sdoclist,\nignore\sthe\sinitial\sdocid\sof\s0.\s(CVS\s4026)
D 2007-05-21T21:59:18
F Makefile.in a42354804b50c2708ce72cf79e4daa30f50191b5
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -36,7 +36,7 @@ F ext/fts1/fulltext.h 08525a47852d1d62a0be81d3fc3fe2d23b094efd
F ext/fts1/simple_tokenizer.c 1844d72f7194c3fd3d7e4173053911bf0661b70d
F ext/fts1/tokenizer.h 0c53421b832366d20d720d21ea3e1f6e66a36ef9
F ext/fts2/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
F ext/fts2/fts2.c 9e1f5942fc063f2d6778bc44372eba9b2b43eebd
F ext/fts2/fts2.c 4c68ff4f2c95f1cb36d760c89b2a98d07a9dc518
F ext/fts2/fts2.h 591916a822cfb6426518fdbf6069359119bc46eb
F ext/fts2/fts2_hash.c b3f22116d4ef0bc8f2da6e3fdc435c86d0951a9b
F ext/fts2/fts2_hash.h e283308156018329f042816eb09334df714e105e
@ -235,7 +235,7 @@ F test/fts1j.test e4c0ffcd0ba2adce09c6b7b43ffd0749b5fda5c7
F test/fts1k.test fdf295cb797ba6a2ef81ec41cb98df0ceb2e572c
F test/fts1l.test 15c119ed2362b2b28d5300c0540a6a43eab66c36
F test/fts1porter.test d86e9c3e0c7f8ff95add6582b4b585fb4e02b96d
F test/fts2a.test 103fc178d134c54c44c1938a4331e9e2030792d9
F test/fts2a.test 473a5c8b473a4e21a8e3fddaed1e59666e0c6ab7
F test/fts2b.test 964abc0236c849c07ca1ae496bb25c268ae94816
F test/fts2c.test ffb5a35230ac72c4354535c547965ce6824537c0
F test/fts2d.test b7eaa671ca9a16997f3e5b158ee777ae21052b0b
@ -494,7 +494,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 315dc71b921ffba514271a2ed571d5f4162c775f
R 6690b927b9e60ea3f1ce16e28d14b75e
U drh
Z 34db7163f46344eeab9731ece1a3c204
P d7539c6e8b66d537307e70aac5f2001135151c78
R fc1fc4b99da3f2060e3c202b7bab5aec
U shess
Z a33da34f6d94403bda46e441bbf9b0fa

View File

@ -1 +1 @@
d7539c6e8b66d537307e70aac5f2001135151c78
ed3a131f1d3fe51d1e79bdfe1bfafa55f825afa9

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script is testing the FTS2 module.
#
# $Id: fts2a.test,v 1.1 2006/10/19 23:36:26 shess Exp $
# $Id: fts2a.test,v 1.2 2007/05/21 21:59:18 shess Exp $
#
set testdir [file dirname $argv0]
@ -181,6 +181,22 @@ do_test fts2a-5.3 {
execsql {SELECT rowid FROM t1 WHERE content MATCH NULL}
} {}
# Test the ability to handle non-positive rowids
#
do_test fts2a-6.0 {
execsql {INSERT INTO t1(rowid, content) VALUES(0, 'four five')}
} {}
do_test fts2a-6.1 {
execsql {SELECT content FROM t1 WHERE rowid = 0}
} {{four five}}
do_test fts2a-6.2 {
execsql {INSERT INTO t1(rowid, content) VALUES(-1, 'three four')}
} {}
do_test fts2a-6.3 {
execsql {SELECT content FROM t1 WHERE rowid = -1}
} {{three four}}
do_test fts2a-6.4 {
execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'four'}
} {-1 0 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31}
finish_test