/ Check-in [ba39382e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:If "PRAGMA page_size" commands are not authorized, the FTS module will assume a page size of 1024.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ba39382ef546b4c4ae15ed90ef0b6c87762bffef
User & Date: drh 2011-06-23 00:59:41
Context
2011-06-23
01:07
Remove unused variables from test_vfs.c check-in: 07884cc2 user: drh tags: trunk
00:59
If "PRAGMA page_size" commands are not authorized, the FTS module will assume a page size of 1024. check-in: ba39382e user: drh tags: trunk
2011-06-22
20:14
Added limited support to omittest.tcl for nmake makefile. check-in: f5f46dc7 user: shaneh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3.c.

   640    640         rc = SQLITE_NOMEM;
   641    641       }else{
   642    642         rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
   643    643         if( rc==SQLITE_OK ){
   644    644           sqlite3_step(pStmt);
   645    645           p->nPgsz = sqlite3_column_int(pStmt, 0);
   646    646           rc = sqlite3_finalize(pStmt);
          647  +      }else if( rc==SQLITE_AUTH ){
          648  +        p->nPgsz = 1024;
          649  +        rc = SQLITE_OK;
   647    650         }
   648    651       }
   649    652       assert( p->nPgsz>0 || rc!=SQLITE_OK );
   650    653       sqlite3_free(zSql);
   651    654       *pRc = rc;
   652    655     }
   653    656   }

Changes to test/fts4aa.test.

    18     18   
    19     19   # If SQLITE_ENABLE_FTS3 is defined, omit this file.
    20     20   ifcapable !fts3 {
    21     21     finish_test
    22     22     return
    23     23   }
    24     24   
    25         -do_test fts4aa-1.0 {
           25  +# This procedure fills an existing FTS3/FTS4 table with many entries.
           26  +# The table needs to have a single column (other than docid) named "words".
           27  +#
           28  +proc fts4aa_fill_table {} {
    26     29   db eval {
    27         -CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
    28     30   BEGIN TRANSACTION;
    29     31   INSERT INTO t1(docid,words) VALUES(1001001,'In the beginning God created the heaven and the earth.');
    30     32   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.');
    31     33   INSERT INTO t1(docid,words) VALUES(1001003,'And God said, Let there be light: and there was light.');
    32     34   INSERT INTO t1(docid,words) VALUES(1001004,'And God saw the light, that it was good: and God divided the light from the darkness.');
    33     35   INSERT INTO t1(docid,words) VALUES(1001005,'And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.');
    34     36   INSERT INTO t1(docid,words) VALUES(1001006,'And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.');
................................................................................
  1557   1559   INSERT INTO t1(docid,words) VALUES(1050022,'And Joseph dwelt in Egypt, he, and his father''s house: and Joseph lived an hundred and ten years.');
  1558   1560   INSERT INTO t1(docid,words) VALUES(1050023,'And Joseph saw Ephraim''s children of the third generation: the children also of Machir the son of Manasseh were brought up upon Joseph''s knees.');
  1559   1561   INSERT INTO t1(docid,words) VALUES(1050024,'And Joseph said unto his brethren, I die: and God will surely visit you, and bring you out of this land unto the land which he sware to Abraham, to Isaac, and to Jacob.');
  1560   1562   INSERT INTO t1(docid,words) VALUES(1050025,'And Joseph took an oath of the children of Israel, saying, God will surely visit you, and ye shall carry up my bones from hence.');
  1561   1563   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.');
  1562   1564   COMMIT;
  1563   1565   }
         1566  +}
         1567  +
         1568  +# The following is a list of queries to perform against the above
         1569  +# FTS3/FTS4 database.  We will be trying these queries in various
         1570  +# configurations to ensure that they always return the same answers.
         1571  +#
         1572  +set fts4aa_queries {
         1573  +  {abraham}
         1574  +  {the king}
         1575  +  {"the king"}
         1576  +  {abraham OR joseph}
         1577  +  {ab* OR jos*}
         1578  +  {lived t*}
         1579  +  {spake hebrew}
         1580  +  {melchizedek}
         1581  +  {t* melchizedek}
         1582  +  {melchizedek t*}
         1583  +}
         1584  +unset -nocomplain fts4aa_res
         1585  +
         1586  +# Set up the baseline results
         1587  +#
         1588  +do_test fts4aa-1.0 {
         1589  +  db eval {
         1590  +    CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
         1591  +  }
         1592  +  fts4aa_fill_table
         1593  +  foreach q $::fts4aa_queries {
         1594  +    set r [db eval {SELECT docid FROM t1 WHERE words MATCH $q ORDER BY docid}]
         1595  +    set ::fts4aa_res($q) $r
         1596  +  }
  1564   1597   } {}
  1565   1598   
  1566         -
         1599  +# Legacy test cases
         1600  +#
  1567   1601   do_test fts4aa-1.1 {
  1568   1602     db eval {
  1569   1603       SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize
  1570   1604     }
  1571   1605   } {}
  1572   1606   do_test fts4aa-1.2 {
  1573   1607     db eval {
................................................................................
  1579   1613     set scan(littleEndian) i*
  1580   1614     set scan(bigEndian) I*
  1581   1615     binary scan $blob $scan($::tcl_platform(byteOrder)) r
  1582   1616     return $r
  1583   1617   }
  1584   1618   db func mit mit
  1585   1619   
  1586         -do_test fts4aa-2.1 {
         1620  +do_test fts4aa-1.3 {
  1587   1621     db eval {
  1588   1622       SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1 WHERE t1 MATCH 'melchizedek';
  1589   1623     }
  1590   1624   } {1014018 {1 1 1 1 1 1533 25 20}}
  1591         -do_test fts4aa-2.2 {
         1625  +do_test fts4aa-1.4 {
  1592   1626     db eval {
  1593   1627       SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
  1594   1628        WHERE t1 MATCH 'spake hebrew'
  1595   1629        ORDER BY docid;
  1596   1630     }
  1597   1631   } {1039014 {2 1 1 40 40 1 6 6 1533 25 42} 1039017 {2 1 1 40 40 1 6 6 1533 25 26}}
  1598         -do_test fts4aa-2.3 {
         1632  +do_test fts4aa-1.5 {
  1599   1633     db eval {
  1600   1634       SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
  1601   1635        WHERE t1 MATCH 'laban overtook jacob'
  1602   1636        ORDER BY docid;
  1603   1637     }
  1604   1638   } {1031025 {3 1 2 54 46 1 3 3 2 181 160 1533 25 24}}
  1605   1639   
  1606         -do_test fts4aa-9.1 {
         1640  +do_test fts4aa-1.6 {
  1607   1641     db eval {
  1608   1642       DELETE FROM t1 WHERE docid!=1050026;
  1609   1643       SELECT hex(size) FROM t1_docsize;
  1610   1644       SELECT hex(value) FROM t1_stat;
  1611   1645     }
  1612   1646   } {17 01176F}
  1613   1647   
  1614         -do_test fts4aa-9.2 {
         1648  +do_test fts4aa-1.7 {
  1615   1649     db eval {
  1616   1650       SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize
  1617   1651     }
  1618   1652   } {}
  1619         -do_test fts4aa-9.3 {
         1653  +do_test fts4aa-1.8 {
  1620   1654     db eval {
  1621   1655       SELECT docid FROM t1_docsize EXCEPT SELECT docid FROM t1
  1622   1656     }
  1623   1657   } {}
  1624         -do_test fts4aa-9.4 {
         1658  +do_test fts4aa-1.9 {
  1625   1659     # Note: Token 'in' is being deferred in the following query. 
  1626   1660     db eval {
  1627   1661       SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1
  1628   1662        WHERE t1 MATCH 'joseph died in egypt'
  1629   1663        ORDER BY docid;
  1630   1664     }
  1631   1665   } {1050026 {4 1 1 1 1 1 1 1 2 1 1 1 1 1 1 23 23}}
         1666  +
         1667  +# Should get the same search results from FTS3
         1668  +#
         1669  +do_test fts4aa-2.0 {
         1670  +  db eval {
         1671  +    DROP TABLE t1;
         1672  +    CREATE VIRTUAL TABLE t1 USING fts3(words, tokenize porter);
         1673  +  }
         1674  +  fts4aa_fill_table
         1675  +} {}
         1676  +unset -nocomplain ii
         1677  +set ii 0
         1678  +foreach {q r} [array get fts4aa_res] {
         1679  +  incr ii
         1680  +  do_test fts4aa-2.$ii {
         1681  +    db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
         1682  +  } $r
         1683  +}
         1684  +
         1685  +# Should get the same search results when the page size is very large
         1686  +#
         1687  +do_test fts4aa-3.0 {
         1688  +  db close
         1689  +  file delete -force test.db
         1690  +  sqlite3 db test.db
         1691  +  db eval {
         1692  +    PRAGMA page_size=65536;
         1693  +    CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
         1694  +  }
         1695  +  fts4aa_fill_table
         1696  +} {}
         1697  +unset -nocomplain ii
         1698  +set ii 0
         1699  +foreach {q r} [array get fts4aa_res] {
         1700  +  incr ii
         1701  +  do_test fts4aa-3.$ii {
         1702  +    db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
         1703  +  } $r
         1704  +}
         1705  +
         1706  +# Should get the same search results when an authorizer prevents
         1707  +# all PRAGMA statements.
         1708  +#
         1709  +proc no_pragma_auth {code arg1 arg2 arg3 arg4} {
         1710  +  if {$code=="SQLITE_PRAGMA"} {return SQLITE_DENY}
         1711  +  return SQLITE_OK;
         1712  +}
         1713  +do_test fts4aa-4.0 {
         1714  +  db auth ::no_pragma_auth
         1715  +  db eval {
         1716  +    DROP TABLE t1;
         1717  +    CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);
         1718  +  }
         1719  +  fts4aa_fill_table
         1720  +} {}
         1721  +unset -nocomplain ii
         1722  +set ii 0
         1723  +foreach {q r} [array get fts4aa_res] {
         1724  +  incr ii
         1725  +  do_test fts4aa-4.$ii {
         1726  +    db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}
         1727  +  } $r
         1728  +}
  1632   1729   
  1633   1730   finish_test