Fossil SCM

Update the built-in SQLite to use the latest 3.41.0 alpha version that includes new efforts to silence nuiscance compiler warnings.

drh 2023-02-08 14:54 trunk
Commit 05fa1c3c24de29a46264c4790048b8f100a0fa702ad0a53fee7722ea7ae3aaa1
+4 -4
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -127,11 +127,11 @@
127127
#include <ctype.h>
128128
#include <stdarg.h>
129129
130130
#if !defined(_WIN32) && !defined(WIN32)
131131
# include <signal.h>
132
-# if !defined(__RTP__) && !defined(_WRS_KERNEL)
132
+# if !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI)
133133
# include <pwd.h>
134134
# endif
135135
#endif
136136
#if (!defined(_WIN32) && !defined(WIN32)) || defined(__MINGW32__)
137137
# include <unistd.h>
@@ -184,11 +184,11 @@
184184
# define SHELL_USE_LOCAL_GETLINE 1
185185
#endif
186186
187187
#ifndef deliberate_fall_through
188188
/* Quiet some compilers about some of our intentional code. */
189
-# if GCC_VERSION>=7000000
189
+# if defined(GCC_VERSION) && GCC_VERSION>=7000000
190190
# define deliberate_fall_through __attribute__((fallthrough));
191191
# else
192192
# define deliberate_fall_through
193193
# endif
194194
#endif
@@ -216,11 +216,11 @@
216216
# endif
217217
#else
218218
/* Make sure isatty() has a prototype. */
219219
extern int isatty(int);
220220
221
-# if !defined(__RTP__) && !defined(_WRS_KERNEL)
221
+# if !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI)
222222
/* popen and pclose are not C89 functions and so are
223223
** sometimes omitted from the <stdio.h> header */
224224
extern FILE *popen(const char*,const char*);
225225
extern int pclose(FILE*);
226226
# else
@@ -26647,11 +26647,11 @@
2664726647
return 0;
2664826648
}
2664926649
if( home_dir ) return home_dir;
2665026650
2665126651
#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \
26652
- && !defined(__RTP__) && !defined(_WRS_KERNEL)
26652
+ && !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI)
2665326653
{
2665426654
struct passwd *pwent;
2665526655
uid_t uid = getuid();
2665626656
if( (pwent=getpwuid(uid)) != NULL) {
2665726657
home_dir = pwent->pw_dir;
2665826658
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -127,11 +127,11 @@
127 #include <ctype.h>
128 #include <stdarg.h>
129
130 #if !defined(_WIN32) && !defined(WIN32)
131 # include <signal.h>
132 # if !defined(__RTP__) && !defined(_WRS_KERNEL)
133 # include <pwd.h>
134 # endif
135 #endif
136 #if (!defined(_WIN32) && !defined(WIN32)) || defined(__MINGW32__)
137 # include <unistd.h>
@@ -184,11 +184,11 @@
184 # define SHELL_USE_LOCAL_GETLINE 1
185 #endif
186
187 #ifndef deliberate_fall_through
188 /* Quiet some compilers about some of our intentional code. */
189 # if GCC_VERSION>=7000000
190 # define deliberate_fall_through __attribute__((fallthrough));
191 # else
192 # define deliberate_fall_through
193 # endif
194 #endif
@@ -216,11 +216,11 @@
216 # endif
217 #else
218 /* Make sure isatty() has a prototype. */
219 extern int isatty(int);
220
221 # if !defined(__RTP__) && !defined(_WRS_KERNEL)
222 /* popen and pclose are not C89 functions and so are
223 ** sometimes omitted from the <stdio.h> header */
224 extern FILE *popen(const char*,const char*);
225 extern int pclose(FILE*);
226 # else
@@ -26647,11 +26647,11 @@
26647 return 0;
26648 }
26649 if( home_dir ) return home_dir;
26650
26651 #if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \
26652 && !defined(__RTP__) && !defined(_WRS_KERNEL)
26653 {
26654 struct passwd *pwent;
26655 uid_t uid = getuid();
26656 if( (pwent=getpwuid(uid)) != NULL) {
26657 home_dir = pwent->pw_dir;
26658
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -127,11 +127,11 @@
127 #include <ctype.h>
128 #include <stdarg.h>
129
130 #if !defined(_WIN32) && !defined(WIN32)
131 # include <signal.h>
132 # if !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI)
133 # include <pwd.h>
134 # endif
135 #endif
136 #if (!defined(_WIN32) && !defined(WIN32)) || defined(__MINGW32__)
137 # include <unistd.h>
@@ -184,11 +184,11 @@
184 # define SHELL_USE_LOCAL_GETLINE 1
185 #endif
186
187 #ifndef deliberate_fall_through
188 /* Quiet some compilers about some of our intentional code. */
189 # if defined(GCC_VERSION) && GCC_VERSION>=7000000
190 # define deliberate_fall_through __attribute__((fallthrough));
191 # else
192 # define deliberate_fall_through
193 # endif
194 #endif
@@ -216,11 +216,11 @@
216 # endif
217 #else
218 /* Make sure isatty() has a prototype. */
219 extern int isatty(int);
220
221 # if !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI)
222 /* popen and pclose are not C89 functions and so are
223 ** sometimes omitted from the <stdio.h> header */
224 extern FILE *popen(const char*,const char*);
225 extern int pclose(FILE*);
226 # else
@@ -26647,11 +26647,11 @@
26647 return 0;
26648 }
26649 if( home_dir ) return home_dir;
26650
26651 #if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \
26652 && !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI)
26653 {
26654 struct passwd *pwent;
26655 uid_t uid = getuid();
26656 if( (pwent=getpwuid(uid)) != NULL) {
26657 home_dir = pwent->pw_dir;
26658
+129 -48
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452452
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453453
** [sqlite_version()] and [sqlite_source_id()].
454454
*/
455455
#define SQLITE_VERSION "3.41.0"
456456
#define SQLITE_VERSION_NUMBER 3041000
457
-#define SQLITE_SOURCE_ID "2023-02-03 14:57:40 c045d76b908a8c90d22511df7884e78d452b250db9ba70d4cb0935048a3c3ac4"
457
+#define SQLITE_SOURCE_ID "2023-02-08 14:49:52 6b41ba2e996ab7b9c3943ab93a19748db5cf37792f5d59d20eec301085282355"
458458
459459
/*
460460
** CAPI3REF: Run-Time Library Version Numbers
461461
** KEYWORDS: sqlite3_version sqlite3_sourceid
462462
**
@@ -10123,11 +10123,11 @@
1012310123
** ^(Use these routines to access all values on the right-hand side
1012410124
** of the IN constraint using code like the following:
1012510125
**
1012610126
** <blockquote><pre>
1012710127
** &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal);
10128
-** &nbsp; rc==SQLITE_OK && pVal
10128
+** &nbsp; rc==SQLITE_OK && pVal;
1012910129
** &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal)
1013010130
** &nbsp; ){
1013110131
** &nbsp; // do something with pVal
1013210132
** &nbsp; }
1013310133
** &nbsp; if( rc!=SQLITE_OK ){
@@ -10835,10 +10835,23 @@
1083510835
** builds on processors without floating point support.
1083610836
*/
1083710837
#ifdef SQLITE_OMIT_FLOATING_POINT
1083810838
# undef double
1083910839
#endif
10840
+
10841
+#if defined(__wasi__)
10842
+# undef SQLITE_WASI
10843
+# define SQLITE_WASI 1
10844
+# undef SQLITE_OMIT_WAL
10845
+# define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */
10846
+# ifndef SQLITE_OMIT_LOAD_EXTENSION
10847
+# define SQLITE_OMIT_LOAD_EXTENSION
10848
+# endif
10849
+# ifndef SQLITE_THREADSAFE
10850
+# define SQLITE_THREADSAFE 0
10851
+# endif
10852
+#endif
1084010853
1084110854
#if 0
1084210855
} /* End of the 'extern "C"' block */
1084310856
#endif
1084410857
#endif /* SQLITE3_H */
@@ -17103,10 +17116,11 @@
1710317116
u8 mTrace; /* zero or more SQLITE_TRACE flags */
1710417117
u8 noSharedCache; /* True if no shared-cache backends */
1710517118
u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
1710617119
u8 eOpenState; /* Current condition of the connection */
1710717120
int nextPagesize; /* Pagesize after VACUUM if >0 */
17121
+ i64 txnTime; /* Timestamp for current transaction */
1710817122
i64 nChange; /* Value returned by sqlite3_changes() */
1710917123
i64 nTotalChange; /* Value returned by sqlite3_total_changes() */
1711017124
int aLimit[SQLITE_N_LIMIT]; /* Limits */
1711117125
int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */
1711217126
struct sqlite3InitInfo { /* Information used during initialization */
@@ -20822,11 +20836,11 @@
2082220836
SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
2082320837
#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
2082420838
&& !defined(SQLITE_OMIT_VIRTUALTABLE)
2082520839
SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(sqlite3_index_info*);
2082620840
#endif
20827
-SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
20841
+SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*, int);
2082820842
SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
2082920843
SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
2083020844
SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse*,sqlite3*);
2083120845
SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse*);
2083220846
SQLITE_PRIVATE void *sqlite3ParserAddCleanup(Parse*,void(*)(sqlite3*,void*),void*);
@@ -23810,16 +23824,20 @@
2381023824
}
2381123825
return 0;
2381223826
}
2381323827
2381423828
/*
23815
-** Set the time to the current time reported by the VFS.
23829
+** Set the time to the current time reported for the prepared statement
23830
+** that is currently executing. The same time is reported for all
23831
+** invocations of this routine from within the same call to sqlite3_step().
23832
+**
23833
+** Or if bTxn is true, use the transaction time.
2381623834
**
2381723835
** Return the number of errors.
2381823836
*/
23819
-static int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){
23820
- p->iJD = sqlite3StmtCurrentTime(context);
23837
+static int setCurrentStmtTime(sqlite3_context *context, DateTime *p, int bTxn){
23838
+ p->iJD = sqlite3StmtCurrentTime(context, bTxn);
2382123839
if( p->iJD>0 ){
2382223840
p->validJD = 1;
2382323841
return 0;
2382423842
}else{
2382523843
return 1;
@@ -23866,11 +23884,13 @@
2386623884
if( parseYyyyMmDd(zDate,p)==0 ){
2386723885
return 0;
2386823886
}else if( parseHhMmSs(zDate, p)==0 ){
2386923887
return 0;
2387023888
}else if( sqlite3StrICmp(zDate,"now")==0 && sqlite3NotPureFunc(context) ){
23871
- return setDateTimeToCurrent(context, p);
23889
+ return setCurrentStmtTime(context, p, 0);
23890
+ }else if( sqlite3StrICmp(zDate,"txn")==0 && sqlite3NotPureFunc(context) ){
23891
+ return setCurrentStmtTime(context, p, 1);
2387223892
}else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8)>0 ){
2387323893
setRawDateNumber(p, r);
2387423894
return 0;
2387523895
}
2387623896
return 1;
@@ -24410,12 +24430,15 @@
2441024430
** Process time function arguments. argv[0] is a date-time stamp.
2441124431
** argv[1] and following are modifiers. Parse them all and write
2441224432
** the resulting time into the DateTime structure p. Return 0
2441324433
** on success and 1 if there are any errors.
2441424434
**
24415
-** If there are zero parameters (if even argv[0] is undefined)
24416
-** then assume a default value of "now" for argv[0].
24435
+** If there are zero parameters (if argc<=0) then assume a default
24436
+** value of "now" for argv[0] if argc==0 and "txn" if argc<0. SQL
24437
+** functions will always have argc>=0, but the special implementations
24438
+** of CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP set argc to -1
24439
+** in order to force the use of 'txn' semantics.
2441724440
*/
2441824441
static int isDate(
2441924442
sqlite3_context *context,
2442024443
int argc,
2442124444
sqlite3_value **argv,
@@ -24423,13 +24446,13 @@
2442324446
){
2442424447
int i, n;
2442524448
const unsigned char *z;
2442624449
int eType;
2442724450
memset(p, 0, sizeof(*p));
24428
- if( argc==0 ){
24451
+ if( argc<=0 ){
2442924452
if( !sqlite3NotPureFunc(context) ) return 1;
24430
- return setDateTimeToCurrent(context, p);
24453
+ return setCurrentStmtTime(context, p, argc<0);
2443124454
}
2443224455
if( (eType = sqlite3_value_type(argv[0]))==SQLITE_FLOAT
2443324456
|| eType==SQLITE_INTEGER ){
2443424457
setRawDateNumber(p, sqlite3_value_double(argv[0]));
2443524458
}else{
@@ -24732,11 +24755,11 @@
2473224755
sqlite3_context *context,
2473324756
int NotUsed,
2473424757
sqlite3_value **NotUsed2
2473524758
){
2473624759
UNUSED_PARAMETER2(NotUsed, NotUsed2);
24737
- timeFunc(context, 0, 0);
24760
+ timeFunc(context, -1, 0);
2473824761
}
2473924762
2474024763
/*
2474124764
** current_date()
2474224765
**
@@ -24746,11 +24769,11 @@
2474624769
sqlite3_context *context,
2474724770
int NotUsed,
2474824771
sqlite3_value **NotUsed2
2474924772
){
2475024773
UNUSED_PARAMETER2(NotUsed, NotUsed2);
24751
- dateFunc(context, 0, 0);
24774
+ dateFunc(context, -1, 0);
2475224775
}
2475324776
2475424777
/*
2475524778
** current_timestamp()
2475624779
**
@@ -24760,11 +24783,11 @@
2476024783
sqlite3_context *context,
2476124784
int NotUsed,
2476224785
sqlite3_value **NotUsed2
2476324786
){
2476424787
UNUSED_PARAMETER2(NotUsed, NotUsed2);
24765
- datetimeFunc(context, 0, 0);
24788
+ datetimeFunc(context, -1, 0);
2476624789
}
2476724790
#endif /* !defined(SQLITE_OMIT_DATETIME_FUNCS) */
2476824791
2476924792
#ifdef SQLITE_OMIT_DATETIME_FUNCS
2477024793
/*
@@ -24791,11 +24814,11 @@
2479124814
char zBuf[20];
2479224815
2479324816
UNUSED_PARAMETER(argc);
2479424817
UNUSED_PARAMETER(argv);
2479524818
24796
- iT = sqlite3StmtCurrentTime(context);
24819
+ iT = sqlite3StmtCurrentTime(context, 1);
2479724820
if( iT<=0 ) return;
2479824821
t = iT/1000 - 10000*(sqlite3_int64)21086676;
2479924822
#if HAVE_GMTIME_R
2480024823
pTm = gmtime_r(&t, &sNow);
2480124824
#else
@@ -36999,11 +37022,12 @@
3699937022
#include <sys/ioctl.h>
3700037023
#include <unistd.h> /* amalgamator: keep */
3700137024
/* #include <time.h> */
3700237025
#include <sys/time.h> /* amalgamator: keep */
3700337026
#include <errno.h>
37004
-#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
37027
+#if (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) \
37028
+ && !defined(SQLITE_WASI)
3700537029
# include <sys/mman.h>
3700637030
#endif
3700737031
3700837032
#if SQLITE_ENABLE_LOCKING_STYLE
3700937033
/* # include <sys/ioctl.h> */
@@ -37087,13 +37111,50 @@
3708737111
/*
3708837112
** Maximum supported symbolic links
3708937113
*/
3709037114
#define SQLITE_MAX_SYMLINKS 100
3709137115
37116
+/*
37117
+** Remove and stub certain info for WASI (WebAssembly System
37118
+** Interface) builds.
37119
+*/
37120
+#ifdef SQLITE_WASI
37121
+# undef HAVE_FCHMOD
37122
+# undef HAVE_FCHOWN
37123
+# undef HAVE_MREMAP
37124
+# define HAVE_MREMAP 0
37125
+# ifndef SQLITE_DEFAULT_UNIX_VFS
37126
+# define SQLITE_DEFAULT_UNIX_VFS "unix-dotfile"
37127
+ /* ^^^ should SQLITE_DEFAULT_UNIX_VFS be "unix-none"? */
37128
+# endif
37129
+# ifndef F_RDLCK
37130
+# define F_RDLCK 0
37131
+# define F_WRLCK 1
37132
+# define F_UNLCK 2
37133
+# if __LONG_MAX == 0x7fffffffL
37134
+# define F_GETLK 12
37135
+# define F_SETLK 13
37136
+# define F_SETLKW 14
37137
+# else
37138
+# define F_GETLK 5
37139
+# define F_SETLK 6
37140
+# define F_SETLKW 7
37141
+# endif
37142
+# endif
37143
+#else /* !SQLITE_WASI */
37144
+# ifndef HAVE_FCHMOD
37145
+# define HAVE_FCHMOD
37146
+# endif
37147
+#endif /* SQLITE_WASI */
37148
+
37149
+#ifdef SQLITE_WASI
37150
+# define osGetpid(X) (pid_t)1
37151
+#else
3709237152
/* Always cast the getpid() return type for compatibility with
3709337153
** kernel modules in VxWorks. */
37094
-#define osGetpid(X) (pid_t)getpid()
37154
+# define osGetpid(X) (pid_t)getpid()
37155
+#endif
3709537156
3709637157
/*
3709737158
** Only set the lastErrno if the error code is a real error and not
3709837159
** a normal expected return code of SQLITE_BUSY or SQLITE_OK
3709937160
*/
@@ -37361,11 +37422,15 @@
3736137422
{ "pwrite64", (sqlite3_syscall_ptr)0, 0 },
3736237423
#endif
3736337424
#define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off64_t))\
3736437425
aSyscall[13].pCurrent)
3736537426
37427
+#if defined(HAVE_FCHMOD)
3736637428
{ "fchmod", (sqlite3_syscall_ptr)fchmod, 0 },
37429
+#else
37430
+ { "fchmod", (sqlite3_syscall_ptr)0, 0 },
37431
+#endif
3736737432
#define osFchmod ((int(*)(int,mode_t))aSyscall[14].pCurrent)
3736837433
3736937434
#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
3737037435
{ "fallocate", (sqlite3_syscall_ptr)posix_fallocate, 0 },
3737137436
#else
@@ -37397,18 +37462,20 @@
3739737462
#else
3739837463
{ "geteuid", (sqlite3_syscall_ptr)0, 0 },
3739937464
#endif
3740037465
#define osGeteuid ((uid_t(*)(void))aSyscall[21].pCurrent)
3740137466
37402
-#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
37467
+#if (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) \
37468
+ && !defined(SQLITE_WASI)
3740337469
{ "mmap", (sqlite3_syscall_ptr)mmap, 0 },
3740437470
#else
3740537471
{ "mmap", (sqlite3_syscall_ptr)0, 0 },
3740637472
#endif
3740737473
#define osMmap ((void*(*)(void*,size_t,int,int,int,off_t))aSyscall[22].pCurrent)
3740837474
37409
-#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
37475
+#if (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) \
37476
+ && !defined(SQLITE_WASI)
3741037477
{ "munmap", (sqlite3_syscall_ptr)munmap, 0 },
3741137478
#else
3741237479
{ "munmap", (sqlite3_syscall_ptr)0, 0 },
3741337480
#endif
3741437481
#define osMunmap ((int(*)(void*,size_t))aSyscall[23].pCurrent)
@@ -61699,11 +61766,11 @@
6169961766
UNUSED_PARAMETER(isDirectMode);
6170061767
#else
6170161768
# define DIRECT_MODE isDirectMode
6170261769
#endif
6170361770
61704
- if( !pPager->changeCountDone && ALWAYS(pPager->dbSize>0) ){
61771
+ if( !pPager->changeCountDone && pPager->dbSize>0 ){
6170561772
PgHdr *pPgHdr; /* Reference to page 1 */
6170661773
6170761774
assert( !pPager->tempFile && isOpen(pPager->fd) );
6170861775
6170961776
/* Open page 1 of the file for writing. */
@@ -81848,11 +81915,13 @@
8184881915
rc = ctx.isError;
8184981916
sqlite3ErrorMsg(pCtx->pParse, "%s", sqlite3_value_text(pVal));
8185081917
}else{
8185181918
sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8);
8185281919
assert( rc==SQLITE_OK );
81853
- assert( enc==pVal->enc || db->mallocFailed );
81920
+ assert( enc==pVal->enc
81921
+ || (pVal->flags & MEM_Str)==0
81922
+ || db->mallocFailed );
8185481923
#if 0 /* Not reachable except after a prior failure */
8185581924
rc = sqlite3VdbeChangeEncoding(pVal, enc);
8185681925
if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){
8185781926
rc = SQLITE_TOOBIG;
8185881927
pCtx->pParse->nErr++;
@@ -85716,10 +85785,11 @@
8571685785
** by connection db have now been released. Call sqlite3ConnectionUnlocked()
8571785786
** to invoke any required unlock-notify callbacks.
8571885787
*/
8571985788
if( db->autoCommit ){
8572085789
sqlite3ConnectionUnlocked(db);
85790
+ db->txnTime = 0;
8572185791
}
8572285792
8572385793
assert( db->nVdbeActive>0 || db->autoCommit==0 || db->nStatement==0 );
8572485794
return (p->rc==SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK);
8572585795
}
@@ -88674,22 +88744,31 @@
8867488744
** Return the current time for a statement. If the current time
8867588745
** is requested more than once within the same run of a single prepared
8867688746
** statement, the exact same time is returned for each invocation regardless
8867788747
** of the amount of time that elapses between invocations. In other words,
8867888748
** the time returned is always the time of the first call.
88749
+**
88750
+** Or, if bTxn, return the transaction time. The transaction time is the
88751
+** same for all calls within the same transaction.
88752
+**
88753
+** bTxn is 0 for SQL like datetime('now') and is 1 for datetime('txn').
8867988754
*/
88680
-SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){
88755
+SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p, int bTxn){
8868188756
int rc;
8868288757
#ifndef SQLITE_ENABLE_STAT4
88683
- sqlite3_int64 *piTime = &p->pVdbe->iCurrentTime;
88758
+ sqlite3_int64 *piTime;
88759
+ sqlite3 *db = p->pOut->db;
8868488760
assert( p->pVdbe!=0 );
88761
+ piTime = bTxn ? &db->txnTime : &p->pVdbe->iCurrentTime;
8868588762
#else
8868688763
sqlite3_int64 iTime = 0;
88687
- sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;
88764
+ sqlite3_int64 *piTime;
88765
+ sqlite3 *db = p->pOut->db;
88766
+ piTime = bTxn ? &db->txnTime : p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;
8868888767
#endif
8868988768
if( *piTime==0 ){
88690
- rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime);
88769
+ rc = sqlite3OsCurrentTimeInt64(db->pVfs, piTime);
8869188770
if( rc ) *piTime = 0;
8869288771
}
8869388772
return *piTime;
8869488773
}
8869588774
@@ -158421,16 +158500,16 @@
158421158500
** be greater than or equal to the (iCol) field prefix of sample i.
158422158501
** If (i>0), then pRec must also be greater than sample (i-1). */
158423158502
if( iCol>0 ){
158424158503
pRec->nField = iCol;
158425158504
assert( sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)<=0
158426
- || pParse->db->mallocFailed );
158505
+ || pParse->db->mallocFailed || CORRUPT_DB );
158427158506
}
158428158507
if( i>0 ){
158429158508
pRec->nField = nField;
158430158509
assert( sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0
158431
- || pParse->db->mallocFailed );
158510
+ || pParse->db->mallocFailed || CORRUPT_DB );
158432158511
}
158433158512
}
158434158513
}
158435158514
#endif /* ifdef SQLITE_DEBUG */
158436158515
@@ -162396,28 +162475,27 @@
162396162475
*/
162397162476
static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful(
162398162477
const WhereInfo *pWInfo
162399162478
){
162400162479
int i;
162401
- LogEst nSearch;
162480
+ LogEst nSearch = 0;
162402162481
162403162482
assert( pWInfo->nLevel>=2 );
162404162483
assert( OptimizationEnabled(pWInfo->pParse->db, SQLITE_BloomFilter) );
162405
- nSearch = pWInfo->a[0].pWLoop->nOut;
162406
- for(i=1; i<pWInfo->nLevel; i++){
162484
+ for(i=0; i<pWInfo->nLevel; i++){
162407162485
WhereLoop *pLoop = pWInfo->a[i].pWLoop;
162408162486
const unsigned int reqFlags = (WHERE_SELFCULL|WHERE_COLUMN_EQ);
162409
- if( (pLoop->wsFlags & reqFlags)==reqFlags
162487
+ SrcItem *pItem = &pWInfo->pTabList->a[pLoop->iTab];
162488
+ Table *pTab = pItem->pTab;
162489
+ if( (pTab->tabFlags & TF_HasStat1)==0 ) break;
162490
+ pTab->tabFlags |= TF_StatsUsed;
162491
+ if( i>=1
162492
+ && (pLoop->wsFlags & reqFlags)==reqFlags
162410162493
/* vvvvvv--- Always the case if WHERE_COLUMN_EQ is defined */
162411162494
&& ALWAYS((pLoop->wsFlags & (WHERE_IPK|WHERE_INDEXED))!=0)
162412162495
){
162413
- SrcItem *pItem = &pWInfo->pTabList->a[pLoop->iTab];
162414
- Table *pTab = pItem->pTab;
162415
- pTab->tabFlags |= TF_StatsUsed;
162416
- if( nSearch > pTab->nRowLogEst
162417
- && (pTab->tabFlags & TF_HasStat1)!=0
162418
- ){
162496
+ if( nSearch > pTab->nRowLogEst ){
162419162497
testcase( pItem->fg.jointype & JT_LEFT );
162420162498
pLoop->wsFlags |= WHERE_BLOOMFILTER;
162421162499
pLoop->wsFlags &= ~WHERE_IDX_ONLY;
162422162500
WHERETRACE(0xffffffff, (
162423162501
"-> use Bloom-filter on loop %c because there are ~%.1e "
@@ -215795,11 +215873,11 @@
215795215873
if( pCsr->iDb<0 ) return SQLITE_OK;
215796215874
}else{
215797215875
pCsr->iDb = 0;
215798215876
}
215799215877
pBt = db->aDb[pCsr->iDb].pBt;
215800
- if( pBt==0 ) return SQLITE_OK;
215878
+ if( NEVER(pBt==0) ) return SQLITE_OK;
215801215879
pCsr->pPager = sqlite3BtreePager(pBt);
215802215880
pCsr->szPage = sqlite3BtreeGetPageSize(pBt);
215803215881
pCsr->mxPgno = sqlite3BtreeLastPage(pBt);
215804215882
if( idxNum & 1 ){
215805215883
assert( argc>(idxNum>>1) );
@@ -215886,22 +215964,24 @@
215886215964
if( argc==1 ){
215887215965
zErr = "cannot delete";
215888215966
goto update_fail;
215889215967
}
215890215968
pgno = sqlite3_value_int(argv[0]);
215891
- if( (Pgno)sqlite3_value_int(argv[1])!=pgno ){
215969
+ if( sqlite3_value_type(argv[0])==SQLITE_NULL
215970
+ || (Pgno)sqlite3_value_int(argv[1])!=pgno
215971
+ ){
215892215972
zErr = "cannot insert";
215893215973
goto update_fail;
215894215974
}
215895215975
zSchema = (const char*)sqlite3_value_text(argv[4]);
215896
- iDb = zSchema ? sqlite3FindDbName(pTab->db, zSchema) : -1;
215897
- if( iDb<0 ){
215976
+ iDb = ALWAYS(zSchema) ? sqlite3FindDbName(pTab->db, zSchema) : -1;
215977
+ if( NEVER(iDb<0) ){
215898215978
zErr = "no such schema";
215899215979
goto update_fail;
215900215980
}
215901215981
pBt = pTab->db->aDb[iDb].pBt;
215902
- if( pgno<1 || pBt==0 || pgno>sqlite3BtreeLastPage(pBt) ){
215982
+ if( NEVER(pgno<1) || NEVER(pBt==0) || NEVER(pgno>sqlite3BtreeLastPage(pBt)) ){
215903215983
zErr = "bad page number";
215904215984
goto update_fail;
215905215985
}
215906215986
szPage = sqlite3BtreeGetPageSize(pBt);
215907215987
if( sqlite3_value_type(argv[3])!=SQLITE_BLOB
@@ -215936,16 +216016,15 @@
215936216016
*/
215937216017
static int dbpageBegin(sqlite3_vtab *pVtab){
215938216018
DbpageTable *pTab = (DbpageTable *)pVtab;
215939216019
sqlite3 *db = pTab->db;
215940216020
int i;
215941
- int rc = SQLITE_OK;
215942
- for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
216021
+ for(i=0; i<db->nDb; i++){
215943216022
Btree *pBt = db->aDb[i].pBt;
215944
- if( pBt ) rc = sqlite3BtreeBeginTrans(pBt, 1, 0);
216023
+ if( pBt ) (void)sqlite3BtreeBeginTrans(pBt, 1, 0);
215945216024
}
215946
- return rc;
216025
+ return SQLITE_OK;
215947216026
}
215948216027
215949216028
215950216029
/*
215951216030
** Invoke this routine to register the "dbpage" virtual table module
@@ -230526,10 +230605,12 @@
230526230605
230527230606
#if FTS5_MAX_PREFIX_INDEXES > 31
230528230607
# error "FTS5_MAX_PREFIX_INDEXES is too large"
230529230608
#endif
230530230609
230610
+#define FTS5_MAX_LEVEL 64
230611
+
230531230612
/*
230532230613
** Details:
230533230614
**
230534230615
** The %_data table managed by this module,
230535230616
**
@@ -235243,11 +235324,11 @@
235243235324
Fts5StructureLevel *pLvl;
235244235325
nByte = nSeg * sizeof(Fts5StructureSegment);
235245235326
pNew->nLevel = pStruct->nLevel+1;
235246235327
pNew->nRef = 1;
235247235328
pNew->nWriteCounter = pStruct->nWriteCounter;
235248
- pLvl = &pNew->aLevel[pStruct->nLevel];
235329
+ pLvl = &pNew->aLevel[MIN(pStruct->nLevel, FTS5_MAX_LEVEL-1)];
235249235330
pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&p->rc, nByte);
235250235331
if( pLvl->aSeg ){
235251235332
int iLvl, iSeg;
235252235333
int iSegOut = 0;
235253235334
/* Iterate through all segments, from oldest to newest. Add them to
@@ -240088,11 +240169,11 @@
240088240169
int nArg, /* Number of args */
240089240170
sqlite3_value **apUnused /* Function arguments */
240090240171
){
240091240172
assert( nArg==0 );
240092240173
UNUSED_PARAM2(nArg, apUnused);
240093
- sqlite3_result_text(pCtx, "fts5: 2023-02-03 12:03:56 75cdaafc77b8a1efc84e71e90470994227f376e7d7de34c813e75dcadbb9f268", -1, SQLITE_TRANSIENT);
240174
+ sqlite3_result_text(pCtx, "fts5: 2023-02-08 14:49:52 6b41ba2e996ab7b9c3943ab93a19748db5cf37792f5d59d20eec301085282355", -1, SQLITE_TRANSIENT);
240094240175
}
240095240176
240096240177
/*
240097240178
** Return true if zName is the extension on one of the shadow tables used
240098240179
** by this module.
240099240180
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.41.0"
456 #define SQLITE_VERSION_NUMBER 3041000
457 #define SQLITE_SOURCE_ID "2023-02-03 14:57:40 c045d76b908a8c90d22511df7884e78d452b250db9ba70d4cb0935048a3c3ac4"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -10123,11 +10123,11 @@
10123 ** ^(Use these routines to access all values on the right-hand side
10124 ** of the IN constraint using code like the following:
10125 **
10126 ** <blockquote><pre>
10127 ** &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal);
10128 ** &nbsp; rc==SQLITE_OK && pVal
10129 ** &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal)
10130 ** &nbsp; ){
10131 ** &nbsp; // do something with pVal
10132 ** &nbsp; }
10133 ** &nbsp; if( rc!=SQLITE_OK ){
@@ -10835,10 +10835,23 @@
10835 ** builds on processors without floating point support.
10836 */
10837 #ifdef SQLITE_OMIT_FLOATING_POINT
10838 # undef double
10839 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
10840
10841 #if 0
10842 } /* End of the 'extern "C"' block */
10843 #endif
10844 #endif /* SQLITE3_H */
@@ -17103,10 +17116,11 @@
17103 u8 mTrace; /* zero or more SQLITE_TRACE flags */
17104 u8 noSharedCache; /* True if no shared-cache backends */
17105 u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
17106 u8 eOpenState; /* Current condition of the connection */
17107 int nextPagesize; /* Pagesize after VACUUM if >0 */
 
17108 i64 nChange; /* Value returned by sqlite3_changes() */
17109 i64 nTotalChange; /* Value returned by sqlite3_total_changes() */
17110 int aLimit[SQLITE_N_LIMIT]; /* Limits */
17111 int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */
17112 struct sqlite3InitInfo { /* Information used during initialization */
@@ -20822,11 +20836,11 @@
20822 SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
20823 #if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
20824 && !defined(SQLITE_OMIT_VIRTUALTABLE)
20825 SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(sqlite3_index_info*);
20826 #endif
20827 SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
20828 SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
20829 SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
20830 SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse*,sqlite3*);
20831 SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse*);
20832 SQLITE_PRIVATE void *sqlite3ParserAddCleanup(Parse*,void(*)(sqlite3*,void*),void*);
@@ -23810,16 +23824,20 @@
23810 }
23811 return 0;
23812 }
23813
23814 /*
23815 ** Set the time to the current time reported by the VFS.
 
 
 
 
23816 **
23817 ** Return the number of errors.
23818 */
23819 static int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){
23820 p->iJD = sqlite3StmtCurrentTime(context);
23821 if( p->iJD>0 ){
23822 p->validJD = 1;
23823 return 0;
23824 }else{
23825 return 1;
@@ -23866,11 +23884,13 @@
23866 if( parseYyyyMmDd(zDate,p)==0 ){
23867 return 0;
23868 }else if( parseHhMmSs(zDate, p)==0 ){
23869 return 0;
23870 }else if( sqlite3StrICmp(zDate,"now")==0 && sqlite3NotPureFunc(context) ){
23871 return setDateTimeToCurrent(context, p);
 
 
23872 }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8)>0 ){
23873 setRawDateNumber(p, r);
23874 return 0;
23875 }
23876 return 1;
@@ -24410,12 +24430,15 @@
24410 ** Process time function arguments. argv[0] is a date-time stamp.
24411 ** argv[1] and following are modifiers. Parse them all and write
24412 ** the resulting time into the DateTime structure p. Return 0
24413 ** on success and 1 if there are any errors.
24414 **
24415 ** If there are zero parameters (if even argv[0] is undefined)
24416 ** then assume a default value of "now" for argv[0].
 
 
 
24417 */
24418 static int isDate(
24419 sqlite3_context *context,
24420 int argc,
24421 sqlite3_value **argv,
@@ -24423,13 +24446,13 @@
24423 ){
24424 int i, n;
24425 const unsigned char *z;
24426 int eType;
24427 memset(p, 0, sizeof(*p));
24428 if( argc==0 ){
24429 if( !sqlite3NotPureFunc(context) ) return 1;
24430 return setDateTimeToCurrent(context, p);
24431 }
24432 if( (eType = sqlite3_value_type(argv[0]))==SQLITE_FLOAT
24433 || eType==SQLITE_INTEGER ){
24434 setRawDateNumber(p, sqlite3_value_double(argv[0]));
24435 }else{
@@ -24732,11 +24755,11 @@
24732 sqlite3_context *context,
24733 int NotUsed,
24734 sqlite3_value **NotUsed2
24735 ){
24736 UNUSED_PARAMETER2(NotUsed, NotUsed2);
24737 timeFunc(context, 0, 0);
24738 }
24739
24740 /*
24741 ** current_date()
24742 **
@@ -24746,11 +24769,11 @@
24746 sqlite3_context *context,
24747 int NotUsed,
24748 sqlite3_value **NotUsed2
24749 ){
24750 UNUSED_PARAMETER2(NotUsed, NotUsed2);
24751 dateFunc(context, 0, 0);
24752 }
24753
24754 /*
24755 ** current_timestamp()
24756 **
@@ -24760,11 +24783,11 @@
24760 sqlite3_context *context,
24761 int NotUsed,
24762 sqlite3_value **NotUsed2
24763 ){
24764 UNUSED_PARAMETER2(NotUsed, NotUsed2);
24765 datetimeFunc(context, 0, 0);
24766 }
24767 #endif /* !defined(SQLITE_OMIT_DATETIME_FUNCS) */
24768
24769 #ifdef SQLITE_OMIT_DATETIME_FUNCS
24770 /*
@@ -24791,11 +24814,11 @@
24791 char zBuf[20];
24792
24793 UNUSED_PARAMETER(argc);
24794 UNUSED_PARAMETER(argv);
24795
24796 iT = sqlite3StmtCurrentTime(context);
24797 if( iT<=0 ) return;
24798 t = iT/1000 - 10000*(sqlite3_int64)21086676;
24799 #if HAVE_GMTIME_R
24800 pTm = gmtime_r(&t, &sNow);
24801 #else
@@ -36999,11 +37022,12 @@
36999 #include <sys/ioctl.h>
37000 #include <unistd.h> /* amalgamator: keep */
37001 /* #include <time.h> */
37002 #include <sys/time.h> /* amalgamator: keep */
37003 #include <errno.h>
37004 #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
 
37005 # include <sys/mman.h>
37006 #endif
37007
37008 #if SQLITE_ENABLE_LOCKING_STYLE
37009 /* # include <sys/ioctl.h> */
@@ -37087,13 +37111,50 @@
37087 /*
37088 ** Maximum supported symbolic links
37089 */
37090 #define SQLITE_MAX_SYMLINKS 100
37091
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37092 /* Always cast the getpid() return type for compatibility with
37093 ** kernel modules in VxWorks. */
37094 #define osGetpid(X) (pid_t)getpid()
 
37095
37096 /*
37097 ** Only set the lastErrno if the error code is a real error and not
37098 ** a normal expected return code of SQLITE_BUSY or SQLITE_OK
37099 */
@@ -37361,11 +37422,15 @@
37361 { "pwrite64", (sqlite3_syscall_ptr)0, 0 },
37362 #endif
37363 #define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off64_t))\
37364 aSyscall[13].pCurrent)
37365
 
37366 { "fchmod", (sqlite3_syscall_ptr)fchmod, 0 },
 
 
 
37367 #define osFchmod ((int(*)(int,mode_t))aSyscall[14].pCurrent)
37368
37369 #if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
37370 { "fallocate", (sqlite3_syscall_ptr)posix_fallocate, 0 },
37371 #else
@@ -37397,18 +37462,20 @@
37397 #else
37398 { "geteuid", (sqlite3_syscall_ptr)0, 0 },
37399 #endif
37400 #define osGeteuid ((uid_t(*)(void))aSyscall[21].pCurrent)
37401
37402 #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
 
37403 { "mmap", (sqlite3_syscall_ptr)mmap, 0 },
37404 #else
37405 { "mmap", (sqlite3_syscall_ptr)0, 0 },
37406 #endif
37407 #define osMmap ((void*(*)(void*,size_t,int,int,int,off_t))aSyscall[22].pCurrent)
37408
37409 #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
 
37410 { "munmap", (sqlite3_syscall_ptr)munmap, 0 },
37411 #else
37412 { "munmap", (sqlite3_syscall_ptr)0, 0 },
37413 #endif
37414 #define osMunmap ((int(*)(void*,size_t))aSyscall[23].pCurrent)
@@ -61699,11 +61766,11 @@
61699 UNUSED_PARAMETER(isDirectMode);
61700 #else
61701 # define DIRECT_MODE isDirectMode
61702 #endif
61703
61704 if( !pPager->changeCountDone && ALWAYS(pPager->dbSize>0) ){
61705 PgHdr *pPgHdr; /* Reference to page 1 */
61706
61707 assert( !pPager->tempFile && isOpen(pPager->fd) );
61708
61709 /* Open page 1 of the file for writing. */
@@ -81848,11 +81915,13 @@
81848 rc = ctx.isError;
81849 sqlite3ErrorMsg(pCtx->pParse, "%s", sqlite3_value_text(pVal));
81850 }else{
81851 sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8);
81852 assert( rc==SQLITE_OK );
81853 assert( enc==pVal->enc || db->mallocFailed );
 
 
81854 #if 0 /* Not reachable except after a prior failure */
81855 rc = sqlite3VdbeChangeEncoding(pVal, enc);
81856 if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){
81857 rc = SQLITE_TOOBIG;
81858 pCtx->pParse->nErr++;
@@ -85716,10 +85785,11 @@
85716 ** by connection db have now been released. Call sqlite3ConnectionUnlocked()
85717 ** to invoke any required unlock-notify callbacks.
85718 */
85719 if( db->autoCommit ){
85720 sqlite3ConnectionUnlocked(db);
 
85721 }
85722
85723 assert( db->nVdbeActive>0 || db->autoCommit==0 || db->nStatement==0 );
85724 return (p->rc==SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK);
85725 }
@@ -88674,22 +88744,31 @@
88674 ** Return the current time for a statement. If the current time
88675 ** is requested more than once within the same run of a single prepared
88676 ** statement, the exact same time is returned for each invocation regardless
88677 ** of the amount of time that elapses between invocations. In other words,
88678 ** the time returned is always the time of the first call.
 
 
 
 
 
88679 */
88680 SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){
88681 int rc;
88682 #ifndef SQLITE_ENABLE_STAT4
88683 sqlite3_int64 *piTime = &p->pVdbe->iCurrentTime;
 
88684 assert( p->pVdbe!=0 );
 
88685 #else
88686 sqlite3_int64 iTime = 0;
88687 sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;
 
 
88688 #endif
88689 if( *piTime==0 ){
88690 rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime);
88691 if( rc ) *piTime = 0;
88692 }
88693 return *piTime;
88694 }
88695
@@ -158421,16 +158500,16 @@
158421 ** be greater than or equal to the (iCol) field prefix of sample i.
158422 ** If (i>0), then pRec must also be greater than sample (i-1). */
158423 if( iCol>0 ){
158424 pRec->nField = iCol;
158425 assert( sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)<=0
158426 || pParse->db->mallocFailed );
158427 }
158428 if( i>0 ){
158429 pRec->nField = nField;
158430 assert( sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0
158431 || pParse->db->mallocFailed );
158432 }
158433 }
158434 }
158435 #endif /* ifdef SQLITE_DEBUG */
158436
@@ -162396,28 +162475,27 @@
162396 */
162397 static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful(
162398 const WhereInfo *pWInfo
162399 ){
162400 int i;
162401 LogEst nSearch;
162402
162403 assert( pWInfo->nLevel>=2 );
162404 assert( OptimizationEnabled(pWInfo->pParse->db, SQLITE_BloomFilter) );
162405 nSearch = pWInfo->a[0].pWLoop->nOut;
162406 for(i=1; i<pWInfo->nLevel; i++){
162407 WhereLoop *pLoop = pWInfo->a[i].pWLoop;
162408 const unsigned int reqFlags = (WHERE_SELFCULL|WHERE_COLUMN_EQ);
162409 if( (pLoop->wsFlags & reqFlags)==reqFlags
 
 
 
 
 
162410 /* vvvvvv--- Always the case if WHERE_COLUMN_EQ is defined */
162411 && ALWAYS((pLoop->wsFlags & (WHERE_IPK|WHERE_INDEXED))!=0)
162412 ){
162413 SrcItem *pItem = &pWInfo->pTabList->a[pLoop->iTab];
162414 Table *pTab = pItem->pTab;
162415 pTab->tabFlags |= TF_StatsUsed;
162416 if( nSearch > pTab->nRowLogEst
162417 && (pTab->tabFlags & TF_HasStat1)!=0
162418 ){
162419 testcase( pItem->fg.jointype & JT_LEFT );
162420 pLoop->wsFlags |= WHERE_BLOOMFILTER;
162421 pLoop->wsFlags &= ~WHERE_IDX_ONLY;
162422 WHERETRACE(0xffffffff, (
162423 "-> use Bloom-filter on loop %c because there are ~%.1e "
@@ -215795,11 +215873,11 @@
215795 if( pCsr->iDb<0 ) return SQLITE_OK;
215796 }else{
215797 pCsr->iDb = 0;
215798 }
215799 pBt = db->aDb[pCsr->iDb].pBt;
215800 if( pBt==0 ) return SQLITE_OK;
215801 pCsr->pPager = sqlite3BtreePager(pBt);
215802 pCsr->szPage = sqlite3BtreeGetPageSize(pBt);
215803 pCsr->mxPgno = sqlite3BtreeLastPage(pBt);
215804 if( idxNum & 1 ){
215805 assert( argc>(idxNum>>1) );
@@ -215886,22 +215964,24 @@
215886 if( argc==1 ){
215887 zErr = "cannot delete";
215888 goto update_fail;
215889 }
215890 pgno = sqlite3_value_int(argv[0]);
215891 if( (Pgno)sqlite3_value_int(argv[1])!=pgno ){
 
 
215892 zErr = "cannot insert";
215893 goto update_fail;
215894 }
215895 zSchema = (const char*)sqlite3_value_text(argv[4]);
215896 iDb = zSchema ? sqlite3FindDbName(pTab->db, zSchema) : -1;
215897 if( iDb<0 ){
215898 zErr = "no such schema";
215899 goto update_fail;
215900 }
215901 pBt = pTab->db->aDb[iDb].pBt;
215902 if( pgno<1 || pBt==0 || pgno>sqlite3BtreeLastPage(pBt) ){
215903 zErr = "bad page number";
215904 goto update_fail;
215905 }
215906 szPage = sqlite3BtreeGetPageSize(pBt);
215907 if( sqlite3_value_type(argv[3])!=SQLITE_BLOB
@@ -215936,16 +216016,15 @@
215936 */
215937 static int dbpageBegin(sqlite3_vtab *pVtab){
215938 DbpageTable *pTab = (DbpageTable *)pVtab;
215939 sqlite3 *db = pTab->db;
215940 int i;
215941 int rc = SQLITE_OK;
215942 for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
215943 Btree *pBt = db->aDb[i].pBt;
215944 if( pBt ) rc = sqlite3BtreeBeginTrans(pBt, 1, 0);
215945 }
215946 return rc;
215947 }
215948
215949
215950 /*
215951 ** Invoke this routine to register the "dbpage" virtual table module
@@ -230526,10 +230605,12 @@
230526
230527 #if FTS5_MAX_PREFIX_INDEXES > 31
230528 # error "FTS5_MAX_PREFIX_INDEXES is too large"
230529 #endif
230530
 
 
230531 /*
230532 ** Details:
230533 **
230534 ** The %_data table managed by this module,
230535 **
@@ -235243,11 +235324,11 @@
235243 Fts5StructureLevel *pLvl;
235244 nByte = nSeg * sizeof(Fts5StructureSegment);
235245 pNew->nLevel = pStruct->nLevel+1;
235246 pNew->nRef = 1;
235247 pNew->nWriteCounter = pStruct->nWriteCounter;
235248 pLvl = &pNew->aLevel[pStruct->nLevel];
235249 pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&p->rc, nByte);
235250 if( pLvl->aSeg ){
235251 int iLvl, iSeg;
235252 int iSegOut = 0;
235253 /* Iterate through all segments, from oldest to newest. Add them to
@@ -240088,11 +240169,11 @@
240088 int nArg, /* Number of args */
240089 sqlite3_value **apUnused /* Function arguments */
240090 ){
240091 assert( nArg==0 );
240092 UNUSED_PARAM2(nArg, apUnused);
240093 sqlite3_result_text(pCtx, "fts5: 2023-02-03 12:03:56 75cdaafc77b8a1efc84e71e90470994227f376e7d7de34c813e75dcadbb9f268", -1, SQLITE_TRANSIENT);
240094 }
240095
240096 /*
240097 ** Return true if zName is the extension on one of the shadow tables used
240098 ** by this module.
240099
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -452,11 +452,11 @@
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.41.0"
456 #define SQLITE_VERSION_NUMBER 3041000
457 #define SQLITE_SOURCE_ID "2023-02-08 14:49:52 6b41ba2e996ab7b9c3943ab93a19748db5cf37792f5d59d20eec301085282355"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -10123,11 +10123,11 @@
10123 ** ^(Use these routines to access all values on the right-hand side
10124 ** of the IN constraint using code like the following:
10125 **
10126 ** <blockquote><pre>
10127 ** &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal);
10128 ** &nbsp; rc==SQLITE_OK && pVal;
10129 ** &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal)
10130 ** &nbsp; ){
10131 ** &nbsp; // do something with pVal
10132 ** &nbsp; }
10133 ** &nbsp; if( rc!=SQLITE_OK ){
@@ -10835,10 +10835,23 @@
10835 ** builds on processors without floating point support.
10836 */
10837 #ifdef SQLITE_OMIT_FLOATING_POINT
10838 # undef double
10839 #endif
10840
10841 #if defined(__wasi__)
10842 # undef SQLITE_WASI
10843 # define SQLITE_WASI 1
10844 # undef SQLITE_OMIT_WAL
10845 # define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */
10846 # ifndef SQLITE_OMIT_LOAD_EXTENSION
10847 # define SQLITE_OMIT_LOAD_EXTENSION
10848 # endif
10849 # ifndef SQLITE_THREADSAFE
10850 # define SQLITE_THREADSAFE 0
10851 # endif
10852 #endif
10853
10854 #if 0
10855 } /* End of the 'extern "C"' block */
10856 #endif
10857 #endif /* SQLITE3_H */
@@ -17103,10 +17116,11 @@
17116 u8 mTrace; /* zero or more SQLITE_TRACE flags */
17117 u8 noSharedCache; /* True if no shared-cache backends */
17118 u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
17119 u8 eOpenState; /* Current condition of the connection */
17120 int nextPagesize; /* Pagesize after VACUUM if >0 */
17121 i64 txnTime; /* Timestamp for current transaction */
17122 i64 nChange; /* Value returned by sqlite3_changes() */
17123 i64 nTotalChange; /* Value returned by sqlite3_total_changes() */
17124 int aLimit[SQLITE_N_LIMIT]; /* Limits */
17125 int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */
17126 struct sqlite3InitInfo { /* Information used during initialization */
@@ -20822,11 +20836,11 @@
20836 SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
20837 #if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
20838 && !defined(SQLITE_OMIT_VIRTUALTABLE)
20839 SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(sqlite3_index_info*);
20840 #endif
20841 SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*, int);
20842 SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
20843 SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
20844 SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse*,sqlite3*);
20845 SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse*);
20846 SQLITE_PRIVATE void *sqlite3ParserAddCleanup(Parse*,void(*)(sqlite3*,void*),void*);
@@ -23810,16 +23824,20 @@
23824 }
23825 return 0;
23826 }
23827
23828 /*
23829 ** Set the time to the current time reported for the prepared statement
23830 ** that is currently executing. The same time is reported for all
23831 ** invocations of this routine from within the same call to sqlite3_step().
23832 **
23833 ** Or if bTxn is true, use the transaction time.
23834 **
23835 ** Return the number of errors.
23836 */
23837 static int setCurrentStmtTime(sqlite3_context *context, DateTime *p, int bTxn){
23838 p->iJD = sqlite3StmtCurrentTime(context, bTxn);
23839 if( p->iJD>0 ){
23840 p->validJD = 1;
23841 return 0;
23842 }else{
23843 return 1;
@@ -23866,11 +23884,13 @@
23884 if( parseYyyyMmDd(zDate,p)==0 ){
23885 return 0;
23886 }else if( parseHhMmSs(zDate, p)==0 ){
23887 return 0;
23888 }else if( sqlite3StrICmp(zDate,"now")==0 && sqlite3NotPureFunc(context) ){
23889 return setCurrentStmtTime(context, p, 0);
23890 }else if( sqlite3StrICmp(zDate,"txn")==0 && sqlite3NotPureFunc(context) ){
23891 return setCurrentStmtTime(context, p, 1);
23892 }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8)>0 ){
23893 setRawDateNumber(p, r);
23894 return 0;
23895 }
23896 return 1;
@@ -24410,12 +24430,15 @@
24430 ** Process time function arguments. argv[0] is a date-time stamp.
24431 ** argv[1] and following are modifiers. Parse them all and write
24432 ** the resulting time into the DateTime structure p. Return 0
24433 ** on success and 1 if there are any errors.
24434 **
24435 ** If there are zero parameters (if argc<=0) then assume a default
24436 ** value of "now" for argv[0] if argc==0 and "txn" if argc<0. SQL
24437 ** functions will always have argc>=0, but the special implementations
24438 ** of CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP set argc to -1
24439 ** in order to force the use of 'txn' semantics.
24440 */
24441 static int isDate(
24442 sqlite3_context *context,
24443 int argc,
24444 sqlite3_value **argv,
@@ -24423,13 +24446,13 @@
24446 ){
24447 int i, n;
24448 const unsigned char *z;
24449 int eType;
24450 memset(p, 0, sizeof(*p));
24451 if( argc<=0 ){
24452 if( !sqlite3NotPureFunc(context) ) return 1;
24453 return setCurrentStmtTime(context, p, argc<0);
24454 }
24455 if( (eType = sqlite3_value_type(argv[0]))==SQLITE_FLOAT
24456 || eType==SQLITE_INTEGER ){
24457 setRawDateNumber(p, sqlite3_value_double(argv[0]));
24458 }else{
@@ -24732,11 +24755,11 @@
24755 sqlite3_context *context,
24756 int NotUsed,
24757 sqlite3_value **NotUsed2
24758 ){
24759 UNUSED_PARAMETER2(NotUsed, NotUsed2);
24760 timeFunc(context, -1, 0);
24761 }
24762
24763 /*
24764 ** current_date()
24765 **
@@ -24746,11 +24769,11 @@
24769 sqlite3_context *context,
24770 int NotUsed,
24771 sqlite3_value **NotUsed2
24772 ){
24773 UNUSED_PARAMETER2(NotUsed, NotUsed2);
24774 dateFunc(context, -1, 0);
24775 }
24776
24777 /*
24778 ** current_timestamp()
24779 **
@@ -24760,11 +24783,11 @@
24783 sqlite3_context *context,
24784 int NotUsed,
24785 sqlite3_value **NotUsed2
24786 ){
24787 UNUSED_PARAMETER2(NotUsed, NotUsed2);
24788 datetimeFunc(context, -1, 0);
24789 }
24790 #endif /* !defined(SQLITE_OMIT_DATETIME_FUNCS) */
24791
24792 #ifdef SQLITE_OMIT_DATETIME_FUNCS
24793 /*
@@ -24791,11 +24814,11 @@
24814 char zBuf[20];
24815
24816 UNUSED_PARAMETER(argc);
24817 UNUSED_PARAMETER(argv);
24818
24819 iT = sqlite3StmtCurrentTime(context, 1);
24820 if( iT<=0 ) return;
24821 t = iT/1000 - 10000*(sqlite3_int64)21086676;
24822 #if HAVE_GMTIME_R
24823 pTm = gmtime_r(&t, &sNow);
24824 #else
@@ -36999,11 +37022,12 @@
37022 #include <sys/ioctl.h>
37023 #include <unistd.h> /* amalgamator: keep */
37024 /* #include <time.h> */
37025 #include <sys/time.h> /* amalgamator: keep */
37026 #include <errno.h>
37027 #if (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) \
37028 && !defined(SQLITE_WASI)
37029 # include <sys/mman.h>
37030 #endif
37031
37032 #if SQLITE_ENABLE_LOCKING_STYLE
37033 /* # include <sys/ioctl.h> */
@@ -37087,13 +37111,50 @@
37111 /*
37112 ** Maximum supported symbolic links
37113 */
37114 #define SQLITE_MAX_SYMLINKS 100
37115
37116 /*
37117 ** Remove and stub certain info for WASI (WebAssembly System
37118 ** Interface) builds.
37119 */
37120 #ifdef SQLITE_WASI
37121 # undef HAVE_FCHMOD
37122 # undef HAVE_FCHOWN
37123 # undef HAVE_MREMAP
37124 # define HAVE_MREMAP 0
37125 # ifndef SQLITE_DEFAULT_UNIX_VFS
37126 # define SQLITE_DEFAULT_UNIX_VFS "unix-dotfile"
37127 /* ^^^ should SQLITE_DEFAULT_UNIX_VFS be "unix-none"? */
37128 # endif
37129 # ifndef F_RDLCK
37130 # define F_RDLCK 0
37131 # define F_WRLCK 1
37132 # define F_UNLCK 2
37133 # if __LONG_MAX == 0x7fffffffL
37134 # define F_GETLK 12
37135 # define F_SETLK 13
37136 # define F_SETLKW 14
37137 # else
37138 # define F_GETLK 5
37139 # define F_SETLK 6
37140 # define F_SETLKW 7
37141 # endif
37142 # endif
37143 #else /* !SQLITE_WASI */
37144 # ifndef HAVE_FCHMOD
37145 # define HAVE_FCHMOD
37146 # endif
37147 #endif /* SQLITE_WASI */
37148
37149 #ifdef SQLITE_WASI
37150 # define osGetpid(X) (pid_t)1
37151 #else
37152 /* Always cast the getpid() return type for compatibility with
37153 ** kernel modules in VxWorks. */
37154 # define osGetpid(X) (pid_t)getpid()
37155 #endif
37156
37157 /*
37158 ** Only set the lastErrno if the error code is a real error and not
37159 ** a normal expected return code of SQLITE_BUSY or SQLITE_OK
37160 */
@@ -37361,11 +37422,15 @@
37422 { "pwrite64", (sqlite3_syscall_ptr)0, 0 },
37423 #endif
37424 #define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off64_t))\
37425 aSyscall[13].pCurrent)
37426
37427 #if defined(HAVE_FCHMOD)
37428 { "fchmod", (sqlite3_syscall_ptr)fchmod, 0 },
37429 #else
37430 { "fchmod", (sqlite3_syscall_ptr)0, 0 },
37431 #endif
37432 #define osFchmod ((int(*)(int,mode_t))aSyscall[14].pCurrent)
37433
37434 #if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
37435 { "fallocate", (sqlite3_syscall_ptr)posix_fallocate, 0 },
37436 #else
@@ -37397,18 +37462,20 @@
37462 #else
37463 { "geteuid", (sqlite3_syscall_ptr)0, 0 },
37464 #endif
37465 #define osGeteuid ((uid_t(*)(void))aSyscall[21].pCurrent)
37466
37467 #if (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) \
37468 && !defined(SQLITE_WASI)
37469 { "mmap", (sqlite3_syscall_ptr)mmap, 0 },
37470 #else
37471 { "mmap", (sqlite3_syscall_ptr)0, 0 },
37472 #endif
37473 #define osMmap ((void*(*)(void*,size_t,int,int,int,off_t))aSyscall[22].pCurrent)
37474
37475 #if (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) \
37476 && !defined(SQLITE_WASI)
37477 { "munmap", (sqlite3_syscall_ptr)munmap, 0 },
37478 #else
37479 { "munmap", (sqlite3_syscall_ptr)0, 0 },
37480 #endif
37481 #define osMunmap ((int(*)(void*,size_t))aSyscall[23].pCurrent)
@@ -61699,11 +61766,11 @@
61766 UNUSED_PARAMETER(isDirectMode);
61767 #else
61768 # define DIRECT_MODE isDirectMode
61769 #endif
61770
61771 if( !pPager->changeCountDone && pPager->dbSize>0 ){
61772 PgHdr *pPgHdr; /* Reference to page 1 */
61773
61774 assert( !pPager->tempFile && isOpen(pPager->fd) );
61775
61776 /* Open page 1 of the file for writing. */
@@ -81848,11 +81915,13 @@
81915 rc = ctx.isError;
81916 sqlite3ErrorMsg(pCtx->pParse, "%s", sqlite3_value_text(pVal));
81917 }else{
81918 sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8);
81919 assert( rc==SQLITE_OK );
81920 assert( enc==pVal->enc
81921 || (pVal->flags & MEM_Str)==0
81922 || db->mallocFailed );
81923 #if 0 /* Not reachable except after a prior failure */
81924 rc = sqlite3VdbeChangeEncoding(pVal, enc);
81925 if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){
81926 rc = SQLITE_TOOBIG;
81927 pCtx->pParse->nErr++;
@@ -85716,10 +85785,11 @@
85785 ** by connection db have now been released. Call sqlite3ConnectionUnlocked()
85786 ** to invoke any required unlock-notify callbacks.
85787 */
85788 if( db->autoCommit ){
85789 sqlite3ConnectionUnlocked(db);
85790 db->txnTime = 0;
85791 }
85792
85793 assert( db->nVdbeActive>0 || db->autoCommit==0 || db->nStatement==0 );
85794 return (p->rc==SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK);
85795 }
@@ -88674,22 +88744,31 @@
88744 ** Return the current time for a statement. If the current time
88745 ** is requested more than once within the same run of a single prepared
88746 ** statement, the exact same time is returned for each invocation regardless
88747 ** of the amount of time that elapses between invocations. In other words,
88748 ** the time returned is always the time of the first call.
88749 **
88750 ** Or, if bTxn, return the transaction time. The transaction time is the
88751 ** same for all calls within the same transaction.
88752 **
88753 ** bTxn is 0 for SQL like datetime('now') and is 1 for datetime('txn').
88754 */
88755 SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p, int bTxn){
88756 int rc;
88757 #ifndef SQLITE_ENABLE_STAT4
88758 sqlite3_int64 *piTime;
88759 sqlite3 *db = p->pOut->db;
88760 assert( p->pVdbe!=0 );
88761 piTime = bTxn ? &db->txnTime : &p->pVdbe->iCurrentTime;
88762 #else
88763 sqlite3_int64 iTime = 0;
88764 sqlite3_int64 *piTime;
88765 sqlite3 *db = p->pOut->db;
88766 piTime = bTxn ? &db->txnTime : p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;
88767 #endif
88768 if( *piTime==0 ){
88769 rc = sqlite3OsCurrentTimeInt64(db->pVfs, piTime);
88770 if( rc ) *piTime = 0;
88771 }
88772 return *piTime;
88773 }
88774
@@ -158421,16 +158500,16 @@
158500 ** be greater than or equal to the (iCol) field prefix of sample i.
158501 ** If (i>0), then pRec must also be greater than sample (i-1). */
158502 if( iCol>0 ){
158503 pRec->nField = iCol;
158504 assert( sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)<=0
158505 || pParse->db->mallocFailed || CORRUPT_DB );
158506 }
158507 if( i>0 ){
158508 pRec->nField = nField;
158509 assert( sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0
158510 || pParse->db->mallocFailed || CORRUPT_DB );
158511 }
158512 }
158513 }
158514 #endif /* ifdef SQLITE_DEBUG */
158515
@@ -162396,28 +162475,27 @@
162475 */
162476 static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful(
162477 const WhereInfo *pWInfo
162478 ){
162479 int i;
162480 LogEst nSearch = 0;
162481
162482 assert( pWInfo->nLevel>=2 );
162483 assert( OptimizationEnabled(pWInfo->pParse->db, SQLITE_BloomFilter) );
162484 for(i=0; i<pWInfo->nLevel; i++){
 
162485 WhereLoop *pLoop = pWInfo->a[i].pWLoop;
162486 const unsigned int reqFlags = (WHERE_SELFCULL|WHERE_COLUMN_EQ);
162487 SrcItem *pItem = &pWInfo->pTabList->a[pLoop->iTab];
162488 Table *pTab = pItem->pTab;
162489 if( (pTab->tabFlags & TF_HasStat1)==0 ) break;
162490 pTab->tabFlags |= TF_StatsUsed;
162491 if( i>=1
162492 && (pLoop->wsFlags & reqFlags)==reqFlags
162493 /* vvvvvv--- Always the case if WHERE_COLUMN_EQ is defined */
162494 && ALWAYS((pLoop->wsFlags & (WHERE_IPK|WHERE_INDEXED))!=0)
162495 ){
162496 if( nSearch > pTab->nRowLogEst ){
 
 
 
 
 
162497 testcase( pItem->fg.jointype & JT_LEFT );
162498 pLoop->wsFlags |= WHERE_BLOOMFILTER;
162499 pLoop->wsFlags &= ~WHERE_IDX_ONLY;
162500 WHERETRACE(0xffffffff, (
162501 "-> use Bloom-filter on loop %c because there are ~%.1e "
@@ -215795,11 +215873,11 @@
215873 if( pCsr->iDb<0 ) return SQLITE_OK;
215874 }else{
215875 pCsr->iDb = 0;
215876 }
215877 pBt = db->aDb[pCsr->iDb].pBt;
215878 if( NEVER(pBt==0) ) return SQLITE_OK;
215879 pCsr->pPager = sqlite3BtreePager(pBt);
215880 pCsr->szPage = sqlite3BtreeGetPageSize(pBt);
215881 pCsr->mxPgno = sqlite3BtreeLastPage(pBt);
215882 if( idxNum & 1 ){
215883 assert( argc>(idxNum>>1) );
@@ -215886,22 +215964,24 @@
215964 if( argc==1 ){
215965 zErr = "cannot delete";
215966 goto update_fail;
215967 }
215968 pgno = sqlite3_value_int(argv[0]);
215969 if( sqlite3_value_type(argv[0])==SQLITE_NULL
215970 || (Pgno)sqlite3_value_int(argv[1])!=pgno
215971 ){
215972 zErr = "cannot insert";
215973 goto update_fail;
215974 }
215975 zSchema = (const char*)sqlite3_value_text(argv[4]);
215976 iDb = ALWAYS(zSchema) ? sqlite3FindDbName(pTab->db, zSchema) : -1;
215977 if( NEVER(iDb<0) ){
215978 zErr = "no such schema";
215979 goto update_fail;
215980 }
215981 pBt = pTab->db->aDb[iDb].pBt;
215982 if( NEVER(pgno<1) || NEVER(pBt==0) || NEVER(pgno>sqlite3BtreeLastPage(pBt)) ){
215983 zErr = "bad page number";
215984 goto update_fail;
215985 }
215986 szPage = sqlite3BtreeGetPageSize(pBt);
215987 if( sqlite3_value_type(argv[3])!=SQLITE_BLOB
@@ -215936,16 +216016,15 @@
216016 */
216017 static int dbpageBegin(sqlite3_vtab *pVtab){
216018 DbpageTable *pTab = (DbpageTable *)pVtab;
216019 sqlite3 *db = pTab->db;
216020 int i;
216021 for(i=0; i<db->nDb; i++){
 
216022 Btree *pBt = db->aDb[i].pBt;
216023 if( pBt ) (void)sqlite3BtreeBeginTrans(pBt, 1, 0);
216024 }
216025 return SQLITE_OK;
216026 }
216027
216028
216029 /*
216030 ** Invoke this routine to register the "dbpage" virtual table module
@@ -230526,10 +230605,12 @@
230605
230606 #if FTS5_MAX_PREFIX_INDEXES > 31
230607 # error "FTS5_MAX_PREFIX_INDEXES is too large"
230608 #endif
230609
230610 #define FTS5_MAX_LEVEL 64
230611
230612 /*
230613 ** Details:
230614 **
230615 ** The %_data table managed by this module,
230616 **
@@ -235243,11 +235324,11 @@
235324 Fts5StructureLevel *pLvl;
235325 nByte = nSeg * sizeof(Fts5StructureSegment);
235326 pNew->nLevel = pStruct->nLevel+1;
235327 pNew->nRef = 1;
235328 pNew->nWriteCounter = pStruct->nWriteCounter;
235329 pLvl = &pNew->aLevel[MIN(pStruct->nLevel, FTS5_MAX_LEVEL-1)];
235330 pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&p->rc, nByte);
235331 if( pLvl->aSeg ){
235332 int iLvl, iSeg;
235333 int iSegOut = 0;
235334 /* Iterate through all segments, from oldest to newest. Add them to
@@ -240088,11 +240169,11 @@
240169 int nArg, /* Number of args */
240170 sqlite3_value **apUnused /* Function arguments */
240171 ){
240172 assert( nArg==0 );
240173 UNUSED_PARAM2(nArg, apUnused);
240174 sqlite3_result_text(pCtx, "fts5: 2023-02-08 14:49:52 6b41ba2e996ab7b9c3943ab93a19748db5cf37792f5d59d20eec301085282355", -1, SQLITE_TRANSIENT);
240175 }
240176
240177 /*
240178 ** Return true if zName is the extension on one of the shadow tables used
240179 ** by this module.
240180
+15 -2
--- 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.41.0"
150150
#define SQLITE_VERSION_NUMBER 3041000
151
-#define SQLITE_SOURCE_ID "2023-02-03 14:57:40 c045d76b908a8c90d22511df7884e78d452b250db9ba70d4cb0935048a3c3ac4"
151
+#define SQLITE_SOURCE_ID "2023-02-08 14:49:52 6b41ba2e996ab7b9c3943ab93a19748db5cf37792f5d59d20eec301085282355"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -9817,11 +9817,11 @@
98179817
** ^(Use these routines to access all values on the right-hand side
98189818
** of the IN constraint using code like the following:
98199819
**
98209820
** <blockquote><pre>
98219821
** &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal);
9822
-** &nbsp; rc==SQLITE_OK && pVal
9822
+** &nbsp; rc==SQLITE_OK && pVal;
98239823
** &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal)
98249824
** &nbsp; ){
98259825
** &nbsp; // do something with pVal
98269826
** &nbsp; }
98279827
** &nbsp; if( rc!=SQLITE_OK ){
@@ -10529,10 +10529,23 @@
1052910529
** builds on processors without floating point support.
1053010530
*/
1053110531
#ifdef SQLITE_OMIT_FLOATING_POINT
1053210532
# undef double
1053310533
#endif
10534
+
10535
+#if defined(__wasi__)
10536
+# undef SQLITE_WASI
10537
+# define SQLITE_WASI 1
10538
+# undef SQLITE_OMIT_WAL
10539
+# define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */
10540
+# ifndef SQLITE_OMIT_LOAD_EXTENSION
10541
+# define SQLITE_OMIT_LOAD_EXTENSION
10542
+# endif
10543
+# ifndef SQLITE_THREADSAFE
10544
+# define SQLITE_THREADSAFE 0
10545
+# endif
10546
+#endif
1053410547
1053510548
#ifdef __cplusplus
1053610549
} /* End of the 'extern "C"' block */
1053710550
#endif
1053810551
#endif /* SQLITE3_H */
1053910552
--- 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.41.0"
150 #define SQLITE_VERSION_NUMBER 3041000
151 #define SQLITE_SOURCE_ID "2023-02-03 14:57:40 c045d76b908a8c90d22511df7884e78d452b250db9ba70d4cb0935048a3c3ac4"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -9817,11 +9817,11 @@
9817 ** ^(Use these routines to access all values on the right-hand side
9818 ** of the IN constraint using code like the following:
9819 **
9820 ** <blockquote><pre>
9821 ** &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal);
9822 ** &nbsp; rc==SQLITE_OK && pVal
9823 ** &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal)
9824 ** &nbsp; ){
9825 ** &nbsp; // do something with pVal
9826 ** &nbsp; }
9827 ** &nbsp; if( rc!=SQLITE_OK ){
@@ -10529,10 +10529,23 @@
10529 ** builds on processors without floating point support.
10530 */
10531 #ifdef SQLITE_OMIT_FLOATING_POINT
10532 # undef double
10533 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
10534
10535 #ifdef __cplusplus
10536 } /* End of the 'extern "C"' block */
10537 #endif
10538 #endif /* SQLITE3_H */
10539
--- 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.41.0"
150 #define SQLITE_VERSION_NUMBER 3041000
151 #define SQLITE_SOURCE_ID "2023-02-08 14:49:52 6b41ba2e996ab7b9c3943ab93a19748db5cf37792f5d59d20eec301085282355"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -9817,11 +9817,11 @@
9817 ** ^(Use these routines to access all values on the right-hand side
9818 ** of the IN constraint using code like the following:
9819 **
9820 ** <blockquote><pre>
9821 ** &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal);
9822 ** &nbsp; rc==SQLITE_OK && pVal;
9823 ** &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal)
9824 ** &nbsp; ){
9825 ** &nbsp; // do something with pVal
9826 ** &nbsp; }
9827 ** &nbsp; if( rc!=SQLITE_OK ){
@@ -10529,10 +10529,23 @@
10529 ** builds on processors without floating point support.
10530 */
10531 #ifdef SQLITE_OMIT_FLOATING_POINT
10532 # undef double
10533 #endif
10534
10535 #if defined(__wasi__)
10536 # undef SQLITE_WASI
10537 # define SQLITE_WASI 1
10538 # undef SQLITE_OMIT_WAL
10539 # define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */
10540 # ifndef SQLITE_OMIT_LOAD_EXTENSION
10541 # define SQLITE_OMIT_LOAD_EXTENSION
10542 # endif
10543 # ifndef SQLITE_THREADSAFE
10544 # define SQLITE_THREADSAFE 0
10545 # endif
10546 #endif
10547
10548 #ifdef __cplusplus
10549 } /* End of the 'extern "C"' block */
10550 #endif
10551 #endif /* SQLITE3_H */
10552

Keyboard Shortcuts

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