/ Check-in [298113d4]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Check in the missing status.c source file. (CVS 5245)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 298113d4a707ecf59d5dfd8bca45bfe734fb9fbb
User & Date: drh 2008-06-19 13:20:02
Context
2008-06-19
15:06
Add recent API additions to the loadable extension interface. (CVS 5246) check-in: 12ba27d9 user: drh tags: trunk
13:20
Check in the missing status.c source file. (CVS 5245) check-in: 298113d4 user: drh tags: trunk
08:51
Shuffle some of the mutex related documentation in sqlite.h.in to match the new sqlite3_mutex_methods based API. (CVS 5244) check-in: 9cd7f866 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added src/status.c.











































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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;
}