]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add an experimental sqlite3_get_autocommit() API used to test whether or not
authordrh <drh@noemail.net>
Thu, 26 May 2005 16:23:34 +0000 (16:23 +0000)
committerdrh <drh@noemail.net>
Thu, 26 May 2005 16:23:34 +0000 (16:23 +0000)
changes are committed automatically. (CVS 2486)

FossilOrigin-Name: 4a7f1275857602e3841ccb2d43a5c4d3d3e87bff

manifest
manifest.uuid
src/main.c
src/sqlite.h.in
src/test1.c
test/capi3.test

index 6e6f421d6ca2ad5a0128f1a0121d0c04a64bcc98..f302ce885b6aad86a3b73a9ed3e5322f9634671a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sa\s-cleanup\soption\sto\sTcl\stest\sproc\sdo_ioerr_test.\s(CVS\s2485)
-D 2005-05-26T15:20:53
+C Add\san\sexperimental\ssqlite3_get_autocommit()\sAPI\sused\sto\stest\swhether\sor\snot\nchanges\sare\scommitted\sautomatically.\s(CVS\s2486)
+D 2005-05-26T16:23:34
 F Makefile.in 8129e7f261d405db783676f9ca31e0841768c652
 F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -43,7 +43,7 @@ F src/hash.c 2b1b13f7400e179631c83a1be0c664608c8f021f
 F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84
 F src/insert.c 34c25c33f51a43644a42cc091ac967b070c6b6d5
 F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b
-F src/main.c 9fa85c83f5fc6344dcf412db6034375377b7a494
+F src/main.c f61bdb0a1afeb2eff7285f4f3752e1085ecc55ed
 F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
 F src/os.h e5438be25cf96858787bf9b60fc7a2420e139ee3
 F src/os_common.h 0e7f428ba0a6c40a61bc56c4e96f493231301b73
@@ -62,11 +62,11 @@ F src/printf.c 3d20b21cfecadacecac3fb7274e746cb81d3d357
 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
 F src/select.c 071a484044efb74fb5d8f79560822cbfc7c906c3
 F src/shell.c 25b3217d7c64e6497225439d261a253a23efff26
-F src/sqlite.h.in 3675e3ada207e09b9d52a0463561325df4ac26b5
+F src/sqlite.h.in f28f5b018f03a66aaf0bc1ab6985d8605d6b964f
 F src/sqliteInt.h 0de60fafa8d9a15b03b4ed2cfbc2372a5b259295
 F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9
 F src/tclsqlite.c af0f002d9d6ab4f7f32b9bee5b57665946e76ad9
-F src/test1.c 4ad7ffe5a74fd99d4f73f6fd28ba27f403b3adba
+F src/test1.c 6a8943111d63b31433be49d9f9f7bee796ef12e1
 F src/test2.c 7f0ef466706ac01414e1136b96e5d8a65cb97545
 F src/test3.c 683e1e3819152ffd35da2f201e507228921148d0
 F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df
@@ -110,7 +110,7 @@ F test/btree5.test 8e5ff32c02e685d36516c6499add9375fe1377f2
 F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027
 F test/btree7.test a6d3b842db22af97dd14b989e90a2fd96066b72f
 F test/capi2.test f897209386fb21cfdc9267595e0c667ebaca9164
-F test/capi3.test 7c1c91895239fef05427ceb628a193cb4f61031f
+F test/capi3.test feadced0b3cc4085c328439b7e64ce7963801c5b
 F test/capi3b.test 5b6a66f9f295f79f443b5d3f33187fa5ef6cf336
 F test/collate1.test f79736d2ebf5492167ee4d1f4ab4c09dda776b03
 F test/collate2.test 224a632ba04907c049804b08162efd234aa7871f
@@ -281,7 +281,7 @@ F www/tclsqlite.tcl 425be741b8ae664f55cb1ef2371aab0a75109cf9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b
-P 7f67b9f0f398583651d226fabf2fafd2635d772a
-R c6bfa60e45e3c36269b49426e1b9d927
-U danielk1977
-Z 0110a3d4036ad18c1628df7000ce6af7
+P b0a898c05a2285c87d7da4d47dd697c58a0d4d58
+R 113e24d04585bd6cfafaa3cb61125259
+U drh
+Z f82135b994cfa2d26c1f56d5cdbaf4d2
index d67dea4da05493e72de128a86f6ad08863b9b10e..0a7b5afaab67d50dae20d97f6af4b5cc4232e8f8 100644 (file)
@@ -1 +1 @@
-b0a898c05a2285c87d7da4d47dd697c58a0d4d58
\ No newline at end of file
+4a7f1275857602e3841ccb2d43a5c4d3d3e87bff
\ No newline at end of file
index f247803903cda734dc34fff03159ced7b4776a73..0becf229e87c19153b32040e88ab31bceb093da5 100644 (file)
@@ -14,7 +14,7 @@
 ** other files are for internal use by SQLite and should not be
 ** accessed by users of the library.
 **
-** $Id: main.c,v 1.292 2005/05/26 12:37:30 danielk1977 Exp $
+** $Id: main.c,v 1.293 2005/05/26 16:23:34 drh Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -989,3 +989,15 @@ recover_out:
   return rc;
 }
 #endif
+
+/*
+** Test to see whether or not the database connection is in autocommit
+** mode.  Return TRUE if it is and FALSE if not.  Autocommit mode is on
+** by default.  Autocommit is disabled by a BEGIN statement and reenabled
+** by the next COMMIT or ROLLBACK.
+**
+******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
+*/
+int sqlite3_get_autocommit(sqlite3 *db){
+  return db->autoCommit;
+}
index 5e494e028cdbb9ebbdfee63d5e7b0e8de71a7d50..97a93b4aa61b8fe00bad08c2813d4e5e28d2a7bb 100644 (file)
@@ -12,7 +12,7 @@
 ** This header file defines the interface that the SQLite library
 ** presents to client programs.
 **
-** @(#) $Id: sqlite.h.in,v 1.133 2005/04/22 02:38:38 drh Exp $
+** @(#) $Id: sqlite.h.in,v 1.134 2005/05/26 16:23:34 drh Exp $
 */
 #ifndef _SQLITE3_H_
 #define _SQLITE3_H_
@@ -1252,6 +1252,18 @@ extern char *sqlite3_temp_directory;
 */
 int sqlite3_global_recover();
 
+/*
+** Test to see whether or not the database connection is in autocommit
+** mode.  Return TRUE if it is and FALSE if not.  Autocommit mode is on
+** by default.  Autocommit is disabled by a BEGIN statement and reenabled
+** by the next COMMIT or ROLLBACK.
+**
+******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******
+*/
+int sqlite3_get_autocommit(sqlite3*);
+
+
+
 #ifdef __cplusplus
 }  /* End of the 'extern "C"' block */
 #endif
index 0099566f507b7862fbab8fc3e503d47dae28c655..862706208cfbeed9f3befaad244a7f43eb90505b 100644 (file)
@@ -13,7 +13,7 @@
 ** is not included in the SQLite library.  It is used for automated
 ** testing of the SQLite library.
 **
-** $Id: test1.c,v 1.138 2005/04/28 17:18:49 drh Exp $
+** $Id: test1.c,v 1.139 2005/05/26 16:23:34 drh Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -2694,6 +2694,31 @@ static int delete_collation(
   return TCL_OK;
 }
 
+/*
+** Usage: sqlite3_get_autocommit DB
+**
+** Return true if the database DB is currently in auto-commit mode.
+** Return false if not.
+*/
+static int get_autocommit(
+  void * clientData,
+  Tcl_Interp *interp,
+  int argc,
+  char **argv
+){
+  char zBuf[30];
+  sqlite3 *db;
+  if( argc!=2 ){
+    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 
+        " DB", 0);
+    return TCL_ERROR;
+  }
+  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
+  sprintf(zBuf, "%d", sqlite3_get_autocommit(db));
+  Tcl_AppendResult(interp, zBuf, 0);
+  return TCL_OK;
+}
+
 /*
 ** Usage:  tcl_variable_type VARIABLENAME
 **
@@ -2965,8 +2990,9 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
 #if 0
      { "sqlite3_sleep",                 (Tcl_CmdProc*)test_sleep            },
 #endif
-     { "sqlite_delete_function",       (Tcl_CmdProc*)delete_function        },
-     { "sqlite_delete_collation",      (Tcl_CmdProc*)delete_collation       }
+     { "sqlite_delete_function",        (Tcl_CmdProc*)delete_function       },
+     { "sqlite_delete_collation",       (Tcl_CmdProc*)delete_collation      },
+     { "sqlite3_get_autocommit",        (Tcl_CmdProc*)get_autocommit        },
   };
   static struct {
      char *zName;
index d573eda3cb55d11f624cbf548048291e296d8d08..2505a0d8bab62c74ed500afed7a53f94619744bc 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script testing the callback-free C/C++ API.
 #
-# $Id: capi3.test,v 1.31 2005/03/09 12:26:51 danielk1977 Exp $
+# $Id: capi3.test,v 1.32 2005/05/26 16:23:34 drh Exp $
 #
 
 set testdir [file dirname $argv0]
@@ -54,6 +54,9 @@ proc utf8 {str} {
 db close
 set DB [sqlite3 db test.db]
 
+do_test capi3-1.0 {
+  sqlite3_get_autocommit $DB
+} 1
 do_test capi3-1.1 {
   set STMT [sqlite3_prepare $DB {SELECT name FROM sqlite_master} -1 TAIL]
   sqlite3_finalize $STMT
@@ -641,6 +644,9 @@ do_test capi3-11.1 {
     INSERT INTO t1 VALUES(2, 'notatype');
   }
 } {}
+do_test capi3-11.1.1 {
+  sqlite3_get_autocommit $DB
+} 0
 do_test capi3-11.2 {
   set STMT [sqlite3_prepare $DB "SELECT func(b, a) FROM t1" -1 TAIL]
   sqlite3_step $STMT
@@ -650,6 +656,9 @@ do_test capi3-11.3 {
     COMMIT;
   }
 } {1 {cannot commit transaction - SQL statements in progress}}
+do_test capi3-11.3.1 {
+  sqlite3_get_autocommit $DB
+} 0
 do_test capi3-11.4 {
   sqlite3_step $STMT
 } {SQLITE_ERROR}
@@ -661,11 +670,17 @@ do_test capi3-11.6 {
     SELECT * FROM t1;
   }
 } {0 {1 int 2 notatype}}
+do_test capi3-11.6.1 {
+  sqlite3_get_autocommit $DB
+} 0
 do_test capi3-11.7 {
   catchsql {
     COMMIT;
   }
 } {0 {}}
+do_test capi3-11.7.1 {
+  sqlite3_get_autocommit $DB
+} 1
 do_test capi3-11.8 {
   execsql {
     CREATE TABLE t2(a);
@@ -675,15 +690,24 @@ do_test capi3-11.8 {
     INSERT INTO t2 VALUES(3);
   }
 } {}
+do_test capi3-11.8.1 {
+  sqlite3_get_autocommit $DB
+} 0
 do_test capi3-11.9 {
   set STMT [sqlite3_prepare $DB "SELECT a FROM t2" -1 TAIL]
   sqlite3_step $STMT
 } {SQLITE_ROW}
-do_test capi3-11.3 {
+do_test capi3-11.9.1 {
+  sqlite3_get_autocommit $DB
+} 0
+do_test capi3-11.9.2 {
   catchsql {
     ROLLBACK;
   }
 } {1 {cannot rollback transaction - SQL statements in progress}}
+do_test capi3-11.9.3 {
+  sqlite3_get_autocommit $DB
+} 0
 do_test capi3-11.10 {
   sqlite3_step $STMT
 } {SQLITE_ROW}
@@ -701,11 +725,17 @@ do_test capi3-11.14 {
     SELECT a FROM t2;
   }
 } {1 2 3}
+do_test capi3-11.14.1 {
+  sqlite3_get_autocommit $DB
+} 0
 do_test capi3-11.15 {
   catchsql {
     ROLLBACK;
   }
 } {0 {}}
+do_test capi3-11.15.1 {
+  sqlite3_get_autocommit $DB
+} 1
 do_test capi3-11.16 {
   execsql {
     SELECT a FROM t2;