Fossil SCM

Update the built-in SQLite to the latest trunk version for testing.

drh 2026-02-24 00:22 trunk
Commit b8ab8b3d414c23590025ff38f31e433c2074061563b7ea45e48695e7e1a95151
3 files changed +282 -82 +131 -49 +24 -6
+282 -82
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -6749,17 +6749,41 @@
67496749
}while( j<p->nDigit );
67506750
}
67516751
z[i] = 0;
67526752
sqlite3_result_text(pCtx, z, i, sqlite3_free);
67536753
}
6754
+
6755
+/*
6756
+** Round a decimal value to N significant digits. N must be positive.
6757
+*/
6758
+static void decimal_round(Decimal *p, int N){
6759
+ int i;
6760
+ int nZero;
6761
+ if( N<1 ) return;
6762
+ for(nZero=0; nZero<p->nDigit && p->a[nZero]==0; nZero++){}
6763
+ N += nZero;
6764
+ if( p->nDigit<=N ) return;
6765
+ if( p->a[N]>4 ){
6766
+ p->a[N-1]++;
6767
+ for(i=N-1; i>0 && p->a[i]>9; i--){
6768
+ p->a[i] = 0;
6769
+ p->a[i-1]++;
6770
+ }
6771
+ if( p->a[0]>9 ){
6772
+ p->a[0] = 1;
6773
+ p->nFrac--;
6774
+ }
6775
+ }
6776
+ memset(&p->a[N], 0, p->nDigit - N);
6777
+}
67546778
67556779
/*
67566780
** Make the given Decimal the result in an format similar to '%+#e'.
67576781
** In other words, show exponential notation with leading and trailing
67586782
** zeros omitted.
67596783
*/
6760
-static void decimal_result_sci(sqlite3_context *pCtx, Decimal *p){
6784
+static void decimal_result_sci(sqlite3_context *pCtx, Decimal *p, int N){
67616785
char *z; /* The output buffer */
67626786
int i; /* Loop counter */
67636787
int nZero; /* Number of leading zeros */
67646788
int nDigit; /* Number of digits not counting trailing zeros */
67656789
int nFrac; /* Digits to the right of the decimal point */
@@ -6773,11 +6797,12 @@
67736797
}
67746798
if( p->isNull ){
67756799
sqlite3_result_null(pCtx);
67766800
return;
67776801
}
6778
- for(nDigit=p->nDigit; nDigit>0 && p->a[nDigit-1]==0; nDigit--){}
6802
+ if( N<1 ) N = 0;
6803
+ for(nDigit=p->nDigit; nDigit>N && p->a[nDigit-1]==0; nDigit--){}
67796804
for(nZero=0; nZero<nDigit && p->a[nZero]==0; nZero++){}
67806805
nFrac = p->nFrac + (nDigit - p->nDigit);
67816806
nDigit -= nZero;
67826807
z = sqlite3_malloc64( (sqlite3_int64)nDigit+20 );
67836808
if( z==0 ){
@@ -7136,14 +7161,20 @@
71367161
sqlite3_context *context,
71377162
int argc,
71387163
sqlite3_value **argv
71397164
){
71407165
Decimal *p = decimal_new(context, argv[0], 0);
7141
- UNUSED_PARAMETER(argc);
7166
+ int N;
7167
+ if( argc==2 ){
7168
+ N = sqlite3_value_int(argv[1]);
7169
+ if( N>0 ) decimal_round(p, N);
7170
+ }else{
7171
+ N = 0;
7172
+ }
71427173
if( p ){
71437174
if( sqlite3_user_data(context)!=0 ){
7144
- decimal_result_sci(context, p);
7175
+ decimal_result_sci(context, p, N);
71457176
}else{
71467177
decimal_result(context, p);
71477178
}
71487179
decimal_free(p);
71497180
}
@@ -7309,11 +7340,11 @@
73097340
sqlite3_value **argv
73107341
){
73117342
UNUSED_PARAMETER(argc);
73127343
if( sqlite3_value_type(argv[0])==SQLITE_INTEGER ){
73137344
Decimal *pA = decimalPow2(sqlite3_value_int(argv[0]));
7314
- decimal_result_sci(context, pA);
7345
+ decimal_result_sci(context, pA, 0);
73157346
decimal_free(pA);
73167347
}
73177348
}
73187349
73197350
#ifdef _WIN32
@@ -7330,11 +7361,13 @@
73307361
int nArg;
73317362
int iArg;
73327363
void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
73337364
} aFunc[] = {
73347365
{ "decimal", 1, 0, decimalFunc },
7366
+ { "decimal", 2, 0, decimalFunc },
73357367
{ "decimal_exp", 1, 1, decimalFunc },
7368
+ { "decimal_exp", 2, 1, decimalFunc },
73367369
{ "decimal_cmp", 2, 0, decimalCmpFunc },
73377370
{ "decimal_add", 2, 0, decimalAddFunc },
73387371
{ "decimal_sub", 2, 0, decimalSubFunc },
73397372
{ "decimal_mul", 2, 0, decimalMulFunc },
73407373
{ "decimal_pow2", 1, 0, decimalPow2Func },
@@ -8384,10 +8417,42 @@
83848417
v >>= 8;
83858418
}
83868419
sqlite3_result_blob(context, a, sizeof(r), SQLITE_TRANSIENT);
83878420
}
83888421
}
8422
+
8423
+/*
8424
+** Functions to convert between 64-bit integers and floats.
8425
+**
8426
+** The bit patterns are copied. The numeric values are different.
8427
+*/
8428
+static void ieee754func_from_int(
8429
+ sqlite3_context *context,
8430
+ int argc,
8431
+ sqlite3_value **argv
8432
+){
8433
+ UNUSED_PARAMETER(argc);
8434
+ if( sqlite3_value_type(argv[0])==SQLITE_INTEGER ){
8435
+ double r;
8436
+ sqlite3_int64 v = sqlite3_value_int64(argv[0]);
8437
+ memcpy(&r, &v, sizeof(r));
8438
+ sqlite3_result_double(context, r);
8439
+ }
8440
+}
8441
+static void ieee754func_to_int(
8442
+ sqlite3_context *context,
8443
+ int argc,
8444
+ sqlite3_value **argv
8445
+){
8446
+ UNUSED_PARAMETER(argc);
8447
+ if( sqlite3_value_type(argv[0])==SQLITE_FLOAT ){
8448
+ double r = sqlite3_value_double(argv[0]);
8449
+ sqlite3_uint64 v;
8450
+ memcpy(&v, &r, sizeof(v));
8451
+ sqlite3_result_int64(context, v);
8452
+ }
8453
+}
83898454
83908455
/*
83918456
** SQL Function: ieee754_inc(r,N)
83928457
**
83938458
** Move the floating point value r by N quantums and return the new
@@ -8437,10 +8502,12 @@
84378502
{ "ieee754", 2, 0, ieee754func },
84388503
{ "ieee754_mantissa", 1, 1, ieee754func },
84398504
{ "ieee754_exponent", 1, 2, ieee754func },
84408505
{ "ieee754_to_blob", 1, 0, ieee754func_to_blob },
84418506
{ "ieee754_from_blob", 1, 0, ieee754func_from_blob },
8507
+ { "ieee754_to_int", 1, 0, ieee754func_to_int },
8508
+ { "ieee754_from_int", 1, 0, ieee754func_from_int },
84428509
{ "ieee754_inc", 2, 0, ieee754inc },
84438510
};
84448511
unsigned int i;
84458512
int rc = SQLITE_OK;
84468513
SQLITE_EXTENSION_INIT2(pApi);
@@ -10422,16 +10489,20 @@
1042210489
# include <unistd.h>
1042310490
# include <dirent.h>
1042410491
# include <utime.h>
1042510492
# include <sys/time.h>
1042610493
# define STRUCT_STAT struct stat
10494
+# include <limits.h>
10495
+# include <stdlib.h>
1042710496
#else
1042810497
/* # include "windirent.h" */
1042910498
# include <direct.h>
1043010499
# define STRUCT_STAT struct _stat
1043110500
# define chmod(path,mode) fileio_chmod(path,mode)
1043210501
# define mkdir(path,mode) fileio_mkdir(path)
10502
+ extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
10503
+ extern char *sqlite3_win32_unicode_to_utf8(LPCWSTR);
1043310504
#endif
1043410505
#include <time.h>
1043510506
#include <errno.h>
1043610507
1043710508
/* When used as part of the CLI, the sqlite3_stdio.h module will have
@@ -10459,16 +10530,13 @@
1045910530
/*
1046010531
** UTF8 chmod() function for Windows
1046110532
*/
1046210533
#if defined(_WIN32) || defined(WIN32)
1046310534
static int fileio_chmod(const char *zPath, int pmode){
10464
- sqlite3_int64 sz = strlen(zPath);
10465
- wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
1046610535
int rc;
10536
+ wchar_t *b1 = sqlite3_win32_utf8_to_unicode(zPath);
1046710537
if( b1==0 ) return -1;
10468
- sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
10469
- b1[sz] = 0;
1047010538
rc = _wchmod(b1, pmode);
1047110539
sqlite3_free(b1);
1047210540
return rc;
1047310541
}
1047410542
#endif
@@ -10476,16 +10544,13 @@
1047610544
/*
1047710545
** UTF8 mkdir() function for Windows
1047810546
*/
1047910547
#if defined(_WIN32) || defined(WIN32)
1048010548
static int fileio_mkdir(const char *zPath){
10481
- sqlite3_int64 sz = strlen(zPath);
10482
- wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
1048310549
int rc;
10550
+ wchar_t *b1 = sqlite3_win32_utf8_to_unicode(zPath);
1048410551
if( b1==0 ) return -1;
10485
- sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
10486
- b1[sz] = 0;
1048710552
rc = _wmkdir(b1);
1048810553
sqlite3_free(b1);
1048910554
return rc;
1049010555
}
1049110556
#endif
@@ -10594,54 +10659,11 @@
1059410659
fileIntervals.LowPart = pFileTime->dwLowDateTime;
1059510660
fileIntervals.HighPart = pFileTime->dwHighDateTime;
1059610661
1059710662
return (fileIntervals.QuadPart - epochIntervals.QuadPart) / 10000000;
1059810663
}
10599
-
10600
-
10601
-#if defined(FILEIO_WIN32_DLL) && (defined(_WIN32) || defined(WIN32))
10602
-# /* To allow a standalone DLL, use this next replacement function: */
10603
-# undef sqlite3_win32_utf8_to_unicode
10604
-# define sqlite3_win32_utf8_to_unicode utf8_to_utf16
10605
-#
10606
-LPWSTR utf8_to_utf16(const char *z){
10607
- int nAllot = MultiByteToWideChar(CP_UTF8, 0, z, -1, NULL, 0);
10608
- LPWSTR rv = sqlite3_malloc(nAllot * sizeof(WCHAR));
10609
- if( rv!=0 && 0 < MultiByteToWideChar(CP_UTF8, 0, z, -1, rv, nAllot) )
10610
- return rv;
10611
- sqlite3_free(rv);
10612
- return 0;
10613
-}
10614
-#endif
10615
-
10616
-/*
10617
-** This function attempts to normalize the time values found in the stat()
10618
-** buffer to UTC. This is necessary on Win32, where the runtime library
10619
-** appears to return these values as local times.
10620
-*/
10621
-static void statTimesToUtc(
10622
- const char *zPath,
10623
- STRUCT_STAT *pStatBuf
10624
-){
10625
- HANDLE hFindFile;
10626
- WIN32_FIND_DATAW fd;
10627
- LPWSTR zUnicodeName;
10628
- extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
10629
- zUnicodeName = sqlite3_win32_utf8_to_unicode(zPath);
10630
- if( zUnicodeName ){
10631
- memset(&fd, 0, sizeof(WIN32_FIND_DATAW));
10632
- hFindFile = FindFirstFileW(zUnicodeName, &fd);
10633
- if( hFindFile!=NULL ){
10634
- pStatBuf->st_ctime = (time_t)fileTimeToUnixTime(&fd.ftCreationTime);
10635
- pStatBuf->st_atime = (time_t)fileTimeToUnixTime(&fd.ftLastAccessTime);
10636
- pStatBuf->st_mtime = (time_t)fileTimeToUnixTime(&fd.ftLastWriteTime);
10637
- FindClose(hFindFile);
10638
- }
10639
- sqlite3_free(zUnicodeName);
10640
- }
10641
-}
10642
-#endif
10664
+#endif /* _WIN32 */
1064310665
1064410666
/*
1064510667
** This function is used in place of stat(). On Windows, special handling
1064610668
** is required in order for the included time to be returned as UTC. On all
1064710669
** other systems, this function simply calls stat().
@@ -10649,18 +10671,26 @@
1064910671
static int fileStat(
1065010672
const char *zPath,
1065110673
STRUCT_STAT *pStatBuf
1065210674
){
1065310675
#if defined(_WIN32)
10654
- sqlite3_int64 sz = strlen(zPath);
10655
- wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
1065610676
int rc;
10677
+ wchar_t *b1 = sqlite3_win32_utf8_to_unicode(zPath);
1065710678
if( b1==0 ) return 1;
10658
- sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
10659
- b1[sz] = 0;
1066010679
rc = _wstat(b1, pStatBuf);
10661
- if( rc==0 ) statTimesToUtc(zPath, pStatBuf);
10680
+ if( rc==0 ){
10681
+ HANDLE hFindFile;
10682
+ WIN32_FIND_DATAW fd;
10683
+ memset(&fd, 0, sizeof(WIN32_FIND_DATAW));
10684
+ hFindFile = FindFirstFileW(b1, &fd);
10685
+ if( hFindFile!=NULL ){
10686
+ pStatBuf->st_ctime = (time_t)fileTimeToUnixTime(&fd.ftCreationTime);
10687
+ pStatBuf->st_atime = (time_t)fileTimeToUnixTime(&fd.ftLastAccessTime);
10688
+ pStatBuf->st_mtime = (time_t)fileTimeToUnixTime(&fd.ftLastWriteTime);
10689
+ FindClose(hFindFile);
10690
+ }
10691
+ }
1066210692
sqlite3_free(b1);
1066310693
return rc;
1066410694
#else
1066510695
return stat(zPath, pStatBuf);
1066610696
#endif
@@ -11420,10 +11450,158 @@
1142011450
return rc;
1142111451
}
1142211452
#else /* SQLITE_OMIT_VIRTUALTABLE */
1142311453
# define fsdirRegister(x) SQLITE_OK
1142411454
#endif
11455
+
11456
+/*
11457
+** This version of realpath() works on any system. The string
11458
+** returned is held in memory allocated using sqlite3_malloc64().
11459
+** The caller is responsible for calling sqlite3_free().
11460
+*/
11461
+static char *portable_realpath(const char *zPath){
11462
+#if !defined(_WIN32) /* BEGIN unix */
11463
+
11464
+ char *zOut = 0; /* Result */
11465
+ char *z; /* Temporary buffer */
11466
+#if defined(PATH_MAX)
11467
+ char zBuf[PATH_MAX+1]; /* Space for the temporary buffer */
11468
+#endif
11469
+
11470
+ if( zPath==0 ) return 0;
11471
+#if defined(PATH_MAX)
11472
+ z = realpath(zPath, zBuf);
11473
+ if( z ){
11474
+ zOut = sqlite3_mprintf("%s", zBuf);
11475
+ }
11476
+#endif /* defined(PATH_MAX) */
11477
+ if( zOut==0 ){
11478
+ /* Try POSIX.1-2008 malloc behavior */
11479
+ z = realpath(zPath, NULL);
11480
+ if( z ){
11481
+ zOut = sqlite3_mprintf("%s", z);
11482
+ free(z);
11483
+ }
11484
+ }
11485
+ return zOut;
11486
+
11487
+#else /* End UNIX, Begin WINDOWS */
11488
+
11489
+ wchar_t *zPath16; /* UTF16 translation of zPath */
11490
+ char *zOut = 0; /* Result */
11491
+ wchar_t *z = 0; /* Temporary buffer */
11492
+
11493
+ if( zPath==0 ) return 0;
11494
+
11495
+ zPath16 = sqlite3_win32_utf8_to_unicode(zPath);
11496
+ if( zPath16==0 ) return 0;
11497
+ z = _wfullpath(NULL, zPath16, 0);
11498
+ sqlite3_free(zPath16);
11499
+ if( z ){
11500
+ zOut = sqlite3_win32_unicode_to_utf8(z);
11501
+ free(z);
11502
+ }
11503
+ return zOut;
11504
+
11505
+#endif /* End WINDOWS, Begin common code */
11506
+}
11507
+
11508
+/*
11509
+** SQL function: realpath(X)
11510
+**
11511
+** Try to convert file or pathname X into its real, absolute pathname.
11512
+** Return NULL if unable.
11513
+**
11514
+** The file or directory X is not required to exist. The answer is formed
11515
+** by calling system realpath() on the prefix of X that does exist and
11516
+** appending the tail of X that does not (yet) exist.
11517
+*/
11518
+static void realpathFunc(
11519
+ sqlite3_context *context,
11520
+ int argc,
11521
+ sqlite3_value **argv
11522
+){
11523
+ const char *zPath; /* Original input path */
11524
+ char *zCopy; /* An editable copy of zPath */
11525
+ char *zOut; /* The result */
11526
+ char cSep = 0; /* Separator turned into \000 */
11527
+ size_t len; /* Prefix length before cSep */
11528
+#ifdef _WIN32
11529
+ const int isWin = 1;
11530
+#else
11531
+ const int isWin = 0;
11532
+#endif
11533
+
11534
+ (void)argc;
11535
+ zPath = (const char*)sqlite3_value_text(argv[0]);
11536
+ if( zPath==0 ) return;
11537
+ if( zPath[0]==0 ) zPath = ".";
11538
+ zCopy = sqlite3_mprintf("%s",zPath);
11539
+ len = strlen(zCopy);
11540
+ while( len>1 && (zCopy[len-1]=='/' || (isWin && zCopy[len-1]=='\\')) ){
11541
+ len--;
11542
+ }
11543
+ zCopy[len] = 0;
11544
+ while( 1 /*exit-by-break*/ ){
11545
+ zOut = portable_realpath(zCopy);
11546
+ zCopy[len] = cSep;
11547
+ if( zOut ){
11548
+ if( cSep ){
11549
+ zOut = sqlite3_mprintf("%z%s",zOut,&zCopy[len]);
11550
+ }
11551
+ break;
11552
+ }else{
11553
+ size_t i = len-1;
11554
+ while( i>0 ){
11555
+ if( zCopy[i]=='/' || (isWin && zCopy[i]=='\\') ) break;
11556
+ i--;
11557
+ }
11558
+ if( i<=0 ){
11559
+ if( zCopy[0]=='/' ){
11560
+ zOut = zCopy;
11561
+ zCopy = 0;
11562
+ }else if( (zOut = portable_realpath("."))!=0 ){
11563
+ zOut = sqlite3_mprintf("%z/%s", zOut, zCopy);
11564
+ }
11565
+ break;
11566
+ }
11567
+ cSep = zCopy[i];
11568
+ zCopy[i] = 0;
11569
+ len = i;
11570
+ }
11571
+ }
11572
+ sqlite3_free(zCopy);
11573
+ if( zOut ){
11574
+ /* Simplify any "/./" or "/../" that might have snuck into the
11575
+ ** pathname due to appending of zCopy. We only have to consider
11576
+ ** unix "/" separators, because the _wfilepath() system call on
11577
+ ** Windows will have already done this simplification for us. */
11578
+ size_t i, j, n;
11579
+ n = strlen(zOut);
11580
+ for(i=j=0; i<n; i++){
11581
+ if( zOut[i]=='/' ){
11582
+ if( zOut[i+1]=='/' ) continue;
11583
+ if( zOut[i+1]=='.' && i+2<n && zOut[i+2]=='/' ){
11584
+ i += 1;
11585
+ continue;
11586
+ }
11587
+ if( zOut[i+1]=='.' && i+3<n && zOut[i+2]=='.' && zOut[i+3]=='/' ){
11588
+ while( j>0 && zOut[j-1]!='/' ){ j--; }
11589
+ if( j>0 ){ j--; }
11590
+ i += 2;
11591
+ continue;
11592
+ }
11593
+ }
11594
+ zOut[j++] = zOut[i];
11595
+ }
11596
+ zOut[j] = 0;
11597
+
11598
+ /* Return the result */
11599
+ sqlite3_result_text(context, zOut, -1, sqlite3_free);
11600
+ }
11601
+}
11602
+
1142511603
1142611604
#ifdef _WIN32
1142711605
1142811606
#endif
1142911607
int sqlite3_fileio_init(
@@ -11447,10 +11625,15 @@
1144711625
lsModeFunc, 0, 0);
1144811626
}
1144911627
if( rc==SQLITE_OK ){
1145011628
rc = fsdirRegister(db);
1145111629
}
11630
+ if( rc==SQLITE_OK ){
11631
+ rc = sqlite3_create_function(db, "realpath", 1,
11632
+ SQLITE_UTF8, 0,
11633
+ realpathFunc, 0, 0);
11634
+ }
1145211635
return rc;
1145311636
}
1145411637
1145511638
/************************* End ext/misc/fileio.c ********************/
1145611639
/************************* Begin ext/misc/completion.c ******************/
@@ -29882,15 +30065,19 @@
2988230065
/*
2988330066
** Implementation of .ar "eXtract" command.
2988430067
*/
2988530068
static int arExtractCommand(ArCommand *pAr){
2988630069
const char *zSql1 =
29887
- "SELECT "
29888
- " ($dir || name),"
29889
- " writefile(($dir || name), %s, mode, mtime) "
29890
- "FROM %s WHERE (%s) AND (data IS NULL OR $dirOnly = 0)"
29891
- " AND name NOT GLOB '*..[/\\]*'";
30070
+ "WITH dest(dpath,dlen) AS (SELECT realpath($dir),length(realpath($dir)))\n"
30071
+ "SELECT ($dir || name),\n"
30072
+ " CASE WHEN $dryrun THEN 0\n"
30073
+ " ELSE writefile($dir||name, %s, mode, mtime) END\n"
30074
+ " FROM dest CROSS JOIN %s\n"
30075
+ " WHERE (%s)\n"
30076
+ " AND (data IS NULL OR $pass==0)\n" /* Dirs both passes */
30077
+ " AND dpath=substr(realpath($dir||name),1,dlen)\n" /* No escapes */
30078
+ " AND name NOT GLOB '*..[/\\]*'\n"; /* No /../ in paths */
2989230079
2989330080
const char *azExtraArg[] = {
2989430081
"sqlar_uncompress(data, sz)",
2989530082
"data"
2989630083
};
@@ -29921,28 +30108,32 @@
2992130108
);
2992230109
2992330110
if( rc==SQLITE_OK ){
2992430111
j = sqlite3_bind_parameter_index(pSql, "$dir");
2992530112
sqlite3_bind_text(pSql, j, zDir, -1, SQLITE_STATIC);
30113
+ j = sqlite3_bind_parameter_index(pSql, "$dryrun");
30114
+ sqlite3_bind_int(pSql, j, pAr->bDryRun);
2992630115
29927
- /* Run the SELECT statement twice. The first time, writefile() is called
29928
- ** for all archive members that should be extracted. The second time,
29929
- ** only for the directories. This is because the timestamps for
29930
- ** extracted directories must be reset after they are populated (as
29931
- ** populating them changes the timestamp). */
30116
+ /* Run the SELECT statement twice
30117
+ ** (0) writefile() all files and directories
30118
+ ** (1) writefile() for directory again
30119
+ ** The second pass is so that the timestamps for extracted directories
30120
+ ** will be reset to the value in the archive, since populating them
30121
+ ** in the first pass will have changed the timestamp. */
2993230122
for(i=0; i<2; i++){
29933
- j = sqlite3_bind_parameter_index(pSql, "$dirOnly");
30123
+ j = sqlite3_bind_parameter_index(pSql, "$pass");
2993430124
sqlite3_bind_int(pSql, j, i);
2993530125
if( pAr->bDryRun ){
2993630126
cli_printf(pAr->out, "%s\n", sqlite3_sql(pSql));
29937
- }else{
29938
- while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
29939
- if( i==0 && pAr->bVerbose ){
29940
- cli_printf(pAr->out, "%s\n", sqlite3_column_text(pSql, 0));
29941
- }
30127
+ if( pAr->bVerbose==0 ) break;
30128
+ }
30129
+ while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
30130
+ if( i==0 && pAr->bVerbose ){
30131
+ cli_printf(pAr->out, "%s\n", sqlite3_column_text(pSql, 0));
2994230132
}
2994330133
}
30134
+ if( pAr->bDryRun ) break;
2994430135
shellReset(&rc, pSql);
2994530136
}
2994630137
shellFinalize(&rc, pSql);
2994730138
}
2994830139
@@ -32484,10 +32675,11 @@
3248432675
{ "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
3248532676
{ "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
3248632677
{ "enable_trigger", SQLITE_DBCONFIG_ENABLE_TRIGGER },
3248732678
{ "enable_view", SQLITE_DBCONFIG_ENABLE_VIEW },
3248832679
{ "fts3_tokenizer", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
32680
+ { "fp_digits", SQLITE_DBCONFIG_FP_DIGITS },
3248932681
{ "legacy_alter_table", SQLITE_DBCONFIG_LEGACY_ALTER_TABLE },
3249032682
{ "legacy_file_format", SQLITE_DBCONFIG_LEGACY_FILE_FORMAT },
3249132683
{ "load_extension", SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION },
3249232684
{ "no_ckpt_on_close", SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE },
3249332685
{ "reset_database", SQLITE_DBCONFIG_RESET_DATABASE },
@@ -32500,15 +32692,23 @@
3250032692
int ii, v;
3250132693
open_db(p, 0);
3250232694
for(ii=0; ii<ArraySize(aDbConfig); ii++){
3250332695
if( nArg>1 && cli_strcmp(azArg[1], aDbConfig[ii].zName)!=0 ) continue;
3250432696
if( nArg>=3 ){
32505
- sqlite3_db_config(p->db, aDbConfig[ii].op, booleanValue(azArg[2]), 0);
32697
+ if( aDbConfig[ii].op==SQLITE_DBCONFIG_FP_DIGITS ){
32698
+ sqlite3_db_config(p->db, aDbConfig[ii].op, atoi(azArg[2]), 0);
32699
+ }else{
32700
+ sqlite3_db_config(p->db, aDbConfig[ii].op, booleanValue(azArg[2]), 0);
32701
+ }
3250632702
}
3250732703
sqlite3_db_config(p->db, aDbConfig[ii].op, -1, &v);
32508
- cli_printf(p->out, "%19s %s\n",
32509
- aDbConfig[ii].zName, v ? "on" : "off");
32704
+ if( aDbConfig[ii].op==SQLITE_DBCONFIG_FP_DIGITS ){
32705
+ cli_printf(p->out, "%19s %d\n", aDbConfig[ii].zName, v);
32706
+ }else{
32707
+ cli_printf(p->out, "%19s %s\n",
32708
+ aDbConfig[ii].zName, v ? "on" : "off");
32709
+ }
3251032710
if( nArg>1 ) break;
3251132711
}
3251232712
if( nArg>1 && ii==ArraySize(aDbConfig) ){
3251332713
dotCmdError(p, 1, "unknown dbconfig",
3251432714
"Enter \".dbconfig\" with no arguments for a list");
@@ -36563,11 +36763,11 @@
3656336763
** we retain the goofy behavior for historical compatibility. */
3656436764
if( i==argc-1 ) break;
3656536765
z = cmdline_option_value(argc,argv,++i);
3656636766
if( z[0]=='.' ){
3656736767
rc = do_meta_command(z, &data);
36568
- if( rc && bail_on_error ){
36768
+ if( rc && (bail_on_error || rc==2) ){
3656936769
if( rc==2 ) rc = 0;
3657036770
goto shell_main_exit;
3657136771
}
3657236772
}else{
3657336773
open_db(&data, 0);
3657436774
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -6749,17 +6749,41 @@
6749 }while( j<p->nDigit );
6750 }
6751 z[i] = 0;
6752 sqlite3_result_text(pCtx, z, i, sqlite3_free);
6753 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6754
6755 /*
6756 ** Make the given Decimal the result in an format similar to '%+#e'.
6757 ** In other words, show exponential notation with leading and trailing
6758 ** zeros omitted.
6759 */
6760 static void decimal_result_sci(sqlite3_context *pCtx, Decimal *p){
6761 char *z; /* The output buffer */
6762 int i; /* Loop counter */
6763 int nZero; /* Number of leading zeros */
6764 int nDigit; /* Number of digits not counting trailing zeros */
6765 int nFrac; /* Digits to the right of the decimal point */
@@ -6773,11 +6797,12 @@
6773 }
6774 if( p->isNull ){
6775 sqlite3_result_null(pCtx);
6776 return;
6777 }
6778 for(nDigit=p->nDigit; nDigit>0 && p->a[nDigit-1]==0; nDigit--){}
 
6779 for(nZero=0; nZero<nDigit && p->a[nZero]==0; nZero++){}
6780 nFrac = p->nFrac + (nDigit - p->nDigit);
6781 nDigit -= nZero;
6782 z = sqlite3_malloc64( (sqlite3_int64)nDigit+20 );
6783 if( z==0 ){
@@ -7136,14 +7161,20 @@
7136 sqlite3_context *context,
7137 int argc,
7138 sqlite3_value **argv
7139 ){
7140 Decimal *p = decimal_new(context, argv[0], 0);
7141 UNUSED_PARAMETER(argc);
 
 
 
 
 
 
7142 if( p ){
7143 if( sqlite3_user_data(context)!=0 ){
7144 decimal_result_sci(context, p);
7145 }else{
7146 decimal_result(context, p);
7147 }
7148 decimal_free(p);
7149 }
@@ -7309,11 +7340,11 @@
7309 sqlite3_value **argv
7310 ){
7311 UNUSED_PARAMETER(argc);
7312 if( sqlite3_value_type(argv[0])==SQLITE_INTEGER ){
7313 Decimal *pA = decimalPow2(sqlite3_value_int(argv[0]));
7314 decimal_result_sci(context, pA);
7315 decimal_free(pA);
7316 }
7317 }
7318
7319 #ifdef _WIN32
@@ -7330,11 +7361,13 @@
7330 int nArg;
7331 int iArg;
7332 void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
7333 } aFunc[] = {
7334 { "decimal", 1, 0, decimalFunc },
 
7335 { "decimal_exp", 1, 1, decimalFunc },
 
7336 { "decimal_cmp", 2, 0, decimalCmpFunc },
7337 { "decimal_add", 2, 0, decimalAddFunc },
7338 { "decimal_sub", 2, 0, decimalSubFunc },
7339 { "decimal_mul", 2, 0, decimalMulFunc },
7340 { "decimal_pow2", 1, 0, decimalPow2Func },
@@ -8384,10 +8417,42 @@
8384 v >>= 8;
8385 }
8386 sqlite3_result_blob(context, a, sizeof(r), SQLITE_TRANSIENT);
8387 }
8388 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8389
8390 /*
8391 ** SQL Function: ieee754_inc(r,N)
8392 **
8393 ** Move the floating point value r by N quantums and return the new
@@ -8437,10 +8502,12 @@
8437 { "ieee754", 2, 0, ieee754func },
8438 { "ieee754_mantissa", 1, 1, ieee754func },
8439 { "ieee754_exponent", 1, 2, ieee754func },
8440 { "ieee754_to_blob", 1, 0, ieee754func_to_blob },
8441 { "ieee754_from_blob", 1, 0, ieee754func_from_blob },
 
 
8442 { "ieee754_inc", 2, 0, ieee754inc },
8443 };
8444 unsigned int i;
8445 int rc = SQLITE_OK;
8446 SQLITE_EXTENSION_INIT2(pApi);
@@ -10422,16 +10489,20 @@
10422 # include <unistd.h>
10423 # include <dirent.h>
10424 # include <utime.h>
10425 # include <sys/time.h>
10426 # define STRUCT_STAT struct stat
 
 
10427 #else
10428 /* # include "windirent.h" */
10429 # include <direct.h>
10430 # define STRUCT_STAT struct _stat
10431 # define chmod(path,mode) fileio_chmod(path,mode)
10432 # define mkdir(path,mode) fileio_mkdir(path)
 
 
10433 #endif
10434 #include <time.h>
10435 #include <errno.h>
10436
10437 /* When used as part of the CLI, the sqlite3_stdio.h module will have
@@ -10459,16 +10530,13 @@
10459 /*
10460 ** UTF8 chmod() function for Windows
10461 */
10462 #if defined(_WIN32) || defined(WIN32)
10463 static int fileio_chmod(const char *zPath, int pmode){
10464 sqlite3_int64 sz = strlen(zPath);
10465 wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
10466 int rc;
 
10467 if( b1==0 ) return -1;
10468 sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
10469 b1[sz] = 0;
10470 rc = _wchmod(b1, pmode);
10471 sqlite3_free(b1);
10472 return rc;
10473 }
10474 #endif
@@ -10476,16 +10544,13 @@
10476 /*
10477 ** UTF8 mkdir() function for Windows
10478 */
10479 #if defined(_WIN32) || defined(WIN32)
10480 static int fileio_mkdir(const char *zPath){
10481 sqlite3_int64 sz = strlen(zPath);
10482 wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
10483 int rc;
 
10484 if( b1==0 ) return -1;
10485 sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
10486 b1[sz] = 0;
10487 rc = _wmkdir(b1);
10488 sqlite3_free(b1);
10489 return rc;
10490 }
10491 #endif
@@ -10594,54 +10659,11 @@
10594 fileIntervals.LowPart = pFileTime->dwLowDateTime;
10595 fileIntervals.HighPart = pFileTime->dwHighDateTime;
10596
10597 return (fileIntervals.QuadPart - epochIntervals.QuadPart) / 10000000;
10598 }
10599
10600
10601 #if defined(FILEIO_WIN32_DLL) && (defined(_WIN32) || defined(WIN32))
10602 # /* To allow a standalone DLL, use this next replacement function: */
10603 # undef sqlite3_win32_utf8_to_unicode
10604 # define sqlite3_win32_utf8_to_unicode utf8_to_utf16
10605 #
10606 LPWSTR utf8_to_utf16(const char *z){
10607 int nAllot = MultiByteToWideChar(CP_UTF8, 0, z, -1, NULL, 0);
10608 LPWSTR rv = sqlite3_malloc(nAllot * sizeof(WCHAR));
10609 if( rv!=0 && 0 < MultiByteToWideChar(CP_UTF8, 0, z, -1, rv, nAllot) )
10610 return rv;
10611 sqlite3_free(rv);
10612 return 0;
10613 }
10614 #endif
10615
10616 /*
10617 ** This function attempts to normalize the time values found in the stat()
10618 ** buffer to UTC. This is necessary on Win32, where the runtime library
10619 ** appears to return these values as local times.
10620 */
10621 static void statTimesToUtc(
10622 const char *zPath,
10623 STRUCT_STAT *pStatBuf
10624 ){
10625 HANDLE hFindFile;
10626 WIN32_FIND_DATAW fd;
10627 LPWSTR zUnicodeName;
10628 extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
10629 zUnicodeName = sqlite3_win32_utf8_to_unicode(zPath);
10630 if( zUnicodeName ){
10631 memset(&fd, 0, sizeof(WIN32_FIND_DATAW));
10632 hFindFile = FindFirstFileW(zUnicodeName, &fd);
10633 if( hFindFile!=NULL ){
10634 pStatBuf->st_ctime = (time_t)fileTimeToUnixTime(&fd.ftCreationTime);
10635 pStatBuf->st_atime = (time_t)fileTimeToUnixTime(&fd.ftLastAccessTime);
10636 pStatBuf->st_mtime = (time_t)fileTimeToUnixTime(&fd.ftLastWriteTime);
10637 FindClose(hFindFile);
10638 }
10639 sqlite3_free(zUnicodeName);
10640 }
10641 }
10642 #endif
10643
10644 /*
10645 ** This function is used in place of stat(). On Windows, special handling
10646 ** is required in order for the included time to be returned as UTC. On all
10647 ** other systems, this function simply calls stat().
@@ -10649,18 +10671,26 @@
10649 static int fileStat(
10650 const char *zPath,
10651 STRUCT_STAT *pStatBuf
10652 ){
10653 #if defined(_WIN32)
10654 sqlite3_int64 sz = strlen(zPath);
10655 wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
10656 int rc;
 
10657 if( b1==0 ) return 1;
10658 sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
10659 b1[sz] = 0;
10660 rc = _wstat(b1, pStatBuf);
10661 if( rc==0 ) statTimesToUtc(zPath, pStatBuf);
 
 
 
 
 
 
 
 
 
 
 
10662 sqlite3_free(b1);
10663 return rc;
10664 #else
10665 return stat(zPath, pStatBuf);
10666 #endif
@@ -11420,10 +11450,158 @@
11420 return rc;
11421 }
11422 #else /* SQLITE_OMIT_VIRTUALTABLE */
11423 # define fsdirRegister(x) SQLITE_OK
11424 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11425
11426 #ifdef _WIN32
11427
11428 #endif
11429 int sqlite3_fileio_init(
@@ -11447,10 +11625,15 @@
11447 lsModeFunc, 0, 0);
11448 }
11449 if( rc==SQLITE_OK ){
11450 rc = fsdirRegister(db);
11451 }
 
 
 
 
 
11452 return rc;
11453 }
11454
11455 /************************* End ext/misc/fileio.c ********************/
11456 /************************* Begin ext/misc/completion.c ******************/
@@ -29882,15 +30065,19 @@
29882 /*
29883 ** Implementation of .ar "eXtract" command.
29884 */
29885 static int arExtractCommand(ArCommand *pAr){
29886 const char *zSql1 =
29887 "SELECT "
29888 " ($dir || name),"
29889 " writefile(($dir || name), %s, mode, mtime) "
29890 "FROM %s WHERE (%s) AND (data IS NULL OR $dirOnly = 0)"
29891 " AND name NOT GLOB '*..[/\\]*'";
 
 
 
 
29892
29893 const char *azExtraArg[] = {
29894 "sqlar_uncompress(data, sz)",
29895 "data"
29896 };
@@ -29921,28 +30108,32 @@
29921 );
29922
29923 if( rc==SQLITE_OK ){
29924 j = sqlite3_bind_parameter_index(pSql, "$dir");
29925 sqlite3_bind_text(pSql, j, zDir, -1, SQLITE_STATIC);
 
 
29926
29927 /* Run the SELECT statement twice. The first time, writefile() is called
29928 ** for all archive members that should be extracted. The second time,
29929 ** only for the directories. This is because the timestamps for
29930 ** extracted directories must be reset after they are populated (as
29931 ** populating them changes the timestamp). */
 
29932 for(i=0; i<2; i++){
29933 j = sqlite3_bind_parameter_index(pSql, "$dirOnly");
29934 sqlite3_bind_int(pSql, j, i);
29935 if( pAr->bDryRun ){
29936 cli_printf(pAr->out, "%s\n", sqlite3_sql(pSql));
29937 }else{
29938 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
29939 if( i==0 && pAr->bVerbose ){
29940 cli_printf(pAr->out, "%s\n", sqlite3_column_text(pSql, 0));
29941 }
29942 }
29943 }
 
29944 shellReset(&rc, pSql);
29945 }
29946 shellFinalize(&rc, pSql);
29947 }
29948
@@ -32484,10 +32675,11 @@
32484 { "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
32485 { "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
32486 { "enable_trigger", SQLITE_DBCONFIG_ENABLE_TRIGGER },
32487 { "enable_view", SQLITE_DBCONFIG_ENABLE_VIEW },
32488 { "fts3_tokenizer", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
 
32489 { "legacy_alter_table", SQLITE_DBCONFIG_LEGACY_ALTER_TABLE },
32490 { "legacy_file_format", SQLITE_DBCONFIG_LEGACY_FILE_FORMAT },
32491 { "load_extension", SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION },
32492 { "no_ckpt_on_close", SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE },
32493 { "reset_database", SQLITE_DBCONFIG_RESET_DATABASE },
@@ -32500,15 +32692,23 @@
32500 int ii, v;
32501 open_db(p, 0);
32502 for(ii=0; ii<ArraySize(aDbConfig); ii++){
32503 if( nArg>1 && cli_strcmp(azArg[1], aDbConfig[ii].zName)!=0 ) continue;
32504 if( nArg>=3 ){
32505 sqlite3_db_config(p->db, aDbConfig[ii].op, booleanValue(azArg[2]), 0);
 
 
 
 
32506 }
32507 sqlite3_db_config(p->db, aDbConfig[ii].op, -1, &v);
32508 cli_printf(p->out, "%19s %s\n",
32509 aDbConfig[ii].zName, v ? "on" : "off");
 
 
 
 
32510 if( nArg>1 ) break;
32511 }
32512 if( nArg>1 && ii==ArraySize(aDbConfig) ){
32513 dotCmdError(p, 1, "unknown dbconfig",
32514 "Enter \".dbconfig\" with no arguments for a list");
@@ -36563,11 +36763,11 @@
36563 ** we retain the goofy behavior for historical compatibility. */
36564 if( i==argc-1 ) break;
36565 z = cmdline_option_value(argc,argv,++i);
36566 if( z[0]=='.' ){
36567 rc = do_meta_command(z, &data);
36568 if( rc && bail_on_error ){
36569 if( rc==2 ) rc = 0;
36570 goto shell_main_exit;
36571 }
36572 }else{
36573 open_db(&data, 0);
36574
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -6749,17 +6749,41 @@
6749 }while( j<p->nDigit );
6750 }
6751 z[i] = 0;
6752 sqlite3_result_text(pCtx, z, i, sqlite3_free);
6753 }
6754
6755 /*
6756 ** Round a decimal value to N significant digits. N must be positive.
6757 */
6758 static void decimal_round(Decimal *p, int N){
6759 int i;
6760 int nZero;
6761 if( N<1 ) return;
6762 for(nZero=0; nZero<p->nDigit && p->a[nZero]==0; nZero++){}
6763 N += nZero;
6764 if( p->nDigit<=N ) return;
6765 if( p->a[N]>4 ){
6766 p->a[N-1]++;
6767 for(i=N-1; i>0 && p->a[i]>9; i--){
6768 p->a[i] = 0;
6769 p->a[i-1]++;
6770 }
6771 if( p->a[0]>9 ){
6772 p->a[0] = 1;
6773 p->nFrac--;
6774 }
6775 }
6776 memset(&p->a[N], 0, p->nDigit - N);
6777 }
6778
6779 /*
6780 ** Make the given Decimal the result in an format similar to '%+#e'.
6781 ** In other words, show exponential notation with leading and trailing
6782 ** zeros omitted.
6783 */
6784 static void decimal_result_sci(sqlite3_context *pCtx, Decimal *p, int N){
6785 char *z; /* The output buffer */
6786 int i; /* Loop counter */
6787 int nZero; /* Number of leading zeros */
6788 int nDigit; /* Number of digits not counting trailing zeros */
6789 int nFrac; /* Digits to the right of the decimal point */
@@ -6773,11 +6797,12 @@
6797 }
6798 if( p->isNull ){
6799 sqlite3_result_null(pCtx);
6800 return;
6801 }
6802 if( N<1 ) N = 0;
6803 for(nDigit=p->nDigit; nDigit>N && p->a[nDigit-1]==0; nDigit--){}
6804 for(nZero=0; nZero<nDigit && p->a[nZero]==0; nZero++){}
6805 nFrac = p->nFrac + (nDigit - p->nDigit);
6806 nDigit -= nZero;
6807 z = sqlite3_malloc64( (sqlite3_int64)nDigit+20 );
6808 if( z==0 ){
@@ -7136,14 +7161,20 @@
7161 sqlite3_context *context,
7162 int argc,
7163 sqlite3_value **argv
7164 ){
7165 Decimal *p = decimal_new(context, argv[0], 0);
7166 int N;
7167 if( argc==2 ){
7168 N = sqlite3_value_int(argv[1]);
7169 if( N>0 ) decimal_round(p, N);
7170 }else{
7171 N = 0;
7172 }
7173 if( p ){
7174 if( sqlite3_user_data(context)!=0 ){
7175 decimal_result_sci(context, p, N);
7176 }else{
7177 decimal_result(context, p);
7178 }
7179 decimal_free(p);
7180 }
@@ -7309,11 +7340,11 @@
7340 sqlite3_value **argv
7341 ){
7342 UNUSED_PARAMETER(argc);
7343 if( sqlite3_value_type(argv[0])==SQLITE_INTEGER ){
7344 Decimal *pA = decimalPow2(sqlite3_value_int(argv[0]));
7345 decimal_result_sci(context, pA, 0);
7346 decimal_free(pA);
7347 }
7348 }
7349
7350 #ifdef _WIN32
@@ -7330,11 +7361,13 @@
7361 int nArg;
7362 int iArg;
7363 void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
7364 } aFunc[] = {
7365 { "decimal", 1, 0, decimalFunc },
7366 { "decimal", 2, 0, decimalFunc },
7367 { "decimal_exp", 1, 1, decimalFunc },
7368 { "decimal_exp", 2, 1, decimalFunc },
7369 { "decimal_cmp", 2, 0, decimalCmpFunc },
7370 { "decimal_add", 2, 0, decimalAddFunc },
7371 { "decimal_sub", 2, 0, decimalSubFunc },
7372 { "decimal_mul", 2, 0, decimalMulFunc },
7373 { "decimal_pow2", 1, 0, decimalPow2Func },
@@ -8384,10 +8417,42 @@
8417 v >>= 8;
8418 }
8419 sqlite3_result_blob(context, a, sizeof(r), SQLITE_TRANSIENT);
8420 }
8421 }
8422
8423 /*
8424 ** Functions to convert between 64-bit integers and floats.
8425 **
8426 ** The bit patterns are copied. The numeric values are different.
8427 */
8428 static void ieee754func_from_int(
8429 sqlite3_context *context,
8430 int argc,
8431 sqlite3_value **argv
8432 ){
8433 UNUSED_PARAMETER(argc);
8434 if( sqlite3_value_type(argv[0])==SQLITE_INTEGER ){
8435 double r;
8436 sqlite3_int64 v = sqlite3_value_int64(argv[0]);
8437 memcpy(&r, &v, sizeof(r));
8438 sqlite3_result_double(context, r);
8439 }
8440 }
8441 static void ieee754func_to_int(
8442 sqlite3_context *context,
8443 int argc,
8444 sqlite3_value **argv
8445 ){
8446 UNUSED_PARAMETER(argc);
8447 if( sqlite3_value_type(argv[0])==SQLITE_FLOAT ){
8448 double r = sqlite3_value_double(argv[0]);
8449 sqlite3_uint64 v;
8450 memcpy(&v, &r, sizeof(v));
8451 sqlite3_result_int64(context, v);
8452 }
8453 }
8454
8455 /*
8456 ** SQL Function: ieee754_inc(r,N)
8457 **
8458 ** Move the floating point value r by N quantums and return the new
@@ -8437,10 +8502,12 @@
8502 { "ieee754", 2, 0, ieee754func },
8503 { "ieee754_mantissa", 1, 1, ieee754func },
8504 { "ieee754_exponent", 1, 2, ieee754func },
8505 { "ieee754_to_blob", 1, 0, ieee754func_to_blob },
8506 { "ieee754_from_blob", 1, 0, ieee754func_from_blob },
8507 { "ieee754_to_int", 1, 0, ieee754func_to_int },
8508 { "ieee754_from_int", 1, 0, ieee754func_from_int },
8509 { "ieee754_inc", 2, 0, ieee754inc },
8510 };
8511 unsigned int i;
8512 int rc = SQLITE_OK;
8513 SQLITE_EXTENSION_INIT2(pApi);
@@ -10422,16 +10489,20 @@
10489 # include <unistd.h>
10490 # include <dirent.h>
10491 # include <utime.h>
10492 # include <sys/time.h>
10493 # define STRUCT_STAT struct stat
10494 # include <limits.h>
10495 # include <stdlib.h>
10496 #else
10497 /* # include "windirent.h" */
10498 # include <direct.h>
10499 # define STRUCT_STAT struct _stat
10500 # define chmod(path,mode) fileio_chmod(path,mode)
10501 # define mkdir(path,mode) fileio_mkdir(path)
10502 extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
10503 extern char *sqlite3_win32_unicode_to_utf8(LPCWSTR);
10504 #endif
10505 #include <time.h>
10506 #include <errno.h>
10507
10508 /* When used as part of the CLI, the sqlite3_stdio.h module will have
@@ -10459,16 +10530,13 @@
10530 /*
10531 ** UTF8 chmod() function for Windows
10532 */
10533 #if defined(_WIN32) || defined(WIN32)
10534 static int fileio_chmod(const char *zPath, int pmode){
 
 
10535 int rc;
10536 wchar_t *b1 = sqlite3_win32_utf8_to_unicode(zPath);
10537 if( b1==0 ) return -1;
 
 
10538 rc = _wchmod(b1, pmode);
10539 sqlite3_free(b1);
10540 return rc;
10541 }
10542 #endif
@@ -10476,16 +10544,13 @@
10544 /*
10545 ** UTF8 mkdir() function for Windows
10546 */
10547 #if defined(_WIN32) || defined(WIN32)
10548 static int fileio_mkdir(const char *zPath){
 
 
10549 int rc;
10550 wchar_t *b1 = sqlite3_win32_utf8_to_unicode(zPath);
10551 if( b1==0 ) return -1;
 
 
10552 rc = _wmkdir(b1);
10553 sqlite3_free(b1);
10554 return rc;
10555 }
10556 #endif
@@ -10594,54 +10659,11 @@
10659 fileIntervals.LowPart = pFileTime->dwLowDateTime;
10660 fileIntervals.HighPart = pFileTime->dwHighDateTime;
10661
10662 return (fileIntervals.QuadPart - epochIntervals.QuadPart) / 10000000;
10663 }
10664 #endif /* _WIN32 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10665
10666 /*
10667 ** This function is used in place of stat(). On Windows, special handling
10668 ** is required in order for the included time to be returned as UTC. On all
10669 ** other systems, this function simply calls stat().
@@ -10649,18 +10671,26 @@
10671 static int fileStat(
10672 const char *zPath,
10673 STRUCT_STAT *pStatBuf
10674 ){
10675 #if defined(_WIN32)
 
 
10676 int rc;
10677 wchar_t *b1 = sqlite3_win32_utf8_to_unicode(zPath);
10678 if( b1==0 ) return 1;
 
 
10679 rc = _wstat(b1, pStatBuf);
10680 if( rc==0 ){
10681 HANDLE hFindFile;
10682 WIN32_FIND_DATAW fd;
10683 memset(&fd, 0, sizeof(WIN32_FIND_DATAW));
10684 hFindFile = FindFirstFileW(b1, &fd);
10685 if( hFindFile!=NULL ){
10686 pStatBuf->st_ctime = (time_t)fileTimeToUnixTime(&fd.ftCreationTime);
10687 pStatBuf->st_atime = (time_t)fileTimeToUnixTime(&fd.ftLastAccessTime);
10688 pStatBuf->st_mtime = (time_t)fileTimeToUnixTime(&fd.ftLastWriteTime);
10689 FindClose(hFindFile);
10690 }
10691 }
10692 sqlite3_free(b1);
10693 return rc;
10694 #else
10695 return stat(zPath, pStatBuf);
10696 #endif
@@ -11420,10 +11450,158 @@
11450 return rc;
11451 }
11452 #else /* SQLITE_OMIT_VIRTUALTABLE */
11453 # define fsdirRegister(x) SQLITE_OK
11454 #endif
11455
11456 /*
11457 ** This version of realpath() works on any system. The string
11458 ** returned is held in memory allocated using sqlite3_malloc64().
11459 ** The caller is responsible for calling sqlite3_free().
11460 */
11461 static char *portable_realpath(const char *zPath){
11462 #if !defined(_WIN32) /* BEGIN unix */
11463
11464 char *zOut = 0; /* Result */
11465 char *z; /* Temporary buffer */
11466 #if defined(PATH_MAX)
11467 char zBuf[PATH_MAX+1]; /* Space for the temporary buffer */
11468 #endif
11469
11470 if( zPath==0 ) return 0;
11471 #if defined(PATH_MAX)
11472 z = realpath(zPath, zBuf);
11473 if( z ){
11474 zOut = sqlite3_mprintf("%s", zBuf);
11475 }
11476 #endif /* defined(PATH_MAX) */
11477 if( zOut==0 ){
11478 /* Try POSIX.1-2008 malloc behavior */
11479 z = realpath(zPath, NULL);
11480 if( z ){
11481 zOut = sqlite3_mprintf("%s", z);
11482 free(z);
11483 }
11484 }
11485 return zOut;
11486
11487 #else /* End UNIX, Begin WINDOWS */
11488
11489 wchar_t *zPath16; /* UTF16 translation of zPath */
11490 char *zOut = 0; /* Result */
11491 wchar_t *z = 0; /* Temporary buffer */
11492
11493 if( zPath==0 ) return 0;
11494
11495 zPath16 = sqlite3_win32_utf8_to_unicode(zPath);
11496 if( zPath16==0 ) return 0;
11497 z = _wfullpath(NULL, zPath16, 0);
11498 sqlite3_free(zPath16);
11499 if( z ){
11500 zOut = sqlite3_win32_unicode_to_utf8(z);
11501 free(z);
11502 }
11503 return zOut;
11504
11505 #endif /* End WINDOWS, Begin common code */
11506 }
11507
11508 /*
11509 ** SQL function: realpath(X)
11510 **
11511 ** Try to convert file or pathname X into its real, absolute pathname.
11512 ** Return NULL if unable.
11513 **
11514 ** The file or directory X is not required to exist. The answer is formed
11515 ** by calling system realpath() on the prefix of X that does exist and
11516 ** appending the tail of X that does not (yet) exist.
11517 */
11518 static void realpathFunc(
11519 sqlite3_context *context,
11520 int argc,
11521 sqlite3_value **argv
11522 ){
11523 const char *zPath; /* Original input path */
11524 char *zCopy; /* An editable copy of zPath */
11525 char *zOut; /* The result */
11526 char cSep = 0; /* Separator turned into \000 */
11527 size_t len; /* Prefix length before cSep */
11528 #ifdef _WIN32
11529 const int isWin = 1;
11530 #else
11531 const int isWin = 0;
11532 #endif
11533
11534 (void)argc;
11535 zPath = (const char*)sqlite3_value_text(argv[0]);
11536 if( zPath==0 ) return;
11537 if( zPath[0]==0 ) zPath = ".";
11538 zCopy = sqlite3_mprintf("%s",zPath);
11539 len = strlen(zCopy);
11540 while( len>1 && (zCopy[len-1]=='/' || (isWin && zCopy[len-1]=='\\')) ){
11541 len--;
11542 }
11543 zCopy[len] = 0;
11544 while( 1 /*exit-by-break*/ ){
11545 zOut = portable_realpath(zCopy);
11546 zCopy[len] = cSep;
11547 if( zOut ){
11548 if( cSep ){
11549 zOut = sqlite3_mprintf("%z%s",zOut,&zCopy[len]);
11550 }
11551 break;
11552 }else{
11553 size_t i = len-1;
11554 while( i>0 ){
11555 if( zCopy[i]=='/' || (isWin && zCopy[i]=='\\') ) break;
11556 i--;
11557 }
11558 if( i<=0 ){
11559 if( zCopy[0]=='/' ){
11560 zOut = zCopy;
11561 zCopy = 0;
11562 }else if( (zOut = portable_realpath("."))!=0 ){
11563 zOut = sqlite3_mprintf("%z/%s", zOut, zCopy);
11564 }
11565 break;
11566 }
11567 cSep = zCopy[i];
11568 zCopy[i] = 0;
11569 len = i;
11570 }
11571 }
11572 sqlite3_free(zCopy);
11573 if( zOut ){
11574 /* Simplify any "/./" or "/../" that might have snuck into the
11575 ** pathname due to appending of zCopy. We only have to consider
11576 ** unix "/" separators, because the _wfilepath() system call on
11577 ** Windows will have already done this simplification for us. */
11578 size_t i, j, n;
11579 n = strlen(zOut);
11580 for(i=j=0; i<n; i++){
11581 if( zOut[i]=='/' ){
11582 if( zOut[i+1]=='/' ) continue;
11583 if( zOut[i+1]=='.' && i+2<n && zOut[i+2]=='/' ){
11584 i += 1;
11585 continue;
11586 }
11587 if( zOut[i+1]=='.' && i+3<n && zOut[i+2]=='.' && zOut[i+3]=='/' ){
11588 while( j>0 && zOut[j-1]!='/' ){ j--; }
11589 if( j>0 ){ j--; }
11590 i += 2;
11591 continue;
11592 }
11593 }
11594 zOut[j++] = zOut[i];
11595 }
11596 zOut[j] = 0;
11597
11598 /* Return the result */
11599 sqlite3_result_text(context, zOut, -1, sqlite3_free);
11600 }
11601 }
11602
11603
11604 #ifdef _WIN32
11605
11606 #endif
11607 int sqlite3_fileio_init(
@@ -11447,10 +11625,15 @@
11625 lsModeFunc, 0, 0);
11626 }
11627 if( rc==SQLITE_OK ){
11628 rc = fsdirRegister(db);
11629 }
11630 if( rc==SQLITE_OK ){
11631 rc = sqlite3_create_function(db, "realpath", 1,
11632 SQLITE_UTF8, 0,
11633 realpathFunc, 0, 0);
11634 }
11635 return rc;
11636 }
11637
11638 /************************* End ext/misc/fileio.c ********************/
11639 /************************* Begin ext/misc/completion.c ******************/
@@ -29882,15 +30065,19 @@
30065 /*
30066 ** Implementation of .ar "eXtract" command.
30067 */
30068 static int arExtractCommand(ArCommand *pAr){
30069 const char *zSql1 =
30070 "WITH dest(dpath,dlen) AS (SELECT realpath($dir),length(realpath($dir)))\n"
30071 "SELECT ($dir || name),\n"
30072 " CASE WHEN $dryrun THEN 0\n"
30073 " ELSE writefile($dir||name, %s, mode, mtime) END\n"
30074 " FROM dest CROSS JOIN %s\n"
30075 " WHERE (%s)\n"
30076 " AND (data IS NULL OR $pass==0)\n" /* Dirs both passes */
30077 " AND dpath=substr(realpath($dir||name),1,dlen)\n" /* No escapes */
30078 " AND name NOT GLOB '*..[/\\]*'\n"; /* No /../ in paths */
30079
30080 const char *azExtraArg[] = {
30081 "sqlar_uncompress(data, sz)",
30082 "data"
30083 };
@@ -29921,28 +30108,32 @@
30108 );
30109
30110 if( rc==SQLITE_OK ){
30111 j = sqlite3_bind_parameter_index(pSql, "$dir");
30112 sqlite3_bind_text(pSql, j, zDir, -1, SQLITE_STATIC);
30113 j = sqlite3_bind_parameter_index(pSql, "$dryrun");
30114 sqlite3_bind_int(pSql, j, pAr->bDryRun);
30115
30116 /* Run the SELECT statement twice
30117 ** (0) writefile() all files and directories
30118 ** (1) writefile() for directory again
30119 ** The second pass is so that the timestamps for extracted directories
30120 ** will be reset to the value in the archive, since populating them
30121 ** in the first pass will have changed the timestamp. */
30122 for(i=0; i<2; i++){
30123 j = sqlite3_bind_parameter_index(pSql, "$pass");
30124 sqlite3_bind_int(pSql, j, i);
30125 if( pAr->bDryRun ){
30126 cli_printf(pAr->out, "%s\n", sqlite3_sql(pSql));
30127 if( pAr->bVerbose==0 ) break;
30128 }
30129 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
30130 if( i==0 && pAr->bVerbose ){
30131 cli_printf(pAr->out, "%s\n", sqlite3_column_text(pSql, 0));
30132 }
30133 }
30134 if( pAr->bDryRun ) break;
30135 shellReset(&rc, pSql);
30136 }
30137 shellFinalize(&rc, pSql);
30138 }
30139
@@ -32484,10 +32675,11 @@
32675 { "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
32676 { "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
32677 { "enable_trigger", SQLITE_DBCONFIG_ENABLE_TRIGGER },
32678 { "enable_view", SQLITE_DBCONFIG_ENABLE_VIEW },
32679 { "fts3_tokenizer", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
32680 { "fp_digits", SQLITE_DBCONFIG_FP_DIGITS },
32681 { "legacy_alter_table", SQLITE_DBCONFIG_LEGACY_ALTER_TABLE },
32682 { "legacy_file_format", SQLITE_DBCONFIG_LEGACY_FILE_FORMAT },
32683 { "load_extension", SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION },
32684 { "no_ckpt_on_close", SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE },
32685 { "reset_database", SQLITE_DBCONFIG_RESET_DATABASE },
@@ -32500,15 +32692,23 @@
32692 int ii, v;
32693 open_db(p, 0);
32694 for(ii=0; ii<ArraySize(aDbConfig); ii++){
32695 if( nArg>1 && cli_strcmp(azArg[1], aDbConfig[ii].zName)!=0 ) continue;
32696 if( nArg>=3 ){
32697 if( aDbConfig[ii].op==SQLITE_DBCONFIG_FP_DIGITS ){
32698 sqlite3_db_config(p->db, aDbConfig[ii].op, atoi(azArg[2]), 0);
32699 }else{
32700 sqlite3_db_config(p->db, aDbConfig[ii].op, booleanValue(azArg[2]), 0);
32701 }
32702 }
32703 sqlite3_db_config(p->db, aDbConfig[ii].op, -1, &v);
32704 if( aDbConfig[ii].op==SQLITE_DBCONFIG_FP_DIGITS ){
32705 cli_printf(p->out, "%19s %d\n", aDbConfig[ii].zName, v);
32706 }else{
32707 cli_printf(p->out, "%19s %s\n",
32708 aDbConfig[ii].zName, v ? "on" : "off");
32709 }
32710 if( nArg>1 ) break;
32711 }
32712 if( nArg>1 && ii==ArraySize(aDbConfig) ){
32713 dotCmdError(p, 1, "unknown dbconfig",
32714 "Enter \".dbconfig\" with no arguments for a list");
@@ -36563,11 +36763,11 @@
36763 ** we retain the goofy behavior for historical compatibility. */
36764 if( i==argc-1 ) break;
36765 z = cmdline_option_value(argc,argv,++i);
36766 if( z[0]=='.' ){
36767 rc = do_meta_command(z, &data);
36768 if( rc && (bail_on_error || rc==2) ){
36769 if( rc==2 ) rc = 0;
36770 goto shell_main_exit;
36771 }
36772 }else{
36773 open_db(&data, 0);
36774
+131 -49
--- 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
-** e540f6c370675ae043af8cdbb80f7eb17c08 with changes in files:
21
+** 3ca1ed81c4fa41f5f9fdbebf0929dd8421a4 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.52.0"
471471
#define SQLITE_VERSION_NUMBER 3052000
472
-#define SQLITE_SOURCE_ID "2026-02-19 12:59:42 e540f6c370675ae043af8cdbb80f7eb17c08e50f7634e0b78f0b1dccf7bd4b18"
472
+#define SQLITE_SOURCE_ID "2026-02-23 19:51:54 3ca1ed81c4fa41f5f9fdbebf0929dd8421a4e29f95764fe1027d4d8706a41480"
473473
#define SQLITE_SCM_BRANCH "trunk"
474474
#define SQLITE_SCM_TAGS ""
475
-#define SQLITE_SCM_DATETIME "2026-02-19T12:59:42.005Z"
475
+#define SQLITE_SCM_DATETIME "2026-02-23T19:51:54.706Z"
476476
477477
/*
478478
** CAPI3REF: Run-Time Library Version Numbers
479479
** KEYWORDS: sqlite3_version sqlite3_sourceid
480480
**
@@ -2967,10 +2967,26 @@
29672967
** respectively. If the second argument is not NULL, then 0 or 1 is written
29682968
** into the integer that the second argument points to depending on if
29692969
** comments are allowed in SQL text after processing the first argument.
29702970
** </dd>
29712971
**
2972
+** [[SQLITE_DBCONFIG_FP_DIGITS]]
2973
+** <dt>SQLITE_DBCONFIG_FP_DIGITS</dt>
2974
+** <dd>The SQLITE_DBCONFIG_FP_DIGITS setting is a small integer that determines
2975
+** the number of significant digits that SQLite will attempt to preserve when
2976
+** converting floating point numbers (IEEE 754 "doubles") into text. The
2977
+** default value 17, as of SQLite version 3.52.0. The value was 15 in all
2978
+** prior versions.<p>
2979
+** This option takes two arguments which are an integer and a pointer
2980
+** to an integer. The first argument is a small integer, between 3 and 23, or
2981
+** zero. The FP_DIGITS setting is changed to that small integer, or left
2982
+** altered if the first argument is zero or out of range. The second argument
2983
+** is a pointer to an integer. If the pointer is not NULL, then the value of
2984
+** the FP_DIGITS setting, after possibly being modified by the first
2985
+** arguments, is written into the integer to which the second argument points.
2986
+** </dd>
2987
+**
29722988
** </dl>
29732989
**
29742990
** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
29752991
**
29762992
** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
@@ -2984,13 +3000,14 @@
29843000
** the integer to which the second argument points, depending on whether the
29853001
** setting is disabled or enabled after applying any changes specified by
29863002
** the first argument.
29873003
**
29883004
** <p>While most SQLITE_DBCONFIG options use the argument format
2989
-** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME]
2990
-** and [SQLITE_DBCONFIG_LOOKASIDE] options are different. See the
2991
-** documentation of those exceptional options for details.
3005
+** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME],
3006
+** [SQLITE_DBCONFIG_LOOKASIDE], and [SQLITE_DBCONFIG_FP_DIGITS] options
3007
+** are different. See the documentation of those exceptional options for
3008
+** details.
29923009
*/
29933010
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
29943011
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
29953012
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
29963013
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
@@ -3011,11 +3028,12 @@
30113028
#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
30123029
#define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
30133030
#define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */
30143031
#define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */
30153032
#define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */
3016
-#define SQLITE_DBCONFIG_MAX 1022 /* Largest DBCONFIG */
3033
+#define SQLITE_DBCONFIG_FP_DIGITS 1023 /* int int* */
3034
+#define SQLITE_DBCONFIG_MAX 1023 /* Largest DBCONFIG */
30173035
30183036
/*
30193037
** CAPI3REF: Enable Or Disable Extended Result Codes
30203038
** METHOD: sqlite3
30213039
**
@@ -18428,10 +18446,11 @@
1842818446
u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
1842918447
u8 mTrace; /* zero or more SQLITE_TRACE flags */
1843018448
u8 noSharedCache; /* True if no shared-cache backends */
1843118449
u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
1843218450
u8 eOpenState; /* Current condition of the connection */
18451
+ u8 nFpDigit; /* Significant digits to keep on double->text */
1843318452
int nextPagesize; /* Pagesize after VACUUM if >0 */
1843418453
i64 nChange; /* Value returned by sqlite3_changes() */
1843518454
i64 nTotalChange; /* Value returned by sqlite3_total_changes() */
1843618455
int aLimit[SQLITE_N_LIMIT]; /* Limits */
1843718456
int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */
@@ -21556,16 +21575,16 @@
2155621575
/*
2155721576
** An instance of this object receives the decoding of a floating point
2155821577
** value into an approximate decimal representation.
2155921578
*/
2156021579
struct FpDecode {
21561
- char sign; /* '+' or '-' */
21562
- char isSpecial; /* 1: Infinity 2: NaN */
2156321580
int n; /* Significant digits in the decode */
2156421581
int iDP; /* Location of the decimal point */
2156521582
char *z; /* Start of significant digits */
21566
- char zBuf[24]; /* Storage for significant digits */
21583
+ char zBuf[20]; /* Storage for significant digits */
21584
+ char sign; /* '+' or '-' */
21585
+ char isSpecial; /* 1: Infinity 2: NaN */
2156721586
};
2156821587
2156921588
SQLITE_PRIVATE void sqlite3FpDecode(FpDecode*,double,int,int);
2157021589
SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);
2157121590
SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
@@ -32606,11 +32625,11 @@
3260632625
if( precision==0 ) precision = 1;
3260732626
iRound = precision;
3260832627
}else{
3260932628
iRound = precision+1;
3261032629
}
32611
- sqlite3FpDecode(&s, realvalue, iRound, flag_altform2 ? 26 : 16);
32630
+ sqlite3FpDecode(&s, realvalue, iRound, flag_altform2 ? 20 : 16);
3261232631
if( s.isSpecial ){
3261332632
if( s.isSpecial==2 ){
3261432633
bufpt = flag_zeropad ? "null" : "NaN";
3261532634
length = sqlite3Strlen30(bufpt);
3261632635
break;
@@ -36654,15 +36673,21 @@
3665436673
** m should be left-shifted, and e decremented, to maximize the value of m.
3665536674
*/
3665636675
static void sqlite3Fp2Convert10(u64 m, int e, int n, u64 *pD, int *pP){
3665736676
int p;
3665836677
u64 h;
36678
+ assert( n>=1 && n<=18 );
3665936679
p = n - 1 - pwr2to10(e+63);
3666036680
h = sqlite3Multiply128(m, powerOfTen(p));
36661
- assert( -(e + pwr10to2(p) + 1) >=0 );
36662
- assert( -(e + pwr10to2(p) + 1) <64 );
36663
- *pD = h >> -(e + pwr10to2(p) + 1);
36681
+ assert( -(e + pwr10to2(p) + 2) >= 0 );
36682
+ assert( -(e + pwr10to2(p) + 1) <= 63 );
36683
+ if( n==18 ){
36684
+ h >>= -(e + pwr10to2(p) + 2);
36685
+ *pD = (h + ((h<<1)&2))>>1;
36686
+ }else{
36687
+ *pD = h >> -(e + pwr10to2(p) + 1);
36688
+ }
3666436689
*pP = -p;
3666536690
}
3666636691
3666736692
/*
3666836693
** Return an IEEE754 floating point value that approximates d*pow(10,p).
@@ -37173,16 +37198,18 @@
3717337198
** stored in p->z[] which is a often (but not always) a pointer
3717437199
** into the middle of p->zBuf[]. There are p->n significant digits.
3717537200
** The p->z[] array is *not* zero-terminated.
3717637201
*/
3717737202
SQLITE_PRIVATE void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){
37178
- int i;
37179
- u64 v;
37180
- int e, exp = 0;
37203
+ int i; /* Index into zBuf[] where to put next character */
37204
+ int n; /* Number of digits */
37205
+ u64 v; /* mantissa */
37206
+ int e, exp = 0; /* Base-2 and base-10 exponent */
37207
+ char *zBuf; /* Local alias for p->zBuf */
37208
+ char *z; /* Local alias for p->z */
3718137209
3718237210
p->isSpecial = 0;
37183
- p->z = p->zBuf;
3718437211
assert( mxRound>0 );
3718537212
3718637213
/* Convert negative numbers to positive. Deal with Infinity, 0.0, and
3718737214
** NaN. */
3718837215
if( r<0.0 ){
@@ -37201,80 +37228,118 @@
3720137228
e = (v>>52)&0x7ff;
3720237229
if( e==0x7ff ){
3720337230
p->isSpecial = 1 + (v!=0x7ff0000000000000LL);
3720437231
p->n = 0;
3720537232
p->iDP = 0;
37233
+ p->z = p->zBuf;
3720637234
return;
3720737235
}
3720837236
v &= 0x000fffffffffffffULL;
3720937237
if( e==0 ){
37210
- int n = countLeadingZeros(v);
37211
- v <<= n;
37212
- e = -1074 - n;
37238
+ int nn = countLeadingZeros(v);
37239
+ v <<= nn;
37240
+ e = -1074 - nn;
3721337241
}else{
3721437242
v = (v<<11) | U64_BIT(63);
3721537243
e -= 1086;
3721637244
}
3721737245
sqlite3Fp2Convert10(v, e, (iRound<=0||iRound>=18)?18:iRound+1, &v, &exp);
3721837246
37219
- /* Extract significant digits. */
37247
+ /* Extract significant digits, start at the right-most slot in p->zBuf
37248
+ ** and working back to the right. "i" keeps track of the next slot in
37249
+ ** which to store a digit. */
3722037250
i = sizeof(p->zBuf)-1;
37251
+ zBuf = p->zBuf;
3722137252
assert( v>0 );
3722237253
while( v>=10 ){
3722337254
int kk = (v%100)*2;
3722437255
assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) );
37225
- assert( TWO_BYTE_ALIGNMENT(&p->zBuf[i-1]) );
37226
- *(u16*)(&p->zBuf[i-1]) = *(u16*)&sqlite3DigitPairs.a[kk];
37256
+ assert( TWO_BYTE_ALIGNMENT(&zBuf[i-1]) );
37257
+ *(u16*)(&zBuf[i-1]) = *(u16*)&sqlite3DigitPairs.a[kk];
3722737258
i -= 2;
3722837259
v /= 100;
3722937260
}
3723037261
if( v ){
3723137262
assert( v<10 );
37232
- p->zBuf[i--] = v + '0';
37263
+ zBuf[i--] = v + '0';
3723337264
}
3723437265
assert( i>=0 && i<sizeof(p->zBuf)-1 );
37235
- p->n = sizeof(p->zBuf) - 1 - i;
37236
- assert( p->n>0 );
37237
- assert( p->n<sizeof(p->zBuf) );
37238
- p->iDP = p->n + exp;
37266
+ n = sizeof(p->zBuf) - 1 - i; /* Total number of digits extracted */
37267
+ assert( n>0 );
37268
+ assert( n<sizeof(p->zBuf) );
37269
+ testcase( n==sizeof(p->zBuf)-1 );
37270
+ p->iDP = n + exp;
3723937271
if( iRound<=0 ){
3724037272
iRound = p->iDP - iRound;
37241
- if( iRound==0 && p->zBuf[i+1]>='5' ){
37273
+ if( iRound==0 && zBuf[i+1]>='5' ){
3724237274
iRound = 1;
37243
- p->zBuf[i--] = '0';
37244
- p->n++;
37275
+ zBuf[i--] = '0';
37276
+ n++;
3724537277
p->iDP++;
3724637278
}
3724737279
}
37248
- if( iRound>0 && (iRound<p->n || p->n>mxRound) ){
37249
- char *z = &p->zBuf[i+1];
37280
+ z = &zBuf[i+1]; /* z points to the first digit */
37281
+ if( iRound>0 && (iRound<n || n>mxRound) ){
3725037282
if( iRound>mxRound ) iRound = mxRound;
37251
- p->n = iRound;
37283
+ if( iRound==17 ){
37284
+ /* If the precision is exactly 17, which only happens with the "!"
37285
+ ** flag (ex: "%!.17g") then try to reduce the precision if that
37286
+ ** yields text that will round-trip to the original floating-point.
37287
+ ** value. Thus, for exaple, 49.47 will render as 49.47, rather than
37288
+ ** as 49.469999999999999. */
37289
+ if( z[15]=='9' && z[14]=='9' ){
37290
+ int jj, kk;
37291
+ u64 v2;
37292
+ for(jj=14; jj>0 && z[jj-1]=='9'; jj--){}
37293
+ if( jj==0 ){
37294
+ v2 = 1;
37295
+ }else{
37296
+ v2 = z[0] - '0';
37297
+ for(kk=1; kk<jj; kk++) v2 = (v2*10) + z[kk] - '0';
37298
+ v2++;
37299
+ }
37300
+ if( r==sqlite3Fp10Convert2(v2, exp + n - jj) ){
37301
+ iRound = jj+1;
37302
+ }
37303
+ }else if( p->iDP>=n || (z[15]=='0' && z[14]=='0' && z[13]=='0') ){
37304
+ int jj, kk;
37305
+ u64 v2;
37306
+ assert( z[0]!='0' );
37307
+ for(jj=14; z[jj-1]=='0'; jj--){}
37308
+ v2 = z[0] - '0';
37309
+ for(kk=1; kk<jj; kk++) v2 = (v2*10) + z[kk] - '0';
37310
+ if( r==sqlite3Fp10Convert2(v2, exp + n - jj) ){
37311
+ iRound = jj+1;
37312
+ }
37313
+ }
37314
+ }
37315
+ n = iRound;
3725237316
if( z[iRound]>='5' ){
3725337317
int j = iRound-1;
3725437318
while( 1 /*exit-by-break*/ ){
3725537319
z[j]++;
3725637320
if( z[j]<='9' ) break;
3725737321
z[j] = '0';
3725837322
if( j==0 ){
37259
- p->z[i--] = '1';
37260
- p->n++;
37323
+ z--;
37324
+ z[0] = '1';
37325
+ n++;
3726137326
p->iDP++;
3726237327
break;
3726337328
}else{
3726437329
j--;
3726537330
}
3726637331
}
3726737332
}
3726837333
}
37269
- p->z = &p->zBuf[i+1];
37270
- assert( i+p->n < sizeof(p->zBuf) );
37271
- assert( p->n>0 );
37272
- while( p->z[p->n-1]=='0' ){
37273
- p->n--;
37274
- assert( p->n>0 );
37334
+ assert( n>0 );
37335
+ while( z[n-1]=='0' ){
37336
+ n--;
37337
+ assert( n>0 );
3727537338
}
37339
+ p->n = n;
37340
+ p->z = z;
3727637341
}
3727737342
3727837343
/*
3727937344
** Try to convert z into an unsigned 32-bit integer. Return true on
3728037345
** success and false if there is an error.
@@ -84937,25 +85002,30 @@
8493785002
*/
8493885003
static void vdbeMemRenderNum(int sz, char *zBuf, Mem *p){
8493985004
StrAccum acc;
8494085005
assert( p->flags & (MEM_Int|MEM_Real|MEM_IntReal) );
8494185006
assert( sz>22 );
84942
- if( p->flags & MEM_Int ){
84943
-#if GCC_VERSION>=7000000
85007
+ if( p->flags & (MEM_Int|MEM_IntReal) ){
85008
+#if 0
8494485009
/* Work-around for GCC bug
84945
- ** https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96270 */
85010
+ ** https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96270.
85011
+ ** Bug fixed circa 2020, so this work-around removed in 2026. */
8494685012
i64 x;
8494785013
assert( (p->flags&MEM_Int)*2==sizeof(x) );
8494885014
memcpy(&x, (char*)&p->u, (p->flags&MEM_Int)*2);
8494985015
p->n = sqlite3Int64ToText(x, zBuf);
8495085016
#else
8495185017
p->n = sqlite3Int64ToText(p->u.i, zBuf);
8495285018
#endif
85019
+ if( p->flags & MEM_IntReal ){
85020
+ memcpy(zBuf+p->n,".0", 3);
85021
+ p->n += 2;
85022
+ }
8495385023
}else{
8495485024
sqlite3StrAccumInit(&acc, 0, zBuf, sz, 0);
84955
- sqlite3_str_appendf(&acc, "%!.15g",
84956
- (p->flags & MEM_IntReal)!=0 ? (double)p->u.i : p->u.r);
85025
+ sqlite3_str_appendf(&acc, "%!.*g",
85026
+ (p->db ? p->db->nFpDigit : 17), p->u.r);
8495785027
assert( acc.zText==zBuf && acc.mxAlloc<=0 );
8495885028
zBuf[acc.nChar] = 0; /* Fast version of sqlite3StrAccumFinish(&acc) */
8495985029
p->n = acc.nChar;
8496085030
}
8496185031
}
@@ -85000,10 +85070,13 @@
8500085070
assert( p->z[p->n]==0 );
8500185071
assert( p->enc==SQLITE_UTF8 || p->z[(p->n+1)&~1]==0 );
8500285072
assert( p->enc==SQLITE_UTF8 || p->z[((p->n+1)&~1)+1]==0 );
8500385073
}
8500485074
if( (p->flags & (MEM_Int|MEM_Real|MEM_IntReal))==0 ) return 1;
85075
+ if( p->db==0 ){
85076
+ return 1; /* db->nFpDigit required to validate p->z[] */
85077
+ }
8500585078
memcpy(&tmp, p, sizeof(tmp));
8500685079
vdbeMemRenderNum(sizeof(zBuf), zBuf, &tmp);
8500785080
z = p->z;
8500885081
i = j = 0;
8500985082
incr = 1;
@@ -187091,10 +187164,18 @@
187091187164
void *pBuf = va_arg(ap, void*); /* IMP: R-26835-10964 */
187092187165
int sz = va_arg(ap, int); /* IMP: R-47871-25994 */
187093187166
int cnt = va_arg(ap, int); /* IMP: R-04460-53386 */
187094187167
rc = setupLookaside(db, pBuf, sz, cnt);
187095187168
break;
187169
+ }
187170
+ case SQLITE_DBCONFIG_FP_DIGITS: {
187171
+ int nIn = va_arg(ap, int);
187172
+ int *pOut = va_arg(ap, int*);
187173
+ if( nIn>3 && nIn<24 ) db->nFpDigit = (u8)nIn;
187174
+ if( pOut ) *pOut = db->nFpDigit;
187175
+ rc = SQLITE_OK;
187176
+ break;
187096187177
}
187097187178
default: {
187098187179
static const struct {
187099187180
int op; /* The opcode */
187100187181
u64 mask; /* Mask of the bit in sqlite3.flags to set/clear */
@@ -189520,10 +189601,11 @@
189520189601
db->nDb = 2;
189521189602
db->eOpenState = SQLITE_STATE_BUSY;
189522189603
db->aDb = db->aDbStatic;
189523189604
db->lookaside.bDisable = 1;
189524189605
db->lookaside.sz = 0;
189606
+ db->nFpDigit = 17;
189525189607
189526189608
assert( sizeof(db->aLimit)==sizeof(aHardLimit) );
189527189609
memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
189528189610
db->aLimit[SQLITE_LIMIT_WORKER_THREADS] = SQLITE_DEFAULT_WORKER_THREADS;
189529189611
db->autoCommit = 1;
@@ -261749,11 +261831,11 @@
261749261831
int nArg, /* Number of args */
261750261832
sqlite3_value **apUnused /* Function arguments */
261751261833
){
261752261834
assert( nArg==0 );
261753261835
UNUSED_PARAM2(nArg, apUnused);
261754
- sqlite3_result_text(pCtx, "fts5: 2026-02-19 12:59:42 e540f6c370675ae043af8cdbb80f7eb17c08e50f7634e0b78f0b1dccf7bd4b18", -1, SQLITE_TRANSIENT);
261836
+ sqlite3_result_text(pCtx, "fts5: 2026-02-23 13:29:29 5da9bf09cc00faf98cc515fb5a10a0af325b8f7608893808d031dfef62380be2", -1, SQLITE_TRANSIENT);
261755261837
}
261756261838
261757261839
/*
261758261840
** Implementation of fts5_locale(LOCALE, TEXT) function.
261759261841
**
261760261842
--- 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 ** e540f6c370675ae043af8cdbb80f7eb17c08 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.52.0"
471 #define SQLITE_VERSION_NUMBER 3052000
472 #define SQLITE_SOURCE_ID "2026-02-19 12:59:42 e540f6c370675ae043af8cdbb80f7eb17c08e50f7634e0b78f0b1dccf7bd4b18"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2026-02-19T12:59:42.005Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -2967,10 +2967,26 @@
2967 ** respectively. If the second argument is not NULL, then 0 or 1 is written
2968 ** into the integer that the second argument points to depending on if
2969 ** comments are allowed in SQL text after processing the first argument.
2970 ** </dd>
2971 **
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2972 ** </dl>
2973 **
2974 ** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2975 **
2976 ** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
@@ -2984,13 +3000,14 @@
2984 ** the integer to which the second argument points, depending on whether the
2985 ** setting is disabled or enabled after applying any changes specified by
2986 ** the first argument.
2987 **
2988 ** <p>While most SQLITE_DBCONFIG options use the argument format
2989 ** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME]
2990 ** and [SQLITE_DBCONFIG_LOOKASIDE] options are different. See the
2991 ** documentation of those exceptional options for details.
 
2992 */
2993 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2994 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2995 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2996 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
@@ -3011,11 +3028,12 @@
3011 #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
3012 #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
3013 #define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */
3014 #define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */
3015 #define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */
3016 #define SQLITE_DBCONFIG_MAX 1022 /* Largest DBCONFIG */
 
3017
3018 /*
3019 ** CAPI3REF: Enable Or Disable Extended Result Codes
3020 ** METHOD: sqlite3
3021 **
@@ -18428,10 +18446,11 @@
18428 u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
18429 u8 mTrace; /* zero or more SQLITE_TRACE flags */
18430 u8 noSharedCache; /* True if no shared-cache backends */
18431 u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
18432 u8 eOpenState; /* Current condition of the connection */
 
18433 int nextPagesize; /* Pagesize after VACUUM if >0 */
18434 i64 nChange; /* Value returned by sqlite3_changes() */
18435 i64 nTotalChange; /* Value returned by sqlite3_total_changes() */
18436 int aLimit[SQLITE_N_LIMIT]; /* Limits */
18437 int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */
@@ -21556,16 +21575,16 @@
21556 /*
21557 ** An instance of this object receives the decoding of a floating point
21558 ** value into an approximate decimal representation.
21559 */
21560 struct FpDecode {
21561 char sign; /* '+' or '-' */
21562 char isSpecial; /* 1: Infinity 2: NaN */
21563 int n; /* Significant digits in the decode */
21564 int iDP; /* Location of the decimal point */
21565 char *z; /* Start of significant digits */
21566 char zBuf[24]; /* Storage for significant digits */
 
 
21567 };
21568
21569 SQLITE_PRIVATE void sqlite3FpDecode(FpDecode*,double,int,int);
21570 SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);
21571 SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
@@ -32606,11 +32625,11 @@
32606 if( precision==0 ) precision = 1;
32607 iRound = precision;
32608 }else{
32609 iRound = precision+1;
32610 }
32611 sqlite3FpDecode(&s, realvalue, iRound, flag_altform2 ? 26 : 16);
32612 if( s.isSpecial ){
32613 if( s.isSpecial==2 ){
32614 bufpt = flag_zeropad ? "null" : "NaN";
32615 length = sqlite3Strlen30(bufpt);
32616 break;
@@ -36654,15 +36673,21 @@
36654 ** m should be left-shifted, and e decremented, to maximize the value of m.
36655 */
36656 static void sqlite3Fp2Convert10(u64 m, int e, int n, u64 *pD, int *pP){
36657 int p;
36658 u64 h;
 
36659 p = n - 1 - pwr2to10(e+63);
36660 h = sqlite3Multiply128(m, powerOfTen(p));
36661 assert( -(e + pwr10to2(p) + 1) >=0 );
36662 assert( -(e + pwr10to2(p) + 1) <64 );
36663 *pD = h >> -(e + pwr10to2(p) + 1);
 
 
 
 
 
36664 *pP = -p;
36665 }
36666
36667 /*
36668 ** Return an IEEE754 floating point value that approximates d*pow(10,p).
@@ -37173,16 +37198,18 @@
37173 ** stored in p->z[] which is a often (but not always) a pointer
37174 ** into the middle of p->zBuf[]. There are p->n significant digits.
37175 ** The p->z[] array is *not* zero-terminated.
37176 */
37177 SQLITE_PRIVATE void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){
37178 int i;
37179 u64 v;
37180 int e, exp = 0;
 
 
 
37181
37182 p->isSpecial = 0;
37183 p->z = p->zBuf;
37184 assert( mxRound>0 );
37185
37186 /* Convert negative numbers to positive. Deal with Infinity, 0.0, and
37187 ** NaN. */
37188 if( r<0.0 ){
@@ -37201,80 +37228,118 @@
37201 e = (v>>52)&0x7ff;
37202 if( e==0x7ff ){
37203 p->isSpecial = 1 + (v!=0x7ff0000000000000LL);
37204 p->n = 0;
37205 p->iDP = 0;
 
37206 return;
37207 }
37208 v &= 0x000fffffffffffffULL;
37209 if( e==0 ){
37210 int n = countLeadingZeros(v);
37211 v <<= n;
37212 e = -1074 - n;
37213 }else{
37214 v = (v<<11) | U64_BIT(63);
37215 e -= 1086;
37216 }
37217 sqlite3Fp2Convert10(v, e, (iRound<=0||iRound>=18)?18:iRound+1, &v, &exp);
37218
37219 /* Extract significant digits. */
 
 
37220 i = sizeof(p->zBuf)-1;
 
37221 assert( v>0 );
37222 while( v>=10 ){
37223 int kk = (v%100)*2;
37224 assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) );
37225 assert( TWO_BYTE_ALIGNMENT(&p->zBuf[i-1]) );
37226 *(u16*)(&p->zBuf[i-1]) = *(u16*)&sqlite3DigitPairs.a[kk];
37227 i -= 2;
37228 v /= 100;
37229 }
37230 if( v ){
37231 assert( v<10 );
37232 p->zBuf[i--] = v + '0';
37233 }
37234 assert( i>=0 && i<sizeof(p->zBuf)-1 );
37235 p->n = sizeof(p->zBuf) - 1 - i;
37236 assert( p->n>0 );
37237 assert( p->n<sizeof(p->zBuf) );
37238 p->iDP = p->n + exp;
 
37239 if( iRound<=0 ){
37240 iRound = p->iDP - iRound;
37241 if( iRound==0 && p->zBuf[i+1]>='5' ){
37242 iRound = 1;
37243 p->zBuf[i--] = '0';
37244 p->n++;
37245 p->iDP++;
37246 }
37247 }
37248 if( iRound>0 && (iRound<p->n || p->n>mxRound) ){
37249 char *z = &p->zBuf[i+1];
37250 if( iRound>mxRound ) iRound = mxRound;
37251 p->n = iRound;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37252 if( z[iRound]>='5' ){
37253 int j = iRound-1;
37254 while( 1 /*exit-by-break*/ ){
37255 z[j]++;
37256 if( z[j]<='9' ) break;
37257 z[j] = '0';
37258 if( j==0 ){
37259 p->z[i--] = '1';
37260 p->n++;
 
37261 p->iDP++;
37262 break;
37263 }else{
37264 j--;
37265 }
37266 }
37267 }
37268 }
37269 p->z = &p->zBuf[i+1];
37270 assert( i+p->n < sizeof(p->zBuf) );
37271 assert( p->n>0 );
37272 while( p->z[p->n-1]=='0' ){
37273 p->n--;
37274 assert( p->n>0 );
37275 }
 
 
37276 }
37277
37278 /*
37279 ** Try to convert z into an unsigned 32-bit integer. Return true on
37280 ** success and false if there is an error.
@@ -84937,25 +85002,30 @@
84937 */
84938 static void vdbeMemRenderNum(int sz, char *zBuf, Mem *p){
84939 StrAccum acc;
84940 assert( p->flags & (MEM_Int|MEM_Real|MEM_IntReal) );
84941 assert( sz>22 );
84942 if( p->flags & MEM_Int ){
84943 #if GCC_VERSION>=7000000
84944 /* Work-around for GCC bug
84945 ** https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96270 */
 
84946 i64 x;
84947 assert( (p->flags&MEM_Int)*2==sizeof(x) );
84948 memcpy(&x, (char*)&p->u, (p->flags&MEM_Int)*2);
84949 p->n = sqlite3Int64ToText(x, zBuf);
84950 #else
84951 p->n = sqlite3Int64ToText(p->u.i, zBuf);
84952 #endif
 
 
 
 
84953 }else{
84954 sqlite3StrAccumInit(&acc, 0, zBuf, sz, 0);
84955 sqlite3_str_appendf(&acc, "%!.15g",
84956 (p->flags & MEM_IntReal)!=0 ? (double)p->u.i : p->u.r);
84957 assert( acc.zText==zBuf && acc.mxAlloc<=0 );
84958 zBuf[acc.nChar] = 0; /* Fast version of sqlite3StrAccumFinish(&acc) */
84959 p->n = acc.nChar;
84960 }
84961 }
@@ -85000,10 +85070,13 @@
85000 assert( p->z[p->n]==0 );
85001 assert( p->enc==SQLITE_UTF8 || p->z[(p->n+1)&~1]==0 );
85002 assert( p->enc==SQLITE_UTF8 || p->z[((p->n+1)&~1)+1]==0 );
85003 }
85004 if( (p->flags & (MEM_Int|MEM_Real|MEM_IntReal))==0 ) return 1;
 
 
 
85005 memcpy(&tmp, p, sizeof(tmp));
85006 vdbeMemRenderNum(sizeof(zBuf), zBuf, &tmp);
85007 z = p->z;
85008 i = j = 0;
85009 incr = 1;
@@ -187091,10 +187164,18 @@
187091 void *pBuf = va_arg(ap, void*); /* IMP: R-26835-10964 */
187092 int sz = va_arg(ap, int); /* IMP: R-47871-25994 */
187093 int cnt = va_arg(ap, int); /* IMP: R-04460-53386 */
187094 rc = setupLookaside(db, pBuf, sz, cnt);
187095 break;
 
 
 
 
 
 
 
 
187096 }
187097 default: {
187098 static const struct {
187099 int op; /* The opcode */
187100 u64 mask; /* Mask of the bit in sqlite3.flags to set/clear */
@@ -189520,10 +189601,11 @@
189520 db->nDb = 2;
189521 db->eOpenState = SQLITE_STATE_BUSY;
189522 db->aDb = db->aDbStatic;
189523 db->lookaside.bDisable = 1;
189524 db->lookaside.sz = 0;
 
189525
189526 assert( sizeof(db->aLimit)==sizeof(aHardLimit) );
189527 memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
189528 db->aLimit[SQLITE_LIMIT_WORKER_THREADS] = SQLITE_DEFAULT_WORKER_THREADS;
189529 db->autoCommit = 1;
@@ -261749,11 +261831,11 @@
261749 int nArg, /* Number of args */
261750 sqlite3_value **apUnused /* Function arguments */
261751 ){
261752 assert( nArg==0 );
261753 UNUSED_PARAM2(nArg, apUnused);
261754 sqlite3_result_text(pCtx, "fts5: 2026-02-19 12:59:42 e540f6c370675ae043af8cdbb80f7eb17c08e50f7634e0b78f0b1dccf7bd4b18", -1, SQLITE_TRANSIENT);
261755 }
261756
261757 /*
261758 ** Implementation of fts5_locale(LOCALE, TEXT) function.
261759 **
261760
--- 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 ** 3ca1ed81c4fa41f5f9fdbebf0929dd8421a4 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.52.0"
471 #define SQLITE_VERSION_NUMBER 3052000
472 #define SQLITE_SOURCE_ID "2026-02-23 19:51:54 3ca1ed81c4fa41f5f9fdbebf0929dd8421a4e29f95764fe1027d4d8706a41480"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2026-02-23T19:51:54.706Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -2967,10 +2967,26 @@
2967 ** respectively. If the second argument is not NULL, then 0 or 1 is written
2968 ** into the integer that the second argument points to depending on if
2969 ** comments are allowed in SQL text after processing the first argument.
2970 ** </dd>
2971 **
2972 ** [[SQLITE_DBCONFIG_FP_DIGITS]]
2973 ** <dt>SQLITE_DBCONFIG_FP_DIGITS</dt>
2974 ** <dd>The SQLITE_DBCONFIG_FP_DIGITS setting is a small integer that determines
2975 ** the number of significant digits that SQLite will attempt to preserve when
2976 ** converting floating point numbers (IEEE 754 "doubles") into text. The
2977 ** default value 17, as of SQLite version 3.52.0. The value was 15 in all
2978 ** prior versions.<p>
2979 ** This option takes two arguments which are an integer and a pointer
2980 ** to an integer. The first argument is a small integer, between 3 and 23, or
2981 ** zero. The FP_DIGITS setting is changed to that small integer, or left
2982 ** altered if the first argument is zero or out of range. The second argument
2983 ** is a pointer to an integer. If the pointer is not NULL, then the value of
2984 ** the FP_DIGITS setting, after possibly being modified by the first
2985 ** arguments, is written into the integer to which the second argument points.
2986 ** </dd>
2987 **
2988 ** </dl>
2989 **
2990 ** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2991 **
2992 ** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
@@ -2984,13 +3000,14 @@
3000 ** the integer to which the second argument points, depending on whether the
3001 ** setting is disabled or enabled after applying any changes specified by
3002 ** the first argument.
3003 **
3004 ** <p>While most SQLITE_DBCONFIG options use the argument format
3005 ** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME],
3006 ** [SQLITE_DBCONFIG_LOOKASIDE], and [SQLITE_DBCONFIG_FP_DIGITS] options
3007 ** are different. See the documentation of those exceptional options for
3008 ** details.
3009 */
3010 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
3011 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
3012 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
3013 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
@@ -3011,11 +3028,12 @@
3028 #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
3029 #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
3030 #define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */
3031 #define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */
3032 #define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */
3033 #define SQLITE_DBCONFIG_FP_DIGITS 1023 /* int int* */
3034 #define SQLITE_DBCONFIG_MAX 1023 /* Largest DBCONFIG */
3035
3036 /*
3037 ** CAPI3REF: Enable Or Disable Extended Result Codes
3038 ** METHOD: sqlite3
3039 **
@@ -18428,10 +18446,11 @@
18446 u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
18447 u8 mTrace; /* zero or more SQLITE_TRACE flags */
18448 u8 noSharedCache; /* True if no shared-cache backends */
18449 u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
18450 u8 eOpenState; /* Current condition of the connection */
18451 u8 nFpDigit; /* Significant digits to keep on double->text */
18452 int nextPagesize; /* Pagesize after VACUUM if >0 */
18453 i64 nChange; /* Value returned by sqlite3_changes() */
18454 i64 nTotalChange; /* Value returned by sqlite3_total_changes() */
18455 int aLimit[SQLITE_N_LIMIT]; /* Limits */
18456 int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */
@@ -21556,16 +21575,16 @@
21575 /*
21576 ** An instance of this object receives the decoding of a floating point
21577 ** value into an approximate decimal representation.
21578 */
21579 struct FpDecode {
 
 
21580 int n; /* Significant digits in the decode */
21581 int iDP; /* Location of the decimal point */
21582 char *z; /* Start of significant digits */
21583 char zBuf[20]; /* Storage for significant digits */
21584 char sign; /* '+' or '-' */
21585 char isSpecial; /* 1: Infinity 2: NaN */
21586 };
21587
21588 SQLITE_PRIVATE void sqlite3FpDecode(FpDecode*,double,int,int);
21589 SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);
21590 SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
@@ -32606,11 +32625,11 @@
32625 if( precision==0 ) precision = 1;
32626 iRound = precision;
32627 }else{
32628 iRound = precision+1;
32629 }
32630 sqlite3FpDecode(&s, realvalue, iRound, flag_altform2 ? 20 : 16);
32631 if( s.isSpecial ){
32632 if( s.isSpecial==2 ){
32633 bufpt = flag_zeropad ? "null" : "NaN";
32634 length = sqlite3Strlen30(bufpt);
32635 break;
@@ -36654,15 +36673,21 @@
36673 ** m should be left-shifted, and e decremented, to maximize the value of m.
36674 */
36675 static void sqlite3Fp2Convert10(u64 m, int e, int n, u64 *pD, int *pP){
36676 int p;
36677 u64 h;
36678 assert( n>=1 && n<=18 );
36679 p = n - 1 - pwr2to10(e+63);
36680 h = sqlite3Multiply128(m, powerOfTen(p));
36681 assert( -(e + pwr10to2(p) + 2) >= 0 );
36682 assert( -(e + pwr10to2(p) + 1) <= 63 );
36683 if( n==18 ){
36684 h >>= -(e + pwr10to2(p) + 2);
36685 *pD = (h + ((h<<1)&2))>>1;
36686 }else{
36687 *pD = h >> -(e + pwr10to2(p) + 1);
36688 }
36689 *pP = -p;
36690 }
36691
36692 /*
36693 ** Return an IEEE754 floating point value that approximates d*pow(10,p).
@@ -37173,16 +37198,18 @@
37198 ** stored in p->z[] which is a often (but not always) a pointer
37199 ** into the middle of p->zBuf[]. There are p->n significant digits.
37200 ** The p->z[] array is *not* zero-terminated.
37201 */
37202 SQLITE_PRIVATE void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){
37203 int i; /* Index into zBuf[] where to put next character */
37204 int n; /* Number of digits */
37205 u64 v; /* mantissa */
37206 int e, exp = 0; /* Base-2 and base-10 exponent */
37207 char *zBuf; /* Local alias for p->zBuf */
37208 char *z; /* Local alias for p->z */
37209
37210 p->isSpecial = 0;
 
37211 assert( mxRound>0 );
37212
37213 /* Convert negative numbers to positive. Deal with Infinity, 0.0, and
37214 ** NaN. */
37215 if( r<0.0 ){
@@ -37201,80 +37228,118 @@
37228 e = (v>>52)&0x7ff;
37229 if( e==0x7ff ){
37230 p->isSpecial = 1 + (v!=0x7ff0000000000000LL);
37231 p->n = 0;
37232 p->iDP = 0;
37233 p->z = p->zBuf;
37234 return;
37235 }
37236 v &= 0x000fffffffffffffULL;
37237 if( e==0 ){
37238 int nn = countLeadingZeros(v);
37239 v <<= nn;
37240 e = -1074 - nn;
37241 }else{
37242 v = (v<<11) | U64_BIT(63);
37243 e -= 1086;
37244 }
37245 sqlite3Fp2Convert10(v, e, (iRound<=0||iRound>=18)?18:iRound+1, &v, &exp);
37246
37247 /* Extract significant digits, start at the right-most slot in p->zBuf
37248 ** and working back to the right. "i" keeps track of the next slot in
37249 ** which to store a digit. */
37250 i = sizeof(p->zBuf)-1;
37251 zBuf = p->zBuf;
37252 assert( v>0 );
37253 while( v>=10 ){
37254 int kk = (v%100)*2;
37255 assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) );
37256 assert( TWO_BYTE_ALIGNMENT(&zBuf[i-1]) );
37257 *(u16*)(&zBuf[i-1]) = *(u16*)&sqlite3DigitPairs.a[kk];
37258 i -= 2;
37259 v /= 100;
37260 }
37261 if( v ){
37262 assert( v<10 );
37263 zBuf[i--] = v + '0';
37264 }
37265 assert( i>=0 && i<sizeof(p->zBuf)-1 );
37266 n = sizeof(p->zBuf) - 1 - i; /* Total number of digits extracted */
37267 assert( n>0 );
37268 assert( n<sizeof(p->zBuf) );
37269 testcase( n==sizeof(p->zBuf)-1 );
37270 p->iDP = n + exp;
37271 if( iRound<=0 ){
37272 iRound = p->iDP - iRound;
37273 if( iRound==0 && zBuf[i+1]>='5' ){
37274 iRound = 1;
37275 zBuf[i--] = '0';
37276 n++;
37277 p->iDP++;
37278 }
37279 }
37280 z = &zBuf[i+1]; /* z points to the first digit */
37281 if( iRound>0 && (iRound<n || n>mxRound) ){
37282 if( iRound>mxRound ) iRound = mxRound;
37283 if( iRound==17 ){
37284 /* If the precision is exactly 17, which only happens with the "!"
37285 ** flag (ex: "%!.17g") then try to reduce the precision if that
37286 ** yields text that will round-trip to the original floating-point.
37287 ** value. Thus, for exaple, 49.47 will render as 49.47, rather than
37288 ** as 49.469999999999999. */
37289 if( z[15]=='9' && z[14]=='9' ){
37290 int jj, kk;
37291 u64 v2;
37292 for(jj=14; jj>0 && z[jj-1]=='9'; jj--){}
37293 if( jj==0 ){
37294 v2 = 1;
37295 }else{
37296 v2 = z[0] - '0';
37297 for(kk=1; kk<jj; kk++) v2 = (v2*10) + z[kk] - '0';
37298 v2++;
37299 }
37300 if( r==sqlite3Fp10Convert2(v2, exp + n - jj) ){
37301 iRound = jj+1;
37302 }
37303 }else if( p->iDP>=n || (z[15]=='0' && z[14]=='0' && z[13]=='0') ){
37304 int jj, kk;
37305 u64 v2;
37306 assert( z[0]!='0' );
37307 for(jj=14; z[jj-1]=='0'; jj--){}
37308 v2 = z[0] - '0';
37309 for(kk=1; kk<jj; kk++) v2 = (v2*10) + z[kk] - '0';
37310 if( r==sqlite3Fp10Convert2(v2, exp + n - jj) ){
37311 iRound = jj+1;
37312 }
37313 }
37314 }
37315 n = iRound;
37316 if( z[iRound]>='5' ){
37317 int j = iRound-1;
37318 while( 1 /*exit-by-break*/ ){
37319 z[j]++;
37320 if( z[j]<='9' ) break;
37321 z[j] = '0';
37322 if( j==0 ){
37323 z--;
37324 z[0] = '1';
37325 n++;
37326 p->iDP++;
37327 break;
37328 }else{
37329 j--;
37330 }
37331 }
37332 }
37333 }
37334 assert( n>0 );
37335 while( z[n-1]=='0' ){
37336 n--;
37337 assert( n>0 );
 
 
37338 }
37339 p->n = n;
37340 p->z = z;
37341 }
37342
37343 /*
37344 ** Try to convert z into an unsigned 32-bit integer. Return true on
37345 ** success and false if there is an error.
@@ -84937,25 +85002,30 @@
85002 */
85003 static void vdbeMemRenderNum(int sz, char *zBuf, Mem *p){
85004 StrAccum acc;
85005 assert( p->flags & (MEM_Int|MEM_Real|MEM_IntReal) );
85006 assert( sz>22 );
85007 if( p->flags & (MEM_Int|MEM_IntReal) ){
85008 #if 0
85009 /* Work-around for GCC bug
85010 ** https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96270.
85011 ** Bug fixed circa 2020, so this work-around removed in 2026. */
85012 i64 x;
85013 assert( (p->flags&MEM_Int)*2==sizeof(x) );
85014 memcpy(&x, (char*)&p->u, (p->flags&MEM_Int)*2);
85015 p->n = sqlite3Int64ToText(x, zBuf);
85016 #else
85017 p->n = sqlite3Int64ToText(p->u.i, zBuf);
85018 #endif
85019 if( p->flags & MEM_IntReal ){
85020 memcpy(zBuf+p->n,".0", 3);
85021 p->n += 2;
85022 }
85023 }else{
85024 sqlite3StrAccumInit(&acc, 0, zBuf, sz, 0);
85025 sqlite3_str_appendf(&acc, "%!.*g",
85026 (p->db ? p->db->nFpDigit : 17), p->u.r);
85027 assert( acc.zText==zBuf && acc.mxAlloc<=0 );
85028 zBuf[acc.nChar] = 0; /* Fast version of sqlite3StrAccumFinish(&acc) */
85029 p->n = acc.nChar;
85030 }
85031 }
@@ -85000,10 +85070,13 @@
85070 assert( p->z[p->n]==0 );
85071 assert( p->enc==SQLITE_UTF8 || p->z[(p->n+1)&~1]==0 );
85072 assert( p->enc==SQLITE_UTF8 || p->z[((p->n+1)&~1)+1]==0 );
85073 }
85074 if( (p->flags & (MEM_Int|MEM_Real|MEM_IntReal))==0 ) return 1;
85075 if( p->db==0 ){
85076 return 1; /* db->nFpDigit required to validate p->z[] */
85077 }
85078 memcpy(&tmp, p, sizeof(tmp));
85079 vdbeMemRenderNum(sizeof(zBuf), zBuf, &tmp);
85080 z = p->z;
85081 i = j = 0;
85082 incr = 1;
@@ -187091,10 +187164,18 @@
187164 void *pBuf = va_arg(ap, void*); /* IMP: R-26835-10964 */
187165 int sz = va_arg(ap, int); /* IMP: R-47871-25994 */
187166 int cnt = va_arg(ap, int); /* IMP: R-04460-53386 */
187167 rc = setupLookaside(db, pBuf, sz, cnt);
187168 break;
187169 }
187170 case SQLITE_DBCONFIG_FP_DIGITS: {
187171 int nIn = va_arg(ap, int);
187172 int *pOut = va_arg(ap, int*);
187173 if( nIn>3 && nIn<24 ) db->nFpDigit = (u8)nIn;
187174 if( pOut ) *pOut = db->nFpDigit;
187175 rc = SQLITE_OK;
187176 break;
187177 }
187178 default: {
187179 static const struct {
187180 int op; /* The opcode */
187181 u64 mask; /* Mask of the bit in sqlite3.flags to set/clear */
@@ -189520,10 +189601,11 @@
189601 db->nDb = 2;
189602 db->eOpenState = SQLITE_STATE_BUSY;
189603 db->aDb = db->aDbStatic;
189604 db->lookaside.bDisable = 1;
189605 db->lookaside.sz = 0;
189606 db->nFpDigit = 17;
189607
189608 assert( sizeof(db->aLimit)==sizeof(aHardLimit) );
189609 memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
189610 db->aLimit[SQLITE_LIMIT_WORKER_THREADS] = SQLITE_DEFAULT_WORKER_THREADS;
189611 db->autoCommit = 1;
@@ -261749,11 +261831,11 @@
261831 int nArg, /* Number of args */
261832 sqlite3_value **apUnused /* Function arguments */
261833 ){
261834 assert( nArg==0 );
261835 UNUSED_PARAM2(nArg, apUnused);
261836 sqlite3_result_text(pCtx, "fts5: 2026-02-23 13:29:29 5da9bf09cc00faf98cc515fb5a10a0af325b8f7608893808d031dfef62380be2", -1, SQLITE_TRANSIENT);
261837 }
261838
261839 /*
261840 ** Implementation of fts5_locale(LOCALE, TEXT) function.
261841 **
261842
+24 -6
--- 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.52.0"
150150
#define SQLITE_VERSION_NUMBER 3052000
151
-#define SQLITE_SOURCE_ID "2026-02-19 12:59:42 e540f6c370675ae043af8cdbb80f7eb17c08e50f7634e0b78f0b1dccf7bd4b18"
151
+#define SQLITE_SOURCE_ID "2026-02-23 19:51:54 3ca1ed81c4fa41f5f9fdbebf0929dd8421a4e29f95764fe1027d4d8706a41480"
152152
#define SQLITE_SCM_BRANCH "trunk"
153153
#define SQLITE_SCM_TAGS ""
154
-#define SQLITE_SCM_DATETIME "2026-02-19T12:59:42.005Z"
154
+#define SQLITE_SCM_DATETIME "2026-02-23T19:51:54.706Z"
155155
156156
/*
157157
** CAPI3REF: Run-Time Library Version Numbers
158158
** KEYWORDS: sqlite3_version sqlite3_sourceid
159159
**
@@ -2646,10 +2646,26 @@
26462646
** respectively. If the second argument is not NULL, then 0 or 1 is written
26472647
** into the integer that the second argument points to depending on if
26482648
** comments are allowed in SQL text after processing the first argument.
26492649
** </dd>
26502650
**
2651
+** [[SQLITE_DBCONFIG_FP_DIGITS]]
2652
+** <dt>SQLITE_DBCONFIG_FP_DIGITS</dt>
2653
+** <dd>The SQLITE_DBCONFIG_FP_DIGITS setting is a small integer that determines
2654
+** the number of significant digits that SQLite will attempt to preserve when
2655
+** converting floating point numbers (IEEE 754 "doubles") into text. The
2656
+** default value 17, as of SQLite version 3.52.0. The value was 15 in all
2657
+** prior versions.<p>
2658
+** This option takes two arguments which are an integer and a pointer
2659
+** to an integer. The first argument is a small integer, between 3 and 23, or
2660
+** zero. The FP_DIGITS setting is changed to that small integer, or left
2661
+** altered if the first argument is zero or out of range. The second argument
2662
+** is a pointer to an integer. If the pointer is not NULL, then the value of
2663
+** the FP_DIGITS setting, after possibly being modified by the first
2664
+** arguments, is written into the integer to which the second argument points.
2665
+** </dd>
2666
+**
26512667
** </dl>
26522668
**
26532669
** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
26542670
**
26552671
** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
@@ -2663,13 +2679,14 @@
26632679
** the integer to which the second argument points, depending on whether the
26642680
** setting is disabled or enabled after applying any changes specified by
26652681
** the first argument.
26662682
**
26672683
** <p>While most SQLITE_DBCONFIG options use the argument format
2668
-** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME]
2669
-** and [SQLITE_DBCONFIG_LOOKASIDE] options are different. See the
2670
-** documentation of those exceptional options for details.
2684
+** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME],
2685
+** [SQLITE_DBCONFIG_LOOKASIDE], and [SQLITE_DBCONFIG_FP_DIGITS] options
2686
+** are different. See the documentation of those exceptional options for
2687
+** details.
26712688
*/
26722689
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
26732690
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
26742691
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
26752692
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
@@ -2690,11 +2707,12 @@
26902707
#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
26912708
#define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
26922709
#define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */
26932710
#define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */
26942711
#define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */
2695
-#define SQLITE_DBCONFIG_MAX 1022 /* Largest DBCONFIG */
2712
+#define SQLITE_DBCONFIG_FP_DIGITS 1023 /* int int* */
2713
+#define SQLITE_DBCONFIG_MAX 1023 /* Largest DBCONFIG */
26962714
26972715
/*
26982716
** CAPI3REF: Enable Or Disable Extended Result Codes
26992717
** METHOD: sqlite3
27002718
**
27012719
--- 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.52.0"
150 #define SQLITE_VERSION_NUMBER 3052000
151 #define SQLITE_SOURCE_ID "2026-02-19 12:59:42 e540f6c370675ae043af8cdbb80f7eb17c08e50f7634e0b78f0b1dccf7bd4b18"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2026-02-19T12:59:42.005Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
@@ -2646,10 +2646,26 @@
2646 ** respectively. If the second argument is not NULL, then 0 or 1 is written
2647 ** into the integer that the second argument points to depending on if
2648 ** comments are allowed in SQL text after processing the first argument.
2649 ** </dd>
2650 **
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2651 ** </dl>
2652 **
2653 ** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2654 **
2655 ** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
@@ -2663,13 +2679,14 @@
2663 ** the integer to which the second argument points, depending on whether the
2664 ** setting is disabled or enabled after applying any changes specified by
2665 ** the first argument.
2666 **
2667 ** <p>While most SQLITE_DBCONFIG options use the argument format
2668 ** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME]
2669 ** and [SQLITE_DBCONFIG_LOOKASIDE] options are different. See the
2670 ** documentation of those exceptional options for details.
 
2671 */
2672 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2673 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2674 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2675 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
@@ -2690,11 +2707,12 @@
2690 #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
2691 #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2692 #define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */
2693 #define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */
2694 #define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */
2695 #define SQLITE_DBCONFIG_MAX 1022 /* Largest DBCONFIG */
 
2696
2697 /*
2698 ** CAPI3REF: Enable Or Disable Extended Result Codes
2699 ** METHOD: sqlite3
2700 **
2701
--- 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.52.0"
150 #define SQLITE_VERSION_NUMBER 3052000
151 #define SQLITE_SOURCE_ID "2026-02-23 19:51:54 3ca1ed81c4fa41f5f9fdbebf0929dd8421a4e29f95764fe1027d4d8706a41480"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2026-02-23T19:51:54.706Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
@@ -2646,10 +2646,26 @@
2646 ** respectively. If the second argument is not NULL, then 0 or 1 is written
2647 ** into the integer that the second argument points to depending on if
2648 ** comments are allowed in SQL text after processing the first argument.
2649 ** </dd>
2650 **
2651 ** [[SQLITE_DBCONFIG_FP_DIGITS]]
2652 ** <dt>SQLITE_DBCONFIG_FP_DIGITS</dt>
2653 ** <dd>The SQLITE_DBCONFIG_FP_DIGITS setting is a small integer that determines
2654 ** the number of significant digits that SQLite will attempt to preserve when
2655 ** converting floating point numbers (IEEE 754 "doubles") into text. The
2656 ** default value 17, as of SQLite version 3.52.0. The value was 15 in all
2657 ** prior versions.<p>
2658 ** This option takes two arguments which are an integer and a pointer
2659 ** to an integer. The first argument is a small integer, between 3 and 23, or
2660 ** zero. The FP_DIGITS setting is changed to that small integer, or left
2661 ** altered if the first argument is zero or out of range. The second argument
2662 ** is a pointer to an integer. If the pointer is not NULL, then the value of
2663 ** the FP_DIGITS setting, after possibly being modified by the first
2664 ** arguments, is written into the integer to which the second argument points.
2665 ** </dd>
2666 **
2667 ** </dl>
2668 **
2669 ** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2670 **
2671 ** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
@@ -2663,13 +2679,14 @@
2679 ** the integer to which the second argument points, depending on whether the
2680 ** setting is disabled or enabled after applying any changes specified by
2681 ** the first argument.
2682 **
2683 ** <p>While most SQLITE_DBCONFIG options use the argument format
2684 ** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME],
2685 ** [SQLITE_DBCONFIG_LOOKASIDE], and [SQLITE_DBCONFIG_FP_DIGITS] options
2686 ** are different. See the documentation of those exceptional options for
2687 ** details.
2688 */
2689 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2690 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2691 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2692 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
@@ -2690,11 +2707,12 @@
2707 #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
2708 #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2709 #define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */
2710 #define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */
2711 #define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */
2712 #define SQLITE_DBCONFIG_FP_DIGITS 1023 /* int int* */
2713 #define SQLITE_DBCONFIG_MAX 1023 /* Largest DBCONFIG */
2714
2715 /*
2716 ** CAPI3REF: Enable Or Disable Extended Result Codes
2717 ** METHOD: sqlite3
2718 **
2719

Keyboard Shortcuts

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