Index: src/sqlite.h.in ================================================================== --- src/sqlite.h.in +++ src/sqlite.h.in @@ -28,11 +28,11 @@ ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** 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_ #include /* Needed for the definition of va_list */ @@ -967,15 +967,20 @@ ** To get an accurate count of the number of rows deleted, use ** "DELETE FROM table WHERE 1" instead. ** ** 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 ** while [sqlite3_changes()] is running then the value returned @@ -1013,10 +1018,14 @@ ** {F12261} The [sqlite3_total_changes()] returns the total number ** of row changes caused by INSERT, UPDATE, and/or DELETE ** statements on the same [database connection], in any ** 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 ** while [sqlite3_total_changes()] is running then the value Index: src/vacuum.c ================================================================== --- src/vacuum.c +++ src/vacuum.c @@ -12,11 +12,11 @@ ** 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.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" #if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH) @@ -82,15 +82,19 @@ int rc = SQLITE_OK; /* Return code from service routines */ Btree *pMain; /* The database being vacuumed */ 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 ){ sqlite3SetString(pzErrMsg, "cannot VACUUM from within a transaction", (char*)0); @@ -251,10 +255,12 @@ } 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 ** was committed at the btree level). So it safe to end the transaction ** by manually setting the autoCommit flag to true and detaching the