mirror of
https://github.com/sqlite/sqlite.git
synced 2025-12-24 14:17:58 +03:00
Add the sqlite3_db_status64() interface.
FossilOrigin-Name: bb5b982dba774e6b8011e6c980d34131c378967fadc59a18fed1cefda596449a
This commit is contained in:
17
manifest
17
manifest
@@ -1,5 +1,5 @@
|
||||
C Remove\snewly\sunreachable\scode\sin\sthe\ssolver\sof\sthe\squery\splanner.
|
||||
D 2025-09-17T17:09:07.209
|
||||
C Add\sthe\ssqlite3_db_status64()\sinterface.
|
||||
D 2025-09-17T19:19:52.225
|
||||
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
@@ -744,12 +744,12 @@ F src/resolve.c f8d1d011aba0964ff1bdccd049d4d2c2fec217efd90d202a4bb775e926b2c25d
|
||||
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
|
||||
F src/select.c b95181711d59c36d9789e67f76c4cfec64b99f9629a50be5e6566e117b87d957
|
||||
F src/shell.c.in 458c1a24d19251db547770fac50ae9c94dca42c310f8ecc937e3c587cd76ac8d
|
||||
F src/sqlite.h.in 5732519a2acb09066032ceac21f25996eb3f28f807a4468e30633c7c70faae1c
|
||||
F src/sqlite.h.in 131a18ff5e648447b8412ee6a0de757ce025e061d3ddd737a5fe72d7001b24d1
|
||||
F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479
|
||||
F src/sqlite3ext.h 3f0c4ed6934e7309a61c6f3c30f70a30a5b869f785bb3d9f721a36c5e4359126
|
||||
F src/sqliteInt.h 27c73e48878d31ef230ba867d1f8c3af6aed357fd93ccc605d3f1aae007ea62b
|
||||
F src/sqliteLimit.h fe70bd8983e5d317a264f2ea97473b359faf3ebb0827877a76813f5cf0cdc364
|
||||
F src/status.c 0e72e4f6be6ccfde2488eb63210297e75f569f3ce9920f6c3d77590ec6ce5ffd
|
||||
F src/status.c 03d441b856391f7863da28cf1d59f61a38e24782ac4b75b0454dba42f8f6cdf7
|
||||
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
|
||||
F src/tclsqlite.c 3c604c49e6cf4211960a9ddb9505280fd22cde32175f40884c641c0f5a286036
|
||||
F src/tclsqlite.h 614b3780a62522bc9f8f2b9fb22689e8009958e7aa77e572d0f3149050af348a
|
||||
@@ -2175,8 +2175,11 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
|
||||
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
|
||||
F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 3b7a5babf0843c4b3ce93d26f1447218585ce645ec3acd942ac649204e16675a
|
||||
R c4d7c0664f61638db0cb05b5995d6ac5
|
||||
P 9abaa0ac2b3049341f36ff683ff6eebb589698bd910624aa24f11398d557b3c2
|
||||
R 805db115b49d544ce20e2219bf55f575
|
||||
T *branch * db-status64
|
||||
T *sym-db-status64 *
|
||||
T -sym-trunk *
|
||||
U drh
|
||||
Z 1c130d86b402705871af8ae469e01493
|
||||
Z aa94c20ffd25bd9873ab760178273927
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
branch trunk
|
||||
tag trunk
|
||||
branch db-status64
|
||||
tag db-status64
|
||||
|
||||
@@ -1 +1 @@
|
||||
9abaa0ac2b3049341f36ff683ff6eebb589698bd910624aa24f11398d557b3c2
|
||||
bb5b982dba774e6b8011e6c980d34131c378967fadc59a18fed1cefda596449a
|
||||
|
||||
@@ -8921,9 +8921,18 @@ int sqlite3_status64(
|
||||
** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
|
||||
** non-zero [error code] on failure.
|
||||
**
|
||||
** ^The sqlite3_db_status64(D,O,C,H,R) routine works exactly the same
|
||||
** way as sqlite3_db_status(D,O,C,H,R) routine except that the C and H
|
||||
** parameters are pointer to 64-bit integers (type: sqlite3_int64) instead
|
||||
** of pointers to 32-bit integers, which allows larger status values
|
||||
** to be returned. If a status value exceeds 2,147,483,647 then
|
||||
** sqlite3_db_status() will truncate the value whereas sqlite3_db_status64()
|
||||
** will return the full value.
|
||||
**
|
||||
** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
|
||||
*/
|
||||
int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
|
||||
int sqlite3_db_status64(sqlite3*,int,sqlite3_int64*,sqlite3_int64*,int);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Status Parameters for database connections
|
||||
|
||||
65
src/status.c
65
src/status.c
@@ -200,23 +200,25 @@ int sqlite3LookasideUsed(sqlite3 *db, int *pHighwater){
|
||||
/*
|
||||
** Query status information for a single database connection
|
||||
*/
|
||||
int sqlite3_db_status(
|
||||
sqlite3 *db, /* The database connection whose status is desired */
|
||||
int op, /* Status verb */
|
||||
int *pCurrent, /* Write current value here */
|
||||
int *pHighwater, /* Write high-water mark here */
|
||||
int resetFlag /* Reset high-water mark if true */
|
||||
int sqlite3_db_status64(
|
||||
sqlite3 *db, /* The database connection whose status is desired */
|
||||
int op, /* Status verb */
|
||||
sqlite3_int64 *pCurrent, /* Write current value here */
|
||||
sqlite3_int64 *pHighwtr, /* Write high-water mark here */
|
||||
int resetFlag /* Reset high-water mark if true */
|
||||
){
|
||||
int rc = SQLITE_OK; /* Return code */
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( !sqlite3SafetyCheckOk(db) || pCurrent==0|| pHighwater==0 ){
|
||||
if( !sqlite3SafetyCheckOk(db) || pCurrent==0|| pHighwtr==0 ){
|
||||
return SQLITE_MISUSE_BKPT;
|
||||
}
|
||||
#endif
|
||||
sqlite3_mutex_enter(db->mutex);
|
||||
switch( op ){
|
||||
case SQLITE_DBSTATUS_LOOKASIDE_USED: {
|
||||
*pCurrent = sqlite3LookasideUsed(db, pHighwater);
|
||||
int H = 0;
|
||||
*pCurrent = sqlite3LookasideUsed(db, &H);
|
||||
*pHighwtr = H;
|
||||
if( resetFlag ){
|
||||
LookasideSlot *p = db->lookaside.pFree;
|
||||
if( p ){
|
||||
@@ -247,7 +249,7 @@ int sqlite3_db_status(
|
||||
assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 );
|
||||
assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 );
|
||||
*pCurrent = 0;
|
||||
*pHighwater = (int)db->lookaside.anStat[op-SQLITE_DBSTATUS_LOOKASIDE_HIT];
|
||||
*pHighwtr = db->lookaside.anStat[op-SQLITE_DBSTATUS_LOOKASIDE_HIT];
|
||||
if( resetFlag ){
|
||||
db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0;
|
||||
}
|
||||
@@ -261,7 +263,7 @@ int sqlite3_db_status(
|
||||
*/
|
||||
case SQLITE_DBSTATUS_CACHE_USED_SHARED:
|
||||
case SQLITE_DBSTATUS_CACHE_USED: {
|
||||
int totalUsed = 0;
|
||||
sqlite3_int64 totalUsed = 0;
|
||||
int i;
|
||||
sqlite3BtreeEnterAll(db);
|
||||
for(i=0; i<db->nDb; i++){
|
||||
@@ -277,18 +279,18 @@ int sqlite3_db_status(
|
||||
}
|
||||
sqlite3BtreeLeaveAll(db);
|
||||
*pCurrent = totalUsed;
|
||||
*pHighwater = 0;
|
||||
*pHighwtr = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
** *pCurrent gets an accurate estimate of the amount of memory used
|
||||
** to store the schema for all databases (main, temp, and any ATTACHed
|
||||
** databases. *pHighwater is set to zero.
|
||||
** databases. *pHighwtr is set to zero.
|
||||
*/
|
||||
case SQLITE_DBSTATUS_SCHEMA_USED: {
|
||||
int i; /* Used to iterate through schemas */
|
||||
int nByte = 0; /* Used to accumulate return value */
|
||||
int i; /* Used to iterate through schemas */
|
||||
int nByte = 0; /* Used to accumulate return value */
|
||||
|
||||
sqlite3BtreeEnterAll(db);
|
||||
db->pnBytesFreed = &nByte;
|
||||
@@ -322,7 +324,7 @@ int sqlite3_db_status(
|
||||
db->lookaside.pEnd = db->lookaside.pTrueEnd;
|
||||
sqlite3BtreeLeaveAll(db);
|
||||
|
||||
*pHighwater = 0;
|
||||
*pHighwtr = 0;
|
||||
*pCurrent = nByte;
|
||||
break;
|
||||
}
|
||||
@@ -330,7 +332,7 @@ int sqlite3_db_status(
|
||||
/*
|
||||
** *pCurrent gets an accurate estimate of the amount of memory used
|
||||
** to store all prepared statements.
|
||||
** *pHighwater is set to zero.
|
||||
** *pHighwtr is set to zero.
|
||||
*/
|
||||
case SQLITE_DBSTATUS_STMT_USED: {
|
||||
struct Vdbe *pVdbe; /* Used to iterate through VMs */
|
||||
@@ -345,7 +347,7 @@ int sqlite3_db_status(
|
||||
db->lookaside.pEnd = db->lookaside.pTrueEnd;
|
||||
db->pnBytesFreed = 0;
|
||||
|
||||
*pHighwater = 0; /* IMP: R-64479-57858 */
|
||||
*pHighwtr = 0; /* IMP: R-64479-57858 */
|
||||
*pCurrent = nByte;
|
||||
|
||||
break;
|
||||
@@ -353,7 +355,7 @@ int sqlite3_db_status(
|
||||
|
||||
/*
|
||||
** Set *pCurrent to the total cache hits or misses encountered by all
|
||||
** pagers the database handle is connected to. *pHighwater is always set
|
||||
** pagers the database handle is connected to. *pHighwtr is always set
|
||||
** to zero.
|
||||
*/
|
||||
case SQLITE_DBSTATUS_CACHE_SPILL:
|
||||
@@ -373,19 +375,19 @@ int sqlite3_db_status(
|
||||
sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);
|
||||
}
|
||||
}
|
||||
*pHighwater = 0; /* IMP: R-42420-56072 */
|
||||
*pHighwtr = 0; /* IMP: R-42420-56072 */
|
||||
/* IMP: R-54100-20147 */
|
||||
/* IMP: R-29431-39229 */
|
||||
*pCurrent = (int)nRet & 0x7fffffff;
|
||||
*pCurrent = nRet;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set *pCurrent to non-zero if there are unresolved deferred foreign
|
||||
** key constraints. Set *pCurrent to zero if all foreign key constraints
|
||||
** have been satisfied. The *pHighwater is always set to zero.
|
||||
** have been satisfied. The *pHighwtr is always set to zero.
|
||||
*/
|
||||
case SQLITE_DBSTATUS_DEFERRED_FKS: {
|
||||
*pHighwater = 0; /* IMP: R-11967-56545 */
|
||||
*pHighwtr = 0; /* IMP: R-11967-56545 */
|
||||
*pCurrent = db->nDeferredImmCons>0 || db->nDeferredCons>0;
|
||||
break;
|
||||
}
|
||||
@@ -397,3 +399,22 @@ int sqlite3_db_status(
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** 32-bit variant of sqlite3_db_status64()
|
||||
*/
|
||||
int sqlite3_db_status(
|
||||
sqlite3 *db, /* The database connection whose status is desired */
|
||||
int op, /* Status verb */
|
||||
int *pCurrent, /* Write current value here */
|
||||
int *pHighwtr, /* Write high-water mark here */
|
||||
int resetFlag /* Reset high-water mark if true */
|
||||
){
|
||||
sqlite3_int64 C = 0, H = 0;
|
||||
int rc = sqlite3_db_status64(db, op, &C, &H, resetFlag);
|
||||
if( rc==0 ){
|
||||
*pCurrent = C & 0x7fffffff;
|
||||
*pHighwtr = H & 0x7fffffff;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user