Skip to content

Commit

Permalink
Update SQLite with more logs, v5
Browse files Browse the repository at this point in the history
  • Loading branch information
flodnv committed Oct 23, 2024
1 parent 621d9d5 commit bf00224
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 21 deletions.
56 changes: 36 additions & 20 deletions libstuff/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
** separate file. This file contains only code for the core SQLite library.
**
** The content in this amalgamation comes from Fossil check-in
** d02ec06e5bde7c8dc0f21ca2bfc44597aca0.
** 9cafae1fff34ff45772910d6f2a19d08038e.
*/
#define SQLITE_CORE 1
#define SQLITE_AMALGAMATION 1
Expand Down Expand Up @@ -465,7 +465,7 @@ extern "C" {
*/
#define SQLITE_VERSION "3.47.0"
#define SQLITE_VERSION_NUMBER 3047000
#define SQLITE_SOURCE_ID "2024-10-22 16:26:14 d02ec06e5bde7c8dc0f21ca2bfc44597aca015854d5656f851f4518476d04381"
#define SQLITE_SOURCE_ID "2024-10-23 17:16:59 9cafae1fff34ff45772910d6f2a19d08038edea4327234f577f6da30e5baa558"

/*
** CAPI3REF: Run-Time Library Version Numbers
Expand Down Expand Up @@ -17445,17 +17445,21 @@ SQLITE_PRIVATE int sqlite3CursorRangeHintExprCheck(Walker *pWalker, Expr *pExpr)
#define COMMIT_TIME_START_RELOCATE1 5
#define COMMIT_TIME_START_RELOCATE2 6

#define COMMIT_TIME_AFTER_FIXUNLOCKED 7
#define COMMIT_TIME_AFTER_WALFRAMES 8
#define COMMIT_TIME_OTHERWRITERS 7
#define COMMIT_TIME_RELOCATE1COUNT 8
#define COMMIT_TIME_RELOCATE2COUNT 9

#define COMMIT_TIME_BEFORE_PHASETWO 9
#define COMMIT_TIME_AFTER_PHASETWO 10
#define COMMIT_TIME_AFTER_FIXUNLOCKED 10
#define COMMIT_TIME_AFTER_WALFRAMES 11

#define COMMIT_TIME_AFTER_VDBECOMMIT 11
#define COMMIT_TIME_AFTER_HALT 12
#define COMMIT_TIME_FINISH 13
#define COMMIT_TIME_BEFORE_PHASETWO 12
#define COMMIT_TIME_AFTER_PHASETWO 13

#define COMMIT_TIME_N 14
#define COMMIT_TIME_AFTER_VDBECOMMIT 14
#define COMMIT_TIME_AFTER_HALT 15
#define COMMIT_TIME_FINISH 16

#define COMMIT_TIME_N 17

/* #define COMMIT_TIME_TIMEOUT (2*1000*1000) */
#define COMMIT_TIME_TIMEOUT (10*1000) /* 10ms threshold */
Expand Down Expand Up @@ -18201,7 +18205,7 @@ struct sqlite3 {
#define SCHEMA_TIME_FINISH 12

#define SCHEMA_TIME_N 13
#define SCHEMA_TIME_TIMEOUT (1 * 1000 * 1000)
#define SCHEMA_TIME_TIMEOUT (2 * 1000 * 1000)



Expand Down Expand Up @@ -23732,8 +23736,6 @@ struct VdbeCursor {
** static element declared in the structure. nField total array slots for
** aType[] and nField+1 array slots for aOffset[] */
u32 aType[1]; /* Type values record decode. MUST BE LAST */

u8 *aCommit;
};

/* Return true if P is a null-only cursor
Expand Down Expand Up @@ -77454,6 +77456,11 @@ static int btreeFixUnlocked(Btree *p){
nFin--;
}
nFin = MAX(nFin, nHPage);
if( p->pBt->aCommitTime ){
p->pBt->aCommitTime[COMMIT_TIME_OTHERWRITERS] = (1+nHPage-pMap->iFirst);
p->pBt->aCommitTime[COMMIT_TIME_RELOCATE1COUNT] = (1+iLast-pMap->iFirst);
p->pBt->aCommitTime[COMMIT_TIME_RELOCATE2COUNT] = (nFin - nCurrent);
}
sqlite3CommitTimeSet(
p->pBt->aCommitTime, COMMIT_TIME_START_RELOCATE2
);
Expand Down Expand Up @@ -93206,11 +93213,20 @@ SQLITE_PRIVATE void sqlite3CommitTimeLog(u64 *aCommit){
char *zStr = 0;
int ii;
for(ii=1; ii<COMMIT_TIME_N; ii++){
zStr = sqlite3_mprintf("%z%s%d", zStr, (zStr?", ":""),
(aCommit[ii]==0 ? 0 : (int)(aCommit[ii] - i1))
);
int iVal;
const char *zHash = "";
if( ii==COMMIT_TIME_RELOCATE1COUNT
|| ii==COMMIT_TIME_RELOCATE2COUNT
|| ii==COMMIT_TIME_OTHERWRITERS
){
iVal = (int)aCommit[ii];
zHash = "#";
}else{
iVal = (aCommit[ii]==0 ? 0 : (int)(aCommit[ii] - i1));
}
zStr = sqlite3_mprintf("%z%s%s%d", zStr, (zStr?", ":""), zHash, iVal);
}
sqlite3_log(SQLITE_WARNING, "slow commit (v=4): (%s)", zStr);
sqlite3_log(SQLITE_WARNING, "slow commit (v=5): (%s)", zStr);
sqlite3_free(zStr);
}
}
Expand Down Expand Up @@ -93238,7 +93254,7 @@ SQLITE_PRIVATE void sqlite3PrepareTimeLog(const char *zSql, int nSql, u64 *aPrep
}
if( nByte<0 ){ nByte = sqlite3Strlen30(zSql); }
sqlite3_log(SQLITE_WARNING,
"slow prepare (v=4): (%s) [%.*s]", zStr, nByte, zSql
"slow prepare (v=5): (%s) [%.*s]", zStr, nByte, zSql
);
sqlite3_free(zStr);
}
Expand All @@ -93254,7 +93270,7 @@ SQLITE_PRIVATE void sqlite3SchemaTimeLog(u64 *aSchema){
(aSchema[ii]==0 ? 0 : (int)(aSchema[ii] - i1))
);
}
sqlite3_log(SQLITE_WARNING, "slow schema (v=4): (%s)", zStr);
sqlite3_log(SQLITE_WARNING, "slow schema (v=5): (%s)", zStr);
sqlite3_free(zStr);
}
}
Expand Down Expand Up @@ -257632,7 +257648,7 @@ static void fts5SourceIdFunc(
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
sqlite3_result_text(pCtx, "fts5: 2024-10-22 16:26:14 d02ec06e5bde7c8dc0f21ca2bfc44597aca015854d5656f851f4518476d04381", -1, SQLITE_TRANSIENT);
sqlite3_result_text(pCtx, "fts5: 2024-10-23 17:16:59 9cafae1fff34ff45772910d6f2a19d08038edea4327234f577f6da30e5baa558", -1, SQLITE_TRANSIENT);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion libstuff/sqlite3.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ extern "C" {
*/
#define SQLITE_VERSION "3.47.0"
#define SQLITE_VERSION_NUMBER 3047000
#define SQLITE_SOURCE_ID "2024-10-22 16:26:14 d02ec06e5bde7c8dc0f21ca2bfc44597aca015854d5656f851f4518476d04381"
#define SQLITE_SOURCE_ID "2024-10-23 17:16:59 9cafae1fff34ff45772910d6f2a19d08038edea4327234f577f6da30e5baa558"

/*
** CAPI3REF: Run-Time Library Version Numbers
Expand Down

0 comments on commit bf00224

Please sign in to comment.