]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Check in the missing status.c source file. (CVS 5245)
authordrh <drh@noemail.net>
Thu, 19 Jun 2008 13:20:01 +0000 (13:20 +0000)
committerdrh <drh@noemail.net>
Thu, 19 Jun 2008 13:20:01 +0000 (13:20 +0000)
FossilOrigin-Name: 298113d4a707ecf59d5dfd8bca45bfe734fb9fbb

manifest
manifest.uuid
src/status.c [new file with mode: 0644]

index 8f9127ff66e0d1faeb4183bed9722d81ffaaf0b8..3ffd9ba39dfca271dc1693e63ba3a46d994d02c3 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Shuffle\ssome\sof\sthe\smutex\srelated\sdocumentation\sin\ssqlite.h.in\sto\smatch\sthe\snew\ssqlite3_mutex_methods\sbased\sAPI.\s(CVS\s5244)
-D 2008-06-19T08:51:24
+C Check\sin\sthe\smissing\sstatus.c\ssource\sfile.\s(CVS\s5245)
+D 2008-06-19T13:20:02
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in ff6f90048555a0088f6a4b7406bed5e55a7c4eff
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -147,6 +147,7 @@ F src/sqlite.h.in cc64323ecc21320692c12726102976689ee5ae53
 F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3
 F src/sqliteInt.h 6dd55232e738a4dac23475cd4b0e444dff75c896
 F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
+F src/status.c 6cb10377992505bd69f1ca1d75c1240a65f25a58
 F src/table.c 1fa8f8113ac9cbc09ae4801c6d2a7f0af82c5822
 F src/tclsqlite.c 4dd9ee4cb44846ad9bcc4d0da8088c1e7d4b33d9
 F src/test1.c e78c07d7f1db40593ab1e4aa321016184af0c7ad
@@ -599,7 +600,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 565a530896b40790287eeaad709edd51980fbddf
-R 950854b62a7a587d35382e80a0549a75
-U danielk1977
-Z 2b8089afd328ee7a65250c0132b39dd9
+P 9cd7f8669a59c6096331229df2e2ad87e628abab
+R 2ae02cc3666590b0ae8cac03168cec93
+U drh
+Z dc8fb3a0d249f077cc181d199fa20d70
index 862802d6f4a3983d9d4943d45a01762bfcf657a4..3e83217856726f881472cd04bbf90cf047a06f8e 100644 (file)
@@ -1 +1 @@
-9cd7f8669a59c6096331229df2e2ad87e628abab
\ No newline at end of file
+298113d4a707ecf59d5dfd8bca45bfe734fb9fbb
\ No newline at end of file
diff --git a/src/status.c b/src/status.c
new file mode 100644 (file)
index 0000000..f4afa18
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+** 2008 June 18
+**
+** 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 module implements the sqlite3_status() interface and related
+** functionality.
+**
+** $Id: status.c,v 1.1 2008/06/19 13:20:02 drh Exp $
+*/
+#include "sqliteInt.h"
+
+/*
+** Variables in which to record status information.
+*/
+static struct {
+  int nowValue[6];         /* Current value */
+  int mxValue[6];          /* Maximum value */
+} sqlite3Stat;
+
+
+/*
+** Reset the status records.  This routine is called by
+** sqlite3_initialize().
+*/
+void sqlite3StatusReset(void){
+  memset(&sqlite3Stat, 0, sizeof(sqlite3Stat));
+}
+
+/*
+** Return the current value of a status parameter.
+*/
+int sqlite3StatusValue(int op){
+  assert( op>=0 && op<ArraySize(sqlite3Stat.nowValue) );
+  return sqlite3Stat.nowValue[op];
+}
+
+/*
+** Add N to the value of a status record.  It is assumed that the
+** caller holds appropriate locks.
+*/
+void sqlite3StatusAdd(int op, int N){
+  assert( op>=0 && op<ArraySize(sqlite3Stat.nowValue) );
+  sqlite3Stat.nowValue[op] += N;
+  if( sqlite3Stat.nowValue[op]>sqlite3Stat.mxValue[op] ){
+    sqlite3Stat.mxValue[op] = sqlite3Stat.nowValue[op];
+  }
+}
+
+/*
+** Set the value of a status to X.
+*/
+void sqlite3StatusSet(int op, int X){
+  assert( op>=0 && op<ArraySize(sqlite3Stat.nowValue) );
+  sqlite3Stat.nowValue[op] = X;
+  if( sqlite3Stat.nowValue[op]>sqlite3Stat.mxValue[op] ){
+    sqlite3Stat.mxValue[op] = sqlite3Stat.nowValue[op];
+  }
+}
+
+/*
+** Query status information.
+**
+** This implementation assumes that reading or writing an aligned
+** 32-bit integer is an atomic operation.  If that assumption is not true,
+** then this routine is not threadsafe.
+*/
+int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
+  if( op<0 || op>=ArraySize(sqlite3Stat.nowValue) ){
+    return SQLITE_MISUSE;
+  }
+  *pCurrent = sqlite3Stat.nowValue[op];
+  *pHighwater = sqlite3Stat.mxValue[op];
+  if( resetFlag ){
+    sqlite3Stat.mxValue[op] = sqlite3Stat.nowValue[op];
+  }
+  return SQLITE_OK;
+}