]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix the VACUUM command so that it does not modify the changes counts
authordrh <drh@noemail.net>
Wed, 21 May 2008 13:44:13 +0000 (13:44 +0000)
committerdrh <drh@noemail.net>
Wed, 21 May 2008 13:44:13 +0000 (13:44 +0000)
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

manifest
manifest.uuid
src/sqlite.h.in
src/vacuum.c

index cbfbfb8cbf61205daba3639e747ee48f662e7d9c..21585b65c8b6abf4db8be90c0b0b03b579d1b41a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sOS/2\scompilation\sfor\spre-C99\scompilers.\s(CVS\s5150)
-D 2008-05-20T19:08:54
+C Fix\sthe\sVACUUM\scommand\sso\sthat\sit\sdoes\snot\smodify\sthe\schanges\scounts\nreported\sby\ssqlite3_changes()\sor\ssqlite3_total_changes().\s\sUpdate\sdocumentation\non\ssqlite3_changes()\sand\ssqlite3_total_changes()\sto\sstate\sthat\n"DELETE\sFROM\stable"\srecords\sa\schange\scount\sof\szero.\s(CVS\s5151)
+D 2008-05-21T13:44:14
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in 79aeba12300a54903f1b1257c1e7c190234045dd
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -130,7 +130,7 @@ F src/printf.c f2d4f6c5b0ec24b643e85fe60258adad8b1f6acc
 F src/random.c 2b2db2de4ab491f5a14d3480466f8f4b5a5db74a
 F src/select.c da43ce3080112aa77863e9c570c1df19a892acb8
 F src/shell.c a12ea645271b7876c8f080146f48e20b00d367ec
-F src/sqlite.h.in b953ce955c65c07a024212ff76863a5f98c33c79
+F src/sqlite.h.in 96b68b840683341d0a312bb7211570335842d271
 F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3
 F src/sqliteInt.h 70a2b0bf856bbdb86b10d994ea863f6591ab7144
 F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
@@ -166,7 +166,7 @@ F src/trigger.c 1e751f8d5ceeb328d26bf1ccfb2de50653670d49
 F src/update.c 2d7143b9014e955509cc4f323f9a9584fb898f34
 F src/utf.c 8c94fa10efc78c2568d08d436acc59df4df7191b
 F src/util.c 43277088f8fea4109a640aa46731b8752c3fb4a7
-F src/vacuum.c c3b2b70677f874102b8753bf494c232e777f3998
+F src/vacuum.c a5c289e561ed72283e97d2485491986bc7d684eb
 F src/vdbe.c 25a362a4fdd5ff2797db0e20a9cf4300e053891e
 F src/vdbe.h f4bb70962d9c13e0f65b215c90e8acea1ae6e8ee
 F src/vdbeInt.h ede1a31cfa74d4718f41da491bd1d2b3abc137fc
@@ -636,7 +636,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 894085a59cdc60c34c8a3eb560d98bcb4a087cb1
-R 9cd012b9b6638413801262c433fecb94
-U pweilbacher
-Z d561cc78f2b3ec86435123f580dbcd83
+P de8e67182d8f9d1f0b215da93a396b9467604a50
+R 5e43d7445a41e487e91a32f3f92251f9
+U drh
+Z f00defe86398257c2a438618ab5ea19b
index 2b6fdf0e371d773c7ae82e2bce852a8d2547e8e4..c59f946d2d46bf4c49b4467cb071f7db0d7d0dd0 100644 (file)
@@ -1 +1 @@
-de8e67182d8f9d1f0b215da93a396b9467604a50
\ No newline at end of file
+f5d61d7d982b58accaf33df4362ce4a5eb79307e
\ No newline at end of file
index 06f61b077576630c4112cc5abe33dc4f8bf48f4c..b584d8bf19eed0d4c9e151a5d97efbd7e40f5124 100644 (file)
@@ -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
index 469c314d68216711c8a2ba9ba7ff6eae54946192..ea2f535cad5cc51968eb78c684d78310b30d1771 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.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