]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Get VACUUM working with UNIQUE indices. Ticket #829. (CVS 1870)
authordrh <drh@noemail.net>
Mon, 26 Jul 2004 23:07:51 +0000 (23:07 +0000)
committerdrh <drh@noemail.net>
Mon, 26 Jul 2004 23:07:51 +0000 (23:07 +0000)
FossilOrigin-Name: 88a19a4386708c3c10448740d2bbe149055bcc6e

manifest
manifest.uuid
src/vacuum.c
test/vacuum.test

index 6ab3d0525de4d26f3acac34e2b838489a10b8f66..05e0025a033223c828317c51719d99be90b05d0a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C add\ssqlite3_get_auxdata\ssqlite3_set_auxdata\sC\sAPI\sexports\s(CVS\s1869)
-D 2004-07-26T15:31:21
+C Get\sVACUUM\sworking\swith\sUNIQUE\sindices.\s\sTicket\s#829.\s(CVS\s1870)
+D 2004-07-26T23:07:52
 F Makefile.in 4a5e570a9e2d35b09c31b3cf01b78cea764ade4b
 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -73,7 +73,7 @@ F src/trigger.c 360cf8f12edd4eb3a8a2895b136aac238c3cf44e
 F src/update.c b66b1896c9da54678ba3eff2bf0b4d291a95986a
 F src/utf.c f03535db72bfa09e24202ccdd245f21d2fc65f0a
 F src/util.c 2aacc79b7bf5df5859813dafd3bf3258f67a5234
-F src/vacuum.c 23ec8c5f3134c6315f883d648fa63b72d8c3ead3
+F src/vacuum.c 9978a5760c2c430bc5b5e66505a02dad76f25813
 F src/vdbe.c f40f4ca4d9a7ba7c330e5673419f32dd3512547c
 F src/vdbe.h 75b241c02431b9c0f16eaa9cdbb34146c6287f52
 F src/vdbeInt.h 3d8e08c54dcb5ca2169db8bb3a37b81a12efaecd
@@ -180,7 +180,7 @@ F test/types2.test f23c147a2ab3e51d5dbcfa9987200db5acba7aa7
 F test/unique.test 0e38d4cc7affeef2527720d1dafd1f6870f02f2b
 F test/update.test b29bd9061a1150426dab6959806fcc73a41b1217
 F test/utf16.test 459c2f5ab80c60092c603630a348c32d6e59c558
-F test/vacuum.test 51d3a52535f77af6fb6fa7e742230f4958a708c1
+F test/vacuum.test 3aabfb73dcafffed01fefd0789f2fcc8540b9b52
 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
 F test/view.test ca5c296989d3045f121be9a67588ff88c64874a8
 F test/where.test 9c5752b807b78078fab8da6f52e689832579ca20
@@ -240,7 +240,7 @@ F www/tclsqlite.tcl 06a86cba4d7fc88e2bcd633b57702d3d16abebb5
 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P e3cad1ab6226089265b4d15c6fc67cc33a31425f
-R 40da3b6dcd5f1faf460eec98cdfa23eb
-U dougcurrie
-Z a41c984af00128c15325725263cd022e
+P 15bfb2d153b9ffbb6b59146e1288d0e2e4cdf66f
+R ee707c764e2bb8451fb37013b45cc605
+U drh
+Z ba6b19d006dc27280511a74c7f232d33
index 99ffd8c2e276674fa92121526d2887107030ef69..a733d61a2848368f667466131f91eeebea674176 100644 (file)
@@ -1 +1 @@
-15bfb2d153b9ffbb6b59146e1288d0e2e4cdf66f
\ No newline at end of file
+88a19a4386708c3c10448740d2bbe149055bcc6e
\ No newline at end of file
index c1a35051eae8173d81c2738951db2fb329041f17..81a8bcd04af6932ff77b8eb33e8387d33355662f 100644 (file)
@@ -14,7 +14,7 @@
 ** Most of the code in this file may be omitted by defining the
 ** SQLITE_OMIT_VACUUM macro.
 **
-** $Id: vacuum.c,v 1.27 2004/07/24 14:35:59 drh Exp $
+** $Id: vacuum.c,v 1.28 2004/07/26 23:07:52 drh Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -160,11 +160,17 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
   ** in the temporary database.
   */
   rc = execExecSql(db, 
-      "SELECT 'CREATE ' || type || ' vacuum_db.' || "
-      "substr(sql, length(type)+9, 1000000) "
-      "FROM sqlite_master "
-      "WHERE type != 'trigger' AND sql IS NOT NULL "
-      "ORDER BY (type != 'table');" 
+      "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14,100000000) "
+      "  FROM sqlite_master WHERE type='table' "
+      "UNION ALL "
+      "SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14,100000000) "
+      "  FROM sqlite_master WHERE sql LIKE 'CREATE INDEX %' "
+      "UNION ALL "
+      "SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21,100000000) "
+      "  FROM sqlite_master WHERE sql LIKE 'CREATE UNIQUE INDEX %'"
+      "UNION ALL "
+      "SELECT 'CREATE VIEW vacuum_db.' || substr(sql,13,100000000) "
+      "  FROM sqlite_master WHERE type='view'"
   );
   if( rc!=SQLITE_OK ) goto end_of_vacuum;
 
@@ -186,10 +192,8 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
   ** point also.
   */
   rc = execExecSql(db, 
-      "SELECT 'CREATE ' || type || ' vacuum_db.' || "
-      "substr(sql, length(type)+9, 1000000) "
-      "FROM sqlite_master "
-      "WHERE type = 'trigger' AND sql IS NOT NULL;"
+      "SELECT 'CREATE TRIGGER  vacuum_db.' || substr(sql, 16, 1000000) "
+      "FROM sqlite_master WHERE type='trigger'"
   );
   if( rc!=SQLITE_OK ) goto end_of_vacuum;
 
index ec9008358ff971647967499eaedc598cef33de7a..107e2b49642979b59599b507c139bd9c2d9536ae 100644 (file)
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the VACUUM statement.
 #
-# $Id: vacuum.test,v 1.23 2004/06/30 10:54:30 danielk1977 Exp $
+# $Id: vacuum.test,v 1.24 2004/07/26 23:07:52 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
 
+set fcnt 1
 proc cksum {{db db}} {
   set sql "SELECT name, type, sql FROM sqlite_master ORDER BY name, type"
   set txt [$db eval $sql]\n
@@ -23,9 +24,16 @@ proc cksum {{db db}} {
   foreach tbl [$db eval $sql] {
     append txt [$db eval "SELECT * FROM $tbl"]\n
   }
-  foreach prag {default_synchronous default_cache_size} {
+  foreach prag {default_cache_size} {
     append txt $prag-[$db eval "PRAGMA $prag"]\n
   }
+  if 1 {
+    global fcnt
+    set fd [open dump$fcnt.txt w]
+    puts -nonewline $fd $txt
+    close $fd
+    incr fcnt
+  }
   set cksum [string length $txt]-[md5 $txt]
   # puts $cksum-[file size test.db]
   return $cksum
@@ -44,6 +52,7 @@ do_test vacuum-1.1 {
     INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
     INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
     CREATE INDEX i1 ON t1(b,c);
+    CREATE UNIQUE INDEX i2 ON t1(c,a);
     CREATE TABLE t2 AS SELECT * FROM t1;
     COMMIT;
     DROP TABLE t2;