Fossil SCM

Merge the latest SQLite 3.53.0 beta for testing.

drh 2026-04-07 09:58 trunk
Commit 0201a1e2cc7a54bb1cf0e894f61c3ea3eb0be931df3e2844ab7ebb117f9e0998
+1 -1
--- extsrc/qrf.h
+++ extsrc/qrf.h
@@ -8,11 +8,11 @@
88
** May you find forgiveness for yourself and forgive others.
99
** May you share freely, never taking more than you give.
1010
**
1111
*************************************************************************
1212
** Header file for the Result-Format or "resfmt" utility library for SQLite.
13
-** See the resfmt.md documentation for additional information.
13
+** See the README.md documentation for additional information.
1414
*/
1515
#ifndef SQLITE_QRF_H
1616
#define SQLITE_QRF_H
1717
#ifdef __cplusplus
1818
extern "C" {
1919
--- extsrc/qrf.h
+++ extsrc/qrf.h
@@ -8,11 +8,11 @@
8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give.
10 **
11 *************************************************************************
12 ** Header file for the Result-Format or "resfmt" utility library for SQLite.
13 ** See the resfmt.md documentation for additional information.
14 */
15 #ifndef SQLITE_QRF_H
16 #define SQLITE_QRF_H
17 #ifdef __cplusplus
18 extern "C" {
19
--- extsrc/qrf.h
+++ extsrc/qrf.h
@@ -8,11 +8,11 @@
8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give.
10 **
11 *************************************************************************
12 ** Header file for the Result-Format or "resfmt" utility library for SQLite.
13 ** See the README.md documentation for additional information.
14 */
15 #ifndef SQLITE_QRF_H
16 #define SQLITE_QRF_H
17 #ifdef __cplusplus
18 extern "C" {
19
+46 -27
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -449,12 +449,12 @@
449449
wchar_t *b1, *b2;
450450
int sz1, sz2;
451451
452452
sz1 = (int)strlen(zFilename);
453453
sz2 = (int)strlen(zMode);
454
- b1 = sqlite3_malloc( (sz1+1)*sizeof(b1[0]) );
455
- b2 = sqlite3_malloc( (sz2+1)*sizeof(b1[0]) );
454
+ b1 = sqlite3_malloc64( (sz1+1)*sizeof(b1[0]) );
455
+ b2 = sqlite3_malloc64( (sz2+1)*sizeof(b1[0]) );
456456
if( b1 && b2 ){
457457
sz1 = MultiByteToWideChar(CP_UTF8, 0, zFilename, sz1, b1, sz1);
458458
b1[sz1] = 0;
459459
sz2 = MultiByteToWideChar(CP_UTF8, 0, zMode, sz2, b2, sz2);
460460
b2[sz2] = 0;
@@ -475,12 +475,12 @@
475475
wchar_t *b1, *b2;
476476
int sz1, sz2;
477477
478478
sz1 = (int)strlen(zCommand);
479479
sz2 = (int)strlen(zMode);
480
- b1 = sqlite3_malloc( (sz1+1)*sizeof(b1[0]) );
481
- b2 = sqlite3_malloc( (sz2+1)*sizeof(b1[0]) );
480
+ b1 = sqlite3_malloc64( (sz1+1)*sizeof(b1[0]) );
481
+ b2 = sqlite3_malloc64( (sz2+1)*sizeof(b1[0]) );
482482
if( b1 && b2 ){
483483
sz1 = MultiByteToWideChar(CP_UTF8, 0, zCommand, sz1, b1, sz1);
484484
b1[sz1] = 0;
485485
sz2 = MultiByteToWideChar(CP_UTF8, 0, zMode, sz2, b2, sz2);
486486
b2[sz2] = 0;
@@ -499,11 +499,11 @@
499499
/* When reading from the command-prompt in Windows, it is necessary
500500
** to use _O_WTEXT input mode to read UTF-16 characters, then translate
501501
** that into UTF-8. Otherwise, non-ASCII characters all get translated
502502
** into '?'.
503503
*/
504
- wchar_t *b1 = sqlite3_malloc( sz*sizeof(wchar_t) );
504
+ wchar_t *b1 = sqlite3_malloc64( sz*sizeof(wchar_t) );
505505
if( b1==0 ) return 0;
506506
#ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
507507
DWORD nRead = 0;
508508
if( IsConsole(in)
509509
&& ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz-1, &nRead, 0)
@@ -574,11 +574,11 @@
574574
}else{
575575
/* One must use UTF16 in order to get unicode support when writing
576576
** to the console on Windows.
577577
*/
578578
int sz = (int)strlen(z);
579
- wchar_t *b1 = sqlite3_malloc( (sz+1)*sizeof(wchar_t) );
579
+ wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(wchar_t) );
580580
if( b1==0 ) return 0;
581581
sz = MultiByteToWideChar(CP_UTF8, 0, z, sz, b1, sz);
582582
b1[sz] = 0;
583583
584584
#ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
@@ -683,11 +683,11 @@
683683
** May you find forgiveness for yourself and forgive others.
684684
** May you share freely, never taking more than you give.
685685
**
686686
*************************************************************************
687687
** Header file for the Result-Format or "resfmt" utility library for SQLite.
688
-** See the resfmt.md documentation for additional information.
688
+** See the README.md documentation for additional information.
689689
*/
690690
#ifndef SQLITE_QRF_H
691691
#define SQLITE_QRF_H
692692
#ifdef __cplusplus
693693
extern "C" {
@@ -5813,11 +5813,11 @@
58135813
Decimal *p = 0;
58145814
int i;
58155815
int iExp = 0;
58165816
58175817
if( zIn==0 ) goto new_from_text_failed;
5818
- p = sqlite3_malloc( sizeof(*p) );
5818
+ p = sqlite3_malloc64( sizeof(*p) );
58195819
if( p==0 ) goto new_from_text_failed;
58205820
p->sign = 0;
58215821
p->oom = 0;
58225822
p->isInit = 1;
58235823
p->isNull = 0;
@@ -6553,11 +6553,11 @@
65536553
UNUSED_PARAMETER(argc);
65546554
p = sqlite3_aggregate_context(context, sizeof(*p));
65556555
if( p==0 ) return;
65566556
if( !p->isInit ){
65576557
p->isInit = 1;
6558
- p->a = sqlite3_malloc(2);
6558
+ p->a = sqlite3_malloc64(2);
65596559
if( p->a==0 ){
65606560
p->oom = 1;
65616561
}else{
65626562
p->a[0] = 0;
65636563
}
@@ -6926,11 +6926,11 @@
69266926
goto memFail;
69276927
}
69286928
sqlite3_result_text(context,"",-1,SQLITE_STATIC);
69296929
break;
69306930
}
6931
- cBuf = sqlite3_malloc(nc);
6931
+ cBuf = sqlite3_malloc64(nc);
69326932
if( !cBuf ) goto memFail;
69336933
nc = (int)(toBase64(bBuf, nb, cBuf) - cBuf);
69346934
sqlite3_result_text(context, cBuf, nc, sqlite3_free);
69356935
break;
69366936
case SQLITE_TEXT:
@@ -6948,11 +6948,11 @@
69486948
goto memFail;
69496949
}
69506950
sqlite3_result_zeroblob(context, 0);
69516951
break;
69526952
}
6953
- bBuf = sqlite3_malloc(nb);
6953
+ bBuf = sqlite3_malloc64(nb);
69546954
if( !bBuf ) goto memFail;
69556955
nb = (int)(fromBase64(cBuf, nc, bBuf) - bBuf);
69566956
sqlite3_result_blob(context, bBuf, nb, sqlite3_free);
69576957
break;
69586958
default:
@@ -7303,11 +7303,11 @@
73037303
goto memFail;
73047304
}
73057305
sqlite3_result_text(context,"",-1,SQLITE_STATIC);
73067306
break;
73077307
}
7308
- cBuf = sqlite3_malloc(nc);
7308
+ cBuf = sqlite3_malloc64(nc);
73097309
if( !cBuf ) goto memFail;
73107310
nc = (int)(toBase85(bBuf, nb, cBuf, "\n") - cBuf);
73117311
sqlite3_result_text(context, cBuf, nc, sqlite3_free);
73127312
break;
73137313
case SQLITE_TEXT:
@@ -7325,11 +7325,11 @@
73257325
goto memFail;
73267326
}
73277327
sqlite3_result_zeroblob(context, 0);
73287328
break;
73297329
}
7330
- bBuf = sqlite3_malloc(nb);
7330
+ bBuf = sqlite3_malloc64(nb);
73317331
if( !bBuf ) goto memFail;
73327332
nb = (int)(fromBase85(cBuf, nc, bBuf) - bBuf);
73337333
sqlite3_result_blob(context, bBuf, nb, sqlite3_free);
73347334
break;
73357335
default:
@@ -8054,11 +8054,11 @@
80548054
(void)argvUnused;
80558055
(void)pzErrUnused;
80568056
rc = sqlite3_declare_vtab(db,
80578057
"CREATE TABLE x(value,start hidden,stop hidden,step hidden)");
80588058
if( rc==SQLITE_OK ){
8059
- pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) );
8059
+ pNew = *ppVtab = sqlite3_malloc64( sizeof(*pNew) );
80608060
if( pNew==0 ) return SQLITE_NOMEM;
80618061
memset(pNew, 0, sizeof(*pNew));
80628062
sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS);
80638063
}
80648064
return rc;
@@ -8076,11 +8076,11 @@
80768076
** Constructor for a new series_cursor object.
80778077
*/
80788078
static int seriesOpen(sqlite3_vtab *pUnused, sqlite3_vtab_cursor **ppCursor){
80798079
series_cursor *pCur;
80808080
(void)pUnused;
8081
- pCur = sqlite3_malloc( sizeof(*pCur) );
8081
+ pCur = sqlite3_malloc64( sizeof(*pCur) );
80828082
if( pCur==0 ) return SQLITE_NOMEM;
80838083
memset(pCur, 0, sizeof(*pCur));
80848084
*ppCursor = &pCur->base;
80858085
return SQLITE_OK;
80868086
}
@@ -9431,11 +9431,11 @@
94319431
ReCompiled *pRe;
94329432
const char *zErr;
94339433
int i, j;
94349434
94359435
*ppRe = 0;
9436
- pRe = sqlite3_malloc( sizeof(*pRe) );
9436
+ pRe = sqlite3_malloc64( sizeof(*pRe) );
94379437
if( pRe==0 ){
94389438
return "out of memory";
94399439
}
94409440
memset(pRe, 0, sizeof(*pRe));
94419441
pRe->xNextChar = noCase ? re_next_char_nocase : re_next_char;
@@ -10300,11 +10300,11 @@
1030010300
(void)argc;
1030110301
(void)argv;
1030210302
(void)pzErr;
1030310303
rc = sqlite3_declare_vtab(db, "CREATE TABLE x" FSDIR_SCHEMA);
1030410304
if( rc==SQLITE_OK ){
10305
- pNew = (fsdir_tab*)sqlite3_malloc( sizeof(*pNew) );
10305
+ pNew = (fsdir_tab*)sqlite3_malloc64( sizeof(*pNew) );
1030610306
if( pNew==0 ) return SQLITE_NOMEM;
1030710307
memset(pNew, 0, sizeof(*pNew));
1030810308
sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY);
1030910309
}
1031010310
*ppVtab = (sqlite3_vtab*)pNew;
@@ -10323,11 +10323,11 @@
1032310323
** Constructor for a new fsdir_cursor object.
1032410324
*/
1032510325
static int fsdirOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
1032610326
fsdir_cursor *pCur;
1032710327
(void)p;
10328
- pCur = sqlite3_malloc( sizeof(*pCur) );
10328
+ pCur = sqlite3_malloc64( sizeof(*pCur) );
1032910329
if( pCur==0 ) return SQLITE_NOMEM;
1033010330
memset(pCur, 0, sizeof(*pCur));
1033110331
pCur->iLvl = -1;
1033210332
*ppCursor = &pCur->base;
1033310333
return SQLITE_OK;
@@ -11056,11 +11056,11 @@
1105611056
" prefix TEXT HIDDEN,"
1105711057
" wholeline TEXT HIDDEN,"
1105811058
" phase INT HIDDEN" /* Used for debugging only */
1105911059
")");
1106011060
if( rc==SQLITE_OK ){
11061
- pNew = sqlite3_malloc( sizeof(*pNew) );
11061
+ pNew = sqlite3_malloc64( sizeof(*pNew) );
1106211062
*ppVtab = (sqlite3_vtab*)pNew;
1106311063
if( pNew==0 ) return SQLITE_NOMEM;
1106411064
memset(pNew, 0, sizeof(*pNew));
1106511065
pNew->db = db;
1106611066
}
@@ -11078,11 +11078,11 @@
1107811078
/*
1107911079
** Constructor for a new completion_cursor object.
1108011080
*/
1108111081
static int completionOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
1108211082
completion_cursor *pCur;
11083
- pCur = sqlite3_malloc( sizeof(*pCur) );
11083
+ pCur = sqlite3_malloc64( sizeof(*pCur) );
1108411084
if( pCur==0 ) return SQLITE_NOMEM;
1108511085
memset(pCur, 0, sizeof(*pCur));
1108611086
pCur->db = ((completion_vtab*)p)->db;
1108711087
*ppCursor = &pCur->base;
1108811088
return SQLITE_OK;
@@ -12582,11 +12582,11 @@
1258212582
** Constructor for a new ZipfileCsr object.
1258312583
*/
1258412584
static int zipfileOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCsr){
1258512585
ZipfileTab *pTab = (ZipfileTab*)p;
1258612586
ZipfileCsr *pCsr;
12587
- pCsr = sqlite3_malloc(sizeof(*pCsr));
12587
+ pCsr = sqlite3_malloc64(sizeof(*pCsr));
1258812588
*ppCsr = (sqlite3_vtab_cursor*)pCsr;
1258912589
if( pCsr==0 ){
1259012590
return SQLITE_NOMEM;
1259112591
}
1259212592
memset(pCsr, 0, sizeof(*pCsr));
@@ -13121,11 +13121,11 @@
1312113121
sqlite3_context *pCtx, /* Store result here */
1312213122
const u8 *aIn, /* Compressed data */
1312313123
int nIn, /* Size of buffer aIn[] in bytes */
1312413124
int nOut /* Expected output size */
1312513125
){
13126
- u8 *aRes = sqlite3_malloc(nOut);
13126
+ u8 *aRes = sqlite3_malloc64(nOut);
1312713127
if( aRes==0 ){
1312813128
sqlite3_result_error_nomem(pCtx);
1312913129
}else{
1313013130
int err;
1313113131
z_stream str;
@@ -13518,11 +13518,11 @@
1351813518
return SQLITE_OK;
1351913519
}
1352013520
1352113521
static ZipfileEntry *zipfileNewEntry(const char *zPath){
1352213522
ZipfileEntry *pNew;
13523
- pNew = sqlite3_malloc(sizeof(ZipfileEntry));
13523
+ pNew = sqlite3_malloc64(sizeof(ZipfileEntry));
1352413524
if( pNew ){
1352513525
memset(pNew, 0, sizeof(ZipfileEntry));
1352613526
pNew->cds.zFile = sqlite3_mprintf("%s", zPath);
1352713527
if( pNew->cds.zFile==0 ){
1352813528
sqlite3_free(pNew);
@@ -14468,11 +14468,11 @@
1446814468
const Bytef *pData = sqlite3_value_blob(argv[0]);
1446914469
uLong nData = sqlite3_value_bytes(argv[0]);
1447014470
uLongf nOut = compressBound(nData);
1447114471
Bytef *pOut;
1447214472
14473
- pOut = (Bytef*)sqlite3_malloc(nOut);
14473
+ pOut = (Bytef*)sqlite3_malloc64(nOut);
1447414474
if( pOut==0 ){
1447514475
sqlite3_result_error_nomem(context);
1447614476
return;
1447714477
}else{
1447814478
if( Z_OK!=compress(pOut, &nOut, pData, nData) ){
@@ -14513,11 +14513,11 @@
1451314513
if( sz<=0 || sz==(nData = sqlite3_value_bytes(argv[0])) ){
1451414514
sqlite3_result_value(context, argv[0]);
1451514515
}else{
1451614516
uLongf szf = sz;
1451714517
const Bytef *pData= sqlite3_value_blob(argv[0]);
14518
- Bytef *pOut = sqlite3_malloc(sz);
14518
+ Bytef *pOut = sqlite3_malloc64(sz);
1451914519
if( pOut==0 ){
1452014520
sqlite3_result_error_nomem(context);
1452114521
}else if( Z_OK!=uncompress(pOut, &szf, pData, nData) ){
1452214522
sqlite3_result_error(context, "error in uncompress()", -1);
1452314523
}else{
@@ -18134,11 +18134,11 @@
1813418134
Stmtrand *p;
1813518135
1813618136
p = (Stmtrand*)sqlite3_get_auxdata(context, STMTRAND_KEY);
1813718137
if( p==0 ){
1813818138
unsigned int seed;
18139
- p = sqlite3_malloc( sizeof(*p) );
18139
+ p = sqlite3_malloc64( sizeof(*p) );
1814018140
if( p==0 ){
1814118141
sqlite3_result_error_nomem(context);
1814218142
return;
1814318143
}
1814418144
if( argc>=1 ){
@@ -19074,11 +19074,11 @@
1907419074
rc = pRoot->xOpen(pRoot, zName, p->pReal, flags, pOutFlags);
1907519075
vfstraceOnOff(pInfo, VTR_OPEN);
1907619076
vfstrace_printf(pInfo, "%s.xOpen(%s,flags=0x%x)",
1907719077
pInfo->zVfsName, p->zFName, flags);
1907819078
if( p->pReal->pMethods ){
19079
- sqlite3_io_methods *pNew = sqlite3_malloc( sizeof(*pNew) );
19079
+ sqlite3_io_methods *pNew = sqlite3_malloc64( sizeof(*pNew) );
1908019080
const sqlite3_io_methods *pSub = p->pReal->pMethods;
1908119081
memset(pNew, 0, sizeof(*pNew));
1908219082
pNew->iVersion = pSub->iVersion;
1908319083
pNew->xClose = vfstraceClose;
1908419084
pNew->xRead = vfstraceRead;
@@ -36326,10 +36326,25 @@
3632636326
ShellState *p = (ShellState*)pArg;
3632736327
cli_puts(z, p->out);
3632836328
fflush(p->out);
3632936329
return 1;
3633036330
}
36331
+
36332
+#if defined(SQLITE_DEBUG) && !defined(SQLITE_SHELL_FIDDLE)
36333
+/* Ensure that sqlite3_reset_auto_extension() clears auto-extension
36334
+** memory. https://sqlite.org/forum/forumpost/310cb231b07c80d1.
36335
+** Testing this: if we (inadvertently) remove the
36336
+** sqlite3_reset_auto_extension() call from main(), most shell tests
36337
+** will fail because of a leak message in their output. */
36338
+static int auto_ext_leak_tester(
36339
+ sqlite3 *db, const char **pzErrMsg,
36340
+ const struct sqlite3_api_routines *pThunk
36341
+){
36342
+ (void)db; (void)pzErrMsg; (void)pThunk;
36343
+ return SQLITE_OK;
36344
+}
36345
+#endif
3633136346
3633236347
/* Alternative name to the entry point for Fiddle */
3633336348
#ifdef SQLITE_SHELL_FIDDLE
3633436349
# define main fiddle_main
3633536350
#endif
@@ -36729,10 +36744,13 @@
3672936744
if( bEnableVfstrace ){
3673036745
vfstrace_register("trace",0,vfstraceOut, &data, 1);
3673136746
}
3673236747
#ifndef SQLITE_SHELL_FIDDLE
3673336748
sqlite3_appendvfs_init(0,0,0);
36749
+#ifdef SQLITE_DEBUG
36750
+ sqlite3_auto_extension( (void (*)())auto_ext_leak_tester );
36751
+#endif
3673436752
#endif
3673536753
modeDefault(&data);
3673636754
3673736755
/* Go ahead and open the database file if it already exists. If the
3673836756
** file does not exist, delay opening it. This prevents empty database
@@ -37106,10 +37124,11 @@
3710637124
** leaks */
3710737125
memset(&data, 0, sizeof(data));
3710837126
if( bEnableVfstrace ){
3710937127
vfstrace_unregister("trace");
3711037128
}
37129
+ sqlite3_reset_auto_extension();
3711137130
#ifdef SQLITE_DEBUG
3711237131
if( sqlite3_memory_used()>mem_main_enter ){
3711337132
cli_printf(stderr,"Memory leaked: %u bytes\n",
3711437133
(unsigned int)(sqlite3_memory_used()-mem_main_enter));
3711537134
}
3711637135
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -449,12 +449,12 @@
449 wchar_t *b1, *b2;
450 int sz1, sz2;
451
452 sz1 = (int)strlen(zFilename);
453 sz2 = (int)strlen(zMode);
454 b1 = sqlite3_malloc( (sz1+1)*sizeof(b1[0]) );
455 b2 = sqlite3_malloc( (sz2+1)*sizeof(b1[0]) );
456 if( b1 && b2 ){
457 sz1 = MultiByteToWideChar(CP_UTF8, 0, zFilename, sz1, b1, sz1);
458 b1[sz1] = 0;
459 sz2 = MultiByteToWideChar(CP_UTF8, 0, zMode, sz2, b2, sz2);
460 b2[sz2] = 0;
@@ -475,12 +475,12 @@
475 wchar_t *b1, *b2;
476 int sz1, sz2;
477
478 sz1 = (int)strlen(zCommand);
479 sz2 = (int)strlen(zMode);
480 b1 = sqlite3_malloc( (sz1+1)*sizeof(b1[0]) );
481 b2 = sqlite3_malloc( (sz2+1)*sizeof(b1[0]) );
482 if( b1 && b2 ){
483 sz1 = MultiByteToWideChar(CP_UTF8, 0, zCommand, sz1, b1, sz1);
484 b1[sz1] = 0;
485 sz2 = MultiByteToWideChar(CP_UTF8, 0, zMode, sz2, b2, sz2);
486 b2[sz2] = 0;
@@ -499,11 +499,11 @@
499 /* When reading from the command-prompt in Windows, it is necessary
500 ** to use _O_WTEXT input mode to read UTF-16 characters, then translate
501 ** that into UTF-8. Otherwise, non-ASCII characters all get translated
502 ** into '?'.
503 */
504 wchar_t *b1 = sqlite3_malloc( sz*sizeof(wchar_t) );
505 if( b1==0 ) return 0;
506 #ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
507 DWORD nRead = 0;
508 if( IsConsole(in)
509 && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz-1, &nRead, 0)
@@ -574,11 +574,11 @@
574 }else{
575 /* One must use UTF16 in order to get unicode support when writing
576 ** to the console on Windows.
577 */
578 int sz = (int)strlen(z);
579 wchar_t *b1 = sqlite3_malloc( (sz+1)*sizeof(wchar_t) );
580 if( b1==0 ) return 0;
581 sz = MultiByteToWideChar(CP_UTF8, 0, z, sz, b1, sz);
582 b1[sz] = 0;
583
584 #ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
@@ -683,11 +683,11 @@
683 ** May you find forgiveness for yourself and forgive others.
684 ** May you share freely, never taking more than you give.
685 **
686 *************************************************************************
687 ** Header file for the Result-Format or "resfmt" utility library for SQLite.
688 ** See the resfmt.md documentation for additional information.
689 */
690 #ifndef SQLITE_QRF_H
691 #define SQLITE_QRF_H
692 #ifdef __cplusplus
693 extern "C" {
@@ -5813,11 +5813,11 @@
5813 Decimal *p = 0;
5814 int i;
5815 int iExp = 0;
5816
5817 if( zIn==0 ) goto new_from_text_failed;
5818 p = sqlite3_malloc( sizeof(*p) );
5819 if( p==0 ) goto new_from_text_failed;
5820 p->sign = 0;
5821 p->oom = 0;
5822 p->isInit = 1;
5823 p->isNull = 0;
@@ -6553,11 +6553,11 @@
6553 UNUSED_PARAMETER(argc);
6554 p = sqlite3_aggregate_context(context, sizeof(*p));
6555 if( p==0 ) return;
6556 if( !p->isInit ){
6557 p->isInit = 1;
6558 p->a = sqlite3_malloc(2);
6559 if( p->a==0 ){
6560 p->oom = 1;
6561 }else{
6562 p->a[0] = 0;
6563 }
@@ -6926,11 +6926,11 @@
6926 goto memFail;
6927 }
6928 sqlite3_result_text(context,"",-1,SQLITE_STATIC);
6929 break;
6930 }
6931 cBuf = sqlite3_malloc(nc);
6932 if( !cBuf ) goto memFail;
6933 nc = (int)(toBase64(bBuf, nb, cBuf) - cBuf);
6934 sqlite3_result_text(context, cBuf, nc, sqlite3_free);
6935 break;
6936 case SQLITE_TEXT:
@@ -6948,11 +6948,11 @@
6948 goto memFail;
6949 }
6950 sqlite3_result_zeroblob(context, 0);
6951 break;
6952 }
6953 bBuf = sqlite3_malloc(nb);
6954 if( !bBuf ) goto memFail;
6955 nb = (int)(fromBase64(cBuf, nc, bBuf) - bBuf);
6956 sqlite3_result_blob(context, bBuf, nb, sqlite3_free);
6957 break;
6958 default:
@@ -7303,11 +7303,11 @@
7303 goto memFail;
7304 }
7305 sqlite3_result_text(context,"",-1,SQLITE_STATIC);
7306 break;
7307 }
7308 cBuf = sqlite3_malloc(nc);
7309 if( !cBuf ) goto memFail;
7310 nc = (int)(toBase85(bBuf, nb, cBuf, "\n") - cBuf);
7311 sqlite3_result_text(context, cBuf, nc, sqlite3_free);
7312 break;
7313 case SQLITE_TEXT:
@@ -7325,11 +7325,11 @@
7325 goto memFail;
7326 }
7327 sqlite3_result_zeroblob(context, 0);
7328 break;
7329 }
7330 bBuf = sqlite3_malloc(nb);
7331 if( !bBuf ) goto memFail;
7332 nb = (int)(fromBase85(cBuf, nc, bBuf) - bBuf);
7333 sqlite3_result_blob(context, bBuf, nb, sqlite3_free);
7334 break;
7335 default:
@@ -8054,11 +8054,11 @@
8054 (void)argvUnused;
8055 (void)pzErrUnused;
8056 rc = sqlite3_declare_vtab(db,
8057 "CREATE TABLE x(value,start hidden,stop hidden,step hidden)");
8058 if( rc==SQLITE_OK ){
8059 pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) );
8060 if( pNew==0 ) return SQLITE_NOMEM;
8061 memset(pNew, 0, sizeof(*pNew));
8062 sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS);
8063 }
8064 return rc;
@@ -8076,11 +8076,11 @@
8076 ** Constructor for a new series_cursor object.
8077 */
8078 static int seriesOpen(sqlite3_vtab *pUnused, sqlite3_vtab_cursor **ppCursor){
8079 series_cursor *pCur;
8080 (void)pUnused;
8081 pCur = sqlite3_malloc( sizeof(*pCur) );
8082 if( pCur==0 ) return SQLITE_NOMEM;
8083 memset(pCur, 0, sizeof(*pCur));
8084 *ppCursor = &pCur->base;
8085 return SQLITE_OK;
8086 }
@@ -9431,11 +9431,11 @@
9431 ReCompiled *pRe;
9432 const char *zErr;
9433 int i, j;
9434
9435 *ppRe = 0;
9436 pRe = sqlite3_malloc( sizeof(*pRe) );
9437 if( pRe==0 ){
9438 return "out of memory";
9439 }
9440 memset(pRe, 0, sizeof(*pRe));
9441 pRe->xNextChar = noCase ? re_next_char_nocase : re_next_char;
@@ -10300,11 +10300,11 @@
10300 (void)argc;
10301 (void)argv;
10302 (void)pzErr;
10303 rc = sqlite3_declare_vtab(db, "CREATE TABLE x" FSDIR_SCHEMA);
10304 if( rc==SQLITE_OK ){
10305 pNew = (fsdir_tab*)sqlite3_malloc( sizeof(*pNew) );
10306 if( pNew==0 ) return SQLITE_NOMEM;
10307 memset(pNew, 0, sizeof(*pNew));
10308 sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY);
10309 }
10310 *ppVtab = (sqlite3_vtab*)pNew;
@@ -10323,11 +10323,11 @@
10323 ** Constructor for a new fsdir_cursor object.
10324 */
10325 static int fsdirOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
10326 fsdir_cursor *pCur;
10327 (void)p;
10328 pCur = sqlite3_malloc( sizeof(*pCur) );
10329 if( pCur==0 ) return SQLITE_NOMEM;
10330 memset(pCur, 0, sizeof(*pCur));
10331 pCur->iLvl = -1;
10332 *ppCursor = &pCur->base;
10333 return SQLITE_OK;
@@ -11056,11 +11056,11 @@
11056 " prefix TEXT HIDDEN,"
11057 " wholeline TEXT HIDDEN,"
11058 " phase INT HIDDEN" /* Used for debugging only */
11059 ")");
11060 if( rc==SQLITE_OK ){
11061 pNew = sqlite3_malloc( sizeof(*pNew) );
11062 *ppVtab = (sqlite3_vtab*)pNew;
11063 if( pNew==0 ) return SQLITE_NOMEM;
11064 memset(pNew, 0, sizeof(*pNew));
11065 pNew->db = db;
11066 }
@@ -11078,11 +11078,11 @@
11078 /*
11079 ** Constructor for a new completion_cursor object.
11080 */
11081 static int completionOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
11082 completion_cursor *pCur;
11083 pCur = sqlite3_malloc( sizeof(*pCur) );
11084 if( pCur==0 ) return SQLITE_NOMEM;
11085 memset(pCur, 0, sizeof(*pCur));
11086 pCur->db = ((completion_vtab*)p)->db;
11087 *ppCursor = &pCur->base;
11088 return SQLITE_OK;
@@ -12582,11 +12582,11 @@
12582 ** Constructor for a new ZipfileCsr object.
12583 */
12584 static int zipfileOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCsr){
12585 ZipfileTab *pTab = (ZipfileTab*)p;
12586 ZipfileCsr *pCsr;
12587 pCsr = sqlite3_malloc(sizeof(*pCsr));
12588 *ppCsr = (sqlite3_vtab_cursor*)pCsr;
12589 if( pCsr==0 ){
12590 return SQLITE_NOMEM;
12591 }
12592 memset(pCsr, 0, sizeof(*pCsr));
@@ -13121,11 +13121,11 @@
13121 sqlite3_context *pCtx, /* Store result here */
13122 const u8 *aIn, /* Compressed data */
13123 int nIn, /* Size of buffer aIn[] in bytes */
13124 int nOut /* Expected output size */
13125 ){
13126 u8 *aRes = sqlite3_malloc(nOut);
13127 if( aRes==0 ){
13128 sqlite3_result_error_nomem(pCtx);
13129 }else{
13130 int err;
13131 z_stream str;
@@ -13518,11 +13518,11 @@
13518 return SQLITE_OK;
13519 }
13520
13521 static ZipfileEntry *zipfileNewEntry(const char *zPath){
13522 ZipfileEntry *pNew;
13523 pNew = sqlite3_malloc(sizeof(ZipfileEntry));
13524 if( pNew ){
13525 memset(pNew, 0, sizeof(ZipfileEntry));
13526 pNew->cds.zFile = sqlite3_mprintf("%s", zPath);
13527 if( pNew->cds.zFile==0 ){
13528 sqlite3_free(pNew);
@@ -14468,11 +14468,11 @@
14468 const Bytef *pData = sqlite3_value_blob(argv[0]);
14469 uLong nData = sqlite3_value_bytes(argv[0]);
14470 uLongf nOut = compressBound(nData);
14471 Bytef *pOut;
14472
14473 pOut = (Bytef*)sqlite3_malloc(nOut);
14474 if( pOut==0 ){
14475 sqlite3_result_error_nomem(context);
14476 return;
14477 }else{
14478 if( Z_OK!=compress(pOut, &nOut, pData, nData) ){
@@ -14513,11 +14513,11 @@
14513 if( sz<=0 || sz==(nData = sqlite3_value_bytes(argv[0])) ){
14514 sqlite3_result_value(context, argv[0]);
14515 }else{
14516 uLongf szf = sz;
14517 const Bytef *pData= sqlite3_value_blob(argv[0]);
14518 Bytef *pOut = sqlite3_malloc(sz);
14519 if( pOut==0 ){
14520 sqlite3_result_error_nomem(context);
14521 }else if( Z_OK!=uncompress(pOut, &szf, pData, nData) ){
14522 sqlite3_result_error(context, "error in uncompress()", -1);
14523 }else{
@@ -18134,11 +18134,11 @@
18134 Stmtrand *p;
18135
18136 p = (Stmtrand*)sqlite3_get_auxdata(context, STMTRAND_KEY);
18137 if( p==0 ){
18138 unsigned int seed;
18139 p = sqlite3_malloc( sizeof(*p) );
18140 if( p==0 ){
18141 sqlite3_result_error_nomem(context);
18142 return;
18143 }
18144 if( argc>=1 ){
@@ -19074,11 +19074,11 @@
19074 rc = pRoot->xOpen(pRoot, zName, p->pReal, flags, pOutFlags);
19075 vfstraceOnOff(pInfo, VTR_OPEN);
19076 vfstrace_printf(pInfo, "%s.xOpen(%s,flags=0x%x)",
19077 pInfo->zVfsName, p->zFName, flags);
19078 if( p->pReal->pMethods ){
19079 sqlite3_io_methods *pNew = sqlite3_malloc( sizeof(*pNew) );
19080 const sqlite3_io_methods *pSub = p->pReal->pMethods;
19081 memset(pNew, 0, sizeof(*pNew));
19082 pNew->iVersion = pSub->iVersion;
19083 pNew->xClose = vfstraceClose;
19084 pNew->xRead = vfstraceRead;
@@ -36326,10 +36326,25 @@
36326 ShellState *p = (ShellState*)pArg;
36327 cli_puts(z, p->out);
36328 fflush(p->out);
36329 return 1;
36330 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36331
36332 /* Alternative name to the entry point for Fiddle */
36333 #ifdef SQLITE_SHELL_FIDDLE
36334 # define main fiddle_main
36335 #endif
@@ -36729,10 +36744,13 @@
36729 if( bEnableVfstrace ){
36730 vfstrace_register("trace",0,vfstraceOut, &data, 1);
36731 }
36732 #ifndef SQLITE_SHELL_FIDDLE
36733 sqlite3_appendvfs_init(0,0,0);
 
 
 
36734 #endif
36735 modeDefault(&data);
36736
36737 /* Go ahead and open the database file if it already exists. If the
36738 ** file does not exist, delay opening it. This prevents empty database
@@ -37106,10 +37124,11 @@
37106 ** leaks */
37107 memset(&data, 0, sizeof(data));
37108 if( bEnableVfstrace ){
37109 vfstrace_unregister("trace");
37110 }
 
37111 #ifdef SQLITE_DEBUG
37112 if( sqlite3_memory_used()>mem_main_enter ){
37113 cli_printf(stderr,"Memory leaked: %u bytes\n",
37114 (unsigned int)(sqlite3_memory_used()-mem_main_enter));
37115 }
37116
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -449,12 +449,12 @@
449 wchar_t *b1, *b2;
450 int sz1, sz2;
451
452 sz1 = (int)strlen(zFilename);
453 sz2 = (int)strlen(zMode);
454 b1 = sqlite3_malloc64( (sz1+1)*sizeof(b1[0]) );
455 b2 = sqlite3_malloc64( (sz2+1)*sizeof(b1[0]) );
456 if( b1 && b2 ){
457 sz1 = MultiByteToWideChar(CP_UTF8, 0, zFilename, sz1, b1, sz1);
458 b1[sz1] = 0;
459 sz2 = MultiByteToWideChar(CP_UTF8, 0, zMode, sz2, b2, sz2);
460 b2[sz2] = 0;
@@ -475,12 +475,12 @@
475 wchar_t *b1, *b2;
476 int sz1, sz2;
477
478 sz1 = (int)strlen(zCommand);
479 sz2 = (int)strlen(zMode);
480 b1 = sqlite3_malloc64( (sz1+1)*sizeof(b1[0]) );
481 b2 = sqlite3_malloc64( (sz2+1)*sizeof(b1[0]) );
482 if( b1 && b2 ){
483 sz1 = MultiByteToWideChar(CP_UTF8, 0, zCommand, sz1, b1, sz1);
484 b1[sz1] = 0;
485 sz2 = MultiByteToWideChar(CP_UTF8, 0, zMode, sz2, b2, sz2);
486 b2[sz2] = 0;
@@ -499,11 +499,11 @@
499 /* When reading from the command-prompt in Windows, it is necessary
500 ** to use _O_WTEXT input mode to read UTF-16 characters, then translate
501 ** that into UTF-8. Otherwise, non-ASCII characters all get translated
502 ** into '?'.
503 */
504 wchar_t *b1 = sqlite3_malloc64( sz*sizeof(wchar_t) );
505 if( b1==0 ) return 0;
506 #ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
507 DWORD nRead = 0;
508 if( IsConsole(in)
509 && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz-1, &nRead, 0)
@@ -574,11 +574,11 @@
574 }else{
575 /* One must use UTF16 in order to get unicode support when writing
576 ** to the console on Windows.
577 */
578 int sz = (int)strlen(z);
579 wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(wchar_t) );
580 if( b1==0 ) return 0;
581 sz = MultiByteToWideChar(CP_UTF8, 0, z, sz, b1, sz);
582 b1[sz] = 0;
583
584 #ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
@@ -683,11 +683,11 @@
683 ** May you find forgiveness for yourself and forgive others.
684 ** May you share freely, never taking more than you give.
685 **
686 *************************************************************************
687 ** Header file for the Result-Format or "resfmt" utility library for SQLite.
688 ** See the README.md documentation for additional information.
689 */
690 #ifndef SQLITE_QRF_H
691 #define SQLITE_QRF_H
692 #ifdef __cplusplus
693 extern "C" {
@@ -5813,11 +5813,11 @@
5813 Decimal *p = 0;
5814 int i;
5815 int iExp = 0;
5816
5817 if( zIn==0 ) goto new_from_text_failed;
5818 p = sqlite3_malloc64( sizeof(*p) );
5819 if( p==0 ) goto new_from_text_failed;
5820 p->sign = 0;
5821 p->oom = 0;
5822 p->isInit = 1;
5823 p->isNull = 0;
@@ -6553,11 +6553,11 @@
6553 UNUSED_PARAMETER(argc);
6554 p = sqlite3_aggregate_context(context, sizeof(*p));
6555 if( p==0 ) return;
6556 if( !p->isInit ){
6557 p->isInit = 1;
6558 p->a = sqlite3_malloc64(2);
6559 if( p->a==0 ){
6560 p->oom = 1;
6561 }else{
6562 p->a[0] = 0;
6563 }
@@ -6926,11 +6926,11 @@
6926 goto memFail;
6927 }
6928 sqlite3_result_text(context,"",-1,SQLITE_STATIC);
6929 break;
6930 }
6931 cBuf = sqlite3_malloc64(nc);
6932 if( !cBuf ) goto memFail;
6933 nc = (int)(toBase64(bBuf, nb, cBuf) - cBuf);
6934 sqlite3_result_text(context, cBuf, nc, sqlite3_free);
6935 break;
6936 case SQLITE_TEXT:
@@ -6948,11 +6948,11 @@
6948 goto memFail;
6949 }
6950 sqlite3_result_zeroblob(context, 0);
6951 break;
6952 }
6953 bBuf = sqlite3_malloc64(nb);
6954 if( !bBuf ) goto memFail;
6955 nb = (int)(fromBase64(cBuf, nc, bBuf) - bBuf);
6956 sqlite3_result_blob(context, bBuf, nb, sqlite3_free);
6957 break;
6958 default:
@@ -7303,11 +7303,11 @@
7303 goto memFail;
7304 }
7305 sqlite3_result_text(context,"",-1,SQLITE_STATIC);
7306 break;
7307 }
7308 cBuf = sqlite3_malloc64(nc);
7309 if( !cBuf ) goto memFail;
7310 nc = (int)(toBase85(bBuf, nb, cBuf, "\n") - cBuf);
7311 sqlite3_result_text(context, cBuf, nc, sqlite3_free);
7312 break;
7313 case SQLITE_TEXT:
@@ -7325,11 +7325,11 @@
7325 goto memFail;
7326 }
7327 sqlite3_result_zeroblob(context, 0);
7328 break;
7329 }
7330 bBuf = sqlite3_malloc64(nb);
7331 if( !bBuf ) goto memFail;
7332 nb = (int)(fromBase85(cBuf, nc, bBuf) - bBuf);
7333 sqlite3_result_blob(context, bBuf, nb, sqlite3_free);
7334 break;
7335 default:
@@ -8054,11 +8054,11 @@
8054 (void)argvUnused;
8055 (void)pzErrUnused;
8056 rc = sqlite3_declare_vtab(db,
8057 "CREATE TABLE x(value,start hidden,stop hidden,step hidden)");
8058 if( rc==SQLITE_OK ){
8059 pNew = *ppVtab = sqlite3_malloc64( sizeof(*pNew) );
8060 if( pNew==0 ) return SQLITE_NOMEM;
8061 memset(pNew, 0, sizeof(*pNew));
8062 sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS);
8063 }
8064 return rc;
@@ -8076,11 +8076,11 @@
8076 ** Constructor for a new series_cursor object.
8077 */
8078 static int seriesOpen(sqlite3_vtab *pUnused, sqlite3_vtab_cursor **ppCursor){
8079 series_cursor *pCur;
8080 (void)pUnused;
8081 pCur = sqlite3_malloc64( sizeof(*pCur) );
8082 if( pCur==0 ) return SQLITE_NOMEM;
8083 memset(pCur, 0, sizeof(*pCur));
8084 *ppCursor = &pCur->base;
8085 return SQLITE_OK;
8086 }
@@ -9431,11 +9431,11 @@
9431 ReCompiled *pRe;
9432 const char *zErr;
9433 int i, j;
9434
9435 *ppRe = 0;
9436 pRe = sqlite3_malloc64( sizeof(*pRe) );
9437 if( pRe==0 ){
9438 return "out of memory";
9439 }
9440 memset(pRe, 0, sizeof(*pRe));
9441 pRe->xNextChar = noCase ? re_next_char_nocase : re_next_char;
@@ -10300,11 +10300,11 @@
10300 (void)argc;
10301 (void)argv;
10302 (void)pzErr;
10303 rc = sqlite3_declare_vtab(db, "CREATE TABLE x" FSDIR_SCHEMA);
10304 if( rc==SQLITE_OK ){
10305 pNew = (fsdir_tab*)sqlite3_malloc64( sizeof(*pNew) );
10306 if( pNew==0 ) return SQLITE_NOMEM;
10307 memset(pNew, 0, sizeof(*pNew));
10308 sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY);
10309 }
10310 *ppVtab = (sqlite3_vtab*)pNew;
@@ -10323,11 +10323,11 @@
10323 ** Constructor for a new fsdir_cursor object.
10324 */
10325 static int fsdirOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
10326 fsdir_cursor *pCur;
10327 (void)p;
10328 pCur = sqlite3_malloc64( sizeof(*pCur) );
10329 if( pCur==0 ) return SQLITE_NOMEM;
10330 memset(pCur, 0, sizeof(*pCur));
10331 pCur->iLvl = -1;
10332 *ppCursor = &pCur->base;
10333 return SQLITE_OK;
@@ -11056,11 +11056,11 @@
11056 " prefix TEXT HIDDEN,"
11057 " wholeline TEXT HIDDEN,"
11058 " phase INT HIDDEN" /* Used for debugging only */
11059 ")");
11060 if( rc==SQLITE_OK ){
11061 pNew = sqlite3_malloc64( sizeof(*pNew) );
11062 *ppVtab = (sqlite3_vtab*)pNew;
11063 if( pNew==0 ) return SQLITE_NOMEM;
11064 memset(pNew, 0, sizeof(*pNew));
11065 pNew->db = db;
11066 }
@@ -11078,11 +11078,11 @@
11078 /*
11079 ** Constructor for a new completion_cursor object.
11080 */
11081 static int completionOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
11082 completion_cursor *pCur;
11083 pCur = sqlite3_malloc64( sizeof(*pCur) );
11084 if( pCur==0 ) return SQLITE_NOMEM;
11085 memset(pCur, 0, sizeof(*pCur));
11086 pCur->db = ((completion_vtab*)p)->db;
11087 *ppCursor = &pCur->base;
11088 return SQLITE_OK;
@@ -12582,11 +12582,11 @@
12582 ** Constructor for a new ZipfileCsr object.
12583 */
12584 static int zipfileOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCsr){
12585 ZipfileTab *pTab = (ZipfileTab*)p;
12586 ZipfileCsr *pCsr;
12587 pCsr = sqlite3_malloc64(sizeof(*pCsr));
12588 *ppCsr = (sqlite3_vtab_cursor*)pCsr;
12589 if( pCsr==0 ){
12590 return SQLITE_NOMEM;
12591 }
12592 memset(pCsr, 0, sizeof(*pCsr));
@@ -13121,11 +13121,11 @@
13121 sqlite3_context *pCtx, /* Store result here */
13122 const u8 *aIn, /* Compressed data */
13123 int nIn, /* Size of buffer aIn[] in bytes */
13124 int nOut /* Expected output size */
13125 ){
13126 u8 *aRes = sqlite3_malloc64(nOut);
13127 if( aRes==0 ){
13128 sqlite3_result_error_nomem(pCtx);
13129 }else{
13130 int err;
13131 z_stream str;
@@ -13518,11 +13518,11 @@
13518 return SQLITE_OK;
13519 }
13520
13521 static ZipfileEntry *zipfileNewEntry(const char *zPath){
13522 ZipfileEntry *pNew;
13523 pNew = sqlite3_malloc64(sizeof(ZipfileEntry));
13524 if( pNew ){
13525 memset(pNew, 0, sizeof(ZipfileEntry));
13526 pNew->cds.zFile = sqlite3_mprintf("%s", zPath);
13527 if( pNew->cds.zFile==0 ){
13528 sqlite3_free(pNew);
@@ -14468,11 +14468,11 @@
14468 const Bytef *pData = sqlite3_value_blob(argv[0]);
14469 uLong nData = sqlite3_value_bytes(argv[0]);
14470 uLongf nOut = compressBound(nData);
14471 Bytef *pOut;
14472
14473 pOut = (Bytef*)sqlite3_malloc64(nOut);
14474 if( pOut==0 ){
14475 sqlite3_result_error_nomem(context);
14476 return;
14477 }else{
14478 if( Z_OK!=compress(pOut, &nOut, pData, nData) ){
@@ -14513,11 +14513,11 @@
14513 if( sz<=0 || sz==(nData = sqlite3_value_bytes(argv[0])) ){
14514 sqlite3_result_value(context, argv[0]);
14515 }else{
14516 uLongf szf = sz;
14517 const Bytef *pData= sqlite3_value_blob(argv[0]);
14518 Bytef *pOut = sqlite3_malloc64(sz);
14519 if( pOut==0 ){
14520 sqlite3_result_error_nomem(context);
14521 }else if( Z_OK!=uncompress(pOut, &szf, pData, nData) ){
14522 sqlite3_result_error(context, "error in uncompress()", -1);
14523 }else{
@@ -18134,11 +18134,11 @@
18134 Stmtrand *p;
18135
18136 p = (Stmtrand*)sqlite3_get_auxdata(context, STMTRAND_KEY);
18137 if( p==0 ){
18138 unsigned int seed;
18139 p = sqlite3_malloc64( sizeof(*p) );
18140 if( p==0 ){
18141 sqlite3_result_error_nomem(context);
18142 return;
18143 }
18144 if( argc>=1 ){
@@ -19074,11 +19074,11 @@
19074 rc = pRoot->xOpen(pRoot, zName, p->pReal, flags, pOutFlags);
19075 vfstraceOnOff(pInfo, VTR_OPEN);
19076 vfstrace_printf(pInfo, "%s.xOpen(%s,flags=0x%x)",
19077 pInfo->zVfsName, p->zFName, flags);
19078 if( p->pReal->pMethods ){
19079 sqlite3_io_methods *pNew = sqlite3_malloc64( sizeof(*pNew) );
19080 const sqlite3_io_methods *pSub = p->pReal->pMethods;
19081 memset(pNew, 0, sizeof(*pNew));
19082 pNew->iVersion = pSub->iVersion;
19083 pNew->xClose = vfstraceClose;
19084 pNew->xRead = vfstraceRead;
@@ -36326,10 +36326,25 @@
36326 ShellState *p = (ShellState*)pArg;
36327 cli_puts(z, p->out);
36328 fflush(p->out);
36329 return 1;
36330 }
36331
36332 #if defined(SQLITE_DEBUG) && !defined(SQLITE_SHELL_FIDDLE)
36333 /* Ensure that sqlite3_reset_auto_extension() clears auto-extension
36334 ** memory. https://sqlite.org/forum/forumpost/310cb231b07c80d1.
36335 ** Testing this: if we (inadvertently) remove the
36336 ** sqlite3_reset_auto_extension() call from main(), most shell tests
36337 ** will fail because of a leak message in their output. */
36338 static int auto_ext_leak_tester(
36339 sqlite3 *db, const char **pzErrMsg,
36340 const struct sqlite3_api_routines *pThunk
36341 ){
36342 (void)db; (void)pzErrMsg; (void)pThunk;
36343 return SQLITE_OK;
36344 }
36345 #endif
36346
36347 /* Alternative name to the entry point for Fiddle */
36348 #ifdef SQLITE_SHELL_FIDDLE
36349 # define main fiddle_main
36350 #endif
@@ -36729,10 +36744,13 @@
36744 if( bEnableVfstrace ){
36745 vfstrace_register("trace",0,vfstraceOut, &data, 1);
36746 }
36747 #ifndef SQLITE_SHELL_FIDDLE
36748 sqlite3_appendvfs_init(0,0,0);
36749 #ifdef SQLITE_DEBUG
36750 sqlite3_auto_extension( (void (*)())auto_ext_leak_tester );
36751 #endif
36752 #endif
36753 modeDefault(&data);
36754
36755 /* Go ahead and open the database file if it already exists. If the
36756 ** file does not exist, delay opening it. This prevents empty database
@@ -37106,10 +37124,11 @@
37124 ** leaks */
37125 memset(&data, 0, sizeof(data));
37126 if( bEnableVfstrace ){
37127 vfstrace_unregister("trace");
37128 }
37129 sqlite3_reset_auto_extension();
37130 #ifdef SQLITE_DEBUG
37131 if( sqlite3_memory_used()>mem_main_enter ){
37132 cli_printf(stderr,"Memory leaked: %u bytes\n",
37133 (unsigned int)(sqlite3_memory_used()-mem_main_enter));
37134 }
37135
+15 -10
--- 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
-** 7bc1d0c4572f126cfe68fa51fe992d2bd46b with changes in files:
21
+** c8121593fa455cd43b3878f8b65ebac47c07 with changes in files:
2222
**
2323
**
2424
*/
2525
#ifndef SQLITE_AMALGAMATION
2626
#define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467467
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468468
** [sqlite_version()] and [sqlite_source_id()].
469469
*/
470470
#define SQLITE_VERSION "3.53.0"
471471
#define SQLITE_VERSION_NUMBER 3053000
472
-#define SQLITE_SOURCE_ID "2026-04-01 11:54:20 7bc1d0c4572f126cfe68fa51fe992d2bd46b1e57c04721991bd5fad36dd795c5"
472
+#define SQLITE_SOURCE_ID "2026-04-07 09:15:21 c8121593fa455cd43b3878f8b65ebac47c07dab4b8ce081aa34b14fc9440afbc"
473473
#define SQLITE_SCM_BRANCH "trunk"
474474
#define SQLITE_SCM_TAGS ""
475
-#define SQLITE_SCM_DATETIME "2026-04-01T11:54:20.065Z"
475
+#define SQLITE_SCM_DATETIME "2026-04-07T09:15:21.538Z"
476476
477477
/*
478478
** CAPI3REF: Run-Time Library Version Numbers
479479
** KEYWORDS: sqlite3_version sqlite3_sourceid
480480
**
@@ -68519,11 +68519,11 @@
6851968519
walLockName(lockIdx), n));
6852068520
}
6852168521
6852268522
/*
6852368523
** Compute a hash on a page number. The resulting hash value must land
68524
-** between 0 and (HASHTABLE_NSLOT-1). The walHashNext() function advances
68524
+** between 0 and (HASHTABLE_NSLOT-1). The walNextHash() function advances
6852568525
** the hash to the next value in the event of a collision.
6852668526
*/
6852768527
static int walHash(u32 iPage){
6852868528
assert( iPage>0 );
6852968529
assert( (HASHTABLE_NSLOT & (HASHTABLE_NSLOT-1))==0 );
@@ -68727,11 +68727,11 @@
6872768727
/* Write the aPgno[] array entry and the hash-table slot. */
6872868728
nCollide = idx;
6872968729
for(iKey=walHash(iPage); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){
6873068730
if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT;
6873168731
}
68732
- sLoc.aPgno[idx-1] = iPage;
68732
+ sLoc.aPgno[(idx-1)&(HASHTABLE_NPAGE-1)] = iPage;
6873368733
AtomicStore(&sLoc.aHash[iKey], (ht_slot)idx);
6873468734
6873568735
#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
6873668736
/* Verify that the number of entries in the hash table exactly equals
6873768737
** the number of entries in the mapping region.
@@ -70975,11 +70975,14 @@
7097570975
nCollide = HASHTABLE_NSLOT;
7097670976
iKey = walHash(pgno);
7097770977
SEH_INJECT_FAULT;
7097870978
while( (iH = AtomicLoad(&sLoc.aHash[iKey]))!=0 ){
7097970979
u32 iFrame = iH + sLoc.iZero;
70980
- if( iFrame<=iLast && iFrame>=pWal->minFrame && sLoc.aPgno[iH-1]==pgno ){
70980
+ if( iFrame<=iLast
70981
+ && iFrame>=pWal->minFrame
70982
+ && sLoc.aPgno[(iH-1)&(HASHTABLE_NPAGE-1)]==pgno
70983
+ ){
7098170984
assert( iFrame>iRead || CORRUPT_DB );
7098270985
iRead = iFrame;
7098370986
}
7098470987
if( (nCollide--)==0 ){
7098570988
*piRead = 0;
@@ -233662,13 +233665,13 @@
233662233665
/*
233663233666
** Read a varint value from buffer aBuf[], size nBuf bytes, into *piVal.
233664233667
** Return the number of bytes read.
233665233668
*/
233666233669
static int sessionVarintGetSafe(const u8 *aBuf, int nBuf, int *piVal){
233667
- u8 aCopy[5];
233670
+ u8 aCopy[9];
233668233671
const u8 *aRead = aBuf;
233669
- if( nBuf<5 ){
233672
+ if( nBuf<sizeof(aCopy) ){
233670233673
memcpy(aCopy, aBuf, nBuf);
233671233674
aRead = aCopy;
233672233675
}
233673233676
return getVarint32(aRead, *piVal);
233674233677
}
@@ -239360,11 +239363,13 @@
239360239363
return SQLITE_NOMEM;
239361239364
}
239362239365
memset(pTab, 0, sizeof(SessionTable));
239363239366
pTab->nCol = nCol;
239364239367
pTab->abPK = (u8*)&pTab[1];
239365
- memcpy(pTab->abPK, abPK, nCol);
239368
+ if( nCol>0 ){
239369
+ memcpy(pTab->abPK, abPK, nCol);
239370
+ }
239366239371
pTab->zName = (char*)&pTab->abPK[nCol];
239367239372
memcpy(pTab->zName, zTab, nTab+1);
239368239373
239369239374
if( pGrp->db ){
239370239375
pTab->nCol = 0;
@@ -263206,11 +263211,11 @@
263206263211
int nArg, /* Number of args */
263207263212
sqlite3_value **apUnused /* Function arguments */
263208263213
){
263209263214
assert( nArg==0 );
263210263215
UNUSED_PARAM2(nArg, apUnused);
263211
- sqlite3_result_text(pCtx, "fts5: 2026-04-01 11:39:13 009b576dcd5fccaaa52459dbfaa1b2a6fcf6d372e4b8d63553dfa88aab9a759c", -1, SQLITE_TRANSIENT);
263216
+ sqlite3_result_text(pCtx, "fts5: 2026-04-07 09:15:21 c8121593fa455cd43b3878f8b65ebac47c07dab4b8ce081aa34b14fc9440afbc", -1, SQLITE_TRANSIENT);
263212263217
}
263213263218
263214263219
/*
263215263220
** Implementation of fts5_locale(LOCALE, TEXT) function.
263216263221
**
263217263222
--- 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 ** 7bc1d0c4572f126cfe68fa51fe992d2bd46b with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.53.0"
471 #define SQLITE_VERSION_NUMBER 3053000
472 #define SQLITE_SOURCE_ID "2026-04-01 11:54:20 7bc1d0c4572f126cfe68fa51fe992d2bd46b1e57c04721991bd5fad36dd795c5"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2026-04-01T11:54:20.065Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -68519,11 +68519,11 @@
68519 walLockName(lockIdx), n));
68520 }
68521
68522 /*
68523 ** Compute a hash on a page number. The resulting hash value must land
68524 ** between 0 and (HASHTABLE_NSLOT-1). The walHashNext() function advances
68525 ** the hash to the next value in the event of a collision.
68526 */
68527 static int walHash(u32 iPage){
68528 assert( iPage>0 );
68529 assert( (HASHTABLE_NSLOT & (HASHTABLE_NSLOT-1))==0 );
@@ -68727,11 +68727,11 @@
68727 /* Write the aPgno[] array entry and the hash-table slot. */
68728 nCollide = idx;
68729 for(iKey=walHash(iPage); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){
68730 if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT;
68731 }
68732 sLoc.aPgno[idx-1] = iPage;
68733 AtomicStore(&sLoc.aHash[iKey], (ht_slot)idx);
68734
68735 #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
68736 /* Verify that the number of entries in the hash table exactly equals
68737 ** the number of entries in the mapping region.
@@ -70975,11 +70975,14 @@
70975 nCollide = HASHTABLE_NSLOT;
70976 iKey = walHash(pgno);
70977 SEH_INJECT_FAULT;
70978 while( (iH = AtomicLoad(&sLoc.aHash[iKey]))!=0 ){
70979 u32 iFrame = iH + sLoc.iZero;
70980 if( iFrame<=iLast && iFrame>=pWal->minFrame && sLoc.aPgno[iH-1]==pgno ){
 
 
 
70981 assert( iFrame>iRead || CORRUPT_DB );
70982 iRead = iFrame;
70983 }
70984 if( (nCollide--)==0 ){
70985 *piRead = 0;
@@ -233662,13 +233665,13 @@
233662 /*
233663 ** Read a varint value from buffer aBuf[], size nBuf bytes, into *piVal.
233664 ** Return the number of bytes read.
233665 */
233666 static int sessionVarintGetSafe(const u8 *aBuf, int nBuf, int *piVal){
233667 u8 aCopy[5];
233668 const u8 *aRead = aBuf;
233669 if( nBuf<5 ){
233670 memcpy(aCopy, aBuf, nBuf);
233671 aRead = aCopy;
233672 }
233673 return getVarint32(aRead, *piVal);
233674 }
@@ -239360,11 +239363,13 @@
239360 return SQLITE_NOMEM;
239361 }
239362 memset(pTab, 0, sizeof(SessionTable));
239363 pTab->nCol = nCol;
239364 pTab->abPK = (u8*)&pTab[1];
239365 memcpy(pTab->abPK, abPK, nCol);
 
 
239366 pTab->zName = (char*)&pTab->abPK[nCol];
239367 memcpy(pTab->zName, zTab, nTab+1);
239368
239369 if( pGrp->db ){
239370 pTab->nCol = 0;
@@ -263206,11 +263211,11 @@
263206 int nArg, /* Number of args */
263207 sqlite3_value **apUnused /* Function arguments */
263208 ){
263209 assert( nArg==0 );
263210 UNUSED_PARAM2(nArg, apUnused);
263211 sqlite3_result_text(pCtx, "fts5: 2026-04-01 11:39:13 009b576dcd5fccaaa52459dbfaa1b2a6fcf6d372e4b8d63553dfa88aab9a759c", -1, SQLITE_TRANSIENT);
263212 }
263213
263214 /*
263215 ** Implementation of fts5_locale(LOCALE, TEXT) function.
263216 **
263217
--- 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 ** c8121593fa455cd43b3878f8b65ebac47c07 with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.53.0"
471 #define SQLITE_VERSION_NUMBER 3053000
472 #define SQLITE_SOURCE_ID "2026-04-07 09:15:21 c8121593fa455cd43b3878f8b65ebac47c07dab4b8ce081aa34b14fc9440afbc"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2026-04-07T09:15:21.538Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -68519,11 +68519,11 @@
68519 walLockName(lockIdx), n));
68520 }
68521
68522 /*
68523 ** Compute a hash on a page number. The resulting hash value must land
68524 ** between 0 and (HASHTABLE_NSLOT-1). The walNextHash() function advances
68525 ** the hash to the next value in the event of a collision.
68526 */
68527 static int walHash(u32 iPage){
68528 assert( iPage>0 );
68529 assert( (HASHTABLE_NSLOT & (HASHTABLE_NSLOT-1))==0 );
@@ -68727,11 +68727,11 @@
68727 /* Write the aPgno[] array entry and the hash-table slot. */
68728 nCollide = idx;
68729 for(iKey=walHash(iPage); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){
68730 if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT;
68731 }
68732 sLoc.aPgno[(idx-1)&(HASHTABLE_NPAGE-1)] = iPage;
68733 AtomicStore(&sLoc.aHash[iKey], (ht_slot)idx);
68734
68735 #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
68736 /* Verify that the number of entries in the hash table exactly equals
68737 ** the number of entries in the mapping region.
@@ -70975,11 +70975,14 @@
70975 nCollide = HASHTABLE_NSLOT;
70976 iKey = walHash(pgno);
70977 SEH_INJECT_FAULT;
70978 while( (iH = AtomicLoad(&sLoc.aHash[iKey]))!=0 ){
70979 u32 iFrame = iH + sLoc.iZero;
70980 if( iFrame<=iLast
70981 && iFrame>=pWal->minFrame
70982 && sLoc.aPgno[(iH-1)&(HASHTABLE_NPAGE-1)]==pgno
70983 ){
70984 assert( iFrame>iRead || CORRUPT_DB );
70985 iRead = iFrame;
70986 }
70987 if( (nCollide--)==0 ){
70988 *piRead = 0;
@@ -233662,13 +233665,13 @@
233665 /*
233666 ** Read a varint value from buffer aBuf[], size nBuf bytes, into *piVal.
233667 ** Return the number of bytes read.
233668 */
233669 static int sessionVarintGetSafe(const u8 *aBuf, int nBuf, int *piVal){
233670 u8 aCopy[9];
233671 const u8 *aRead = aBuf;
233672 if( nBuf<sizeof(aCopy) ){
233673 memcpy(aCopy, aBuf, nBuf);
233674 aRead = aCopy;
233675 }
233676 return getVarint32(aRead, *piVal);
233677 }
@@ -239360,11 +239363,13 @@
239363 return SQLITE_NOMEM;
239364 }
239365 memset(pTab, 0, sizeof(SessionTable));
239366 pTab->nCol = nCol;
239367 pTab->abPK = (u8*)&pTab[1];
239368 if( nCol>0 ){
239369 memcpy(pTab->abPK, abPK, nCol);
239370 }
239371 pTab->zName = (char*)&pTab->abPK[nCol];
239372 memcpy(pTab->zName, zTab, nTab+1);
239373
239374 if( pGrp->db ){
239375 pTab->nCol = 0;
@@ -263206,11 +263211,11 @@
263211 int nArg, /* Number of args */
263212 sqlite3_value **apUnused /* Function arguments */
263213 ){
263214 assert( nArg==0 );
263215 UNUSED_PARAM2(nArg, apUnused);
263216 sqlite3_result_text(pCtx, "fts5: 2026-04-07 09:15:21 c8121593fa455cd43b3878f8b65ebac47c07dab4b8ce081aa34b14fc9440afbc", -1, SQLITE_TRANSIENT);
263217 }
263218
263219 /*
263220 ** Implementation of fts5_locale(LOCALE, TEXT) function.
263221 **
263222
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.53.0"
150150
#define SQLITE_VERSION_NUMBER 3053000
151
-#define SQLITE_SOURCE_ID "2026-04-01 11:54:20 7bc1d0c4572f126cfe68fa51fe992d2bd46b1e57c04721991bd5fad36dd795c5"
151
+#define SQLITE_SOURCE_ID "2026-04-07 09:15:21 c8121593fa455cd43b3878f8b65ebac47c07dab4b8ce081aa34b14fc9440afbc"
152152
#define SQLITE_SCM_BRANCH "trunk"
153153
#define SQLITE_SCM_TAGS ""
154
-#define SQLITE_SCM_DATETIME "2026-04-01T11:54:20.065Z"
154
+#define SQLITE_SCM_DATETIME "2026-04-07T09:15:21.538Z"
155155
156156
/*
157157
** CAPI3REF: Run-Time Library Version Numbers
158158
** KEYWORDS: sqlite3_version sqlite3_sourceid
159159
**
160160
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.53.0"
150 #define SQLITE_VERSION_NUMBER 3053000
151 #define SQLITE_SOURCE_ID "2026-04-01 11:54:20 7bc1d0c4572f126cfe68fa51fe992d2bd46b1e57c04721991bd5fad36dd795c5"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2026-04-01T11:54:20.065Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
160
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.53.0"
150 #define SQLITE_VERSION_NUMBER 3053000
151 #define SQLITE_SOURCE_ID "2026-04-07 09:15:21 c8121593fa455cd43b3878f8b65ebac47c07dab4b8ce081aa34b14fc9440afbc"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2026-04-07T09:15:21.538Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
160

Keyboard Shortcuts

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