aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2008-05-21 13:44:13 +0000
committerdrh <drh@noemail.net>2008-05-21 13:44:13 +0000
commite63b2c215eff711330341589da1e16b1ceb49a88 (patch)
treeb72db1c298ba697ce0b6b6707c426c97a6655ed3 /src
parent8407f0eb3e45575ab556da98c518140c6e2d41b8 (diff)
downloadsqlite-e63b2c215eff711330341589da1e16b1ceb49a88.tar.gz
sqlite-e63b2c215eff711330341589da1e16b1ceb49a88.zip
Fix the VACUUM command so that it does not modify the changes counts
reported by sqlite3_changes() or sqlite3_total_changes(). Update documentation on sqlite3_changes() and sqlite3_total_changes() to state that "DELETE FROM table" records a change count of zero. (CVS 5151) FossilOrigin-Name: f5d61d7d982b58accaf33df4362ce4a5eb79307e
Diffstat (limited to 'src')
-rw-r--r--src/sqlite.h.in15
-rw-r--r--src/vacuum.c8
2 files changed, 19 insertions, 4 deletions
diff --git a/src/sqlite.h.in b/src/sqlite.h.in
index 06f61b077..b584d8bf1 100644
--- a/src/sqlite.h.in
+++ b/src/sqlite.h.in
@@ -30,7 +30,7 @@
** the version number) and changes its name to "sqlite3.h" as
** part of the build process.
**
-** @(#) $Id: sqlite.h.in,v 1.315 2008/05/20 18:43:38 drh Exp $
+** @(#) $Id: sqlite.h.in,v 1.316 2008/05/21 13:44:14 drh Exp $
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
@@ -969,12 +969,17 @@ sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
**
** INVARIANTS:
**
-** {F12241} The [sqlite3_changes()] function returns the number of
+** {F12241} The [sqlite3_changes()] function shall return the number of
** row changes caused by the most recent INSERT, UPDATE,
** or DELETE statement on the same database connection and
-** within the same trigger context, or zero if there have
+** within the same or higher trigger context, or zero if there have
** not been any qualifying row changes.
**
+** {F12243} Statements of the form "DELETE FROM tablename" with no
+** WHERE clause shall cause subsequent calls to
+** [sqlite3_changes()] to return zero, regardless of the
+** number of rows originally in the table.
+**
** LIMITATIONS:
**
** {U12252} If a separate thread makes changes on the same database connection
@@ -1016,6 +1021,10 @@ int sqlite3_changes(sqlite3*);
** trigger context, since the database connection was
** created.
**
+** {F12263} Statements of the form "DELETE FROM tablename" with no
+** WHERE clause shall not change the value returned
+** by [sqlite3_total_changes()]
+**
** LIMITATIONS:
**
** {U12264} If a separate thread makes changes on the same database connection
diff --git a/src/vacuum.c b/src/vacuum.c
index 469c314d6..ea2f535ca 100644
--- a/src/vacuum.c
+++ b/src/vacuum.c
@@ -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.78 2008/04/30 16:38:23 drh Exp $
+** $Id: vacuum.c,v 1.79 2008/05/21 13:44:14 drh Exp $
*/
#include "sqliteInt.h"
#include "vdbeInt.h"
@@ -84,11 +84,15 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
Btree *pTemp; /* The temporary database we vacuum into */
char *zSql = 0; /* SQL statements */
int saved_flags; /* Saved value of the db->flags */
+ int saved_nChange; /* Saved value of db->nChange */
+ int saved_nTotalChange; /* Saved value of db->nTotalChange */
Db *pDb = 0; /* Database to detach at end of vacuum */
int nRes;
/* Save the current value of the write-schema flag before setting it. */
saved_flags = db->flags;
+ saved_nChange = db->nChange;
+ saved_nTotalChange = db->nTotalChange;
db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
if( !db->autoCommit ){
@@ -253,6 +257,8 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
end_of_vacuum:
/* Restore the original value of db->flags */
db->flags = saved_flags;
+ db->nChange = saved_nChange;
+ db->nTotalChange = saved_nTotalChange;
/* Currently there is an SQL level transaction open on the vacuum
** database. No locks are held on any other files (since the main file