]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Purge lingering references to SQLITE_STAT2 from the code and test scripts.
authordrh <drh@noemail.net>
Fri, 21 Oct 2011 19:06:32 +0000 (19:06 +0000)
committerdrh <drh@noemail.net>
Fri, 21 Oct 2011 19:06:32 +0000 (19:06 +0000)
FossilOrigin-Name: aed2bf7a3c828a7191389b3f8235a9387977b476

13 files changed:
manifest
manifest.uuid
src/analyze.c
src/build.c
src/ctime.c
src/sqliteInt.h
src/test_config.c
src/where.c
test/alter.test
test/analyze2.test [deleted file]
test/analyze3.test
test/auth.test
test/malloc.test

index 368c393f8f086ceee1ebf47c499b3c6ad8cbc942..fa0c41a3b7d96549e8e17dd597ff5868e27d0c31 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\sstale\srequirements\smarks\sfrom\sthe\squery\splanner.
-D 2011-10-21T16:47:31.558
+C Purge\slingering\sreferences\sto\sSQLITE_STAT2\sfrom\sthe\scode\sand\stest\sscripts.
+D 2011-10-21T19:06:32.669
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -118,7 +118,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
 F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
 F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad
 F src/alter.c ac80a0f31189f8b4a524ebf661e47e84536ee7f5
-F src/analyze.c 682fd999a01c897a682365a459190758b83de836
+F src/analyze.c 5a1db16a651ce6310c8b046b2cbb736e030e14b9
 F src/attach.c 12c6957996908edc31c96d7c68d4942c2474405f
 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
 F src/backup.c 4368158da74d4711888e03264105c5c527d76caf
@@ -127,10 +127,10 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
 F src/btree.c 32199e2d939233ade25340eaba450f818b37c079
 F src/btree.h f5d775cd6cfc7ac32a2535b70e8d2af48ef5f2ce
 F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3
-F src/build.c ae152efb9c2d6615b14adb7a5f2c51483d4d55df
+F src/build.c 8af67a08a852ff4c63701963cb1ab7166f577814
 F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a
 F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
-F src/ctime.c 829f3261d3db48e3d87891bc887208734734c2e4
+F src/ctime.c a9c26822515f81ec21588cbb482ca6724be02e33
 F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4
 F src/delete.c ff68e5ef23aee08c0ff528f699a19397ed8bbed8
 F src/expr.c fbf116f90cabc917ae50bba24a73a0b55519a0c8
@@ -183,7 +183,7 @@ F src/select.c 80f3ac44a8514b1d107b80f5df4a424ae059d2b6
 F src/shell.c f0ab793261ab045a0b8c47fa2707e8a894d2898f
 F src/sqlite.h.in c3d7085eb5f7d3b4ce7a484e0ecb9082e57daab1
 F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93
-F src/sqliteInt.h 6f8e592fc28d16160d017684966b3528833a46c1
+F src/sqliteInt.h c74457cd2c4bd77683bac76e698bf2ec2d3e13f9
 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
 F src/status.c 4568e72dfd36b6a5911f93457364deb072e0b03a
 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
@@ -201,7 +201,7 @@ F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad
 F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e
 F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de
 F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2
-F src/test_config.c baf4eda361adc7444bd452d352999fea351fe256
+F src/test_config.c bc8826296a7b3a86eeaba1ac2af5551d1c20c35b
 F src/test_demovfs.c 20a4975127993f4959890016ae9ce5535a880094
 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc
 F src/test_func.c cbdec5cededa0761daedde5baf06004a9bf416b5
@@ -251,19 +251,18 @@ F src/vtab.c 901791a47318c0562cd0c676a2c6ff1bc530e582
 F src/wal.c 9658df8d404b82e6b2d40fd05944463214e2d935
 F src/wal.h 66b40bd91bc29a5be1c88ddd1f5ade8f3f48728a
 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
-F src/where.c 922145a39cf91a5dbb83bbc54f0e316f52023fa2
+F src/where.c 7c85f4c93058e27100d404f0777aaeb0d1b296ae
 F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
 F test/all.test 52fc8dee494092031a556911d404ca30a749a30b
-F test/alter.test 54912d932309df2e4f62aeb47169c2ff740e53ed
+F test/alter.test 66f5818f9848c4f22de022a345fae25bcd30f8fb
 F test/alter2.test 7ea05c7d92ac99349a802ef7ada17294dd647060
 F test/alter3.test 49c9d9fba2b8fcdce2dedeca97bbf1f369cc548d
 F test/alter4.test b2debc14d8cbe4c1d12ccd6a41eef88a8c1f15d5
 F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc
 F test/analyze.test f8ab7d15858b4093b06caf5e57e2a5ff7104bdae
-F test/analyze2.test 8f2b1534d43f5547ce9a6b736c021d4192c75be3
-F test/analyze3.test 9be0af5e23b711559e8f78c42a6c04de956cba9b
+F test/analyze3.test c3c7f6c3951900c188cf94b2d5ee3246d6b3ff89
 F test/analyze4.test 757b37875cf9bb528d46f74497bc789c88365045
 F test/analyze5.test 713354664c5ff1853ab2cbcb740f0cf5cb7c802e
 F test/analyze6.test bd3625806a5ee6f7bef72d06295bd319f0290af2
@@ -279,7 +278,7 @@ F test/attach2.test e54436ed956d3d88bdee61221da59bf3935a0966
 F test/attach3.test d89ccfe4fe6e2b5e368d480fcdfe4b496c54cf4e
 F test/attach4.test 53bf502f17647c6d6c5add46dda6bac8b6f4665c
 F test/attachmalloc.test 3a4bfca9545bfe906a8d2e622de10fbac5b711b0
-F test/auth.test ac996c81ad910148606f5c7e3b3f85d47c29960f
+F test/auth.test 304e82f31592820d3bde26ab6b75deaa123e1a6f
 F test/auth2.test 270baddc8b9c273682760cffba6739d907bd2882
 F test/auth3.test a4755e6a2a2fea547ffe63c874eb569e60a28eb5
 F test/autoinc.test bd30d372d00045252f6c2e41b5f41455e1975acf
@@ -565,7 +564,7 @@ F test/lock_common.tcl 0c270b121d40959fa2f3add382200c27045b3d95
 F test/lookaside.test 93f07bac140c5bb1d49f3892d2684decafdc7af2
 F test/main.test 39c4bb8a157f57298ed1659d6df89d9f35aaf2c8
 F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9
-F test/malloc.test 8c727fe29fccd280cbf8f6acf08bd10b76beaf34
+F test/malloc.test bc745155ff4252d4f35ec8316625b0dfe2abc659
 F test/malloc3.test de8eca0c3e748878845fdca3663ec4b642073caf
 F test/malloc4.test 957337613002b7058a85116493a262f679f3a261
 F test/malloc5.test 30dc30b57fa22552eba0d8c95210d96c3d958a39
@@ -972,7 +971,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
-P 07159e84b40b01fa40cac5fad1f433888e5984f8
-R 59b3b1fdd8178d0f82d2b752104b93d8
+P 76de9914bed11abda3898928633ad09d5a284f84
+R 9b3a6c060ffdadcd5f6abcd839fba359
 U drh
-Z 3d414bcbeacde088fb044f861f268a3d
+Z ef6fbf08b85d3319379c1b870a96f90d
index f4d78eed3e799b665bf61c84b58576fa43ec517c..07d577aadfab8df2df266e004933641f020a1db7 100644 (file)
@@ -1 +1 @@
-76de9914bed11abda3898928633ad09d5a284f84
\ No newline at end of file
+aed2bf7a3c828a7191389b3f8235a9387977b476
\ No newline at end of file
index 99929e93c768487e5f4c66cc4b6480647ca880ff..b6a987ab85408bc15495a25446b055ae65437d61 100644 (file)
 /*
 ** This routine generates code that opens the sqlite_stat1 table for
 ** writing with cursor iStatCur. If the library was built with the
-** SQLITE_ENABLE_STAT2 macro defined, then the sqlite_stat2 table is
+** SQLITE_ENABLE_STAT3 macro defined, then the sqlite_stat3 table is
 ** opened for writing using cursor (iStatCur+1)
 **
 ** If the sqlite_stat1 tables does not previously exist, it is created.
-** Similarly, if the sqlite_stat2 table does not exist and the library
-** is compiled with SQLITE_ENABLE_STAT2 defined, it is created. 
+** Similarly, if the sqlite_stat3 table does not exist and the library
+** is compiled with SQLITE_ENABLE_STAT3 defined, it is created. 
 **
 ** Argument zWhere may be a pointer to a buffer containing a table name,
 ** or it may be a NULL pointer. If it is not NULL, then all entries in
-** the sqlite_stat1 and (if applicable) sqlite_stat2 tables associated
+** the sqlite_stat1 and (if applicable) sqlite_stat3 tables associated
 ** with the named table are deleted. If zWhere==0, then code is generated
 ** to delete all stat table entries.
 */
index 050643d183ba512131b432e636de5b0a488a6421..e23aab6b19115b496999667f6365dae77e95bacb 100644 (file)
@@ -1981,7 +1981,7 @@ static void destroyTable(Parse *pParse, Table *pTab){
 }
 
 /*
-** Remove entries from the sqlite_stat1 and sqlite_stat2 tables
+** Remove entries from the sqlite_statN tables (for N in (1,2,3))
 ** after a DROP INDEX or DROP TABLE command.
 */
 static void sqlite3ClearStatTables(
@@ -1990,18 +1990,15 @@ static void sqlite3ClearStatTables(
   const char *zType,     /* "idx" or "tbl" */
   const char *zName      /* Name of index or table */
 ){
-  static const char *azStatTab[] = { 
-    "sqlite_stat1",
-    "sqlite_stat2",
-    "sqlite_stat3",
-  };
   int i;
   const char *zDbName = pParse->db->aDb[iDb].zName;
-  for(i=0; i<ArraySize(azStatTab); i++){
-    if( sqlite3FindTable(pParse->db, azStatTab[i], zDbName) ){
+  for(i=1; i<=3; i++){
+    char zTab[24];
+    sqlite3_snprintf(sizeof(zTab),zTab,"sqlite_stat%d",i);
+    if( sqlite3FindTable(pParse->db, zTab, zDbName) ){
       sqlite3NestedParse(pParse,
         "DELETE FROM %Q.%s WHERE %s=%Q",
-        zDbName, azStatTab[i], zType, zName
+        zDbName, zTab, zType, zName
       );
     }
   }
index bea7faaf44e8feb374e64574d45e9da1350cf601..1688069cb393bba73ed593395563522f9bb6501f 100644 (file)
@@ -114,9 +114,6 @@ static const char * const azCompileOpt[] = {
 #ifdef SQLITE_ENABLE_RTREE
   "ENABLE_RTREE",
 #endif
-#ifdef SQLITE_ENABLE_STAT2
-  "ENABLE_STAT2",
-#endif
 #ifdef SQLITE_ENABLE_STAT3
   "ENABLE_STAT3",
 #endif
index ed1a8d17da5721f8e028cce566ba80b1e93aa507..9e276541c65c2186b60a340b2f8fccce43d53196 100644 (file)
 #include <inttypes.h>
 #endif
 
-/*
-** The number of samples of an index that SQLite takes in order to 
-** construct a histogram of the table content when running ANALYZE
-** and with SQLITE_ENABLE_STAT2
-*/
-#define SQLITE_INDEX_SAMPLES 10
-
 /*
 ** The following macros are used to cast pointers to integers and
 ** integers to pointers.  The way you do this varies from one compiler
@@ -1514,8 +1507,9 @@ struct Index {
 };
 
 /*
-** Each sample stored in the sqlite_stat2 table is represented in memory 
-** using a structure of this type.
+** Each sample stored in the sqlite_stat3 table is represented in memory 
+** using a structure of this type.  See documentation at the top of the
+** analyze.c source file for additional information.
 */
 struct IndexSample {
   union {
index b0efe232470c2ec718e487d44c730f206abd8294..ce72f87376adde3167dcb05ea22e8223098320f4 100644 (file)
@@ -424,12 +424,6 @@ Tcl_SetVar2(interp, "sqlite_options", "long_double",
   Tcl_SetVar2(interp, "sqlite_options", "schema_version", "1", TCL_GLOBAL_ONLY);
 #endif
 
-#ifdef SQLITE_ENABLE_STAT2
-  Tcl_SetVar2(interp, "sqlite_options", "stat2", "1", TCL_GLOBAL_ONLY);
-#else
-  Tcl_SetVar2(interp, "sqlite_options", "stat2", "0", TCL_GLOBAL_ONLY);
-#endif
-
 #ifdef SQLITE_ENABLE_STAT3
   Tcl_SetVar2(interp, "sqlite_options", "stat3", "1", TCL_GLOBAL_ONLY);
 #else
index 7a4b8bfaeeb9ef4b96644993f96c383bd24fe077..05414da58b4cf02dcca176d42a25ab192eca4426 100644 (file)
@@ -3167,7 +3167,7 @@ static void bestBtreeIndex(
     ** slower with larger records, presumably because fewer records fit
     ** on one page and hence more pages have to be fetched.
     **
-    ** The ANALYZE command and the sqlite_stat1 and sqlite_stat2 tables do
+    ** The ANALYZE command and the sqlite_stat1 and sqlite_stat3 tables do
     ** not give us data on the relative sizes of table and index records.
     ** So this computation assumes table records are about twice as big
     ** as index records
index e915d26c50481cbf5ba70311c8e4870d1d3c0ddf..1481bc20190bc2179423581504ff3ccd763058c3 100644 (file)
@@ -846,7 +846,6 @@ do_test alter-14.2 {
 set system_table_list {1 sqlite_master}
 catchsql ANALYZE
 ifcapable analyze { lappend system_table_list 2 sqlite_stat1 }
-ifcapable stat2   { lappend system_table_list 3 sqlite_stat2 }
 ifcapable stat3   { lappend system_table_list 4 sqlite_stat3 }
 
 foreach {tn tbl} $system_table_list {
diff --git a/test/analyze2.test b/test/analyze2.test
deleted file mode 100644 (file)
index de2567b..0000000
+++ /dev/null
@@ -1,554 +0,0 @@
-# 2009 August 06
-#
-# The author disclaims copyright to this source code.  In place of
-# a legal notice, here is a blessing:
-#
-#    May you do good and not evil.
-#    May you find forgiveness for yourself and forgive others.
-#    May you share freely, never taking more than you give.
-#
-#***********************************************************************
-#
-# This file implements regression tests for SQLite library. This file 
-# implements tests for the extra functionality provided by the ANALYZE 
-# command when the library is compiled with SQLITE_ENABLE_STAT2 defined.
-#
-
-set testdir [file dirname $argv0]
-source $testdir/tester.tcl
-
-ifcapable !stat2 {
-  finish_test
-  return
-}
-
-set testprefix analyze2
-
-# Do not use a codec for tests in this file, as the database file is
-# manipulated directly using tcl scripts (using the [hexio_write] command).
-#
-do_not_use_codec
-
-#--------------------------------------------------------------------
-# Test organization:
-#
-# analyze2-1.*: Tests to verify that ANALYZE creates and populates the
-#               sqlite_stat2 table as expected.
-#
-# analyze2-2.*: Test that when a table has two indexes on it and either
-#               index may be used for the scan, the index suggested by
-#               the contents of sqlite_stat2 table is prefered.
-# 
-# analyze2-3.*: Similar to the previous block of tests, but using tables
-#               that contain a mixture of NULL, numeric, text and blob
-#               values.
-#
-# analyze2-4.*: Check that when an indexed column uses a collation other
-#               than BINARY, the collation is taken into account when
-#               using the contents of sqlite_stat2 to estimate the cost
-#               of a range scan.
-#
-# analyze2-5.*: Check that collation sequences are used as described above
-#               even when the only available version of the collation 
-#               function require UTF-16 encoded arguments.
-#
-# analyze2-6.*: Check that the library behaves correctly when one of the
-#               sqlite_stat2 or sqlite_stat1 tables are missing.
-#
-# analyze2-7.*: Check that in a shared-schema situation, nothing goes
-#               wrong if sqlite_stat2 data is read by one connection,
-#               and freed by another.
-# 
-
-proc eqp {sql {db db}} {
-  uplevel execsql [list "EXPLAIN QUERY PLAN $sql"] $db
-}
-
-do_test analyze2-1.1 {
-  execsql { CREATE TABLE t1(x PRIMARY KEY) }
-  for {set i 0} {$i < 1000} {incr i} {
-    execsql { INSERT INTO t1 VALUES($i) }
-  }
-  execsql { 
-    ANALYZE;
-    SELECT * FROM sqlite_stat2;
-  }
-} [list t1 sqlite_autoindex_t1_1 0 50  \
-        t1 sqlite_autoindex_t1_1 1 149 \
-        t1 sqlite_autoindex_t1_1 2 249 \
-        t1 sqlite_autoindex_t1_1 3 349 \
-        t1 sqlite_autoindex_t1_1 4 449 \
-        t1 sqlite_autoindex_t1_1 5 549 \
-        t1 sqlite_autoindex_t1_1 6 649 \
-        t1 sqlite_autoindex_t1_1 7 749 \
-        t1 sqlite_autoindex_t1_1 8 849 \
-        t1 sqlite_autoindex_t1_1 9 949 \
-]
-
-do_test analyze2-1.2 {
-  execsql {
-    DELETE FROM t1 WHERe x>9;
-    ANALYZE;
-    SELECT tbl, idx, group_concat(sample, ' ') FROM sqlite_stat2;
-  }
-} {t1 sqlite_autoindex_t1_1 {0 1 2 3 4 5 6 7 8 9}}
-do_test analyze2-1.3 {
-  execsql {
-    DELETE FROM t1 WHERE x>8;
-    ANALYZE;
-    SELECT * FROM sqlite_stat2;
-  }
-} {}
-do_test analyze2-1.4 {
-  execsql {
-    DELETE FROM t1;
-    ANALYZE;
-    SELECT * FROM sqlite_stat2;
-  }
-} {}
-
-do_test analyze2-2.1 {
-  execsql { 
-    BEGIN;
-    DROP TABLE t1;
-    CREATE TABLE t1(x, y);
-    CREATE INDEX t1_x ON t1(x);
-    CREATE INDEX t1_y ON t1(y);
-  }
-  for {set i 0} {$i < 1000} {incr i} {
-    execsql { INSERT INTO t1 VALUES($i, $i) }
-  }
-  execsql COMMIT
-  execsql ANALYZE
-} {}
-do_eqp_test 2.2 {
-  SELECT * FROM t1 WHERE x>500 AND y>700
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_y (y>?) (~100 rows)}
-}
-do_eqp_test 2.3 {
-  SELECT * FROM t1 WHERE x>700 AND y>500
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_x (x>?) (~100 rows)}
-}
-do_eqp_test 2.3 {
-  SELECT * FROM t1 WHERE y>700 AND x>500
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_y (y>?) (~100 rows)}
-}
-do_eqp_test 2.4 {
-  SELECT * FROM t1 WHERE y>500 AND x>700
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_x (x>?) (~100 rows)}
-}
-do_eqp_test 2.5 {
-  SELECT * FROM t1 WHERE x BETWEEN 100 AND 200 AND y BETWEEN 400 AND 700
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_x (x>? AND x<?) (~25 rows)}
-}
-do_eqp_test 2.6 {
-  SELECT * FROM t1 WHERE x BETWEEN 100 AND 500 AND y BETWEEN 400 AND 700
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_y (y>? AND y<?) (~75 rows)}
-}
-do_eqp_test 2.7 {
-  SELECT * FROM t1 WHERE x BETWEEN -400 AND -300 AND y BETWEEN 100 AND 300
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_x (x>? AND x<?) (~12 rows)}
-}
-do_eqp_test 2.8 {
-  SELECT * FROM t1 WHERE x BETWEEN 100 AND 300 AND y BETWEEN -400 AND -300
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_y (y>? AND y<?) (~12 rows)}
-}
-do_eqp_test 2.9 {
-  SELECT * FROM t1 WHERE x BETWEEN 500 AND 100 AND y BETWEEN 100 AND 300
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_x (x>? AND x<?) (~12 rows)}
-}
-do_eqp_test 2.10 {
-  SELECT * FROM t1 WHERE x BETWEEN 100 AND 300 AND y BETWEEN 500 AND 100
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_y (y>? AND y<?) (~12 rows)}
-}
-
-do_test analyze2-3.1 {
-  set alphabet [list a b c d e f g h i j]
-  execsql BEGIN
-  for {set i 0} {$i < 1000} {incr i} {
-    set str    [lindex $alphabet [expr ($i/100)%10]] 
-    append str [lindex $alphabet [expr ($i/ 10)%10]]
-    append str [lindex $alphabet [expr ($i/  1)%10]]
-    execsql { INSERT INTO t1 VALUES($str, $str) }
-  }
-  execsql COMMIT
-  execsql ANALYZE
-  execsql { 
-    SELECT tbl,idx,group_concat(sample,' ') 
-    FROM sqlite_stat2 
-    WHERE idx = 't1_x' 
-    GROUP BY tbl,idx
-  }
-} {t1 t1_x {100 299 499 699 899 ajj cjj ejj gjj ijj}}
-do_test analyze2-3.2 {
-  execsql { 
-    SELECT tbl,idx,group_concat(sample,' ') 
-    FROM sqlite_stat2 
-    WHERE idx = 't1_y' 
-    GROUP BY tbl,idx
-  }
-} {t1 t1_y {100 299 499 699 899 ajj cjj ejj gjj ijj}}
-
-do_eqp_test 3.3 {
-  SELECT * FROM t1 WHERE x BETWEEN 100 AND 500 AND y BETWEEN 'a' AND 'b'
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_y (y>? AND y<?) (~50 rows)}
-}
-do_eqp_test 3.4 {
-  SELECT * FROM t1 WHERE x BETWEEN 100 AND 400 AND y BETWEEN 'a' AND 'h'
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_x (x>? AND x<?) (~100 rows)}
-}
-do_eqp_test 3.5 {
-  SELECT * FROM t1 WHERE x<'a' AND y>'h'
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_y (y>?) (~66 rows)}
-}
-do_eqp_test 3.6 {
-  SELECT * FROM t1 WHERE x<444 AND y>'h'
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_y (y>?) (~66 rows)}
-}
-do_eqp_test 3.7 {
-  SELECT * FROM t1 WHERE x<221 AND y>'g'
-} {
-  0 0 0 {SEARCH TABLE t1 USING INDEX t1_x (x<?) (~66 rows)}
-}
-
-do_test analyze2-4.1 {
-  execsql { CREATE TABLE t3(a COLLATE nocase, b) }
-  execsql { CREATE INDEX t3a ON t3(a) }
-  execsql { CREATE INDEX t3b ON t3(b) }
-  set alphabet [list A b C d E f G h I j]
-  execsql BEGIN
-  for {set i 0} {$i < 1000} {incr i} {
-    set str    [lindex $alphabet [expr ($i/100)%10]] 
-    append str [lindex $alphabet [expr ($i/ 10)%10]]
-    append str [lindex $alphabet [expr ($i/  1)%10]]
-    execsql { INSERT INTO t3 VALUES($str, $str) }
-  }
-  execsql COMMIT
-  execsql ANALYZE
-} {}
-do_test analyze2-4.2 {
-  execsql { 
-    PRAGMA automatic_index=OFF;
-    SELECT tbl,idx,group_concat(sample,' ') 
-    FROM sqlite_stat2 
-    WHERE idx = 't3a' 
-    GROUP BY tbl,idx;
-    PRAGMA automatic_index=ON;
-  }
-} {t3 t3a {AfA bEj CEj dEj EEj fEj GEj hEj IEj jEj}}
-do_test analyze2-4.3 {
-  execsql { 
-    SELECT tbl,idx,group_concat(sample,' ') 
-    FROM sqlite_stat2 
-    WHERE idx = 't3b' 
-    GROUP BY tbl,idx
-  }
-} {t3 t3b {AbA CIj EIj GIj IIj bIj dIj fIj hIj jIj}}
-
-do_eqp_test 4.4 {
-  SELECT * FROM t3 WHERE a > 'A' AND a < 'C' AND b > 'A' AND b < 'C'
-} {
-  0 0 0 {SEARCH TABLE t3 USING INDEX t3b (b>? AND b<?) (~11 rows)}
-}
-do_eqp_test 4.5 {
-  SELECT * FROM t3 WHERE a > 'A' AND a < 'c' AND b > 'A' AND b < 'c'
-} {
-  0 0 0 {SEARCH TABLE t3 USING INDEX t3a (a>? AND a<?) (~22 rows)}
-}
-
-ifcapable utf16 {
-  proc test_collate {enc lhs rhs} {
-    # puts $enc
-    return [string compare $lhs $rhs]
-  }
-  do_test analyze2-5.1 {
-    add_test_collate db 0 0 1
-    execsql { CREATE TABLE t4(x COLLATE test_collate) }
-    execsql { CREATE INDEX t4x ON t4(x) }
-    set alphabet [list a b c d e f g h i j]
-    execsql BEGIN
-    for {set i 0} {$i < 1000} {incr i} {
-      set str    [lindex $alphabet [expr ($i/100)%10]] 
-      append str [lindex $alphabet [expr ($i/ 10)%10]]
-      append str [lindex $alphabet [expr ($i/  1)%10]]
-      execsql { INSERT INTO t4 VALUES($str) }
-    }
-    execsql COMMIT
-    execsql ANALYZE
-  } {}
-  do_test analyze2-5.2 {
-    execsql { 
-      SELECT tbl,idx,group_concat(sample,' ') 
-      FROM sqlite_stat2 
-      WHERE tbl = 't4' 
-      GROUP BY tbl,idx
-    }
-  } {t4 t4x {afa bej cej dej eej fej gej hej iej jej}}
-  do_eqp_test 5.3 {
-    SELECT * FROM t4 WHERE x>'ccc'
-  } {0 0 0 {SEARCH TABLE t4 USING COVERING INDEX t4x (x>?) (~800 rows)}}
-  do_eqp_test 5.4 {
-    SELECT * FROM t4 AS t41, t4 AS t42 WHERE t41.x>'ccc' AND t42.x>'ggg'
-  } {
-    0 0 1 {SEARCH TABLE t4 AS t42 USING COVERING INDEX t4x (x>?) (~300 rows)} 
-    0 1 0 {SEARCH TABLE t4 AS t41 USING COVERING INDEX t4x (x>?) (~800 rows)}
-  }
-  do_eqp_test 5.5 {
-    SELECT * FROM t4 AS t41, t4 AS t42 WHERE t41.x>'ddd' AND t42.x>'ccc'
-  } {
-    0 0 0 {SEARCH TABLE t4 AS t41 USING COVERING INDEX t4x (x>?) (~700 rows)} 
-    0 1 1 {SEARCH TABLE t4 AS t42 USING COVERING INDEX t4x (x>?) (~800 rows)}
-  }
-}
-
-#--------------------------------------------------------------------
-# These tests, analyze2-6.*, verify that the library behaves correctly
-# when one of the sqlite_stat1 and sqlite_stat2 tables is missing.
-#
-# If the sqlite_stat1 table is not present, then the sqlite_stat2
-# table is not read. However, if it is the sqlite_stat2 table that
-# is missing, the data in the sqlite_stat1 table is still used.
-#
-# Tests analyze2-6.1.* test the libary when the sqlite_stat2 table
-# is missing. Tests analyze2-6.2.* test the library when sqlite_stat1
-# is not present.
-#
-do_test analyze2-6.0 {
-  execsql {
-    DROP TABLE IF EXISTS t4;
-    CREATE TABLE t5(a, b); CREATE INDEX t5i ON t5(a, b);
-    CREATE TABLE t6(a, b); CREATE INDEX t6i ON t6(a, b);
-  }
-  for {set ii 0} {$ii < 20} {incr ii} {
-    execsql {
-      INSERT INTO t5 VALUES($ii, $ii);
-      INSERT INTO t6 VALUES($ii/10, $ii/10);
-    }
-  }
-  execsql { 
-    CREATE TABLE master AS 
-    SELECT * FROM sqlite_master WHERE name LIKE 'sqlite_stat%' 
-  }
-} {}
-
-do_test analyze2-6.1.1 {
-  eqp {SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-       t5.a = 1 AND
-       t6.a = 1 AND t6.b = 1
-  }
-} {0 0 1 {SEARCH TABLE t6 USING COVERING INDEX t6i (a=? AND b=?) (~9 rows)} 0 1 0 {SEARCH TABLE t5 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-do_test analyze2-6.1.2 {
-  db cache flush
-  execsql ANALYZE
-  eqp {SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-       t5.a = 1 AND
-       t6.a = 1 AND t6.b = 1
-  }
-} {0 0 0 {SEARCH TABLE t5 USING COVERING INDEX t5i (a=?) (~1 rows)} 0 1 1 {SEARCH TABLE t6 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-do_test analyze2-6.1.3 {
-  sqlite3 db test.db
-  eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-       t5.a = 1 AND
-       t6.a = 1 AND t6.b = 1
-  }
-} {0 0 0 {SEARCH TABLE t5 USING COVERING INDEX t5i (a=?) (~1 rows)} 0 1 1 {SEARCH TABLE t6 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-do_test analyze2-6.1.4 {
-  execsql { 
-    PRAGMA writable_schema = 1;
-    DELETE FROM sqlite_master WHERE tbl_name = 'sqlite_stat2';
-  }
-  sqlite3 db test.db
-  eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-       t5.a = 1 AND
-       t6.a = 1 AND t6.b = 1
-  }
-} {0 0 0 {SEARCH TABLE t5 USING COVERING INDEX t5i (a=?) (~1 rows)} 0 1 1 {SEARCH TABLE t6 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-do_test analyze2-6.1.5 {
-  execsql { 
-    PRAGMA writable_schema = 1;
-    DELETE FROM sqlite_master WHERE tbl_name = 'sqlite_stat1';
-  }
-  sqlite3 db test.db
-  eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-       t5.a = 1 AND
-       t6.a = 1 AND t6.b = 1
-  }
-} {0 0 1 {SEARCH TABLE t6 USING COVERING INDEX t6i (a=? AND b=?) (~9 rows)} 0 1 0 {SEARCH TABLE t5 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-do_test analyze2-6.1.6 {
-  execsql { 
-    PRAGMA writable_schema = 1;
-    INSERT INTO sqlite_master SELECT * FROM master;
-  }
-  sqlite3 db test.db
-  eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-       t5.a = 1 AND
-       t6.a = 1 AND t6.b = 1
-  }
-} {0 0 0 {SEARCH TABLE t5 USING COVERING INDEX t5i (a=?) (~1 rows)} 0 1 1 {SEARCH TABLE t6 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-
-do_test analyze2-6.2.1 {
-  execsql { 
-    DELETE FROM sqlite_stat1;
-    DELETE FROM sqlite_stat2;
-  }
-  sqlite3 db test.db
-  eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-        t5.a>1 AND t5.a<15 AND
-        t6.a>1
-  }
-} {0 0 0 {SEARCH TABLE t5 USING COVERING INDEX t5i (a>? AND a<?) (~60000 rows)} 0 1 1 {SEARCH TABLE t6 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-do_test analyze2-6.2.2 {
-  db cache flush
-  execsql ANALYZE
-  eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-        t5.a>1 AND t5.a<15 AND
-        t6.a>1
-  }
-} {0 0 1 {SEARCH TABLE t6 USING COVERING INDEX t6i (a>?) (~1 rows)} 0 1 0 {SEARCH TABLE t5 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-do_test analyze2-6.2.3 {
-  sqlite3 db test.db
-  eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-        t5.a>1 AND t5.a<15 AND
-        t6.a>1
-  }
-} {0 0 1 {SEARCH TABLE t6 USING COVERING INDEX t6i (a>?) (~1 rows)} 0 1 0 {SEARCH TABLE t5 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-do_test analyze2-6.2.4 {
-  execsql { 
-    PRAGMA writable_schema = 1;
-    DELETE FROM sqlite_master WHERE tbl_name = 'sqlite_stat1';
-  }
-  sqlite3 db test.db
-  eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-        t5.a>1 AND t5.a<15 AND
-        t6.a>1
-  }
-} {0 0 0 {SEARCH TABLE t5 USING COVERING INDEX t5i (a>? AND a<?) (~60000 rows)} 0 1 1 {SEARCH TABLE t6 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-do_test analyze2-6.2.5 {
-  execsql { 
-    PRAGMA writable_schema = 1;
-    DELETE FROM sqlite_master WHERE tbl_name = 'sqlite_stat2';
-  }
-  sqlite3 db test.db
-  eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-        t5.a>1 AND t5.a<15 AND
-        t6.a>1
-  }
-} {0 0 0 {SEARCH TABLE t5 USING COVERING INDEX t5i (a>? AND a<?) (~60000 rows)} 0 1 1 {SEARCH TABLE t6 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-do_test analyze2-6.2.6 {
-  execsql { 
-    PRAGMA writable_schema = 1;
-    INSERT INTO sqlite_master SELECT * FROM master;
-  }
-  sqlite3 db test.db
-  execsql ANALYZE
-  eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-        t5.a>1 AND t5.a<15 AND
-        t6.a>1
-  }
-} {0 0 1 {SEARCH TABLE t6 USING COVERING INDEX t6i (a>?) (~1 rows)} 0 1 0 {SEARCH TABLE t5 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-
-#--------------------------------------------------------------------
-# These tests, analyze2-7.*, test that the sqlite_stat2 functionality
-# works in shared-cache mode. Note that these tests reuse the database
-# created for the analyze2-6.* tests.
-#
-ifcapable shared_cache {
-  db close
-  set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
-
-  proc incr_schema_cookie {zDb} {
-    foreach iOffset {24 40} {
-      set cookie [hexio_get_int [hexio_read $zDb $iOffset 4]]
-      incr cookie
-      hexio_write $zDb $iOffset [hexio_render_int32 $cookie]
-    }
-  }
-
-  do_test analyze2-7.1 {
-    sqlite3 db1 test.db
-    sqlite3 db2 test.db
-    db1 cache size 0
-    db2 cache size 0
-    execsql { SELECT count(*) FROM t5 } db1
-  } {20}
-  do_test analyze2-7.2 {
-    incr_schema_cookie test.db
-    execsql { SELECT count(*) FROM t5 } db2
-  } {20}
-  do_test analyze2-7.3 {
-    incr_schema_cookie test.db
-    execsql { SELECT count(*) FROM t5 } db1
-  } {20}
-  do_test analyze2-7.4 {
-    incr_schema_cookie test.db
-    execsql { SELECT count(*) FROM t5 } db2
-  } {20}
-
-  do_test analyze2-7.5 {
-    eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-          t5.a>1 AND t5.a<15 AND
-          t6.a>1
-    } db1
-  } {0 0 1 {SEARCH TABLE t6 USING COVERING INDEX t6i (a>?) (~1 rows)} 0 1 0 {SEARCH TABLE t5 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-  do_test analyze2-7.6 {
-    incr_schema_cookie test.db
-    execsql { SELECT * FROM sqlite_master } db2
-    eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-          t5.a>1 AND t5.a<15 AND
-          t6.a>1
-    } db2
-  } {0 0 1 {SEARCH TABLE t6 USING COVERING INDEX t6i (a>?) (~1 rows)} 0 1 0 {SEARCH TABLE t5 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-  do_test analyze2-7.7 {
-    incr_schema_cookie test.db
-    execsql { SELECT * FROM sqlite_master } db1
-    eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-          t5.a>1 AND t5.a<15 AND
-          t6.a>1
-    } db1
-  } {0 0 1 {SEARCH TABLE t6 USING COVERING INDEX t6i (a>?) (~1 rows)} 0 1 0 {SEARCH TABLE t5 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-
-  do_test analyze2-7.8 {
-    execsql { DELETE FROM sqlite_stat2 } db2
-    execsql { SELECT * FROM sqlite_master } db1
-    eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-          t5.a>1 AND t5.a<15 AND
-          t6.a>1
-    } db1
-  } {0 0 1 {SEARCH TABLE t6 USING COVERING INDEX t6i (a>?) (~1 rows)} 0 1 0 {SEARCH TABLE t5 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-  do_test analyze2-7.9 {
-    execsql { SELECT * FROM sqlite_master } db2
-    eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-          t5.a>1 AND t5.a<15 AND
-          t6.a>1
-    } db2
-  } {0 0 1 {SEARCH TABLE t6 USING COVERING INDEX t6i (a>?) (~1 rows)} 0 1 0 {SEARCH TABLE t5 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-
-  do_test analyze2-7.10 {
-    incr_schema_cookie test.db
-    execsql { SELECT * FROM sqlite_master } db1
-    eqp { SELECT * FROM t5,t6 WHERE t5.rowid=t6.rowid AND 
-          t5.a>1 AND t5.a<15 AND
-          t6.a>1
-    } db1
-  } {0 0 0 {SEARCH TABLE t5 USING COVERING INDEX t5i (a>? AND a<?) (~1 rows)} 0 1 1 {SEARCH TABLE t6 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)}}
-
-  db1 close
-  db2 close
-  sqlite3_enable_shared_cache $::enable_shared_cache
-}
-
-finish_test
index 4e58200f5d1b7b51e75c49d124ee715cc054aba2..f705bc6661733facaadf0ba821dfb2948587b74f 100644 (file)
@@ -70,7 +70,7 @@ proc sf_execsql {sql {db db}} {
 #   Show that there are two possible plans for querying the table with
 #   a range constraint on the indexed column - "full table scan" or "use 
 #   the index". When the range is specified using literal values, SQLite
-#   is able to pick the best plan based on the samples in sqlite_stat2.
+#   is able to pick the best plan based on the samples in sqlite_stat3.
 #
 # analyze3-1.1.4 - 3.1.9
 #   Show that using SQL variables produces the same results as using
index 5b97a9d7421ec1f0c5e14f3102b805af4e41ba43..211ae7e21ceb483042658cd00a3f19b5245b66b6 100644 (file)
@@ -2321,14 +2321,10 @@ ifcapable compound&&subquery {
       }
     }
   }
-  ifcapable stat2 {
-    set stat2 "sqlite_stat2 "
+  ifcapable stat3 {
+    set stat3 "sqlite_stat3 "
   } else {
-    ifcapable stat3 {
-      set stat2 "sqlite_stat3 "
-    } else {
-      set stat2 ""
-    }
+    set stat3 ""
   }
   do_test auth-5.2 {
     execsql {
@@ -2337,7 +2333,7 @@ ifcapable compound&&subquery {
       WHERE type='table'
       ORDER BY name
     }
-  } "sqlite_stat1 ${stat2}t1 t2 t3 t4"
+  } "sqlite_stat1 ${stat3}t1 t2 t3 t4"
 }
 
 # Ticket #3944
index 1041ce842248ce3f1b4ea485c97d92e814b1c40f..0d213d7bb96ee8d331a79cc8509dcc81891e6980 100644 (file)
@@ -867,32 +867,6 @@ if {[db eval {PRAGMA locking_mode}]!="exclusive"} {
   catch { db2 close }
 }
 
-ifcapable stat2&&utf16 {
-  do_malloc_test 38 -tclprep {
-    add_test_collate db 0 0 1
-    execsql {
-      ANALYZE;
-      CREATE TABLE t4(x COLLATE test_collate);
-      CREATE INDEX t4x ON t4(x);
-      INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 0, 'aaa');
-      INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 1, 'aaa');
-      INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 2, 'aaa');
-      INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 3, 'aaa');
-      INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 4, 'aaa');
-      INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 5, 'aaa');
-      INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 6, 'aaa');
-      INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 7, 'aaa');
-      INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 8, 'aaa');
-      INSERT INTO sqlite_stat2 VALUES('t4', 't4x', 9, 'aaa');
-    }
-    db close
-    sqlite3 db test.db
-    sqlite3_db_config_lookaside db 0 0 0
-    add_test_collate db 0 0 1
-  } -sqlbody {
-    SELECT * FROM t4 AS t41, t4 AS t42 WHERE t41.x>'ddd' AND t42.x>'ccc'
-  }
-}
 
 # Test that if an OOM error occurs, aux-data is still correctly destroyed.
 # This test case was causing either a memory-leak or an assert() failure