Fossil SCM

Update the built-in SQLite to the latest 3.47.0 alpha for testing.

drh 2024-10-07 13:33 trunk
Commit 72070b304b8d269dd451c39168db7919ab32076ff54efbea30472af1b7b1522c
+7 -22
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -917,11 +917,11 @@
917917
*/
918918
static const struct {
919919
unsigned char w; /* Width of the character in columns */
920920
int iFirst; /* First character in a span having this width */
921921
} aUWidth[] = {
922
- /* {0, 0x00000}, {1, 0x00020}, {0, 0x0007f}, {1, 0x000a0}, */
922
+ /* {1, 0x00000}, */
923923
{0, 0x00300}, {1, 0x00370}, {0, 0x00483}, {1, 0x00487}, {0, 0x00488},
924924
{1, 0x0048a}, {0, 0x00591}, {1, 0x005be}, {0, 0x005bf}, {1, 0x005c0},
925925
{0, 0x005c1}, {1, 0x005c3}, {0, 0x005c4}, {1, 0x005c6}, {0, 0x005c7},
926926
{1, 0x005c8}, {0, 0x00600}, {1, 0x00604}, {0, 0x00610}, {1, 0x00616},
927927
{0, 0x0064b}, {1, 0x0065f}, {0, 0x00670}, {1, 0x00671}, {0, 0x006d6},
@@ -995,13 +995,10 @@
995995
*/
996996
int cli_wcwidth(int c){
997997
int iFirst, iLast;
998998
999999
/* Fast path for common characters */
1000
- if( c<0x20 ) return 0;
1001
- if( c<0x7f ) return 1;
1002
- if( c<0xa0 ) return 0;
10031000
if( c<=0x300 ) return 1;
10041001
10051002
/* The general case */
10061003
iFirst = 0;
10071004
iLast = sizeof(aUWidth)/sizeof(aUWidth[0]) - 1;
@@ -29667,11 +29664,11 @@
2966729664
int bTxtMode = 0;
2966829665
int i;
2966929666
int eMode = 0;
2967029667
int bOnce = 0; /* 0: .output, 1: .once, 2: .excel/.www */
2967129668
int bPlain = 0; /* --plain option */
29672
- static const char *zBomUtf8 = "\xef\xbb\xbf";
29669
+ static const char *zBomUtf8 = "\357\273\277";
2967329670
const char *zBom = 0;
2967429671
2967529672
failIfSafeMode(p, "cannot run .%s in safe mode", azArg[0]);
2967629673
if( c=='e' ){
2967729674
eMode = 'x';
@@ -31014,11 +31011,10 @@
3101431011
{"prng_save", SQLITE_TESTCTRL_PRNG_SAVE, 0, "" },
3101531012
{"prng_seed", SQLITE_TESTCTRL_PRNG_SEED, 0, "SEED ?db?" },
3101631013
{"seek_count", SQLITE_TESTCTRL_SEEK_COUNT, 0, "" },
3101731014
{"sorter_mmap", SQLITE_TESTCTRL_SORTER_MMAP, 0, "NMAX" },
3101831015
{"tune", SQLITE_TESTCTRL_TUNE, 1, "ID VALUE" },
31019
- {"uselongdouble", SQLITE_TESTCTRL_USELONGDOUBLE,0,"?BOOLEAN|\"default\"?"},
3102031016
};
3102131017
int testctrl = -1;
3102231018
int iCtrl = -1;
3102331019
int rc2 = 0; /* 0: usage. 1: %d 2: %x 3: no-output */
3102431020
int isOk = 0;
@@ -31248,25 +31244,10 @@
3124831244
rc2 = sqlite3_test_control(testctrl, opt);
3124931245
isOk = 3;
3125031246
}
3125131247
break;
3125231248
31253
- /* sqlite3_test_control(int, int) */
31254
- case SQLITE_TESTCTRL_USELONGDOUBLE: {
31255
- int opt = -1;
31256
- if( nArg==3 ){
31257
- if( cli_strcmp(azArg[2],"default")==0 ){
31258
- opt = 2;
31259
- }else{
31260
- opt = booleanValue(azArg[2]);
31261
- }
31262
- }
31263
- rc2 = sqlite3_test_control(testctrl, opt);
31264
- isOk = 1;
31265
- break;
31266
- }
31267
-
3126831249
/* sqlite3_test_control(sqlite3*) */
3126931250
case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS:
3127031251
rc2 = sqlite3_test_control(testctrl, p->db);
3127131252
isOk = 3;
3127231253
break;
@@ -32486,11 +32467,15 @@
3248632467
if( isatty(0) && isatty(2) ){
3248732468
char zLine[100];
3248832469
sqlite3_fprintf(stderr,
3248932470
"attach debugger to process %d and press ENTER to continue...",
3249032471
GETPID());
32491
- sqlite3_fgets(zLine, sizeof(zLine), stdin);
32472
+ if( sqlite3_fgets(zLine, sizeof(zLine), stdin)!=0
32473
+ && cli_strcmp(zLine,"stop")==0
32474
+ ){
32475
+ exit(1);
32476
+ }
3249232477
}else{
3249332478
#if defined(_WIN32) || defined(WIN32)
3249432479
#if SQLITE_OS_WINRT
3249532480
__debugbreak();
3249632481
#else
3249732482
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -917,11 +917,11 @@
917 */
918 static const struct {
919 unsigned char w; /* Width of the character in columns */
920 int iFirst; /* First character in a span having this width */
921 } aUWidth[] = {
922 /* {0, 0x00000}, {1, 0x00020}, {0, 0x0007f}, {1, 0x000a0}, */
923 {0, 0x00300}, {1, 0x00370}, {0, 0x00483}, {1, 0x00487}, {0, 0x00488},
924 {1, 0x0048a}, {0, 0x00591}, {1, 0x005be}, {0, 0x005bf}, {1, 0x005c0},
925 {0, 0x005c1}, {1, 0x005c3}, {0, 0x005c4}, {1, 0x005c6}, {0, 0x005c7},
926 {1, 0x005c8}, {0, 0x00600}, {1, 0x00604}, {0, 0x00610}, {1, 0x00616},
927 {0, 0x0064b}, {1, 0x0065f}, {0, 0x00670}, {1, 0x00671}, {0, 0x006d6},
@@ -995,13 +995,10 @@
995 */
996 int cli_wcwidth(int c){
997 int iFirst, iLast;
998
999 /* Fast path for common characters */
1000 if( c<0x20 ) return 0;
1001 if( c<0x7f ) return 1;
1002 if( c<0xa0 ) return 0;
1003 if( c<=0x300 ) return 1;
1004
1005 /* The general case */
1006 iFirst = 0;
1007 iLast = sizeof(aUWidth)/sizeof(aUWidth[0]) - 1;
@@ -29667,11 +29664,11 @@
29667 int bTxtMode = 0;
29668 int i;
29669 int eMode = 0;
29670 int bOnce = 0; /* 0: .output, 1: .once, 2: .excel/.www */
29671 int bPlain = 0; /* --plain option */
29672 static const char *zBomUtf8 = "\xef\xbb\xbf";
29673 const char *zBom = 0;
29674
29675 failIfSafeMode(p, "cannot run .%s in safe mode", azArg[0]);
29676 if( c=='e' ){
29677 eMode = 'x';
@@ -31014,11 +31011,10 @@
31014 {"prng_save", SQLITE_TESTCTRL_PRNG_SAVE, 0, "" },
31015 {"prng_seed", SQLITE_TESTCTRL_PRNG_SEED, 0, "SEED ?db?" },
31016 {"seek_count", SQLITE_TESTCTRL_SEEK_COUNT, 0, "" },
31017 {"sorter_mmap", SQLITE_TESTCTRL_SORTER_MMAP, 0, "NMAX" },
31018 {"tune", SQLITE_TESTCTRL_TUNE, 1, "ID VALUE" },
31019 {"uselongdouble", SQLITE_TESTCTRL_USELONGDOUBLE,0,"?BOOLEAN|\"default\"?"},
31020 };
31021 int testctrl = -1;
31022 int iCtrl = -1;
31023 int rc2 = 0; /* 0: usage. 1: %d 2: %x 3: no-output */
31024 int isOk = 0;
@@ -31248,25 +31244,10 @@
31248 rc2 = sqlite3_test_control(testctrl, opt);
31249 isOk = 3;
31250 }
31251 break;
31252
31253 /* sqlite3_test_control(int, int) */
31254 case SQLITE_TESTCTRL_USELONGDOUBLE: {
31255 int opt = -1;
31256 if( nArg==3 ){
31257 if( cli_strcmp(azArg[2],"default")==0 ){
31258 opt = 2;
31259 }else{
31260 opt = booleanValue(azArg[2]);
31261 }
31262 }
31263 rc2 = sqlite3_test_control(testctrl, opt);
31264 isOk = 1;
31265 break;
31266 }
31267
31268 /* sqlite3_test_control(sqlite3*) */
31269 case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS:
31270 rc2 = sqlite3_test_control(testctrl, p->db);
31271 isOk = 3;
31272 break;
@@ -32486,11 +32467,15 @@
32486 if( isatty(0) && isatty(2) ){
32487 char zLine[100];
32488 sqlite3_fprintf(stderr,
32489 "attach debugger to process %d and press ENTER to continue...",
32490 GETPID());
32491 sqlite3_fgets(zLine, sizeof(zLine), stdin);
 
 
 
 
32492 }else{
32493 #if defined(_WIN32) || defined(WIN32)
32494 #if SQLITE_OS_WINRT
32495 __debugbreak();
32496 #else
32497
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -917,11 +917,11 @@
917 */
918 static const struct {
919 unsigned char w; /* Width of the character in columns */
920 int iFirst; /* First character in a span having this width */
921 } aUWidth[] = {
922 /* {1, 0x00000}, */
923 {0, 0x00300}, {1, 0x00370}, {0, 0x00483}, {1, 0x00487}, {0, 0x00488},
924 {1, 0x0048a}, {0, 0x00591}, {1, 0x005be}, {0, 0x005bf}, {1, 0x005c0},
925 {0, 0x005c1}, {1, 0x005c3}, {0, 0x005c4}, {1, 0x005c6}, {0, 0x005c7},
926 {1, 0x005c8}, {0, 0x00600}, {1, 0x00604}, {0, 0x00610}, {1, 0x00616},
927 {0, 0x0064b}, {1, 0x0065f}, {0, 0x00670}, {1, 0x00671}, {0, 0x006d6},
@@ -995,13 +995,10 @@
995 */
996 int cli_wcwidth(int c){
997 int iFirst, iLast;
998
999 /* Fast path for common characters */
 
 
 
1000 if( c<=0x300 ) return 1;
1001
1002 /* The general case */
1003 iFirst = 0;
1004 iLast = sizeof(aUWidth)/sizeof(aUWidth[0]) - 1;
@@ -29667,11 +29664,11 @@
29664 int bTxtMode = 0;
29665 int i;
29666 int eMode = 0;
29667 int bOnce = 0; /* 0: .output, 1: .once, 2: .excel/.www */
29668 int bPlain = 0; /* --plain option */
29669 static const char *zBomUtf8 = "\357\273\277";
29670 const char *zBom = 0;
29671
29672 failIfSafeMode(p, "cannot run .%s in safe mode", azArg[0]);
29673 if( c=='e' ){
29674 eMode = 'x';
@@ -31014,11 +31011,10 @@
31011 {"prng_save", SQLITE_TESTCTRL_PRNG_SAVE, 0, "" },
31012 {"prng_seed", SQLITE_TESTCTRL_PRNG_SEED, 0, "SEED ?db?" },
31013 {"seek_count", SQLITE_TESTCTRL_SEEK_COUNT, 0, "" },
31014 {"sorter_mmap", SQLITE_TESTCTRL_SORTER_MMAP, 0, "NMAX" },
31015 {"tune", SQLITE_TESTCTRL_TUNE, 1, "ID VALUE" },
 
31016 };
31017 int testctrl = -1;
31018 int iCtrl = -1;
31019 int rc2 = 0; /* 0: usage. 1: %d 2: %x 3: no-output */
31020 int isOk = 0;
@@ -31248,25 +31244,10 @@
31244 rc2 = sqlite3_test_control(testctrl, opt);
31245 isOk = 3;
31246 }
31247 break;
31248
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31249 /* sqlite3_test_control(sqlite3*) */
31250 case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS:
31251 rc2 = sqlite3_test_control(testctrl, p->db);
31252 isOk = 3;
31253 break;
@@ -32486,11 +32467,15 @@
32467 if( isatty(0) && isatty(2) ){
32468 char zLine[100];
32469 sqlite3_fprintf(stderr,
32470 "attach debugger to process %d and press ENTER to continue...",
32471 GETPID());
32472 if( sqlite3_fgets(zLine, sizeof(zLine), stdin)!=0
32473 && cli_strcmp(zLine,"stop")==0
32474 ){
32475 exit(1);
32476 }
32477 }else{
32478 #if defined(_WIN32) || defined(WIN32)
32479 #if SQLITE_OS_WINRT
32480 __debugbreak();
32481 #else
32482
+522 -393
--- 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
-** f97f9944b829a49da12786f934da0a5ad515.
21
+** 011fab70cb3d194b27742ebb236b05be5822.
2222
*/
2323
#define SQLITE_CORE 1
2424
#define SQLITE_AMALGAMATION 1
2525
#ifndef SQLITE_PRIVATE
2626
# define SQLITE_PRIVATE static
@@ -462,11 +462,11 @@
462462
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
463463
** [sqlite_version()] and [sqlite_source_id()].
464464
*/
465465
#define SQLITE_VERSION "3.47.0"
466466
#define SQLITE_VERSION_NUMBER 3047000
467
-#define SQLITE_SOURCE_ID "2024-09-26 19:38:34 f97f9944b829a49da12786f934da0a5ad51591afd6d8a19a4a0835f51bbdbff2"
467
+#define SQLITE_SOURCE_ID "2024-10-07 12:48:21 011fab70cb3d194b27742ebb236b05be582230567cf78e3e6cac6911de86922f"
468468
469469
/*
470470
** CAPI3REF: Run-Time Library Version Numbers
471471
** KEYWORDS: sqlite3_version sqlite3_sourceid
472472
**
@@ -5917,11 +5917,11 @@
59175917
** The SQLITE_SUBTYPE flag indicates to SQLite that a function might call
59185918
** [sqlite3_value_subtype()] to inspect the sub-types of its arguments.
59195919
** This flag instructs SQLite to omit some corner-case optimizations that
59205920
** might disrupt the operation of the [sqlite3_value_subtype()] function,
59215921
** causing it to return zero rather than the correct subtype().
5922
-** SQL functions that invokes [sqlite3_value_subtype()] should have this
5922
+** All SQL functions that invoke [sqlite3_value_subtype()] should have this
59235923
** property. If the SQLITE_SUBTYPE property is omitted, then the return
59245924
** value from [sqlite3_value_subtype()] might sometimes be zero even though
59255925
** a non-zero subtype was specified by the function argument expression.
59265926
**
59275927
** [[SQLITE_RESULT_SUBTYPE]] <dt>SQLITE_RESULT_SUBTYPE</dt><dd>
@@ -8682,11 +8682,11 @@
86828682
#define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
86838683
#define SQLITE_TESTCTRL_SEEK_COUNT 30
86848684
#define SQLITE_TESTCTRL_TRACEFLAGS 31
86858685
#define SQLITE_TESTCTRL_TUNE 32
86868686
#define SQLITE_TESTCTRL_LOGEST 33
8687
-#define SQLITE_TESTCTRL_USELONGDOUBLE 34
8687
+#define SQLITE_TESTCTRL_USELONGDOUBLE 34 /* NOT USED */
86888688
#define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
86898689
86908690
/*
86918691
** CAPI3REF: SQL Keyword Checking
86928692
**
@@ -10856,10 +10856,18 @@
1085610856
** schema S in database connection D. ^On success, the
1085710857
** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
1085810858
** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
1085910859
** If there is not already a read-transaction open on schema S when
1086010860
** this function is called, one is opened automatically.
10861
+**
10862
+** If a read-transaction is opened by this function, then it is guaranteed
10863
+** that the returned snapshot object may not be invalidated by a database
10864
+** writer or checkpointer until after the read-transaction is closed. This
10865
+** is not guaranteed if a read-transaction is already open when this
10866
+** function is called. In that case, any subsequent write or checkpoint
10867
+** operation on the database may invalidate the returned snapshot handle,
10868
+** even while the read-transaction remains open.
1086110869
**
1086210870
** The following must be true for this function to succeed. If any of
1086310871
** the following statements are false when sqlite3_snapshot_get() is
1086410872
** called, SQLITE_ERROR is returned. The final value of *P is undefined
1086510873
** in this case.
@@ -14813,10 +14821,11 @@
1481314821
#include <stdio.h>
1481414822
#include <stdlib.h>
1481514823
#include <string.h>
1481614824
#include <assert.h>
1481714825
#include <stddef.h>
14826
+#include <ctype.h>
1481814827
1481914828
/*
1482014829
** Use a macro to replace memcpy() if compiled with SQLITE_INLINE_MEMCPY.
1482114830
** This allows better measurements of where memcpy() is used when running
1482214831
** cachegrind. But this macro version of memcpy() is very slow so it
@@ -14835,11 +14844,10 @@
1483514844
#ifdef SQLITE_OMIT_FLOATING_POINT
1483614845
# define double sqlite_int64
1483714846
# define float sqlite_int64
1483814847
# define fabs(X) ((X)<0?-(X):(X))
1483914848
# define sqlite3IsOverflow(X) 0
14840
-# define LONGDOUBLE_TYPE sqlite_int64
1484114849
# ifndef SQLITE_BIG_DBL
1484214850
# define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50)
1484314851
# endif
1484414852
# define SQLITE_OMIT_DATETIME_FUNCS 1
1484514853
# define SQLITE_OMIT_TRACE 1
@@ -15010,13 +15018,10 @@
1501015018
# define INT8_TYPE int8_t
1501115019
# else
1501215020
# define INT8_TYPE signed char
1501315021
# endif
1501415022
#endif
15015
-#ifndef LONGDOUBLE_TYPE
15016
-# define LONGDOUBLE_TYPE long double
15017
-#endif
1501815023
typedef sqlite_int64 i64; /* 8-byte signed integer */
1501915024
typedef sqlite_uint64 u64; /* 8-byte unsigned integer */
1502015025
typedef UINT32_TYPE u32; /* 4-byte unsigned integer */
1502115026
typedef UINT16_TYPE u16; /* 2-byte unsigned integer */
1502215027
typedef INT16_TYPE i16; /* 2-byte signed integer */
@@ -20380,11 +20385,10 @@
2038020385
u8 bFullMutex; /* True to enable full mutexing */
2038120386
u8 bOpenUri; /* True to interpret filenames as URIs */
2038220387
u8 bUseCis; /* Use covering indices for full-scans */
2038320388
u8 bSmallMalloc; /* Avoid large memory allocations if true */
2038420389
u8 bExtraSchemaChecks; /* Verify type,name,tbl_name in schema */
20385
- u8 bUseLongDouble; /* Make use of long double */
2038620390
#ifdef SQLITE_DEBUG
2038720391
u8 bJsonSelfcheck; /* Double-check JSON parsing */
2038820392
#endif
2038920393
int mxStrlen; /* Maximum string length */
2039020394
int neverCorrupt; /* Database is always well-formed */
@@ -20755,19 +20759,10 @@
2075520759
*/
2075620760
#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)
2075720761
# define SQLITE_ENABLE_FTS3 1
2075820762
#endif
2075920763
20760
-/*
20761
-** The ctype.h header is needed for non-ASCII systems. It is also
20762
-** needed by FTS3 when FTS3 is included in the amalgamation.
20763
-*/
20764
-#if !defined(SQLITE_ASCII) || \
20765
- (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION))
20766
-# include <ctype.h>
20767
-#endif
20768
-
2076920764
/*
2077020765
** The following macros mimic the standard library functions toupper(),
2077120766
** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The
2077220767
** sqlite versions only work for ASCII characters, regardless of locale.
2077320768
*/
@@ -23121,11 +23116,10 @@
2312123116
SQLITE_THREADSAFE==1, /* bFullMutex */
2312223117
SQLITE_USE_URI, /* bOpenUri */
2312323118
SQLITE_ALLOW_COVERING_INDEX_SCAN, /* bUseCis */
2312423119
0, /* bSmallMalloc */
2312523120
1, /* bExtraSchemaChecks */
23126
- sizeof(LONGDOUBLE_TYPE)>8, /* bUseLongDouble */
2312723121
#ifdef SQLITE_DEBUG
2312823122
0, /* bJsonSelfcheck */
2312923123
#endif
2313023124
0x7ffffffe, /* mxStrlen */
2313123125
0, /* neverCorrupt */
@@ -35679,10 +35673,12 @@
3567935673
int esign = 1; /* sign of exponent */
3568035674
int e = 0; /* exponent */
3568135675
int eValid = 1; /* True exponent is either not used or is well-formed */
3568235676
int nDigit = 0; /* Number of digits processed */
3568335677
int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */
35678
+ double rr[2];
35679
+ u64 s2;
3568435680
3568535681
assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
3568635682
*pResult = 0.0; /* Default return value, in case of an error */
3568735683
if( length==0 ) return 0;
3568835684
@@ -35790,72 +35786,45 @@
3579035786
while( e<0 && (s%10)==0 ){
3579135787
s /= 10;
3579235788
e++;
3579335789
}
3579435790
35795
- if( e==0 ){
35796
- *pResult = s;
35797
- }else if( sqlite3Config.bUseLongDouble ){
35798
- LONGDOUBLE_TYPE r = (LONGDOUBLE_TYPE)s;
35799
- if( e>0 ){
35800
- while( e>=100 ){ e-=100; r *= 1.0e+100L; }
35801
- while( e>=10 ){ e-=10; r *= 1.0e+10L; }
35802
- while( e>=1 ){ e-=1; r *= 1.0e+01L; }
35803
- }else{
35804
- while( e<=-100 ){ e+=100; r *= 1.0e-100L; }
35805
- while( e<=-10 ){ e+=10; r *= 1.0e-10L; }
35806
- while( e<=-1 ){ e+=1; r *= 1.0e-01L; }
35807
- }
35808
- assert( r>=0.0 );
35809
- if( r>+1.7976931348623157081452742373e+308L ){
35810
-#ifdef INFINITY
35811
- *pResult = +INFINITY;
35812
-#else
35813
- *pResult = 1.0e308*10.0;
35814
-#endif
35815
- }else{
35816
- *pResult = (double)r;
35817
- }
35818
- }else{
35819
- double rr[2];
35820
- u64 s2;
35821
- rr[0] = (double)s;
35822
- s2 = (u64)rr[0];
35791
+ rr[0] = (double)s;
35792
+ s2 = (u64)rr[0];
3582335793
#if defined(_MSC_VER) && _MSC_VER<1700
35824
- if( s2==0x8000000000000000LL ){ s2 = 2*(u64)(0.5*rr[0]); }
35794
+ if( s2==0x8000000000000000LL ){ s2 = 2*(u64)(0.5*rr[0]); }
3582535795
#endif
35826
- rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s);
35827
- if( e>0 ){
35828
- while( e>=100 ){
35829
- e -= 100;
35830
- dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83);
35831
- }
35832
- while( e>=10 ){
35833
- e -= 10;
35834
- dekkerMul2(rr, 1.0e+10, 0.0);
35835
- }
35836
- while( e>=1 ){
35837
- e -= 1;
35838
- dekkerMul2(rr, 1.0e+01, 0.0);
35839
- }
35840
- }else{
35841
- while( e<=-100 ){
35842
- e += 100;
35843
- dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117);
35844
- }
35845
- while( e<=-10 ){
35846
- e += 10;
35847
- dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27);
35848
- }
35849
- while( e<=-1 ){
35850
- e += 1;
35851
- dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18);
35852
- }
35853
- }
35854
- *pResult = rr[0]+rr[1];
35855
- if( sqlite3IsNaN(*pResult) ) *pResult = 1e300*1e300;
35856
- }
35796
+ rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s);
35797
+ if( e>0 ){
35798
+ while( e>=100 ){
35799
+ e -= 100;
35800
+ dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83);
35801
+ }
35802
+ while( e>=10 ){
35803
+ e -= 10;
35804
+ dekkerMul2(rr, 1.0e+10, 0.0);
35805
+ }
35806
+ while( e>=1 ){
35807
+ e -= 1;
35808
+ dekkerMul2(rr, 1.0e+01, 0.0);
35809
+ }
35810
+ }else{
35811
+ while( e<=-100 ){
35812
+ e += 100;
35813
+ dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117);
35814
+ }
35815
+ while( e<=-10 ){
35816
+ e += 10;
35817
+ dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27);
35818
+ }
35819
+ while( e<=-1 ){
35820
+ e += 1;
35821
+ dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18);
35822
+ }
35823
+ }
35824
+ *pResult = rr[0]+rr[1];
35825
+ if( sqlite3IsNaN(*pResult) ) *pResult = 1e300*1e300;
3585735826
if( sign<0 ) *pResult = -*pResult;
3585835827
assert( !sqlite3IsNaN(*pResult) );
3585935828
3586035829
atof_return:
3586135830
/* return true if number and no extra non-whitespace characters after */
@@ -36172,13 +36141,14 @@
3617236141
*/
3617336142
SQLITE_PRIVATE void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){
3617436143
int i;
3617536144
u64 v;
3617636145
int e, exp = 0;
36146
+ double rr[2];
36147
+
3617736148
p->isSpecial = 0;
3617836149
p->z = p->zBuf;
36179
-
3618036150
assert( mxRound>0 );
3618136151
3618236152
/* Convert negative numbers to positive. Deal with Infinity, 0.0, and
3618336153
** NaN. */
3618436154
if( r<0.0 ){
@@ -36202,66 +36172,49 @@
3620236172
return;
3620336173
}
3620436174
3620536175
/* Multiply r by powers of ten until it lands somewhere in between
3620636176
** 1.0e+19 and 1.0e+17.
36207
- */
36208
- if( sqlite3Config.bUseLongDouble ){
36209
- LONGDOUBLE_TYPE rr = r;
36210
- if( rr>=1.0e+19 ){
36211
- while( rr>=1.0e+119L ){ exp+=100; rr *= 1.0e-100L; }
36212
- while( rr>=1.0e+29L ){ exp+=10; rr *= 1.0e-10L; }
36213
- while( rr>=1.0e+19L ){ exp++; rr *= 1.0e-1L; }
36214
- }else{
36215
- while( rr<1.0e-97L ){ exp-=100; rr *= 1.0e+100L; }
36216
- while( rr<1.0e+07L ){ exp-=10; rr *= 1.0e+10L; }
36217
- while( rr<1.0e+17L ){ exp--; rr *= 1.0e+1L; }
36218
- }
36219
- v = (u64)rr;
36220
- }else{
36221
- /* If high-precision floating point is not available using "long double",
36222
- ** then use Dekker-style double-double computation to increase the
36223
- ** precision.
36224
- **
36225
- ** The error terms on constants like 1.0e+100 computed using the
36226
- ** decimal extension, for example as follows:
36227
- **
36228
- ** SELECT decimal_exp(decimal_sub('1.0e+100',decimal(1.0e+100)));
36229
- */
36230
- double rr[2];
36231
- rr[0] = r;
36232
- rr[1] = 0.0;
36233
- if( rr[0]>9.223372036854774784e+18 ){
36234
- while( rr[0]>9.223372036854774784e+118 ){
36235
- exp += 100;
36236
- dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117);
36237
- }
36238
- while( rr[0]>9.223372036854774784e+28 ){
36239
- exp += 10;
36240
- dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27);
36241
- }
36242
- while( rr[0]>9.223372036854774784e+18 ){
36243
- exp += 1;
36244
- dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18);
36245
- }
36246
- }else{
36247
- while( rr[0]<9.223372036854774784e-83 ){
36248
- exp -= 100;
36249
- dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83);
36250
- }
36251
- while( rr[0]<9.223372036854774784e+07 ){
36252
- exp -= 10;
36253
- dekkerMul2(rr, 1.0e+10, 0.0);
36254
- }
36255
- while( rr[0]<9.22337203685477478e+17 ){
36256
- exp -= 1;
36257
- dekkerMul2(rr, 1.0e+01, 0.0);
36258
- }
36259
- }
36260
- v = rr[1]<0.0 ? (u64)rr[0]-(u64)(-rr[1]) : (u64)rr[0]+(u64)rr[1];
36261
- }
36262
-
36177
+ **
36178
+ ** Use Dekker-style double-double computation to increase the
36179
+ ** precision.
36180
+ **
36181
+ ** The error terms on constants like 1.0e+100 computed using the
36182
+ ** decimal extension, for example as follows:
36183
+ **
36184
+ ** SELECT decimal_exp(decimal_sub('1.0e+100',decimal(1.0e+100)));
36185
+ */
36186
+ rr[0] = r;
36187
+ rr[1] = 0.0;
36188
+ if( rr[0]>9.223372036854774784e+18 ){
36189
+ while( rr[0]>9.223372036854774784e+118 ){
36190
+ exp += 100;
36191
+ dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117);
36192
+ }
36193
+ while( rr[0]>9.223372036854774784e+28 ){
36194
+ exp += 10;
36195
+ dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27);
36196
+ }
36197
+ while( rr[0]>9.223372036854774784e+18 ){
36198
+ exp += 1;
36199
+ dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18);
36200
+ }
36201
+ }else{
36202
+ while( rr[0]<9.223372036854774784e-83 ){
36203
+ exp -= 100;
36204
+ dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83);
36205
+ }
36206
+ while( rr[0]<9.223372036854774784e+07 ){
36207
+ exp -= 10;
36208
+ dekkerMul2(rr, 1.0e+10, 0.0);
36209
+ }
36210
+ while( rr[0]<9.22337203685477478e+17 ){
36211
+ exp -= 1;
36212
+ dekkerMul2(rr, 1.0e+01, 0.0);
36213
+ }
36214
+ }
36215
+ v = rr[1]<0.0 ? (u64)rr[0]-(u64)(-rr[1]) : (u64)rr[0]+(u64)rr[1];
3626336216
3626436217
/* Extract significant digits. */
3626536218
i = sizeof(p->zBuf)-1;
3626636219
assert( v>0 );
3626736220
while( v ){ p->zBuf[i--] = (v%10) + '0'; v /= 10; }
@@ -65688,10 +65641,11 @@
6568865641
int nSehTry; /* Number of nested SEH_TRY{} blocks */
6568965642
u8 lockError; /* True if a locking error has occurred */
6569065643
#endif
6569165644
#ifdef SQLITE_ENABLE_SNAPSHOT
6569265645
WalIndexHdr *pSnapshot; /* Start transaction here if not NULL */
65646
+ int bGetSnapshot; /* Transaction opened for sqlite3_get_snapshot() */
6569365647
#endif
6569465648
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
6569565649
sqlite3 *db;
6569665650
#endif
6569765651
};
@@ -68244,11 +68198,11 @@
6824468198
assert( pWal->apWiData[0]!=0 );
6824568199
pInfo = walCkptInfo(pWal);
6824668200
SEH_INJECT_FAULT;
6824768201
if( !useWal && AtomicLoad(&pInfo->nBackfill)==pWal->hdr.mxFrame
6824868202
#ifdef SQLITE_ENABLE_SNAPSHOT
68249
- && (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0)
68203
+ && ((pWal->bGetSnapshot==0 && pWal->pSnapshot==0) || pWal->hdr.mxFrame==0)
6825068204
#endif
6825168205
){
6825268206
/* The WAL has been completely backfilled (or it is empty).
6825368207
** and can be safely ignored.
6825468208
*/
@@ -69644,11 +69598,24 @@
6964469598
*/
6964569599
SQLITE_PRIVATE void sqlite3WalSnapshotOpen(
6964669600
Wal *pWal,
6964769601
sqlite3_snapshot *pSnapshot
6964869602
){
69649
- pWal->pSnapshot = (WalIndexHdr*)pSnapshot;
69603
+ if( pSnapshot && ((WalIndexHdr*)pSnapshot)->iVersion==0 ){
69604
+ /* iVersion==0 means that this is a call to sqlite3_snapshot_get(). In
69605
+ ** this case set the bGetSnapshot flag so that if the call to
69606
+ ** sqlite3_snapshot_get() is about to read transaction on this wal
69607
+ ** file, it does not take read-lock 0 if the wal file has been completely
69608
+ ** checkpointed. Taking read-lock 0 would work, but then it would be
69609
+ ** possible for a subsequent writer to destroy the snapshot even while
69610
+ ** this connection is holding its read-transaction open. This is contrary
69611
+ ** to user expectations, so we avoid it by not taking read-lock 0. */
69612
+ pWal->bGetSnapshot = 1;
69613
+ }else{
69614
+ pWal->pSnapshot = (WalIndexHdr*)pSnapshot;
69615
+ pWal->bGetSnapshot = 0;
69616
+ }
6965069617
}
6965169618
6965269619
/*
6965369620
** Return a +ve value if snapshot p1 is newer than p2. A -ve value if
6965469621
** p1 is older than p2 and zero if p1 and p2 are the same snapshot.
@@ -89592,11 +89559,11 @@
8959289559
/* The following two functions are used only within testcase() to prove
8959389560
** test coverage. These functions do no exist for production builds.
8959489561
** We must use separate SQLITE_NOINLINE functions here, since otherwise
8959589562
** optimizer code movement causes gcov to become very confused.
8959689563
*/
89597
-#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG)
89564
+#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG)
8959889565
static int SQLITE_NOINLINE doubleLt(double a, double b){ return a<b; }
8959989566
static int SQLITE_NOINLINE doubleEq(double a, double b){ return a==b; }
8960089567
#endif
8960189568
8960289569
/*
@@ -89607,17 +89574,10 @@
8960789574
SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){
8960889575
if( sqlite3IsNaN(r) ){
8960989576
/* SQLite considers NaN to be a NULL. And all integer values are greater
8961089577
** than NULL */
8961189578
return 1;
89612
- }
89613
- if( sqlite3Config.bUseLongDouble ){
89614
- LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i;
89615
- testcase( x<r );
89616
- testcase( x>r );
89617
- testcase( x==r );
89618
- return (x<r) ? -1 : (x>r);
8961989579
}else{
8962089580
i64 y;
8962189581
if( r<-9223372036854775808.0 ) return +1;
8962289582
if( r>=9223372036854775808.0 ) return -1;
8962389583
y = (i64)r;
@@ -131787,11 +131747,17 @@
131787131747
#ifdef SQLITE_DEBUG
131788131748
/*
131789131749
** Implementation of fpdecode(x,y,z) function.
131790131750
**
131791131751
** x is a real number that is to be decoded. y is the precision.
131792
-** z is the maximum real precision.
131752
+** z is the maximum real precision. Return a string that shows the
131753
+** results of the sqlite3FpDecode() function.
131754
+**
131755
+** Used for testing and debugging only, specifically testing and debugging
131756
+** of the sqlite3FpDecode() function. This SQL function does not appear
131757
+** in production builds. This function is not an API and is subject to
131758
+** modification or removal in future versions of SQLite.
131793131759
*/
131794131760
static void fpdecodeFunc(
131795131761
sqlite3_context *context,
131796131762
int argc,
131797131763
sqlite3_value **argv
@@ -131811,10 +131777,86 @@
131811131777
sqlite3_snprintf(sizeof(zBuf), zBuf, "NaN");
131812131778
}else{
131813131779
sqlite3_snprintf(sizeof(zBuf), zBuf, "%c%.*s/%d", s.sign, s.n, s.z, s.iDP);
131814131780
}
131815131781
sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
131782
+}
131783
+#endif /* SQLITE_DEBUG */
131784
+
131785
+#ifdef SQLITE_DEBUG
131786
+/*
131787
+** Implementation of parseuri(uri,flags) function.
131788
+**
131789
+** Required Arguments:
131790
+** "uri" The URI to parse.
131791
+** "flags" Bitmask of flags, as if to sqlite3_open_v2().
131792
+**
131793
+** Additional arguments beyond the first two make calls to
131794
+** sqlite3_uri_key() for integers and sqlite3_uri_parameter for
131795
+** anything else.
131796
+**
131797
+** The result is a string showing the results of calling sqlite3ParseUri().
131798
+**
131799
+** Used for testing and debugging only, specifically testing and debugging
131800
+** of the sqlite3ParseUri() function. This SQL function does not appear
131801
+** in production builds. This function is not an API and is subject to
131802
+** modification or removal in future versions of SQLite.
131803
+*/
131804
+static void parseuriFunc(
131805
+ sqlite3_context *ctx,
131806
+ int argc,
131807
+ sqlite3_value **argv
131808
+){
131809
+ sqlite3_str *pResult;
131810
+ const char *zVfs;
131811
+ const char *zUri;
131812
+ unsigned int flgs;
131813
+ int rc;
131814
+ sqlite3_vfs *pVfs = 0;
131815
+ char *zFile = 0;
131816
+ char *zErr = 0;
131817
+
131818
+ if( argc<2 ) return;
131819
+ pVfs = sqlite3_vfs_find(0);
131820
+ assert( pVfs );
131821
+ zVfs = pVfs->zName;
131822
+ zUri = (const char*)sqlite3_value_text(argv[0]);
131823
+ if( zUri==0 ) return;
131824
+ flgs = (unsigned int)sqlite3_value_int(argv[1]);
131825
+ rc = sqlite3ParseUri(zVfs, zUri, &flgs, &pVfs, &zFile, &zErr);
131826
+ pResult = sqlite3_str_new(0);
131827
+ if( pResult ){
131828
+ int i;
131829
+ sqlite3_str_appendf(pResult, "rc=%d", rc);
131830
+ sqlite3_str_appendf(pResult, ", flags=0x%x", flgs);
131831
+ sqlite3_str_appendf(pResult, ", vfs=%Q", pVfs ? pVfs->zName: 0);
131832
+ sqlite3_str_appendf(pResult, ", err=%Q", zErr);
131833
+ sqlite3_str_appendf(pResult, ", file=%Q", zFile);
131834
+ if( zFile ){
131835
+ const char *z = zFile;
131836
+ z += sqlite3Strlen30(z)+1;
131837
+ while( z[0] ){
131838
+ sqlite3_str_appendf(pResult, ", %Q", z);
131839
+ z += sqlite3Strlen30(z)+1;
131840
+ }
131841
+ for(i=2; i<argc; i++){
131842
+ const char *zArg;
131843
+ if( sqlite3_value_type(argv[i])==SQLITE_INTEGER ){
131844
+ int k = sqlite3_value_int(argv[i]);
131845
+ sqlite3_str_appendf(pResult, ", '%d:%q'",k,sqlite3_uri_key(zFile, k));
131846
+ }else if( (zArg = (const char*)sqlite3_value_text(argv[i]))!=0 ){
131847
+ sqlite3_str_appendf(pResult, ", '%q:%q'",
131848
+ zArg, sqlite3_uri_parameter(zFile,zArg));
131849
+ }else{
131850
+ sqlite3_str_appendf(pResult, ", NULL");
131851
+ }
131852
+ }
131853
+ }
131854
+ sqlite3_result_text(ctx, sqlite3_str_finish(pResult), -1, sqlite3_free);
131855
+ }
131856
+ sqlite3_free_filename(zFile);
131857
+ sqlite3_free(zErr);
131816131858
}
131817131859
#endif /* SQLITE_DEBUG */
131818131860
131819131861
/*
131820131862
** All of the FuncDef structures in the aBuiltinFunc[] array above
@@ -131887,10 +131929,11 @@
131887131929
FUNCTION(unicode, 1, 0, 0, unicodeFunc ),
131888131930
FUNCTION(char, -1, 0, 0, charFunc ),
131889131931
FUNCTION(abs, 1, 0, 0, absFunc ),
131890131932
#ifdef SQLITE_DEBUG
131891131933
FUNCTION(fpdecode, 3, 0, 0, fpdecodeFunc ),
131934
+ FUNCTION(parseuri, -1, 0, 0, parseuriFunc ),
131892131935
#endif
131893131936
#ifndef SQLITE_OMIT_FLOATING_POINT
131894131937
FUNCTION(round, 1, 0, 0, roundFunc ),
131895131938
FUNCTION(round, 2, 0, 0, roundFunc ),
131896131939
#endif
@@ -141115,10 +141158,11 @@
141115141158
}
141116141159
aRoot[0] = cnt;
141117141160
141118141161
/* Make sure sufficient number of registers have been allocated */
141119141162
sqlite3TouchRegister(pParse, 8+cnt);
141163
+ sqlite3VdbeAddOp3(v, OP_Null, 0, 8, 8+cnt);
141120141164
sqlite3ClearTempRegCache(pParse);
141121141165
141122141166
/* Do the b-tree integrity checks */
141123141167
sqlite3VdbeAddOp4(v, OP_IntegrityCk, 1, cnt, 8, (char*)aRoot,P4_INTARRAY);
141124141168
sqlite3VdbeChangeP5(v, (u8)i);
@@ -161344,24 +161388,29 @@
161344161388
}else if( op==TK_STRING ){
161345161389
assert( !ExprHasProperty(pRight, EP_IntValue) );
161346161390
z = (u8*)pRight->u.zToken;
161347161391
}
161348161392
if( z ){
161349
-
161350
- /* Count the number of prefix characters prior to the first wildcard.
161351
- ** If the underlying database has a UTF16LE encoding, then only consider
161352
- ** ASCII characters. Note that the encoding of z[] is UTF8 - we are
161353
- ** dealing with only UTF8 here in this code, but the database engine
161354
- ** itself might be processing content using a different encoding. */
161393
+ /* Count the number of prefix bytes prior to the first wildcard.
161394
+ ** or U+fffd character. If the underlying database has a UTF16LE
161395
+ ** encoding, then only consider ASCII characters. Note that the
161396
+ ** encoding of z[] is UTF8 - we are dealing with only UTF8 here in
161397
+ ** this code, but the database engine itself might be processing
161398
+ ** content using a different encoding. */
161355161399
cnt = 0;
161356161400
while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
161357161401
cnt++;
161358161402
if( c==wc[3] && z[cnt]!=0 ){
161359161403
cnt++;
161360
- }else if( c>=0x80 && ENC(db)==SQLITE_UTF16LE ){
161361
- cnt--;
161362
- break;
161404
+ }else if( c>=0x80 ){
161405
+ const u8 *z2 = z+cnt-1;
161406
+ if( sqlite3Utf8Read(&z2)==0xfffd || ENC(db)==SQLITE_UTF16LE ){
161407
+ cnt--;
161408
+ break;
161409
+ }else{
161410
+ cnt = (int)(z2-z);
161411
+ }
161363161412
}
161364161413
}
161365161414
161366161415
/* The optimization is possible only if (1) the pattern does not begin
161367161416
** with a wildcard and if (2) the non-wildcard prefix does not end with
@@ -161369,11 +161418,11 @@
161369161418
** a single escape character. The second condition is necessary so
161370161419
** that we can increment the prefix key to find an upper bound for the
161371161420
** range search. The third is because the caller assumes that the pattern
161372161421
** consists of at least one character after all escapes have been
161373161422
** removed. */
161374
- if( (cnt>1 || (cnt>0 && z[0]!=wc[3])) && 255!=(u8)z[cnt-1] ){
161423
+ if( (cnt>1 || (cnt>0 && z[0]!=wc[3])) && ALWAYS(255!=(u8)z[cnt-1]) ){
161375161424
Expr *pPrefix;
161376161425
161377161426
/* A "complete" match if the pattern ends with "*" or "%" */
161378161427
*pisComplete = c==wc[0] && z[cnt+1]==0 && ENC(db)!=SQLITE_UTF16LE;
161379161428
@@ -181161,36 +181210,10 @@
181161181210
** all database files specified with a relative pathname.
181162181211
**
181163181212
** See also the "PRAGMA data_store_directory" SQL command.
181164181213
*/
181165181214
SQLITE_API char *sqlite3_data_directory = 0;
181166
-
181167
-/*
181168
-** Determine whether or not high-precision (long double) floating point
181169
-** math works correctly on CPU currently running.
181170
-*/
181171
-static SQLITE_NOINLINE int hasHighPrecisionDouble(int rc){
181172
- if( sizeof(LONGDOUBLE_TYPE)<=8 ){
181173
- /* If the size of "long double" is not more than 8, then
181174
- ** high-precision math is not possible. */
181175
- return 0;
181176
- }else{
181177
- /* Just because sizeof(long double)>8 does not mean that the underlying
181178
- ** hardware actually supports high-precision floating point. For example,
181179
- ** clearing the 0x100 bit in the floating-point control word on Intel
181180
- ** processors will make long double work like double, even though long
181181
- ** double takes up more space. The only way to determine if long double
181182
- ** actually works is to run an experiment. */
181183
- LONGDOUBLE_TYPE a, b, c;
181184
- rc++;
181185
- a = 1.0+rc*0.1;
181186
- b = 1.0e+18+rc*25.0;
181187
- c = a+b;
181188
- return b!=c;
181189
- }
181190
-}
181191
-
181192181215
181193181216
/*
181194181217
** Initialize SQLite.
181195181218
**
181196181219
** This routine must be called to initialize the memory allocation,
@@ -181382,17 +181405,10 @@
181382181405
if( bRunExtraInit ){
181383181406
int SQLITE_EXTRA_INIT(const char*);
181384181407
rc = SQLITE_EXTRA_INIT(0);
181385181408
}
181386181409
#endif
181387
-
181388
- /* Experimentally determine if high-precision floating point is
181389
- ** available. */
181390
-#ifndef SQLITE_OMIT_WSD
181391
- sqlite3Config.bUseLongDouble = hasHighPrecisionDouble(rc);
181392
-#endif
181393
-
181394181410
return rc;
181395181411
}
181396181412
181397181413
/*
181398181414
** Undo the effects of sqlite3_initialize(). Must not be called while
@@ -185640,28 +185656,10 @@
185640185656
*pI1 = rLogEst;
185641185657
*pU64 = sqlite3LogEstToInt(rLogEst);
185642185658
*pI2 = sqlite3LogEst(*pU64);
185643185659
break;
185644185660
}
185645
-
185646
-#if !defined(SQLITE_OMIT_WSD)
185647
- /* sqlite3_test_control(SQLITE_TESTCTRL_USELONGDOUBLE, int X);
185648
- **
185649
- ** X<0 Make no changes to the bUseLongDouble. Just report value.
185650
- ** X==0 Disable bUseLongDouble
185651
- ** X==1 Enable bUseLongDouble
185652
- ** X>=2 Set bUseLongDouble to its default value for this platform
185653
- */
185654
- case SQLITE_TESTCTRL_USELONGDOUBLE: {
185655
- int b = va_arg(ap, int);
185656
- if( b>=2 ) b = hasHighPrecisionDouble(b);
185657
- if( b>=0 ) sqlite3Config.bUseLongDouble = b>0;
185658
- rc = sqlite3Config.bUseLongDouble!=0;
185659
- break;
185660
- }
185661
-#endif
185662
-
185663185661
185664185662
#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD)
185665185663
/* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue)
185666185664
**
185667185665
** If "id" is an integer between 1 and SQLITE_NTUNE then set the value
@@ -185966,11 +185964,15 @@
185966185964
if( db->autoCommit==0 ){
185967185965
int iDb = sqlite3FindDbName(db, zDb);
185968185966
if( iDb==0 || iDb>1 ){
185969185967
Btree *pBt = db->aDb[iDb].pBt;
185970185968
if( SQLITE_TXN_WRITE!=sqlite3BtreeTxnState(pBt) ){
185969
+ Pager *pPager = sqlite3BtreePager(pBt);
185970
+ i64 dummy = 0;
185971
+ sqlite3PagerSnapshotOpen(pPager, (sqlite3_snapshot*)&dummy);
185971185972
rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
185973
+ sqlite3PagerSnapshotOpen(pPager, 0);
185972185974
if( rc==SQLITE_OK ){
185973185975
rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);
185974185976
}
185975185977
}
185976185978
}
@@ -225801,12 +225803,12 @@
225801225803
};
225802225804
225803225805
struct DbpageTable {
225804225806
sqlite3_vtab base; /* Base class. Must be first */
225805225807
sqlite3 *db; /* The database */
225806
- int nTrunc; /* Entries in aTrunc[] */
225807
- Pgno *aTrunc; /* Truncation size for each database */
225808
+ int iDbTrunc; /* Database to truncate */
225809
+ Pgno pgnoTrunc; /* Size to truncate to */
225808225810
};
225809225811
225810225812
/* Columns */
225811225813
#define DBPAGE_COLUMN_PGNO 0
225812225814
#define DBPAGE_COLUMN_DATA 1
@@ -225851,12 +225853,10 @@
225851225853
225852225854
/*
225853225855
** Disconnect from or destroy a dbpagevfs virtual table.
225854225856
*/
225855225857
static int dbpageDisconnect(sqlite3_vtab *pVtab){
225856
- DbpageTable *pTab = (DbpageTable *)pVtab;
225857
- sqlite3_free(pTab->aTrunc);
225858225858
sqlite3_free(pVtab);
225859225859
return SQLITE_OK;
225860225860
}
225861225861
225862225862
/*
@@ -226119,23 +226119,16 @@
226119226119
}
226120226120
szPage = sqlite3BtreeGetPageSize(pBt);
226121226121
if( sqlite3_value_type(argv[3])!=SQLITE_BLOB
226122226122
|| sqlite3_value_bytes(argv[3])!=szPage
226123226123
){
226124
- if( sqlite3_value_type(argv[3])==SQLITE_NULL && isInsert ){
226125
- if( iDb>=pTab->nTrunc ){
226126
- testcase( pTab->aTrunc!=0 );
226127
- pTab->aTrunc = sqlite3_realloc(pTab->aTrunc, (iDb+1)*sizeof(Pgno));
226128
- if( pTab->aTrunc ){
226129
- int j;
226130
- for(j=pTab->nTrunc; j<iDb; j++) pTab->aTrunc[j] = 0;
226131
- pTab->nTrunc = iDb+1;
226132
- }else{
226133
- return SQLITE_NOMEM;
226134
- }
226135
- }
226136
- pTab->aTrunc[iDb] = pgno;
226124
+ if( sqlite3_value_type(argv[3])==SQLITE_NULL && isInsert && pgno>1 ){
226125
+ /* "INSERT INTO dbpage($PGNO,NULL)" causes page number $PGNO and
226126
+ ** all subsequent pages to be deleted. */
226127
+ pTab->iDbTrunc = iDb;
226128
+ pgno--;
226129
+ pTab->pgnoTrunc = pgno;
226137226130
}else{
226138226131
zErr = "bad page value";
226139226132
goto update_fail;
226140226133
}
226141226134
}
@@ -226144,10 +226137,11 @@
226144226137
if( rc==SQLITE_OK ){
226145226138
const void *pData = sqlite3_value_blob(argv[3]);
226146226139
if( (rc = sqlite3PagerWrite(pDbPage))==SQLITE_OK && pData ){
226147226140
unsigned char *aPage = sqlite3PagerGetData(pDbPage);
226148226141
memcpy(aPage, pData, szPage);
226142
+ pTab->pgnoTrunc = 0;
226149226143
}
226150226144
}
226151226145
sqlite3PagerUnref(pDbPage);
226152226146
return rc;
226153226147
@@ -226167,33 +226161,35 @@
226167226161
int i;
226168226162
for(i=0; i<db->nDb; i++){
226169226163
Btree *pBt = db->aDb[i].pBt;
226170226164
if( pBt ) (void)sqlite3BtreeBeginTrans(pBt, 1, 0);
226171226165
}
226172
- if( pTab->nTrunc>0 ){
226173
- memset(pTab->aTrunc, 0, sizeof(pTab->aTrunc[0])*pTab->nTrunc);
226174
- }
226166
+ pTab->pgnoTrunc = 0;
226175226167
return SQLITE_OK;
226176226168
}
226177226169
226178226170
/* Invoke sqlite3PagerTruncate() as necessary, just prior to COMMIT
226179226171
*/
226180226172
static int dbpageSync(sqlite3_vtab *pVtab){
226181
- int iDb;
226173
+ DbpageTable *pTab = (DbpageTable *)pVtab;
226174
+ if( pTab->pgnoTrunc>0 ){
226175
+ Btree *pBt = pTab->db->aDb[pTab->iDbTrunc].pBt;
226176
+ Pager *pPager = sqlite3BtreePager(pBt);
226177
+ sqlite3PagerTruncateImage(pPager, pTab->pgnoTrunc);
226178
+ }
226179
+ pTab->pgnoTrunc = 0;
226180
+ return SQLITE_OK;
226181
+}
226182
+
226183
+/* Cancel any pending truncate.
226184
+*/
226185
+static int dbpageRollbackTo(sqlite3_vtab *pVtab, int notUsed1){
226182226186
DbpageTable *pTab = (DbpageTable *)pVtab;
226183
-
226184
- for(iDb=0; iDb<pTab->nTrunc; iDb++){
226185
- if( pTab->aTrunc[iDb]>0 ){
226186
- Btree *pBt = pTab->db->aDb[iDb].pBt;
226187
- Pager *pPager = sqlite3BtreePager(pBt);
226188
- sqlite3PagerTruncateImage(pPager, pTab->aTrunc[iDb]);
226189
- pTab->aTrunc[iDb] = 0;
226190
- }
226191
- }
226187
+ pTab->pgnoTrunc = 0;
226188
+ (void)notUsed1;
226192226189
return SQLITE_OK;
226193226190
}
226194
-
226195226191
226196226192
/*
226197226193
** Invoke this routine to register the "dbpage" virtual table module
226198226194
*/
226199226195
SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){
@@ -226218,11 +226214,11 @@
226218226214
0, /* xRollback */
226219226215
0, /* xFindMethod */
226220226216
0, /* xRename */
226221226217
0, /* xSavepoint */
226222226218
0, /* xRelease */
226223
- 0, /* xRollbackTo */
226219
+ dbpageRollbackTo, /* xRollbackTo */
226224226220
0, /* xShadowName */
226225226221
0 /* xIntegrity */
226226226222
};
226227226223
return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0);
226228226224
}
@@ -233747,10 +233743,11 @@
233747233743
u8 *abUnindexed; /* True for unindexed columns */
233748233744
int nPrefix; /* Number of prefix indexes */
233749233745
int *aPrefix; /* Sizes in bytes of nPrefix prefix indexes */
233750233746
int eContent; /* An FTS5_CONTENT value */
233751233747
int bContentlessDelete; /* "contentless_delete=" option (dflt==0) */
233748
+ int bContentlessUnindexed; /* "contentless_unindexed=" option (dflt=0) */
233752233749
char *zContent; /* content table */
233753233750
char *zContentRowid; /* "content_rowid=" option value */
233754233751
int bColumnsize; /* "columnsize=" option value (dflt==1) */
233755233752
int bTokendata; /* "tokendata=" option value (dflt==0) */
233756233753
int bLocale; /* "locale=" option value (dflt==0) */
@@ -233785,13 +233782,14 @@
233785233782
** the expected version if the 'secure-delete' option has ever been
233786233783
** set on the table. */
233787233784
#define FTS5_CURRENT_VERSION 4
233788233785
#define FTS5_CURRENT_VERSION_SECUREDELETE 5
233789233786
233790
-#define FTS5_CONTENT_NORMAL 0
233791
-#define FTS5_CONTENT_NONE 1
233792
-#define FTS5_CONTENT_EXTERNAL 2
233787
+#define FTS5_CONTENT_NORMAL 0
233788
+#define FTS5_CONTENT_NONE 1
233789
+#define FTS5_CONTENT_EXTERNAL 2
233790
+#define FTS5_CONTENT_UNINDEXED 3
233793233791
233794233792
#define FTS5_DETAIL_FULL 0
233795233793
#define FTS5_DETAIL_NONE 1
233796233794
#define FTS5_DETAIL_COLUMNS 2
233797233795
@@ -234247,11 +234245,11 @@
234247234245
234248234246
static int sqlite3Fts5DropAll(Fts5Config*);
234249234247
static int sqlite3Fts5CreateTable(Fts5Config*, const char*, const char*, int, char **);
234250234248
234251234249
static int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**, int);
234252
-static int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*);
234250
+static int sqlite3Fts5StorageContentInsert(Fts5Storage *p, int, sqlite3_value**, i64*);
234253234251
static int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64);
234254234252
234255234253
static int sqlite3Fts5StorageIntegrity(Fts5Storage *p, int iArg);
234256234254
234257234255
static int sqlite3Fts5StorageStmt(Fts5Storage *p, int eStmt, sqlite3_stmt**, char**);
@@ -237454,10 +237452,11 @@
237454237452
const char *zArg, /* Argument to parse */
237455237453
char **pzErr /* OUT: Error message */
237456237454
){
237457237455
int rc = SQLITE_OK;
237458237456
int nCmd = (int)strlen(zCmd);
237457
+
237459237458
if( sqlite3_strnicmp("prefix", zCmd, nCmd)==0 ){
237460237459
const int nByte = sizeof(int) * FTS5_MAX_PREFIX_INDEXES;
237461237460
const char *p;
237462237461
int bFirst = 1;
237463237462
if( pConfig->aPrefix==0 ){
@@ -237572,10 +237571,20 @@
237572237571
}else{
237573237572
pConfig->bContentlessDelete = (zArg[0]=='1');
237574237573
}
237575237574
return rc;
237576237575
}
237576
+
237577
+ if( sqlite3_strnicmp("contentless_unindexed", zCmd, nCmd)==0 ){
237578
+ if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1]!='\0' ){
237579
+ *pzErr = sqlite3_mprintf("malformed contentless_delete=... directive");
237580
+ rc = SQLITE_ERROR;
237581
+ }else{
237582
+ pConfig->bContentlessUnindexed = (zArg[0]=='1');
237583
+ }
237584
+ return rc;
237585
+ }
237577237586
237578237587
if( sqlite3_strnicmp("content_rowid", zCmd, nCmd)==0 ){
237579237588
if( pConfig->zContentRowid ){
237580237589
*pzErr = sqlite3_mprintf("multiple content_rowid=... directives");
237581237590
rc = SQLITE_ERROR;
@@ -237690,11 +237699,12 @@
237690237699
237691237700
static int fts5ConfigParseColumn(
237692237701
Fts5Config *p,
237693237702
char *zCol,
237694237703
char *zArg,
237695
- char **pzErr
237704
+ char **pzErr,
237705
+ int *pbUnindexed
237696237706
){
237697237707
int rc = SQLITE_OK;
237698237708
if( 0==sqlite3_stricmp(zCol, FTS5_RANK_NAME)
237699237709
|| 0==sqlite3_stricmp(zCol, FTS5_ROWID_NAME)
237700237710
){
@@ -237701,10 +237711,11 @@
237701237711
*pzErr = sqlite3_mprintf("reserved fts5 column name: %s", zCol);
237702237712
rc = SQLITE_ERROR;
237703237713
}else if( zArg ){
237704237714
if( 0==sqlite3_stricmp(zArg, "unindexed") ){
237705237715
p->abUnindexed[p->nCol] = 1;
237716
+ *pbUnindexed = 1;
237706237717
}else{
237707237718
*pzErr = sqlite3_mprintf("unrecognized column option: %s", zArg);
237708237719
rc = SQLITE_ERROR;
237709237720
}
237710237721
}
@@ -237721,15 +237732,21 @@
237721237732
int rc = SQLITE_OK;
237722237733
Fts5Buffer buf = {0, 0, 0};
237723237734
237724237735
sqlite3Fts5BufferAppendPrintf(&rc, &buf, "T.%Q", p->zContentRowid);
237725237736
if( p->eContent!=FTS5_CONTENT_NONE ){
237737
+ assert( p->eContent==FTS5_CONTENT_EXTERNAL
237738
+ || p->eContent==FTS5_CONTENT_NORMAL
237739
+ || p->eContent==FTS5_CONTENT_UNINDEXED
237740
+ );
237726237741
for(i=0; i<p->nCol; i++){
237727237742
if( p->eContent==FTS5_CONTENT_EXTERNAL ){
237728237743
sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", T.%Q", p->azCol[i]);
237729
- }else{
237744
+ }else if( p->eContent==FTS5_CONTENT_NORMAL || p->abUnindexed[i] ){
237730237745
sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", T.c%d", i);
237746
+ }else{
237747
+ sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", NULL");
237731237748
}
237732237749
}
237733237750
}
237734237751
if( p->eContent==FTS5_CONTENT_NORMAL && p->bLocale ){
237735237752
for(i=0; i<p->nCol; i++){
@@ -237768,10 +237785,11 @@
237768237785
){
237769237786
int rc = SQLITE_OK; /* Return code */
237770237787
Fts5Config *pRet; /* New object to return */
237771237788
int i;
237772237789
sqlite3_int64 nByte;
237790
+ int bUnindexed = 0; /* True if there are one or more UNINDEXED */
237773237791
237774237792
*ppOut = pRet = (Fts5Config*)sqlite3_malloc(sizeof(Fts5Config));
237775237793
if( pRet==0 ) return SQLITE_NOMEM;
237776237794
memset(pRet, 0, sizeof(Fts5Config));
237777237795
pRet->pGlobal = pGlobal;
@@ -237827,11 +237845,11 @@
237827237845
ALWAYS(zOne)?zOne:"",
237828237846
zTwo?zTwo:"",
237829237847
pzErr
237830237848
);
237831237849
}else{
237832
- rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr);
237850
+ rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr, &bUnindexed);
237833237851
zOne = 0;
237834237852
}
237835237853
}
237836237854
}
237837237855
@@ -237858,18 +237876,34 @@
237858237876
*pzErr = sqlite3_mprintf(
237859237877
"contentless_delete=1 is incompatible with columnsize=0"
237860237878
);
237861237879
rc = SQLITE_ERROR;
237862237880
}
237881
+
237882
+ /* We only allow contentless_unindexed=1 if the table is actually a
237883
+ ** contentless one.
237884
+ */
237885
+ if( rc==SQLITE_OK
237886
+ && pRet->bContentlessUnindexed
237887
+ && pRet->eContent!=FTS5_CONTENT_NONE
237888
+ ){
237889
+ *pzErr = sqlite3_mprintf(
237890
+ "contentless_unindexed=1 requires a contentless table"
237891
+ );
237892
+ rc = SQLITE_ERROR;
237893
+ }
237863237894
237864237895
/* If no zContent option was specified, fill in the default values. */
237865237896
if( rc==SQLITE_OK && pRet->zContent==0 ){
237866237897
const char *zTail = 0;
237867237898
assert( pRet->eContent==FTS5_CONTENT_NORMAL
237868237899
|| pRet->eContent==FTS5_CONTENT_NONE
237869237900
);
237870237901
if( pRet->eContent==FTS5_CONTENT_NORMAL ){
237902
+ zTail = "content";
237903
+ }else if( bUnindexed && pRet->bContentlessUnindexed ){
237904
+ pRet->eContent = FTS5_CONTENT_UNINDEXED;
237871237905
zTail = "content";
237872237906
}else if( pRet->bColumnsize ){
237873237907
zTail = "docsize";
237874237908
}
237875237909
@@ -247040,10 +247074,15 @@
247040247074
if( nPercent>=pConfig->nDeleteMerge && nPercent>nBest ){
247041247075
iRet = ii;
247042247076
nBest = nPercent;
247043247077
}
247044247078
}
247079
+
247080
+ /* If pLvl is already the input level to an ongoing merge, look no
247081
+ ** further for a merge candidate. The caller should be allowed to
247082
+ ** continue merging from pLvl first. */
247083
+ if( pLvl->nMerge ) break;
247045247084
}
247046247085
}
247047247086
return iRet;
247048247087
}
247049247088
@@ -250964,11 +251003,11 @@
250964251003
return rc;
250965251004
}
250966251005
250967251006
/*
250968251007
** We must have a single struct=? constraint that will be passed through
250969
-** into the xFilter method. If there is no valid stmt=? constraint,
251008
+** into the xFilter method. If there is no valid struct=? constraint,
250970251009
** then return an SQLITE_CONSTRAINT error.
250971251010
*/
250972251011
static int fts5structBestIndexMethod(
250973251012
sqlite3_vtab *tab,
250974251013
sqlite3_index_info *pIdxInfo
@@ -251555,14 +251594,20 @@
251555251594
#else
251556251595
# define fts5CheckTransactionState(x,y,z)
251557251596
#endif
251558251597
251559251598
/*
251560
-** Return true if pTab is a contentless table.
251599
+** Return true if pTab is a contentless table. If parameter bIncludeUnindexed
251600
+** is true, this includes contentless tables that store UNINDEXED columns
251601
+** only.
251561251602
*/
251562
-static int fts5IsContentless(Fts5FullTable *pTab){
251563
- return pTab->p.pConfig->eContent==FTS5_CONTENT_NONE;
251603
+static int fts5IsContentless(Fts5FullTable *pTab, int bIncludeUnindexed){
251604
+ int eContent = pTab->p.pConfig->eContent;
251605
+ return (
251606
+ eContent==FTS5_CONTENT_NONE
251607
+ || (bIncludeUnindexed && eContent==FTS5_CONTENT_UNINDEXED)
251608
+ );
251564251609
}
251565251610
251566251611
/*
251567251612
** Delete a virtual table handle allocated by fts5InitVtab().
251568251613
*/
@@ -252949,11 +252994,11 @@
252949252994
}else{
252950252995
rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage);
252951252996
}
252952252997
bLoadConfig = 1;
252953252998
}else if( 0==sqlite3_stricmp("rebuild", zCmd) ){
252954
- if( pConfig->eContent==FTS5_CONTENT_NONE ){
252999
+ if( fts5IsContentless(pTab, 1) ){
252955253000
fts5SetVtabError(pTab,
252956253001
"'rebuild' may not be used with a contentless fts5 table"
252957253002
);
252958253003
rc = SQLITE_ERROR;
252959253004
}else{
@@ -253018,17 +253063,78 @@
253018253063
sqlite3_value **apVal,
253019253064
i64 *piRowid
253020253065
){
253021253066
int rc = *pRc;
253022253067
if( rc==SQLITE_OK ){
253023
- rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, piRowid);
253068
+ rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, 0, apVal, piRowid);
253024253069
}
253025253070
if( rc==SQLITE_OK ){
253026253071
rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *piRowid);
253027253072
}
253028253073
*pRc = rc;
253029253074
}
253075
+
253076
+/*
253077
+**
253078
+** This function is called when the user attempts an UPDATE on a contentless
253079
+** table. Parameter bRowidModified is true if the UPDATE statement modifies
253080
+** the rowid value. Parameter apVal[] contains the new values for each user
253081
+** defined column of the fts5 table. pConfig is the configuration object of the
253082
+** table being updated (guaranteed to be contentless). The contentless_delete=1
253083
+** and contentless_unindexed=1 options may or may not be set.
253084
+**
253085
+** This function returns SQLITE_OK if the UPDATE can go ahead, or an SQLite
253086
+** error code if it cannot. In this case an error message is also loaded into
253087
+** pConfig. Output parameter (*pbContent) is set to true if the caller should
253088
+** update the %_content table only - not the FTS index or any other shadow
253089
+** table. This occurs when an UPDATE modifies only UNINDEXED columns of the
253090
+** table.
253091
+**
253092
+** An UPDATE may proceed if:
253093
+**
253094
+** * The only columns modified are UNINDEXED columns, or
253095
+**
253096
+** * The contentless_delete=1 option was specified and all of the indexed
253097
+** columns (not a subset) have been modified.
253098
+*/
253099
+static int fts5ContentlessUpdate(
253100
+ Fts5Config *pConfig,
253101
+ sqlite3_value **apVal,
253102
+ int bRowidModified,
253103
+ int *pbContent
253104
+){
253105
+ int ii;
253106
+ int bSeenIndex = 0; /* Have seen modified indexed column */
253107
+ int bSeenIndexNC = 0; /* Have seen unmodified indexed column */
253108
+ int rc = SQLITE_OK;
253109
+
253110
+ for(ii=0; ii<pConfig->nCol; ii++){
253111
+ if( pConfig->abUnindexed[ii]==0 ){
253112
+ if( sqlite3_value_nochange(apVal[ii]) ){
253113
+ bSeenIndexNC++;
253114
+ }else{
253115
+ bSeenIndex++;
253116
+ }
253117
+ }
253118
+ }
253119
+
253120
+ if( bSeenIndex==0 && bRowidModified==0 ){
253121
+ *pbContent = 1;
253122
+ }else{
253123
+ if( bSeenIndexNC || pConfig->bContentlessDelete==0 ){
253124
+ rc = SQLITE_ERROR;
253125
+ sqlite3Fts5ConfigErrmsg(pConfig,
253126
+ (pConfig->bContentlessDelete ?
253127
+ "%s a subset of columns on fts5 contentless-delete table: %s" :
253128
+ "%s contentless fts5 table: %s")
253129
+ , "cannot UPDATE", pConfig->zName
253130
+ );
253131
+ }
253132
+ }
253133
+
253134
+ return rc;
253135
+}
253030253136
253031253137
/*
253032253138
** This function is the implementation of the xUpdate callback used by
253033253139
** FTS3 virtual tables. It is invoked by SQLite each time a row is to be
253034253140
** inserted, updated or deleted.
@@ -253112,29 +253218,24 @@
253112253218
}
253113253219
253114253220
assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL );
253115253221
assert( nArg!=1 || eType0==SQLITE_INTEGER );
253116253222
253117
- /* Filter out attempts to run UPDATE or DELETE on contentless tables.
253118
- ** This is not suported. Except - they are both supported if the CREATE
253119
- ** VIRTUAL TABLE statement contained "contentless_delete=1". */
253120
- if( eType0==SQLITE_INTEGER
253121
- && pConfig->eContent==FTS5_CONTENT_NONE
253122
- && pConfig->bContentlessDelete==0
253123
- ){
253124
- pTab->p.base.zErrMsg = sqlite3_mprintf(
253125
- "cannot %s contentless fts5 table: %s",
253126
- (nArg>1 ? "UPDATE" : "DELETE from"), pConfig->zName
253127
- );
253128
- rc = SQLITE_ERROR;
253129
- }
253130
-
253131253223
/* DELETE */
253132
- else if( nArg==1 ){
253133
- i64 iDel = sqlite3_value_int64(apVal[0]); /* Rowid to delete */
253134
- rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0, 0);
253135
- bUpdateOrDelete = 1;
253224
+ if( nArg==1 ){
253225
+ /* It is only possible to DELETE from a contentless table if the
253226
+ ** contentless_delete=1 flag is set. */
253227
+ if( fts5IsContentless(pTab, 1) && pConfig->bContentlessDelete==0 ){
253228
+ fts5SetVtabError(pTab,
253229
+ "cannot DELETE from contentless fts5 table: %s", pConfig->zName
253230
+ );
253231
+ rc = SQLITE_ERROR;
253232
+ }else{
253233
+ i64 iDel = sqlite3_value_int64(apVal[0]); /* Rowid to delete */
253234
+ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0, 0);
253235
+ bUpdateOrDelete = 1;
253236
+ }
253136253237
}
253137253238
253138253239
/* INSERT or UPDATE */
253139253240
else{
253140253241
int eType1 = sqlite3_value_numeric_type(apVal[1]);
@@ -253164,39 +253265,59 @@
253164253265
fts5StorageInsert(&rc, pTab, apVal, pRowid);
253165253266
}
253166253267
253167253268
/* UPDATE */
253168253269
else{
253169
- i64 iOld = sqlite3_value_int64(apVal[0]); /* Old rowid */
253170
- i64 iNew = sqlite3_value_int64(apVal[1]); /* New rowid */
253171
- if( eType1!=SQLITE_INTEGER ){
253172
- rc = SQLITE_MISMATCH;
253173
- }else if( iOld!=iNew ){
253174
- if( eConflict==SQLITE_REPLACE ){
253175
- rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0, 1);
253176
- if( rc==SQLITE_OK ){
253177
- rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0, 0);
253178
- }
253179
- fts5StorageInsert(&rc, pTab, apVal, pRowid);
253180
- }else{
253181
- rc = sqlite3Fts5StorageFindDeleteRow(pTab->pStorage, iOld);
253182
- if( rc==SQLITE_OK ){
253183
- rc = sqlite3Fts5StorageContentInsert(pTab->pStorage,apVal,pRowid);
253184
- }
253185
- if( rc==SQLITE_OK ){
253186
- rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0, 1);
253187
- }
253188
- if( rc==SQLITE_OK ){
253189
- rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal,*pRowid);
253190
- }
253191
- }
253192
- }else{
253193
- rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0, 1);
253194
- fts5StorageInsert(&rc, pTab, apVal, pRowid);
253195
- }
253196
- bUpdateOrDelete = 1;
253197
- sqlite3Fts5StorageReleaseDeleteRow(pTab->pStorage);
253270
+ Fts5Storage *pStorage = pTab->pStorage;
253271
+ i64 iOld = sqlite3_value_int64(apVal[0]); /* Old rowid */
253272
+ i64 iNew = sqlite3_value_int64(apVal[1]); /* New rowid */
253273
+ int bContent = 0; /* Content only update */
253274
+
253275
+ /* If this is a contentless table (including contentless_unindexed=1
253276
+ ** tables), check if the UPDATE may proceed. */
253277
+ if( fts5IsContentless(pTab, 1) ){
253278
+ rc = fts5ContentlessUpdate(pConfig, &apVal[2], iOld!=iNew, &bContent);
253279
+ if( rc!=SQLITE_OK ) goto update_out;
253280
+ }
253281
+
253282
+ if( eType1!=SQLITE_INTEGER ){
253283
+ rc = SQLITE_MISMATCH;
253284
+ }else if( iOld!=iNew ){
253285
+ assert( bContent==0 );
253286
+ if( eConflict==SQLITE_REPLACE ){
253287
+ rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 1);
253288
+ if( rc==SQLITE_OK ){
253289
+ rc = sqlite3Fts5StorageDelete(pStorage, iNew, 0, 0);
253290
+ }
253291
+ fts5StorageInsert(&rc, pTab, apVal, pRowid);
253292
+ }else{
253293
+ rc = sqlite3Fts5StorageFindDeleteRow(pStorage, iOld);
253294
+ if( rc==SQLITE_OK ){
253295
+ rc = sqlite3Fts5StorageContentInsert(pStorage, 0, apVal, pRowid);
253296
+ }
253297
+ if( rc==SQLITE_OK ){
253298
+ rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 0);
253299
+ }
253300
+ if( rc==SQLITE_OK ){
253301
+ rc = sqlite3Fts5StorageIndexInsert(pStorage, apVal, *pRowid);
253302
+ }
253303
+ }
253304
+ }else if( bContent ){
253305
+ /* This occurs when an UPDATE on a contentless table affects *only*
253306
+ ** UNINDEXED columns. This is a no-op for contentless_unindexed=0
253307
+ ** tables, or a write to the %_content table only for =1 tables. */
253308
+ assert( fts5IsContentless(pTab, 1) );
253309
+ rc = sqlite3Fts5StorageFindDeleteRow(pStorage, iOld);
253310
+ if( rc==SQLITE_OK ){
253311
+ rc = sqlite3Fts5StorageContentInsert(pStorage, 1, apVal, pRowid);
253312
+ }
253313
+ }else{
253314
+ rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 1);
253315
+ fts5StorageInsert(&rc, pTab, apVal, pRowid);
253316
+ }
253317
+ bUpdateOrDelete = 1;
253318
+ sqlite3Fts5StorageReleaseDeleteRow(pStorage);
253198253319
}
253199253320
253200253321
}
253201253322
}
253202253323
@@ -253393,11 +253514,11 @@
253393253514
Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
253394253515
253395253516
assert( pCsr->ePlan!=FTS5_PLAN_SPECIAL );
253396253517
if( iCol<0 || iCol>=pTab->pConfig->nCol ){
253397253518
rc = SQLITE_RANGE;
253398
- }else if( fts5IsContentless((Fts5FullTable*)(pCsr->base.pVtab)) ){
253519
+ }else if( fts5IsContentless((Fts5FullTable*)(pCsr->base.pVtab), 0) ){
253399253520
*pz = 0;
253400253521
*pn = 0;
253401253522
}else{
253402253523
rc = fts5SeekCursor(pCsr, 0);
253403253524
if( rc==SQLITE_OK ){
@@ -253426,11 +253547,11 @@
253426253547
int bLive = (pCsr->pSorter==0);
253427253548
253428253549
if( iPhrase<0 || iPhrase>=sqlite3Fts5ExprPhraseCount(pCsr->pExpr) ){
253429253550
rc = SQLITE_RANGE;
253430253551
}else if( pConfig->eDetail!=FTS5_DETAIL_FULL
253431
- && pConfig->eContent==FTS5_CONTENT_NONE
253552
+ && fts5IsContentless((Fts5FullTable*)pCsr->base.pVtab, 1)
253432253553
){
253433253554
*pa = 0;
253434253555
*pn = 0;
253435253556
return SQLITE_OK;
253436253557
}else if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_POSLIST) ){
@@ -253622,11 +253743,11 @@
253622253743
253623253744
if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_DOCSIZE) ){
253624253745
if( pConfig->bColumnsize ){
253625253746
i64 iRowid = fts5CursorRowid(pCsr);
253626253747
rc = sqlite3Fts5StorageDocsize(pTab->pStorage, iRowid, pCsr->aColumnSize);
253627
- }else if( pConfig->zContent==0 ){
253748
+ }else if( !pConfig->zContent || pConfig->eContent==FTS5_CONTENT_UNINDEXED ){
253628253749
int i;
253629253750
for(i=0; i<pConfig->nCol; i++){
253630253751
if( pConfig->abUnindexed[i]==0 ){
253631253752
pCsr->aColumnSize[i] = -1;
253632253753
}
@@ -253910,11 +254031,11 @@
253910254031
assert( pCsr->ePlan!=FTS5_PLAN_SPECIAL );
253911254032
if( iCol<0 || iCol>=pConfig->nCol ){
253912254033
rc = SQLITE_RANGE;
253913254034
}else if(
253914254035
pConfig->abUnindexed[iCol]==0
253915
- && pConfig->eContent!=FTS5_CONTENT_NONE
254036
+ && 0==fts5IsContentless((Fts5FullTable*)pCsr->base.pVtab, 1)
253916254037
&& pConfig->bLocale
253917254038
){
253918254039
rc = fts5SeekCursor(pCsr, 0);
253919254040
if( rc==SQLITE_OK ){
253920254041
const char *zDummy = 0;
@@ -254185,20 +254306,11 @@
254185254306
if( pCsr->pRank || SQLITE_OK==(rc = fts5FindRankFunction(pCsr)) ){
254186254307
fts5ApiInvoke(pCsr->pRank, pCsr, pCtx, pCsr->nRankArg, pCsr->apRankArg);
254187254308
}
254188254309
}
254189254310
}else{
254190
- /* A column created by the user containing values. */
254191
- int bNochange = sqlite3_vtab_nochange(pCtx);
254192
-
254193
- if( fts5IsContentless(pTab) ){
254194
- if( bNochange && pConfig->bContentlessDelete ){
254195
- fts5ResultError(pCtx, "cannot UPDATE a subset of "
254196
- "columns on fts5 contentless-delete table: %s", pConfig->zName
254197
- );
254198
- }
254199
- }else if( bNochange==0 || pConfig->eContent!=FTS5_CONTENT_NORMAL ){
254311
+ if( !sqlite3_vtab_nochange(pCtx) && pConfig->eContent!=FTS5_CONTENT_NONE ){
254200254312
pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
254201254313
rc = fts5SeekCursor(pCsr, 1);
254202254314
if( rc==SQLITE_OK ){
254203254315
sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, iCol+1);
254204254316
if( pConfig->bLocale
@@ -254737,11 +254849,11 @@
254737254849
int nArg, /* Number of args */
254738254850
sqlite3_value **apUnused /* Function arguments */
254739254851
){
254740254852
assert( nArg==0 );
254741254853
UNUSED_PARAM2(nArg, apUnused);
254742
- sqlite3_result_text(pCtx, "fts5: 2024-09-25 16:11:27 660ca5ce6600d897cc2b00b9d39e5d993c1c0e71ec0d5dc706246c053a163281", -1, SQLITE_TRANSIENT);
254854
+ sqlite3_result_text(pCtx, "fts5: 2024-10-07 12:48:21 011fab70cb3d194b27742ebb236b05be582230567cf78e3e6cac6911de86922f", -1, SQLITE_TRANSIENT);
254743254855
}
254744254856
254745254857
/*
254746254858
** Implementation of fts5_locale(LOCALE, TEXT) function.
254747254859
**
@@ -255065,34 +255177,10 @@
255065255177
#define FTS5_STMT_DELETE_DOCSIZE 8
255066255178
#define FTS5_STMT_LOOKUP_DOCSIZE 9
255067255179
#define FTS5_STMT_REPLACE_CONFIG 10
255068255180
#define FTS5_STMT_SCAN 11
255069255181
255070
-/*
255071
-** Return a pointer to a buffer obtained from sqlite3_malloc() that contains
255072
-** nBind comma-separated question marks. e.g. if nBind is passed 5, this
255073
-** function returns "?,?,?,?,?".
255074
-**
255075
-** If *pRc is not SQLITE_OK when this function is called, it is a no-op and
255076
-** NULL is returned immediately. Or, if the attempt to malloc a buffer
255077
-** fails, then *pRc is set to SQLITE_NOMEM and NULL is returned. Otherwise,
255078
-** if it is SQLITE_OK when this function is called and the malloc() succeeds,
255079
-** *pRc is left unchanged.
255080
-*/
255081
-static char *fts5BindingsList(int *pRc, int nBind){
255082
- char *zBind = sqlite3Fts5MallocZero(pRc, 1 + nBind*2);
255083
- if( zBind ){
255084
- int ii;
255085
- for(ii=0; ii<nBind; ii++){
255086
- zBind[ii*2] = '?';
255087
- zBind[ii*2 + 1] = ',';
255088
- }
255089
- zBind[ii*2-1] = '\0';
255090
- }
255091
- return zBind;
255092
-}
255093
-
255094255182
/*
255095255183
** Prepare the two insert statements - Fts5Storage.pInsertContent and
255096255184
** Fts5Storage.pInsertDocsize - if they have not already been prepared.
255097255185
** Return SQLITE_OK if successful, or an SQLite error code if an error
255098255186
** occurs.
@@ -255157,27 +255245,41 @@
255157255245
zSql = sqlite3_mprintf(azStmt[eStmt],
255158255246
pC->zContentExprlist, pC->zContent, pC->zContentRowid
255159255247
);
255160255248
break;
255161255249
255162
- case FTS5_STMT_INSERT_CONTENT: {
255163
- int nCol = 0;
255164
- char *zBind;
255250
+ case FTS5_STMT_INSERT_CONTENT:
255251
+ case FTS5_STMT_REPLACE_CONTENT: {
255252
+ char *zBind = 0;
255165255253
int i;
255166255254
255167
- nCol = 1 + pC->nCol;
255168
- if( pC->bLocale ){
255169
- for(i=0; i<pC->nCol; i++){
255170
- if( pC->abUnindexed[i]==0 ) nCol++;
255255
+ assert( pC->eContent==FTS5_CONTENT_NORMAL
255256
+ || pC->eContent==FTS5_CONTENT_UNINDEXED
255257
+ );
255258
+
255259
+ /* Add bindings for the "c*" columns - those that store the actual
255260
+ ** table content. If eContent==NORMAL, then there is one binding
255261
+ ** for each column. Or, if eContent==UNINDEXED, then there are only
255262
+ ** bindings for the UNINDEXED columns. */
255263
+ for(i=0; rc==SQLITE_OK && i<(pC->nCol+1); i++){
255264
+ if( !i || pC->eContent==FTS5_CONTENT_NORMAL || pC->abUnindexed[i-1] ){
255265
+ zBind = sqlite3Fts5Mprintf(&rc, "%z%s?%d", zBind, zBind?",":"",i+1);
255266
+ }
255267
+ }
255268
+
255269
+ /* Add bindings for any "l*" columns. Only non-UNINDEXED columns
255270
+ ** require these. */
255271
+ if( pC->bLocale && pC->eContent==FTS5_CONTENT_NORMAL ){
255272
+ for(i=0; rc==SQLITE_OK && i<pC->nCol; i++){
255273
+ if( pC->abUnindexed[i]==0 ){
255274
+ zBind = sqlite3Fts5Mprintf(&rc, "%z,?%d", zBind, pC->nCol+i+2);
255275
+ }
255171255276
}
255172255277
}
255173255278
255174
- zBind = fts5BindingsList(&rc, nCol);
255175
- if( zBind ){
255176
- zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName, zBind);
255177
- sqlite3_free(zBind);
255178
- }
255279
+ zSql = sqlite3Fts5Mprintf(&rc, azStmt[eStmt], pC->zDb, pC->zName,zBind);
255280
+ sqlite3_free(zBind);
255179255281
break;
255180255282
}
255181255283
255182255284
case FTS5_STMT_REPLACE_DOCSIZE:
255183255285
zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName,
@@ -255359,11 +255461,13 @@
255359255461
p->aTotalSize = (i64*)&p[1];
255360255462
p->pConfig = pConfig;
255361255463
p->pIndex = pIndex;
255362255464
255363255465
if( bCreate ){
255364
- if( pConfig->eContent==FTS5_CONTENT_NORMAL ){
255466
+ if( pConfig->eContent==FTS5_CONTENT_NORMAL
255467
+ || pConfig->eContent==FTS5_CONTENT_UNINDEXED
255468
+ ){
255365255469
int nDefn = 32 + pConfig->nCol*10;
255366255470
char *zDefn = sqlite3_malloc64(32 + (sqlite3_int64)pConfig->nCol * 20);
255367255471
if( zDefn==0 ){
255368255472
rc = SQLITE_NOMEM;
255369255473
}else{
@@ -255370,12 +255474,16 @@
255370255474
int i;
255371255475
int iOff;
255372255476
sqlite3_snprintf(nDefn, zDefn, "id INTEGER PRIMARY KEY");
255373255477
iOff = (int)strlen(zDefn);
255374255478
for(i=0; i<pConfig->nCol; i++){
255375
- sqlite3_snprintf(nDefn-iOff, &zDefn[iOff], ", c%d", i);
255376
- iOff += (int)strlen(&zDefn[iOff]);
255479
+ if( pConfig->eContent==FTS5_CONTENT_NORMAL
255480
+ || pConfig->abUnindexed[i]
255481
+ ){
255482
+ sqlite3_snprintf(nDefn-iOff, &zDefn[iOff], ", c%d", i);
255483
+ iOff += (int)strlen(&zDefn[iOff]);
255484
+ }
255377255485
}
255378255486
if( pConfig->bLocale ){
255379255487
for(i=0; i<pConfig->nCol; i++){
255380255488
if( pConfig->abUnindexed[i]==0 ){
255381255489
sqlite3_snprintf(nDefn-iOff, &zDefn[iOff], ", l%d", i);
@@ -255609,11 +255717,13 @@
255609255717
i64 iOrigin = 0;
255610255718
sqlite3_stmt *pLookup = 0;
255611255719
int rc = SQLITE_OK;
255612255720
255613255721
assert( p->pConfig->bContentlessDelete );
255614
- assert( p->pConfig->eContent==FTS5_CONTENT_NONE );
255722
+ assert( p->pConfig->eContent==FTS5_CONTENT_NONE
255723
+ || p->pConfig->eContent==FTS5_CONTENT_UNINDEXED
255724
+ );
255615255725
255616255726
/* Look up the origin of the document in the %_docsize table. Store
255617255727
** this in stack variable iOrigin. */
255618255728
rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP_DOCSIZE, &pLookup, 0);
255619255729
if( rc==SQLITE_OK ){
@@ -255733,10 +255843,16 @@
255733255843
}
255734255844
255735255845
if( rc==SQLITE_OK ){
255736255846
if( p->pConfig->bContentlessDelete ){
255737255847
rc = fts5StorageContentlessDelete(p, iDel);
255848
+ if( rc==SQLITE_OK
255849
+ && bSaveRow
255850
+ && p->pConfig->eContent==FTS5_CONTENT_UNINDEXED
255851
+ ){
255852
+ rc = sqlite3Fts5StorageFindDeleteRow(p, iDel);
255853
+ }
255738255854
}else{
255739255855
rc = fts5StorageDeleteFromIndex(p, iDel, apVal, bSaveRow);
255740255856
}
255741255857
}
255742255858
@@ -255749,11 +255865,13 @@
255749255865
rc = sqlite3_reset(pDel);
255750255866
}
255751255867
}
255752255868
255753255869
/* Delete the %_content record */
255754
- if( pConfig->eContent==FTS5_CONTENT_NORMAL ){
255870
+ if( pConfig->eContent==FTS5_CONTENT_NORMAL
255871
+ || pConfig->eContent==FTS5_CONTENT_UNINDEXED
255872
+ ){
255755255873
if( rc==SQLITE_OK ){
255756255874
rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_CONTENT, &pDel, 0);
255757255875
}
255758255876
if( rc==SQLITE_OK ){
255759255877
sqlite3_bind_int64(pDel, 1, iDel);
@@ -255781,12 +255899,17 @@
255781255899
pConfig->zDb, pConfig->zName,
255782255900
pConfig->zDb, pConfig->zName
255783255901
);
255784255902
if( rc==SQLITE_OK && pConfig->bColumnsize ){
255785255903
rc = fts5ExecPrintf(pConfig->db, 0,
255786
- "DELETE FROM %Q.'%q_docsize';",
255787
- pConfig->zDb, pConfig->zName
255904
+ "DELETE FROM %Q.'%q_docsize';", pConfig->zDb, pConfig->zName
255905
+ );
255906
+ }
255907
+
255908
+ if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_UNINDEXED ){
255909
+ rc = fts5ExecPrintf(pConfig->db, 0,
255910
+ "DELETE FROM %Q.'%q_content';", pConfig->zDb, pConfig->zName
255788255911
);
255789255912
}
255790255913
255791255914
/* Reinitialize the %_data table. This call creates the initial structure
255792255915
** and averages records. */
@@ -255918,69 +256041,75 @@
255918256041
/*
255919256042
** Insert a new row into the FTS content table.
255920256043
*/
255921256044
static int sqlite3Fts5StorageContentInsert(
255922256045
Fts5Storage *p,
256046
+ int bReplace, /* True to use REPLACE instead of INSERT */
255923256047
sqlite3_value **apVal,
255924256048
i64 *piRowid
255925256049
){
255926256050
Fts5Config *pConfig = p->pConfig;
255927256051
int rc = SQLITE_OK;
255928256052
255929256053
/* Insert the new row into the %_content table. */
255930
- if( pConfig->eContent!=FTS5_CONTENT_NORMAL ){
256054
+ if( pConfig->eContent!=FTS5_CONTENT_NORMAL
256055
+ && pConfig->eContent!=FTS5_CONTENT_UNINDEXED
256056
+ ){
255931256057
if( sqlite3_value_type(apVal[1])==SQLITE_INTEGER ){
255932256058
*piRowid = sqlite3_value_int64(apVal[1]);
255933256059
}else{
255934256060
rc = fts5StorageNewRowid(p, piRowid);
255935256061
}
255936256062
}else{
255937256063
sqlite3_stmt *pInsert = 0; /* Statement to write %_content table */
255938256064
int i; /* Counter variable */
255939
- int nIndexed = 0; /* Number indexed columns seen */
255940
- rc = fts5StorageGetStmt(p, FTS5_STMT_INSERT_CONTENT, &pInsert, 0);
256065
+
256066
+ assert( FTS5_STMT_INSERT_CONTENT+1==FTS5_STMT_REPLACE_CONTENT );
256067
+ assert( bReplace==0 || bReplace==1 );
256068
+ rc = fts5StorageGetStmt(p, FTS5_STMT_INSERT_CONTENT+bReplace, &pInsert, 0);
255941256069
if( pInsert ) sqlite3_clear_bindings(pInsert);
255942256070
255943256071
/* Bind the rowid value */
255944256072
sqlite3_bind_value(pInsert, 1, apVal[1]);
255945256073
255946256074
/* Loop through values for user-defined columns. i=2 is the leftmost
255947256075
** user-defined column. As is column 1 of pSavedRow. */
255948256076
for(i=2; rc==SQLITE_OK && i<=pConfig->nCol+1; i++){
255949256077
int bUnindexed = pConfig->abUnindexed[i-2];
255950
- sqlite3_value *pVal = apVal[i];
255951
-
255952
- nIndexed += !bUnindexed;
255953
- if( sqlite3_value_nochange(pVal) && p->pSavedRow ){
255954
- /* This is an UPDATE statement, and column (i-2) was not modified.
255955
- ** Retrieve the value from Fts5Storage.pSavedRow instead. */
255956
- pVal = sqlite3_column_value(p->pSavedRow, i-1);
255957
- if( pConfig->bLocale && bUnindexed==0 ){
255958
- sqlite3_bind_value(pInsert, pConfig->nCol + 1 + nIndexed,
255959
- sqlite3_column_value(p->pSavedRow, pConfig->nCol + i - 1)
255960
- );
255961
- }
255962
- }else if( sqlite3Fts5IsLocaleValue(pConfig, pVal) ){
255963
- const char *pText = 0;
255964
- const char *pLoc = 0;
255965
- int nText = 0;
255966
- int nLoc = 0;
255967
- assert( pConfig->bLocale );
255968
-
255969
- rc = sqlite3Fts5DecodeLocaleValue(pVal, &pText, &nText, &pLoc, &nLoc);
255970
- if( rc==SQLITE_OK ){
255971
- sqlite3_bind_text(pInsert, i, pText, nText, SQLITE_TRANSIENT);
255972
- if( bUnindexed==0 ){
255973
- int iLoc = pConfig->nCol + 1 + nIndexed;
255974
- sqlite3_bind_text(pInsert, iLoc, pLoc, nLoc, SQLITE_TRANSIENT);
255975
- }
255976
- }
255977
-
255978
- continue;
255979
- }
255980
-
255981
- rc = sqlite3_bind_value(pInsert, i, pVal);
256078
+ if( pConfig->eContent==FTS5_CONTENT_NORMAL || bUnindexed ){
256079
+ sqlite3_value *pVal = apVal[i];
256080
+
256081
+ if( sqlite3_value_nochange(pVal) && p->pSavedRow ){
256082
+ /* This is an UPDATE statement, and user-defined column (i-2) was not
256083
+ ** modified. Retrieve the value from Fts5Storage.pSavedRow. */
256084
+ pVal = sqlite3_column_value(p->pSavedRow, i-1);
256085
+ if( pConfig->bLocale && bUnindexed==0 ){
256086
+ sqlite3_bind_value(pInsert, pConfig->nCol + i,
256087
+ sqlite3_column_value(p->pSavedRow, pConfig->nCol + i - 1)
256088
+ );
256089
+ }
256090
+ }else if( sqlite3Fts5IsLocaleValue(pConfig, pVal) ){
256091
+ const char *pText = 0;
256092
+ const char *pLoc = 0;
256093
+ int nText = 0;
256094
+ int nLoc = 0;
256095
+ assert( pConfig->bLocale );
256096
+
256097
+ rc = sqlite3Fts5DecodeLocaleValue(pVal, &pText, &nText, &pLoc, &nLoc);
256098
+ if( rc==SQLITE_OK ){
256099
+ sqlite3_bind_text(pInsert, i, pText, nText, SQLITE_TRANSIENT);
256100
+ if( bUnindexed==0 ){
256101
+ int iLoc = pConfig->nCol + i;
256102
+ sqlite3_bind_text(pInsert, iLoc, pLoc, nLoc, SQLITE_TRANSIENT);
256103
+ }
256104
+ }
256105
+
256106
+ continue;
256107
+ }
256108
+
256109
+ rc = sqlite3_bind_value(pInsert, i, pVal);
256110
+ }
255982256111
}
255983256112
if( rc==SQLITE_OK ){
255984256113
sqlite3_step(pInsert);
255985256114
rc = sqlite3_reset(pInsert);
255986256115
}
255987256116
--- 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 ** f97f9944b829a49da12786f934da0a5ad515.
22 */
23 #define SQLITE_CORE 1
24 #define SQLITE_AMALGAMATION 1
25 #ifndef SQLITE_PRIVATE
26 # define SQLITE_PRIVATE static
@@ -462,11 +462,11 @@
462 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
463 ** [sqlite_version()] and [sqlite_source_id()].
464 */
465 #define SQLITE_VERSION "3.47.0"
466 #define SQLITE_VERSION_NUMBER 3047000
467 #define SQLITE_SOURCE_ID "2024-09-26 19:38:34 f97f9944b829a49da12786f934da0a5ad51591afd6d8a19a4a0835f51bbdbff2"
468
469 /*
470 ** CAPI3REF: Run-Time Library Version Numbers
471 ** KEYWORDS: sqlite3_version sqlite3_sourceid
472 **
@@ -5917,11 +5917,11 @@
5917 ** The SQLITE_SUBTYPE flag indicates to SQLite that a function might call
5918 ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments.
5919 ** This flag instructs SQLite to omit some corner-case optimizations that
5920 ** might disrupt the operation of the [sqlite3_value_subtype()] function,
5921 ** causing it to return zero rather than the correct subtype().
5922 ** SQL functions that invokes [sqlite3_value_subtype()] should have this
5923 ** property. If the SQLITE_SUBTYPE property is omitted, then the return
5924 ** value from [sqlite3_value_subtype()] might sometimes be zero even though
5925 ** a non-zero subtype was specified by the function argument expression.
5926 **
5927 ** [[SQLITE_RESULT_SUBTYPE]] <dt>SQLITE_RESULT_SUBTYPE</dt><dd>
@@ -8682,11 +8682,11 @@
8682 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
8683 #define SQLITE_TESTCTRL_SEEK_COUNT 30
8684 #define SQLITE_TESTCTRL_TRACEFLAGS 31
8685 #define SQLITE_TESTCTRL_TUNE 32
8686 #define SQLITE_TESTCTRL_LOGEST 33
8687 #define SQLITE_TESTCTRL_USELONGDOUBLE 34
8688 #define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
8689
8690 /*
8691 ** CAPI3REF: SQL Keyword Checking
8692 **
@@ -10856,10 +10856,18 @@
10856 ** schema S in database connection D. ^On success, the
10857 ** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
10858 ** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
10859 ** If there is not already a read-transaction open on schema S when
10860 ** this function is called, one is opened automatically.
 
 
 
 
 
 
 
 
10861 **
10862 ** The following must be true for this function to succeed. If any of
10863 ** the following statements are false when sqlite3_snapshot_get() is
10864 ** called, SQLITE_ERROR is returned. The final value of *P is undefined
10865 ** in this case.
@@ -14813,10 +14821,11 @@
14813 #include <stdio.h>
14814 #include <stdlib.h>
14815 #include <string.h>
14816 #include <assert.h>
14817 #include <stddef.h>
 
14818
14819 /*
14820 ** Use a macro to replace memcpy() if compiled with SQLITE_INLINE_MEMCPY.
14821 ** This allows better measurements of where memcpy() is used when running
14822 ** cachegrind. But this macro version of memcpy() is very slow so it
@@ -14835,11 +14844,10 @@
14835 #ifdef SQLITE_OMIT_FLOATING_POINT
14836 # define double sqlite_int64
14837 # define float sqlite_int64
14838 # define fabs(X) ((X)<0?-(X):(X))
14839 # define sqlite3IsOverflow(X) 0
14840 # define LONGDOUBLE_TYPE sqlite_int64
14841 # ifndef SQLITE_BIG_DBL
14842 # define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50)
14843 # endif
14844 # define SQLITE_OMIT_DATETIME_FUNCS 1
14845 # define SQLITE_OMIT_TRACE 1
@@ -15010,13 +15018,10 @@
15010 # define INT8_TYPE int8_t
15011 # else
15012 # define INT8_TYPE signed char
15013 # endif
15014 #endif
15015 #ifndef LONGDOUBLE_TYPE
15016 # define LONGDOUBLE_TYPE long double
15017 #endif
15018 typedef sqlite_int64 i64; /* 8-byte signed integer */
15019 typedef sqlite_uint64 u64; /* 8-byte unsigned integer */
15020 typedef UINT32_TYPE u32; /* 4-byte unsigned integer */
15021 typedef UINT16_TYPE u16; /* 2-byte unsigned integer */
15022 typedef INT16_TYPE i16; /* 2-byte signed integer */
@@ -20380,11 +20385,10 @@
20380 u8 bFullMutex; /* True to enable full mutexing */
20381 u8 bOpenUri; /* True to interpret filenames as URIs */
20382 u8 bUseCis; /* Use covering indices for full-scans */
20383 u8 bSmallMalloc; /* Avoid large memory allocations if true */
20384 u8 bExtraSchemaChecks; /* Verify type,name,tbl_name in schema */
20385 u8 bUseLongDouble; /* Make use of long double */
20386 #ifdef SQLITE_DEBUG
20387 u8 bJsonSelfcheck; /* Double-check JSON parsing */
20388 #endif
20389 int mxStrlen; /* Maximum string length */
20390 int neverCorrupt; /* Database is always well-formed */
@@ -20755,19 +20759,10 @@
20755 */
20756 #if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)
20757 # define SQLITE_ENABLE_FTS3 1
20758 #endif
20759
20760 /*
20761 ** The ctype.h header is needed for non-ASCII systems. It is also
20762 ** needed by FTS3 when FTS3 is included in the amalgamation.
20763 */
20764 #if !defined(SQLITE_ASCII) || \
20765 (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION))
20766 # include <ctype.h>
20767 #endif
20768
20769 /*
20770 ** The following macros mimic the standard library functions toupper(),
20771 ** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The
20772 ** sqlite versions only work for ASCII characters, regardless of locale.
20773 */
@@ -23121,11 +23116,10 @@
23121 SQLITE_THREADSAFE==1, /* bFullMutex */
23122 SQLITE_USE_URI, /* bOpenUri */
23123 SQLITE_ALLOW_COVERING_INDEX_SCAN, /* bUseCis */
23124 0, /* bSmallMalloc */
23125 1, /* bExtraSchemaChecks */
23126 sizeof(LONGDOUBLE_TYPE)>8, /* bUseLongDouble */
23127 #ifdef SQLITE_DEBUG
23128 0, /* bJsonSelfcheck */
23129 #endif
23130 0x7ffffffe, /* mxStrlen */
23131 0, /* neverCorrupt */
@@ -35679,10 +35673,12 @@
35679 int esign = 1; /* sign of exponent */
35680 int e = 0; /* exponent */
35681 int eValid = 1; /* True exponent is either not used or is well-formed */
35682 int nDigit = 0; /* Number of digits processed */
35683 int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */
 
 
35684
35685 assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
35686 *pResult = 0.0; /* Default return value, in case of an error */
35687 if( length==0 ) return 0;
35688
@@ -35790,72 +35786,45 @@
35790 while( e<0 && (s%10)==0 ){
35791 s /= 10;
35792 e++;
35793 }
35794
35795 if( e==0 ){
35796 *pResult = s;
35797 }else if( sqlite3Config.bUseLongDouble ){
35798 LONGDOUBLE_TYPE r = (LONGDOUBLE_TYPE)s;
35799 if( e>0 ){
35800 while( e>=100 ){ e-=100; r *= 1.0e+100L; }
35801 while( e>=10 ){ e-=10; r *= 1.0e+10L; }
35802 while( e>=1 ){ e-=1; r *= 1.0e+01L; }
35803 }else{
35804 while( e<=-100 ){ e+=100; r *= 1.0e-100L; }
35805 while( e<=-10 ){ e+=10; r *= 1.0e-10L; }
35806 while( e<=-1 ){ e+=1; r *= 1.0e-01L; }
35807 }
35808 assert( r>=0.0 );
35809 if( r>+1.7976931348623157081452742373e+308L ){
35810 #ifdef INFINITY
35811 *pResult = +INFINITY;
35812 #else
35813 *pResult = 1.0e308*10.0;
35814 #endif
35815 }else{
35816 *pResult = (double)r;
35817 }
35818 }else{
35819 double rr[2];
35820 u64 s2;
35821 rr[0] = (double)s;
35822 s2 = (u64)rr[0];
35823 #if defined(_MSC_VER) && _MSC_VER<1700
35824 if( s2==0x8000000000000000LL ){ s2 = 2*(u64)(0.5*rr[0]); }
35825 #endif
35826 rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s);
35827 if( e>0 ){
35828 while( e>=100 ){
35829 e -= 100;
35830 dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83);
35831 }
35832 while( e>=10 ){
35833 e -= 10;
35834 dekkerMul2(rr, 1.0e+10, 0.0);
35835 }
35836 while( e>=1 ){
35837 e -= 1;
35838 dekkerMul2(rr, 1.0e+01, 0.0);
35839 }
35840 }else{
35841 while( e<=-100 ){
35842 e += 100;
35843 dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117);
35844 }
35845 while( e<=-10 ){
35846 e += 10;
35847 dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27);
35848 }
35849 while( e<=-1 ){
35850 e += 1;
35851 dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18);
35852 }
35853 }
35854 *pResult = rr[0]+rr[1];
35855 if( sqlite3IsNaN(*pResult) ) *pResult = 1e300*1e300;
35856 }
35857 if( sign<0 ) *pResult = -*pResult;
35858 assert( !sqlite3IsNaN(*pResult) );
35859
35860 atof_return:
35861 /* return true if number and no extra non-whitespace characters after */
@@ -36172,13 +36141,14 @@
36172 */
36173 SQLITE_PRIVATE void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){
36174 int i;
36175 u64 v;
36176 int e, exp = 0;
 
 
36177 p->isSpecial = 0;
36178 p->z = p->zBuf;
36179
36180 assert( mxRound>0 );
36181
36182 /* Convert negative numbers to positive. Deal with Infinity, 0.0, and
36183 ** NaN. */
36184 if( r<0.0 ){
@@ -36202,66 +36172,49 @@
36202 return;
36203 }
36204
36205 /* Multiply r by powers of ten until it lands somewhere in between
36206 ** 1.0e+19 and 1.0e+17.
36207 */
36208 if( sqlite3Config.bUseLongDouble ){
36209 LONGDOUBLE_TYPE rr = r;
36210 if( rr>=1.0e+19 ){
36211 while( rr>=1.0e+119L ){ exp+=100; rr *= 1.0e-100L; }
36212 while( rr>=1.0e+29L ){ exp+=10; rr *= 1.0e-10L; }
36213 while( rr>=1.0e+19L ){ exp++; rr *= 1.0e-1L; }
36214 }else{
36215 while( rr<1.0e-97L ){ exp-=100; rr *= 1.0e+100L; }
36216 while( rr<1.0e+07L ){ exp-=10; rr *= 1.0e+10L; }
36217 while( rr<1.0e+17L ){ exp--; rr *= 1.0e+1L; }
36218 }
36219 v = (u64)rr;
36220 }else{
36221 /* If high-precision floating point is not available using "long double",
36222 ** then use Dekker-style double-double computation to increase the
36223 ** precision.
36224 **
36225 ** The error terms on constants like 1.0e+100 computed using the
36226 ** decimal extension, for example as follows:
36227 **
36228 ** SELECT decimal_exp(decimal_sub('1.0e+100',decimal(1.0e+100)));
36229 */
36230 double rr[2];
36231 rr[0] = r;
36232 rr[1] = 0.0;
36233 if( rr[0]>9.223372036854774784e+18 ){
36234 while( rr[0]>9.223372036854774784e+118 ){
36235 exp += 100;
36236 dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117);
36237 }
36238 while( rr[0]>9.223372036854774784e+28 ){
36239 exp += 10;
36240 dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27);
36241 }
36242 while( rr[0]>9.223372036854774784e+18 ){
36243 exp += 1;
36244 dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18);
36245 }
36246 }else{
36247 while( rr[0]<9.223372036854774784e-83 ){
36248 exp -= 100;
36249 dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83);
36250 }
36251 while( rr[0]<9.223372036854774784e+07 ){
36252 exp -= 10;
36253 dekkerMul2(rr, 1.0e+10, 0.0);
36254 }
36255 while( rr[0]<9.22337203685477478e+17 ){
36256 exp -= 1;
36257 dekkerMul2(rr, 1.0e+01, 0.0);
36258 }
36259 }
36260 v = rr[1]<0.0 ? (u64)rr[0]-(u64)(-rr[1]) : (u64)rr[0]+(u64)rr[1];
36261 }
36262
36263
36264 /* Extract significant digits. */
36265 i = sizeof(p->zBuf)-1;
36266 assert( v>0 );
36267 while( v ){ p->zBuf[i--] = (v%10) + '0'; v /= 10; }
@@ -65688,10 +65641,11 @@
65688 int nSehTry; /* Number of nested SEH_TRY{} blocks */
65689 u8 lockError; /* True if a locking error has occurred */
65690 #endif
65691 #ifdef SQLITE_ENABLE_SNAPSHOT
65692 WalIndexHdr *pSnapshot; /* Start transaction here if not NULL */
 
65693 #endif
65694 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
65695 sqlite3 *db;
65696 #endif
65697 };
@@ -68244,11 +68198,11 @@
68244 assert( pWal->apWiData[0]!=0 );
68245 pInfo = walCkptInfo(pWal);
68246 SEH_INJECT_FAULT;
68247 if( !useWal && AtomicLoad(&pInfo->nBackfill)==pWal->hdr.mxFrame
68248 #ifdef SQLITE_ENABLE_SNAPSHOT
68249 && (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0)
68250 #endif
68251 ){
68252 /* The WAL has been completely backfilled (or it is empty).
68253 ** and can be safely ignored.
68254 */
@@ -69644,11 +69598,24 @@
69644 */
69645 SQLITE_PRIVATE void sqlite3WalSnapshotOpen(
69646 Wal *pWal,
69647 sqlite3_snapshot *pSnapshot
69648 ){
69649 pWal->pSnapshot = (WalIndexHdr*)pSnapshot;
 
 
 
 
 
 
 
 
 
 
 
 
 
69650 }
69651
69652 /*
69653 ** Return a +ve value if snapshot p1 is newer than p2. A -ve value if
69654 ** p1 is older than p2 and zero if p1 and p2 are the same snapshot.
@@ -89592,11 +89559,11 @@
89592 /* The following two functions are used only within testcase() to prove
89593 ** test coverage. These functions do no exist for production builds.
89594 ** We must use separate SQLITE_NOINLINE functions here, since otherwise
89595 ** optimizer code movement causes gcov to become very confused.
89596 */
89597 #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG)
89598 static int SQLITE_NOINLINE doubleLt(double a, double b){ return a<b; }
89599 static int SQLITE_NOINLINE doubleEq(double a, double b){ return a==b; }
89600 #endif
89601
89602 /*
@@ -89607,17 +89574,10 @@
89607 SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){
89608 if( sqlite3IsNaN(r) ){
89609 /* SQLite considers NaN to be a NULL. And all integer values are greater
89610 ** than NULL */
89611 return 1;
89612 }
89613 if( sqlite3Config.bUseLongDouble ){
89614 LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i;
89615 testcase( x<r );
89616 testcase( x>r );
89617 testcase( x==r );
89618 return (x<r) ? -1 : (x>r);
89619 }else{
89620 i64 y;
89621 if( r<-9223372036854775808.0 ) return +1;
89622 if( r>=9223372036854775808.0 ) return -1;
89623 y = (i64)r;
@@ -131787,11 +131747,17 @@
131787 #ifdef SQLITE_DEBUG
131788 /*
131789 ** Implementation of fpdecode(x,y,z) function.
131790 **
131791 ** x is a real number that is to be decoded. y is the precision.
131792 ** z is the maximum real precision.
 
 
 
 
 
 
131793 */
131794 static void fpdecodeFunc(
131795 sqlite3_context *context,
131796 int argc,
131797 sqlite3_value **argv
@@ -131811,10 +131777,86 @@
131811 sqlite3_snprintf(sizeof(zBuf), zBuf, "NaN");
131812 }else{
131813 sqlite3_snprintf(sizeof(zBuf), zBuf, "%c%.*s/%d", s.sign, s.n, s.z, s.iDP);
131814 }
131815 sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131816 }
131817 #endif /* SQLITE_DEBUG */
131818
131819 /*
131820 ** All of the FuncDef structures in the aBuiltinFunc[] array above
@@ -131887,10 +131929,11 @@
131887 FUNCTION(unicode, 1, 0, 0, unicodeFunc ),
131888 FUNCTION(char, -1, 0, 0, charFunc ),
131889 FUNCTION(abs, 1, 0, 0, absFunc ),
131890 #ifdef SQLITE_DEBUG
131891 FUNCTION(fpdecode, 3, 0, 0, fpdecodeFunc ),
 
131892 #endif
131893 #ifndef SQLITE_OMIT_FLOATING_POINT
131894 FUNCTION(round, 1, 0, 0, roundFunc ),
131895 FUNCTION(round, 2, 0, 0, roundFunc ),
131896 #endif
@@ -141115,10 +141158,11 @@
141115 }
141116 aRoot[0] = cnt;
141117
141118 /* Make sure sufficient number of registers have been allocated */
141119 sqlite3TouchRegister(pParse, 8+cnt);
 
141120 sqlite3ClearTempRegCache(pParse);
141121
141122 /* Do the b-tree integrity checks */
141123 sqlite3VdbeAddOp4(v, OP_IntegrityCk, 1, cnt, 8, (char*)aRoot,P4_INTARRAY);
141124 sqlite3VdbeChangeP5(v, (u8)i);
@@ -161344,24 +161388,29 @@
161344 }else if( op==TK_STRING ){
161345 assert( !ExprHasProperty(pRight, EP_IntValue) );
161346 z = (u8*)pRight->u.zToken;
161347 }
161348 if( z ){
161349
161350 /* Count the number of prefix characters prior to the first wildcard.
161351 ** If the underlying database has a UTF16LE encoding, then only consider
161352 ** ASCII characters. Note that the encoding of z[] is UTF8 - we are
161353 ** dealing with only UTF8 here in this code, but the database engine
161354 ** itself might be processing content using a different encoding. */
161355 cnt = 0;
161356 while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
161357 cnt++;
161358 if( c==wc[3] && z[cnt]!=0 ){
161359 cnt++;
161360 }else if( c>=0x80 && ENC(db)==SQLITE_UTF16LE ){
161361 cnt--;
161362 break;
 
 
 
 
 
161363 }
161364 }
161365
161366 /* The optimization is possible only if (1) the pattern does not begin
161367 ** with a wildcard and if (2) the non-wildcard prefix does not end with
@@ -161369,11 +161418,11 @@
161369 ** a single escape character. The second condition is necessary so
161370 ** that we can increment the prefix key to find an upper bound for the
161371 ** range search. The third is because the caller assumes that the pattern
161372 ** consists of at least one character after all escapes have been
161373 ** removed. */
161374 if( (cnt>1 || (cnt>0 && z[0]!=wc[3])) && 255!=(u8)z[cnt-1] ){
161375 Expr *pPrefix;
161376
161377 /* A "complete" match if the pattern ends with "*" or "%" */
161378 *pisComplete = c==wc[0] && z[cnt+1]==0 && ENC(db)!=SQLITE_UTF16LE;
161379
@@ -181161,36 +181210,10 @@
181161 ** all database files specified with a relative pathname.
181162 **
181163 ** See also the "PRAGMA data_store_directory" SQL command.
181164 */
181165 SQLITE_API char *sqlite3_data_directory = 0;
181166
181167 /*
181168 ** Determine whether or not high-precision (long double) floating point
181169 ** math works correctly on CPU currently running.
181170 */
181171 static SQLITE_NOINLINE int hasHighPrecisionDouble(int rc){
181172 if( sizeof(LONGDOUBLE_TYPE)<=8 ){
181173 /* If the size of "long double" is not more than 8, then
181174 ** high-precision math is not possible. */
181175 return 0;
181176 }else{
181177 /* Just because sizeof(long double)>8 does not mean that the underlying
181178 ** hardware actually supports high-precision floating point. For example,
181179 ** clearing the 0x100 bit in the floating-point control word on Intel
181180 ** processors will make long double work like double, even though long
181181 ** double takes up more space. The only way to determine if long double
181182 ** actually works is to run an experiment. */
181183 LONGDOUBLE_TYPE a, b, c;
181184 rc++;
181185 a = 1.0+rc*0.1;
181186 b = 1.0e+18+rc*25.0;
181187 c = a+b;
181188 return b!=c;
181189 }
181190 }
181191
181192
181193 /*
181194 ** Initialize SQLite.
181195 **
181196 ** This routine must be called to initialize the memory allocation,
@@ -181382,17 +181405,10 @@
181382 if( bRunExtraInit ){
181383 int SQLITE_EXTRA_INIT(const char*);
181384 rc = SQLITE_EXTRA_INIT(0);
181385 }
181386 #endif
181387
181388 /* Experimentally determine if high-precision floating point is
181389 ** available. */
181390 #ifndef SQLITE_OMIT_WSD
181391 sqlite3Config.bUseLongDouble = hasHighPrecisionDouble(rc);
181392 #endif
181393
181394 return rc;
181395 }
181396
181397 /*
181398 ** Undo the effects of sqlite3_initialize(). Must not be called while
@@ -185640,28 +185656,10 @@
185640 *pI1 = rLogEst;
185641 *pU64 = sqlite3LogEstToInt(rLogEst);
185642 *pI2 = sqlite3LogEst(*pU64);
185643 break;
185644 }
185645
185646 #if !defined(SQLITE_OMIT_WSD)
185647 /* sqlite3_test_control(SQLITE_TESTCTRL_USELONGDOUBLE, int X);
185648 **
185649 ** X<0 Make no changes to the bUseLongDouble. Just report value.
185650 ** X==0 Disable bUseLongDouble
185651 ** X==1 Enable bUseLongDouble
185652 ** X>=2 Set bUseLongDouble to its default value for this platform
185653 */
185654 case SQLITE_TESTCTRL_USELONGDOUBLE: {
185655 int b = va_arg(ap, int);
185656 if( b>=2 ) b = hasHighPrecisionDouble(b);
185657 if( b>=0 ) sqlite3Config.bUseLongDouble = b>0;
185658 rc = sqlite3Config.bUseLongDouble!=0;
185659 break;
185660 }
185661 #endif
185662
185663
185664 #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD)
185665 /* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue)
185666 **
185667 ** If "id" is an integer between 1 and SQLITE_NTUNE then set the value
@@ -185966,11 +185964,15 @@
185966 if( db->autoCommit==0 ){
185967 int iDb = sqlite3FindDbName(db, zDb);
185968 if( iDb==0 || iDb>1 ){
185969 Btree *pBt = db->aDb[iDb].pBt;
185970 if( SQLITE_TXN_WRITE!=sqlite3BtreeTxnState(pBt) ){
 
 
 
185971 rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
 
185972 if( rc==SQLITE_OK ){
185973 rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);
185974 }
185975 }
185976 }
@@ -225801,12 +225803,12 @@
225801 };
225802
225803 struct DbpageTable {
225804 sqlite3_vtab base; /* Base class. Must be first */
225805 sqlite3 *db; /* The database */
225806 int nTrunc; /* Entries in aTrunc[] */
225807 Pgno *aTrunc; /* Truncation size for each database */
225808 };
225809
225810 /* Columns */
225811 #define DBPAGE_COLUMN_PGNO 0
225812 #define DBPAGE_COLUMN_DATA 1
@@ -225851,12 +225853,10 @@
225851
225852 /*
225853 ** Disconnect from or destroy a dbpagevfs virtual table.
225854 */
225855 static int dbpageDisconnect(sqlite3_vtab *pVtab){
225856 DbpageTable *pTab = (DbpageTable *)pVtab;
225857 sqlite3_free(pTab->aTrunc);
225858 sqlite3_free(pVtab);
225859 return SQLITE_OK;
225860 }
225861
225862 /*
@@ -226119,23 +226119,16 @@
226119 }
226120 szPage = sqlite3BtreeGetPageSize(pBt);
226121 if( sqlite3_value_type(argv[3])!=SQLITE_BLOB
226122 || sqlite3_value_bytes(argv[3])!=szPage
226123 ){
226124 if( sqlite3_value_type(argv[3])==SQLITE_NULL && isInsert ){
226125 if( iDb>=pTab->nTrunc ){
226126 testcase( pTab->aTrunc!=0 );
226127 pTab->aTrunc = sqlite3_realloc(pTab->aTrunc, (iDb+1)*sizeof(Pgno));
226128 if( pTab->aTrunc ){
226129 int j;
226130 for(j=pTab->nTrunc; j<iDb; j++) pTab->aTrunc[j] = 0;
226131 pTab->nTrunc = iDb+1;
226132 }else{
226133 return SQLITE_NOMEM;
226134 }
226135 }
226136 pTab->aTrunc[iDb] = pgno;
226137 }else{
226138 zErr = "bad page value";
226139 goto update_fail;
226140 }
226141 }
@@ -226144,10 +226137,11 @@
226144 if( rc==SQLITE_OK ){
226145 const void *pData = sqlite3_value_blob(argv[3]);
226146 if( (rc = sqlite3PagerWrite(pDbPage))==SQLITE_OK && pData ){
226147 unsigned char *aPage = sqlite3PagerGetData(pDbPage);
226148 memcpy(aPage, pData, szPage);
 
226149 }
226150 }
226151 sqlite3PagerUnref(pDbPage);
226152 return rc;
226153
@@ -226167,33 +226161,35 @@
226167 int i;
226168 for(i=0; i<db->nDb; i++){
226169 Btree *pBt = db->aDb[i].pBt;
226170 if( pBt ) (void)sqlite3BtreeBeginTrans(pBt, 1, 0);
226171 }
226172 if( pTab->nTrunc>0 ){
226173 memset(pTab->aTrunc, 0, sizeof(pTab->aTrunc[0])*pTab->nTrunc);
226174 }
226175 return SQLITE_OK;
226176 }
226177
226178 /* Invoke sqlite3PagerTruncate() as necessary, just prior to COMMIT
226179 */
226180 static int dbpageSync(sqlite3_vtab *pVtab){
226181 int iDb;
 
 
 
 
 
 
 
 
 
 
 
 
226182 DbpageTable *pTab = (DbpageTable *)pVtab;
226183
226184 for(iDb=0; iDb<pTab->nTrunc; iDb++){
226185 if( pTab->aTrunc[iDb]>0 ){
226186 Btree *pBt = pTab->db->aDb[iDb].pBt;
226187 Pager *pPager = sqlite3BtreePager(pBt);
226188 sqlite3PagerTruncateImage(pPager, pTab->aTrunc[iDb]);
226189 pTab->aTrunc[iDb] = 0;
226190 }
226191 }
226192 return SQLITE_OK;
226193 }
226194
226195
226196 /*
226197 ** Invoke this routine to register the "dbpage" virtual table module
226198 */
226199 SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){
@@ -226218,11 +226214,11 @@
226218 0, /* xRollback */
226219 0, /* xFindMethod */
226220 0, /* xRename */
226221 0, /* xSavepoint */
226222 0, /* xRelease */
226223 0, /* xRollbackTo */
226224 0, /* xShadowName */
226225 0 /* xIntegrity */
226226 };
226227 return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0);
226228 }
@@ -233747,10 +233743,11 @@
233747 u8 *abUnindexed; /* True for unindexed columns */
233748 int nPrefix; /* Number of prefix indexes */
233749 int *aPrefix; /* Sizes in bytes of nPrefix prefix indexes */
233750 int eContent; /* An FTS5_CONTENT value */
233751 int bContentlessDelete; /* "contentless_delete=" option (dflt==0) */
 
233752 char *zContent; /* content table */
233753 char *zContentRowid; /* "content_rowid=" option value */
233754 int bColumnsize; /* "columnsize=" option value (dflt==1) */
233755 int bTokendata; /* "tokendata=" option value (dflt==0) */
233756 int bLocale; /* "locale=" option value (dflt==0) */
@@ -233785,13 +233782,14 @@
233785 ** the expected version if the 'secure-delete' option has ever been
233786 ** set on the table. */
233787 #define FTS5_CURRENT_VERSION 4
233788 #define FTS5_CURRENT_VERSION_SECUREDELETE 5
233789
233790 #define FTS5_CONTENT_NORMAL 0
233791 #define FTS5_CONTENT_NONE 1
233792 #define FTS5_CONTENT_EXTERNAL 2
 
233793
233794 #define FTS5_DETAIL_FULL 0
233795 #define FTS5_DETAIL_NONE 1
233796 #define FTS5_DETAIL_COLUMNS 2
233797
@@ -234247,11 +234245,11 @@
234247
234248 static int sqlite3Fts5DropAll(Fts5Config*);
234249 static int sqlite3Fts5CreateTable(Fts5Config*, const char*, const char*, int, char **);
234250
234251 static int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**, int);
234252 static int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*);
234253 static int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64);
234254
234255 static int sqlite3Fts5StorageIntegrity(Fts5Storage *p, int iArg);
234256
234257 static int sqlite3Fts5StorageStmt(Fts5Storage *p, int eStmt, sqlite3_stmt**, char**);
@@ -237454,10 +237452,11 @@
237454 const char *zArg, /* Argument to parse */
237455 char **pzErr /* OUT: Error message */
237456 ){
237457 int rc = SQLITE_OK;
237458 int nCmd = (int)strlen(zCmd);
 
237459 if( sqlite3_strnicmp("prefix", zCmd, nCmd)==0 ){
237460 const int nByte = sizeof(int) * FTS5_MAX_PREFIX_INDEXES;
237461 const char *p;
237462 int bFirst = 1;
237463 if( pConfig->aPrefix==0 ){
@@ -237572,10 +237571,20 @@
237572 }else{
237573 pConfig->bContentlessDelete = (zArg[0]=='1');
237574 }
237575 return rc;
237576 }
 
 
 
 
 
 
 
 
 
 
237577
237578 if( sqlite3_strnicmp("content_rowid", zCmd, nCmd)==0 ){
237579 if( pConfig->zContentRowid ){
237580 *pzErr = sqlite3_mprintf("multiple content_rowid=... directives");
237581 rc = SQLITE_ERROR;
@@ -237690,11 +237699,12 @@
237690
237691 static int fts5ConfigParseColumn(
237692 Fts5Config *p,
237693 char *zCol,
237694 char *zArg,
237695 char **pzErr
 
237696 ){
237697 int rc = SQLITE_OK;
237698 if( 0==sqlite3_stricmp(zCol, FTS5_RANK_NAME)
237699 || 0==sqlite3_stricmp(zCol, FTS5_ROWID_NAME)
237700 ){
@@ -237701,10 +237711,11 @@
237701 *pzErr = sqlite3_mprintf("reserved fts5 column name: %s", zCol);
237702 rc = SQLITE_ERROR;
237703 }else if( zArg ){
237704 if( 0==sqlite3_stricmp(zArg, "unindexed") ){
237705 p->abUnindexed[p->nCol] = 1;
 
237706 }else{
237707 *pzErr = sqlite3_mprintf("unrecognized column option: %s", zArg);
237708 rc = SQLITE_ERROR;
237709 }
237710 }
@@ -237721,15 +237732,21 @@
237721 int rc = SQLITE_OK;
237722 Fts5Buffer buf = {0, 0, 0};
237723
237724 sqlite3Fts5BufferAppendPrintf(&rc, &buf, "T.%Q", p->zContentRowid);
237725 if( p->eContent!=FTS5_CONTENT_NONE ){
 
 
 
 
237726 for(i=0; i<p->nCol; i++){
237727 if( p->eContent==FTS5_CONTENT_EXTERNAL ){
237728 sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", T.%Q", p->azCol[i]);
237729 }else{
237730 sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", T.c%d", i);
 
 
237731 }
237732 }
237733 }
237734 if( p->eContent==FTS5_CONTENT_NORMAL && p->bLocale ){
237735 for(i=0; i<p->nCol; i++){
@@ -237768,10 +237785,11 @@
237768 ){
237769 int rc = SQLITE_OK; /* Return code */
237770 Fts5Config *pRet; /* New object to return */
237771 int i;
237772 sqlite3_int64 nByte;
 
237773
237774 *ppOut = pRet = (Fts5Config*)sqlite3_malloc(sizeof(Fts5Config));
237775 if( pRet==0 ) return SQLITE_NOMEM;
237776 memset(pRet, 0, sizeof(Fts5Config));
237777 pRet->pGlobal = pGlobal;
@@ -237827,11 +237845,11 @@
237827 ALWAYS(zOne)?zOne:"",
237828 zTwo?zTwo:"",
237829 pzErr
237830 );
237831 }else{
237832 rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr);
237833 zOne = 0;
237834 }
237835 }
237836 }
237837
@@ -237858,18 +237876,34 @@
237858 *pzErr = sqlite3_mprintf(
237859 "contentless_delete=1 is incompatible with columnsize=0"
237860 );
237861 rc = SQLITE_ERROR;
237862 }
 
 
 
 
 
 
 
 
 
 
 
 
 
237863
237864 /* If no zContent option was specified, fill in the default values. */
237865 if( rc==SQLITE_OK && pRet->zContent==0 ){
237866 const char *zTail = 0;
237867 assert( pRet->eContent==FTS5_CONTENT_NORMAL
237868 || pRet->eContent==FTS5_CONTENT_NONE
237869 );
237870 if( pRet->eContent==FTS5_CONTENT_NORMAL ){
 
 
 
237871 zTail = "content";
237872 }else if( pRet->bColumnsize ){
237873 zTail = "docsize";
237874 }
237875
@@ -247040,10 +247074,15 @@
247040 if( nPercent>=pConfig->nDeleteMerge && nPercent>nBest ){
247041 iRet = ii;
247042 nBest = nPercent;
247043 }
247044 }
 
 
 
 
 
247045 }
247046 }
247047 return iRet;
247048 }
247049
@@ -250964,11 +251003,11 @@
250964 return rc;
250965 }
250966
250967 /*
250968 ** We must have a single struct=? constraint that will be passed through
250969 ** into the xFilter method. If there is no valid stmt=? constraint,
250970 ** then return an SQLITE_CONSTRAINT error.
250971 */
250972 static int fts5structBestIndexMethod(
250973 sqlite3_vtab *tab,
250974 sqlite3_index_info *pIdxInfo
@@ -251555,14 +251594,20 @@
251555 #else
251556 # define fts5CheckTransactionState(x,y,z)
251557 #endif
251558
251559 /*
251560 ** Return true if pTab is a contentless table.
 
 
251561 */
251562 static int fts5IsContentless(Fts5FullTable *pTab){
251563 return pTab->p.pConfig->eContent==FTS5_CONTENT_NONE;
 
 
 
 
251564 }
251565
251566 /*
251567 ** Delete a virtual table handle allocated by fts5InitVtab().
251568 */
@@ -252949,11 +252994,11 @@
252949 }else{
252950 rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage);
252951 }
252952 bLoadConfig = 1;
252953 }else if( 0==sqlite3_stricmp("rebuild", zCmd) ){
252954 if( pConfig->eContent==FTS5_CONTENT_NONE ){
252955 fts5SetVtabError(pTab,
252956 "'rebuild' may not be used with a contentless fts5 table"
252957 );
252958 rc = SQLITE_ERROR;
252959 }else{
@@ -253018,17 +253063,78 @@
253018 sqlite3_value **apVal,
253019 i64 *piRowid
253020 ){
253021 int rc = *pRc;
253022 if( rc==SQLITE_OK ){
253023 rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, piRowid);
253024 }
253025 if( rc==SQLITE_OK ){
253026 rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *piRowid);
253027 }
253028 *pRc = rc;
253029 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253030
253031 /*
253032 ** This function is the implementation of the xUpdate callback used by
253033 ** FTS3 virtual tables. It is invoked by SQLite each time a row is to be
253034 ** inserted, updated or deleted.
@@ -253112,29 +253218,24 @@
253112 }
253113
253114 assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL );
253115 assert( nArg!=1 || eType0==SQLITE_INTEGER );
253116
253117 /* Filter out attempts to run UPDATE or DELETE on contentless tables.
253118 ** This is not suported. Except - they are both supported if the CREATE
253119 ** VIRTUAL TABLE statement contained "contentless_delete=1". */
253120 if( eType0==SQLITE_INTEGER
253121 && pConfig->eContent==FTS5_CONTENT_NONE
253122 && pConfig->bContentlessDelete==0
253123 ){
253124 pTab->p.base.zErrMsg = sqlite3_mprintf(
253125 "cannot %s contentless fts5 table: %s",
253126 (nArg>1 ? "UPDATE" : "DELETE from"), pConfig->zName
253127 );
253128 rc = SQLITE_ERROR;
253129 }
253130
253131 /* DELETE */
253132 else if( nArg==1 ){
253133 i64 iDel = sqlite3_value_int64(apVal[0]); /* Rowid to delete */
253134 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0, 0);
253135 bUpdateOrDelete = 1;
 
 
 
 
 
 
 
 
 
253136 }
253137
253138 /* INSERT or UPDATE */
253139 else{
253140 int eType1 = sqlite3_value_numeric_type(apVal[1]);
@@ -253164,39 +253265,59 @@
253164 fts5StorageInsert(&rc, pTab, apVal, pRowid);
253165 }
253166
253167 /* UPDATE */
253168 else{
253169 i64 iOld = sqlite3_value_int64(apVal[0]); /* Old rowid */
253170 i64 iNew = sqlite3_value_int64(apVal[1]); /* New rowid */
253171 if( eType1!=SQLITE_INTEGER ){
253172 rc = SQLITE_MISMATCH;
253173 }else if( iOld!=iNew ){
253174 if( eConflict==SQLITE_REPLACE ){
253175 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0, 1);
253176 if( rc==SQLITE_OK ){
253177 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0, 0);
253178 }
253179 fts5StorageInsert(&rc, pTab, apVal, pRowid);
253180 }else{
253181 rc = sqlite3Fts5StorageFindDeleteRow(pTab->pStorage, iOld);
253182 if( rc==SQLITE_OK ){
253183 rc = sqlite3Fts5StorageContentInsert(pTab->pStorage,apVal,pRowid);
253184 }
253185 if( rc==SQLITE_OK ){
253186 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0, 1);
253187 }
253188 if( rc==SQLITE_OK ){
253189 rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal,*pRowid);
253190 }
253191 }
253192 }else{
253193 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0, 1);
253194 fts5StorageInsert(&rc, pTab, apVal, pRowid);
253195 }
253196 bUpdateOrDelete = 1;
253197 sqlite3Fts5StorageReleaseDeleteRow(pTab->pStorage);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253198 }
253199
253200 }
253201 }
253202
@@ -253393,11 +253514,11 @@
253393 Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
253394
253395 assert( pCsr->ePlan!=FTS5_PLAN_SPECIAL );
253396 if( iCol<0 || iCol>=pTab->pConfig->nCol ){
253397 rc = SQLITE_RANGE;
253398 }else if( fts5IsContentless((Fts5FullTable*)(pCsr->base.pVtab)) ){
253399 *pz = 0;
253400 *pn = 0;
253401 }else{
253402 rc = fts5SeekCursor(pCsr, 0);
253403 if( rc==SQLITE_OK ){
@@ -253426,11 +253547,11 @@
253426 int bLive = (pCsr->pSorter==0);
253427
253428 if( iPhrase<0 || iPhrase>=sqlite3Fts5ExprPhraseCount(pCsr->pExpr) ){
253429 rc = SQLITE_RANGE;
253430 }else if( pConfig->eDetail!=FTS5_DETAIL_FULL
253431 && pConfig->eContent==FTS5_CONTENT_NONE
253432 ){
253433 *pa = 0;
253434 *pn = 0;
253435 return SQLITE_OK;
253436 }else if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_POSLIST) ){
@@ -253622,11 +253743,11 @@
253622
253623 if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_DOCSIZE) ){
253624 if( pConfig->bColumnsize ){
253625 i64 iRowid = fts5CursorRowid(pCsr);
253626 rc = sqlite3Fts5StorageDocsize(pTab->pStorage, iRowid, pCsr->aColumnSize);
253627 }else if( pConfig->zContent==0 ){
253628 int i;
253629 for(i=0; i<pConfig->nCol; i++){
253630 if( pConfig->abUnindexed[i]==0 ){
253631 pCsr->aColumnSize[i] = -1;
253632 }
@@ -253910,11 +254031,11 @@
253910 assert( pCsr->ePlan!=FTS5_PLAN_SPECIAL );
253911 if( iCol<0 || iCol>=pConfig->nCol ){
253912 rc = SQLITE_RANGE;
253913 }else if(
253914 pConfig->abUnindexed[iCol]==0
253915 && pConfig->eContent!=FTS5_CONTENT_NONE
253916 && pConfig->bLocale
253917 ){
253918 rc = fts5SeekCursor(pCsr, 0);
253919 if( rc==SQLITE_OK ){
253920 const char *zDummy = 0;
@@ -254185,20 +254306,11 @@
254185 if( pCsr->pRank || SQLITE_OK==(rc = fts5FindRankFunction(pCsr)) ){
254186 fts5ApiInvoke(pCsr->pRank, pCsr, pCtx, pCsr->nRankArg, pCsr->apRankArg);
254187 }
254188 }
254189 }else{
254190 /* A column created by the user containing values. */
254191 int bNochange = sqlite3_vtab_nochange(pCtx);
254192
254193 if( fts5IsContentless(pTab) ){
254194 if( bNochange && pConfig->bContentlessDelete ){
254195 fts5ResultError(pCtx, "cannot UPDATE a subset of "
254196 "columns on fts5 contentless-delete table: %s", pConfig->zName
254197 );
254198 }
254199 }else if( bNochange==0 || pConfig->eContent!=FTS5_CONTENT_NORMAL ){
254200 pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
254201 rc = fts5SeekCursor(pCsr, 1);
254202 if( rc==SQLITE_OK ){
254203 sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, iCol+1);
254204 if( pConfig->bLocale
@@ -254737,11 +254849,11 @@
254737 int nArg, /* Number of args */
254738 sqlite3_value **apUnused /* Function arguments */
254739 ){
254740 assert( nArg==0 );
254741 UNUSED_PARAM2(nArg, apUnused);
254742 sqlite3_result_text(pCtx, "fts5: 2024-09-25 16:11:27 660ca5ce6600d897cc2b00b9d39e5d993c1c0e71ec0d5dc706246c053a163281", -1, SQLITE_TRANSIENT);
254743 }
254744
254745 /*
254746 ** Implementation of fts5_locale(LOCALE, TEXT) function.
254747 **
@@ -255065,34 +255177,10 @@
255065 #define FTS5_STMT_DELETE_DOCSIZE 8
255066 #define FTS5_STMT_LOOKUP_DOCSIZE 9
255067 #define FTS5_STMT_REPLACE_CONFIG 10
255068 #define FTS5_STMT_SCAN 11
255069
255070 /*
255071 ** Return a pointer to a buffer obtained from sqlite3_malloc() that contains
255072 ** nBind comma-separated question marks. e.g. if nBind is passed 5, this
255073 ** function returns "?,?,?,?,?".
255074 **
255075 ** If *pRc is not SQLITE_OK when this function is called, it is a no-op and
255076 ** NULL is returned immediately. Or, if the attempt to malloc a buffer
255077 ** fails, then *pRc is set to SQLITE_NOMEM and NULL is returned. Otherwise,
255078 ** if it is SQLITE_OK when this function is called and the malloc() succeeds,
255079 ** *pRc is left unchanged.
255080 */
255081 static char *fts5BindingsList(int *pRc, int nBind){
255082 char *zBind = sqlite3Fts5MallocZero(pRc, 1 + nBind*2);
255083 if( zBind ){
255084 int ii;
255085 for(ii=0; ii<nBind; ii++){
255086 zBind[ii*2] = '?';
255087 zBind[ii*2 + 1] = ',';
255088 }
255089 zBind[ii*2-1] = '\0';
255090 }
255091 return zBind;
255092 }
255093
255094 /*
255095 ** Prepare the two insert statements - Fts5Storage.pInsertContent and
255096 ** Fts5Storage.pInsertDocsize - if they have not already been prepared.
255097 ** Return SQLITE_OK if successful, or an SQLite error code if an error
255098 ** occurs.
@@ -255157,27 +255245,41 @@
255157 zSql = sqlite3_mprintf(azStmt[eStmt],
255158 pC->zContentExprlist, pC->zContent, pC->zContentRowid
255159 );
255160 break;
255161
255162 case FTS5_STMT_INSERT_CONTENT: {
255163 int nCol = 0;
255164 char *zBind;
255165 int i;
255166
255167 nCol = 1 + pC->nCol;
255168 if( pC->bLocale ){
255169 for(i=0; i<pC->nCol; i++){
255170 if( pC->abUnindexed[i]==0 ) nCol++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255171 }
255172 }
255173
255174 zBind = fts5BindingsList(&rc, nCol);
255175 if( zBind ){
255176 zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName, zBind);
255177 sqlite3_free(zBind);
255178 }
255179 break;
255180 }
255181
255182 case FTS5_STMT_REPLACE_DOCSIZE:
255183 zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName,
@@ -255359,11 +255461,13 @@
255359 p->aTotalSize = (i64*)&p[1];
255360 p->pConfig = pConfig;
255361 p->pIndex = pIndex;
255362
255363 if( bCreate ){
255364 if( pConfig->eContent==FTS5_CONTENT_NORMAL ){
 
 
255365 int nDefn = 32 + pConfig->nCol*10;
255366 char *zDefn = sqlite3_malloc64(32 + (sqlite3_int64)pConfig->nCol * 20);
255367 if( zDefn==0 ){
255368 rc = SQLITE_NOMEM;
255369 }else{
@@ -255370,12 +255474,16 @@
255370 int i;
255371 int iOff;
255372 sqlite3_snprintf(nDefn, zDefn, "id INTEGER PRIMARY KEY");
255373 iOff = (int)strlen(zDefn);
255374 for(i=0; i<pConfig->nCol; i++){
255375 sqlite3_snprintf(nDefn-iOff, &zDefn[iOff], ", c%d", i);
255376 iOff += (int)strlen(&zDefn[iOff]);
 
 
 
 
255377 }
255378 if( pConfig->bLocale ){
255379 for(i=0; i<pConfig->nCol; i++){
255380 if( pConfig->abUnindexed[i]==0 ){
255381 sqlite3_snprintf(nDefn-iOff, &zDefn[iOff], ", l%d", i);
@@ -255609,11 +255717,13 @@
255609 i64 iOrigin = 0;
255610 sqlite3_stmt *pLookup = 0;
255611 int rc = SQLITE_OK;
255612
255613 assert( p->pConfig->bContentlessDelete );
255614 assert( p->pConfig->eContent==FTS5_CONTENT_NONE );
 
 
255615
255616 /* Look up the origin of the document in the %_docsize table. Store
255617 ** this in stack variable iOrigin. */
255618 rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP_DOCSIZE, &pLookup, 0);
255619 if( rc==SQLITE_OK ){
@@ -255733,10 +255843,16 @@
255733 }
255734
255735 if( rc==SQLITE_OK ){
255736 if( p->pConfig->bContentlessDelete ){
255737 rc = fts5StorageContentlessDelete(p, iDel);
 
 
 
 
 
 
255738 }else{
255739 rc = fts5StorageDeleteFromIndex(p, iDel, apVal, bSaveRow);
255740 }
255741 }
255742
@@ -255749,11 +255865,13 @@
255749 rc = sqlite3_reset(pDel);
255750 }
255751 }
255752
255753 /* Delete the %_content record */
255754 if( pConfig->eContent==FTS5_CONTENT_NORMAL ){
 
 
255755 if( rc==SQLITE_OK ){
255756 rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_CONTENT, &pDel, 0);
255757 }
255758 if( rc==SQLITE_OK ){
255759 sqlite3_bind_int64(pDel, 1, iDel);
@@ -255781,12 +255899,17 @@
255781 pConfig->zDb, pConfig->zName,
255782 pConfig->zDb, pConfig->zName
255783 );
255784 if( rc==SQLITE_OK && pConfig->bColumnsize ){
255785 rc = fts5ExecPrintf(pConfig->db, 0,
255786 "DELETE FROM %Q.'%q_docsize';",
255787 pConfig->zDb, pConfig->zName
 
 
 
 
 
255788 );
255789 }
255790
255791 /* Reinitialize the %_data table. This call creates the initial structure
255792 ** and averages records. */
@@ -255918,69 +256041,75 @@
255918 /*
255919 ** Insert a new row into the FTS content table.
255920 */
255921 static int sqlite3Fts5StorageContentInsert(
255922 Fts5Storage *p,
 
255923 sqlite3_value **apVal,
255924 i64 *piRowid
255925 ){
255926 Fts5Config *pConfig = p->pConfig;
255927 int rc = SQLITE_OK;
255928
255929 /* Insert the new row into the %_content table. */
255930 if( pConfig->eContent!=FTS5_CONTENT_NORMAL ){
 
 
255931 if( sqlite3_value_type(apVal[1])==SQLITE_INTEGER ){
255932 *piRowid = sqlite3_value_int64(apVal[1]);
255933 }else{
255934 rc = fts5StorageNewRowid(p, piRowid);
255935 }
255936 }else{
255937 sqlite3_stmt *pInsert = 0; /* Statement to write %_content table */
255938 int i; /* Counter variable */
255939 int nIndexed = 0; /* Number indexed columns seen */
255940 rc = fts5StorageGetStmt(p, FTS5_STMT_INSERT_CONTENT, &pInsert, 0);
 
 
255941 if( pInsert ) sqlite3_clear_bindings(pInsert);
255942
255943 /* Bind the rowid value */
255944 sqlite3_bind_value(pInsert, 1, apVal[1]);
255945
255946 /* Loop through values for user-defined columns. i=2 is the leftmost
255947 ** user-defined column. As is column 1 of pSavedRow. */
255948 for(i=2; rc==SQLITE_OK && i<=pConfig->nCol+1; i++){
255949 int bUnindexed = pConfig->abUnindexed[i-2];
255950 sqlite3_value *pVal = apVal[i];
255951
255952 nIndexed += !bUnindexed;
255953 if( sqlite3_value_nochange(pVal) && p->pSavedRow ){
255954 /* This is an UPDATE statement, and column (i-2) was not modified.
255955 ** Retrieve the value from Fts5Storage.pSavedRow instead. */
255956 pVal = sqlite3_column_value(p->pSavedRow, i-1);
255957 if( pConfig->bLocale && bUnindexed==0 ){
255958 sqlite3_bind_value(pInsert, pConfig->nCol + 1 + nIndexed,
255959 sqlite3_column_value(p->pSavedRow, pConfig->nCol + i - 1)
255960 );
255961 }
255962 }else if( sqlite3Fts5IsLocaleValue(pConfig, pVal) ){
255963 const char *pText = 0;
255964 const char *pLoc = 0;
255965 int nText = 0;
255966 int nLoc = 0;
255967 assert( pConfig->bLocale );
255968
255969 rc = sqlite3Fts5DecodeLocaleValue(pVal, &pText, &nText, &pLoc, &nLoc);
255970 if( rc==SQLITE_OK ){
255971 sqlite3_bind_text(pInsert, i, pText, nText, SQLITE_TRANSIENT);
255972 if( bUnindexed==0 ){
255973 int iLoc = pConfig->nCol + 1 + nIndexed;
255974 sqlite3_bind_text(pInsert, iLoc, pLoc, nLoc, SQLITE_TRANSIENT);
255975 }
255976 }
255977
255978 continue;
255979 }
255980
255981 rc = sqlite3_bind_value(pInsert, i, pVal);
 
255982 }
255983 if( rc==SQLITE_OK ){
255984 sqlite3_step(pInsert);
255985 rc = sqlite3_reset(pInsert);
255986 }
255987
--- 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 ** 011fab70cb3d194b27742ebb236b05be5822.
22 */
23 #define SQLITE_CORE 1
24 #define SQLITE_AMALGAMATION 1
25 #ifndef SQLITE_PRIVATE
26 # define SQLITE_PRIVATE static
@@ -462,11 +462,11 @@
462 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
463 ** [sqlite_version()] and [sqlite_source_id()].
464 */
465 #define SQLITE_VERSION "3.47.0"
466 #define SQLITE_VERSION_NUMBER 3047000
467 #define SQLITE_SOURCE_ID "2024-10-07 12:48:21 011fab70cb3d194b27742ebb236b05be582230567cf78e3e6cac6911de86922f"
468
469 /*
470 ** CAPI3REF: Run-Time Library Version Numbers
471 ** KEYWORDS: sqlite3_version sqlite3_sourceid
472 **
@@ -5917,11 +5917,11 @@
5917 ** The SQLITE_SUBTYPE flag indicates to SQLite that a function might call
5918 ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments.
5919 ** This flag instructs SQLite to omit some corner-case optimizations that
5920 ** might disrupt the operation of the [sqlite3_value_subtype()] function,
5921 ** causing it to return zero rather than the correct subtype().
5922 ** All SQL functions that invoke [sqlite3_value_subtype()] should have this
5923 ** property. If the SQLITE_SUBTYPE property is omitted, then the return
5924 ** value from [sqlite3_value_subtype()] might sometimes be zero even though
5925 ** a non-zero subtype was specified by the function argument expression.
5926 **
5927 ** [[SQLITE_RESULT_SUBTYPE]] <dt>SQLITE_RESULT_SUBTYPE</dt><dd>
@@ -8682,11 +8682,11 @@
8682 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
8683 #define SQLITE_TESTCTRL_SEEK_COUNT 30
8684 #define SQLITE_TESTCTRL_TRACEFLAGS 31
8685 #define SQLITE_TESTCTRL_TUNE 32
8686 #define SQLITE_TESTCTRL_LOGEST 33
8687 #define SQLITE_TESTCTRL_USELONGDOUBLE 34 /* NOT USED */
8688 #define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
8689
8690 /*
8691 ** CAPI3REF: SQL Keyword Checking
8692 **
@@ -10856,10 +10856,18 @@
10856 ** schema S in database connection D. ^On success, the
10857 ** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
10858 ** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
10859 ** If there is not already a read-transaction open on schema S when
10860 ** this function is called, one is opened automatically.
10861 **
10862 ** If a read-transaction is opened by this function, then it is guaranteed
10863 ** that the returned snapshot object may not be invalidated by a database
10864 ** writer or checkpointer until after the read-transaction is closed. This
10865 ** is not guaranteed if a read-transaction is already open when this
10866 ** function is called. In that case, any subsequent write or checkpoint
10867 ** operation on the database may invalidate the returned snapshot handle,
10868 ** even while the read-transaction remains open.
10869 **
10870 ** The following must be true for this function to succeed. If any of
10871 ** the following statements are false when sqlite3_snapshot_get() is
10872 ** called, SQLITE_ERROR is returned. The final value of *P is undefined
10873 ** in this case.
@@ -14813,10 +14821,11 @@
14821 #include <stdio.h>
14822 #include <stdlib.h>
14823 #include <string.h>
14824 #include <assert.h>
14825 #include <stddef.h>
14826 #include <ctype.h>
14827
14828 /*
14829 ** Use a macro to replace memcpy() if compiled with SQLITE_INLINE_MEMCPY.
14830 ** This allows better measurements of where memcpy() is used when running
14831 ** cachegrind. But this macro version of memcpy() is very slow so it
@@ -14835,11 +14844,10 @@
14844 #ifdef SQLITE_OMIT_FLOATING_POINT
14845 # define double sqlite_int64
14846 # define float sqlite_int64
14847 # define fabs(X) ((X)<0?-(X):(X))
14848 # define sqlite3IsOverflow(X) 0
 
14849 # ifndef SQLITE_BIG_DBL
14850 # define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50)
14851 # endif
14852 # define SQLITE_OMIT_DATETIME_FUNCS 1
14853 # define SQLITE_OMIT_TRACE 1
@@ -15010,13 +15018,10 @@
15018 # define INT8_TYPE int8_t
15019 # else
15020 # define INT8_TYPE signed char
15021 # endif
15022 #endif
 
 
 
15023 typedef sqlite_int64 i64; /* 8-byte signed integer */
15024 typedef sqlite_uint64 u64; /* 8-byte unsigned integer */
15025 typedef UINT32_TYPE u32; /* 4-byte unsigned integer */
15026 typedef UINT16_TYPE u16; /* 2-byte unsigned integer */
15027 typedef INT16_TYPE i16; /* 2-byte signed integer */
@@ -20380,11 +20385,10 @@
20385 u8 bFullMutex; /* True to enable full mutexing */
20386 u8 bOpenUri; /* True to interpret filenames as URIs */
20387 u8 bUseCis; /* Use covering indices for full-scans */
20388 u8 bSmallMalloc; /* Avoid large memory allocations if true */
20389 u8 bExtraSchemaChecks; /* Verify type,name,tbl_name in schema */
 
20390 #ifdef SQLITE_DEBUG
20391 u8 bJsonSelfcheck; /* Double-check JSON parsing */
20392 #endif
20393 int mxStrlen; /* Maximum string length */
20394 int neverCorrupt; /* Database is always well-formed */
@@ -20755,19 +20759,10 @@
20759 */
20760 #if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)
20761 # define SQLITE_ENABLE_FTS3 1
20762 #endif
20763
 
 
 
 
 
 
 
 
 
20764 /*
20765 ** The following macros mimic the standard library functions toupper(),
20766 ** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The
20767 ** sqlite versions only work for ASCII characters, regardless of locale.
20768 */
@@ -23121,11 +23116,10 @@
23116 SQLITE_THREADSAFE==1, /* bFullMutex */
23117 SQLITE_USE_URI, /* bOpenUri */
23118 SQLITE_ALLOW_COVERING_INDEX_SCAN, /* bUseCis */
23119 0, /* bSmallMalloc */
23120 1, /* bExtraSchemaChecks */
 
23121 #ifdef SQLITE_DEBUG
23122 0, /* bJsonSelfcheck */
23123 #endif
23124 0x7ffffffe, /* mxStrlen */
23125 0, /* neverCorrupt */
@@ -35679,10 +35673,12 @@
35673 int esign = 1; /* sign of exponent */
35674 int e = 0; /* exponent */
35675 int eValid = 1; /* True exponent is either not used or is well-formed */
35676 int nDigit = 0; /* Number of digits processed */
35677 int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */
35678 double rr[2];
35679 u64 s2;
35680
35681 assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
35682 *pResult = 0.0; /* Default return value, in case of an error */
35683 if( length==0 ) return 0;
35684
@@ -35790,72 +35786,45 @@
35786 while( e<0 && (s%10)==0 ){
35787 s /= 10;
35788 e++;
35789 }
35790
35791 rr[0] = (double)s;
35792 s2 = (u64)rr[0];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35793 #if defined(_MSC_VER) && _MSC_VER<1700
35794 if( s2==0x8000000000000000LL ){ s2 = 2*(u64)(0.5*rr[0]); }
35795 #endif
35796 rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s);
35797 if( e>0 ){
35798 while( e>=100 ){
35799 e -= 100;
35800 dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83);
35801 }
35802 while( e>=10 ){
35803 e -= 10;
35804 dekkerMul2(rr, 1.0e+10, 0.0);
35805 }
35806 while( e>=1 ){
35807 e -= 1;
35808 dekkerMul2(rr, 1.0e+01, 0.0);
35809 }
35810 }else{
35811 while( e<=-100 ){
35812 e += 100;
35813 dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117);
35814 }
35815 while( e<=-10 ){
35816 e += 10;
35817 dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27);
35818 }
35819 while( e<=-1 ){
35820 e += 1;
35821 dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18);
35822 }
35823 }
35824 *pResult = rr[0]+rr[1];
35825 if( sqlite3IsNaN(*pResult) ) *pResult = 1e300*1e300;
 
35826 if( sign<0 ) *pResult = -*pResult;
35827 assert( !sqlite3IsNaN(*pResult) );
35828
35829 atof_return:
35830 /* return true if number and no extra non-whitespace characters after */
@@ -36172,13 +36141,14 @@
36141 */
36142 SQLITE_PRIVATE void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){
36143 int i;
36144 u64 v;
36145 int e, exp = 0;
36146 double rr[2];
36147
36148 p->isSpecial = 0;
36149 p->z = p->zBuf;
 
36150 assert( mxRound>0 );
36151
36152 /* Convert negative numbers to positive. Deal with Infinity, 0.0, and
36153 ** NaN. */
36154 if( r<0.0 ){
@@ -36202,66 +36172,49 @@
36172 return;
36173 }
36174
36175 /* Multiply r by powers of ten until it lands somewhere in between
36176 ** 1.0e+19 and 1.0e+17.
36177 **
36178 ** Use Dekker-style double-double computation to increase the
36179 ** precision.
36180 **
36181 ** The error terms on constants like 1.0e+100 computed using the
36182 ** decimal extension, for example as follows:
36183 **
36184 ** SELECT decimal_exp(decimal_sub('1.0e+100',decimal(1.0e+100)));
36185 */
36186 rr[0] = r;
36187 rr[1] = 0.0;
36188 if( rr[0]>9.223372036854774784e+18 ){
36189 while( rr[0]>9.223372036854774784e+118 ){
36190 exp += 100;
36191 dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117);
36192 }
36193 while( rr[0]>9.223372036854774784e+28 ){
36194 exp += 10;
36195 dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27);
36196 }
36197 while( rr[0]>9.223372036854774784e+18 ){
36198 exp += 1;
36199 dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18);
36200 }
36201 }else{
36202 while( rr[0]<9.223372036854774784e-83 ){
36203 exp -= 100;
36204 dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83);
36205 }
36206 while( rr[0]<9.223372036854774784e+07 ){
36207 exp -= 10;
36208 dekkerMul2(rr, 1.0e+10, 0.0);
36209 }
36210 while( rr[0]<9.22337203685477478e+17 ){
36211 exp -= 1;
36212 dekkerMul2(rr, 1.0e+01, 0.0);
36213 }
36214 }
36215 v = rr[1]<0.0 ? (u64)rr[0]-(u64)(-rr[1]) : (u64)rr[0]+(u64)rr[1];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36216
36217 /* Extract significant digits. */
36218 i = sizeof(p->zBuf)-1;
36219 assert( v>0 );
36220 while( v ){ p->zBuf[i--] = (v%10) + '0'; v /= 10; }
@@ -65688,10 +65641,11 @@
65641 int nSehTry; /* Number of nested SEH_TRY{} blocks */
65642 u8 lockError; /* True if a locking error has occurred */
65643 #endif
65644 #ifdef SQLITE_ENABLE_SNAPSHOT
65645 WalIndexHdr *pSnapshot; /* Start transaction here if not NULL */
65646 int bGetSnapshot; /* Transaction opened for sqlite3_get_snapshot() */
65647 #endif
65648 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
65649 sqlite3 *db;
65650 #endif
65651 };
@@ -68244,11 +68198,11 @@
68198 assert( pWal->apWiData[0]!=0 );
68199 pInfo = walCkptInfo(pWal);
68200 SEH_INJECT_FAULT;
68201 if( !useWal && AtomicLoad(&pInfo->nBackfill)==pWal->hdr.mxFrame
68202 #ifdef SQLITE_ENABLE_SNAPSHOT
68203 && ((pWal->bGetSnapshot==0 && pWal->pSnapshot==0) || pWal->hdr.mxFrame==0)
68204 #endif
68205 ){
68206 /* The WAL has been completely backfilled (or it is empty).
68207 ** and can be safely ignored.
68208 */
@@ -69644,11 +69598,24 @@
69598 */
69599 SQLITE_PRIVATE void sqlite3WalSnapshotOpen(
69600 Wal *pWal,
69601 sqlite3_snapshot *pSnapshot
69602 ){
69603 if( pSnapshot && ((WalIndexHdr*)pSnapshot)->iVersion==0 ){
69604 /* iVersion==0 means that this is a call to sqlite3_snapshot_get(). In
69605 ** this case set the bGetSnapshot flag so that if the call to
69606 ** sqlite3_snapshot_get() is about to read transaction on this wal
69607 ** file, it does not take read-lock 0 if the wal file has been completely
69608 ** checkpointed. Taking read-lock 0 would work, but then it would be
69609 ** possible for a subsequent writer to destroy the snapshot even while
69610 ** this connection is holding its read-transaction open. This is contrary
69611 ** to user expectations, so we avoid it by not taking read-lock 0. */
69612 pWal->bGetSnapshot = 1;
69613 }else{
69614 pWal->pSnapshot = (WalIndexHdr*)pSnapshot;
69615 pWal->bGetSnapshot = 0;
69616 }
69617 }
69618
69619 /*
69620 ** Return a +ve value if snapshot p1 is newer than p2. A -ve value if
69621 ** p1 is older than p2 and zero if p1 and p2 are the same snapshot.
@@ -89592,11 +89559,11 @@
89559 /* The following two functions are used only within testcase() to prove
89560 ** test coverage. These functions do no exist for production builds.
89561 ** We must use separate SQLITE_NOINLINE functions here, since otherwise
89562 ** optimizer code movement causes gcov to become very confused.
89563 */
89564 #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG)
89565 static int SQLITE_NOINLINE doubleLt(double a, double b){ return a<b; }
89566 static int SQLITE_NOINLINE doubleEq(double a, double b){ return a==b; }
89567 #endif
89568
89569 /*
@@ -89607,17 +89574,10 @@
89574 SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){
89575 if( sqlite3IsNaN(r) ){
89576 /* SQLite considers NaN to be a NULL. And all integer values are greater
89577 ** than NULL */
89578 return 1;
 
 
 
 
 
 
 
89579 }else{
89580 i64 y;
89581 if( r<-9223372036854775808.0 ) return +1;
89582 if( r>=9223372036854775808.0 ) return -1;
89583 y = (i64)r;
@@ -131787,11 +131747,17 @@
131747 #ifdef SQLITE_DEBUG
131748 /*
131749 ** Implementation of fpdecode(x,y,z) function.
131750 **
131751 ** x is a real number that is to be decoded. y is the precision.
131752 ** z is the maximum real precision. Return a string that shows the
131753 ** results of the sqlite3FpDecode() function.
131754 **
131755 ** Used for testing and debugging only, specifically testing and debugging
131756 ** of the sqlite3FpDecode() function. This SQL function does not appear
131757 ** in production builds. This function is not an API and is subject to
131758 ** modification or removal in future versions of SQLite.
131759 */
131760 static void fpdecodeFunc(
131761 sqlite3_context *context,
131762 int argc,
131763 sqlite3_value **argv
@@ -131811,10 +131777,86 @@
131777 sqlite3_snprintf(sizeof(zBuf), zBuf, "NaN");
131778 }else{
131779 sqlite3_snprintf(sizeof(zBuf), zBuf, "%c%.*s/%d", s.sign, s.n, s.z, s.iDP);
131780 }
131781 sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
131782 }
131783 #endif /* SQLITE_DEBUG */
131784
131785 #ifdef SQLITE_DEBUG
131786 /*
131787 ** Implementation of parseuri(uri,flags) function.
131788 **
131789 ** Required Arguments:
131790 ** "uri" The URI to parse.
131791 ** "flags" Bitmask of flags, as if to sqlite3_open_v2().
131792 **
131793 ** Additional arguments beyond the first two make calls to
131794 ** sqlite3_uri_key() for integers and sqlite3_uri_parameter for
131795 ** anything else.
131796 **
131797 ** The result is a string showing the results of calling sqlite3ParseUri().
131798 **
131799 ** Used for testing and debugging only, specifically testing and debugging
131800 ** of the sqlite3ParseUri() function. This SQL function does not appear
131801 ** in production builds. This function is not an API and is subject to
131802 ** modification or removal in future versions of SQLite.
131803 */
131804 static void parseuriFunc(
131805 sqlite3_context *ctx,
131806 int argc,
131807 sqlite3_value **argv
131808 ){
131809 sqlite3_str *pResult;
131810 const char *zVfs;
131811 const char *zUri;
131812 unsigned int flgs;
131813 int rc;
131814 sqlite3_vfs *pVfs = 0;
131815 char *zFile = 0;
131816 char *zErr = 0;
131817
131818 if( argc<2 ) return;
131819 pVfs = sqlite3_vfs_find(0);
131820 assert( pVfs );
131821 zVfs = pVfs->zName;
131822 zUri = (const char*)sqlite3_value_text(argv[0]);
131823 if( zUri==0 ) return;
131824 flgs = (unsigned int)sqlite3_value_int(argv[1]);
131825 rc = sqlite3ParseUri(zVfs, zUri, &flgs, &pVfs, &zFile, &zErr);
131826 pResult = sqlite3_str_new(0);
131827 if( pResult ){
131828 int i;
131829 sqlite3_str_appendf(pResult, "rc=%d", rc);
131830 sqlite3_str_appendf(pResult, ", flags=0x%x", flgs);
131831 sqlite3_str_appendf(pResult, ", vfs=%Q", pVfs ? pVfs->zName: 0);
131832 sqlite3_str_appendf(pResult, ", err=%Q", zErr);
131833 sqlite3_str_appendf(pResult, ", file=%Q", zFile);
131834 if( zFile ){
131835 const char *z = zFile;
131836 z += sqlite3Strlen30(z)+1;
131837 while( z[0] ){
131838 sqlite3_str_appendf(pResult, ", %Q", z);
131839 z += sqlite3Strlen30(z)+1;
131840 }
131841 for(i=2; i<argc; i++){
131842 const char *zArg;
131843 if( sqlite3_value_type(argv[i])==SQLITE_INTEGER ){
131844 int k = sqlite3_value_int(argv[i]);
131845 sqlite3_str_appendf(pResult, ", '%d:%q'",k,sqlite3_uri_key(zFile, k));
131846 }else if( (zArg = (const char*)sqlite3_value_text(argv[i]))!=0 ){
131847 sqlite3_str_appendf(pResult, ", '%q:%q'",
131848 zArg, sqlite3_uri_parameter(zFile,zArg));
131849 }else{
131850 sqlite3_str_appendf(pResult, ", NULL");
131851 }
131852 }
131853 }
131854 sqlite3_result_text(ctx, sqlite3_str_finish(pResult), -1, sqlite3_free);
131855 }
131856 sqlite3_free_filename(zFile);
131857 sqlite3_free(zErr);
131858 }
131859 #endif /* SQLITE_DEBUG */
131860
131861 /*
131862 ** All of the FuncDef structures in the aBuiltinFunc[] array above
@@ -131887,10 +131929,11 @@
131929 FUNCTION(unicode, 1, 0, 0, unicodeFunc ),
131930 FUNCTION(char, -1, 0, 0, charFunc ),
131931 FUNCTION(abs, 1, 0, 0, absFunc ),
131932 #ifdef SQLITE_DEBUG
131933 FUNCTION(fpdecode, 3, 0, 0, fpdecodeFunc ),
131934 FUNCTION(parseuri, -1, 0, 0, parseuriFunc ),
131935 #endif
131936 #ifndef SQLITE_OMIT_FLOATING_POINT
131937 FUNCTION(round, 1, 0, 0, roundFunc ),
131938 FUNCTION(round, 2, 0, 0, roundFunc ),
131939 #endif
@@ -141115,10 +141158,11 @@
141158 }
141159 aRoot[0] = cnt;
141160
141161 /* Make sure sufficient number of registers have been allocated */
141162 sqlite3TouchRegister(pParse, 8+cnt);
141163 sqlite3VdbeAddOp3(v, OP_Null, 0, 8, 8+cnt);
141164 sqlite3ClearTempRegCache(pParse);
141165
141166 /* Do the b-tree integrity checks */
141167 sqlite3VdbeAddOp4(v, OP_IntegrityCk, 1, cnt, 8, (char*)aRoot,P4_INTARRAY);
141168 sqlite3VdbeChangeP5(v, (u8)i);
@@ -161344,24 +161388,29 @@
161388 }else if( op==TK_STRING ){
161389 assert( !ExprHasProperty(pRight, EP_IntValue) );
161390 z = (u8*)pRight->u.zToken;
161391 }
161392 if( z ){
161393 /* Count the number of prefix bytes prior to the first wildcard.
161394 ** or U+fffd character. If the underlying database has a UTF16LE
161395 ** encoding, then only consider ASCII characters. Note that the
161396 ** encoding of z[] is UTF8 - we are dealing with only UTF8 here in
161397 ** this code, but the database engine itself might be processing
161398 ** content using a different encoding. */
161399 cnt = 0;
161400 while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
161401 cnt++;
161402 if( c==wc[3] && z[cnt]!=0 ){
161403 cnt++;
161404 }else if( c>=0x80 ){
161405 const u8 *z2 = z+cnt-1;
161406 if( sqlite3Utf8Read(&z2)==0xfffd || ENC(db)==SQLITE_UTF16LE ){
161407 cnt--;
161408 break;
161409 }else{
161410 cnt = (int)(z2-z);
161411 }
161412 }
161413 }
161414
161415 /* The optimization is possible only if (1) the pattern does not begin
161416 ** with a wildcard and if (2) the non-wildcard prefix does not end with
@@ -161369,11 +161418,11 @@
161418 ** a single escape character. The second condition is necessary so
161419 ** that we can increment the prefix key to find an upper bound for the
161420 ** range search. The third is because the caller assumes that the pattern
161421 ** consists of at least one character after all escapes have been
161422 ** removed. */
161423 if( (cnt>1 || (cnt>0 && z[0]!=wc[3])) && ALWAYS(255!=(u8)z[cnt-1]) ){
161424 Expr *pPrefix;
161425
161426 /* A "complete" match if the pattern ends with "*" or "%" */
161427 *pisComplete = c==wc[0] && z[cnt+1]==0 && ENC(db)!=SQLITE_UTF16LE;
161428
@@ -181161,36 +181210,10 @@
181210 ** all database files specified with a relative pathname.
181211 **
181212 ** See also the "PRAGMA data_store_directory" SQL command.
181213 */
181214 SQLITE_API char *sqlite3_data_directory = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181215
181216 /*
181217 ** Initialize SQLite.
181218 **
181219 ** This routine must be called to initialize the memory allocation,
@@ -181382,17 +181405,10 @@
181405 if( bRunExtraInit ){
181406 int SQLITE_EXTRA_INIT(const char*);
181407 rc = SQLITE_EXTRA_INIT(0);
181408 }
181409 #endif
 
 
 
 
 
 
 
181410 return rc;
181411 }
181412
181413 /*
181414 ** Undo the effects of sqlite3_initialize(). Must not be called while
@@ -185640,28 +185656,10 @@
185656 *pI1 = rLogEst;
185657 *pU64 = sqlite3LogEstToInt(rLogEst);
185658 *pI2 = sqlite3LogEst(*pU64);
185659 break;
185660 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185661
185662 #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD)
185663 /* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue)
185664 **
185665 ** If "id" is an integer between 1 and SQLITE_NTUNE then set the value
@@ -185966,11 +185964,15 @@
185964 if( db->autoCommit==0 ){
185965 int iDb = sqlite3FindDbName(db, zDb);
185966 if( iDb==0 || iDb>1 ){
185967 Btree *pBt = db->aDb[iDb].pBt;
185968 if( SQLITE_TXN_WRITE!=sqlite3BtreeTxnState(pBt) ){
185969 Pager *pPager = sqlite3BtreePager(pBt);
185970 i64 dummy = 0;
185971 sqlite3PagerSnapshotOpen(pPager, (sqlite3_snapshot*)&dummy);
185972 rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
185973 sqlite3PagerSnapshotOpen(pPager, 0);
185974 if( rc==SQLITE_OK ){
185975 rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);
185976 }
185977 }
185978 }
@@ -225801,12 +225803,12 @@
225803 };
225804
225805 struct DbpageTable {
225806 sqlite3_vtab base; /* Base class. Must be first */
225807 sqlite3 *db; /* The database */
225808 int iDbTrunc; /* Database to truncate */
225809 Pgno pgnoTrunc; /* Size to truncate to */
225810 };
225811
225812 /* Columns */
225813 #define DBPAGE_COLUMN_PGNO 0
225814 #define DBPAGE_COLUMN_DATA 1
@@ -225851,12 +225853,10 @@
225853
225854 /*
225855 ** Disconnect from or destroy a dbpagevfs virtual table.
225856 */
225857 static int dbpageDisconnect(sqlite3_vtab *pVtab){
 
 
225858 sqlite3_free(pVtab);
225859 return SQLITE_OK;
225860 }
225861
225862 /*
@@ -226119,23 +226119,16 @@
226119 }
226120 szPage = sqlite3BtreeGetPageSize(pBt);
226121 if( sqlite3_value_type(argv[3])!=SQLITE_BLOB
226122 || sqlite3_value_bytes(argv[3])!=szPage
226123 ){
226124 if( sqlite3_value_type(argv[3])==SQLITE_NULL && isInsert && pgno>1 ){
226125 /* "INSERT INTO dbpage($PGNO,NULL)" causes page number $PGNO and
226126 ** all subsequent pages to be deleted. */
226127 pTab->iDbTrunc = iDb;
226128 pgno--;
226129 pTab->pgnoTrunc = pgno;
 
 
 
 
 
 
 
226130 }else{
226131 zErr = "bad page value";
226132 goto update_fail;
226133 }
226134 }
@@ -226144,10 +226137,11 @@
226137 if( rc==SQLITE_OK ){
226138 const void *pData = sqlite3_value_blob(argv[3]);
226139 if( (rc = sqlite3PagerWrite(pDbPage))==SQLITE_OK && pData ){
226140 unsigned char *aPage = sqlite3PagerGetData(pDbPage);
226141 memcpy(aPage, pData, szPage);
226142 pTab->pgnoTrunc = 0;
226143 }
226144 }
226145 sqlite3PagerUnref(pDbPage);
226146 return rc;
226147
@@ -226167,33 +226161,35 @@
226161 int i;
226162 for(i=0; i<db->nDb; i++){
226163 Btree *pBt = db->aDb[i].pBt;
226164 if( pBt ) (void)sqlite3BtreeBeginTrans(pBt, 1, 0);
226165 }
226166 pTab->pgnoTrunc = 0;
 
 
226167 return SQLITE_OK;
226168 }
226169
226170 /* Invoke sqlite3PagerTruncate() as necessary, just prior to COMMIT
226171 */
226172 static int dbpageSync(sqlite3_vtab *pVtab){
226173 DbpageTable *pTab = (DbpageTable *)pVtab;
226174 if( pTab->pgnoTrunc>0 ){
226175 Btree *pBt = pTab->db->aDb[pTab->iDbTrunc].pBt;
226176 Pager *pPager = sqlite3BtreePager(pBt);
226177 sqlite3PagerTruncateImage(pPager, pTab->pgnoTrunc);
226178 }
226179 pTab->pgnoTrunc = 0;
226180 return SQLITE_OK;
226181 }
226182
226183 /* Cancel any pending truncate.
226184 */
226185 static int dbpageRollbackTo(sqlite3_vtab *pVtab, int notUsed1){
226186 DbpageTable *pTab = (DbpageTable *)pVtab;
226187 pTab->pgnoTrunc = 0;
226188 (void)notUsed1;
 
 
 
 
 
 
 
226189 return SQLITE_OK;
226190 }
 
226191
226192 /*
226193 ** Invoke this routine to register the "dbpage" virtual table module
226194 */
226195 SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){
@@ -226218,11 +226214,11 @@
226214 0, /* xRollback */
226215 0, /* xFindMethod */
226216 0, /* xRename */
226217 0, /* xSavepoint */
226218 0, /* xRelease */
226219 dbpageRollbackTo, /* xRollbackTo */
226220 0, /* xShadowName */
226221 0 /* xIntegrity */
226222 };
226223 return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0);
226224 }
@@ -233747,10 +233743,11 @@
233743 u8 *abUnindexed; /* True for unindexed columns */
233744 int nPrefix; /* Number of prefix indexes */
233745 int *aPrefix; /* Sizes in bytes of nPrefix prefix indexes */
233746 int eContent; /* An FTS5_CONTENT value */
233747 int bContentlessDelete; /* "contentless_delete=" option (dflt==0) */
233748 int bContentlessUnindexed; /* "contentless_unindexed=" option (dflt=0) */
233749 char *zContent; /* content table */
233750 char *zContentRowid; /* "content_rowid=" option value */
233751 int bColumnsize; /* "columnsize=" option value (dflt==1) */
233752 int bTokendata; /* "tokendata=" option value (dflt==0) */
233753 int bLocale; /* "locale=" option value (dflt==0) */
@@ -233785,13 +233782,14 @@
233782 ** the expected version if the 'secure-delete' option has ever been
233783 ** set on the table. */
233784 #define FTS5_CURRENT_VERSION 4
233785 #define FTS5_CURRENT_VERSION_SECUREDELETE 5
233786
233787 #define FTS5_CONTENT_NORMAL 0
233788 #define FTS5_CONTENT_NONE 1
233789 #define FTS5_CONTENT_EXTERNAL 2
233790 #define FTS5_CONTENT_UNINDEXED 3
233791
233792 #define FTS5_DETAIL_FULL 0
233793 #define FTS5_DETAIL_NONE 1
233794 #define FTS5_DETAIL_COLUMNS 2
233795
@@ -234247,11 +234245,11 @@
234245
234246 static int sqlite3Fts5DropAll(Fts5Config*);
234247 static int sqlite3Fts5CreateTable(Fts5Config*, const char*, const char*, int, char **);
234248
234249 static int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**, int);
234250 static int sqlite3Fts5StorageContentInsert(Fts5Storage *p, int, sqlite3_value**, i64*);
234251 static int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64);
234252
234253 static int sqlite3Fts5StorageIntegrity(Fts5Storage *p, int iArg);
234254
234255 static int sqlite3Fts5StorageStmt(Fts5Storage *p, int eStmt, sqlite3_stmt**, char**);
@@ -237454,10 +237452,11 @@
237452 const char *zArg, /* Argument to parse */
237453 char **pzErr /* OUT: Error message */
237454 ){
237455 int rc = SQLITE_OK;
237456 int nCmd = (int)strlen(zCmd);
237457
237458 if( sqlite3_strnicmp("prefix", zCmd, nCmd)==0 ){
237459 const int nByte = sizeof(int) * FTS5_MAX_PREFIX_INDEXES;
237460 const char *p;
237461 int bFirst = 1;
237462 if( pConfig->aPrefix==0 ){
@@ -237572,10 +237571,20 @@
237571 }else{
237572 pConfig->bContentlessDelete = (zArg[0]=='1');
237573 }
237574 return rc;
237575 }
237576
237577 if( sqlite3_strnicmp("contentless_unindexed", zCmd, nCmd)==0 ){
237578 if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1]!='\0' ){
237579 *pzErr = sqlite3_mprintf("malformed contentless_delete=... directive");
237580 rc = SQLITE_ERROR;
237581 }else{
237582 pConfig->bContentlessUnindexed = (zArg[0]=='1');
237583 }
237584 return rc;
237585 }
237586
237587 if( sqlite3_strnicmp("content_rowid", zCmd, nCmd)==0 ){
237588 if( pConfig->zContentRowid ){
237589 *pzErr = sqlite3_mprintf("multiple content_rowid=... directives");
237590 rc = SQLITE_ERROR;
@@ -237690,11 +237699,12 @@
237699
237700 static int fts5ConfigParseColumn(
237701 Fts5Config *p,
237702 char *zCol,
237703 char *zArg,
237704 char **pzErr,
237705 int *pbUnindexed
237706 ){
237707 int rc = SQLITE_OK;
237708 if( 0==sqlite3_stricmp(zCol, FTS5_RANK_NAME)
237709 || 0==sqlite3_stricmp(zCol, FTS5_ROWID_NAME)
237710 ){
@@ -237701,10 +237711,11 @@
237711 *pzErr = sqlite3_mprintf("reserved fts5 column name: %s", zCol);
237712 rc = SQLITE_ERROR;
237713 }else if( zArg ){
237714 if( 0==sqlite3_stricmp(zArg, "unindexed") ){
237715 p->abUnindexed[p->nCol] = 1;
237716 *pbUnindexed = 1;
237717 }else{
237718 *pzErr = sqlite3_mprintf("unrecognized column option: %s", zArg);
237719 rc = SQLITE_ERROR;
237720 }
237721 }
@@ -237721,15 +237732,21 @@
237732 int rc = SQLITE_OK;
237733 Fts5Buffer buf = {0, 0, 0};
237734
237735 sqlite3Fts5BufferAppendPrintf(&rc, &buf, "T.%Q", p->zContentRowid);
237736 if( p->eContent!=FTS5_CONTENT_NONE ){
237737 assert( p->eContent==FTS5_CONTENT_EXTERNAL
237738 || p->eContent==FTS5_CONTENT_NORMAL
237739 || p->eContent==FTS5_CONTENT_UNINDEXED
237740 );
237741 for(i=0; i<p->nCol; i++){
237742 if( p->eContent==FTS5_CONTENT_EXTERNAL ){
237743 sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", T.%Q", p->azCol[i]);
237744 }else if( p->eContent==FTS5_CONTENT_NORMAL || p->abUnindexed[i] ){
237745 sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", T.c%d", i);
237746 }else{
237747 sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", NULL");
237748 }
237749 }
237750 }
237751 if( p->eContent==FTS5_CONTENT_NORMAL && p->bLocale ){
237752 for(i=0; i<p->nCol; i++){
@@ -237768,10 +237785,11 @@
237785 ){
237786 int rc = SQLITE_OK; /* Return code */
237787 Fts5Config *pRet; /* New object to return */
237788 int i;
237789 sqlite3_int64 nByte;
237790 int bUnindexed = 0; /* True if there are one or more UNINDEXED */
237791
237792 *ppOut = pRet = (Fts5Config*)sqlite3_malloc(sizeof(Fts5Config));
237793 if( pRet==0 ) return SQLITE_NOMEM;
237794 memset(pRet, 0, sizeof(Fts5Config));
237795 pRet->pGlobal = pGlobal;
@@ -237827,11 +237845,11 @@
237845 ALWAYS(zOne)?zOne:"",
237846 zTwo?zTwo:"",
237847 pzErr
237848 );
237849 }else{
237850 rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr, &bUnindexed);
237851 zOne = 0;
237852 }
237853 }
237854 }
237855
@@ -237858,18 +237876,34 @@
237876 *pzErr = sqlite3_mprintf(
237877 "contentless_delete=1 is incompatible with columnsize=0"
237878 );
237879 rc = SQLITE_ERROR;
237880 }
237881
237882 /* We only allow contentless_unindexed=1 if the table is actually a
237883 ** contentless one.
237884 */
237885 if( rc==SQLITE_OK
237886 && pRet->bContentlessUnindexed
237887 && pRet->eContent!=FTS5_CONTENT_NONE
237888 ){
237889 *pzErr = sqlite3_mprintf(
237890 "contentless_unindexed=1 requires a contentless table"
237891 );
237892 rc = SQLITE_ERROR;
237893 }
237894
237895 /* If no zContent option was specified, fill in the default values. */
237896 if( rc==SQLITE_OK && pRet->zContent==0 ){
237897 const char *zTail = 0;
237898 assert( pRet->eContent==FTS5_CONTENT_NORMAL
237899 || pRet->eContent==FTS5_CONTENT_NONE
237900 );
237901 if( pRet->eContent==FTS5_CONTENT_NORMAL ){
237902 zTail = "content";
237903 }else if( bUnindexed && pRet->bContentlessUnindexed ){
237904 pRet->eContent = FTS5_CONTENT_UNINDEXED;
237905 zTail = "content";
237906 }else if( pRet->bColumnsize ){
237907 zTail = "docsize";
237908 }
237909
@@ -247040,10 +247074,15 @@
247074 if( nPercent>=pConfig->nDeleteMerge && nPercent>nBest ){
247075 iRet = ii;
247076 nBest = nPercent;
247077 }
247078 }
247079
247080 /* If pLvl is already the input level to an ongoing merge, look no
247081 ** further for a merge candidate. The caller should be allowed to
247082 ** continue merging from pLvl first. */
247083 if( pLvl->nMerge ) break;
247084 }
247085 }
247086 return iRet;
247087 }
247088
@@ -250964,11 +251003,11 @@
251003 return rc;
251004 }
251005
251006 /*
251007 ** We must have a single struct=? constraint that will be passed through
251008 ** into the xFilter method. If there is no valid struct=? constraint,
251009 ** then return an SQLITE_CONSTRAINT error.
251010 */
251011 static int fts5structBestIndexMethod(
251012 sqlite3_vtab *tab,
251013 sqlite3_index_info *pIdxInfo
@@ -251555,14 +251594,20 @@
251594 #else
251595 # define fts5CheckTransactionState(x,y,z)
251596 #endif
251597
251598 /*
251599 ** Return true if pTab is a contentless table. If parameter bIncludeUnindexed
251600 ** is true, this includes contentless tables that store UNINDEXED columns
251601 ** only.
251602 */
251603 static int fts5IsContentless(Fts5FullTable *pTab, int bIncludeUnindexed){
251604 int eContent = pTab->p.pConfig->eContent;
251605 return (
251606 eContent==FTS5_CONTENT_NONE
251607 || (bIncludeUnindexed && eContent==FTS5_CONTENT_UNINDEXED)
251608 );
251609 }
251610
251611 /*
251612 ** Delete a virtual table handle allocated by fts5InitVtab().
251613 */
@@ -252949,11 +252994,11 @@
252994 }else{
252995 rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage);
252996 }
252997 bLoadConfig = 1;
252998 }else if( 0==sqlite3_stricmp("rebuild", zCmd) ){
252999 if( fts5IsContentless(pTab, 1) ){
253000 fts5SetVtabError(pTab,
253001 "'rebuild' may not be used with a contentless fts5 table"
253002 );
253003 rc = SQLITE_ERROR;
253004 }else{
@@ -253018,17 +253063,78 @@
253063 sqlite3_value **apVal,
253064 i64 *piRowid
253065 ){
253066 int rc = *pRc;
253067 if( rc==SQLITE_OK ){
253068 rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, 0, apVal, piRowid);
253069 }
253070 if( rc==SQLITE_OK ){
253071 rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *piRowid);
253072 }
253073 *pRc = rc;
253074 }
253075
253076 /*
253077 **
253078 ** This function is called when the user attempts an UPDATE on a contentless
253079 ** table. Parameter bRowidModified is true if the UPDATE statement modifies
253080 ** the rowid value. Parameter apVal[] contains the new values for each user
253081 ** defined column of the fts5 table. pConfig is the configuration object of the
253082 ** table being updated (guaranteed to be contentless). The contentless_delete=1
253083 ** and contentless_unindexed=1 options may or may not be set.
253084 **
253085 ** This function returns SQLITE_OK if the UPDATE can go ahead, or an SQLite
253086 ** error code if it cannot. In this case an error message is also loaded into
253087 ** pConfig. Output parameter (*pbContent) is set to true if the caller should
253088 ** update the %_content table only - not the FTS index or any other shadow
253089 ** table. This occurs when an UPDATE modifies only UNINDEXED columns of the
253090 ** table.
253091 **
253092 ** An UPDATE may proceed if:
253093 **
253094 ** * The only columns modified are UNINDEXED columns, or
253095 **
253096 ** * The contentless_delete=1 option was specified and all of the indexed
253097 ** columns (not a subset) have been modified.
253098 */
253099 static int fts5ContentlessUpdate(
253100 Fts5Config *pConfig,
253101 sqlite3_value **apVal,
253102 int bRowidModified,
253103 int *pbContent
253104 ){
253105 int ii;
253106 int bSeenIndex = 0; /* Have seen modified indexed column */
253107 int bSeenIndexNC = 0; /* Have seen unmodified indexed column */
253108 int rc = SQLITE_OK;
253109
253110 for(ii=0; ii<pConfig->nCol; ii++){
253111 if( pConfig->abUnindexed[ii]==0 ){
253112 if( sqlite3_value_nochange(apVal[ii]) ){
253113 bSeenIndexNC++;
253114 }else{
253115 bSeenIndex++;
253116 }
253117 }
253118 }
253119
253120 if( bSeenIndex==0 && bRowidModified==0 ){
253121 *pbContent = 1;
253122 }else{
253123 if( bSeenIndexNC || pConfig->bContentlessDelete==0 ){
253124 rc = SQLITE_ERROR;
253125 sqlite3Fts5ConfigErrmsg(pConfig,
253126 (pConfig->bContentlessDelete ?
253127 "%s a subset of columns on fts5 contentless-delete table: %s" :
253128 "%s contentless fts5 table: %s")
253129 , "cannot UPDATE", pConfig->zName
253130 );
253131 }
253132 }
253133
253134 return rc;
253135 }
253136
253137 /*
253138 ** This function is the implementation of the xUpdate callback used by
253139 ** FTS3 virtual tables. It is invoked by SQLite each time a row is to be
253140 ** inserted, updated or deleted.
@@ -253112,29 +253218,24 @@
253218 }
253219
253220 assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL );
253221 assert( nArg!=1 || eType0==SQLITE_INTEGER );
253222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253223 /* DELETE */
253224 if( nArg==1 ){
253225 /* It is only possible to DELETE from a contentless table if the
253226 ** contentless_delete=1 flag is set. */
253227 if( fts5IsContentless(pTab, 1) && pConfig->bContentlessDelete==0 ){
253228 fts5SetVtabError(pTab,
253229 "cannot DELETE from contentless fts5 table: %s", pConfig->zName
253230 );
253231 rc = SQLITE_ERROR;
253232 }else{
253233 i64 iDel = sqlite3_value_int64(apVal[0]); /* Rowid to delete */
253234 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0, 0);
253235 bUpdateOrDelete = 1;
253236 }
253237 }
253238
253239 /* INSERT or UPDATE */
253240 else{
253241 int eType1 = sqlite3_value_numeric_type(apVal[1]);
@@ -253164,39 +253265,59 @@
253265 fts5StorageInsert(&rc, pTab, apVal, pRowid);
253266 }
253267
253268 /* UPDATE */
253269 else{
253270 Fts5Storage *pStorage = pTab->pStorage;
253271 i64 iOld = sqlite3_value_int64(apVal[0]); /* Old rowid */
253272 i64 iNew = sqlite3_value_int64(apVal[1]); /* New rowid */
253273 int bContent = 0; /* Content only update */
253274
253275 /* If this is a contentless table (including contentless_unindexed=1
253276 ** tables), check if the UPDATE may proceed. */
253277 if( fts5IsContentless(pTab, 1) ){
253278 rc = fts5ContentlessUpdate(pConfig, &apVal[2], iOld!=iNew, &bContent);
253279 if( rc!=SQLITE_OK ) goto update_out;
253280 }
253281
253282 if( eType1!=SQLITE_INTEGER ){
253283 rc = SQLITE_MISMATCH;
253284 }else if( iOld!=iNew ){
253285 assert( bContent==0 );
253286 if( eConflict==SQLITE_REPLACE ){
253287 rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 1);
253288 if( rc==SQLITE_OK ){
253289 rc = sqlite3Fts5StorageDelete(pStorage, iNew, 0, 0);
253290 }
253291 fts5StorageInsert(&rc, pTab, apVal, pRowid);
253292 }else{
253293 rc = sqlite3Fts5StorageFindDeleteRow(pStorage, iOld);
253294 if( rc==SQLITE_OK ){
253295 rc = sqlite3Fts5StorageContentInsert(pStorage, 0, apVal, pRowid);
253296 }
253297 if( rc==SQLITE_OK ){
253298 rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 0);
253299 }
253300 if( rc==SQLITE_OK ){
253301 rc = sqlite3Fts5StorageIndexInsert(pStorage, apVal, *pRowid);
253302 }
253303 }
253304 }else if( bContent ){
253305 /* This occurs when an UPDATE on a contentless table affects *only*
253306 ** UNINDEXED columns. This is a no-op for contentless_unindexed=0
253307 ** tables, or a write to the %_content table only for =1 tables. */
253308 assert( fts5IsContentless(pTab, 1) );
253309 rc = sqlite3Fts5StorageFindDeleteRow(pStorage, iOld);
253310 if( rc==SQLITE_OK ){
253311 rc = sqlite3Fts5StorageContentInsert(pStorage, 1, apVal, pRowid);
253312 }
253313 }else{
253314 rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 1);
253315 fts5StorageInsert(&rc, pTab, apVal, pRowid);
253316 }
253317 bUpdateOrDelete = 1;
253318 sqlite3Fts5StorageReleaseDeleteRow(pStorage);
253319 }
253320
253321 }
253322 }
253323
@@ -253393,11 +253514,11 @@
253514 Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
253515
253516 assert( pCsr->ePlan!=FTS5_PLAN_SPECIAL );
253517 if( iCol<0 || iCol>=pTab->pConfig->nCol ){
253518 rc = SQLITE_RANGE;
253519 }else if( fts5IsContentless((Fts5FullTable*)(pCsr->base.pVtab), 0) ){
253520 *pz = 0;
253521 *pn = 0;
253522 }else{
253523 rc = fts5SeekCursor(pCsr, 0);
253524 if( rc==SQLITE_OK ){
@@ -253426,11 +253547,11 @@
253547 int bLive = (pCsr->pSorter==0);
253548
253549 if( iPhrase<0 || iPhrase>=sqlite3Fts5ExprPhraseCount(pCsr->pExpr) ){
253550 rc = SQLITE_RANGE;
253551 }else if( pConfig->eDetail!=FTS5_DETAIL_FULL
253552 && fts5IsContentless((Fts5FullTable*)pCsr->base.pVtab, 1)
253553 ){
253554 *pa = 0;
253555 *pn = 0;
253556 return SQLITE_OK;
253557 }else if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_POSLIST) ){
@@ -253622,11 +253743,11 @@
253743
253744 if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_DOCSIZE) ){
253745 if( pConfig->bColumnsize ){
253746 i64 iRowid = fts5CursorRowid(pCsr);
253747 rc = sqlite3Fts5StorageDocsize(pTab->pStorage, iRowid, pCsr->aColumnSize);
253748 }else if( !pConfig->zContent || pConfig->eContent==FTS5_CONTENT_UNINDEXED ){
253749 int i;
253750 for(i=0; i<pConfig->nCol; i++){
253751 if( pConfig->abUnindexed[i]==0 ){
253752 pCsr->aColumnSize[i] = -1;
253753 }
@@ -253910,11 +254031,11 @@
254031 assert( pCsr->ePlan!=FTS5_PLAN_SPECIAL );
254032 if( iCol<0 || iCol>=pConfig->nCol ){
254033 rc = SQLITE_RANGE;
254034 }else if(
254035 pConfig->abUnindexed[iCol]==0
254036 && 0==fts5IsContentless((Fts5FullTable*)pCsr->base.pVtab, 1)
254037 && pConfig->bLocale
254038 ){
254039 rc = fts5SeekCursor(pCsr, 0);
254040 if( rc==SQLITE_OK ){
254041 const char *zDummy = 0;
@@ -254185,20 +254306,11 @@
254306 if( pCsr->pRank || SQLITE_OK==(rc = fts5FindRankFunction(pCsr)) ){
254307 fts5ApiInvoke(pCsr->pRank, pCsr, pCtx, pCsr->nRankArg, pCsr->apRankArg);
254308 }
254309 }
254310 }else{
254311 if( !sqlite3_vtab_nochange(pCtx) && pConfig->eContent!=FTS5_CONTENT_NONE ){
 
 
 
 
 
 
 
 
 
254312 pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
254313 rc = fts5SeekCursor(pCsr, 1);
254314 if( rc==SQLITE_OK ){
254315 sqlite3_value *pVal = sqlite3_column_value(pCsr->pStmt, iCol+1);
254316 if( pConfig->bLocale
@@ -254737,11 +254849,11 @@
254849 int nArg, /* Number of args */
254850 sqlite3_value **apUnused /* Function arguments */
254851 ){
254852 assert( nArg==0 );
254853 UNUSED_PARAM2(nArg, apUnused);
254854 sqlite3_result_text(pCtx, "fts5: 2024-10-07 12:48:21 011fab70cb3d194b27742ebb236b05be582230567cf78e3e6cac6911de86922f", -1, SQLITE_TRANSIENT);
254855 }
254856
254857 /*
254858 ** Implementation of fts5_locale(LOCALE, TEXT) function.
254859 **
@@ -255065,34 +255177,10 @@
255177 #define FTS5_STMT_DELETE_DOCSIZE 8
255178 #define FTS5_STMT_LOOKUP_DOCSIZE 9
255179 #define FTS5_STMT_REPLACE_CONFIG 10
255180 #define FTS5_STMT_SCAN 11
255181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255182 /*
255183 ** Prepare the two insert statements - Fts5Storage.pInsertContent and
255184 ** Fts5Storage.pInsertDocsize - if they have not already been prepared.
255185 ** Return SQLITE_OK if successful, or an SQLite error code if an error
255186 ** occurs.
@@ -255157,27 +255245,41 @@
255245 zSql = sqlite3_mprintf(azStmt[eStmt],
255246 pC->zContentExprlist, pC->zContent, pC->zContentRowid
255247 );
255248 break;
255249
255250 case FTS5_STMT_INSERT_CONTENT:
255251 case FTS5_STMT_REPLACE_CONTENT: {
255252 char *zBind = 0;
255253 int i;
255254
255255 assert( pC->eContent==FTS5_CONTENT_NORMAL
255256 || pC->eContent==FTS5_CONTENT_UNINDEXED
255257 );
255258
255259 /* Add bindings for the "c*" columns - those that store the actual
255260 ** table content. If eContent==NORMAL, then there is one binding
255261 ** for each column. Or, if eContent==UNINDEXED, then there are only
255262 ** bindings for the UNINDEXED columns. */
255263 for(i=0; rc==SQLITE_OK && i<(pC->nCol+1); i++){
255264 if( !i || pC->eContent==FTS5_CONTENT_NORMAL || pC->abUnindexed[i-1] ){
255265 zBind = sqlite3Fts5Mprintf(&rc, "%z%s?%d", zBind, zBind?",":"",i+1);
255266 }
255267 }
255268
255269 /* Add bindings for any "l*" columns. Only non-UNINDEXED columns
255270 ** require these. */
255271 if( pC->bLocale && pC->eContent==FTS5_CONTENT_NORMAL ){
255272 for(i=0; rc==SQLITE_OK && i<pC->nCol; i++){
255273 if( pC->abUnindexed[i]==0 ){
255274 zBind = sqlite3Fts5Mprintf(&rc, "%z,?%d", zBind, pC->nCol+i+2);
255275 }
255276 }
255277 }
255278
255279 zSql = sqlite3Fts5Mprintf(&rc, azStmt[eStmt], pC->zDb, pC->zName,zBind);
255280 sqlite3_free(zBind);
 
 
 
255281 break;
255282 }
255283
255284 case FTS5_STMT_REPLACE_DOCSIZE:
255285 zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName,
@@ -255359,11 +255461,13 @@
255461 p->aTotalSize = (i64*)&p[1];
255462 p->pConfig = pConfig;
255463 p->pIndex = pIndex;
255464
255465 if( bCreate ){
255466 if( pConfig->eContent==FTS5_CONTENT_NORMAL
255467 || pConfig->eContent==FTS5_CONTENT_UNINDEXED
255468 ){
255469 int nDefn = 32 + pConfig->nCol*10;
255470 char *zDefn = sqlite3_malloc64(32 + (sqlite3_int64)pConfig->nCol * 20);
255471 if( zDefn==0 ){
255472 rc = SQLITE_NOMEM;
255473 }else{
@@ -255370,12 +255474,16 @@
255474 int i;
255475 int iOff;
255476 sqlite3_snprintf(nDefn, zDefn, "id INTEGER PRIMARY KEY");
255477 iOff = (int)strlen(zDefn);
255478 for(i=0; i<pConfig->nCol; i++){
255479 if( pConfig->eContent==FTS5_CONTENT_NORMAL
255480 || pConfig->abUnindexed[i]
255481 ){
255482 sqlite3_snprintf(nDefn-iOff, &zDefn[iOff], ", c%d", i);
255483 iOff += (int)strlen(&zDefn[iOff]);
255484 }
255485 }
255486 if( pConfig->bLocale ){
255487 for(i=0; i<pConfig->nCol; i++){
255488 if( pConfig->abUnindexed[i]==0 ){
255489 sqlite3_snprintf(nDefn-iOff, &zDefn[iOff], ", l%d", i);
@@ -255609,11 +255717,13 @@
255717 i64 iOrigin = 0;
255718 sqlite3_stmt *pLookup = 0;
255719 int rc = SQLITE_OK;
255720
255721 assert( p->pConfig->bContentlessDelete );
255722 assert( p->pConfig->eContent==FTS5_CONTENT_NONE
255723 || p->pConfig->eContent==FTS5_CONTENT_UNINDEXED
255724 );
255725
255726 /* Look up the origin of the document in the %_docsize table. Store
255727 ** this in stack variable iOrigin. */
255728 rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP_DOCSIZE, &pLookup, 0);
255729 if( rc==SQLITE_OK ){
@@ -255733,10 +255843,16 @@
255843 }
255844
255845 if( rc==SQLITE_OK ){
255846 if( p->pConfig->bContentlessDelete ){
255847 rc = fts5StorageContentlessDelete(p, iDel);
255848 if( rc==SQLITE_OK
255849 && bSaveRow
255850 && p->pConfig->eContent==FTS5_CONTENT_UNINDEXED
255851 ){
255852 rc = sqlite3Fts5StorageFindDeleteRow(p, iDel);
255853 }
255854 }else{
255855 rc = fts5StorageDeleteFromIndex(p, iDel, apVal, bSaveRow);
255856 }
255857 }
255858
@@ -255749,11 +255865,13 @@
255865 rc = sqlite3_reset(pDel);
255866 }
255867 }
255868
255869 /* Delete the %_content record */
255870 if( pConfig->eContent==FTS5_CONTENT_NORMAL
255871 || pConfig->eContent==FTS5_CONTENT_UNINDEXED
255872 ){
255873 if( rc==SQLITE_OK ){
255874 rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_CONTENT, &pDel, 0);
255875 }
255876 if( rc==SQLITE_OK ){
255877 sqlite3_bind_int64(pDel, 1, iDel);
@@ -255781,12 +255899,17 @@
255899 pConfig->zDb, pConfig->zName,
255900 pConfig->zDb, pConfig->zName
255901 );
255902 if( rc==SQLITE_OK && pConfig->bColumnsize ){
255903 rc = fts5ExecPrintf(pConfig->db, 0,
255904 "DELETE FROM %Q.'%q_docsize';", pConfig->zDb, pConfig->zName
255905 );
255906 }
255907
255908 if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_UNINDEXED ){
255909 rc = fts5ExecPrintf(pConfig->db, 0,
255910 "DELETE FROM %Q.'%q_content';", pConfig->zDb, pConfig->zName
255911 );
255912 }
255913
255914 /* Reinitialize the %_data table. This call creates the initial structure
255915 ** and averages records. */
@@ -255918,69 +256041,75 @@
256041 /*
256042 ** Insert a new row into the FTS content table.
256043 */
256044 static int sqlite3Fts5StorageContentInsert(
256045 Fts5Storage *p,
256046 int bReplace, /* True to use REPLACE instead of INSERT */
256047 sqlite3_value **apVal,
256048 i64 *piRowid
256049 ){
256050 Fts5Config *pConfig = p->pConfig;
256051 int rc = SQLITE_OK;
256052
256053 /* Insert the new row into the %_content table. */
256054 if( pConfig->eContent!=FTS5_CONTENT_NORMAL
256055 && pConfig->eContent!=FTS5_CONTENT_UNINDEXED
256056 ){
256057 if( sqlite3_value_type(apVal[1])==SQLITE_INTEGER ){
256058 *piRowid = sqlite3_value_int64(apVal[1]);
256059 }else{
256060 rc = fts5StorageNewRowid(p, piRowid);
256061 }
256062 }else{
256063 sqlite3_stmt *pInsert = 0; /* Statement to write %_content table */
256064 int i; /* Counter variable */
256065
256066 assert( FTS5_STMT_INSERT_CONTENT+1==FTS5_STMT_REPLACE_CONTENT );
256067 assert( bReplace==0 || bReplace==1 );
256068 rc = fts5StorageGetStmt(p, FTS5_STMT_INSERT_CONTENT+bReplace, &pInsert, 0);
256069 if( pInsert ) sqlite3_clear_bindings(pInsert);
256070
256071 /* Bind the rowid value */
256072 sqlite3_bind_value(pInsert, 1, apVal[1]);
256073
256074 /* Loop through values for user-defined columns. i=2 is the leftmost
256075 ** user-defined column. As is column 1 of pSavedRow. */
256076 for(i=2; rc==SQLITE_OK && i<=pConfig->nCol+1; i++){
256077 int bUnindexed = pConfig->abUnindexed[i-2];
256078 if( pConfig->eContent==FTS5_CONTENT_NORMAL || bUnindexed ){
256079 sqlite3_value *pVal = apVal[i];
256080
256081 if( sqlite3_value_nochange(pVal) && p->pSavedRow ){
256082 /* This is an UPDATE statement, and user-defined column (i-2) was not
256083 ** modified. Retrieve the value from Fts5Storage.pSavedRow. */
256084 pVal = sqlite3_column_value(p->pSavedRow, i-1);
256085 if( pConfig->bLocale && bUnindexed==0 ){
256086 sqlite3_bind_value(pInsert, pConfig->nCol + i,
256087 sqlite3_column_value(p->pSavedRow, pConfig->nCol + i - 1)
256088 );
256089 }
256090 }else if( sqlite3Fts5IsLocaleValue(pConfig, pVal) ){
256091 const char *pText = 0;
256092 const char *pLoc = 0;
256093 int nText = 0;
256094 int nLoc = 0;
256095 assert( pConfig->bLocale );
256096
256097 rc = sqlite3Fts5DecodeLocaleValue(pVal, &pText, &nText, &pLoc, &nLoc);
256098 if( rc==SQLITE_OK ){
256099 sqlite3_bind_text(pInsert, i, pText, nText, SQLITE_TRANSIENT);
256100 if( bUnindexed==0 ){
256101 int iLoc = pConfig->nCol + i;
256102 sqlite3_bind_text(pInsert, iLoc, pLoc, nLoc, SQLITE_TRANSIENT);
256103 }
256104 }
256105
256106 continue;
256107 }
256108
256109 rc = sqlite3_bind_value(pInsert, i, pVal);
256110 }
256111 }
256112 if( rc==SQLITE_OK ){
256113 sqlite3_step(pInsert);
256114 rc = sqlite3_reset(pInsert);
256115 }
256116
+11 -3
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.47.0"
150150
#define SQLITE_VERSION_NUMBER 3047000
151
-#define SQLITE_SOURCE_ID "2024-09-26 19:38:34 f97f9944b829a49da12786f934da0a5ad51591afd6d8a19a4a0835f51bbdbff2"
151
+#define SQLITE_SOURCE_ID "2024-10-07 12:48:21 011fab70cb3d194b27742ebb236b05be582230567cf78e3e6cac6911de86922f"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -5601,11 +5601,11 @@
56015601
** The SQLITE_SUBTYPE flag indicates to SQLite that a function might call
56025602
** [sqlite3_value_subtype()] to inspect the sub-types of its arguments.
56035603
** This flag instructs SQLite to omit some corner-case optimizations that
56045604
** might disrupt the operation of the [sqlite3_value_subtype()] function,
56055605
** causing it to return zero rather than the correct subtype().
5606
-** SQL functions that invokes [sqlite3_value_subtype()] should have this
5606
+** All SQL functions that invoke [sqlite3_value_subtype()] should have this
56075607
** property. If the SQLITE_SUBTYPE property is omitted, then the return
56085608
** value from [sqlite3_value_subtype()] might sometimes be zero even though
56095609
** a non-zero subtype was specified by the function argument expression.
56105610
**
56115611
** [[SQLITE_RESULT_SUBTYPE]] <dt>SQLITE_RESULT_SUBTYPE</dt><dd>
@@ -8366,11 +8366,11 @@
83668366
#define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
83678367
#define SQLITE_TESTCTRL_SEEK_COUNT 30
83688368
#define SQLITE_TESTCTRL_TRACEFLAGS 31
83698369
#define SQLITE_TESTCTRL_TUNE 32
83708370
#define SQLITE_TESTCTRL_LOGEST 33
8371
-#define SQLITE_TESTCTRL_USELONGDOUBLE 34
8371
+#define SQLITE_TESTCTRL_USELONGDOUBLE 34 /* NOT USED */
83728372
#define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
83738373
83748374
/*
83758375
** CAPI3REF: SQL Keyword Checking
83768376
**
@@ -10540,10 +10540,18 @@
1054010540
** schema S in database connection D. ^On success, the
1054110541
** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
1054210542
** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
1054310543
** If there is not already a read-transaction open on schema S when
1054410544
** this function is called, one is opened automatically.
10545
+**
10546
+** If a read-transaction is opened by this function, then it is guaranteed
10547
+** that the returned snapshot object may not be invalidated by a database
10548
+** writer or checkpointer until after the read-transaction is closed. This
10549
+** is not guaranteed if a read-transaction is already open when this
10550
+** function is called. In that case, any subsequent write or checkpoint
10551
+** operation on the database may invalidate the returned snapshot handle,
10552
+** even while the read-transaction remains open.
1054510553
**
1054610554
** The following must be true for this function to succeed. If any of
1054710555
** the following statements are false when sqlite3_snapshot_get() is
1054810556
** called, SQLITE_ERROR is returned. The final value of *P is undefined
1054910557
** in this case.
1055010558
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.47.0"
150 #define SQLITE_VERSION_NUMBER 3047000
151 #define SQLITE_SOURCE_ID "2024-09-26 19:38:34 f97f9944b829a49da12786f934da0a5ad51591afd6d8a19a4a0835f51bbdbff2"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -5601,11 +5601,11 @@
5601 ** The SQLITE_SUBTYPE flag indicates to SQLite that a function might call
5602 ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments.
5603 ** This flag instructs SQLite to omit some corner-case optimizations that
5604 ** might disrupt the operation of the [sqlite3_value_subtype()] function,
5605 ** causing it to return zero rather than the correct subtype().
5606 ** SQL functions that invokes [sqlite3_value_subtype()] should have this
5607 ** property. If the SQLITE_SUBTYPE property is omitted, then the return
5608 ** value from [sqlite3_value_subtype()] might sometimes be zero even though
5609 ** a non-zero subtype was specified by the function argument expression.
5610 **
5611 ** [[SQLITE_RESULT_SUBTYPE]] <dt>SQLITE_RESULT_SUBTYPE</dt><dd>
@@ -8366,11 +8366,11 @@
8366 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
8367 #define SQLITE_TESTCTRL_SEEK_COUNT 30
8368 #define SQLITE_TESTCTRL_TRACEFLAGS 31
8369 #define SQLITE_TESTCTRL_TUNE 32
8370 #define SQLITE_TESTCTRL_LOGEST 33
8371 #define SQLITE_TESTCTRL_USELONGDOUBLE 34
8372 #define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
8373
8374 /*
8375 ** CAPI3REF: SQL Keyword Checking
8376 **
@@ -10540,10 +10540,18 @@
10540 ** schema S in database connection D. ^On success, the
10541 ** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
10542 ** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
10543 ** If there is not already a read-transaction open on schema S when
10544 ** this function is called, one is opened automatically.
 
 
 
 
 
 
 
 
10545 **
10546 ** The following must be true for this function to succeed. If any of
10547 ** the following statements are false when sqlite3_snapshot_get() is
10548 ** called, SQLITE_ERROR is returned. The final value of *P is undefined
10549 ** in this case.
10550
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.47.0"
150 #define SQLITE_VERSION_NUMBER 3047000
151 #define SQLITE_SOURCE_ID "2024-10-07 12:48:21 011fab70cb3d194b27742ebb236b05be582230567cf78e3e6cac6911de86922f"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -5601,11 +5601,11 @@
5601 ** The SQLITE_SUBTYPE flag indicates to SQLite that a function might call
5602 ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments.
5603 ** This flag instructs SQLite to omit some corner-case optimizations that
5604 ** might disrupt the operation of the [sqlite3_value_subtype()] function,
5605 ** causing it to return zero rather than the correct subtype().
5606 ** All SQL functions that invoke [sqlite3_value_subtype()] should have this
5607 ** property. If the SQLITE_SUBTYPE property is omitted, then the return
5608 ** value from [sqlite3_value_subtype()] might sometimes be zero even though
5609 ** a non-zero subtype was specified by the function argument expression.
5610 **
5611 ** [[SQLITE_RESULT_SUBTYPE]] <dt>SQLITE_RESULT_SUBTYPE</dt><dd>
@@ -8366,11 +8366,11 @@
8366 #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
8367 #define SQLITE_TESTCTRL_SEEK_COUNT 30
8368 #define SQLITE_TESTCTRL_TRACEFLAGS 31
8369 #define SQLITE_TESTCTRL_TUNE 32
8370 #define SQLITE_TESTCTRL_LOGEST 33
8371 #define SQLITE_TESTCTRL_USELONGDOUBLE 34 /* NOT USED */
8372 #define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
8373
8374 /*
8375 ** CAPI3REF: SQL Keyword Checking
8376 **
@@ -10540,10 +10540,18 @@
10540 ** schema S in database connection D. ^On success, the
10541 ** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
10542 ** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
10543 ** If there is not already a read-transaction open on schema S when
10544 ** this function is called, one is opened automatically.
10545 **
10546 ** If a read-transaction is opened by this function, then it is guaranteed
10547 ** that the returned snapshot object may not be invalidated by a database
10548 ** writer or checkpointer until after the read-transaction is closed. This
10549 ** is not guaranteed if a read-transaction is already open when this
10550 ** function is called. In that case, any subsequent write or checkpoint
10551 ** operation on the database may invalidate the returned snapshot handle,
10552 ** even while the read-transaction remains open.
10553 **
10554 ** The following must be true for this function to succeed. If any of
10555 ** the following statements are false when sqlite3_snapshot_get() is
10556 ** called, SQLITE_ERROR is returned. The final value of *P is undefined
10557 ** in this case.
10558

Keyboard Shortcuts

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