Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Get AUTOINCREMENT and VACUUM working together. Ticket #1095. (CVS 2311) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
332a531d06a610e6597b02105fcda767 |
User & Date: | drh 2005-02-03 01:08:20.000 |
Context
2005-02-04
| ||
04:07 | Remove code for SQL cursors. (CVS 2312) (check-in: 2eb9087055 user: danielk1977 tags: trunk) | |
2005-02-03
| ||
01:08 | Get AUTOINCREMENT and VACUUM working together. Ticket #1095. (CVS 2311) (check-in: 332a531d06 user: drh tags: trunk) | |
00:42 | Fix the ".dump" command in the shell so that it works with AUTOVACUUM. This is related to ticket #1095. (CVS 2310) (check-in: 76c4a96c5a user: drh tags: trunk) | |
Changes
Changes to src/vacuum.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** This file contains code used to implement the VACUUM command. ** ** Most of the code in this file may be omitted by defining the ** SQLITE_OMIT_VACUUM macro. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** This file contains code used to implement the VACUUM command. ** ** Most of the code in this file may be omitted by defining the ** SQLITE_OMIT_VACUUM macro. ** ** $Id: vacuum.c,v 1.37 2005/02/03 01:08:20 drh Exp $ */ #include "sqliteInt.h" #include "os.h" #ifndef SQLITE_OMIT_VACUUM /* ** Generate a random name of 20 character in length. |
︙ | ︙ | |||
175 176 177 178 179 180 181 | if( rc!=SQLITE_OK ) goto end_of_vacuum; /* Query the schema of the main database. Create a mirror schema ** in the temporary database. */ rc = execExecSql(db, "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14,100000000) " | | | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | if( rc!=SQLITE_OK ) goto end_of_vacuum; /* Query the schema of the main database. Create a mirror schema ** in the temporary database. */ rc = execExecSql(db, "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14,100000000) " " FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence'"); if( rc!=SQLITE_OK ) goto end_of_vacuum; rc = execExecSql(db, "SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14,100000000)" " FROM sqlite_master WHERE sql LIKE 'CREATE INDEX %' "); if( rc!=SQLITE_OK ) goto end_of_vacuum; rc = execExecSql(db, "SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21,100000000) " |
︙ | ︙ | |||
199 200 201 202 203 204 205 | ** an "INSERT INTO vacuum_db.xxx SELECT * FROM xxx;" to copy ** the contents to the temporary database. */ rc = execExecSql(db, "SELECT 'INSERT INTO vacuum_db.' || quote(name) " "|| ' SELECT * FROM ' || quote(name) || ';'" "FROM sqlite_master " | | > > > > > > > > > > > > > | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | ** an "INSERT INTO vacuum_db.xxx SELECT * FROM xxx;" to copy ** the contents to the temporary database. */ rc = execExecSql(db, "SELECT 'INSERT INTO vacuum_db.' || quote(name) " "|| ' SELECT * FROM ' || quote(name) || ';'" "FROM sqlite_master " "WHERE type = 'table' AND name!='sqlite_sequence';" ); if( rc!=SQLITE_OK ) goto end_of_vacuum; /* Copy over the sequence table */ rc = execExecSql(db, "SELECT 'DELETE FROM vacuum_db.' || quote(name) || ';' " "FROM sqlite_master WHERE name='sqlite_sequence' " "UNION ALL " "SELECT 'INSERT INTO vacuum_db.' || quote(name) " "|| ' SELECT * FROM ' || quote(name) || ';' " "FROM sqlite_master WHERE name=='sqlite_sequence';" ); if( rc!=SQLITE_OK ) goto end_of_vacuum; /* Copy the triggers from the main database to the temporary database. ** This was deferred before in case the triggers interfered with copying ** the data. It's possible the indices should be deferred until this ** point also. */ rc = execExecSql(db, |
︙ | ︙ |
Changes to test/vacuum.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # 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. The # focus of this file is testing the VACUUM statement. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # 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. The # focus of this file is testing the VACUUM statement. # # $Id: vacuum.test,v 1.33 2005/02/03 01:08:20 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # If the VACUUM statement is disabled in the current build, skip all # the tests in this file. # |
︙ | ︙ | |||
261 262 263 264 265 266 267 268 269 | sqlite3 db2 a'z.db execsql { CREATE TABLE t1(t); VACUUM; } db2 } {} db2 close # finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | sqlite3 db2 a'z.db execsql { CREATE TABLE t1(t); VACUUM; } db2 } {} db2 close # Ticket #1095: Vacuum a table that uses AUTOINCREMENT # ifcapable {autoinc} { do_test vacuum-9.1 { execsql { DROP TABLE 'abc abc'; CREATE TABLE autoinc(a INTEGER PRIMARY KEY AUTOINCREMENT, b); INSERT INTO autoinc(b) VALUES('hi'); INSERT INTO autoinc(b) VALUES('there'); DELETE FROM autoinc; } set ::cksum [cksum] expr {$::cksum!=""} } {1} do_test vacuum-9.2 { execsql { VACUUM; } cksum } $::cksum do_test vacuum-9.3 { execsql { INSERT INTO autoinc(b) VALUES('one'); INSERT INTO autoinc(b) VALUES('two'); } set ::cksum [cksum] expr {$::cksum!=""} } {1} do_test vacuum-9.4 { execsql { VACUUM; } cksum } $::cksum } # finish_test |