Fix handling of an OOM error in the fts3 offsets() function. Fix a couple of snippet related test cases in e_fts3.test.

FossilOrigin-Name: 14dc46a74aafe44c0bf7dffd26268395b2c5edb2
This commit is contained in:
dan 2010-01-09 07:33:54 +00:00
parent 819443e506
commit 1a54b8ecfa
4 changed files with 32 additions and 28 deletions

View File

@ -908,9 +908,23 @@ void sqlite3Fts3Offsets(
rc = fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void *)&sCtx);
if( rc!=SQLITE_OK ) goto offsets_out;
/* Initialize a tokenizer iterator to iterate through column iCol. */
/* Retreive the text stored in column iCol. If an SQL NULL is stored
** in column iCol, jump immediately to the next iteration of the loop.
** If an OOM occurs while retrieving the data (this can happen if SQLite
** needs to transform the data from utf-16 to utf-8), return SQLITE_NOMEM
** to the caller.
*/
zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol+1);
nDoc = sqlite3_column_bytes(pCsr->pStmt, iCol+1);
if( zDoc==0 ){
if( sqlite3_column_type(pCsr->pStmt, iCol+1)==SQLITE_NULL ){
continue;
}
rc = SQLITE_NOMEM;
goto offsets_out;
}
/* Initialize a tokenizer iterator to iterate through column iCol. */
rc = pMod->xOpen(pTab->pTokenizer, zDoc, nDoc, &pC);
if( rc!=SQLITE_OK ) goto offsets_out;
pC->pTokenizer = pTab->pTokenizer;

View File

@ -1,8 +1,5 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C Update\scomments\sin\sfts3.c\sto\smore\saccurately\sdescribe\sthe\sdoclist\sformat.
D 2010-01-08T23:01:33
C Fix\shandling\sof\san\sOOM\serror\sin\sthe\sfts3\soffsets()\sfunction.\sFix\sa\scouple\sof\ssnippet\srelated\stest\scases\sin\se_fts3.test.
D 2010-01-09T07:33:54
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -67,7 +64,7 @@ F ext/fts3/fts3_hash.c 3c8f6387a4a7f5305588b203fa7c887d753e1f1c
F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec
F ext/fts3/fts3_icu.c ac494aed69835008185299315403044664bda295
F ext/fts3/fts3_porter.c a651e287e02b49b565a6ccf9441959d434489156
F ext/fts3/fts3_snippet.c 210bd2a9336e25d4d82a2e81c85abd9b9f8f31ca
F ext/fts3/fts3_snippet.c a521f904baca19e0ed7025bc0e38d24fc05d21bf
F ext/fts3/fts3_tokenizer.c 1a49ee3d79cbf0b9386250370d9cbfe4bb89c8ff
F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3
F ext/fts3/fts3_tokenizer1.c 11a604a53cff5e8c28882727bf794e5252e5227b
@ -329,7 +326,7 @@ F test/descidx3.test 3394ad4d089335cac743c36a14129d6d931c316f
F test/diskfull.test 0cede7ef9d8f415d9d3944005c76be7589bb5ebb
F test/distinctagg.test 1a6ef9c87a58669438fc771450d7a72577417376
F test/e_fkey.test 6721a741c6499b3ab7e5385923233343c8f1ad05
F test/e_fts3.test ad5d08ca8634b1636c6129d023a1139938b6be05
F test/e_fts3.test e95c2085c817ebb929c85773394d5fb250a8f610
F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea
F test/enc2.test 6d91a5286f59add0cfcbb2d0da913b76f2242398
F test/enc3.test 5c550d59ff31dccdba5d1a02ae11c7047d77c041
@ -788,14 +785,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 08c545f03082421166a21274b39e07bb348c17e6
R fd480c683a62029e9ec671a9327220e6
U drh
Z fc689ecb2cdb2cbb899bfa1ef8dbe1b0
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFLR7lQoxKgR168RlERAiFaAJ0baFwo7PSUJOJhCvizsqF8gfeh8QCfSRxZ
sHuj1+mD+8zQC/K58Uto6eY=
=pm4s
-----END PGP SIGNATURE-----
P e424a0307359fee6875424c10ecad1a10acfba0e
R 172138024910e4c6fdf1759b2e1ab812
U dan
Z 370e96d093c040b65438f7314092ae6c

View File

@ -1 +1 @@
e424a0307359fee6875424c10ecad1a10acfba0e
14dc46a74aafe44c0bf7dffd26268395b2c5edb2

View File

@ -411,7 +411,7 @@ read_test 1.7.1.6 {
ddl_test 1.7.2.1 { CREATE VIRTUAL TABLE text USING fts3() }
write_test 3.2.2 text_content {
write_test 1.7.2.2 text_content {
INSERT INTO text VALUES('
During 30 Nov-1 Dec, 2-3oC drops. Cool in the upper portion, minimum temperature 14-16oC and cool elsewhere, minimum temperature 17-20oC. Cold to very cold on mountaintops, minimum temperature 6-12oC. Northeasterly winds 15-30 km/hr. After that, temperature increases. Northeasterly winds 15-30 km/hr.
');
@ -419,11 +419,11 @@ write_test 3.2.2 text_content {
read_test 1.7.2.3 {
SELECT snippet(text) FROM text WHERE text MATCH 'cold'
} {{<b>...</b> elsewhere, minimum temperature 17-20oC. <b>Cold</b> to very <b>cold</b> on mountaintops, minimum <b>...</b>}}
} {{<b>...</b>cool elsewhere, minimum temperature 17-20oC. <b>Cold</b> to very <b>cold</b> on mountaintops, minimum temperature 6<b>...</b>}}
read_test 1.7.2.4 {
SELECT snippet(text, '[', ']', '...') FROM text WHERE text MATCH '"min* tem*"'
} {{... 2-3oC drops. Cool in the upper portion, [minimum] [temperature] 14-16oC and cool elsewhere, [minimum] ...}}
} {{...the upper portion, [minimum] [temperature] 14-16oC and cool elsewhere, [minimum] [temperature] 17-20oC. Cold...}}
##########################################################################
# Test the example in section 5 (custom tokenizers).
@ -472,7 +472,7 @@ error_test 2.1.7 {
SELECT snippet() FROM t1 WHERE a MATCH 'one'
} {unable to use function snippet in the requested context}
error_test 2.1.8 {
SELECT snippet(a, b, 'A', 'B', 'C') FROM t1 WHERE a MATCH 'one'
SELECT snippet(a, b, 'A', 'B', 'C', 'D', 'E') FROM t1 WHERE a MATCH 'one'
} {wrong number of arguments to function snippet()}
#-------------------------------------------------------------------------
@ -518,16 +518,16 @@ write_test 5.2 t5_content {
}
read_test 5.3 {
SELECT snippet(t5) FROM t5 WHERE t5 MATCH 'miles'
} {{<b>...</b> Down to a sunless sea. So twice five <b>miles</b> of fertile ground With walls and towers were <b>...</b>}}
} {{<b>...</b>to a sunless sea. So twice five <b>miles</b> of fertile ground With walls and towers<b>...</b>}}
read_test 5.4 {
SELECT snippet(t5, '<i>') FROM t5 WHERE t5 MATCH 'miles'
} {{<b>...</b> Down to a sunless sea. So twice five <i>miles</b> of fertile ground With walls and towers were <b>...</b>}}
} {{<b>...</b>to a sunless sea. So twice five <i>miles</b> of fertile ground With walls and towers<b>...</b>}}
read_test 5.5 {
SELECT snippet(t5, '<i>', '</i>') FROM t5 WHERE t5 MATCH 'miles'
} {{<b>...</b> Down to a sunless sea. So twice five <i>miles</i> of fertile ground With walls and towers were <b>...</b>}}
} {{<b>...</b>to a sunless sea. So twice five <i>miles</i> of fertile ground With walls and towers<b>...</b>}}
read_test 5.6 {
SELECT snippet(t5, '<i>', '</i>', 'XXX') FROM t5 WHERE t5 MATCH 'miles'
} {{XXX Down to a sunless sea. So twice five <i>miles</i> of fertile ground With walls and towers were XXX}}
} {{XXXto a sunless sea. So twice five <i>miles</i> of fertile ground With walls and towersXXX}}
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------