Fossil SCM

Update to a newer SQLite on the enhanced-stat1 branch.

drh 2024-01-01 14:42 enhanced-stat1
Commit e634b581445d79d3cf6e767fe5b39ece24a8c84a164ba5c46d675e9a677b7fd2
2 files changed +152 -93 +1 -1
+152 -93
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
1616
** if you want a wrapper to interface SQLite with your choice of programming
1717
** language. The code for the "sqlite3" command-line shell is also in a
1818
** separate file. This file contains only code for the core SQLite library.
1919
**
2020
** The content in this amalgamation comes from Fossil check-in
21
-** c216921b115169ebfd239267b4ab5ad0fc96.
21
+** 4a8fc17365ccd989cc8050179ac586ca2466.
2222
*/
2323
#define SQLITE_CORE 1
2424
#define SQLITE_AMALGAMATION 1
2525
#ifndef SQLITE_PRIVATE
2626
# define SQLITE_PRIVATE static
@@ -459,11 +459,11 @@
459459
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
460460
** [sqlite_version()] and [sqlite_source_id()].
461461
*/
462462
#define SQLITE_VERSION "3.45.0"
463463
#define SQLITE_VERSION_NUMBER 3045000
464
-#define SQLITE_SOURCE_ID "2023-12-31 12:38:43 c216921b115169ebfd239267b4ab5ad0fc960ffadce09044b68812f49110d607"
464
+#define SQLITE_SOURCE_ID "2024-01-01 14:13:59 4a8fc17365ccd989cc8050179ac586ca246698c71a64d7209786fb5569ba583a"
465465
466466
/*
467467
** CAPI3REF: Run-Time Library Version Numbers
468468
** KEYWORDS: sqlite3_version sqlite3_sourceid
469469
**
@@ -118470,11 +118470,11 @@
118470118470
** Adjustments to the I value are made in some cases. See comments
118471118471
** in-line below.
118472118472
*/
118473118473
sqlite3_str sStat; /* Text of the constructed "stat" line */
118474118474
int i; /* Loop counter */
118475
- int iUneven = 1; /* max/avg */
118475
+ int bUneven = 0; /* True if the uneven=... argument is needed */
118476118476
u64 nRow; /* Number of rows in the index */
118477118477
118478118478
sqlite3StrAccumInit(&sStat, 0, 0, 0, (p->nKeyCol+1)*100);
118479118479
nRow = p->nSkipAhead ? p->nEst : p->nRow;
118480118480
sqlite3_str_appendf(&sStat, "%llu", nRow);
@@ -118486,34 +118486,39 @@
118486118486
/* If we never saw more than a single value in a PRAGMA analysis_limit
118487118487
** search, then set the estimated number of matching rows to the
118488118488
** estimated number of rows in the index. */
118489118489
iVal = p->nEst;
118490118490
}else if( iVal<mx/10 ){
118491
- /* Report uneven= if the maximum run of identical values ever
118492
- ** reaches or exceeds 10 times the average run */
118493
- int iRatio = mx/iVal;
118494
- if( iUneven<iRatio ) iUneven = iRatio;
118491
+ /* ^^-- TUNING: threshold for when var=... is reported.
118492
+ ** tag-20231231-01: Report var=... if the maximum run of identical
118493
+ ** values ever reaches or exceeds 10 (or so) times the average run
118494
+ ** for any column of the index.
118495
+ **
118496
+ ** The reporting threshold of 10 is tunable, but if changed, one
118497
+ ** should also consider changing the aiRowLogEst adjustment factor at
118498
+ ** tag-20231231-02.
118499
+ */
118500
+ bUneven = 1;
118495118501
}else if( iVal==2 && p->nRow*10 <= nDistinct*11 ){
118496118502
/* If the value is less than or equal to 1.1, round it down to 1.0 */
118497118503
iVal = 1;
118498118504
}
118499118505
sqlite3_str_appendf(&sStat, " %llu", iVal);
118500118506
assert( p->current.anEq[i] );
118501118507
118502
- /* Add the "slow" argument if the peak number of rows obtained
118503
- ** from a full equality match is so large that a full table scan
118504
- ** seems likely to be faster.
118505
- */
118506
- if( i==p->nKeyCol-1
118507
- && nRow > 1000
118508
- && nRow <= iVal*iUneven + sqlite3LogEst(nRow*2/3)
118509
- ){
118510
- sqlite3_str_appendf(&sStat, " slow");
118511
- }
118512
- }
118513
- if( iUneven>1 ){
118514
- sqlite3_str_appendf(&sStat, " uneven=%d", iUneven);
118508
+ }
118509
+ if( bUneven ){
118510
+ char cSep = '=';
118511
+ sqlite3_str_appendf(&sStat, " var");
118512
+ for(i=0; i<p->nKeyCol; i++){
118513
+ u64 nDistinct = p->current.anDLt[i] + 1;
118514
+ u64 iVal = (p->nRow + nDistinct - 1) / nDistinct;
118515
+ u64 mx = p->current.amxEq[i];
118516
+ int iRatio = mx/iVal;
118517
+ sqlite3_str_appendf(&sStat, "%c%d", cSep, iRatio);
118518
+ cSep = ',';
118519
+ }
118515118520
}
118516118521
sqlite3ResultStrAccum(context, &sStat);
118517118522
}
118518118523
#ifdef SQLITE_ENABLE_STAT4
118519118524
else if( eCall==STAT_GET_ROWID ){
@@ -119181,36 +119186,55 @@
119181119186
if( pIndex ){
119182119187
#endif
119183119188
pIndex->bUnordered = 0;
119184119189
pIndex->noSkipScan = 0;
119185119190
pIndex->bSlow = 0;
119191
+ assert( aLog!=0 );
119186119192
while( z[0] ){
119187119193
if( sqlite3_strglob("unordered*", z)==0 ){
119188119194
pIndex->bUnordered = 1;
119189119195
}else if( sqlite3_strglob("sz=[0-9]*", z)==0 ){
119190119196
int sz = sqlite3Atoi(z+3);
119191119197
if( sz<2 ) sz = 2;
119192119198
pIndex->szIdxRow = sqlite3LogEst(sz);
119193119199
}else if( sqlite3_strglob("noskipscan*", z)==0 ){
119194119200
pIndex->noSkipScan = 1;
119195
- }else if( sqlite3_strglob("slow*", z)==0 ){
119196
- pIndex->bSlow = 1;
119197
- }else if( sqlite3_strglob("uneven=[0-9]*", z)==0 ){
119198
- /* An argument of "uneven=NNN" means that the maximum length
119199
- ** run of the same value is NNN times longer than the average.
119200
- ** Go through the iaRowLogEst[] values for the index and increase
119201
- ** them so that so that they are each no less than 1/8th the
119202
- ** maximum value. */
119203
- LogEst scale = sqlite3LogEst(sqlite3Atoi(z+7)) - 30;
119204
- if( scale>0 ){
119205
- LogEst mx = aLog[0];
119206
- int jj;
119207
- for(jj=1; jj<pIndex->nKeyCol; jj++){
119208
- LogEst x = aLog[jj] + scale;
119209
- if( x>mx ) x = mx;
119210
- aLog[jj] = x;
119211
- }
119201
+ }else if( sqlite3_strglob("var=[0-9]*", z)==0 ){
119202
+ /* An argument like "var=N1,N2,...NN" means that the maximum length
119203
+ ** run of the same value is Nx times longer than the average for
119204
+ ** the X-th column of the index.
119205
+ **
119206
+ ** For this implementation, go through the iaRowLogEst[] array and
119207
+ ** increase each value by 1/10th of the average value, to account
119208
+ ** for the variability of the estimate.
119209
+ **
119210
+ ** tag-20231231-02: The 1/10th value is tunable. See the tuning
119211
+ ** comment in the body of the loop. The ANALYZE command only
119212
+ ** inserts a var=... argument if one or more of the Nx values is
119213
+ ** within the tuning range, so if changing the tuning factor here,
119214
+ ** consider also changing it at tag-20232131-01.
119215
+ **
119216
+ ** The stat column continue to hold the average run length for the
119217
+ ** initial integers, for backwards compatibility.
119218
+ */
119219
+ int jj = 1;
119220
+ int kk = 4;
119221
+ LogEst mx = aLog[0];
119222
+ while( sqlite3Isdigit(z[kk]) ){
119223
+ u64 v = z[kk++] - '0';
119224
+ LogEst scale;
119225
+ while( sqlite3Isdigit(z[kk]) ){ v = v*10 + z[kk++]-'0'; }
119226
+ scale = sqlite3LogEst(v);
119227
+ if( scale>33 ){
119228
+ /* ^^----- TUNING --------------vv See tag 20231231-02 */
119229
+ LogEst adjusted = aLog[jj] + scale - 33;
119230
+ if( adjusted>mx ) adjusted = mx;
119231
+ aLog[jj] = adjusted;
119232
+ }
119233
+ if( jj==pIndex->nKeyCol ) break;
119234
+ if( z[kk]==',' ) kk++;
119235
+ jj++;
119212119236
}
119213119237
}
119214119238
#ifdef SQLITE_ENABLE_COSTMULT
119215119239
else if( sqlite3_strglob("costmult=[0-9]*",z)==0 ){
119216119240
pIndex->pTable->costMult = sqlite3LogEst(sqlite3Atoi(z+9));
@@ -119217,10 +119241,20 @@
119217119241
}
119218119242
#endif
119219119243
while( z[0]!=0 && z[0]!=' ' ) z++;
119220119244
while( z[0]==' ' ) z++;
119221119245
}
119246
+
119247
+ /* Set the bSlow flag if the peak number of rows obtained
119248
+ ** from a full equality match is so large that a full table scan
119249
+ ** seems likely to be faster than using the index.
119250
+ */
119251
+ if( aLog[0] > 66 /* Index has more than 100 rows */
119252
+ && aLog[0] <= aLog[pIndex->nKeyCol] /* And only a single value seen */
119253
+ ){
119254
+ pIndex->bSlow = 1;
119255
+ }
119222119256
}
119223119257
}
119224119258
119225119259
/*
119226119260
** This callback is invoked once for each index when reading the
@@ -137144,49 +137178,50 @@
137144137178
/* 16 */ "name",
137145137179
/* 17 */ "type",
137146137180
/* 18 */ "ncol",
137147137181
/* 19 */ "wr",
137148137182
/* 20 */ "strict",
137149
- /* 21 */ "seqno", /* Used by: index_xinfo */
137150
- /* 22 */ "cid",
137151
- /* 23 */ "name",
137152
- /* 24 */ "desc",
137153
- /* 25 */ "coll",
137154
- /* 26 */ "key",
137155
- /* 27 */ "name", /* Used by: function_list */
137156
- /* 28 */ "builtin",
137157
- /* 29 */ "type",
137158
- /* 30 */ "enc",
137159
- /* 31 */ "narg",
137160
- /* 32 */ "flags",
137161
- /* 33 */ "tbl", /* Used by: stats */
137162
- /* 34 */ "idx",
137163
- /* 35 */ "wdth",
137164
- /* 36 */ "hght",
137165
- /* 37 */ "flgs",
137166
- /* 38 */ "seq", /* Used by: index_list */
137167
- /* 39 */ "name",
137168
- /* 40 */ "unique",
137169
- /* 41 */ "origin",
137170
- /* 42 */ "partial",
137171
- /* 43 */ "table", /* Used by: foreign_key_check */
137172
- /* 44 */ "rowid",
137173
- /* 45 */ "parent",
137174
- /* 46 */ "fkid",
137175
- /* index_info reuses 21 */
137176
- /* 47 */ "seq", /* Used by: database_list */
137177
- /* 48 */ "name",
137178
- /* 49 */ "file",
137179
- /* 50 */ "busy", /* Used by: wal_checkpoint */
137180
- /* 51 */ "log",
137181
- /* 52 */ "checkpointed",
137182
- /* collation_list reuses 38 */
137183
- /* 53 */ "database", /* Used by: lock_status */
137184
- /* 54 */ "status",
137185
- /* 55 */ "cache_size", /* Used by: default_cache_size */
137183
+ /* 21 */ "tbl", /* Used by: stats */
137184
+ /* 22 */ "idx",
137185
+ /* 23 */ "wdth",
137186
+ /* 24 */ "hght",
137187
+ /* 25 */ "flgs",
137188
+ /* 26 */ "est",
137189
+ /* 27 */ "seqno", /* Used by: index_xinfo */
137190
+ /* 28 */ "cid",
137191
+ /* 29 */ "name",
137192
+ /* 30 */ "desc",
137193
+ /* 31 */ "coll",
137194
+ /* 32 */ "key",
137195
+ /* 33 */ "name", /* Used by: function_list */
137196
+ /* 34 */ "builtin",
137197
+ /* 35 */ "type",
137198
+ /* 36 */ "enc",
137199
+ /* 37 */ "narg",
137200
+ /* 38 */ "flags",
137201
+ /* 39 */ "seq", /* Used by: index_list */
137202
+ /* 40 */ "name",
137203
+ /* 41 */ "unique",
137204
+ /* 42 */ "origin",
137205
+ /* 43 */ "partial",
137206
+ /* 44 */ "table", /* Used by: foreign_key_check */
137207
+ /* 45 */ "rowid",
137208
+ /* 46 */ "parent",
137209
+ /* 47 */ "fkid",
137210
+ /* index_info reuses 27 */
137211
+ /* 48 */ "seq", /* Used by: database_list */
137212
+ /* 49 */ "name",
137213
+ /* 50 */ "file",
137214
+ /* 51 */ "busy", /* Used by: wal_checkpoint */
137215
+ /* 52 */ "log",
137216
+ /* 53 */ "checkpointed",
137217
+ /* collation_list reuses 39 */
137218
+ /* 54 */ "database", /* Used by: lock_status */
137219
+ /* 55 */ "status",
137220
+ /* 56 */ "cache_size", /* Used by: default_cache_size */
137186137221
/* module_list pragma_list reuses 9 */
137187
- /* 56 */ "timeout", /* Used by: busy_timeout */
137222
+ /* 57 */ "timeout", /* Used by: busy_timeout */
137188137223
};
137189137224
137190137225
/* Definitions of all built-in pragmas */
137191137226
typedef struct PragmaName {
137192137227
const char *const zName; /* Name of pragma */
@@ -137233,11 +137268,11 @@
137233137268
#endif
137234137269
#endif
137235137270
{/* zName: */ "busy_timeout",
137236137271
/* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
137237137272
/* ePragFlg: */ PragFlg_Result0,
137238
- /* ColNames: */ 56, 1,
137273
+ /* ColNames: */ 57, 1,
137239137274
/* iArg: */ 0 },
137240137275
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
137241137276
{/* zName: */ "cache_size",
137242137277
/* ePragTyp: */ PragTyp_CACHE_SIZE,
137243137278
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
@@ -137272,11 +137307,11 @@
137272137307
#endif
137273137308
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
137274137309
{/* zName: */ "collation_list",
137275137310
/* ePragTyp: */ PragTyp_COLLATION_LIST,
137276137311
/* ePragFlg: */ PragFlg_Result0,
137277
- /* ColNames: */ 38, 2,
137312
+ /* ColNames: */ 39, 2,
137278137313
/* iArg: */ 0 },
137279137314
#endif
137280137315
#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
137281137316
{/* zName: */ "compile_options",
137282137317
/* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
@@ -137307,18 +137342,18 @@
137307137342
#endif
137308137343
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
137309137344
{/* zName: */ "database_list",
137310137345
/* ePragTyp: */ PragTyp_DATABASE_LIST,
137311137346
/* ePragFlg: */ PragFlg_Result0,
137312
- /* ColNames: */ 47, 3,
137347
+ /* ColNames: */ 48, 3,
137313137348
/* iArg: */ 0 },
137314137349
#endif
137315137350
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
137316137351
{/* zName: */ "default_cache_size",
137317137352
/* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE,
137318137353
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
137319
- /* ColNames: */ 55, 1,
137354
+ /* ColNames: */ 56, 1,
137320137355
/* iArg: */ 0 },
137321137356
#endif
137322137357
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
137323137358
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
137324137359
{/* zName: */ "defer_foreign_keys",
@@ -137344,11 +137379,11 @@
137344137379
#endif
137345137380
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
137346137381
{/* zName: */ "foreign_key_check",
137347137382
/* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
137348137383
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1|PragFlg_SchemaOpt,
137349
- /* ColNames: */ 43, 4,
137384
+ /* ColNames: */ 44, 4,
137350137385
/* iArg: */ 0 },
137351137386
#endif
137352137387
#if !defined(SQLITE_OMIT_FOREIGN_KEY)
137353137388
{/* zName: */ "foreign_key_list",
137354137389
/* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
@@ -137387,11 +137422,11 @@
137387137422
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
137388137423
#if !defined(SQLITE_OMIT_INTROSPECTION_PRAGMAS)
137389137424
{/* zName: */ "function_list",
137390137425
/* ePragTyp: */ PragTyp_FUNCTION_LIST,
137391137426
/* ePragFlg: */ PragFlg_Result0,
137392
- /* ColNames: */ 27, 6,
137427
+ /* ColNames: */ 33, 6,
137393137428
/* iArg: */ 0 },
137394137429
#endif
137395137430
#endif
137396137431
{/* zName: */ "hard_heap_limit",
137397137432
/* ePragTyp: */ PragTyp_HARD_HEAP_LIMIT,
@@ -137416,21 +137451,21 @@
137416137451
#endif
137417137452
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
137418137453
{/* zName: */ "index_info",
137419137454
/* ePragTyp: */ PragTyp_INDEX_INFO,
137420137455
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
137421
- /* ColNames: */ 21, 3,
137456
+ /* ColNames: */ 27, 3,
137422137457
/* iArg: */ 0 },
137423137458
{/* zName: */ "index_list",
137424137459
/* ePragTyp: */ PragTyp_INDEX_LIST,
137425137460
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
137426
- /* ColNames: */ 38, 5,
137461
+ /* ColNames: */ 39, 5,
137427137462
/* iArg: */ 0 },
137428137463
{/* zName: */ "index_xinfo",
137429137464
/* ePragTyp: */ PragTyp_INDEX_INFO,
137430137465
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
137431
- /* ColNames: */ 21, 6,
137466
+ /* ColNames: */ 27, 6,
137432137467
/* iArg: */ 1 },
137433137468
#endif
137434137469
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
137435137470
{/* zName: */ "integrity_check",
137436137471
/* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
@@ -137466,11 +137501,11 @@
137466137501
#endif
137467137502
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
137468137503
{/* zName: */ "lock_status",
137469137504
/* ePragTyp: */ PragTyp_LOCK_STATUS,
137470137505
/* ePragFlg: */ PragFlg_Result0,
137471
- /* ColNames: */ 53, 2,
137506
+ /* ColNames: */ 54, 2,
137472137507
/* iArg: */ 0 },
137473137508
#endif
137474137509
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
137475137510
{/* zName: */ "locking_mode",
137476137511
/* ePragTyp: */ PragTyp_LOCKING_MODE,
@@ -137605,11 +137640,11 @@
137605137640
#endif
137606137641
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG)
137607137642
{/* zName: */ "stats",
137608137643
/* ePragTyp: */ PragTyp_STATS,
137609137644
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
137610
- /* ColNames: */ 33, 5,
137645
+ /* ColNames: */ 21, 6,
137611137646
/* iArg: */ 0 },
137612137647
#endif
137613137648
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
137614137649
{/* zName: */ "synchronous",
137615137650
/* ePragTyp: */ PragTyp_SYNCHRONOUS,
@@ -137701,11 +137736,11 @@
137701137736
/* ColNames: */ 0, 0,
137702137737
/* iArg: */ 0 },
137703137738
{/* zName: */ "wal_checkpoint",
137704137739
/* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
137705137740
/* ePragFlg: */ PragFlg_NeedSchema,
137706
- /* ColNames: */ 50, 3,
137741
+ /* ColNames: */ 51, 3,
137707137742
/* iArg: */ 0 },
137708137743
#endif
137709137744
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
137710137745
{/* zName: */ "writable_schema",
137711137746
/* ePragTyp: */ PragTyp_FLAG,
@@ -138985,30 +139020,54 @@
138985139020
}
138986139021
}
138987139022
break;
138988139023
138989139024
#ifdef SQLITE_DEBUG
139025
+ /* The output of this pragma is undocumented in the official documentation
139026
+ ** because it is subject to change, and we don't want people coming to
139027
+ ** rely on it.
139028
+ **
139029
+ ** Columns:
139030
+ ** tbl Name of a table that is being described
139031
+ ** idx Name of an index (belonging to tbl) being described
139032
+ ** wdth LogEst of the on-disk estimated bytes per row
139033
+ ** hght LogEst of the estimated number of rows
139034
+ ** flgs tabFlags for tables
139035
+ ** est aiRowLogEst[] values for indexes + "slow" flag
139036
+ */
138990139037
case PragTyp_STATS: {
138991139038
Index *pIdx;
138992139039
HashElem *i;
138993
- pParse->nMem = 5;
139040
+ sqlite3_str est;
139041
+ sqlite3StrAccumInit(&est, 0, 0, 0, SQLITE_MAX_LENGTH);
139042
+ pParse->nMem = 6;
138994139043
sqlite3CodeVerifySchema(pParse, iDb);
138995139044
for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){
138996139045
Table *pTab = sqliteHashData(i);
138997
- sqlite3VdbeMultiLoad(v, 1, "ssiii",
139046
+ sqlite3VdbeMultiLoad(v, 1, "ssiiis",
138998139047
sqlite3PreferredTableName(pTab->zName),
138999139048
0,
139000139049
pTab->szTabRow,
139001139050
pTab->nRowLogEst,
139002
- pTab->tabFlags);
139051
+ pTab->tabFlags,
139052
+ 0);
139003139053
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
139004
- sqlite3VdbeMultiLoad(v, 2, "siiiX",
139054
+ int j;
139055
+ est.nChar = 0;
139056
+ for(j=1; j<pIdx->nKeyCol+1; j++){
139057
+ if( j>1 ) sqlite3_str_append(&est, " ", 1);
139058
+ sqlite3_str_appendf(&est, "%d", pIdx->aiRowLogEst[j]);
139059
+ }
139060
+ if( pIdx->bSlow ) sqlite3_str_append(&est, " slow", 5);
139061
+ sqlite3VdbeMultiLoad(v, 2, "siiisX",
139005139062
pIdx->zName,
139006139063
pIdx->szIdxRow,
139007139064
pIdx->aiRowLogEst[0],
139008
- pIdx->hasStat1);
139009
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
139065
+ pIdx->hasStat1,
139066
+ sqlite3_str_value(&est));
139067
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
139068
+ sqlite3_str_reset(&est);
139010139069
}
139011139070
}
139012139071
}
139013139072
break;
139014139073
#endif
139015139074
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** c216921b115169ebfd239267b4ab5ad0fc96.
22 */
23 #define SQLITE_CORE 1
24 #define SQLITE_AMALGAMATION 1
25 #ifndef SQLITE_PRIVATE
26 # define SQLITE_PRIVATE static
@@ -459,11 +459,11 @@
459 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
460 ** [sqlite_version()] and [sqlite_source_id()].
461 */
462 #define SQLITE_VERSION "3.45.0"
463 #define SQLITE_VERSION_NUMBER 3045000
464 #define SQLITE_SOURCE_ID "2023-12-31 12:38:43 c216921b115169ebfd239267b4ab5ad0fc960ffadce09044b68812f49110d607"
465
466 /*
467 ** CAPI3REF: Run-Time Library Version Numbers
468 ** KEYWORDS: sqlite3_version sqlite3_sourceid
469 **
@@ -118470,11 +118470,11 @@
118470 ** Adjustments to the I value are made in some cases. See comments
118471 ** in-line below.
118472 */
118473 sqlite3_str sStat; /* Text of the constructed "stat" line */
118474 int i; /* Loop counter */
118475 int iUneven = 1; /* max/avg */
118476 u64 nRow; /* Number of rows in the index */
118477
118478 sqlite3StrAccumInit(&sStat, 0, 0, 0, (p->nKeyCol+1)*100);
118479 nRow = p->nSkipAhead ? p->nEst : p->nRow;
118480 sqlite3_str_appendf(&sStat, "%llu", nRow);
@@ -118486,34 +118486,39 @@
118486 /* If we never saw more than a single value in a PRAGMA analysis_limit
118487 ** search, then set the estimated number of matching rows to the
118488 ** estimated number of rows in the index. */
118489 iVal = p->nEst;
118490 }else if( iVal<mx/10 ){
118491 /* Report uneven= if the maximum run of identical values ever
118492 ** reaches or exceeds 10 times the average run */
118493 int iRatio = mx/iVal;
118494 if( iUneven<iRatio ) iUneven = iRatio;
 
 
 
 
 
 
118495 }else if( iVal==2 && p->nRow*10 <= nDistinct*11 ){
118496 /* If the value is less than or equal to 1.1, round it down to 1.0 */
118497 iVal = 1;
118498 }
118499 sqlite3_str_appendf(&sStat, " %llu", iVal);
118500 assert( p->current.anEq[i] );
118501
118502 /* Add the "slow" argument if the peak number of rows obtained
118503 ** from a full equality match is so large that a full table scan
118504 ** seems likely to be faster.
118505 */
118506 if( i==p->nKeyCol-1
118507 && nRow > 1000
118508 && nRow <= iVal*iUneven + sqlite3LogEst(nRow*2/3)
118509 ){
118510 sqlite3_str_appendf(&sStat, " slow");
118511 }
118512 }
118513 if( iUneven>1 ){
118514 sqlite3_str_appendf(&sStat, " uneven=%d", iUneven);
118515 }
118516 sqlite3ResultStrAccum(context, &sStat);
118517 }
118518 #ifdef SQLITE_ENABLE_STAT4
118519 else if( eCall==STAT_GET_ROWID ){
@@ -119181,36 +119186,55 @@
119181 if( pIndex ){
119182 #endif
119183 pIndex->bUnordered = 0;
119184 pIndex->noSkipScan = 0;
119185 pIndex->bSlow = 0;
 
119186 while( z[0] ){
119187 if( sqlite3_strglob("unordered*", z)==0 ){
119188 pIndex->bUnordered = 1;
119189 }else if( sqlite3_strglob("sz=[0-9]*", z)==0 ){
119190 int sz = sqlite3Atoi(z+3);
119191 if( sz<2 ) sz = 2;
119192 pIndex->szIdxRow = sqlite3LogEst(sz);
119193 }else if( sqlite3_strglob("noskipscan*", z)==0 ){
119194 pIndex->noSkipScan = 1;
119195 }else if( sqlite3_strglob("slow*", z)==0 ){
119196 pIndex->bSlow = 1;
119197 }else if( sqlite3_strglob("uneven=[0-9]*", z)==0 ){
119198 /* An argument of "uneven=NNN" means that the maximum length
119199 ** run of the same value is NNN times longer than the average.
119200 ** Go through the iaRowLogEst[] values for the index and increase
119201 ** them so that so that they are each no less than 1/8th the
119202 ** maximum value. */
119203 LogEst scale = sqlite3LogEst(sqlite3Atoi(z+7)) - 30;
119204 if( scale>0 ){
119205 LogEst mx = aLog[0];
119206 int jj;
119207 for(jj=1; jj<pIndex->nKeyCol; jj++){
119208 LogEst x = aLog[jj] + scale;
119209 if( x>mx ) x = mx;
119210 aLog[jj] = x;
119211 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119212 }
119213 }
119214 #ifdef SQLITE_ENABLE_COSTMULT
119215 else if( sqlite3_strglob("costmult=[0-9]*",z)==0 ){
119216 pIndex->pTable->costMult = sqlite3LogEst(sqlite3Atoi(z+9));
@@ -119217,10 +119241,20 @@
119217 }
119218 #endif
119219 while( z[0]!=0 && z[0]!=' ' ) z++;
119220 while( z[0]==' ' ) z++;
119221 }
 
 
 
 
 
 
 
 
 
 
119222 }
119223 }
119224
119225 /*
119226 ** This callback is invoked once for each index when reading the
@@ -137144,49 +137178,50 @@
137144 /* 16 */ "name",
137145 /* 17 */ "type",
137146 /* 18 */ "ncol",
137147 /* 19 */ "wr",
137148 /* 20 */ "strict",
137149 /* 21 */ "seqno", /* Used by: index_xinfo */
137150 /* 22 */ "cid",
137151 /* 23 */ "name",
137152 /* 24 */ "desc",
137153 /* 25 */ "coll",
137154 /* 26 */ "key",
137155 /* 27 */ "name", /* Used by: function_list */
137156 /* 28 */ "builtin",
137157 /* 29 */ "type",
137158 /* 30 */ "enc",
137159 /* 31 */ "narg",
137160 /* 32 */ "flags",
137161 /* 33 */ "tbl", /* Used by: stats */
137162 /* 34 */ "idx",
137163 /* 35 */ "wdth",
137164 /* 36 */ "hght",
137165 /* 37 */ "flgs",
137166 /* 38 */ "seq", /* Used by: index_list */
137167 /* 39 */ "name",
137168 /* 40 */ "unique",
137169 /* 41 */ "origin",
137170 /* 42 */ "partial",
137171 /* 43 */ "table", /* Used by: foreign_key_check */
137172 /* 44 */ "rowid",
137173 /* 45 */ "parent",
137174 /* 46 */ "fkid",
137175 /* index_info reuses 21 */
137176 /* 47 */ "seq", /* Used by: database_list */
137177 /* 48 */ "name",
137178 /* 49 */ "file",
137179 /* 50 */ "busy", /* Used by: wal_checkpoint */
137180 /* 51 */ "log",
137181 /* 52 */ "checkpointed",
137182 /* collation_list reuses 38 */
137183 /* 53 */ "database", /* Used by: lock_status */
137184 /* 54 */ "status",
137185 /* 55 */ "cache_size", /* Used by: default_cache_size */
 
137186 /* module_list pragma_list reuses 9 */
137187 /* 56 */ "timeout", /* Used by: busy_timeout */
137188 };
137189
137190 /* Definitions of all built-in pragmas */
137191 typedef struct PragmaName {
137192 const char *const zName; /* Name of pragma */
@@ -137233,11 +137268,11 @@
137233 #endif
137234 #endif
137235 {/* zName: */ "busy_timeout",
137236 /* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
137237 /* ePragFlg: */ PragFlg_Result0,
137238 /* ColNames: */ 56, 1,
137239 /* iArg: */ 0 },
137240 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
137241 {/* zName: */ "cache_size",
137242 /* ePragTyp: */ PragTyp_CACHE_SIZE,
137243 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
@@ -137272,11 +137307,11 @@
137272 #endif
137273 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
137274 {/* zName: */ "collation_list",
137275 /* ePragTyp: */ PragTyp_COLLATION_LIST,
137276 /* ePragFlg: */ PragFlg_Result0,
137277 /* ColNames: */ 38, 2,
137278 /* iArg: */ 0 },
137279 #endif
137280 #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
137281 {/* zName: */ "compile_options",
137282 /* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
@@ -137307,18 +137342,18 @@
137307 #endif
137308 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
137309 {/* zName: */ "database_list",
137310 /* ePragTyp: */ PragTyp_DATABASE_LIST,
137311 /* ePragFlg: */ PragFlg_Result0,
137312 /* ColNames: */ 47, 3,
137313 /* iArg: */ 0 },
137314 #endif
137315 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
137316 {/* zName: */ "default_cache_size",
137317 /* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE,
137318 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
137319 /* ColNames: */ 55, 1,
137320 /* iArg: */ 0 },
137321 #endif
137322 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
137323 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
137324 {/* zName: */ "defer_foreign_keys",
@@ -137344,11 +137379,11 @@
137344 #endif
137345 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
137346 {/* zName: */ "foreign_key_check",
137347 /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
137348 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1|PragFlg_SchemaOpt,
137349 /* ColNames: */ 43, 4,
137350 /* iArg: */ 0 },
137351 #endif
137352 #if !defined(SQLITE_OMIT_FOREIGN_KEY)
137353 {/* zName: */ "foreign_key_list",
137354 /* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
@@ -137387,11 +137422,11 @@
137387 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
137388 #if !defined(SQLITE_OMIT_INTROSPECTION_PRAGMAS)
137389 {/* zName: */ "function_list",
137390 /* ePragTyp: */ PragTyp_FUNCTION_LIST,
137391 /* ePragFlg: */ PragFlg_Result0,
137392 /* ColNames: */ 27, 6,
137393 /* iArg: */ 0 },
137394 #endif
137395 #endif
137396 {/* zName: */ "hard_heap_limit",
137397 /* ePragTyp: */ PragTyp_HARD_HEAP_LIMIT,
@@ -137416,21 +137451,21 @@
137416 #endif
137417 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
137418 {/* zName: */ "index_info",
137419 /* ePragTyp: */ PragTyp_INDEX_INFO,
137420 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
137421 /* ColNames: */ 21, 3,
137422 /* iArg: */ 0 },
137423 {/* zName: */ "index_list",
137424 /* ePragTyp: */ PragTyp_INDEX_LIST,
137425 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
137426 /* ColNames: */ 38, 5,
137427 /* iArg: */ 0 },
137428 {/* zName: */ "index_xinfo",
137429 /* ePragTyp: */ PragTyp_INDEX_INFO,
137430 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
137431 /* ColNames: */ 21, 6,
137432 /* iArg: */ 1 },
137433 #endif
137434 #if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
137435 {/* zName: */ "integrity_check",
137436 /* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
@@ -137466,11 +137501,11 @@
137466 #endif
137467 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
137468 {/* zName: */ "lock_status",
137469 /* ePragTyp: */ PragTyp_LOCK_STATUS,
137470 /* ePragFlg: */ PragFlg_Result0,
137471 /* ColNames: */ 53, 2,
137472 /* iArg: */ 0 },
137473 #endif
137474 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
137475 {/* zName: */ "locking_mode",
137476 /* ePragTyp: */ PragTyp_LOCKING_MODE,
@@ -137605,11 +137640,11 @@
137605 #endif
137606 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG)
137607 {/* zName: */ "stats",
137608 /* ePragTyp: */ PragTyp_STATS,
137609 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
137610 /* ColNames: */ 33, 5,
137611 /* iArg: */ 0 },
137612 #endif
137613 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
137614 {/* zName: */ "synchronous",
137615 /* ePragTyp: */ PragTyp_SYNCHRONOUS,
@@ -137701,11 +137736,11 @@
137701 /* ColNames: */ 0, 0,
137702 /* iArg: */ 0 },
137703 {/* zName: */ "wal_checkpoint",
137704 /* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
137705 /* ePragFlg: */ PragFlg_NeedSchema,
137706 /* ColNames: */ 50, 3,
137707 /* iArg: */ 0 },
137708 #endif
137709 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
137710 {/* zName: */ "writable_schema",
137711 /* ePragTyp: */ PragTyp_FLAG,
@@ -138985,30 +139020,54 @@
138985 }
138986 }
138987 break;
138988
138989 #ifdef SQLITE_DEBUG
 
 
 
 
 
 
 
 
 
 
 
 
138990 case PragTyp_STATS: {
138991 Index *pIdx;
138992 HashElem *i;
138993 pParse->nMem = 5;
 
 
138994 sqlite3CodeVerifySchema(pParse, iDb);
138995 for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){
138996 Table *pTab = sqliteHashData(i);
138997 sqlite3VdbeMultiLoad(v, 1, "ssiii",
138998 sqlite3PreferredTableName(pTab->zName),
138999 0,
139000 pTab->szTabRow,
139001 pTab->nRowLogEst,
139002 pTab->tabFlags);
 
139003 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
139004 sqlite3VdbeMultiLoad(v, 2, "siiiX",
 
 
 
 
 
 
 
139005 pIdx->zName,
139006 pIdx->szIdxRow,
139007 pIdx->aiRowLogEst[0],
139008 pIdx->hasStat1);
139009 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
 
 
139010 }
139011 }
139012 }
139013 break;
139014 #endif
139015
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 4a8fc17365ccd989cc8050179ac586ca2466.
22 */
23 #define SQLITE_CORE 1
24 #define SQLITE_AMALGAMATION 1
25 #ifndef SQLITE_PRIVATE
26 # define SQLITE_PRIVATE static
@@ -459,11 +459,11 @@
459 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
460 ** [sqlite_version()] and [sqlite_source_id()].
461 */
462 #define SQLITE_VERSION "3.45.0"
463 #define SQLITE_VERSION_NUMBER 3045000
464 #define SQLITE_SOURCE_ID "2024-01-01 14:13:59 4a8fc17365ccd989cc8050179ac586ca246698c71a64d7209786fb5569ba583a"
465
466 /*
467 ** CAPI3REF: Run-Time Library Version Numbers
468 ** KEYWORDS: sqlite3_version sqlite3_sourceid
469 **
@@ -118470,11 +118470,11 @@
118470 ** Adjustments to the I value are made in some cases. See comments
118471 ** in-line below.
118472 */
118473 sqlite3_str sStat; /* Text of the constructed "stat" line */
118474 int i; /* Loop counter */
118475 int bUneven = 0; /* True if the uneven=... argument is needed */
118476 u64 nRow; /* Number of rows in the index */
118477
118478 sqlite3StrAccumInit(&sStat, 0, 0, 0, (p->nKeyCol+1)*100);
118479 nRow = p->nSkipAhead ? p->nEst : p->nRow;
118480 sqlite3_str_appendf(&sStat, "%llu", nRow);
@@ -118486,34 +118486,39 @@
118486 /* If we never saw more than a single value in a PRAGMA analysis_limit
118487 ** search, then set the estimated number of matching rows to the
118488 ** estimated number of rows in the index. */
118489 iVal = p->nEst;
118490 }else if( iVal<mx/10 ){
118491 /* ^^-- TUNING: threshold for when var=... is reported.
118492 ** tag-20231231-01: Report var=... if the maximum run of identical
118493 ** values ever reaches or exceeds 10 (or so) times the average run
118494 ** for any column of the index.
118495 **
118496 ** The reporting threshold of 10 is tunable, but if changed, one
118497 ** should also consider changing the aiRowLogEst adjustment factor at
118498 ** tag-20231231-02.
118499 */
118500 bUneven = 1;
118501 }else if( iVal==2 && p->nRow*10 <= nDistinct*11 ){
118502 /* If the value is less than or equal to 1.1, round it down to 1.0 */
118503 iVal = 1;
118504 }
118505 sqlite3_str_appendf(&sStat, " %llu", iVal);
118506 assert( p->current.anEq[i] );
118507
118508 }
118509 if( bUneven ){
118510 char cSep = '=';
118511 sqlite3_str_appendf(&sStat, " var");
118512 for(i=0; i<p->nKeyCol; i++){
118513 u64 nDistinct = p->current.anDLt[i] + 1;
118514 u64 iVal = (p->nRow + nDistinct - 1) / nDistinct;
118515 u64 mx = p->current.amxEq[i];
118516 int iRatio = mx/iVal;
118517 sqlite3_str_appendf(&sStat, "%c%d", cSep, iRatio);
118518 cSep = ',';
118519 }
 
118520 }
118521 sqlite3ResultStrAccum(context, &sStat);
118522 }
118523 #ifdef SQLITE_ENABLE_STAT4
118524 else if( eCall==STAT_GET_ROWID ){
@@ -119181,36 +119186,55 @@
119186 if( pIndex ){
119187 #endif
119188 pIndex->bUnordered = 0;
119189 pIndex->noSkipScan = 0;
119190 pIndex->bSlow = 0;
119191 assert( aLog!=0 );
119192 while( z[0] ){
119193 if( sqlite3_strglob("unordered*", z)==0 ){
119194 pIndex->bUnordered = 1;
119195 }else if( sqlite3_strglob("sz=[0-9]*", z)==0 ){
119196 int sz = sqlite3Atoi(z+3);
119197 if( sz<2 ) sz = 2;
119198 pIndex->szIdxRow = sqlite3LogEst(sz);
119199 }else if( sqlite3_strglob("noskipscan*", z)==0 ){
119200 pIndex->noSkipScan = 1;
119201 }else if( sqlite3_strglob("var=[0-9]*", z)==0 ){
119202 /* An argument like "var=N1,N2,...NN" means that the maximum length
119203 ** run of the same value is Nx times longer than the average for
119204 ** the X-th column of the index.
119205 **
119206 ** For this implementation, go through the iaRowLogEst[] array and
119207 ** increase each value by 1/10th of the average value, to account
119208 ** for the variability of the estimate.
119209 **
119210 ** tag-20231231-02: The 1/10th value is tunable. See the tuning
119211 ** comment in the body of the loop. The ANALYZE command only
119212 ** inserts a var=... argument if one or more of the Nx values is
119213 ** within the tuning range, so if changing the tuning factor here,
119214 ** consider also changing it at tag-20232131-01.
119215 **
119216 ** The stat column continue to hold the average run length for the
119217 ** initial integers, for backwards compatibility.
119218 */
119219 int jj = 1;
119220 int kk = 4;
119221 LogEst mx = aLog[0];
119222 while( sqlite3Isdigit(z[kk]) ){
119223 u64 v = z[kk++] - '0';
119224 LogEst scale;
119225 while( sqlite3Isdigit(z[kk]) ){ v = v*10 + z[kk++]-'0'; }
119226 scale = sqlite3LogEst(v);
119227 if( scale>33 ){
119228 /* ^^----- TUNING --------------vv See tag 20231231-02 */
119229 LogEst adjusted = aLog[jj] + scale - 33;
119230 if( adjusted>mx ) adjusted = mx;
119231 aLog[jj] = adjusted;
119232 }
119233 if( jj==pIndex->nKeyCol ) break;
119234 if( z[kk]==',' ) kk++;
119235 jj++;
119236 }
119237 }
119238 #ifdef SQLITE_ENABLE_COSTMULT
119239 else if( sqlite3_strglob("costmult=[0-9]*",z)==0 ){
119240 pIndex->pTable->costMult = sqlite3LogEst(sqlite3Atoi(z+9));
@@ -119217,10 +119241,20 @@
119241 }
119242 #endif
119243 while( z[0]!=0 && z[0]!=' ' ) z++;
119244 while( z[0]==' ' ) z++;
119245 }
119246
119247 /* Set the bSlow flag if the peak number of rows obtained
119248 ** from a full equality match is so large that a full table scan
119249 ** seems likely to be faster than using the index.
119250 */
119251 if( aLog[0] > 66 /* Index has more than 100 rows */
119252 && aLog[0] <= aLog[pIndex->nKeyCol] /* And only a single value seen */
119253 ){
119254 pIndex->bSlow = 1;
119255 }
119256 }
119257 }
119258
119259 /*
119260 ** This callback is invoked once for each index when reading the
@@ -137144,49 +137178,50 @@
137178 /* 16 */ "name",
137179 /* 17 */ "type",
137180 /* 18 */ "ncol",
137181 /* 19 */ "wr",
137182 /* 20 */ "strict",
137183 /* 21 */ "tbl", /* Used by: stats */
137184 /* 22 */ "idx",
137185 /* 23 */ "wdth",
137186 /* 24 */ "hght",
137187 /* 25 */ "flgs",
137188 /* 26 */ "est",
137189 /* 27 */ "seqno", /* Used by: index_xinfo */
137190 /* 28 */ "cid",
137191 /* 29 */ "name",
137192 /* 30 */ "desc",
137193 /* 31 */ "coll",
137194 /* 32 */ "key",
137195 /* 33 */ "name", /* Used by: function_list */
137196 /* 34 */ "builtin",
137197 /* 35 */ "type",
137198 /* 36 */ "enc",
137199 /* 37 */ "narg",
137200 /* 38 */ "flags",
137201 /* 39 */ "seq", /* Used by: index_list */
137202 /* 40 */ "name",
137203 /* 41 */ "unique",
137204 /* 42 */ "origin",
137205 /* 43 */ "partial",
137206 /* 44 */ "table", /* Used by: foreign_key_check */
137207 /* 45 */ "rowid",
137208 /* 46 */ "parent",
137209 /* 47 */ "fkid",
137210 /* index_info reuses 27 */
137211 /* 48 */ "seq", /* Used by: database_list */
137212 /* 49 */ "name",
137213 /* 50 */ "file",
137214 /* 51 */ "busy", /* Used by: wal_checkpoint */
137215 /* 52 */ "log",
137216 /* 53 */ "checkpointed",
137217 /* collation_list reuses 39 */
137218 /* 54 */ "database", /* Used by: lock_status */
137219 /* 55 */ "status",
137220 /* 56 */ "cache_size", /* Used by: default_cache_size */
137221 /* module_list pragma_list reuses 9 */
137222 /* 57 */ "timeout", /* Used by: busy_timeout */
137223 };
137224
137225 /* Definitions of all built-in pragmas */
137226 typedef struct PragmaName {
137227 const char *const zName; /* Name of pragma */
@@ -137233,11 +137268,11 @@
137268 #endif
137269 #endif
137270 {/* zName: */ "busy_timeout",
137271 /* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
137272 /* ePragFlg: */ PragFlg_Result0,
137273 /* ColNames: */ 57, 1,
137274 /* iArg: */ 0 },
137275 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
137276 {/* zName: */ "cache_size",
137277 /* ePragTyp: */ PragTyp_CACHE_SIZE,
137278 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
@@ -137272,11 +137307,11 @@
137307 #endif
137308 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
137309 {/* zName: */ "collation_list",
137310 /* ePragTyp: */ PragTyp_COLLATION_LIST,
137311 /* ePragFlg: */ PragFlg_Result0,
137312 /* ColNames: */ 39, 2,
137313 /* iArg: */ 0 },
137314 #endif
137315 #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
137316 {/* zName: */ "compile_options",
137317 /* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
@@ -137307,18 +137342,18 @@
137342 #endif
137343 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
137344 {/* zName: */ "database_list",
137345 /* ePragTyp: */ PragTyp_DATABASE_LIST,
137346 /* ePragFlg: */ PragFlg_Result0,
137347 /* ColNames: */ 48, 3,
137348 /* iArg: */ 0 },
137349 #endif
137350 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
137351 {/* zName: */ "default_cache_size",
137352 /* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE,
137353 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
137354 /* ColNames: */ 56, 1,
137355 /* iArg: */ 0 },
137356 #endif
137357 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
137358 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
137359 {/* zName: */ "defer_foreign_keys",
@@ -137344,11 +137379,11 @@
137379 #endif
137380 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
137381 {/* zName: */ "foreign_key_check",
137382 /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
137383 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1|PragFlg_SchemaOpt,
137384 /* ColNames: */ 44, 4,
137385 /* iArg: */ 0 },
137386 #endif
137387 #if !defined(SQLITE_OMIT_FOREIGN_KEY)
137388 {/* zName: */ "foreign_key_list",
137389 /* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
@@ -137387,11 +137422,11 @@
137422 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
137423 #if !defined(SQLITE_OMIT_INTROSPECTION_PRAGMAS)
137424 {/* zName: */ "function_list",
137425 /* ePragTyp: */ PragTyp_FUNCTION_LIST,
137426 /* ePragFlg: */ PragFlg_Result0,
137427 /* ColNames: */ 33, 6,
137428 /* iArg: */ 0 },
137429 #endif
137430 #endif
137431 {/* zName: */ "hard_heap_limit",
137432 /* ePragTyp: */ PragTyp_HARD_HEAP_LIMIT,
@@ -137416,21 +137451,21 @@
137451 #endif
137452 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
137453 {/* zName: */ "index_info",
137454 /* ePragTyp: */ PragTyp_INDEX_INFO,
137455 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
137456 /* ColNames: */ 27, 3,
137457 /* iArg: */ 0 },
137458 {/* zName: */ "index_list",
137459 /* ePragTyp: */ PragTyp_INDEX_LIST,
137460 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
137461 /* ColNames: */ 39, 5,
137462 /* iArg: */ 0 },
137463 {/* zName: */ "index_xinfo",
137464 /* ePragTyp: */ PragTyp_INDEX_INFO,
137465 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
137466 /* ColNames: */ 27, 6,
137467 /* iArg: */ 1 },
137468 #endif
137469 #if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
137470 {/* zName: */ "integrity_check",
137471 /* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
@@ -137466,11 +137501,11 @@
137501 #endif
137502 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
137503 {/* zName: */ "lock_status",
137504 /* ePragTyp: */ PragTyp_LOCK_STATUS,
137505 /* ePragFlg: */ PragFlg_Result0,
137506 /* ColNames: */ 54, 2,
137507 /* iArg: */ 0 },
137508 #endif
137509 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
137510 {/* zName: */ "locking_mode",
137511 /* ePragTyp: */ PragTyp_LOCKING_MODE,
@@ -137605,11 +137640,11 @@
137640 #endif
137641 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG)
137642 {/* zName: */ "stats",
137643 /* ePragTyp: */ PragTyp_STATS,
137644 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
137645 /* ColNames: */ 21, 6,
137646 /* iArg: */ 0 },
137647 #endif
137648 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
137649 {/* zName: */ "synchronous",
137650 /* ePragTyp: */ PragTyp_SYNCHRONOUS,
@@ -137701,11 +137736,11 @@
137736 /* ColNames: */ 0, 0,
137737 /* iArg: */ 0 },
137738 {/* zName: */ "wal_checkpoint",
137739 /* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
137740 /* ePragFlg: */ PragFlg_NeedSchema,
137741 /* ColNames: */ 51, 3,
137742 /* iArg: */ 0 },
137743 #endif
137744 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
137745 {/* zName: */ "writable_schema",
137746 /* ePragTyp: */ PragTyp_FLAG,
@@ -138985,30 +139020,54 @@
139020 }
139021 }
139022 break;
139023
139024 #ifdef SQLITE_DEBUG
139025 /* The output of this pragma is undocumented in the official documentation
139026 ** because it is subject to change, and we don't want people coming to
139027 ** rely on it.
139028 **
139029 ** Columns:
139030 ** tbl Name of a table that is being described
139031 ** idx Name of an index (belonging to tbl) being described
139032 ** wdth LogEst of the on-disk estimated bytes per row
139033 ** hght LogEst of the estimated number of rows
139034 ** flgs tabFlags for tables
139035 ** est aiRowLogEst[] values for indexes + "slow" flag
139036 */
139037 case PragTyp_STATS: {
139038 Index *pIdx;
139039 HashElem *i;
139040 sqlite3_str est;
139041 sqlite3StrAccumInit(&est, 0, 0, 0, SQLITE_MAX_LENGTH);
139042 pParse->nMem = 6;
139043 sqlite3CodeVerifySchema(pParse, iDb);
139044 for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){
139045 Table *pTab = sqliteHashData(i);
139046 sqlite3VdbeMultiLoad(v, 1, "ssiiis",
139047 sqlite3PreferredTableName(pTab->zName),
139048 0,
139049 pTab->szTabRow,
139050 pTab->nRowLogEst,
139051 pTab->tabFlags,
139052 0);
139053 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
139054 int j;
139055 est.nChar = 0;
139056 for(j=1; j<pIdx->nKeyCol+1; j++){
139057 if( j>1 ) sqlite3_str_append(&est, " ", 1);
139058 sqlite3_str_appendf(&est, "%d", pIdx->aiRowLogEst[j]);
139059 }
139060 if( pIdx->bSlow ) sqlite3_str_append(&est, " slow", 5);
139061 sqlite3VdbeMultiLoad(v, 2, "siiisX",
139062 pIdx->zName,
139063 pIdx->szIdxRow,
139064 pIdx->aiRowLogEst[0],
139065 pIdx->hasStat1,
139066 sqlite3_str_value(&est));
139067 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
139068 sqlite3_str_reset(&est);
139069 }
139070 }
139071 }
139072 break;
139073 #endif
139074
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.45.0"
150150
#define SQLITE_VERSION_NUMBER 3045000
151
-#define SQLITE_SOURCE_ID "2023-12-31 12:38:43 c216921b115169ebfd239267b4ab5ad0fc960ffadce09044b68812f49110d607"
151
+#define SQLITE_SOURCE_ID "2024-01-01 14:13:59 4a8fc17365ccd989cc8050179ac586ca246698c71a64d7209786fb5569ba583a"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
157157
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.45.0"
150 #define SQLITE_VERSION_NUMBER 3045000
151 #define SQLITE_SOURCE_ID "2023-12-31 12:38:43 c216921b115169ebfd239267b4ab5ad0fc960ffadce09044b68812f49110d607"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
157
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.45.0"
150 #define SQLITE_VERSION_NUMBER 3045000
151 #define SQLITE_SOURCE_ID "2024-01-01 14:13:59 4a8fc17365ccd989cc8050179ac586ca246698c71a64d7209786fb5569ba583a"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
157

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button