From: drh Date: Thu, 23 Jun 2011 00:59:41 +0000 (+0000) Subject: If "PRAGMA page_size" commands are not authorized, the FTS module will assume X-Git-Tag: version-3.7.7~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=45de8d5f0fd9c4484ef558dea339f50acc2b3a37;p=thirdparty%2Fsqlite.git If "PRAGMA page_size" commands are not authorized, the FTS module will assume a page size of 1024. FossilOrigin-Name: ba39382ef546b4c4ae15ed90ef0b6c87762bffef --- diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 2cbcbff89e..67a0ea2096 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -644,6 +644,9 @@ static void fts3DatabasePageSize(int *pRc, Fts3Table *p){ sqlite3_step(pStmt); p->nPgsz = sqlite3_column_int(pStmt, 0); rc = sqlite3_finalize(pStmt); + }else if( rc==SQLITE_AUTH ){ + p->nPgsz = 1024; + rc = SQLITE_OK; } } assert( p->nPgsz>0 || rc!=SQLITE_OK ); diff --git a/manifest b/manifest index 72883e03d5..3895c7a5fd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Added\slimited\ssupport\sto\somittest.tcl\sfor\snmake\smakefile. -D 2011-06-22T20:14:09.429 +C If\s"PRAGMA\spage_size"\scommands\sare\snot\sauthorized,\sthe\sFTS\smodule\swill\sassume\na\spage\ssize\sof\s1024. +D 2011-06-23T00:59:41.395 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,7 +62,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 1c8a45dfd6836e7dea0307008079793ac0fc3b68 +F ext/fts3/fts3.c ca776037493d0081da70a6afc0df80f5ce347cb7 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h fa493ccbad78a2c99ad1c984f651c0c202e68536 F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691 @@ -482,7 +482,7 @@ F test/fts3rnd.test 1320d8826a845e38a96e769562bf83d7a92a15d0 F test/fts3shared.test 8bb266521d7c5495c0ae522bb4d376ad5387d4a2 F test/fts3snippet.test a12f22a3ba4dd59751a57c79b031d07ab5f51ddd F test/fts3sort.test 63d52c1812904b751f9e1ff487472e44833f5402 -F test/fts4aa.test b99ad4d9a43a00efd096ef4d0b082de58d848d41 +F test/fts4aa.test 148d9eb54901af23b5d402b1f388f43e559e1728 F test/func.test 6c5ce11e3a0021ca3c0649234e2d4454c89110ca F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 7ba2ca5a1e9bca900ba2c230cf04bd67184bc1bc @@ -948,7 +948,7 @@ F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d -P f853fa63c357b78f93e553eb81cd79d4c3e06850 -R ddc3e17983db538a7697328fd62bb1d7 -U shaneh -Z 53ee1769a28d0b67b6ec5c95bb5607ec +P f5f46dc7b8c23e77fd1ff792b7d0cf070de47ca3 +R 75bcfe449226b3d5c48d659bee0c9f49 +U drh +Z 3a2cb80a9cc46dd7ad3b57ead9348db1 diff --git a/manifest.uuid b/manifest.uuid index 467483d7d7..d75b641e50 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f5f46dc7b8c23e77fd1ff792b7d0cf070de47ca3 \ No newline at end of file +ba39382ef546b4c4ae15ed90ef0b6c87762bffef \ No newline at end of file diff --git a/test/fts4aa.test b/test/fts4aa.test index f20d07660b..1131df3bec 100644 --- a/test/fts4aa.test +++ b/test/fts4aa.test @@ -22,9 +22,11 @@ ifcapable !fts3 { return } -do_test fts4aa-1.0 { +# This procedure fills an existing FTS3/FTS4 table with many entries. +# The table needs to have a single column (other than docid) named "words". +# +proc fts4aa_fill_table {} { db eval { -CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter); BEGIN TRANSACTION; INSERT INTO t1(docid,words) VALUES(1001001,'In the beginning God created the heaven and the earth.'); INSERT INTO t1(docid,words) VALUES(1001002,'And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.'); @@ -1561,9 +1563,41 @@ INSERT INTO t1(docid,words) VALUES(1050025,'And Joseph took an oath of the child INSERT INTO t1(docid,words) VALUES(1050026,'So Joseph died, being an hundred and ten years old: and they embalmed him, and he was put in a coffin in Egypt.'); COMMIT; } -} {} +} +# The following is a list of queries to perform against the above +# FTS3/FTS4 database. We will be trying these queries in various +# configurations to ensure that they always return the same answers. +# +set fts4aa_queries { + {abraham} + {the king} + {"the king"} + {abraham OR joseph} + {ab* OR jos*} + {lived t*} + {spake hebrew} + {melchizedek} + {t* melchizedek} + {melchizedek t*} +} +unset -nocomplain fts4aa_res +# Set up the baseline results +# +do_test fts4aa-1.0 { + db eval { + CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter); + } + fts4aa_fill_table + foreach q $::fts4aa_queries { + set r [db eval {SELECT docid FROM t1 WHERE words MATCH $q ORDER BY docid}] + set ::fts4aa_res($q) $r + } +} {} + +# Legacy test cases +# do_test fts4aa-1.1 { db eval { SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize @@ -1583,19 +1617,19 @@ proc mit {blob} { } db func mit mit -do_test fts4aa-2.1 { +do_test fts4aa-1.3 { db eval { SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1 WHERE t1 MATCH 'melchizedek'; } } {1014018 {1 1 1 1 1 1533 25 20}} -do_test fts4aa-2.2 { +do_test fts4aa-1.4 { db eval { SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1 WHERE t1 MATCH 'spake hebrew' ORDER BY docid; } } {1039014 {2 1 1 40 40 1 6 6 1533 25 42} 1039017 {2 1 1 40 40 1 6 6 1533 25 26}} -do_test fts4aa-2.3 { +do_test fts4aa-1.5 { db eval { SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1 WHERE t1 MATCH 'laban overtook jacob' @@ -1603,7 +1637,7 @@ do_test fts4aa-2.3 { } } {1031025 {3 1 2 54 46 1 3 3 2 181 160 1533 25 24}} -do_test fts4aa-9.1 { +do_test fts4aa-1.6 { db eval { DELETE FROM t1 WHERE docid!=1050026; SELECT hex(size) FROM t1_docsize; @@ -1611,17 +1645,17 @@ do_test fts4aa-9.1 { } } {17 01176F} -do_test fts4aa-9.2 { +do_test fts4aa-1.7 { db eval { SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize } } {} -do_test fts4aa-9.3 { +do_test fts4aa-1.8 { db eval { SELECT docid FROM t1_docsize EXCEPT SELECT docid FROM t1 } } {} -do_test fts4aa-9.4 { +do_test fts4aa-1.9 { # Note: Token 'in' is being deferred in the following query. db eval { SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1 @@ -1630,4 +1664,67 @@ do_test fts4aa-9.4 { } } {1050026 {4 1 1 1 1 1 1 1 2 1 1 1 1 1 1 23 23}} +# Should get the same search results from FTS3 +# +do_test fts4aa-2.0 { + db eval { + DROP TABLE t1; + CREATE VIRTUAL TABLE t1 USING fts3(words, tokenize porter); + } + fts4aa_fill_table +} {} +unset -nocomplain ii +set ii 0 +foreach {q r} [array get fts4aa_res] { + incr ii + do_test fts4aa-2.$ii { + db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid} + } $r +} + +# Should get the same search results when the page size is very large +# +do_test fts4aa-3.0 { + db close + file delete -force test.db + sqlite3 db test.db + db eval { + PRAGMA page_size=65536; + CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter); + } + fts4aa_fill_table +} {} +unset -nocomplain ii +set ii 0 +foreach {q r} [array get fts4aa_res] { + incr ii + do_test fts4aa-3.$ii { + db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid} + } $r +} + +# Should get the same search results when an authorizer prevents +# all PRAGMA statements. +# +proc no_pragma_auth {code arg1 arg2 arg3 arg4} { + if {$code=="SQLITE_PRAGMA"} {return SQLITE_DENY} + return SQLITE_OK; +} +do_test fts4aa-4.0 { + db auth ::no_pragma_auth + db eval { + DROP TABLE t1; + CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter); + } + fts4aa_fill_table +} {} +unset -nocomplain ii +set ii 0 +foreach {q r} [array get fts4aa_res] { + incr ii + do_test fts4aa-4.$ii { + db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid} + } $r +} + finish_test