From: drh Date: Mon, 15 Mar 2010 20:53:01 +0000 (+0000) Subject: Improved error message when the right-hand operand of MATCH in FTS3 is X-Git-Tag: version-3.7.2~533 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3a3dd3ac8dad62422c3c07ecd8868b39d60624de;p=thirdparty%2Fsqlite.git Improved error message when the right-hand operand of MATCH in FTS3 is not a valid search expression. Ticket [170872f1c3]. FossilOrigin-Name: bea9258643edfeb98ebf59d93fa18a14e4221fea --- diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 003c93d682..3b09bf3d23 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -2048,7 +2048,13 @@ static int fts3FilterMethod( rc = sqlite3Fts3ExprParse(p->pTokenizer, p->azColumn, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr ); - if( rc!=SQLITE_OK ) return rc; + if( rc!=SQLITE_OK ){ + if( rc==SQLITE_ERROR ){ + p->base.zErrMsg = sqlite3_mprintf("malformed MATCH expression: [%s]", + zQuery); + } + return rc; + } rc = evalFts3Expr(p, pCsr->pExpr, &pCsr->aDoclist, &pCsr->nDoclist, 0); pCsr->pNextId = pCsr->aDoclist; diff --git a/manifest b/manifest index 0f9d73e735..632bf7033a 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\sFTS3\sso\sthat\sit\sdoes\snot\srun\sillegal\sSQL\sand\scause\sa\sspurious\slog\nmessage.\s\sTicket\s[42d45a693e6]. -D 2010-03-15T19:27:56 +C Improved\serror\smessage\swhen\sthe\sright-hand\soperand\sof\sMATCH\sin\sFTS3\sis\nnot\sa\svalid\ssearch\sexpression.\s\sTicket\s[170872f1c3]. +D 2010-03-15T20:53:01 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -59,7 +59,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 54d3c2273c1ef7928f8a77b2dff0b6736e5b8f6b +F ext/fts3/fts3.c 2bb2045d1412184e9eea71eb151b159168be5131 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h df812ef35f1b47a44ec68a44ec0c2a769c973d85 F ext/fts3/fts3_expr.c f4ff02ebe854e97ac03ff00b38b728a9ab57fd4b @@ -392,7 +392,7 @@ F test/fts3ac.test fc1ac42c33f8a66d48ae41e4728f7ca4b6dfc950 F test/fts3ad.test e40570cb6f74f059129ad48bcef3d7cbc20dda49 F test/fts3ae.test ce32a13b34b0260928e4213b4481acf801533bda F test/fts3af.test d394978c534eabf22dd0837e718b913fd66b499c -F test/fts3ag.test 38d9c7dd4b607929498e8e0b32299af5665da1ab +F test/fts3ag.test 0b7d303f61ae5d620c4efb5e825713ea34ff9441 F test/fts3ah.test ba181d6a3dee0c929f0d69df67cac9c47cda6bff F test/fts3ai.test d29cee6ed653e30de478066881cec8aa766531b2 F test/fts3aj.test 584facbc9ac4381a7ec624bfde677340ffc2a5a4 @@ -407,7 +407,7 @@ F test/fts3c.test fc723a9cf10b397fdfc2b32e73c53c8b1ec02958 F test/fts3cov.test 3a9d8618a3107166530c447e808f8992372e0415 F test/fts3d.test 95fb3c862cbc4297c93fceb9a635543744e9ef52 F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851 -F test/fts3expr.test 05dab77387801e4900009917bb18f556037d82da +F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a F test/fts3malloc.test 059592c4f37ccd30138bbf8e3e5b7982cb5c8f2e F test/fts3near.test 2e318ee434d32babd27c167142e2b94ddbab4844 @@ -796,14 +796,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 59f75bba028e1107ed41d447c27aef31a6656b68 -R 1f89c10b36338422510ff672b0f80d2d +P f186b6a61909be1d65b76a6fbaa42f57bbd0d1e5 +R fc80669f4915ada3796481624547e3ec U drh -Z 6cc5c3980c33b9c6deb66707a1aeeba9 +Z 2f4ab276a582edf60527cadf937d02b0 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFLnoo/oxKgR168RlERAiiOAKCKBx1/MB8tgbUyWC1g9MT2otS2OQCfWVoV -DVWU3wk0fSDCduM/O7VAtXE= -=rlq/ +iD8DBQFLnp4xoxKgR168RlERArRnAKCFf/D9C9jjnXrLZQSSVB5obQctKwCfSst5 +zzT89o4tdlKI0qCLl4DCz+M= +=61f4 -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 6b5cec3f5c..eaf4fafc08 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f186b6a61909be1d65b76a6fbaa42f57bbd0d1e5 \ No newline at end of file +bea9258643edfeb98ebf59d93fa18a14e4221fea \ No newline at end of file diff --git a/test/fts3ag.test b/test/fts3ag.test index 34ef9497ed..18ed5ae31f 100644 --- a/test/fts3ag.test +++ b/test/fts3ag.test @@ -73,7 +73,7 @@ do_test fts3ag-1.9 { # No support for all-except queries. do_test fts3ag-1.10 { catchsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this -something'} -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [-this -something]}} # Test that docListOrMerge() correctly handles reaching the end of one # doclist before it reaches the end of the other. diff --git a/test/fts3expr.test b/test/fts3expr.test index 4cedecb2d9..e7c4f65598 100644 --- a/test/fts3expr.test +++ b/test/fts3expr.test @@ -336,53 +336,53 @@ do_test fts3expr-4.1 { # Mismatched parenthesis: do_test fts3expr-4.2.1 { catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example AND (hello OR world))' } -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [example AND (hello OR world))]}} do_test fts3expr-4.2.2 { catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example AND (hello OR world' } -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [example AND (hello OR world]}} do_test fts3expr-4.2.3 { catchsql { SELECT * FROM t1 WHERE t1 MATCH '(hello' } -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [(hello]}} do_test fts3expr-4.2.4 { catchsql { SELECT * FROM t1 WHERE t1 MATCH '(' } -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [(]}} do_test fts3expr-4.2.5 { catchsql { SELECT * FROM t1 WHERE t1 MATCH ')' } -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [)]}} do_test fts3expr-4.2.6 { catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example (hello world' } -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [example (hello world]}} # Unterminated quotation marks: do_test fts3expr-4.3.1 { catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example OR "hello world' } -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [example OR "hello world]}} do_test fts3expr-4.3.2 { catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example OR hello world"' } -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [example OR hello world"]}} # Binary operators without the required operands. do_test fts3expr-4.4.1 { catchsql { SELECT * FROM t1 WHERE t1 MATCH 'OR hello world' } -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [OR hello world]}} do_test fts3expr-4.4.2 { catchsql { SELECT * FROM t1 WHERE t1 MATCH 'hello world OR' } -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [hello world OR]}} do_test fts3expr-4.4.3 { catchsql { SELECT * FROM t1 WHERE t1 MATCH 'one (hello world OR) two' } -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [one (hello world OR) two]}} do_test fts3expr-4.4.4 { catchsql { SELECT * FROM t1 WHERE t1 MATCH 'one (OR hello world) two' } -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [one (OR hello world) two]}} # NEAR operators with something other than phrases as arguments. do_test fts3expr-4.5.1 { catchsql { SELECT * FROM t1 WHERE t1 MATCH '(hello OR world) NEAR one' } -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [(hello OR world) NEAR one]}} do_test fts3expr-4.5.2 { catchsql { SELECT * FROM t1 WHERE t1 MATCH 'one NEAR (hello OR world)' } -} {1 {SQL logic error or missing database}} +} {1 {malformed MATCH expression: [one NEAR (hello OR world)]}} #------------------------------------------------------------------------ # The following OOM tests are designed to cover cases in fts3_expr.c.