Fossil SCM

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

drh 2023-04-10 20:23 trunk
Commit 2eb2077c1bbd609c79ceabadc7c5bd618ae4cc3f18e92641181e6d7f9ae12797
+13 -6
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -3172,10 +3172,11 @@
31723172
#ifndef U8_TYPEDEF
31733173
/* typedef unsigned char u8; */
31743174
#define U8_TYPEDEF
31753175
#endif
31763176
3177
+/* Decoding table, ASCII (7-bit) value to base 64 digit value or other */
31773178
static const u8 b64DigitValues[128] = {
31783179
/* HT LF VT FF CR */
31793180
ND,ND,ND,ND, ND,ND,ND,ND, ND,WS,WS,WS, WS,WS,ND,ND,
31803181
/* US */
31813182
ND,ND,ND,ND, ND,ND,ND,ND, ND,ND,ND,ND, ND,ND,ND,ND,
@@ -8772,11 +8773,14 @@
87728773
}else{
87738774
/* Figure out if this is a directory or a zero-sized file. Consider
87748775
** it to be a directory either if the mode suggests so, or if
87758776
** the final character in the name is '/'. */
87768777
u32 mode = pCDS->iExternalAttr >> 16;
8777
- if( !(mode & S_IFDIR) && pCDS->zFile[pCDS->nFile-1]!='/' ){
8778
+ if( !(mode & S_IFDIR)
8779
+ && pCDS->nFile>=1
8780
+ && pCDS->zFile[pCDS->nFile-1]!='/'
8781
+ ){
87788782
sqlite3_result_blob(ctx, "", 0, SQLITE_STATIC);
87798783
}
87808784
}
87818785
}
87828786
break;
@@ -12506,11 +12510,10 @@
1250612510
#endif
1250712511
1250812512
#endif /* ifndef _SQLITE_RECOVER_H */
1250912513
1251012514
/************************* End ../ext/recover/sqlite3recover.h ********************/
12511
-# ifndef SQLITE_HAVE_SQLITE3R
1251212515
/************************* Begin ../ext/recover/dbdata.c ******************/
1251312516
/*
1251412517
** 2019-04-17
1251512518
**
1251612519
** The author disclaims copyright to this source code. In place of
@@ -12677,10 +12680,11 @@
1267712680
int rc = sqlite3_declare_vtab(db, pAux ? DBPTR_SCHEMA : DBDATA_SCHEMA);
1267812681
1267912682
(void)argc;
1268012683
(void)argv;
1268112684
(void)pzErr;
12685
+ sqlite3_vtab_config(db, SQLITE_VTAB_USES_ALL_SCHEMAS);
1268212686
if( rc==SQLITE_OK ){
1268312687
pTab = (DbdataTable*)sqlite3_malloc64(sizeof(DbdataTable));
1268412688
if( pTab==0 ){
1268512689
rc = SQLITE_NOMEM;
1268612690
}else{
@@ -16336,11 +16340,10 @@
1633616340
}
1633716341
1633816342
#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
1633916343
1634016344
/************************* End ../ext/recover/sqlite3recover.c ********************/
16341
-# endif
1634216345
#endif
1634316346
#ifdef SQLITE_SHELL_EXTSRC
1634416347
# include SHELL_STRINGIFY(SQLITE_SHELL_EXTSRC)
1634516348
#endif
1634616349
@@ -17926,11 +17929,11 @@
1792617929
char *zMsg;
1792717930
int i;
1792817931
if( db==0
1792917932
|| zSql==0
1793017933
|| (iOffset = sqlite3_error_offset(db))<0
17931
- || iOffset>=strlen(zSql)
17934
+ || iOffset>=(int)strlen(zSql)
1793217935
){
1793317936
return sqlite3_mprintf("");
1793417937
}
1793517938
while( iOffset>50 ){
1793617939
iOffset--;
@@ -17938,11 +17941,11 @@
1793817941
while( (zSql[0]&0xc0)==0x80 ){ zSql++; iOffset--; }
1793917942
}
1794017943
len = strlen(zSql);
1794117944
if( len>78 ){
1794217945
len = 78;
17943
- while( (zSql[len]&0xc0)==0x80 ) len--;
17946
+ while( len>0 && (zSql[len]&0xc0)==0x80 ) len--;
1794417947
}
1794517948
zCode = sqlite3_mprintf("%.*s", len, zSql);
1794617949
shell_check_oom(zCode);
1794717950
for(i=0; zCode[i]; i++){ if( IsSpace(zSql[i]) ) zCode[i] = ' '; }
1794817951
if( iOffset<25 ){
@@ -20353,10 +20356,13 @@
2035320356
sqlite3_base64_init(p->db, 0, 0);
2035420357
sqlite3_base85_init(p->db, 0, 0);
2035520358
sqlite3_regexp_init(p->db, 0, 0);
2035620359
sqlite3_ieee_init(p->db, 0, 0);
2035720360
sqlite3_series_init(p->db, 0, 0);
20361
+#if SQLITE_SHELL_HAVE_RECOVER
20362
+ sqlite3_dbdata_init(p->db, 0, 0);
20363
+#endif
2035820364
#ifndef SQLITE_SHELL_FIDDLE
2035920365
sqlite3_fileio_init(p->db, 0, 0);
2036020366
sqlite3_completion_init(p->db, 0, 0);
2036120367
#endif
2036220368
#ifdef SQLITE_HAVE_ZLIB
@@ -21168,11 +21174,11 @@
2116821174
}
2116921175
sqlite3_finalize(pStmt);
2117021176
return res;
2117121177
}
2117221178
21173
-#if defined(SQLITE_SHELL_HAVE_RECOVER)
21179
+#if SQLITE_SHELL_HAVE_RECOVER
2117421180
/*
2117521181
** Convert a 2-byte or 4-byte big-endian integer into a native integer
2117621182
*/
2117721183
static unsigned int get2byteInt(unsigned char *a){
2117821184
return (a[0]<<8) + a[1];
@@ -24798,10 +24804,11 @@
2479824804
if( cli_strcmp(azArg[1], "est")==0 ){
2479924805
p->scanstatsOn = 2;
2480024806
}else{
2480124807
p->scanstatsOn = (u8)booleanValue(azArg[1]);
2480224808
}
24809
+ open_db(p, 0);
2480324810
sqlite3_db_config(
2480424811
p->db, SQLITE_DBCONFIG_STMT_SCANSTATUS, p->scanstatsOn, (int*)0
2480524812
);
2480624813
#ifndef SQLITE_ENABLE_STMT_SCANSTATUS
2480724814
raw_printf(stderr, "Warning: .scanstats not available in this build.\n");
2480824815
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -3172,10 +3172,11 @@
3172 #ifndef U8_TYPEDEF
3173 /* typedef unsigned char u8; */
3174 #define U8_TYPEDEF
3175 #endif
3176
 
3177 static const u8 b64DigitValues[128] = {
3178 /* HT LF VT FF CR */
3179 ND,ND,ND,ND, ND,ND,ND,ND, ND,WS,WS,WS, WS,WS,ND,ND,
3180 /* US */
3181 ND,ND,ND,ND, ND,ND,ND,ND, ND,ND,ND,ND, ND,ND,ND,ND,
@@ -8772,11 +8773,14 @@
8772 }else{
8773 /* Figure out if this is a directory or a zero-sized file. Consider
8774 ** it to be a directory either if the mode suggests so, or if
8775 ** the final character in the name is '/'. */
8776 u32 mode = pCDS->iExternalAttr >> 16;
8777 if( !(mode & S_IFDIR) && pCDS->zFile[pCDS->nFile-1]!='/' ){
 
 
 
8778 sqlite3_result_blob(ctx, "", 0, SQLITE_STATIC);
8779 }
8780 }
8781 }
8782 break;
@@ -12506,11 +12510,10 @@
12506 #endif
12507
12508 #endif /* ifndef _SQLITE_RECOVER_H */
12509
12510 /************************* End ../ext/recover/sqlite3recover.h ********************/
12511 # ifndef SQLITE_HAVE_SQLITE3R
12512 /************************* Begin ../ext/recover/dbdata.c ******************/
12513 /*
12514 ** 2019-04-17
12515 **
12516 ** The author disclaims copyright to this source code. In place of
@@ -12677,10 +12680,11 @@
12677 int rc = sqlite3_declare_vtab(db, pAux ? DBPTR_SCHEMA : DBDATA_SCHEMA);
12678
12679 (void)argc;
12680 (void)argv;
12681 (void)pzErr;
 
12682 if( rc==SQLITE_OK ){
12683 pTab = (DbdataTable*)sqlite3_malloc64(sizeof(DbdataTable));
12684 if( pTab==0 ){
12685 rc = SQLITE_NOMEM;
12686 }else{
@@ -16336,11 +16340,10 @@
16336 }
16337
16338 #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
16339
16340 /************************* End ../ext/recover/sqlite3recover.c ********************/
16341 # endif
16342 #endif
16343 #ifdef SQLITE_SHELL_EXTSRC
16344 # include SHELL_STRINGIFY(SQLITE_SHELL_EXTSRC)
16345 #endif
16346
@@ -17926,11 +17929,11 @@
17926 char *zMsg;
17927 int i;
17928 if( db==0
17929 || zSql==0
17930 || (iOffset = sqlite3_error_offset(db))<0
17931 || iOffset>=strlen(zSql)
17932 ){
17933 return sqlite3_mprintf("");
17934 }
17935 while( iOffset>50 ){
17936 iOffset--;
@@ -17938,11 +17941,11 @@
17938 while( (zSql[0]&0xc0)==0x80 ){ zSql++; iOffset--; }
17939 }
17940 len = strlen(zSql);
17941 if( len>78 ){
17942 len = 78;
17943 while( (zSql[len]&0xc0)==0x80 ) len--;
17944 }
17945 zCode = sqlite3_mprintf("%.*s", len, zSql);
17946 shell_check_oom(zCode);
17947 for(i=0; zCode[i]; i++){ if( IsSpace(zSql[i]) ) zCode[i] = ' '; }
17948 if( iOffset<25 ){
@@ -20353,10 +20356,13 @@
20353 sqlite3_base64_init(p->db, 0, 0);
20354 sqlite3_base85_init(p->db, 0, 0);
20355 sqlite3_regexp_init(p->db, 0, 0);
20356 sqlite3_ieee_init(p->db, 0, 0);
20357 sqlite3_series_init(p->db, 0, 0);
 
 
 
20358 #ifndef SQLITE_SHELL_FIDDLE
20359 sqlite3_fileio_init(p->db, 0, 0);
20360 sqlite3_completion_init(p->db, 0, 0);
20361 #endif
20362 #ifdef SQLITE_HAVE_ZLIB
@@ -21168,11 +21174,11 @@
21168 }
21169 sqlite3_finalize(pStmt);
21170 return res;
21171 }
21172
21173 #if defined(SQLITE_SHELL_HAVE_RECOVER)
21174 /*
21175 ** Convert a 2-byte or 4-byte big-endian integer into a native integer
21176 */
21177 static unsigned int get2byteInt(unsigned char *a){
21178 return (a[0]<<8) + a[1];
@@ -24798,10 +24804,11 @@
24798 if( cli_strcmp(azArg[1], "est")==0 ){
24799 p->scanstatsOn = 2;
24800 }else{
24801 p->scanstatsOn = (u8)booleanValue(azArg[1]);
24802 }
 
24803 sqlite3_db_config(
24804 p->db, SQLITE_DBCONFIG_STMT_SCANSTATUS, p->scanstatsOn, (int*)0
24805 );
24806 #ifndef SQLITE_ENABLE_STMT_SCANSTATUS
24807 raw_printf(stderr, "Warning: .scanstats not available in this build.\n");
24808
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -3172,10 +3172,11 @@
3172 #ifndef U8_TYPEDEF
3173 /* typedef unsigned char u8; */
3174 #define U8_TYPEDEF
3175 #endif
3176
3177 /* Decoding table, ASCII (7-bit) value to base 64 digit value or other */
3178 static const u8 b64DigitValues[128] = {
3179 /* HT LF VT FF CR */
3180 ND,ND,ND,ND, ND,ND,ND,ND, ND,WS,WS,WS, WS,WS,ND,ND,
3181 /* US */
3182 ND,ND,ND,ND, ND,ND,ND,ND, ND,ND,ND,ND, ND,ND,ND,ND,
@@ -8772,11 +8773,14 @@
8773 }else{
8774 /* Figure out if this is a directory or a zero-sized file. Consider
8775 ** it to be a directory either if the mode suggests so, or if
8776 ** the final character in the name is '/'. */
8777 u32 mode = pCDS->iExternalAttr >> 16;
8778 if( !(mode & S_IFDIR)
8779 && pCDS->nFile>=1
8780 && pCDS->zFile[pCDS->nFile-1]!='/'
8781 ){
8782 sqlite3_result_blob(ctx, "", 0, SQLITE_STATIC);
8783 }
8784 }
8785 }
8786 break;
@@ -12506,11 +12510,10 @@
12510 #endif
12511
12512 #endif /* ifndef _SQLITE_RECOVER_H */
12513
12514 /************************* End ../ext/recover/sqlite3recover.h ********************/
 
12515 /************************* Begin ../ext/recover/dbdata.c ******************/
12516 /*
12517 ** 2019-04-17
12518 **
12519 ** The author disclaims copyright to this source code. In place of
@@ -12677,10 +12680,11 @@
12680 int rc = sqlite3_declare_vtab(db, pAux ? DBPTR_SCHEMA : DBDATA_SCHEMA);
12681
12682 (void)argc;
12683 (void)argv;
12684 (void)pzErr;
12685 sqlite3_vtab_config(db, SQLITE_VTAB_USES_ALL_SCHEMAS);
12686 if( rc==SQLITE_OK ){
12687 pTab = (DbdataTable*)sqlite3_malloc64(sizeof(DbdataTable));
12688 if( pTab==0 ){
12689 rc = SQLITE_NOMEM;
12690 }else{
@@ -16336,11 +16340,10 @@
16340 }
16341
16342 #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
16343
16344 /************************* End ../ext/recover/sqlite3recover.c ********************/
 
16345 #endif
16346 #ifdef SQLITE_SHELL_EXTSRC
16347 # include SHELL_STRINGIFY(SQLITE_SHELL_EXTSRC)
16348 #endif
16349
@@ -17926,11 +17929,11 @@
17929 char *zMsg;
17930 int i;
17931 if( db==0
17932 || zSql==0
17933 || (iOffset = sqlite3_error_offset(db))<0
17934 || iOffset>=(int)strlen(zSql)
17935 ){
17936 return sqlite3_mprintf("");
17937 }
17938 while( iOffset>50 ){
17939 iOffset--;
@@ -17938,11 +17941,11 @@
17941 while( (zSql[0]&0xc0)==0x80 ){ zSql++; iOffset--; }
17942 }
17943 len = strlen(zSql);
17944 if( len>78 ){
17945 len = 78;
17946 while( len>0 && (zSql[len]&0xc0)==0x80 ) len--;
17947 }
17948 zCode = sqlite3_mprintf("%.*s", len, zSql);
17949 shell_check_oom(zCode);
17950 for(i=0; zCode[i]; i++){ if( IsSpace(zSql[i]) ) zCode[i] = ' '; }
17951 if( iOffset<25 ){
@@ -20353,10 +20356,13 @@
20356 sqlite3_base64_init(p->db, 0, 0);
20357 sqlite3_base85_init(p->db, 0, 0);
20358 sqlite3_regexp_init(p->db, 0, 0);
20359 sqlite3_ieee_init(p->db, 0, 0);
20360 sqlite3_series_init(p->db, 0, 0);
20361 #if SQLITE_SHELL_HAVE_RECOVER
20362 sqlite3_dbdata_init(p->db, 0, 0);
20363 #endif
20364 #ifndef SQLITE_SHELL_FIDDLE
20365 sqlite3_fileio_init(p->db, 0, 0);
20366 sqlite3_completion_init(p->db, 0, 0);
20367 #endif
20368 #ifdef SQLITE_HAVE_ZLIB
@@ -21168,11 +21174,11 @@
21174 }
21175 sqlite3_finalize(pStmt);
21176 return res;
21177 }
21178
21179 #if SQLITE_SHELL_HAVE_RECOVER
21180 /*
21181 ** Convert a 2-byte or 4-byte big-endian integer into a native integer
21182 */
21183 static unsigned int get2byteInt(unsigned char *a){
21184 return (a[0]<<8) + a[1];
@@ -24798,10 +24804,11 @@
24804 if( cli_strcmp(azArg[1], "est")==0 ){
24805 p->scanstatsOn = 2;
24806 }else{
24807 p->scanstatsOn = (u8)booleanValue(azArg[1]);
24808 }
24809 open_db(p, 0);
24810 sqlite3_db_config(
24811 p->db, SQLITE_DBCONFIG_STMT_SCANSTATUS, p->scanstatsOn, (int*)0
24812 );
24813 #ifndef SQLITE_ENABLE_STMT_SCANSTATUS
24814 raw_printf(stderr, "Warning: .scanstats not available in this build.\n");
24815
+466 -242
--- 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.42.0"
456456
#define SQLITE_VERSION_NUMBER 3042000
457
-#define SQLITE_SOURCE_ID "2023-04-01 15:51:21 a4fb2864fe01cce9694242a0750623ca47fcecd68f74c4239d3eb5fbf978770a"
457
+#define SQLITE_SOURCE_ID "2023-04-10 18:44:00 4c5a3c5fb351cc1c2ce16c33314ce19c53531f09263f87456283d9d756002f9d"
458458
459459
/*
460460
** CAPI3REF: Run-Time Library Version Numbers
461461
** KEYWORDS: sqlite3_version sqlite3_sourceid
462462
**
@@ -2800,11 +2800,11 @@
28002800
#define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
28012801
#define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
28022802
#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
28032803
#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
28042804
#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
2805
-#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1080 /* int int* */
2805
+#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
28062806
#define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
28072807
#define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
28082808
28092809
/*
28102810
** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -9910,22 +9910,32 @@
99109910
** </dd>
99119911
**
99129912
** [[SQLITE_VTAB_INNOCUOUS]]<dt>SQLITE_VTAB_INNOCUOUS</dt>
99139913
** <dd>Calls of the form
99149914
** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the
9915
-** the [xConnect] or [xCreate] methods of a [virtual table] implmentation
9915
+** the [xConnect] or [xCreate] methods of a [virtual table] implementation
99169916
** identify that virtual table as being safe to use from within triggers
99179917
** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the
99189918
** virtual table can do no serious harm even if it is controlled by a
99199919
** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS
99209920
** flag unless absolutely necessary.
99219921
** </dd>
9922
+**
9923
+** [[SQLITE_VTAB_USES_ALL_SCHEMAS]]<dt>SQLITE_VTAB_USES_ALL_SCHEMAS</dt>
9924
+** <dd>Calls of the form
9925
+** [sqlite3_vtab_config](db,SQLITE_VTAB_USES_ALL_SCHEMA) from within the
9926
+** the [xConnect] or [xCreate] methods of a [virtual table] implementation
9927
+** instruct the query planner to begin at least a read transaction on
9928
+** all schemas ("main", "temp", and any ATTACH-ed databases) whenever the
9929
+** virtual table is used.
9930
+** </dd>
99229931
** </dl>
99239932
*/
99249933
#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1
99259934
#define SQLITE_VTAB_INNOCUOUS 2
99269935
#define SQLITE_VTAB_DIRECTONLY 3
9936
+#define SQLITE_VTAB_USES_ALL_SCHEMAS 4
99279937
99289938
/*
99299939
** CAPI3REF: Determine The Virtual Table Conflict Policy
99309940
**
99319941
** This function may only be called from within a call to the [xUpdate] method
@@ -13629,19 +13639,26 @@
1362913639
# define SQLITE_INT_TO_PTR(X) ((void*)(X))
1363013640
# define SQLITE_PTR_TO_INT(X) ((int)(X))
1363113641
#endif
1363213642
1363313643
/*
13634
-** A macro to hint to the compiler that a function should not be
13644
+** Macros to hint to the compiler that a function should or should not be
1363513645
** inlined.
1363613646
*/
1363713647
#if defined(__GNUC__)
1363813648
# define SQLITE_NOINLINE __attribute__((noinline))
13649
+# define SQLITE_INLINE __attribute__((always_inline)) inline
1363913650
#elif defined(_MSC_VER) && _MSC_VER>=1310
1364013651
# define SQLITE_NOINLINE __declspec(noinline)
13652
+# define SQLITE_INLINE __forceinline
1364113653
#else
1364213654
# define SQLITE_NOINLINE
13655
+# define SQLITE_INLINE
13656
+#endif
13657
+#if defined(SQLITE_COVERAGE_TEST)
13658
+# undef SQLITE_INLINE
13659
+# define SQLITE_INLINE
1364313660
#endif
1364413661
1364513662
/*
1364613663
** Make sure that the compiler intrinsics we desire are enabled when
1364713664
** compiling with an appropriate version of MSVC unless prevented by
@@ -16597,10 +16614,14 @@
1659716614
#endif
1659816615
1659916616
#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
1660016617
SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE*, int, VdbeOp*);
1660116618
#endif
16619
+
16620
+#if defined(SQLITE_ENABLE_CURSOR_HINTS) && defined(SQLITE_DEBUG)
16621
+SQLITE_PRIVATE int sqlite3CursorRangeHintExprCheck(Walker *pWalker, Expr *pExpr);
16622
+#endif
1660216623
1660316624
#endif /* SQLITE_VDBE_H */
1660416625
1660516626
/************** End of vdbe.h ************************************************/
1660616627
/************** Continuing where we left off in sqliteInt.h ******************/
@@ -17862,10 +17883,11 @@
1786217883
sqlite3 *db; /* Database connection associated with this table */
1786317884
Module *pMod; /* Pointer to module implementation */
1786417885
sqlite3_vtab *pVtab; /* Pointer to vtab instance */
1786517886
int nRef; /* Number of pointers to this structure */
1786617887
u8 bConstraint; /* True if constraints are supported */
17888
+ u8 bAllSchemas; /* True if might use any attached schema */
1786717889
u8 eVtabRisk; /* Riskiness of allowing hacker access */
1786817890
int iSavepoint; /* Depth of the SAVEPOINT stack */
1786917891
VTable *pNext; /* Next in linked list (see above) */
1787017892
};
1787117893
@@ -19728,10 +19750,11 @@
1972819750
struct RenameCtx *pRename; /* RENAME COLUMN context */
1972919751
struct Table *pTab; /* Table of generated column */
1973019752
struct CoveringIndexCheck *pCovIdxCk; /* Check for covering index */
1973119753
SrcItem *pSrcItem; /* A single FROM clause item */
1973219754
DbFixer *pFix; /* See sqlite3FixSelect() */
19755
+ Mem *aMem; /* See sqlite3BtreeCursorHint() */
1973319756
} u;
1973419757
};
1973519758
1973619759
/*
1973719760
** The following structure contains information used by the sqliteFix...
@@ -20890,14 +20913,11 @@
2089020913
SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
2089120914
SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
2089220915
SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
2089320916
2089420917
SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
20895
-#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
20896
- && !defined(SQLITE_OMIT_VIRTUALTABLE)
20897
-SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(sqlite3_index_info*);
20898
-#endif
20918
+SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(Parse*);
2089920919
SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
2090020920
SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
2090120921
SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
2090220922
SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse*,sqlite3*);
2090320923
SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse*);
@@ -69500,12 +69520,29 @@
6950069520
** and number of the varargs parameters) is determined by the eHintType
6950169521
** parameter. See the definitions of the BTREE_HINT_* macros for details.
6950269522
*/
6950369523
SQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor *pCur, int eHintType, ...){
6950469524
/* Used only by system that substitute their own storage engine */
69525
+#ifdef SQLITE_DEBUG
69526
+ if( ALWAYS(eHintType==BTREE_HINT_RANGE) ){
69527
+ va_list ap;
69528
+ Expr *pExpr;
69529
+ Walker w;
69530
+ memset(&w, 0, sizeof(w));
69531
+ w.xExprCallback = sqlite3CursorRangeHintExprCheck;
69532
+ va_start(ap, eHintType);
69533
+ pExpr = va_arg(ap, Expr*);
69534
+ w.u.aMem = va_arg(ap, Mem*);
69535
+ va_end(ap);
69536
+ assert( pExpr!=0 );
69537
+ assert( w.u.aMem!=0 );
69538
+ sqlite3WalkExpr(&w, pExpr);
69539
+ }
69540
+#endif /* SQLITE_DEBUG */
6950569541
}
69506
-#endif
69542
+#endif /* SQLITE_ENABLE_CURSOR_HINTS */
69543
+
6950769544
6950869545
/*
6950969546
** Provide flag hints to the cursor.
6951069547
*/
6951169548
SQLITE_PRIVATE void sqlite3BtreeCursorHintFlags(BtCursor *pCur, unsigned x){
@@ -70300,11 +70337,11 @@
7030070337
** all the space together, however. This routine will avoid using
7030170338
** the first two bytes past the cell pointer area since presumably this
7030270339
** allocation is being made in order to insert a new cell, so we will
7030370340
** also end up needing a new cell pointer.
7030470341
*/
70305
-static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
70342
+static SQLITE_INLINE int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
7030670343
const int hdr = pPage->hdrOffset; /* Local cache of pPage->hdrOffset */
7030770344
u8 * const data = pPage->aData; /* Local cache of pPage->aData */
7030870345
int top; /* First byte of cell content area */
7030970346
int rc = SQLITE_OK; /* Integer return code */
7031070347
u8 *pTmp; /* Temp ptr into data[] */
@@ -70326,17 +70363,18 @@
7032670363
** then the cell content offset of an empty page wants to be 65536.
7032770364
** However, that integer is too large to be stored in a 2-byte unsigned
7032870365
** integer, so a value of 0 is used in its place. */
7032970366
pTmp = &data[hdr+5];
7033070367
top = get2byte(pTmp);
70331
- assert( top<=(int)pPage->pBt->usableSize ); /* by btreeComputeFreeSpace() */
7033270368
if( gap>top ){
7033370369
if( top==0 && pPage->pBt->usableSize==65536 ){
7033470370
top = 65536;
7033570371
}else{
7033670372
return SQLITE_CORRUPT_PAGE(pPage);
7033770373
}
70374
+ }else if( top>(int)pPage->pBt->usableSize ){
70375
+ return SQLITE_CORRUPT_PAGE(pPage);
7033870376
}
7033970377
7034070378
/* If there is enough space between gap and top for one more cell pointer,
7034170379
** and if the freelist is not empty, then search the
7034270380
** freelist looking for a slot big enough to satisfy the request.
@@ -70415,11 +70453,11 @@
7041570453
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
7041670454
assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize );
7041770455
assert( CORRUPT_DB || iEnd <= pPage->pBt->usableSize );
7041870456
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
7041970457
assert( iSize>=4 ); /* Minimum cell size is 4 */
70420
- assert( iStart<=pPage->pBt->usableSize-4 );
70458
+ assert( CORRUPT_DB || iStart<=pPage->pBt->usableSize-4 );
7042170459
7042270460
/* The list of freeblocks must be in ascending order. Find the
7042370461
** spot on the list where iStart should be inserted.
7042470462
*/
7042570463
hdr = pPage->hdrOffset;
@@ -70472,10 +70510,15 @@
7047270510
if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_PAGE(pPage);
7047370511
data[hdr+7] -= nFrag;
7047470512
}
7047570513
pTmp = &data[hdr+5];
7047670514
x = get2byte(pTmp);
70515
+ if( pPage->pBt->btsFlags & BTS_FAST_SECURE ){
70516
+ /* Overwrite deleted information with zeros when the secure_delete
70517
+ ** option is enabled */
70518
+ memset(&data[iStart], 0, iSize);
70519
+ }
7047770520
if( iStart<=x ){
7047870521
/* The new freeblock is at the beginning of the cell content area,
7047970522
** so just extend the cell content area rather than create another
7048070523
** freelist entry */
7048170524
if( iStart<x ) return SQLITE_CORRUPT_PAGE(pPage);
@@ -70483,18 +70526,13 @@
7048370526
put2byte(&data[hdr+1], iFreeBlk);
7048470527
put2byte(&data[hdr+5], iEnd);
7048570528
}else{
7048670529
/* Insert the new freeblock into the freelist */
7048770530
put2byte(&data[iPtr], iStart);
70488
- }
70489
- if( pPage->pBt->btsFlags & BTS_FAST_SECURE ){
70490
- /* Overwrite deleted information with zeros when the secure_delete
70491
- ** option is enabled */
70492
- memset(&data[iStart], 0, iSize);
70493
- }
70494
- put2byte(&data[iStart], iFreeBlk);
70495
- put2byte(&data[iStart+2], iSize);
70531
+ put2byte(&data[iStart], iFreeBlk);
70532
+ put2byte(&data[iStart+2], iSize);
70533
+ }
7049670534
pPage->nFree += iOrigSize;
7049770535
return SQLITE_OK;
7049870536
}
7049970537
7050070538
/*
@@ -75649,10 +75687,18 @@
7564975687
** pTemp is not null. Regardless of pTemp, allocate a new entry
7565075688
** in pPage->apOvfl[] and make it point to the cell content (either
7565175689
** in pTemp or the original pCell) and also record its index.
7565275690
** Allocating a new entry in pPage->aCell[] implies that
7565375691
** pPage->nOverflow is incremented.
75692
+**
75693
+** The insertCellFast() routine below works exactly the same as
75694
+** insertCell() except that it lacks the pTemp and iChild parameters
75695
+** which are assumed zero. Other than that, the two routines are the
75696
+** same.
75697
+**
75698
+** Fixes or enhancements to this routine should be reflected in
75699
+** insertCellFast()!
7565475700
*/
7565575701
static int insertCell(
7565675702
MemPage *pPage, /* Page into which we are copying */
7565775703
int i, /* New cell becomes the i-th cell of the page */
7565875704
u8 *pCell, /* Content of the new cell */
@@ -75671,18 +75717,107 @@
7567175717
assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );
7567275718
assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );
7567375719
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
7567475720
assert( sz==pPage->xCellSize(pPage, pCell) || CORRUPT_DB );
7567575721
assert( pPage->nFree>=0 );
75722
+ assert( iChild>0 );
7567675723
if( pPage->nOverflow || sz+2>pPage->nFree ){
7567775724
if( pTemp ){
7567875725
memcpy(pTemp, pCell, sz);
7567975726
pCell = pTemp;
7568075727
}
75681
- if( iChild ){
75682
- put4byte(pCell, iChild);
75728
+ put4byte(pCell, iChild);
75729
+ j = pPage->nOverflow++;
75730
+ /* Comparison against ArraySize-1 since we hold back one extra slot
75731
+ ** as a contingency. In other words, never need more than 3 overflow
75732
+ ** slots but 4 are allocated, just to be safe. */
75733
+ assert( j < ArraySize(pPage->apOvfl)-1 );
75734
+ pPage->apOvfl[j] = pCell;
75735
+ pPage->aiOvfl[j] = (u16)i;
75736
+
75737
+ /* When multiple overflows occur, they are always sequential and in
75738
+ ** sorted order. This invariants arise because multiple overflows can
75739
+ ** only occur when inserting divider cells into the parent page during
75740
+ ** balancing, and the dividers are adjacent and sorted.
75741
+ */
75742
+ assert( j==0 || pPage->aiOvfl[j-1]<(u16)i ); /* Overflows in sorted order */
75743
+ assert( j==0 || i==pPage->aiOvfl[j-1]+1 ); /* Overflows are sequential */
75744
+ }else{
75745
+ int rc = sqlite3PagerWrite(pPage->pDbPage);
75746
+ if( NEVER(rc!=SQLITE_OK) ){
75747
+ return rc;
7568375748
}
75749
+ assert( sqlite3PagerIswriteable(pPage->pDbPage) );
75750
+ data = pPage->aData;
75751
+ assert( &data[pPage->cellOffset]==pPage->aCellIdx );
75752
+ rc = allocateSpace(pPage, sz, &idx);
75753
+ if( rc ){ return rc; }
75754
+ /* The allocateSpace() routine guarantees the following properties
75755
+ ** if it returns successfully */
75756
+ assert( idx >= 0 );
75757
+ assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );
75758
+ assert( idx+sz <= (int)pPage->pBt->usableSize );
75759
+ pPage->nFree -= (u16)(2 + sz);
75760
+ /* In a corrupt database where an entry in the cell index section of
75761
+ ** a btree page has a value of 3 or less, the pCell value might point
75762
+ ** as many as 4 bytes in front of the start of the aData buffer for
75763
+ ** the source page. Make sure this does not cause problems by not
75764
+ ** reading the first 4 bytes */
75765
+ memcpy(&data[idx+4], pCell+4, sz-4);
75766
+ put4byte(&data[idx], iChild);
75767
+ pIns = pPage->aCellIdx + i*2;
75768
+ memmove(pIns+2, pIns, 2*(pPage->nCell - i));
75769
+ put2byte(pIns, idx);
75770
+ pPage->nCell++;
75771
+ /* increment the cell count */
75772
+ if( (++data[pPage->hdrOffset+4])==0 ) data[pPage->hdrOffset+3]++;
75773
+ assert( get2byte(&data[pPage->hdrOffset+3])==pPage->nCell || CORRUPT_DB );
75774
+#ifndef SQLITE_OMIT_AUTOVACUUM
75775
+ if( pPage->pBt->autoVacuum ){
75776
+ int rc2 = SQLITE_OK;
75777
+ /* The cell may contain a pointer to an overflow page. If so, write
75778
+ ** the entry for the overflow page into the pointer map.
75779
+ */
75780
+ ptrmapPutOvflPtr(pPage, pPage, pCell, &rc2);
75781
+ if( rc2 ) return rc2;
75782
+ }
75783
+#endif
75784
+ }
75785
+ return SQLITE_OK;
75786
+}
75787
+
75788
+/*
75789
+** This variant of insertCell() assumes that the pTemp and iChild
75790
+** parameters are both zero. Use this variant in sqlite3BtreeInsert()
75791
+** for performance improvement, and also so that this variant is only
75792
+** called from that one place, and is thus inlined, and thus runs must
75793
+** faster.
75794
+**
75795
+** Fixes or enhancements to this routine should be reflected into
75796
+** the insertCell() routine.
75797
+*/
75798
+static int insertCellFast(
75799
+ MemPage *pPage, /* Page into which we are copying */
75800
+ int i, /* New cell becomes the i-th cell of the page */
75801
+ u8 *pCell, /* Content of the new cell */
75802
+ int sz /* Bytes of content in pCell */
75803
+){
75804
+ int idx = 0; /* Where to write new cell content in data[] */
75805
+ int j; /* Loop counter */
75806
+ u8 *data; /* The content of the whole page */
75807
+ u8 *pIns; /* The point in pPage->aCellIdx[] where no cell inserted */
75808
+
75809
+ assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );
75810
+ assert( MX_CELL(pPage->pBt)<=10921 );
75811
+ assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB );
75812
+ assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );
75813
+ assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );
75814
+ assert( sqlite3_mutex_held(pPage->pBt->mutex) );
75815
+ assert( sz==pPage->xCellSize(pPage, pCell) || CORRUPT_DB );
75816
+ assert( pPage->nFree>=0 );
75817
+ assert( pPage->nOverflow==0 );
75818
+ if( sz+2>pPage->nFree ){
7568475819
j = pPage->nOverflow++;
7568575820
/* Comparison against ArraySize-1 since we hold back one extra slot
7568675821
** as a contingency. In other words, never need more than 3 overflow
7568775822
** slots but 4 are allocated, just to be safe. */
7568875823
assert( j < ArraySize(pPage->apOvfl)-1 );
@@ -75710,21 +75845,11 @@
7571075845
** if it returns successfully */
7571175846
assert( idx >= 0 );
7571275847
assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );
7571375848
assert( idx+sz <= (int)pPage->pBt->usableSize );
7571475849
pPage->nFree -= (u16)(2 + sz);
75715
- if( iChild ){
75716
- /* In a corrupt database where an entry in the cell index section of
75717
- ** a btree page has a value of 3 or less, the pCell value might point
75718
- ** as many as 4 bytes in front of the start of the aData buffer for
75719
- ** the source page. Make sure this does not cause problems by not
75720
- ** reading the first 4 bytes */
75721
- memcpy(&data[idx+4], pCell+4, sz-4);
75722
- put4byte(&data[idx], iChild);
75723
- }else{
75724
- memcpy(&data[idx], pCell, sz);
75725
- }
75850
+ memcpy(&data[idx], pCell, sz);
7572675851
pIns = pPage->aCellIdx + i*2;
7572775852
memmove(pIns+2, pIns, 2*(pPage->nCell - i));
7572875853
put2byte(pIns, idx);
7572975854
pPage->nCell++;
7573075855
/* increment the cell count */
@@ -75905,11 +76030,11 @@
7590576030
int k; /* Current slot in pCArray->apEnd[] */
7590676031
u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */
7590776032
7590876033
assert( i<iEnd );
7590976034
j = get2byte(&aData[hdr+5]);
75910
- if( j>(u32)usableSize ){ j = 0; }
76035
+ if( NEVER(j>(u32)usableSize) ){ j = 0; }
7591176036
memcpy(&pTmp[j], &aData[j], usableSize - j);
7591276037
7591376038
for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
7591476039
pSrcEnd = pCArray->apEnd[k];
7591576040
@@ -76049,46 +76174,54 @@
7604976174
){
7605076175
u8 * const aData = pPg->aData;
7605176176
u8 * const pEnd = &aData[pPg->pBt->usableSize];
7605276177
u8 * const pStart = &aData[pPg->hdrOffset + 8 + pPg->childPtrSize];
7605376178
int nRet = 0;
76054
- int i;
76179
+ int i, j;
7605576180
int iEnd = iFirst + nCell;
76056
- u8 *pFree = 0; /* \__ Parameters for pending call to */
76057
- int szFree = 0; /* / freeSpace() */
76181
+ int nFree = 0;
76182
+ int aOfst[10];
76183
+ int aAfter[10];
7605876184
7605976185
for(i=iFirst; i<iEnd; i++){
7606076186
u8 *pCell = pCArray->apCell[i];
7606176187
if( SQLITE_WITHIN(pCell, pStart, pEnd) ){
7606276188
int sz;
76189
+ int iAfter;
76190
+ int iOfst;
7606376191
/* No need to use cachedCellSize() here. The sizes of all cells that
7606476192
** are to be freed have already been computing while deciding which
7606576193
** cells need freeing */
7606676194
sz = pCArray->szCell[i]; assert( sz>0 );
76067
- if( pFree!=(pCell + sz) ){
76068
- if( pFree ){
76069
- assert( pFree>aData && (pFree - aData)<65536 );
76070
- freeSpace(pPg, (u16)(pFree - aData), szFree);
76071
- }
76072
- pFree = pCell;
76073
- szFree = sz;
76074
- if( pFree+sz>pEnd ){
76075
- return 0;
76076
- }
76077
- }else{
76078
- /* The current cell is adjacent to and before the pFree cell.
76079
- ** Combine the two regions into one to reduce the number of calls
76080
- ** to freeSpace(). */
76081
- pFree = pCell;
76082
- szFree += sz;
76195
+ iOfst = (u16)(pCell - aData);
76196
+ iAfter = iOfst+sz;
76197
+ for(j=0; j<nFree; j++){
76198
+ if( aOfst[j]==iAfter ){
76199
+ aOfst[j] = iOfst;
76200
+ break;
76201
+ }else if( aAfter[j]==iOfst ){
76202
+ aAfter[j] = iAfter;
76203
+ break;
76204
+ }
76205
+ }
76206
+ if( j>=nFree ){
76207
+ if( nFree>=sizeof(aOfst)/sizeof(aOfst[0]) ){
76208
+ for(j=0; j<nFree; j++){
76209
+ freeSpace(pPg, aOfst[j], aAfter[j]-aOfst[j]);
76210
+ }
76211
+ nFree = 0;
76212
+ }
76213
+ aOfst[nFree] = iOfst;
76214
+ aAfter[nFree] = iAfter;
76215
+ if( &aData[iAfter]>pEnd ) return 0;
76216
+ nFree++;
7608376217
}
7608476218
nRet++;
7608576219
}
7608676220
}
76087
- if( pFree ){
76088
- assert( pFree>aData && (pFree - aData)<65536 );
76089
- freeSpace(pPg, (u16)(pFree - aData), szFree);
76221
+ for(j=0; j<nFree; j++){
76222
+ freeSpace(pPg, aOfst[j], aAfter[j]-aOfst[j]);
7609076223
}
7609176224
return nRet;
7609276225
}
7609376226
7609476227
/*
@@ -76139,11 +76272,11 @@
7613976272
nCell -= nTail;
7614076273
}
7614176274
7614276275
pData = &aData[get2byteNotZero(&aData[hdr+5])];
7614376276
if( pData<pBegin ) goto editpage_fail;
76144
- if( pData>pPg->aDataEnd ) goto editpage_fail;
76277
+ if( NEVER(pData>pPg->aDataEnd) ) goto editpage_fail;
7614576278
7614676279
/* Add cells to the start of the page */
7614776280
if( iNew<iOld ){
7614876281
int nAdd = MIN(nNew,iOld-iNew);
7614976282
assert( (iOld-iNew)<nNew || nCell==0 || CORRUPT_DB );
@@ -77865,11 +77998,11 @@
7786577998
idx = ++pCur->ix;
7786677999
pCur->curFlags &= ~BTCF_ValidNKey;
7786778000
}else{
7786878001
assert( pPage->leaf );
7786978002
}
77870
- rc = insertCell(pPage, idx, newCell, szNew, 0, 0);
78003
+ rc = insertCellFast(pPage, idx, newCell, szNew);
7787178004
assert( pPage->nOverflow==0 || rc==SQLITE_OK );
7787278005
assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );
7787378006
7787478007
/* If no error has occurred and pPage has an overflow cell, call balance()
7787578008
** to redistribute the cells within the tree. Since balance() may move
@@ -78088,10 +78221,13 @@
7808878221
return SQLITE_CORRUPT_BKPT;
7808978222
}
7809078223
pCell = findCell(pPage, iCellIdx);
7809178224
if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ){
7809278225
return SQLITE_CORRUPT_BKPT;
78226
+ }
78227
+ if( pCell<&pPage->aCellIdx[pPage->nCell] ){
78228
+ return SQLITE_CORRUPT_BKPT;
7809378229
}
7809478230
7809578231
/* If the BTREE_SAVEPOSITION bit is on, then the cursor position must
7809678232
** be preserved following this delete operation. If the current delete
7809778233
** will cause a b-tree rebalance, then this is done by saving the cursor
@@ -80991,11 +81127,11 @@
8099181127
return SQLITE_NOMEM_BKPT;
8099281128
}
8099381129
8099481130
vdbeMemRenderNum(nByte, pMem->z, pMem);
8099581131
assert( pMem->z!=0 );
80996
- assert( pMem->n==sqlite3Strlen30NN(pMem->z) );
81132
+ assert( pMem->n==(int)sqlite3Strlen30NN(pMem->z) );
8099781133
pMem->enc = SQLITE_UTF8;
8099881134
pMem->flags |= MEM_Str|MEM_Term;
8099981135
if( bForce ) pMem->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal);
8100081136
sqlite3VdbeChangeEncoding(pMem, enc);
8100181137
return SQLITE_OK;
@@ -82035,10 +82171,13 @@
8203582171
assert( ExprUseXList(p) );
8203682172
pList = p->x.pList;
8203782173
if( pList ) nVal = pList->nExpr;
8203882174
assert( !ExprHasProperty(p, EP_IntValue) );
8203982175
pFunc = sqlite3FindFunction(db, p->u.zToken, nVal, enc, 0);
82176
+#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
82177
+ if( pFunc==0 ) return SQLITE_OK;
82178
+#endif
8204082179
assert( pFunc );
8204182180
if( (pFunc->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0
8204282181
|| (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)
8204382182
){
8204482183
return SQLITE_OK;
@@ -85875,10 +86014,12 @@
8587586014
db->nDeferredCons = 0;
8587686015
db->nDeferredImmCons = 0;
8587786016
db->flags &= ~(u64)SQLITE_DeferFKs;
8587886017
sqlite3CommitInternalChanges(db);
8587986018
}
86019
+ }else if( p->rc==SQLITE_SCHEMA && db->nVdbeActive>1 ){
86020
+ p->nChange = 0;
8588086021
}else{
8588186022
sqlite3RollbackAll(db, SQLITE_OK);
8588286023
p->nChange = 0;
8588386024
}
8588486025
db->nStatement = 0;
@@ -87822,10 +87963,24 @@
8782287963
return 0;
8782387964
}
8782487965
return 1;
8782587966
}
8782687967
87968
+#if defined(SQLITE_ENABLE_CURSOR_HINTS) && defined(SQLITE_DEBUG)
87969
+/*
87970
+** This Walker callback is used to help verify that calls to
87971
+** sqlite3BtreeCursorHint() with opcode BTREE_HINT_RANGE have
87972
+** byte-code register values correctly initialized.
87973
+*/
87974
+SQLITE_PRIVATE int sqlite3CursorRangeHintExprCheck(Walker *pWalker, Expr *pExpr){
87975
+ if( pExpr->op==TK_REGISTER ){
87976
+ assert( (pWalker->u.aMem[pExpr->iTable].flags & MEM_Undefined)==0 );
87977
+ }
87978
+ return WRC_Continue;
87979
+}
87980
+#endif /* SQLITE_ENABLE_CURSOR_HINTS && SQLITE_DEBUG */
87981
+
8782787982
#ifndef SQLITE_OMIT_VIRTUALTABLE
8782887983
/*
8782987984
** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored
8783087985
** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored
8783187986
** in memory obtained from sqlite3DbMalloc).
@@ -88208,11 +88363,11 @@
8820888363
SQLITE_NULL, /* 0x1d (not possible) */
8820988364
SQLITE_INTEGER, /* 0x1e (not possible) */
8821088365
SQLITE_NULL, /* 0x1f (not possible) */
8821188366
SQLITE_FLOAT, /* 0x20 INTREAL */
8821288367
SQLITE_NULL, /* 0x21 (not possible) */
88213
- SQLITE_TEXT, /* 0x22 INTREAL + TEXT */
88368
+ SQLITE_FLOAT, /* 0x22 INTREAL + TEXT */
8821488369
SQLITE_NULL, /* 0x23 (not possible) */
8821588370
SQLITE_FLOAT, /* 0x24 (not possible) */
8821688371
SQLITE_NULL, /* 0x25 (not possible) */
8821788372
SQLITE_FLOAT, /* 0x26 (not possible) */
8821888373
SQLITE_NULL, /* 0x27 (not possible) */
@@ -106208,15 +106363,14 @@
106208106363
if( p->pLeft && (p->pLeft->flags & EP_Collate)!=0 ){
106209106364
p = p->pLeft;
106210106365
}else{
106211106366
Expr *pNext = p->pRight;
106212106367
/* The Expr.x union is never used at the same time as Expr.pRight */
106213
- assert( ExprUseXList(p) );
106214
- assert( p->x.pList==0 || p->pRight==0 );
106215
- if( p->x.pList!=0 && !db->mallocFailed ){
106368
+ assert( !ExprUseXList(p) || p->x.pList==0 || p->pRight==0 );
106369
+ if( ExprUseXList(p) && p->x.pList!=0 && !db->mallocFailed ){
106216106370
int i;
106217
- for(i=0; ALWAYS(i<p->x.pList->nExpr); i++){
106371
+ for(i=0; i<p->x.pList->nExpr; i++){
106218106372
if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){
106219106373
pNext = p->x.pList->a[i].pExpr;
106220106374
break;
106221106375
}
106222106376
}
@@ -108866,11 +109020,10 @@
108866109020
Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i);
108867109021
Expr *pRhs = pEList->a[i].pExpr;
108868109022
CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);
108869109023
int j;
108870109024
108871
- assert( pReq!=0 || pRhs->iColumn==XN_ROWID || pParse->nErr );
108872109025
for(j=0; j<nExpr; j++){
108873109026
if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;
108874109027
assert( pIdx->azColl[j] );
108875109028
if( pReq!=0 && sqlite3StrICmp(pReq->zName, pIdx->azColl[j])!=0 ){
108876109029
continue;
@@ -111031,11 +111184,13 @@
111031111184
assert( pParse->pVdbe!=0 || pParse->db->mallocFailed );
111032111185
if( pParse->pVdbe==0 ) return;
111033111186
inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
111034111187
if( inReg!=target ){
111035111188
u8 op;
111036
- if( ALWAYS(pExpr) && ExprHasProperty(pExpr,EP_Subquery) ){
111189
+ if( ALWAYS(pExpr)
111190
+ && (ExprHasProperty(pExpr,EP_Subquery) || pExpr->op==TK_REGISTER)
111191
+ ){
111037111192
op = OP_Copy;
111038111193
}else{
111039111194
op = OP_SCopy;
111040111195
}
111041111196
sqlite3VdbeAddOp2(pParse->pVdbe, op, inReg, target);
@@ -112218,11 +112373,11 @@
112218112373
int iAgg = pExpr->iAgg;
112219112374
Parse *pParse = pWalker->pParse;
112220112375
sqlite3 *db = pParse->db;
112221112376
assert( iAgg>=0 );
112222112377
if( pExpr->op!=TK_AGG_FUNCTION ){
112223
- if( iAgg<pAggInfo->nColumn
112378
+ if( ALWAYS(iAgg<pAggInfo->nColumn)
112224112379
&& pAggInfo->aCol[iAgg].pCExpr==pExpr
112225112380
){
112226112381
pExpr = sqlite3ExprDup(db, pExpr, 0);
112227112382
if( pExpr ){
112228112383
pAggInfo->aCol[iAgg].pCExpr = pExpr;
@@ -112381,11 +112536,15 @@
112381112536
if( iDataCur<0 ) continue;
112382112537
if( sqlite3ExprCompare(0, pExpr, pIEpr->pExpr, iDataCur)==0 ) break;
112383112538
}
112384112539
if( pIEpr==0 ) break;
112385112540
if( NEVER(!ExprUseYTab(pExpr)) ) break;
112386
- if( pExpr->pAggInfo!=0 ) break; /* Already resolved by outer context */
112541
+ for(i=0; i<pSrcList->nSrc; i++){
112542
+ if( pSrcList->a[0].iCursor==pIEpr->iDataCur ) break;
112543
+ }
112544
+ if( i>=pSrcList->nSrc ) break;
112545
+ if( NEVER(pExpr->pAggInfo!=0) ) break; /* Resolved by outer context */
112387112546
if( pParse->nErr ){ return WRC_Abort; }
112388112547
112389112548
/* If we reach this point, it means that expression pExpr can be
112390112549
** translated into a reference to an index column as described by
112391112550
** pIEpr.
@@ -145087,16 +145246,17 @@
145087145246
if( pExpr->pAggInfo==0 ) return WRC_Continue;
145088145247
if( pExpr->op==TK_AGG_COLUMN ) return WRC_Continue;
145089145248
if( pExpr->op==TK_AGG_FUNCTION ) return WRC_Continue;
145090145249
if( pExpr->op==TK_IF_NULL_ROW ) return WRC_Continue;
145091145250
pAggInfo = pExpr->pAggInfo;
145092
- if( pExpr->iAgg>=pAggInfo->nColumn ) return WRC_Continue;
145251
+ if( NEVER(pExpr->iAgg>=pAggInfo->nColumn) ) return WRC_Continue;
145093145252
assert( pExpr->iAgg>=0 );
145094145253
pCol = &pAggInfo->aCol[pExpr->iAgg];
145095145254
pExpr->op = TK_AGG_COLUMN;
145096145255
pExpr->iTable = pCol->iTable;
145097145256
pExpr->iColumn = pCol->iColumn;
145257
+ ExprClearProperty(pExpr, EP_Skip|EP_Collate);
145098145258
return WRC_Prune;
145099145259
}
145100145260
145101145261
/*
145102145262
** Convert every pAggInfo->aFunc[].pExpr such that any node within
@@ -152012,10 +152172,14 @@
152012152172
break;
152013152173
}
152014152174
case SQLITE_VTAB_DIRECTONLY: {
152015152175
p->pVTable->eVtabRisk = SQLITE_VTABRISK_High;
152016152176
break;
152177
+ }
152178
+ case SQLITE_VTAB_USES_ALL_SCHEMAS: {
152179
+ p->pVTable->bAllSchemas = 1;
152180
+ break;
152017152181
}
152018152182
default: {
152019152183
rc = SQLITE_MISUSE_BKPT;
152020152184
break;
152021152185
}
@@ -153686,31 +153850,29 @@
153686153850
** know because CCurHint.pIdx!=0) then transform the TK_COLUMN into
153687153851
** an access of the index rather than the original table.
153688153852
*/
153689153853
static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){
153690153854
int rc = WRC_Continue;
153855
+ int reg;
153691153856
struct CCurHint *pHint = pWalker->u.pCCurHint;
153692153857
if( pExpr->op==TK_COLUMN ){
153693153858
if( pExpr->iTable!=pHint->iTabCur ){
153694
- int reg = ++pWalker->pParse->nMem; /* Register for column value */
153695
- sqlite3ExprCode(pWalker->pParse, pExpr, reg);
153859
+ reg = ++pWalker->pParse->nMem; /* Register for column value */
153860
+ reg = sqlite3ExprCodeTarget(pWalker->pParse, pExpr, reg);
153696153861
pExpr->op = TK_REGISTER;
153697153862
pExpr->iTable = reg;
153698153863
}else if( pHint->pIdx!=0 ){
153699153864
pExpr->iTable = pHint->iIdxCur;
153700153865
pExpr->iColumn = sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn);
153701153866
assert( pExpr->iColumn>=0 );
153702153867
}
153703
- }else if( pExpr->op==TK_AGG_FUNCTION ){
153704
- /* An aggregate function in the WHERE clause of a query means this must
153705
- ** be a correlated sub-query, and expression pExpr is an aggregate from
153706
- ** the parent context. Do not walk the function arguments in this case.
153707
- **
153708
- ** todo: It should be possible to replace this node with a TK_REGISTER
153709
- ** expression, as the result of the expression must be stored in a
153710
- ** register at this point. The same holds for TK_AGG_COLUMN nodes. */
153868
+ }else if( pExpr->pAggInfo ){
153711153869
rc = WRC_Prune;
153870
+ reg = ++pWalker->pParse->nMem; /* Register for column value */
153871
+ reg = sqlite3ExprCodeTarget(pWalker->pParse, pExpr, reg);
153872
+ pExpr->op = TK_REGISTER;
153873
+ pExpr->iTable = reg;
153712153874
}
153713153875
return rc;
153714153876
}
153715153877
153716153878
/*
@@ -158823,10 +158985,13 @@
158823158985
sqlite3ErrorMsg(pParse, "%s", sqlite3ErrStr(rc));
158824158986
}else{
158825158987
sqlite3ErrorMsg(pParse, "%s", pVtab->zErrMsg);
158826158988
}
158827158989
}
158990
+ if( pTab->u.vtab.p->bAllSchemas ){
158991
+ sqlite3VtabUsesAllSchemas(pParse);
158992
+ }
158828158993
sqlite3_free(pVtab->zErrMsg);
158829158994
pVtab->zErrMsg = 0;
158830158995
return rc;
158831158996
}
158832158997
#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */
@@ -159353,11 +159518,11 @@
159353159518
#else
159354159519
UNUSED_PARAMETER(pParse);
159355159520
UNUSED_PARAMETER(pBuilder);
159356159521
assert( pLower || pUpper );
159357159522
#endif
159358
- assert( pUpper==0 || (pUpper->wtFlags & TERM_VNULL)==0 );
159523
+ assert( pUpper==0 || (pUpper->wtFlags & TERM_VNULL)==0 || pParse->nErr>0 );
159359159524
nNew = whereRangeAdjust(pLower, nOut);
159360159525
nNew = whereRangeAdjust(pUpper, nNew);
159361159526
159362159527
/* TUNING: If there is both an upper and lower limit and neither limit
159363159528
** has an application-defined likelihood(), assume the range is
@@ -161454,24 +161619,20 @@
161454161619
HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
161455161620
assert( pHidden->eDistinct>=0 && pHidden->eDistinct<=3 );
161456161621
return pHidden->eDistinct;
161457161622
}
161458161623
161459
-#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
161460
- && !defined(SQLITE_OMIT_VIRTUALTABLE)
161461161624
/*
161462161625
** Cause the prepared statement that is associated with a call to
161463161626
** xBestIndex to potentially use all schemas. If the statement being
161464161627
** prepared is read-only, then just start read transactions on all
161465161628
** schemas. But if this is a write operation, start writes on all
161466161629
** schemas.
161467161630
**
161468161631
** This is used by the (built-in) sqlite_dbpage virtual table.
161469161632
*/
161470
-SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(sqlite3_index_info *pIdxInfo){
161471
- HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
161472
- Parse *pParse = pHidden->pParse;
161633
+SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(Parse *pParse){
161473161634
int nDb = pParse->db->nDb;
161474161635
int i;
161475161636
for(i=0; i<nDb; i++){
161476161637
sqlite3CodeVerifySchema(pParse, i);
161477161638
}
@@ -161479,11 +161640,10 @@
161479161640
for(i=0; i<nDb; i++){
161480161641
sqlite3BeginWriteOperation(pParse, 0, i);
161481161642
}
161482161643
}
161483161644
}
161484
-#endif
161485161645
161486161646
/*
161487161647
** Add all WhereLoop objects for a table of the join identified by
161488161648
** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
161489161649
**
@@ -164036,11 +164196,12 @@
164036164196
}
164037164197
}
164038164198
k = pLevel->addrBody + 1;
164039164199
#ifdef SQLITE_DEBUG
164040164200
if( db->flags & SQLITE_VdbeAddopTrace ){
164041
- printf("TRANSLATE opcodes in range %d..%d\n", k, last-1);
164201
+ printf("TRANSLATE cursor %d->%d in opcode range %d..%d\n",
164202
+ pLevel->iTabCur, pLevel->iIdxCur, k, last-1);
164042164203
}
164043164204
/* Proof that the "+1" on the k value above is safe */
164044164205
pOp = sqlite3VdbeGetOp(v, k - 1);
164045164206
assert( pOp->opcode!=OP_Column || pOp->p1!=pLevel->iTabCur );
164046164207
assert( pOp->opcode!=OP_Rowid || pOp->p1!=pLevel->iTabCur );
@@ -172901,11 +173062,11 @@
172901173062
132, 0, 98, 38, 39, 0, 20, 45, 117, 93,
172902173063
};
172903173064
/* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
172904173065
** then the i-th keyword has no more hash collisions. Otherwise,
172905173066
** the next keyword with the same hash is aKWHash[i]-1. */
172906
-static const unsigned char aKWNext[147] = {
173067
+static const unsigned char aKWNext[148] = {0,
172907173068
0, 0, 0, 0, 4, 0, 43, 0, 0, 106, 114, 0, 0,
172908173069
0, 2, 0, 0, 143, 0, 0, 0, 13, 0, 0, 0, 0,
172909173070
141, 0, 0, 119, 52, 0, 0, 137, 12, 0, 0, 62, 0,
172910173071
138, 0, 133, 0, 0, 36, 0, 0, 28, 77, 0, 0, 0,
172911173072
0, 59, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -172916,11 +173077,11 @@
172916173077
112, 21, 7, 67, 0, 79, 96, 118, 0, 0, 68, 0, 0,
172917173078
99, 44, 0, 55, 0, 76, 0, 95, 32, 33, 57, 25, 0,
172918173079
102, 0, 0, 87,
172919173080
};
172920173081
/* aKWLen[i] is the length (in bytes) of the i-th keyword */
172921
-static const unsigned char aKWLen[147] = {
173082
+static const unsigned char aKWLen[148] = {0,
172922173083
7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
172923173084
7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 7,
172924173085
6, 9, 4, 2, 6, 5, 9, 9, 4, 7, 3, 2, 4,
172925173086
4, 6, 11, 6, 2, 7, 5, 5, 9, 6, 10, 4, 6,
172926173087
2, 3, 7, 5, 9, 6, 6, 4, 5, 5, 10, 6, 5,
@@ -172932,11 +173093,11 @@
172932173093
4, 9, 5, 8, 4, 3, 9, 5, 5, 6, 4, 6, 2,
172933173094
2, 9, 3, 7,
172934173095
};
172935173096
/* aKWOffset[i] is the index into zKWText[] of the start of
172936173097
** the text for the i-th keyword. */
172937
-static const unsigned short int aKWOffset[147] = {
173098
+static const unsigned short int aKWOffset[148] = {0,
172938173099
0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
172939173100
36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
172940173101
86, 90, 90, 94, 99, 101, 105, 111, 119, 123, 123, 123, 126,
172941173102
129, 132, 137, 142, 146, 147, 152, 156, 160, 168, 174, 181, 184,
172942173103
184, 187, 189, 195, 198, 206, 211, 216, 219, 222, 226, 236, 239,
@@ -172947,11 +173108,11 @@
172947173108
520, 523, 527, 532, 539, 544, 553, 557, 560, 565, 567, 571, 579,
172948173109
585, 588, 597, 602, 610, 610, 614, 623, 628, 633, 639, 642, 645,
172949173110
648, 650, 655, 659,
172950173111
};
172951173112
/* aKWCode[i] is the parser symbol code for the i-th keyword */
172952
-static const unsigned char aKWCode[147] = {
173113
+static const unsigned char aKWCode[148] = {0,
172953173114
TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
172954173115
TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
172955173116
TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
172956173117
TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
172957173118
TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
@@ -173116,11 +173277,11 @@
173116173277
static int keywordCode(const char *z, int n, int *pType){
173117173278
int i, j;
173118173279
const char *zKW;
173119173280
if( n>=2 ){
173120173281
i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n*1) % 127;
173121
- for(i=((int)aKWHash[i])-1; i>=0; i=((int)aKWNext[i])-1){
173282
+ for(i=(int)aKWHash[i]; i>0; i=aKWNext[i]){
173122173283
if( aKWLen[i]!=n ) continue;
173123173284
zKW = &zKWText[aKWOffset[i]];
173124173285
#ifdef SQLITE_ASCII
173125173286
if( (z[0]&~0x20)!=zKW[0] ) continue;
173126173287
if( (z[1]&~0x20)!=zKW[1] ) continue;
@@ -173132,157 +173293,157 @@
173132173293
if( toupper(z[1])!=zKW[1] ) continue;
173133173294
j = 2;
173134173295
while( j<n && toupper(z[j])==zKW[j] ){ j++; }
173135173296
#endif
173136173297
if( j<n ) continue;
173137
- testcase( i==0 ); /* REINDEX */
173138
- testcase( i==1 ); /* INDEXED */
173139
- testcase( i==2 ); /* INDEX */
173140
- testcase( i==3 ); /* DESC */
173141
- testcase( i==4 ); /* ESCAPE */
173142
- testcase( i==5 ); /* EACH */
173143
- testcase( i==6 ); /* CHECK */
173144
- testcase( i==7 ); /* KEY */
173145
- testcase( i==8 ); /* BEFORE */
173146
- testcase( i==9 ); /* FOREIGN */
173147
- testcase( i==10 ); /* FOR */
173148
- testcase( i==11 ); /* IGNORE */
173149
- testcase( i==12 ); /* REGEXP */
173150
- testcase( i==13 ); /* EXPLAIN */
173151
- testcase( i==14 ); /* INSTEAD */
173152
- testcase( i==15 ); /* ADD */
173153
- testcase( i==16 ); /* DATABASE */
173154
- testcase( i==17 ); /* AS */
173155
- testcase( i==18 ); /* SELECT */
173156
- testcase( i==19 ); /* TABLE */
173157
- testcase( i==20 ); /* LEFT */
173158
- testcase( i==21 ); /* THEN */
173159
- testcase( i==22 ); /* END */
173160
- testcase( i==23 ); /* DEFERRABLE */
173161
- testcase( i==24 ); /* ELSE */
173162
- testcase( i==25 ); /* EXCLUDE */
173163
- testcase( i==26 ); /* DELETE */
173164
- testcase( i==27 ); /* TEMPORARY */
173165
- testcase( i==28 ); /* TEMP */
173166
- testcase( i==29 ); /* OR */
173167
- testcase( i==30 ); /* ISNULL */
173168
- testcase( i==31 ); /* NULLS */
173169
- testcase( i==32 ); /* SAVEPOINT */
173170
- testcase( i==33 ); /* INTERSECT */
173171
- testcase( i==34 ); /* TIES */
173172
- testcase( i==35 ); /* NOTNULL */
173173
- testcase( i==36 ); /* NOT */
173174
- testcase( i==37 ); /* NO */
173175
- testcase( i==38 ); /* NULL */
173176
- testcase( i==39 ); /* LIKE */
173177
- testcase( i==40 ); /* EXCEPT */
173178
- testcase( i==41 ); /* TRANSACTION */
173179
- testcase( i==42 ); /* ACTION */
173180
- testcase( i==43 ); /* ON */
173181
- testcase( i==44 ); /* NATURAL */
173182
- testcase( i==45 ); /* ALTER */
173183
- testcase( i==46 ); /* RAISE */
173184
- testcase( i==47 ); /* EXCLUSIVE */
173185
- testcase( i==48 ); /* EXISTS */
173186
- testcase( i==49 ); /* CONSTRAINT */
173187
- testcase( i==50 ); /* INTO */
173188
- testcase( i==51 ); /* OFFSET */
173189
- testcase( i==52 ); /* OF */
173190
- testcase( i==53 ); /* SET */
173191
- testcase( i==54 ); /* TRIGGER */
173192
- testcase( i==55 ); /* RANGE */
173193
- testcase( i==56 ); /* GENERATED */
173194
- testcase( i==57 ); /* DETACH */
173195
- testcase( i==58 ); /* HAVING */
173196
- testcase( i==59 ); /* GLOB */
173197
- testcase( i==60 ); /* BEGIN */
173198
- testcase( i==61 ); /* INNER */
173199
- testcase( i==62 ); /* REFERENCES */
173200
- testcase( i==63 ); /* UNIQUE */
173201
- testcase( i==64 ); /* QUERY */
173202
- testcase( i==65 ); /* WITHOUT */
173203
- testcase( i==66 ); /* WITH */
173204
- testcase( i==67 ); /* OUTER */
173205
- testcase( i==68 ); /* RELEASE */
173206
- testcase( i==69 ); /* ATTACH */
173207
- testcase( i==70 ); /* BETWEEN */
173208
- testcase( i==71 ); /* NOTHING */
173209
- testcase( i==72 ); /* GROUPS */
173210
- testcase( i==73 ); /* GROUP */
173211
- testcase( i==74 ); /* CASCADE */
173212
- testcase( i==75 ); /* ASC */
173213
- testcase( i==76 ); /* DEFAULT */
173214
- testcase( i==77 ); /* CASE */
173215
- testcase( i==78 ); /* COLLATE */
173216
- testcase( i==79 ); /* CREATE */
173217
- testcase( i==80 ); /* CURRENT_DATE */
173218
- testcase( i==81 ); /* IMMEDIATE */
173219
- testcase( i==82 ); /* JOIN */
173220
- testcase( i==83 ); /* INSERT */
173221
- testcase( i==84 ); /* MATCH */
173222
- testcase( i==85 ); /* PLAN */
173223
- testcase( i==86 ); /* ANALYZE */
173224
- testcase( i==87 ); /* PRAGMA */
173225
- testcase( i==88 ); /* MATERIALIZED */
173226
- testcase( i==89 ); /* DEFERRED */
173227
- testcase( i==90 ); /* DISTINCT */
173228
- testcase( i==91 ); /* IS */
173229
- testcase( i==92 ); /* UPDATE */
173230
- testcase( i==93 ); /* VALUES */
173231
- testcase( i==94 ); /* VIRTUAL */
173232
- testcase( i==95 ); /* ALWAYS */
173233
- testcase( i==96 ); /* WHEN */
173234
- testcase( i==97 ); /* WHERE */
173235
- testcase( i==98 ); /* RECURSIVE */
173236
- testcase( i==99 ); /* ABORT */
173237
- testcase( i==100 ); /* AFTER */
173238
- testcase( i==101 ); /* RENAME */
173239
- testcase( i==102 ); /* AND */
173240
- testcase( i==103 ); /* DROP */
173241
- testcase( i==104 ); /* PARTITION */
173242
- testcase( i==105 ); /* AUTOINCREMENT */
173243
- testcase( i==106 ); /* TO */
173244
- testcase( i==107 ); /* IN */
173245
- testcase( i==108 ); /* CAST */
173246
- testcase( i==109 ); /* COLUMN */
173247
- testcase( i==110 ); /* COMMIT */
173248
- testcase( i==111 ); /* CONFLICT */
173249
- testcase( i==112 ); /* CROSS */
173250
- testcase( i==113 ); /* CURRENT_TIMESTAMP */
173251
- testcase( i==114 ); /* CURRENT_TIME */
173252
- testcase( i==115 ); /* CURRENT */
173253
- testcase( i==116 ); /* PRECEDING */
173254
- testcase( i==117 ); /* FAIL */
173255
- testcase( i==118 ); /* LAST */
173256
- testcase( i==119 ); /* FILTER */
173257
- testcase( i==120 ); /* REPLACE */
173258
- testcase( i==121 ); /* FIRST */
173259
- testcase( i==122 ); /* FOLLOWING */
173260
- testcase( i==123 ); /* FROM */
173261
- testcase( i==124 ); /* FULL */
173262
- testcase( i==125 ); /* LIMIT */
173263
- testcase( i==126 ); /* IF */
173264
- testcase( i==127 ); /* ORDER */
173265
- testcase( i==128 ); /* RESTRICT */
173266
- testcase( i==129 ); /* OTHERS */
173267
- testcase( i==130 ); /* OVER */
173268
- testcase( i==131 ); /* RETURNING */
173269
- testcase( i==132 ); /* RIGHT */
173270
- testcase( i==133 ); /* ROLLBACK */
173271
- testcase( i==134 ); /* ROWS */
173272
- testcase( i==135 ); /* ROW */
173273
- testcase( i==136 ); /* UNBOUNDED */
173274
- testcase( i==137 ); /* UNION */
173275
- testcase( i==138 ); /* USING */
173276
- testcase( i==139 ); /* VACUUM */
173277
- testcase( i==140 ); /* VIEW */
173278
- testcase( i==141 ); /* WINDOW */
173279
- testcase( i==142 ); /* DO */
173280
- testcase( i==143 ); /* BY */
173281
- testcase( i==144 ); /* INITIALLY */
173282
- testcase( i==145 ); /* ALL */
173283
- testcase( i==146 ); /* PRIMARY */
173298
+ testcase( i==1 ); /* REINDEX */
173299
+ testcase( i==2 ); /* INDEXED */
173300
+ testcase( i==3 ); /* INDEX */
173301
+ testcase( i==4 ); /* DESC */
173302
+ testcase( i==5 ); /* ESCAPE */
173303
+ testcase( i==6 ); /* EACH */
173304
+ testcase( i==7 ); /* CHECK */
173305
+ testcase( i==8 ); /* KEY */
173306
+ testcase( i==9 ); /* BEFORE */
173307
+ testcase( i==10 ); /* FOREIGN */
173308
+ testcase( i==11 ); /* FOR */
173309
+ testcase( i==12 ); /* IGNORE */
173310
+ testcase( i==13 ); /* REGEXP */
173311
+ testcase( i==14 ); /* EXPLAIN */
173312
+ testcase( i==15 ); /* INSTEAD */
173313
+ testcase( i==16 ); /* ADD */
173314
+ testcase( i==17 ); /* DATABASE */
173315
+ testcase( i==18 ); /* AS */
173316
+ testcase( i==19 ); /* SELECT */
173317
+ testcase( i==20 ); /* TABLE */
173318
+ testcase( i==21 ); /* LEFT */
173319
+ testcase( i==22 ); /* THEN */
173320
+ testcase( i==23 ); /* END */
173321
+ testcase( i==24 ); /* DEFERRABLE */
173322
+ testcase( i==25 ); /* ELSE */
173323
+ testcase( i==26 ); /* EXCLUDE */
173324
+ testcase( i==27 ); /* DELETE */
173325
+ testcase( i==28 ); /* TEMPORARY */
173326
+ testcase( i==29 ); /* TEMP */
173327
+ testcase( i==30 ); /* OR */
173328
+ testcase( i==31 ); /* ISNULL */
173329
+ testcase( i==32 ); /* NULLS */
173330
+ testcase( i==33 ); /* SAVEPOINT */
173331
+ testcase( i==34 ); /* INTERSECT */
173332
+ testcase( i==35 ); /* TIES */
173333
+ testcase( i==36 ); /* NOTNULL */
173334
+ testcase( i==37 ); /* NOT */
173335
+ testcase( i==38 ); /* NO */
173336
+ testcase( i==39 ); /* NULL */
173337
+ testcase( i==40 ); /* LIKE */
173338
+ testcase( i==41 ); /* EXCEPT */
173339
+ testcase( i==42 ); /* TRANSACTION */
173340
+ testcase( i==43 ); /* ACTION */
173341
+ testcase( i==44 ); /* ON */
173342
+ testcase( i==45 ); /* NATURAL */
173343
+ testcase( i==46 ); /* ALTER */
173344
+ testcase( i==47 ); /* RAISE */
173345
+ testcase( i==48 ); /* EXCLUSIVE */
173346
+ testcase( i==49 ); /* EXISTS */
173347
+ testcase( i==50 ); /* CONSTRAINT */
173348
+ testcase( i==51 ); /* INTO */
173349
+ testcase( i==52 ); /* OFFSET */
173350
+ testcase( i==53 ); /* OF */
173351
+ testcase( i==54 ); /* SET */
173352
+ testcase( i==55 ); /* TRIGGER */
173353
+ testcase( i==56 ); /* RANGE */
173354
+ testcase( i==57 ); /* GENERATED */
173355
+ testcase( i==58 ); /* DETACH */
173356
+ testcase( i==59 ); /* HAVING */
173357
+ testcase( i==60 ); /* GLOB */
173358
+ testcase( i==61 ); /* BEGIN */
173359
+ testcase( i==62 ); /* INNER */
173360
+ testcase( i==63 ); /* REFERENCES */
173361
+ testcase( i==64 ); /* UNIQUE */
173362
+ testcase( i==65 ); /* QUERY */
173363
+ testcase( i==66 ); /* WITHOUT */
173364
+ testcase( i==67 ); /* WITH */
173365
+ testcase( i==68 ); /* OUTER */
173366
+ testcase( i==69 ); /* RELEASE */
173367
+ testcase( i==70 ); /* ATTACH */
173368
+ testcase( i==71 ); /* BETWEEN */
173369
+ testcase( i==72 ); /* NOTHING */
173370
+ testcase( i==73 ); /* GROUPS */
173371
+ testcase( i==74 ); /* GROUP */
173372
+ testcase( i==75 ); /* CASCADE */
173373
+ testcase( i==76 ); /* ASC */
173374
+ testcase( i==77 ); /* DEFAULT */
173375
+ testcase( i==78 ); /* CASE */
173376
+ testcase( i==79 ); /* COLLATE */
173377
+ testcase( i==80 ); /* CREATE */
173378
+ testcase( i==81 ); /* CURRENT_DATE */
173379
+ testcase( i==82 ); /* IMMEDIATE */
173380
+ testcase( i==83 ); /* JOIN */
173381
+ testcase( i==84 ); /* INSERT */
173382
+ testcase( i==85 ); /* MATCH */
173383
+ testcase( i==86 ); /* PLAN */
173384
+ testcase( i==87 ); /* ANALYZE */
173385
+ testcase( i==88 ); /* PRAGMA */
173386
+ testcase( i==89 ); /* MATERIALIZED */
173387
+ testcase( i==90 ); /* DEFERRED */
173388
+ testcase( i==91 ); /* DISTINCT */
173389
+ testcase( i==92 ); /* IS */
173390
+ testcase( i==93 ); /* UPDATE */
173391
+ testcase( i==94 ); /* VALUES */
173392
+ testcase( i==95 ); /* VIRTUAL */
173393
+ testcase( i==96 ); /* ALWAYS */
173394
+ testcase( i==97 ); /* WHEN */
173395
+ testcase( i==98 ); /* WHERE */
173396
+ testcase( i==99 ); /* RECURSIVE */
173397
+ testcase( i==100 ); /* ABORT */
173398
+ testcase( i==101 ); /* AFTER */
173399
+ testcase( i==102 ); /* RENAME */
173400
+ testcase( i==103 ); /* AND */
173401
+ testcase( i==104 ); /* DROP */
173402
+ testcase( i==105 ); /* PARTITION */
173403
+ testcase( i==106 ); /* AUTOINCREMENT */
173404
+ testcase( i==107 ); /* TO */
173405
+ testcase( i==108 ); /* IN */
173406
+ testcase( i==109 ); /* CAST */
173407
+ testcase( i==110 ); /* COLUMN */
173408
+ testcase( i==111 ); /* COMMIT */
173409
+ testcase( i==112 ); /* CONFLICT */
173410
+ testcase( i==113 ); /* CROSS */
173411
+ testcase( i==114 ); /* CURRENT_TIMESTAMP */
173412
+ testcase( i==115 ); /* CURRENT_TIME */
173413
+ testcase( i==116 ); /* CURRENT */
173414
+ testcase( i==117 ); /* PRECEDING */
173415
+ testcase( i==118 ); /* FAIL */
173416
+ testcase( i==119 ); /* LAST */
173417
+ testcase( i==120 ); /* FILTER */
173418
+ testcase( i==121 ); /* REPLACE */
173419
+ testcase( i==122 ); /* FIRST */
173420
+ testcase( i==123 ); /* FOLLOWING */
173421
+ testcase( i==124 ); /* FROM */
173422
+ testcase( i==125 ); /* FULL */
173423
+ testcase( i==126 ); /* LIMIT */
173424
+ testcase( i==127 ); /* IF */
173425
+ testcase( i==128 ); /* ORDER */
173426
+ testcase( i==129 ); /* RESTRICT */
173427
+ testcase( i==130 ); /* OTHERS */
173428
+ testcase( i==131 ); /* OVER */
173429
+ testcase( i==132 ); /* RETURNING */
173430
+ testcase( i==133 ); /* RIGHT */
173431
+ testcase( i==134 ); /* ROLLBACK */
173432
+ testcase( i==135 ); /* ROWS */
173433
+ testcase( i==136 ); /* ROW */
173434
+ testcase( i==137 ); /* UNBOUNDED */
173435
+ testcase( i==138 ); /* UNION */
173436
+ testcase( i==139 ); /* USING */
173437
+ testcase( i==140 ); /* VACUUM */
173438
+ testcase( i==141 ); /* VIEW */
173439
+ testcase( i==142 ); /* WINDOW */
173440
+ testcase( i==143 ); /* DO */
173441
+ testcase( i==144 ); /* BY */
173442
+ testcase( i==145 ); /* INITIALLY */
173443
+ testcase( i==146 ); /* ALL */
173444
+ testcase( i==147 ); /* PRIMARY */
173284173445
*pType = aKWCode[i];
173285173446
break;
173286173447
}
173287173448
}
173288173449
return n;
@@ -173293,10 +173454,11 @@
173293173454
return id;
173294173455
}
173295173456
#define SQLITE_N_KEYWORD 147
173296173457
SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
173297173458
if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
173459
+ i++;
173298173460
*pzName = zKWText + aKWOffset[i];
173299173461
*pnName = aKWLen[i];
173300173462
return SQLITE_OK;
173301173463
}
173302173464
SQLITE_API int sqlite3_keyword_count(void){ return SQLITE_N_KEYWORD; }
@@ -199991,10 +200153,31 @@
199991200153
int i;
199992200154
for(i=0; i<4; i++) if( !sqlite3Isxdigit(z[i]) ) return 0;
199993200155
return 1;
199994200156
}
199995200157
200158
+#ifdef SQLITE_ENABLE_JSON_NAN_INF
200159
+/*
200160
+** Extra floating-point literals to allow in JSON.
200161
+*/
200162
+static const struct NanInfName {
200163
+ char c1;
200164
+ char c2;
200165
+ char n;
200166
+ char eType;
200167
+ char nRepl;
200168
+ char *zMatch;
200169
+ char *zRepl;
200170
+} aNanInfName[] = {
200171
+ { 'i', 'I', 3, JSON_REAL, 7, "inf", "9.0e999" },
200172
+ { 'i', 'I', 8, JSON_REAL, 7, "infinity", "9.0e999" },
200173
+ { 'n', 'N', 3, JSON_NULL, 4, "NaN", "null" },
200174
+ { 'q', 'Q', 4, JSON_NULL, 4, "QNaN", "null" },
200175
+ { 's', 'S', 4, JSON_NULL, 4, "SNaN", "null" },
200176
+};
200177
+#endif /* SQLITE_ENABLE_JSON_NAN_INF */
200178
+
199996200179
/*
199997200180
** Parse a single JSON value which begins at pParse->zJson[i]. Return the
199998200181
** index of the first character past the end of the value parsed.
199999200182
**
200000200183
** Return negative for a syntax error. Special cases: return -2 if the
@@ -200136,10 +200319,28 @@
200136200319
c = z[j+1];
200137200320
}
200138200321
if( c<'0' || c>'9' ) return -1;
200139200322
continue;
200140200323
}
200324
+#ifdef SQLITE_ENABLE_JSON_NAN_INF
200325
+ /* Non-standard JSON: Allow "-Inf" (in any case)
200326
+ ** to be understood as floating point literals. */
200327
+ if( (c=='i' || c=='I')
200328
+ && j==i+1
200329
+ && z[i]=='-'
200330
+ && sqlite3StrNICmp(&z[j], "inf",3)==0
200331
+ ){
200332
+ if( !sqlite3Isalnum(z[j+3]) ){
200333
+ jsonParseAddNode(pParse, JSON_REAL, 8, "-9.0e999");
200334
+ return i+4;
200335
+ }else if( (sqlite3StrNICmp(&z[j],"infinity",8)==0 &&
200336
+ !sqlite3Isalnum(z[j+8])) ){
200337
+ jsonParseAddNode(pParse, JSON_REAL, 8, "-9.0e999");
200338
+ return i+9;
200339
+ }
200340
+ }
200341
+#endif
200141200342
break;
200142200343
}
200143200344
if( z[j-1]<'0' ) return -1;
200144200345
jsonParseAddNode(pParse, seenDP ? JSON_REAL : JSON_INT,
200145200346
j - i, &z[i]);
@@ -200149,10 +200350,24 @@
200149200350
}else if( c==']' ){
200150200351
return -3; /* End of [...] */
200151200352
}else if( c==0 ){
200152200353
return 0; /* End of file */
200153200354
}else{
200355
+#ifdef SQLITE_ENABLE_JSON_NAN_INF
200356
+ int k, nn;
200357
+ for(k=0; k<sizeof(aNanInfName)/sizeof(aNanInfName[0]); k++){
200358
+ if( c!=aNanInfName[k].c1 && c!=aNanInfName[k].c2 ) continue;
200359
+ nn = aNanInfName[k].n;
200360
+ if( sqlite3StrNICmp(&z[i], aNanInfName[k].zMatch, nn)!=0 ){
200361
+ continue;
200362
+ }
200363
+ if( sqlite3Isalnum(z[i+nn]) ) continue;
200364
+ jsonParseAddNode(pParse, aNanInfName[k].eType,
200365
+ aNanInfName[k].nRepl, aNanInfName[k].zRepl);
200366
+ return i + nn;
200367
+ }
200368
+#endif
200154200369
return -1; /* Syntax error */
200155200370
}
200156200371
}
200157200372
200158200373
/*
@@ -212971,19 +213186,28 @@
212971213186
212972213187
iOff = (i64)(pFrame->iDbPage-1) * p->pgsz;
212973213188
p->rc = pDb->pMethods->xWrite(pDb, p->aBuf, p->pgsz, iOff);
212974213189
}
212975213190
213191
+/*
213192
+** This value is copied from the definition of ZIPVFS_CTRL_FILE_POINTER
213193
+** in zipvfs.h.
213194
+*/
213195
+#define RBU_ZIPVFS_CTRL_FILE_POINTER 230439
212976213196
212977213197
/*
212978213198
** Take an EXCLUSIVE lock on the database file. Return SQLITE_OK if
212979213199
** successful, or an SQLite error code otherwise.
212980213200
*/
212981213201
static int rbuLockDatabase(sqlite3 *db){
212982213202
int rc = SQLITE_OK;
212983213203
sqlite3_file *fd = 0;
212984
- sqlite3_file_control(db, "main", SQLITE_FCNTL_FILE_POINTER, &fd);
213204
+
213205
+ sqlite3_file_control(db, "main", RBU_ZIPVFS_CTRL_FILE_POINTER, &fd);
213206
+ if( fd==0 ){
213207
+ sqlite3_file_control(db, "main", SQLITE_FCNTL_FILE_POINTER, &fd);
213208
+ }
212985213209
212986213210
if( fd->pMethods ){
212987213211
rc = fd->pMethods->xLock(fd, SQLITE_LOCK_SHARED);
212988213212
if( rc==SQLITE_OK ){
212989213213
rc = fd->pMethods->xLock(fd, SQLITE_LOCK_EXCLUSIVE);
@@ -216218,10 +216442,11 @@
216218216442
(void)argc;
216219216443
(void)argv;
216220216444
(void)pzErr;
216221216445
216222216446
sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY);
216447
+ sqlite3_vtab_config(db, SQLITE_VTAB_USES_ALL_SCHEMAS);
216223216448
rc = sqlite3_declare_vtab(db,
216224216449
"CREATE TABLE x(pgno INTEGER PRIMARY KEY, data BLOB, schema HIDDEN)");
216225216450
if( rc==SQLITE_OK ){
216226216451
pTab = (DbpageTable *)sqlite3_malloc64(sizeof(DbpageTable));
216227216452
if( pTab==0 ) rc = SQLITE_NOMEM_BKPT;
@@ -216301,11 +216526,10 @@
216301216526
&& pIdxInfo->aOrderBy[0].iColumn<=0
216302216527
&& pIdxInfo->aOrderBy[0].desc==0
216303216528
){
216304216529
pIdxInfo->orderByConsumed = 1;
216305216530
}
216306
- sqlite3VtabUsesAllSchemas(pIdxInfo);
216307216531
return SQLITE_OK;
216308216532
}
216309216533
216310216534
/*
216311216535
** Open a new dbpagevfs cursor.
@@ -240797,11 +241021,11 @@
240797241021
int nArg, /* Number of args */
240798241022
sqlite3_value **apUnused /* Function arguments */
240799241023
){
240800241024
assert( nArg==0 );
240801241025
UNUSED_PARAM2(nArg, apUnused);
240802
- sqlite3_result_text(pCtx, "fts5: 2023-04-01 12:22:57 33ac62d8eec56eb71f20ccd28a5d6e4e8051522feb2db0199abee9e18ce1f64e", -1, SQLITE_TRANSIENT);
241026
+ sqlite3_result_text(pCtx, "fts5: 2023-04-10 13:20:51 49ba030080dd00b4fdf788fd3da057b333e705fa0fe37d653e2461bf96ca3785", -1, SQLITE_TRANSIENT);
240803241027
}
240804241028
240805241029
/*
240806241030
** Return true if zName is the extension on one of the shadow tables used
240807241031
** by this module.
240808241032
--- 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.42.0"
456 #define SQLITE_VERSION_NUMBER 3042000
457 #define SQLITE_SOURCE_ID "2023-04-01 15:51:21 a4fb2864fe01cce9694242a0750623ca47fcecd68f74c4239d3eb5fbf978770a"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -2800,11 +2800,11 @@
2800 #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
2801 #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
2802 #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2803 #define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
2804 #define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
2805 #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1080 /* int int* */
2806 #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2807 #define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
2808
2809 /*
2810 ** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -9910,22 +9910,32 @@
9910 ** </dd>
9911 **
9912 ** [[SQLITE_VTAB_INNOCUOUS]]<dt>SQLITE_VTAB_INNOCUOUS</dt>
9913 ** <dd>Calls of the form
9914 ** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the
9915 ** the [xConnect] or [xCreate] methods of a [virtual table] implmentation
9916 ** identify that virtual table as being safe to use from within triggers
9917 ** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the
9918 ** virtual table can do no serious harm even if it is controlled by a
9919 ** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS
9920 ** flag unless absolutely necessary.
9921 ** </dd>
 
 
 
 
 
 
 
 
 
9922 ** </dl>
9923 */
9924 #define SQLITE_VTAB_CONSTRAINT_SUPPORT 1
9925 #define SQLITE_VTAB_INNOCUOUS 2
9926 #define SQLITE_VTAB_DIRECTONLY 3
 
9927
9928 /*
9929 ** CAPI3REF: Determine The Virtual Table Conflict Policy
9930 **
9931 ** This function may only be called from within a call to the [xUpdate] method
@@ -13629,19 +13639,26 @@
13629 # define SQLITE_INT_TO_PTR(X) ((void*)(X))
13630 # define SQLITE_PTR_TO_INT(X) ((int)(X))
13631 #endif
13632
13633 /*
13634 ** A macro to hint to the compiler that a function should not be
13635 ** inlined.
13636 */
13637 #if defined(__GNUC__)
13638 # define SQLITE_NOINLINE __attribute__((noinline))
 
13639 #elif defined(_MSC_VER) && _MSC_VER>=1310
13640 # define SQLITE_NOINLINE __declspec(noinline)
 
13641 #else
13642 # define SQLITE_NOINLINE
 
 
 
 
 
13643 #endif
13644
13645 /*
13646 ** Make sure that the compiler intrinsics we desire are enabled when
13647 ** compiling with an appropriate version of MSVC unless prevented by
@@ -16597,10 +16614,14 @@
16597 #endif
16598
16599 #if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
16600 SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE*, int, VdbeOp*);
16601 #endif
 
 
 
 
16602
16603 #endif /* SQLITE_VDBE_H */
16604
16605 /************** End of vdbe.h ************************************************/
16606 /************** Continuing where we left off in sqliteInt.h ******************/
@@ -17862,10 +17883,11 @@
17862 sqlite3 *db; /* Database connection associated with this table */
17863 Module *pMod; /* Pointer to module implementation */
17864 sqlite3_vtab *pVtab; /* Pointer to vtab instance */
17865 int nRef; /* Number of pointers to this structure */
17866 u8 bConstraint; /* True if constraints are supported */
 
17867 u8 eVtabRisk; /* Riskiness of allowing hacker access */
17868 int iSavepoint; /* Depth of the SAVEPOINT stack */
17869 VTable *pNext; /* Next in linked list (see above) */
17870 };
17871
@@ -19728,10 +19750,11 @@
19728 struct RenameCtx *pRename; /* RENAME COLUMN context */
19729 struct Table *pTab; /* Table of generated column */
19730 struct CoveringIndexCheck *pCovIdxCk; /* Check for covering index */
19731 SrcItem *pSrcItem; /* A single FROM clause item */
19732 DbFixer *pFix; /* See sqlite3FixSelect() */
 
19733 } u;
19734 };
19735
19736 /*
19737 ** The following structure contains information used by the sqliteFix...
@@ -20890,14 +20913,11 @@
20890 SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
20891 SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
20892 SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
20893
20894 SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
20895 #if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
20896 && !defined(SQLITE_OMIT_VIRTUALTABLE)
20897 SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(sqlite3_index_info*);
20898 #endif
20899 SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
20900 SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
20901 SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
20902 SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse*,sqlite3*);
20903 SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse*);
@@ -69500,12 +69520,29 @@
69500 ** and number of the varargs parameters) is determined by the eHintType
69501 ** parameter. See the definitions of the BTREE_HINT_* macros for details.
69502 */
69503 SQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor *pCur, int eHintType, ...){
69504 /* Used only by system that substitute their own storage engine */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69505 }
69506 #endif
 
69507
69508 /*
69509 ** Provide flag hints to the cursor.
69510 */
69511 SQLITE_PRIVATE void sqlite3BtreeCursorHintFlags(BtCursor *pCur, unsigned x){
@@ -70300,11 +70337,11 @@
70300 ** all the space together, however. This routine will avoid using
70301 ** the first two bytes past the cell pointer area since presumably this
70302 ** allocation is being made in order to insert a new cell, so we will
70303 ** also end up needing a new cell pointer.
70304 */
70305 static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
70306 const int hdr = pPage->hdrOffset; /* Local cache of pPage->hdrOffset */
70307 u8 * const data = pPage->aData; /* Local cache of pPage->aData */
70308 int top; /* First byte of cell content area */
70309 int rc = SQLITE_OK; /* Integer return code */
70310 u8 *pTmp; /* Temp ptr into data[] */
@@ -70326,17 +70363,18 @@
70326 ** then the cell content offset of an empty page wants to be 65536.
70327 ** However, that integer is too large to be stored in a 2-byte unsigned
70328 ** integer, so a value of 0 is used in its place. */
70329 pTmp = &data[hdr+5];
70330 top = get2byte(pTmp);
70331 assert( top<=(int)pPage->pBt->usableSize ); /* by btreeComputeFreeSpace() */
70332 if( gap>top ){
70333 if( top==0 && pPage->pBt->usableSize==65536 ){
70334 top = 65536;
70335 }else{
70336 return SQLITE_CORRUPT_PAGE(pPage);
70337 }
 
 
70338 }
70339
70340 /* If there is enough space between gap and top for one more cell pointer,
70341 ** and if the freelist is not empty, then search the
70342 ** freelist looking for a slot big enough to satisfy the request.
@@ -70415,11 +70453,11 @@
70415 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
70416 assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize );
70417 assert( CORRUPT_DB || iEnd <= pPage->pBt->usableSize );
70418 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
70419 assert( iSize>=4 ); /* Minimum cell size is 4 */
70420 assert( iStart<=pPage->pBt->usableSize-4 );
70421
70422 /* The list of freeblocks must be in ascending order. Find the
70423 ** spot on the list where iStart should be inserted.
70424 */
70425 hdr = pPage->hdrOffset;
@@ -70472,10 +70510,15 @@
70472 if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_PAGE(pPage);
70473 data[hdr+7] -= nFrag;
70474 }
70475 pTmp = &data[hdr+5];
70476 x = get2byte(pTmp);
 
 
 
 
 
70477 if( iStart<=x ){
70478 /* The new freeblock is at the beginning of the cell content area,
70479 ** so just extend the cell content area rather than create another
70480 ** freelist entry */
70481 if( iStart<x ) return SQLITE_CORRUPT_PAGE(pPage);
@@ -70483,18 +70526,13 @@
70483 put2byte(&data[hdr+1], iFreeBlk);
70484 put2byte(&data[hdr+5], iEnd);
70485 }else{
70486 /* Insert the new freeblock into the freelist */
70487 put2byte(&data[iPtr], iStart);
70488 }
70489 if( pPage->pBt->btsFlags & BTS_FAST_SECURE ){
70490 /* Overwrite deleted information with zeros when the secure_delete
70491 ** option is enabled */
70492 memset(&data[iStart], 0, iSize);
70493 }
70494 put2byte(&data[iStart], iFreeBlk);
70495 put2byte(&data[iStart+2], iSize);
70496 pPage->nFree += iOrigSize;
70497 return SQLITE_OK;
70498 }
70499
70500 /*
@@ -75649,10 +75687,18 @@
75649 ** pTemp is not null. Regardless of pTemp, allocate a new entry
75650 ** in pPage->apOvfl[] and make it point to the cell content (either
75651 ** in pTemp or the original pCell) and also record its index.
75652 ** Allocating a new entry in pPage->aCell[] implies that
75653 ** pPage->nOverflow is incremented.
 
 
 
 
 
 
 
 
75654 */
75655 static int insertCell(
75656 MemPage *pPage, /* Page into which we are copying */
75657 int i, /* New cell becomes the i-th cell of the page */
75658 u8 *pCell, /* Content of the new cell */
@@ -75671,18 +75717,107 @@
75671 assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );
75672 assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );
75673 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
75674 assert( sz==pPage->xCellSize(pPage, pCell) || CORRUPT_DB );
75675 assert( pPage->nFree>=0 );
 
75676 if( pPage->nOverflow || sz+2>pPage->nFree ){
75677 if( pTemp ){
75678 memcpy(pTemp, pCell, sz);
75679 pCell = pTemp;
75680 }
75681 if( iChild ){
75682 put4byte(pCell, iChild);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75683 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75684 j = pPage->nOverflow++;
75685 /* Comparison against ArraySize-1 since we hold back one extra slot
75686 ** as a contingency. In other words, never need more than 3 overflow
75687 ** slots but 4 are allocated, just to be safe. */
75688 assert( j < ArraySize(pPage->apOvfl)-1 );
@@ -75710,21 +75845,11 @@
75710 ** if it returns successfully */
75711 assert( idx >= 0 );
75712 assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );
75713 assert( idx+sz <= (int)pPage->pBt->usableSize );
75714 pPage->nFree -= (u16)(2 + sz);
75715 if( iChild ){
75716 /* In a corrupt database where an entry in the cell index section of
75717 ** a btree page has a value of 3 or less, the pCell value might point
75718 ** as many as 4 bytes in front of the start of the aData buffer for
75719 ** the source page. Make sure this does not cause problems by not
75720 ** reading the first 4 bytes */
75721 memcpy(&data[idx+4], pCell+4, sz-4);
75722 put4byte(&data[idx], iChild);
75723 }else{
75724 memcpy(&data[idx], pCell, sz);
75725 }
75726 pIns = pPage->aCellIdx + i*2;
75727 memmove(pIns+2, pIns, 2*(pPage->nCell - i));
75728 put2byte(pIns, idx);
75729 pPage->nCell++;
75730 /* increment the cell count */
@@ -75905,11 +76030,11 @@
75905 int k; /* Current slot in pCArray->apEnd[] */
75906 u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */
75907
75908 assert( i<iEnd );
75909 j = get2byte(&aData[hdr+5]);
75910 if( j>(u32)usableSize ){ j = 0; }
75911 memcpy(&pTmp[j], &aData[j], usableSize - j);
75912
75913 for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
75914 pSrcEnd = pCArray->apEnd[k];
75915
@@ -76049,46 +76174,54 @@
76049 ){
76050 u8 * const aData = pPg->aData;
76051 u8 * const pEnd = &aData[pPg->pBt->usableSize];
76052 u8 * const pStart = &aData[pPg->hdrOffset + 8 + pPg->childPtrSize];
76053 int nRet = 0;
76054 int i;
76055 int iEnd = iFirst + nCell;
76056 u8 *pFree = 0; /* \__ Parameters for pending call to */
76057 int szFree = 0; /* / freeSpace() */
 
76058
76059 for(i=iFirst; i<iEnd; i++){
76060 u8 *pCell = pCArray->apCell[i];
76061 if( SQLITE_WITHIN(pCell, pStart, pEnd) ){
76062 int sz;
 
 
76063 /* No need to use cachedCellSize() here. The sizes of all cells that
76064 ** are to be freed have already been computing while deciding which
76065 ** cells need freeing */
76066 sz = pCArray->szCell[i]; assert( sz>0 );
76067 if( pFree!=(pCell + sz) ){
76068 if( pFree ){
76069 assert( pFree>aData && (pFree - aData)<65536 );
76070 freeSpace(pPg, (u16)(pFree - aData), szFree);
76071 }
76072 pFree = pCell;
76073 szFree = sz;
76074 if( pFree+sz>pEnd ){
76075 return 0;
76076 }
76077 }else{
76078 /* The current cell is adjacent to and before the pFree cell.
76079 ** Combine the two regions into one to reduce the number of calls
76080 ** to freeSpace(). */
76081 pFree = pCell;
76082 szFree += sz;
 
 
 
 
 
 
76083 }
76084 nRet++;
76085 }
76086 }
76087 if( pFree ){
76088 assert( pFree>aData && (pFree - aData)<65536 );
76089 freeSpace(pPg, (u16)(pFree - aData), szFree);
76090 }
76091 return nRet;
76092 }
76093
76094 /*
@@ -76139,11 +76272,11 @@
76139 nCell -= nTail;
76140 }
76141
76142 pData = &aData[get2byteNotZero(&aData[hdr+5])];
76143 if( pData<pBegin ) goto editpage_fail;
76144 if( pData>pPg->aDataEnd ) goto editpage_fail;
76145
76146 /* Add cells to the start of the page */
76147 if( iNew<iOld ){
76148 int nAdd = MIN(nNew,iOld-iNew);
76149 assert( (iOld-iNew)<nNew || nCell==0 || CORRUPT_DB );
@@ -77865,11 +77998,11 @@
77865 idx = ++pCur->ix;
77866 pCur->curFlags &= ~BTCF_ValidNKey;
77867 }else{
77868 assert( pPage->leaf );
77869 }
77870 rc = insertCell(pPage, idx, newCell, szNew, 0, 0);
77871 assert( pPage->nOverflow==0 || rc==SQLITE_OK );
77872 assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );
77873
77874 /* If no error has occurred and pPage has an overflow cell, call balance()
77875 ** to redistribute the cells within the tree. Since balance() may move
@@ -78088,10 +78221,13 @@
78088 return SQLITE_CORRUPT_BKPT;
78089 }
78090 pCell = findCell(pPage, iCellIdx);
78091 if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ){
78092 return SQLITE_CORRUPT_BKPT;
 
 
 
78093 }
78094
78095 /* If the BTREE_SAVEPOSITION bit is on, then the cursor position must
78096 ** be preserved following this delete operation. If the current delete
78097 ** will cause a b-tree rebalance, then this is done by saving the cursor
@@ -80991,11 +81127,11 @@
80991 return SQLITE_NOMEM_BKPT;
80992 }
80993
80994 vdbeMemRenderNum(nByte, pMem->z, pMem);
80995 assert( pMem->z!=0 );
80996 assert( pMem->n==sqlite3Strlen30NN(pMem->z) );
80997 pMem->enc = SQLITE_UTF8;
80998 pMem->flags |= MEM_Str|MEM_Term;
80999 if( bForce ) pMem->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal);
81000 sqlite3VdbeChangeEncoding(pMem, enc);
81001 return SQLITE_OK;
@@ -82035,10 +82171,13 @@
82035 assert( ExprUseXList(p) );
82036 pList = p->x.pList;
82037 if( pList ) nVal = pList->nExpr;
82038 assert( !ExprHasProperty(p, EP_IntValue) );
82039 pFunc = sqlite3FindFunction(db, p->u.zToken, nVal, enc, 0);
 
 
 
82040 assert( pFunc );
82041 if( (pFunc->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0
82042 || (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)
82043 ){
82044 return SQLITE_OK;
@@ -85875,10 +86014,12 @@
85875 db->nDeferredCons = 0;
85876 db->nDeferredImmCons = 0;
85877 db->flags &= ~(u64)SQLITE_DeferFKs;
85878 sqlite3CommitInternalChanges(db);
85879 }
 
 
85880 }else{
85881 sqlite3RollbackAll(db, SQLITE_OK);
85882 p->nChange = 0;
85883 }
85884 db->nStatement = 0;
@@ -87822,10 +87963,24 @@
87822 return 0;
87823 }
87824 return 1;
87825 }
87826
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87827 #ifndef SQLITE_OMIT_VIRTUALTABLE
87828 /*
87829 ** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored
87830 ** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored
87831 ** in memory obtained from sqlite3DbMalloc).
@@ -88208,11 +88363,11 @@
88208 SQLITE_NULL, /* 0x1d (not possible) */
88209 SQLITE_INTEGER, /* 0x1e (not possible) */
88210 SQLITE_NULL, /* 0x1f (not possible) */
88211 SQLITE_FLOAT, /* 0x20 INTREAL */
88212 SQLITE_NULL, /* 0x21 (not possible) */
88213 SQLITE_TEXT, /* 0x22 INTREAL + TEXT */
88214 SQLITE_NULL, /* 0x23 (not possible) */
88215 SQLITE_FLOAT, /* 0x24 (not possible) */
88216 SQLITE_NULL, /* 0x25 (not possible) */
88217 SQLITE_FLOAT, /* 0x26 (not possible) */
88218 SQLITE_NULL, /* 0x27 (not possible) */
@@ -106208,15 +106363,14 @@
106208 if( p->pLeft && (p->pLeft->flags & EP_Collate)!=0 ){
106209 p = p->pLeft;
106210 }else{
106211 Expr *pNext = p->pRight;
106212 /* The Expr.x union is never used at the same time as Expr.pRight */
106213 assert( ExprUseXList(p) );
106214 assert( p->x.pList==0 || p->pRight==0 );
106215 if( p->x.pList!=0 && !db->mallocFailed ){
106216 int i;
106217 for(i=0; ALWAYS(i<p->x.pList->nExpr); i++){
106218 if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){
106219 pNext = p->x.pList->a[i].pExpr;
106220 break;
106221 }
106222 }
@@ -108866,11 +109020,10 @@
108866 Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i);
108867 Expr *pRhs = pEList->a[i].pExpr;
108868 CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);
108869 int j;
108870
108871 assert( pReq!=0 || pRhs->iColumn==XN_ROWID || pParse->nErr );
108872 for(j=0; j<nExpr; j++){
108873 if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;
108874 assert( pIdx->azColl[j] );
108875 if( pReq!=0 && sqlite3StrICmp(pReq->zName, pIdx->azColl[j])!=0 ){
108876 continue;
@@ -111031,11 +111184,13 @@
111031 assert( pParse->pVdbe!=0 || pParse->db->mallocFailed );
111032 if( pParse->pVdbe==0 ) return;
111033 inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
111034 if( inReg!=target ){
111035 u8 op;
111036 if( ALWAYS(pExpr) && ExprHasProperty(pExpr,EP_Subquery) ){
 
 
111037 op = OP_Copy;
111038 }else{
111039 op = OP_SCopy;
111040 }
111041 sqlite3VdbeAddOp2(pParse->pVdbe, op, inReg, target);
@@ -112218,11 +112373,11 @@
112218 int iAgg = pExpr->iAgg;
112219 Parse *pParse = pWalker->pParse;
112220 sqlite3 *db = pParse->db;
112221 assert( iAgg>=0 );
112222 if( pExpr->op!=TK_AGG_FUNCTION ){
112223 if( iAgg<pAggInfo->nColumn
112224 && pAggInfo->aCol[iAgg].pCExpr==pExpr
112225 ){
112226 pExpr = sqlite3ExprDup(db, pExpr, 0);
112227 if( pExpr ){
112228 pAggInfo->aCol[iAgg].pCExpr = pExpr;
@@ -112381,11 +112536,15 @@
112381 if( iDataCur<0 ) continue;
112382 if( sqlite3ExprCompare(0, pExpr, pIEpr->pExpr, iDataCur)==0 ) break;
112383 }
112384 if( pIEpr==0 ) break;
112385 if( NEVER(!ExprUseYTab(pExpr)) ) break;
112386 if( pExpr->pAggInfo!=0 ) break; /* Already resolved by outer context */
 
 
 
 
112387 if( pParse->nErr ){ return WRC_Abort; }
112388
112389 /* If we reach this point, it means that expression pExpr can be
112390 ** translated into a reference to an index column as described by
112391 ** pIEpr.
@@ -145087,16 +145246,17 @@
145087 if( pExpr->pAggInfo==0 ) return WRC_Continue;
145088 if( pExpr->op==TK_AGG_COLUMN ) return WRC_Continue;
145089 if( pExpr->op==TK_AGG_FUNCTION ) return WRC_Continue;
145090 if( pExpr->op==TK_IF_NULL_ROW ) return WRC_Continue;
145091 pAggInfo = pExpr->pAggInfo;
145092 if( pExpr->iAgg>=pAggInfo->nColumn ) return WRC_Continue;
145093 assert( pExpr->iAgg>=0 );
145094 pCol = &pAggInfo->aCol[pExpr->iAgg];
145095 pExpr->op = TK_AGG_COLUMN;
145096 pExpr->iTable = pCol->iTable;
145097 pExpr->iColumn = pCol->iColumn;
 
145098 return WRC_Prune;
145099 }
145100
145101 /*
145102 ** Convert every pAggInfo->aFunc[].pExpr such that any node within
@@ -152012,10 +152172,14 @@
152012 break;
152013 }
152014 case SQLITE_VTAB_DIRECTONLY: {
152015 p->pVTable->eVtabRisk = SQLITE_VTABRISK_High;
152016 break;
 
 
 
 
152017 }
152018 default: {
152019 rc = SQLITE_MISUSE_BKPT;
152020 break;
152021 }
@@ -153686,31 +153850,29 @@
153686 ** know because CCurHint.pIdx!=0) then transform the TK_COLUMN into
153687 ** an access of the index rather than the original table.
153688 */
153689 static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){
153690 int rc = WRC_Continue;
 
153691 struct CCurHint *pHint = pWalker->u.pCCurHint;
153692 if( pExpr->op==TK_COLUMN ){
153693 if( pExpr->iTable!=pHint->iTabCur ){
153694 int reg = ++pWalker->pParse->nMem; /* Register for column value */
153695 sqlite3ExprCode(pWalker->pParse, pExpr, reg);
153696 pExpr->op = TK_REGISTER;
153697 pExpr->iTable = reg;
153698 }else if( pHint->pIdx!=0 ){
153699 pExpr->iTable = pHint->iIdxCur;
153700 pExpr->iColumn = sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn);
153701 assert( pExpr->iColumn>=0 );
153702 }
153703 }else if( pExpr->op==TK_AGG_FUNCTION ){
153704 /* An aggregate function in the WHERE clause of a query means this must
153705 ** be a correlated sub-query, and expression pExpr is an aggregate from
153706 ** the parent context. Do not walk the function arguments in this case.
153707 **
153708 ** todo: It should be possible to replace this node with a TK_REGISTER
153709 ** expression, as the result of the expression must be stored in a
153710 ** register at this point. The same holds for TK_AGG_COLUMN nodes. */
153711 rc = WRC_Prune;
 
 
 
 
153712 }
153713 return rc;
153714 }
153715
153716 /*
@@ -158823,10 +158985,13 @@
158823 sqlite3ErrorMsg(pParse, "%s", sqlite3ErrStr(rc));
158824 }else{
158825 sqlite3ErrorMsg(pParse, "%s", pVtab->zErrMsg);
158826 }
158827 }
 
 
 
158828 sqlite3_free(pVtab->zErrMsg);
158829 pVtab->zErrMsg = 0;
158830 return rc;
158831 }
158832 #endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */
@@ -159353,11 +159518,11 @@
159353 #else
159354 UNUSED_PARAMETER(pParse);
159355 UNUSED_PARAMETER(pBuilder);
159356 assert( pLower || pUpper );
159357 #endif
159358 assert( pUpper==0 || (pUpper->wtFlags & TERM_VNULL)==0 );
159359 nNew = whereRangeAdjust(pLower, nOut);
159360 nNew = whereRangeAdjust(pUpper, nNew);
159361
159362 /* TUNING: If there is both an upper and lower limit and neither limit
159363 ** has an application-defined likelihood(), assume the range is
@@ -161454,24 +161619,20 @@
161454 HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
161455 assert( pHidden->eDistinct>=0 && pHidden->eDistinct<=3 );
161456 return pHidden->eDistinct;
161457 }
161458
161459 #if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
161460 && !defined(SQLITE_OMIT_VIRTUALTABLE)
161461 /*
161462 ** Cause the prepared statement that is associated with a call to
161463 ** xBestIndex to potentially use all schemas. If the statement being
161464 ** prepared is read-only, then just start read transactions on all
161465 ** schemas. But if this is a write operation, start writes on all
161466 ** schemas.
161467 **
161468 ** This is used by the (built-in) sqlite_dbpage virtual table.
161469 */
161470 SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(sqlite3_index_info *pIdxInfo){
161471 HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
161472 Parse *pParse = pHidden->pParse;
161473 int nDb = pParse->db->nDb;
161474 int i;
161475 for(i=0; i<nDb; i++){
161476 sqlite3CodeVerifySchema(pParse, i);
161477 }
@@ -161479,11 +161640,10 @@
161479 for(i=0; i<nDb; i++){
161480 sqlite3BeginWriteOperation(pParse, 0, i);
161481 }
161482 }
161483 }
161484 #endif
161485
161486 /*
161487 ** Add all WhereLoop objects for a table of the join identified by
161488 ** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
161489 **
@@ -164036,11 +164196,12 @@
164036 }
164037 }
164038 k = pLevel->addrBody + 1;
164039 #ifdef SQLITE_DEBUG
164040 if( db->flags & SQLITE_VdbeAddopTrace ){
164041 printf("TRANSLATE opcodes in range %d..%d\n", k, last-1);
 
164042 }
164043 /* Proof that the "+1" on the k value above is safe */
164044 pOp = sqlite3VdbeGetOp(v, k - 1);
164045 assert( pOp->opcode!=OP_Column || pOp->p1!=pLevel->iTabCur );
164046 assert( pOp->opcode!=OP_Rowid || pOp->p1!=pLevel->iTabCur );
@@ -172901,11 +173062,11 @@
172901 132, 0, 98, 38, 39, 0, 20, 45, 117, 93,
172902 };
172903 /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
172904 ** then the i-th keyword has no more hash collisions. Otherwise,
172905 ** the next keyword with the same hash is aKWHash[i]-1. */
172906 static const unsigned char aKWNext[147] = {
172907 0, 0, 0, 0, 4, 0, 43, 0, 0, 106, 114, 0, 0,
172908 0, 2, 0, 0, 143, 0, 0, 0, 13, 0, 0, 0, 0,
172909 141, 0, 0, 119, 52, 0, 0, 137, 12, 0, 0, 62, 0,
172910 138, 0, 133, 0, 0, 36, 0, 0, 28, 77, 0, 0, 0,
172911 0, 59, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -172916,11 +173077,11 @@
172916 112, 21, 7, 67, 0, 79, 96, 118, 0, 0, 68, 0, 0,
172917 99, 44, 0, 55, 0, 76, 0, 95, 32, 33, 57, 25, 0,
172918 102, 0, 0, 87,
172919 };
172920 /* aKWLen[i] is the length (in bytes) of the i-th keyword */
172921 static const unsigned char aKWLen[147] = {
172922 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
172923 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 7,
172924 6, 9, 4, 2, 6, 5, 9, 9, 4, 7, 3, 2, 4,
172925 4, 6, 11, 6, 2, 7, 5, 5, 9, 6, 10, 4, 6,
172926 2, 3, 7, 5, 9, 6, 6, 4, 5, 5, 10, 6, 5,
@@ -172932,11 +173093,11 @@
172932 4, 9, 5, 8, 4, 3, 9, 5, 5, 6, 4, 6, 2,
172933 2, 9, 3, 7,
172934 };
172935 /* aKWOffset[i] is the index into zKWText[] of the start of
172936 ** the text for the i-th keyword. */
172937 static const unsigned short int aKWOffset[147] = {
172938 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
172939 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
172940 86, 90, 90, 94, 99, 101, 105, 111, 119, 123, 123, 123, 126,
172941 129, 132, 137, 142, 146, 147, 152, 156, 160, 168, 174, 181, 184,
172942 184, 187, 189, 195, 198, 206, 211, 216, 219, 222, 226, 236, 239,
@@ -172947,11 +173108,11 @@
172947 520, 523, 527, 532, 539, 544, 553, 557, 560, 565, 567, 571, 579,
172948 585, 588, 597, 602, 610, 610, 614, 623, 628, 633, 639, 642, 645,
172949 648, 650, 655, 659,
172950 };
172951 /* aKWCode[i] is the parser symbol code for the i-th keyword */
172952 static const unsigned char aKWCode[147] = {
172953 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
172954 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
172955 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
172956 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
172957 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
@@ -173116,11 +173277,11 @@
173116 static int keywordCode(const char *z, int n, int *pType){
173117 int i, j;
173118 const char *zKW;
173119 if( n>=2 ){
173120 i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n*1) % 127;
173121 for(i=((int)aKWHash[i])-1; i>=0; i=((int)aKWNext[i])-1){
173122 if( aKWLen[i]!=n ) continue;
173123 zKW = &zKWText[aKWOffset[i]];
173124 #ifdef SQLITE_ASCII
173125 if( (z[0]&~0x20)!=zKW[0] ) continue;
173126 if( (z[1]&~0x20)!=zKW[1] ) continue;
@@ -173132,157 +173293,157 @@
173132 if( toupper(z[1])!=zKW[1] ) continue;
173133 j = 2;
173134 while( j<n && toupper(z[j])==zKW[j] ){ j++; }
173135 #endif
173136 if( j<n ) continue;
173137 testcase( i==0 ); /* REINDEX */
173138 testcase( i==1 ); /* INDEXED */
173139 testcase( i==2 ); /* INDEX */
173140 testcase( i==3 ); /* DESC */
173141 testcase( i==4 ); /* ESCAPE */
173142 testcase( i==5 ); /* EACH */
173143 testcase( i==6 ); /* CHECK */
173144 testcase( i==7 ); /* KEY */
173145 testcase( i==8 ); /* BEFORE */
173146 testcase( i==9 ); /* FOREIGN */
173147 testcase( i==10 ); /* FOR */
173148 testcase( i==11 ); /* IGNORE */
173149 testcase( i==12 ); /* REGEXP */
173150 testcase( i==13 ); /* EXPLAIN */
173151 testcase( i==14 ); /* INSTEAD */
173152 testcase( i==15 ); /* ADD */
173153 testcase( i==16 ); /* DATABASE */
173154 testcase( i==17 ); /* AS */
173155 testcase( i==18 ); /* SELECT */
173156 testcase( i==19 ); /* TABLE */
173157 testcase( i==20 ); /* LEFT */
173158 testcase( i==21 ); /* THEN */
173159 testcase( i==22 ); /* END */
173160 testcase( i==23 ); /* DEFERRABLE */
173161 testcase( i==24 ); /* ELSE */
173162 testcase( i==25 ); /* EXCLUDE */
173163 testcase( i==26 ); /* DELETE */
173164 testcase( i==27 ); /* TEMPORARY */
173165 testcase( i==28 ); /* TEMP */
173166 testcase( i==29 ); /* OR */
173167 testcase( i==30 ); /* ISNULL */
173168 testcase( i==31 ); /* NULLS */
173169 testcase( i==32 ); /* SAVEPOINT */
173170 testcase( i==33 ); /* INTERSECT */
173171 testcase( i==34 ); /* TIES */
173172 testcase( i==35 ); /* NOTNULL */
173173 testcase( i==36 ); /* NOT */
173174 testcase( i==37 ); /* NO */
173175 testcase( i==38 ); /* NULL */
173176 testcase( i==39 ); /* LIKE */
173177 testcase( i==40 ); /* EXCEPT */
173178 testcase( i==41 ); /* TRANSACTION */
173179 testcase( i==42 ); /* ACTION */
173180 testcase( i==43 ); /* ON */
173181 testcase( i==44 ); /* NATURAL */
173182 testcase( i==45 ); /* ALTER */
173183 testcase( i==46 ); /* RAISE */
173184 testcase( i==47 ); /* EXCLUSIVE */
173185 testcase( i==48 ); /* EXISTS */
173186 testcase( i==49 ); /* CONSTRAINT */
173187 testcase( i==50 ); /* INTO */
173188 testcase( i==51 ); /* OFFSET */
173189 testcase( i==52 ); /* OF */
173190 testcase( i==53 ); /* SET */
173191 testcase( i==54 ); /* TRIGGER */
173192 testcase( i==55 ); /* RANGE */
173193 testcase( i==56 ); /* GENERATED */
173194 testcase( i==57 ); /* DETACH */
173195 testcase( i==58 ); /* HAVING */
173196 testcase( i==59 ); /* GLOB */
173197 testcase( i==60 ); /* BEGIN */
173198 testcase( i==61 ); /* INNER */
173199 testcase( i==62 ); /* REFERENCES */
173200 testcase( i==63 ); /* UNIQUE */
173201 testcase( i==64 ); /* QUERY */
173202 testcase( i==65 ); /* WITHOUT */
173203 testcase( i==66 ); /* WITH */
173204 testcase( i==67 ); /* OUTER */
173205 testcase( i==68 ); /* RELEASE */
173206 testcase( i==69 ); /* ATTACH */
173207 testcase( i==70 ); /* BETWEEN */
173208 testcase( i==71 ); /* NOTHING */
173209 testcase( i==72 ); /* GROUPS */
173210 testcase( i==73 ); /* GROUP */
173211 testcase( i==74 ); /* CASCADE */
173212 testcase( i==75 ); /* ASC */
173213 testcase( i==76 ); /* DEFAULT */
173214 testcase( i==77 ); /* CASE */
173215 testcase( i==78 ); /* COLLATE */
173216 testcase( i==79 ); /* CREATE */
173217 testcase( i==80 ); /* CURRENT_DATE */
173218 testcase( i==81 ); /* IMMEDIATE */
173219 testcase( i==82 ); /* JOIN */
173220 testcase( i==83 ); /* INSERT */
173221 testcase( i==84 ); /* MATCH */
173222 testcase( i==85 ); /* PLAN */
173223 testcase( i==86 ); /* ANALYZE */
173224 testcase( i==87 ); /* PRAGMA */
173225 testcase( i==88 ); /* MATERIALIZED */
173226 testcase( i==89 ); /* DEFERRED */
173227 testcase( i==90 ); /* DISTINCT */
173228 testcase( i==91 ); /* IS */
173229 testcase( i==92 ); /* UPDATE */
173230 testcase( i==93 ); /* VALUES */
173231 testcase( i==94 ); /* VIRTUAL */
173232 testcase( i==95 ); /* ALWAYS */
173233 testcase( i==96 ); /* WHEN */
173234 testcase( i==97 ); /* WHERE */
173235 testcase( i==98 ); /* RECURSIVE */
173236 testcase( i==99 ); /* ABORT */
173237 testcase( i==100 ); /* AFTER */
173238 testcase( i==101 ); /* RENAME */
173239 testcase( i==102 ); /* AND */
173240 testcase( i==103 ); /* DROP */
173241 testcase( i==104 ); /* PARTITION */
173242 testcase( i==105 ); /* AUTOINCREMENT */
173243 testcase( i==106 ); /* TO */
173244 testcase( i==107 ); /* IN */
173245 testcase( i==108 ); /* CAST */
173246 testcase( i==109 ); /* COLUMN */
173247 testcase( i==110 ); /* COMMIT */
173248 testcase( i==111 ); /* CONFLICT */
173249 testcase( i==112 ); /* CROSS */
173250 testcase( i==113 ); /* CURRENT_TIMESTAMP */
173251 testcase( i==114 ); /* CURRENT_TIME */
173252 testcase( i==115 ); /* CURRENT */
173253 testcase( i==116 ); /* PRECEDING */
173254 testcase( i==117 ); /* FAIL */
173255 testcase( i==118 ); /* LAST */
173256 testcase( i==119 ); /* FILTER */
173257 testcase( i==120 ); /* REPLACE */
173258 testcase( i==121 ); /* FIRST */
173259 testcase( i==122 ); /* FOLLOWING */
173260 testcase( i==123 ); /* FROM */
173261 testcase( i==124 ); /* FULL */
173262 testcase( i==125 ); /* LIMIT */
173263 testcase( i==126 ); /* IF */
173264 testcase( i==127 ); /* ORDER */
173265 testcase( i==128 ); /* RESTRICT */
173266 testcase( i==129 ); /* OTHERS */
173267 testcase( i==130 ); /* OVER */
173268 testcase( i==131 ); /* RETURNING */
173269 testcase( i==132 ); /* RIGHT */
173270 testcase( i==133 ); /* ROLLBACK */
173271 testcase( i==134 ); /* ROWS */
173272 testcase( i==135 ); /* ROW */
173273 testcase( i==136 ); /* UNBOUNDED */
173274 testcase( i==137 ); /* UNION */
173275 testcase( i==138 ); /* USING */
173276 testcase( i==139 ); /* VACUUM */
173277 testcase( i==140 ); /* VIEW */
173278 testcase( i==141 ); /* WINDOW */
173279 testcase( i==142 ); /* DO */
173280 testcase( i==143 ); /* BY */
173281 testcase( i==144 ); /* INITIALLY */
173282 testcase( i==145 ); /* ALL */
173283 testcase( i==146 ); /* PRIMARY */
173284 *pType = aKWCode[i];
173285 break;
173286 }
173287 }
173288 return n;
@@ -173293,10 +173454,11 @@
173293 return id;
173294 }
173295 #define SQLITE_N_KEYWORD 147
173296 SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
173297 if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
 
173298 *pzName = zKWText + aKWOffset[i];
173299 *pnName = aKWLen[i];
173300 return SQLITE_OK;
173301 }
173302 SQLITE_API int sqlite3_keyword_count(void){ return SQLITE_N_KEYWORD; }
@@ -199991,10 +200153,31 @@
199991 int i;
199992 for(i=0; i<4; i++) if( !sqlite3Isxdigit(z[i]) ) return 0;
199993 return 1;
199994 }
199995
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199996 /*
199997 ** Parse a single JSON value which begins at pParse->zJson[i]. Return the
199998 ** index of the first character past the end of the value parsed.
199999 **
200000 ** Return negative for a syntax error. Special cases: return -2 if the
@@ -200136,10 +200319,28 @@
200136 c = z[j+1];
200137 }
200138 if( c<'0' || c>'9' ) return -1;
200139 continue;
200140 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200141 break;
200142 }
200143 if( z[j-1]<'0' ) return -1;
200144 jsonParseAddNode(pParse, seenDP ? JSON_REAL : JSON_INT,
200145 j - i, &z[i]);
@@ -200149,10 +200350,24 @@
200149 }else if( c==']' ){
200150 return -3; /* End of [...] */
200151 }else if( c==0 ){
200152 return 0; /* End of file */
200153 }else{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200154 return -1; /* Syntax error */
200155 }
200156 }
200157
200158 /*
@@ -212971,19 +213186,28 @@
212971
212972 iOff = (i64)(pFrame->iDbPage-1) * p->pgsz;
212973 p->rc = pDb->pMethods->xWrite(pDb, p->aBuf, p->pgsz, iOff);
212974 }
212975
 
 
 
 
 
212976
212977 /*
212978 ** Take an EXCLUSIVE lock on the database file. Return SQLITE_OK if
212979 ** successful, or an SQLite error code otherwise.
212980 */
212981 static int rbuLockDatabase(sqlite3 *db){
212982 int rc = SQLITE_OK;
212983 sqlite3_file *fd = 0;
212984 sqlite3_file_control(db, "main", SQLITE_FCNTL_FILE_POINTER, &fd);
 
 
 
 
212985
212986 if( fd->pMethods ){
212987 rc = fd->pMethods->xLock(fd, SQLITE_LOCK_SHARED);
212988 if( rc==SQLITE_OK ){
212989 rc = fd->pMethods->xLock(fd, SQLITE_LOCK_EXCLUSIVE);
@@ -216218,10 +216442,11 @@
216218 (void)argc;
216219 (void)argv;
216220 (void)pzErr;
216221
216222 sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY);
 
216223 rc = sqlite3_declare_vtab(db,
216224 "CREATE TABLE x(pgno INTEGER PRIMARY KEY, data BLOB, schema HIDDEN)");
216225 if( rc==SQLITE_OK ){
216226 pTab = (DbpageTable *)sqlite3_malloc64(sizeof(DbpageTable));
216227 if( pTab==0 ) rc = SQLITE_NOMEM_BKPT;
@@ -216301,11 +216526,10 @@
216301 && pIdxInfo->aOrderBy[0].iColumn<=0
216302 && pIdxInfo->aOrderBy[0].desc==0
216303 ){
216304 pIdxInfo->orderByConsumed = 1;
216305 }
216306 sqlite3VtabUsesAllSchemas(pIdxInfo);
216307 return SQLITE_OK;
216308 }
216309
216310 /*
216311 ** Open a new dbpagevfs cursor.
@@ -240797,11 +241021,11 @@
240797 int nArg, /* Number of args */
240798 sqlite3_value **apUnused /* Function arguments */
240799 ){
240800 assert( nArg==0 );
240801 UNUSED_PARAM2(nArg, apUnused);
240802 sqlite3_result_text(pCtx, "fts5: 2023-04-01 12:22:57 33ac62d8eec56eb71f20ccd28a5d6e4e8051522feb2db0199abee9e18ce1f64e", -1, SQLITE_TRANSIENT);
240803 }
240804
240805 /*
240806 ** Return true if zName is the extension on one of the shadow tables used
240807 ** by this module.
240808
--- 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.42.0"
456 #define SQLITE_VERSION_NUMBER 3042000
457 #define SQLITE_SOURCE_ID "2023-04-10 18:44:00 4c5a3c5fb351cc1c2ce16c33314ce19c53531f09263f87456283d9d756002f9d"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -2800,11 +2800,11 @@
2800 #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
2801 #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
2802 #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2803 #define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
2804 #define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
2805 #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
2806 #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2807 #define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
2808
2809 /*
2810 ** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -9910,22 +9910,32 @@
9910 ** </dd>
9911 **
9912 ** [[SQLITE_VTAB_INNOCUOUS]]<dt>SQLITE_VTAB_INNOCUOUS</dt>
9913 ** <dd>Calls of the form
9914 ** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the
9915 ** the [xConnect] or [xCreate] methods of a [virtual table] implementation
9916 ** identify that virtual table as being safe to use from within triggers
9917 ** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the
9918 ** virtual table can do no serious harm even if it is controlled by a
9919 ** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS
9920 ** flag unless absolutely necessary.
9921 ** </dd>
9922 **
9923 ** [[SQLITE_VTAB_USES_ALL_SCHEMAS]]<dt>SQLITE_VTAB_USES_ALL_SCHEMAS</dt>
9924 ** <dd>Calls of the form
9925 ** [sqlite3_vtab_config](db,SQLITE_VTAB_USES_ALL_SCHEMA) from within the
9926 ** the [xConnect] or [xCreate] methods of a [virtual table] implementation
9927 ** instruct the query planner to begin at least a read transaction on
9928 ** all schemas ("main", "temp", and any ATTACH-ed databases) whenever the
9929 ** virtual table is used.
9930 ** </dd>
9931 ** </dl>
9932 */
9933 #define SQLITE_VTAB_CONSTRAINT_SUPPORT 1
9934 #define SQLITE_VTAB_INNOCUOUS 2
9935 #define SQLITE_VTAB_DIRECTONLY 3
9936 #define SQLITE_VTAB_USES_ALL_SCHEMAS 4
9937
9938 /*
9939 ** CAPI3REF: Determine The Virtual Table Conflict Policy
9940 **
9941 ** This function may only be called from within a call to the [xUpdate] method
@@ -13629,19 +13639,26 @@
13639 # define SQLITE_INT_TO_PTR(X) ((void*)(X))
13640 # define SQLITE_PTR_TO_INT(X) ((int)(X))
13641 #endif
13642
13643 /*
13644 ** Macros to hint to the compiler that a function should or should not be
13645 ** inlined.
13646 */
13647 #if defined(__GNUC__)
13648 # define SQLITE_NOINLINE __attribute__((noinline))
13649 # define SQLITE_INLINE __attribute__((always_inline)) inline
13650 #elif defined(_MSC_VER) && _MSC_VER>=1310
13651 # define SQLITE_NOINLINE __declspec(noinline)
13652 # define SQLITE_INLINE __forceinline
13653 #else
13654 # define SQLITE_NOINLINE
13655 # define SQLITE_INLINE
13656 #endif
13657 #if defined(SQLITE_COVERAGE_TEST)
13658 # undef SQLITE_INLINE
13659 # define SQLITE_INLINE
13660 #endif
13661
13662 /*
13663 ** Make sure that the compiler intrinsics we desire are enabled when
13664 ** compiling with an appropriate version of MSVC unless prevented by
@@ -16597,10 +16614,14 @@
16614 #endif
16615
16616 #if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
16617 SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE*, int, VdbeOp*);
16618 #endif
16619
16620 #if defined(SQLITE_ENABLE_CURSOR_HINTS) && defined(SQLITE_DEBUG)
16621 SQLITE_PRIVATE int sqlite3CursorRangeHintExprCheck(Walker *pWalker, Expr *pExpr);
16622 #endif
16623
16624 #endif /* SQLITE_VDBE_H */
16625
16626 /************** End of vdbe.h ************************************************/
16627 /************** Continuing where we left off in sqliteInt.h ******************/
@@ -17862,10 +17883,11 @@
17883 sqlite3 *db; /* Database connection associated with this table */
17884 Module *pMod; /* Pointer to module implementation */
17885 sqlite3_vtab *pVtab; /* Pointer to vtab instance */
17886 int nRef; /* Number of pointers to this structure */
17887 u8 bConstraint; /* True if constraints are supported */
17888 u8 bAllSchemas; /* True if might use any attached schema */
17889 u8 eVtabRisk; /* Riskiness of allowing hacker access */
17890 int iSavepoint; /* Depth of the SAVEPOINT stack */
17891 VTable *pNext; /* Next in linked list (see above) */
17892 };
17893
@@ -19728,10 +19750,11 @@
19750 struct RenameCtx *pRename; /* RENAME COLUMN context */
19751 struct Table *pTab; /* Table of generated column */
19752 struct CoveringIndexCheck *pCovIdxCk; /* Check for covering index */
19753 SrcItem *pSrcItem; /* A single FROM clause item */
19754 DbFixer *pFix; /* See sqlite3FixSelect() */
19755 Mem *aMem; /* See sqlite3BtreeCursorHint() */
19756 } u;
19757 };
19758
19759 /*
19760 ** The following structure contains information used by the sqliteFix...
@@ -20890,14 +20913,11 @@
20913 SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
20914 SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
20915 SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
20916
20917 SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
20918 SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(Parse*);
 
 
 
20919 SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
20920 SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
20921 SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
20922 SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse*,sqlite3*);
20923 SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse*);
@@ -69500,12 +69520,29 @@
69520 ** and number of the varargs parameters) is determined by the eHintType
69521 ** parameter. See the definitions of the BTREE_HINT_* macros for details.
69522 */
69523 SQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor *pCur, int eHintType, ...){
69524 /* Used only by system that substitute their own storage engine */
69525 #ifdef SQLITE_DEBUG
69526 if( ALWAYS(eHintType==BTREE_HINT_RANGE) ){
69527 va_list ap;
69528 Expr *pExpr;
69529 Walker w;
69530 memset(&w, 0, sizeof(w));
69531 w.xExprCallback = sqlite3CursorRangeHintExprCheck;
69532 va_start(ap, eHintType);
69533 pExpr = va_arg(ap, Expr*);
69534 w.u.aMem = va_arg(ap, Mem*);
69535 va_end(ap);
69536 assert( pExpr!=0 );
69537 assert( w.u.aMem!=0 );
69538 sqlite3WalkExpr(&w, pExpr);
69539 }
69540 #endif /* SQLITE_DEBUG */
69541 }
69542 #endif /* SQLITE_ENABLE_CURSOR_HINTS */
69543
69544
69545 /*
69546 ** Provide flag hints to the cursor.
69547 */
69548 SQLITE_PRIVATE void sqlite3BtreeCursorHintFlags(BtCursor *pCur, unsigned x){
@@ -70300,11 +70337,11 @@
70337 ** all the space together, however. This routine will avoid using
70338 ** the first two bytes past the cell pointer area since presumably this
70339 ** allocation is being made in order to insert a new cell, so we will
70340 ** also end up needing a new cell pointer.
70341 */
70342 static SQLITE_INLINE int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
70343 const int hdr = pPage->hdrOffset; /* Local cache of pPage->hdrOffset */
70344 u8 * const data = pPage->aData; /* Local cache of pPage->aData */
70345 int top; /* First byte of cell content area */
70346 int rc = SQLITE_OK; /* Integer return code */
70347 u8 *pTmp; /* Temp ptr into data[] */
@@ -70326,17 +70363,18 @@
70363 ** then the cell content offset of an empty page wants to be 65536.
70364 ** However, that integer is too large to be stored in a 2-byte unsigned
70365 ** integer, so a value of 0 is used in its place. */
70366 pTmp = &data[hdr+5];
70367 top = get2byte(pTmp);
 
70368 if( gap>top ){
70369 if( top==0 && pPage->pBt->usableSize==65536 ){
70370 top = 65536;
70371 }else{
70372 return SQLITE_CORRUPT_PAGE(pPage);
70373 }
70374 }else if( top>(int)pPage->pBt->usableSize ){
70375 return SQLITE_CORRUPT_PAGE(pPage);
70376 }
70377
70378 /* If there is enough space between gap and top for one more cell pointer,
70379 ** and if the freelist is not empty, then search the
70380 ** freelist looking for a slot big enough to satisfy the request.
@@ -70415,11 +70453,11 @@
70453 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
70454 assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize );
70455 assert( CORRUPT_DB || iEnd <= pPage->pBt->usableSize );
70456 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
70457 assert( iSize>=4 ); /* Minimum cell size is 4 */
70458 assert( CORRUPT_DB || iStart<=pPage->pBt->usableSize-4 );
70459
70460 /* The list of freeblocks must be in ascending order. Find the
70461 ** spot on the list where iStart should be inserted.
70462 */
70463 hdr = pPage->hdrOffset;
@@ -70472,10 +70510,15 @@
70510 if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_PAGE(pPage);
70511 data[hdr+7] -= nFrag;
70512 }
70513 pTmp = &data[hdr+5];
70514 x = get2byte(pTmp);
70515 if( pPage->pBt->btsFlags & BTS_FAST_SECURE ){
70516 /* Overwrite deleted information with zeros when the secure_delete
70517 ** option is enabled */
70518 memset(&data[iStart], 0, iSize);
70519 }
70520 if( iStart<=x ){
70521 /* The new freeblock is at the beginning of the cell content area,
70522 ** so just extend the cell content area rather than create another
70523 ** freelist entry */
70524 if( iStart<x ) return SQLITE_CORRUPT_PAGE(pPage);
@@ -70483,18 +70526,13 @@
70526 put2byte(&data[hdr+1], iFreeBlk);
70527 put2byte(&data[hdr+5], iEnd);
70528 }else{
70529 /* Insert the new freeblock into the freelist */
70530 put2byte(&data[iPtr], iStart);
70531 put2byte(&data[iStart], iFreeBlk);
70532 put2byte(&data[iStart+2], iSize);
70533 }
 
 
 
 
 
70534 pPage->nFree += iOrigSize;
70535 return SQLITE_OK;
70536 }
70537
70538 /*
@@ -75649,10 +75687,18 @@
75687 ** pTemp is not null. Regardless of pTemp, allocate a new entry
75688 ** in pPage->apOvfl[] and make it point to the cell content (either
75689 ** in pTemp or the original pCell) and also record its index.
75690 ** Allocating a new entry in pPage->aCell[] implies that
75691 ** pPage->nOverflow is incremented.
75692 **
75693 ** The insertCellFast() routine below works exactly the same as
75694 ** insertCell() except that it lacks the pTemp and iChild parameters
75695 ** which are assumed zero. Other than that, the two routines are the
75696 ** same.
75697 **
75698 ** Fixes or enhancements to this routine should be reflected in
75699 ** insertCellFast()!
75700 */
75701 static int insertCell(
75702 MemPage *pPage, /* Page into which we are copying */
75703 int i, /* New cell becomes the i-th cell of the page */
75704 u8 *pCell, /* Content of the new cell */
@@ -75671,18 +75717,107 @@
75717 assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );
75718 assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );
75719 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
75720 assert( sz==pPage->xCellSize(pPage, pCell) || CORRUPT_DB );
75721 assert( pPage->nFree>=0 );
75722 assert( iChild>0 );
75723 if( pPage->nOverflow || sz+2>pPage->nFree ){
75724 if( pTemp ){
75725 memcpy(pTemp, pCell, sz);
75726 pCell = pTemp;
75727 }
75728 put4byte(pCell, iChild);
75729 j = pPage->nOverflow++;
75730 /* Comparison against ArraySize-1 since we hold back one extra slot
75731 ** as a contingency. In other words, never need more than 3 overflow
75732 ** slots but 4 are allocated, just to be safe. */
75733 assert( j < ArraySize(pPage->apOvfl)-1 );
75734 pPage->apOvfl[j] = pCell;
75735 pPage->aiOvfl[j] = (u16)i;
75736
75737 /* When multiple overflows occur, they are always sequential and in
75738 ** sorted order. This invariants arise because multiple overflows can
75739 ** only occur when inserting divider cells into the parent page during
75740 ** balancing, and the dividers are adjacent and sorted.
75741 */
75742 assert( j==0 || pPage->aiOvfl[j-1]<(u16)i ); /* Overflows in sorted order */
75743 assert( j==0 || i==pPage->aiOvfl[j-1]+1 ); /* Overflows are sequential */
75744 }else{
75745 int rc = sqlite3PagerWrite(pPage->pDbPage);
75746 if( NEVER(rc!=SQLITE_OK) ){
75747 return rc;
75748 }
75749 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
75750 data = pPage->aData;
75751 assert( &data[pPage->cellOffset]==pPage->aCellIdx );
75752 rc = allocateSpace(pPage, sz, &idx);
75753 if( rc ){ return rc; }
75754 /* The allocateSpace() routine guarantees the following properties
75755 ** if it returns successfully */
75756 assert( idx >= 0 );
75757 assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );
75758 assert( idx+sz <= (int)pPage->pBt->usableSize );
75759 pPage->nFree -= (u16)(2 + sz);
75760 /* In a corrupt database where an entry in the cell index section of
75761 ** a btree page has a value of 3 or less, the pCell value might point
75762 ** as many as 4 bytes in front of the start of the aData buffer for
75763 ** the source page. Make sure this does not cause problems by not
75764 ** reading the first 4 bytes */
75765 memcpy(&data[idx+4], pCell+4, sz-4);
75766 put4byte(&data[idx], iChild);
75767 pIns = pPage->aCellIdx + i*2;
75768 memmove(pIns+2, pIns, 2*(pPage->nCell - i));
75769 put2byte(pIns, idx);
75770 pPage->nCell++;
75771 /* increment the cell count */
75772 if( (++data[pPage->hdrOffset+4])==0 ) data[pPage->hdrOffset+3]++;
75773 assert( get2byte(&data[pPage->hdrOffset+3])==pPage->nCell || CORRUPT_DB );
75774 #ifndef SQLITE_OMIT_AUTOVACUUM
75775 if( pPage->pBt->autoVacuum ){
75776 int rc2 = SQLITE_OK;
75777 /* The cell may contain a pointer to an overflow page. If so, write
75778 ** the entry for the overflow page into the pointer map.
75779 */
75780 ptrmapPutOvflPtr(pPage, pPage, pCell, &rc2);
75781 if( rc2 ) return rc2;
75782 }
75783 #endif
75784 }
75785 return SQLITE_OK;
75786 }
75787
75788 /*
75789 ** This variant of insertCell() assumes that the pTemp and iChild
75790 ** parameters are both zero. Use this variant in sqlite3BtreeInsert()
75791 ** for performance improvement, and also so that this variant is only
75792 ** called from that one place, and is thus inlined, and thus runs must
75793 ** faster.
75794 **
75795 ** Fixes or enhancements to this routine should be reflected into
75796 ** the insertCell() routine.
75797 */
75798 static int insertCellFast(
75799 MemPage *pPage, /* Page into which we are copying */
75800 int i, /* New cell becomes the i-th cell of the page */
75801 u8 *pCell, /* Content of the new cell */
75802 int sz /* Bytes of content in pCell */
75803 ){
75804 int idx = 0; /* Where to write new cell content in data[] */
75805 int j; /* Loop counter */
75806 u8 *data; /* The content of the whole page */
75807 u8 *pIns; /* The point in pPage->aCellIdx[] where no cell inserted */
75808
75809 assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );
75810 assert( MX_CELL(pPage->pBt)<=10921 );
75811 assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB );
75812 assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );
75813 assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );
75814 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
75815 assert( sz==pPage->xCellSize(pPage, pCell) || CORRUPT_DB );
75816 assert( pPage->nFree>=0 );
75817 assert( pPage->nOverflow==0 );
75818 if( sz+2>pPage->nFree ){
75819 j = pPage->nOverflow++;
75820 /* Comparison against ArraySize-1 since we hold back one extra slot
75821 ** as a contingency. In other words, never need more than 3 overflow
75822 ** slots but 4 are allocated, just to be safe. */
75823 assert( j < ArraySize(pPage->apOvfl)-1 );
@@ -75710,21 +75845,11 @@
75845 ** if it returns successfully */
75846 assert( idx >= 0 );
75847 assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );
75848 assert( idx+sz <= (int)pPage->pBt->usableSize );
75849 pPage->nFree -= (u16)(2 + sz);
75850 memcpy(&data[idx], pCell, sz);
 
 
 
 
 
 
 
 
 
 
75851 pIns = pPage->aCellIdx + i*2;
75852 memmove(pIns+2, pIns, 2*(pPage->nCell - i));
75853 put2byte(pIns, idx);
75854 pPage->nCell++;
75855 /* increment the cell count */
@@ -75905,11 +76030,11 @@
76030 int k; /* Current slot in pCArray->apEnd[] */
76031 u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */
76032
76033 assert( i<iEnd );
76034 j = get2byte(&aData[hdr+5]);
76035 if( NEVER(j>(u32)usableSize) ){ j = 0; }
76036 memcpy(&pTmp[j], &aData[j], usableSize - j);
76037
76038 for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
76039 pSrcEnd = pCArray->apEnd[k];
76040
@@ -76049,46 +76174,54 @@
76174 ){
76175 u8 * const aData = pPg->aData;
76176 u8 * const pEnd = &aData[pPg->pBt->usableSize];
76177 u8 * const pStart = &aData[pPg->hdrOffset + 8 + pPg->childPtrSize];
76178 int nRet = 0;
76179 int i, j;
76180 int iEnd = iFirst + nCell;
76181 int nFree = 0;
76182 int aOfst[10];
76183 int aAfter[10];
76184
76185 for(i=iFirst; i<iEnd; i++){
76186 u8 *pCell = pCArray->apCell[i];
76187 if( SQLITE_WITHIN(pCell, pStart, pEnd) ){
76188 int sz;
76189 int iAfter;
76190 int iOfst;
76191 /* No need to use cachedCellSize() here. The sizes of all cells that
76192 ** are to be freed have already been computing while deciding which
76193 ** cells need freeing */
76194 sz = pCArray->szCell[i]; assert( sz>0 );
76195 iOfst = (u16)(pCell - aData);
76196 iAfter = iOfst+sz;
76197 for(j=0; j<nFree; j++){
76198 if( aOfst[j]==iAfter ){
76199 aOfst[j] = iOfst;
76200 break;
76201 }else if( aAfter[j]==iOfst ){
76202 aAfter[j] = iAfter;
76203 break;
76204 }
76205 }
76206 if( j>=nFree ){
76207 if( nFree>=sizeof(aOfst)/sizeof(aOfst[0]) ){
76208 for(j=0; j<nFree; j++){
76209 freeSpace(pPg, aOfst[j], aAfter[j]-aOfst[j]);
76210 }
76211 nFree = 0;
76212 }
76213 aOfst[nFree] = iOfst;
76214 aAfter[nFree] = iAfter;
76215 if( &aData[iAfter]>pEnd ) return 0;
76216 nFree++;
76217 }
76218 nRet++;
76219 }
76220 }
76221 for(j=0; j<nFree; j++){
76222 freeSpace(pPg, aOfst[j], aAfter[j]-aOfst[j]);
 
76223 }
76224 return nRet;
76225 }
76226
76227 /*
@@ -76139,11 +76272,11 @@
76272 nCell -= nTail;
76273 }
76274
76275 pData = &aData[get2byteNotZero(&aData[hdr+5])];
76276 if( pData<pBegin ) goto editpage_fail;
76277 if( NEVER(pData>pPg->aDataEnd) ) goto editpage_fail;
76278
76279 /* Add cells to the start of the page */
76280 if( iNew<iOld ){
76281 int nAdd = MIN(nNew,iOld-iNew);
76282 assert( (iOld-iNew)<nNew || nCell==0 || CORRUPT_DB );
@@ -77865,11 +77998,11 @@
77998 idx = ++pCur->ix;
77999 pCur->curFlags &= ~BTCF_ValidNKey;
78000 }else{
78001 assert( pPage->leaf );
78002 }
78003 rc = insertCellFast(pPage, idx, newCell, szNew);
78004 assert( pPage->nOverflow==0 || rc==SQLITE_OK );
78005 assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );
78006
78007 /* If no error has occurred and pPage has an overflow cell, call balance()
78008 ** to redistribute the cells within the tree. Since balance() may move
@@ -78088,10 +78221,13 @@
78221 return SQLITE_CORRUPT_BKPT;
78222 }
78223 pCell = findCell(pPage, iCellIdx);
78224 if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ){
78225 return SQLITE_CORRUPT_BKPT;
78226 }
78227 if( pCell<&pPage->aCellIdx[pPage->nCell] ){
78228 return SQLITE_CORRUPT_BKPT;
78229 }
78230
78231 /* If the BTREE_SAVEPOSITION bit is on, then the cursor position must
78232 ** be preserved following this delete operation. If the current delete
78233 ** will cause a b-tree rebalance, then this is done by saving the cursor
@@ -80991,11 +81127,11 @@
81127 return SQLITE_NOMEM_BKPT;
81128 }
81129
81130 vdbeMemRenderNum(nByte, pMem->z, pMem);
81131 assert( pMem->z!=0 );
81132 assert( pMem->n==(int)sqlite3Strlen30NN(pMem->z) );
81133 pMem->enc = SQLITE_UTF8;
81134 pMem->flags |= MEM_Str|MEM_Term;
81135 if( bForce ) pMem->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal);
81136 sqlite3VdbeChangeEncoding(pMem, enc);
81137 return SQLITE_OK;
@@ -82035,10 +82171,13 @@
82171 assert( ExprUseXList(p) );
82172 pList = p->x.pList;
82173 if( pList ) nVal = pList->nExpr;
82174 assert( !ExprHasProperty(p, EP_IntValue) );
82175 pFunc = sqlite3FindFunction(db, p->u.zToken, nVal, enc, 0);
82176 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
82177 if( pFunc==0 ) return SQLITE_OK;
82178 #endif
82179 assert( pFunc );
82180 if( (pFunc->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0
82181 || (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)
82182 ){
82183 return SQLITE_OK;
@@ -85875,10 +86014,12 @@
86014 db->nDeferredCons = 0;
86015 db->nDeferredImmCons = 0;
86016 db->flags &= ~(u64)SQLITE_DeferFKs;
86017 sqlite3CommitInternalChanges(db);
86018 }
86019 }else if( p->rc==SQLITE_SCHEMA && db->nVdbeActive>1 ){
86020 p->nChange = 0;
86021 }else{
86022 sqlite3RollbackAll(db, SQLITE_OK);
86023 p->nChange = 0;
86024 }
86025 db->nStatement = 0;
@@ -87822,10 +87963,24 @@
87963 return 0;
87964 }
87965 return 1;
87966 }
87967
87968 #if defined(SQLITE_ENABLE_CURSOR_HINTS) && defined(SQLITE_DEBUG)
87969 /*
87970 ** This Walker callback is used to help verify that calls to
87971 ** sqlite3BtreeCursorHint() with opcode BTREE_HINT_RANGE have
87972 ** byte-code register values correctly initialized.
87973 */
87974 SQLITE_PRIVATE int sqlite3CursorRangeHintExprCheck(Walker *pWalker, Expr *pExpr){
87975 if( pExpr->op==TK_REGISTER ){
87976 assert( (pWalker->u.aMem[pExpr->iTable].flags & MEM_Undefined)==0 );
87977 }
87978 return WRC_Continue;
87979 }
87980 #endif /* SQLITE_ENABLE_CURSOR_HINTS && SQLITE_DEBUG */
87981
87982 #ifndef SQLITE_OMIT_VIRTUALTABLE
87983 /*
87984 ** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored
87985 ** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored
87986 ** in memory obtained from sqlite3DbMalloc).
@@ -88208,11 +88363,11 @@
88363 SQLITE_NULL, /* 0x1d (not possible) */
88364 SQLITE_INTEGER, /* 0x1e (not possible) */
88365 SQLITE_NULL, /* 0x1f (not possible) */
88366 SQLITE_FLOAT, /* 0x20 INTREAL */
88367 SQLITE_NULL, /* 0x21 (not possible) */
88368 SQLITE_FLOAT, /* 0x22 INTREAL + TEXT */
88369 SQLITE_NULL, /* 0x23 (not possible) */
88370 SQLITE_FLOAT, /* 0x24 (not possible) */
88371 SQLITE_NULL, /* 0x25 (not possible) */
88372 SQLITE_FLOAT, /* 0x26 (not possible) */
88373 SQLITE_NULL, /* 0x27 (not possible) */
@@ -106208,15 +106363,14 @@
106363 if( p->pLeft && (p->pLeft->flags & EP_Collate)!=0 ){
106364 p = p->pLeft;
106365 }else{
106366 Expr *pNext = p->pRight;
106367 /* The Expr.x union is never used at the same time as Expr.pRight */
106368 assert( !ExprUseXList(p) || p->x.pList==0 || p->pRight==0 );
106369 if( ExprUseXList(p) && p->x.pList!=0 && !db->mallocFailed ){
 
106370 int i;
106371 for(i=0; i<p->x.pList->nExpr; i++){
106372 if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){
106373 pNext = p->x.pList->a[i].pExpr;
106374 break;
106375 }
106376 }
@@ -108866,11 +109020,10 @@
109020 Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i);
109021 Expr *pRhs = pEList->a[i].pExpr;
109022 CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);
109023 int j;
109024
 
109025 for(j=0; j<nExpr; j++){
109026 if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;
109027 assert( pIdx->azColl[j] );
109028 if( pReq!=0 && sqlite3StrICmp(pReq->zName, pIdx->azColl[j])!=0 ){
109029 continue;
@@ -111031,11 +111184,13 @@
111184 assert( pParse->pVdbe!=0 || pParse->db->mallocFailed );
111185 if( pParse->pVdbe==0 ) return;
111186 inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
111187 if( inReg!=target ){
111188 u8 op;
111189 if( ALWAYS(pExpr)
111190 && (ExprHasProperty(pExpr,EP_Subquery) || pExpr->op==TK_REGISTER)
111191 ){
111192 op = OP_Copy;
111193 }else{
111194 op = OP_SCopy;
111195 }
111196 sqlite3VdbeAddOp2(pParse->pVdbe, op, inReg, target);
@@ -112218,11 +112373,11 @@
112373 int iAgg = pExpr->iAgg;
112374 Parse *pParse = pWalker->pParse;
112375 sqlite3 *db = pParse->db;
112376 assert( iAgg>=0 );
112377 if( pExpr->op!=TK_AGG_FUNCTION ){
112378 if( ALWAYS(iAgg<pAggInfo->nColumn)
112379 && pAggInfo->aCol[iAgg].pCExpr==pExpr
112380 ){
112381 pExpr = sqlite3ExprDup(db, pExpr, 0);
112382 if( pExpr ){
112383 pAggInfo->aCol[iAgg].pCExpr = pExpr;
@@ -112381,11 +112536,15 @@
112536 if( iDataCur<0 ) continue;
112537 if( sqlite3ExprCompare(0, pExpr, pIEpr->pExpr, iDataCur)==0 ) break;
112538 }
112539 if( pIEpr==0 ) break;
112540 if( NEVER(!ExprUseYTab(pExpr)) ) break;
112541 for(i=0; i<pSrcList->nSrc; i++){
112542 if( pSrcList->a[0].iCursor==pIEpr->iDataCur ) break;
112543 }
112544 if( i>=pSrcList->nSrc ) break;
112545 if( NEVER(pExpr->pAggInfo!=0) ) break; /* Resolved by outer context */
112546 if( pParse->nErr ){ return WRC_Abort; }
112547
112548 /* If we reach this point, it means that expression pExpr can be
112549 ** translated into a reference to an index column as described by
112550 ** pIEpr.
@@ -145087,16 +145246,17 @@
145246 if( pExpr->pAggInfo==0 ) return WRC_Continue;
145247 if( pExpr->op==TK_AGG_COLUMN ) return WRC_Continue;
145248 if( pExpr->op==TK_AGG_FUNCTION ) return WRC_Continue;
145249 if( pExpr->op==TK_IF_NULL_ROW ) return WRC_Continue;
145250 pAggInfo = pExpr->pAggInfo;
145251 if( NEVER(pExpr->iAgg>=pAggInfo->nColumn) ) return WRC_Continue;
145252 assert( pExpr->iAgg>=0 );
145253 pCol = &pAggInfo->aCol[pExpr->iAgg];
145254 pExpr->op = TK_AGG_COLUMN;
145255 pExpr->iTable = pCol->iTable;
145256 pExpr->iColumn = pCol->iColumn;
145257 ExprClearProperty(pExpr, EP_Skip|EP_Collate);
145258 return WRC_Prune;
145259 }
145260
145261 /*
145262 ** Convert every pAggInfo->aFunc[].pExpr such that any node within
@@ -152012,10 +152172,14 @@
152172 break;
152173 }
152174 case SQLITE_VTAB_DIRECTONLY: {
152175 p->pVTable->eVtabRisk = SQLITE_VTABRISK_High;
152176 break;
152177 }
152178 case SQLITE_VTAB_USES_ALL_SCHEMAS: {
152179 p->pVTable->bAllSchemas = 1;
152180 break;
152181 }
152182 default: {
152183 rc = SQLITE_MISUSE_BKPT;
152184 break;
152185 }
@@ -153686,31 +153850,29 @@
153850 ** know because CCurHint.pIdx!=0) then transform the TK_COLUMN into
153851 ** an access of the index rather than the original table.
153852 */
153853 static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){
153854 int rc = WRC_Continue;
153855 int reg;
153856 struct CCurHint *pHint = pWalker->u.pCCurHint;
153857 if( pExpr->op==TK_COLUMN ){
153858 if( pExpr->iTable!=pHint->iTabCur ){
153859 reg = ++pWalker->pParse->nMem; /* Register for column value */
153860 reg = sqlite3ExprCodeTarget(pWalker->pParse, pExpr, reg);
153861 pExpr->op = TK_REGISTER;
153862 pExpr->iTable = reg;
153863 }else if( pHint->pIdx!=0 ){
153864 pExpr->iTable = pHint->iIdxCur;
153865 pExpr->iColumn = sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn);
153866 assert( pExpr->iColumn>=0 );
153867 }
153868 }else if( pExpr->pAggInfo ){
 
 
 
 
 
 
 
153869 rc = WRC_Prune;
153870 reg = ++pWalker->pParse->nMem; /* Register for column value */
153871 reg = sqlite3ExprCodeTarget(pWalker->pParse, pExpr, reg);
153872 pExpr->op = TK_REGISTER;
153873 pExpr->iTable = reg;
153874 }
153875 return rc;
153876 }
153877
153878 /*
@@ -158823,10 +158985,13 @@
158985 sqlite3ErrorMsg(pParse, "%s", sqlite3ErrStr(rc));
158986 }else{
158987 sqlite3ErrorMsg(pParse, "%s", pVtab->zErrMsg);
158988 }
158989 }
158990 if( pTab->u.vtab.p->bAllSchemas ){
158991 sqlite3VtabUsesAllSchemas(pParse);
158992 }
158993 sqlite3_free(pVtab->zErrMsg);
158994 pVtab->zErrMsg = 0;
158995 return rc;
158996 }
158997 #endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */
@@ -159353,11 +159518,11 @@
159518 #else
159519 UNUSED_PARAMETER(pParse);
159520 UNUSED_PARAMETER(pBuilder);
159521 assert( pLower || pUpper );
159522 #endif
159523 assert( pUpper==0 || (pUpper->wtFlags & TERM_VNULL)==0 || pParse->nErr>0 );
159524 nNew = whereRangeAdjust(pLower, nOut);
159525 nNew = whereRangeAdjust(pUpper, nNew);
159526
159527 /* TUNING: If there is both an upper and lower limit and neither limit
159528 ** has an application-defined likelihood(), assume the range is
@@ -161454,24 +161619,20 @@
161619 HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
161620 assert( pHidden->eDistinct>=0 && pHidden->eDistinct<=3 );
161621 return pHidden->eDistinct;
161622 }
161623
 
 
161624 /*
161625 ** Cause the prepared statement that is associated with a call to
161626 ** xBestIndex to potentially use all schemas. If the statement being
161627 ** prepared is read-only, then just start read transactions on all
161628 ** schemas. But if this is a write operation, start writes on all
161629 ** schemas.
161630 **
161631 ** This is used by the (built-in) sqlite_dbpage virtual table.
161632 */
161633 SQLITE_PRIVATE void sqlite3VtabUsesAllSchemas(Parse *pParse){
 
 
161634 int nDb = pParse->db->nDb;
161635 int i;
161636 for(i=0; i<nDb; i++){
161637 sqlite3CodeVerifySchema(pParse, i);
161638 }
@@ -161479,11 +161640,10 @@
161640 for(i=0; i<nDb; i++){
161641 sqlite3BeginWriteOperation(pParse, 0, i);
161642 }
161643 }
161644 }
 
161645
161646 /*
161647 ** Add all WhereLoop objects for a table of the join identified by
161648 ** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
161649 **
@@ -164036,11 +164196,12 @@
164196 }
164197 }
164198 k = pLevel->addrBody + 1;
164199 #ifdef SQLITE_DEBUG
164200 if( db->flags & SQLITE_VdbeAddopTrace ){
164201 printf("TRANSLATE cursor %d->%d in opcode range %d..%d\n",
164202 pLevel->iTabCur, pLevel->iIdxCur, k, last-1);
164203 }
164204 /* Proof that the "+1" on the k value above is safe */
164205 pOp = sqlite3VdbeGetOp(v, k - 1);
164206 assert( pOp->opcode!=OP_Column || pOp->p1!=pLevel->iTabCur );
164207 assert( pOp->opcode!=OP_Rowid || pOp->p1!=pLevel->iTabCur );
@@ -172901,11 +173062,11 @@
173062 132, 0, 98, 38, 39, 0, 20, 45, 117, 93,
173063 };
173064 /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
173065 ** then the i-th keyword has no more hash collisions. Otherwise,
173066 ** the next keyword with the same hash is aKWHash[i]-1. */
173067 static const unsigned char aKWNext[148] = {0,
173068 0, 0, 0, 0, 4, 0, 43, 0, 0, 106, 114, 0, 0,
173069 0, 2, 0, 0, 143, 0, 0, 0, 13, 0, 0, 0, 0,
173070 141, 0, 0, 119, 52, 0, 0, 137, 12, 0, 0, 62, 0,
173071 138, 0, 133, 0, 0, 36, 0, 0, 28, 77, 0, 0, 0,
173072 0, 59, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -172916,11 +173077,11 @@
173077 112, 21, 7, 67, 0, 79, 96, 118, 0, 0, 68, 0, 0,
173078 99, 44, 0, 55, 0, 76, 0, 95, 32, 33, 57, 25, 0,
173079 102, 0, 0, 87,
173080 };
173081 /* aKWLen[i] is the length (in bytes) of the i-th keyword */
173082 static const unsigned char aKWLen[148] = {0,
173083 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
173084 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 7,
173085 6, 9, 4, 2, 6, 5, 9, 9, 4, 7, 3, 2, 4,
173086 4, 6, 11, 6, 2, 7, 5, 5, 9, 6, 10, 4, 6,
173087 2, 3, 7, 5, 9, 6, 6, 4, 5, 5, 10, 6, 5,
@@ -172932,11 +173093,11 @@
173093 4, 9, 5, 8, 4, 3, 9, 5, 5, 6, 4, 6, 2,
173094 2, 9, 3, 7,
173095 };
173096 /* aKWOffset[i] is the index into zKWText[] of the start of
173097 ** the text for the i-th keyword. */
173098 static const unsigned short int aKWOffset[148] = {0,
173099 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
173100 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
173101 86, 90, 90, 94, 99, 101, 105, 111, 119, 123, 123, 123, 126,
173102 129, 132, 137, 142, 146, 147, 152, 156, 160, 168, 174, 181, 184,
173103 184, 187, 189, 195, 198, 206, 211, 216, 219, 222, 226, 236, 239,
@@ -172947,11 +173108,11 @@
173108 520, 523, 527, 532, 539, 544, 553, 557, 560, 565, 567, 571, 579,
173109 585, 588, 597, 602, 610, 610, 614, 623, 628, 633, 639, 642, 645,
173110 648, 650, 655, 659,
173111 };
173112 /* aKWCode[i] is the parser symbol code for the i-th keyword */
173113 static const unsigned char aKWCode[148] = {0,
173114 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
173115 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
173116 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
173117 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
173118 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
@@ -173116,11 +173277,11 @@
173277 static int keywordCode(const char *z, int n, int *pType){
173278 int i, j;
173279 const char *zKW;
173280 if( n>=2 ){
173281 i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n*1) % 127;
173282 for(i=(int)aKWHash[i]; i>0; i=aKWNext[i]){
173283 if( aKWLen[i]!=n ) continue;
173284 zKW = &zKWText[aKWOffset[i]];
173285 #ifdef SQLITE_ASCII
173286 if( (z[0]&~0x20)!=zKW[0] ) continue;
173287 if( (z[1]&~0x20)!=zKW[1] ) continue;
@@ -173132,157 +173293,157 @@
173293 if( toupper(z[1])!=zKW[1] ) continue;
173294 j = 2;
173295 while( j<n && toupper(z[j])==zKW[j] ){ j++; }
173296 #endif
173297 if( j<n ) continue;
173298 testcase( i==1 ); /* REINDEX */
173299 testcase( i==2 ); /* INDEXED */
173300 testcase( i==3 ); /* INDEX */
173301 testcase( i==4 ); /* DESC */
173302 testcase( i==5 ); /* ESCAPE */
173303 testcase( i==6 ); /* EACH */
173304 testcase( i==7 ); /* CHECK */
173305 testcase( i==8 ); /* KEY */
173306 testcase( i==9 ); /* BEFORE */
173307 testcase( i==10 ); /* FOREIGN */
173308 testcase( i==11 ); /* FOR */
173309 testcase( i==12 ); /* IGNORE */
173310 testcase( i==13 ); /* REGEXP */
173311 testcase( i==14 ); /* EXPLAIN */
173312 testcase( i==15 ); /* INSTEAD */
173313 testcase( i==16 ); /* ADD */
173314 testcase( i==17 ); /* DATABASE */
173315 testcase( i==18 ); /* AS */
173316 testcase( i==19 ); /* SELECT */
173317 testcase( i==20 ); /* TABLE */
173318 testcase( i==21 ); /* LEFT */
173319 testcase( i==22 ); /* THEN */
173320 testcase( i==23 ); /* END */
173321 testcase( i==24 ); /* DEFERRABLE */
173322 testcase( i==25 ); /* ELSE */
173323 testcase( i==26 ); /* EXCLUDE */
173324 testcase( i==27 ); /* DELETE */
173325 testcase( i==28 ); /* TEMPORARY */
173326 testcase( i==29 ); /* TEMP */
173327 testcase( i==30 ); /* OR */
173328 testcase( i==31 ); /* ISNULL */
173329 testcase( i==32 ); /* NULLS */
173330 testcase( i==33 ); /* SAVEPOINT */
173331 testcase( i==34 ); /* INTERSECT */
173332 testcase( i==35 ); /* TIES */
173333 testcase( i==36 ); /* NOTNULL */
173334 testcase( i==37 ); /* NOT */
173335 testcase( i==38 ); /* NO */
173336 testcase( i==39 ); /* NULL */
173337 testcase( i==40 ); /* LIKE */
173338 testcase( i==41 ); /* EXCEPT */
173339 testcase( i==42 ); /* TRANSACTION */
173340 testcase( i==43 ); /* ACTION */
173341 testcase( i==44 ); /* ON */
173342 testcase( i==45 ); /* NATURAL */
173343 testcase( i==46 ); /* ALTER */
173344 testcase( i==47 ); /* RAISE */
173345 testcase( i==48 ); /* EXCLUSIVE */
173346 testcase( i==49 ); /* EXISTS */
173347 testcase( i==50 ); /* CONSTRAINT */
173348 testcase( i==51 ); /* INTO */
173349 testcase( i==52 ); /* OFFSET */
173350 testcase( i==53 ); /* OF */
173351 testcase( i==54 ); /* SET */
173352 testcase( i==55 ); /* TRIGGER */
173353 testcase( i==56 ); /* RANGE */
173354 testcase( i==57 ); /* GENERATED */
173355 testcase( i==58 ); /* DETACH */
173356 testcase( i==59 ); /* HAVING */
173357 testcase( i==60 ); /* GLOB */
173358 testcase( i==61 ); /* BEGIN */
173359 testcase( i==62 ); /* INNER */
173360 testcase( i==63 ); /* REFERENCES */
173361 testcase( i==64 ); /* UNIQUE */
173362 testcase( i==65 ); /* QUERY */
173363 testcase( i==66 ); /* WITHOUT */
173364 testcase( i==67 ); /* WITH */
173365 testcase( i==68 ); /* OUTER */
173366 testcase( i==69 ); /* RELEASE */
173367 testcase( i==70 ); /* ATTACH */
173368 testcase( i==71 ); /* BETWEEN */
173369 testcase( i==72 ); /* NOTHING */
173370 testcase( i==73 ); /* GROUPS */
173371 testcase( i==74 ); /* GROUP */
173372 testcase( i==75 ); /* CASCADE */
173373 testcase( i==76 ); /* ASC */
173374 testcase( i==77 ); /* DEFAULT */
173375 testcase( i==78 ); /* CASE */
173376 testcase( i==79 ); /* COLLATE */
173377 testcase( i==80 ); /* CREATE */
173378 testcase( i==81 ); /* CURRENT_DATE */
173379 testcase( i==82 ); /* IMMEDIATE */
173380 testcase( i==83 ); /* JOIN */
173381 testcase( i==84 ); /* INSERT */
173382 testcase( i==85 ); /* MATCH */
173383 testcase( i==86 ); /* PLAN */
173384 testcase( i==87 ); /* ANALYZE */
173385 testcase( i==88 ); /* PRAGMA */
173386 testcase( i==89 ); /* MATERIALIZED */
173387 testcase( i==90 ); /* DEFERRED */
173388 testcase( i==91 ); /* DISTINCT */
173389 testcase( i==92 ); /* IS */
173390 testcase( i==93 ); /* UPDATE */
173391 testcase( i==94 ); /* VALUES */
173392 testcase( i==95 ); /* VIRTUAL */
173393 testcase( i==96 ); /* ALWAYS */
173394 testcase( i==97 ); /* WHEN */
173395 testcase( i==98 ); /* WHERE */
173396 testcase( i==99 ); /* RECURSIVE */
173397 testcase( i==100 ); /* ABORT */
173398 testcase( i==101 ); /* AFTER */
173399 testcase( i==102 ); /* RENAME */
173400 testcase( i==103 ); /* AND */
173401 testcase( i==104 ); /* DROP */
173402 testcase( i==105 ); /* PARTITION */
173403 testcase( i==106 ); /* AUTOINCREMENT */
173404 testcase( i==107 ); /* TO */
173405 testcase( i==108 ); /* IN */
173406 testcase( i==109 ); /* CAST */
173407 testcase( i==110 ); /* COLUMN */
173408 testcase( i==111 ); /* COMMIT */
173409 testcase( i==112 ); /* CONFLICT */
173410 testcase( i==113 ); /* CROSS */
173411 testcase( i==114 ); /* CURRENT_TIMESTAMP */
173412 testcase( i==115 ); /* CURRENT_TIME */
173413 testcase( i==116 ); /* CURRENT */
173414 testcase( i==117 ); /* PRECEDING */
173415 testcase( i==118 ); /* FAIL */
173416 testcase( i==119 ); /* LAST */
173417 testcase( i==120 ); /* FILTER */
173418 testcase( i==121 ); /* REPLACE */
173419 testcase( i==122 ); /* FIRST */
173420 testcase( i==123 ); /* FOLLOWING */
173421 testcase( i==124 ); /* FROM */
173422 testcase( i==125 ); /* FULL */
173423 testcase( i==126 ); /* LIMIT */
173424 testcase( i==127 ); /* IF */
173425 testcase( i==128 ); /* ORDER */
173426 testcase( i==129 ); /* RESTRICT */
173427 testcase( i==130 ); /* OTHERS */
173428 testcase( i==131 ); /* OVER */
173429 testcase( i==132 ); /* RETURNING */
173430 testcase( i==133 ); /* RIGHT */
173431 testcase( i==134 ); /* ROLLBACK */
173432 testcase( i==135 ); /* ROWS */
173433 testcase( i==136 ); /* ROW */
173434 testcase( i==137 ); /* UNBOUNDED */
173435 testcase( i==138 ); /* UNION */
173436 testcase( i==139 ); /* USING */
173437 testcase( i==140 ); /* VACUUM */
173438 testcase( i==141 ); /* VIEW */
173439 testcase( i==142 ); /* WINDOW */
173440 testcase( i==143 ); /* DO */
173441 testcase( i==144 ); /* BY */
173442 testcase( i==145 ); /* INITIALLY */
173443 testcase( i==146 ); /* ALL */
173444 testcase( i==147 ); /* PRIMARY */
173445 *pType = aKWCode[i];
173446 break;
173447 }
173448 }
173449 return n;
@@ -173293,10 +173454,11 @@
173454 return id;
173455 }
173456 #define SQLITE_N_KEYWORD 147
173457 SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
173458 if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
173459 i++;
173460 *pzName = zKWText + aKWOffset[i];
173461 *pnName = aKWLen[i];
173462 return SQLITE_OK;
173463 }
173464 SQLITE_API int sqlite3_keyword_count(void){ return SQLITE_N_KEYWORD; }
@@ -199991,10 +200153,31 @@
200153 int i;
200154 for(i=0; i<4; i++) if( !sqlite3Isxdigit(z[i]) ) return 0;
200155 return 1;
200156 }
200157
200158 #ifdef SQLITE_ENABLE_JSON_NAN_INF
200159 /*
200160 ** Extra floating-point literals to allow in JSON.
200161 */
200162 static const struct NanInfName {
200163 char c1;
200164 char c2;
200165 char n;
200166 char eType;
200167 char nRepl;
200168 char *zMatch;
200169 char *zRepl;
200170 } aNanInfName[] = {
200171 { 'i', 'I', 3, JSON_REAL, 7, "inf", "9.0e999" },
200172 { 'i', 'I', 8, JSON_REAL, 7, "infinity", "9.0e999" },
200173 { 'n', 'N', 3, JSON_NULL, 4, "NaN", "null" },
200174 { 'q', 'Q', 4, JSON_NULL, 4, "QNaN", "null" },
200175 { 's', 'S', 4, JSON_NULL, 4, "SNaN", "null" },
200176 };
200177 #endif /* SQLITE_ENABLE_JSON_NAN_INF */
200178
200179 /*
200180 ** Parse a single JSON value which begins at pParse->zJson[i]. Return the
200181 ** index of the first character past the end of the value parsed.
200182 **
200183 ** Return negative for a syntax error. Special cases: return -2 if the
@@ -200136,10 +200319,28 @@
200319 c = z[j+1];
200320 }
200321 if( c<'0' || c>'9' ) return -1;
200322 continue;
200323 }
200324 #ifdef SQLITE_ENABLE_JSON_NAN_INF
200325 /* Non-standard JSON: Allow "-Inf" (in any case)
200326 ** to be understood as floating point literals. */
200327 if( (c=='i' || c=='I')
200328 && j==i+1
200329 && z[i]=='-'
200330 && sqlite3StrNICmp(&z[j], "inf",3)==0
200331 ){
200332 if( !sqlite3Isalnum(z[j+3]) ){
200333 jsonParseAddNode(pParse, JSON_REAL, 8, "-9.0e999");
200334 return i+4;
200335 }else if( (sqlite3StrNICmp(&z[j],"infinity",8)==0 &&
200336 !sqlite3Isalnum(z[j+8])) ){
200337 jsonParseAddNode(pParse, JSON_REAL, 8, "-9.0e999");
200338 return i+9;
200339 }
200340 }
200341 #endif
200342 break;
200343 }
200344 if( z[j-1]<'0' ) return -1;
200345 jsonParseAddNode(pParse, seenDP ? JSON_REAL : JSON_INT,
200346 j - i, &z[i]);
@@ -200149,10 +200350,24 @@
200350 }else if( c==']' ){
200351 return -3; /* End of [...] */
200352 }else if( c==0 ){
200353 return 0; /* End of file */
200354 }else{
200355 #ifdef SQLITE_ENABLE_JSON_NAN_INF
200356 int k, nn;
200357 for(k=0; k<sizeof(aNanInfName)/sizeof(aNanInfName[0]); k++){
200358 if( c!=aNanInfName[k].c1 && c!=aNanInfName[k].c2 ) continue;
200359 nn = aNanInfName[k].n;
200360 if( sqlite3StrNICmp(&z[i], aNanInfName[k].zMatch, nn)!=0 ){
200361 continue;
200362 }
200363 if( sqlite3Isalnum(z[i+nn]) ) continue;
200364 jsonParseAddNode(pParse, aNanInfName[k].eType,
200365 aNanInfName[k].nRepl, aNanInfName[k].zRepl);
200366 return i + nn;
200367 }
200368 #endif
200369 return -1; /* Syntax error */
200370 }
200371 }
200372
200373 /*
@@ -212971,19 +213186,28 @@
213186
213187 iOff = (i64)(pFrame->iDbPage-1) * p->pgsz;
213188 p->rc = pDb->pMethods->xWrite(pDb, p->aBuf, p->pgsz, iOff);
213189 }
213190
213191 /*
213192 ** This value is copied from the definition of ZIPVFS_CTRL_FILE_POINTER
213193 ** in zipvfs.h.
213194 */
213195 #define RBU_ZIPVFS_CTRL_FILE_POINTER 230439
213196
213197 /*
213198 ** Take an EXCLUSIVE lock on the database file. Return SQLITE_OK if
213199 ** successful, or an SQLite error code otherwise.
213200 */
213201 static int rbuLockDatabase(sqlite3 *db){
213202 int rc = SQLITE_OK;
213203 sqlite3_file *fd = 0;
213204
213205 sqlite3_file_control(db, "main", RBU_ZIPVFS_CTRL_FILE_POINTER, &fd);
213206 if( fd==0 ){
213207 sqlite3_file_control(db, "main", SQLITE_FCNTL_FILE_POINTER, &fd);
213208 }
213209
213210 if( fd->pMethods ){
213211 rc = fd->pMethods->xLock(fd, SQLITE_LOCK_SHARED);
213212 if( rc==SQLITE_OK ){
213213 rc = fd->pMethods->xLock(fd, SQLITE_LOCK_EXCLUSIVE);
@@ -216218,10 +216442,11 @@
216442 (void)argc;
216443 (void)argv;
216444 (void)pzErr;
216445
216446 sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY);
216447 sqlite3_vtab_config(db, SQLITE_VTAB_USES_ALL_SCHEMAS);
216448 rc = sqlite3_declare_vtab(db,
216449 "CREATE TABLE x(pgno INTEGER PRIMARY KEY, data BLOB, schema HIDDEN)");
216450 if( rc==SQLITE_OK ){
216451 pTab = (DbpageTable *)sqlite3_malloc64(sizeof(DbpageTable));
216452 if( pTab==0 ) rc = SQLITE_NOMEM_BKPT;
@@ -216301,11 +216526,10 @@
216526 && pIdxInfo->aOrderBy[0].iColumn<=0
216527 && pIdxInfo->aOrderBy[0].desc==0
216528 ){
216529 pIdxInfo->orderByConsumed = 1;
216530 }
 
216531 return SQLITE_OK;
216532 }
216533
216534 /*
216535 ** Open a new dbpagevfs cursor.
@@ -240797,11 +241021,11 @@
241021 int nArg, /* Number of args */
241022 sqlite3_value **apUnused /* Function arguments */
241023 ){
241024 assert( nArg==0 );
241025 UNUSED_PARAM2(nArg, apUnused);
241026 sqlite3_result_text(pCtx, "fts5: 2023-04-10 13:20:51 49ba030080dd00b4fdf788fd3da057b333e705fa0fe37d653e2461bf96ca3785", -1, SQLITE_TRANSIENT);
241027 }
241028
241029 /*
241030 ** Return true if zName is the extension on one of the shadow tables used
241031 ** by this module.
241032
+13 -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.42.0"
150150
#define SQLITE_VERSION_NUMBER 3042000
151
-#define SQLITE_SOURCE_ID "2023-04-01 15:51:21 a4fb2864fe01cce9694242a0750623ca47fcecd68f74c4239d3eb5fbf978770a"
151
+#define SQLITE_SOURCE_ID "2023-04-10 18:44:00 4c5a3c5fb351cc1c2ce16c33314ce19c53531f09263f87456283d9d756002f9d"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -2494,11 +2494,11 @@
24942494
#define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
24952495
#define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
24962496
#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
24972497
#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
24982498
#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
2499
-#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1080 /* int int* */
2499
+#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
25002500
#define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
25012501
#define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
25022502
25032503
/*
25042504
** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -9604,22 +9604,32 @@
96049604
** </dd>
96059605
**
96069606
** [[SQLITE_VTAB_INNOCUOUS]]<dt>SQLITE_VTAB_INNOCUOUS</dt>
96079607
** <dd>Calls of the form
96089608
** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the
9609
-** the [xConnect] or [xCreate] methods of a [virtual table] implmentation
9609
+** the [xConnect] or [xCreate] methods of a [virtual table] implementation
96109610
** identify that virtual table as being safe to use from within triggers
96119611
** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the
96129612
** virtual table can do no serious harm even if it is controlled by a
96139613
** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS
96149614
** flag unless absolutely necessary.
96159615
** </dd>
9616
+**
9617
+** [[SQLITE_VTAB_USES_ALL_SCHEMAS]]<dt>SQLITE_VTAB_USES_ALL_SCHEMAS</dt>
9618
+** <dd>Calls of the form
9619
+** [sqlite3_vtab_config](db,SQLITE_VTAB_USES_ALL_SCHEMA) from within the
9620
+** the [xConnect] or [xCreate] methods of a [virtual table] implementation
9621
+** instruct the query planner to begin at least a read transaction on
9622
+** all schemas ("main", "temp", and any ATTACH-ed databases) whenever the
9623
+** virtual table is used.
9624
+** </dd>
96169625
** </dl>
96179626
*/
96189627
#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1
96199628
#define SQLITE_VTAB_INNOCUOUS 2
96209629
#define SQLITE_VTAB_DIRECTONLY 3
9630
+#define SQLITE_VTAB_USES_ALL_SCHEMAS 4
96219631
96229632
/*
96239633
** CAPI3REF: Determine The Virtual Table Conflict Policy
96249634
**
96259635
** This function may only be called from within a call to the [xUpdate] method
96269636
--- 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.42.0"
150 #define SQLITE_VERSION_NUMBER 3042000
151 #define SQLITE_SOURCE_ID "2023-04-01 15:51:21 a4fb2864fe01cce9694242a0750623ca47fcecd68f74c4239d3eb5fbf978770a"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -2494,11 +2494,11 @@
2494 #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
2495 #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
2496 #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2497 #define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
2498 #define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
2499 #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1080 /* int int* */
2500 #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2501 #define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
2502
2503 /*
2504 ** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -9604,22 +9604,32 @@
9604 ** </dd>
9605 **
9606 ** [[SQLITE_VTAB_INNOCUOUS]]<dt>SQLITE_VTAB_INNOCUOUS</dt>
9607 ** <dd>Calls of the form
9608 ** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the
9609 ** the [xConnect] or [xCreate] methods of a [virtual table] implmentation
9610 ** identify that virtual table as being safe to use from within triggers
9611 ** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the
9612 ** virtual table can do no serious harm even if it is controlled by a
9613 ** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS
9614 ** flag unless absolutely necessary.
9615 ** </dd>
 
 
 
 
 
 
 
 
 
9616 ** </dl>
9617 */
9618 #define SQLITE_VTAB_CONSTRAINT_SUPPORT 1
9619 #define SQLITE_VTAB_INNOCUOUS 2
9620 #define SQLITE_VTAB_DIRECTONLY 3
 
9621
9622 /*
9623 ** CAPI3REF: Determine The Virtual Table Conflict Policy
9624 **
9625 ** This function may only be called from within a call to the [xUpdate] method
9626
--- 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.42.0"
150 #define SQLITE_VERSION_NUMBER 3042000
151 #define SQLITE_SOURCE_ID "2023-04-10 18:44:00 4c5a3c5fb351cc1c2ce16c33314ce19c53531f09263f87456283d9d756002f9d"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -2494,11 +2494,11 @@
2494 #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */
2495 #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */
2496 #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2497 #define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
2498 #define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
2499 #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
2500 #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2501 #define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
2502
2503 /*
2504 ** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -9604,22 +9604,32 @@
9604 ** </dd>
9605 **
9606 ** [[SQLITE_VTAB_INNOCUOUS]]<dt>SQLITE_VTAB_INNOCUOUS</dt>
9607 ** <dd>Calls of the form
9608 ** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the
9609 ** the [xConnect] or [xCreate] methods of a [virtual table] implementation
9610 ** identify that virtual table as being safe to use from within triggers
9611 ** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the
9612 ** virtual table can do no serious harm even if it is controlled by a
9613 ** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS
9614 ** flag unless absolutely necessary.
9615 ** </dd>
9616 **
9617 ** [[SQLITE_VTAB_USES_ALL_SCHEMAS]]<dt>SQLITE_VTAB_USES_ALL_SCHEMAS</dt>
9618 ** <dd>Calls of the form
9619 ** [sqlite3_vtab_config](db,SQLITE_VTAB_USES_ALL_SCHEMA) from within the
9620 ** the [xConnect] or [xCreate] methods of a [virtual table] implementation
9621 ** instruct the query planner to begin at least a read transaction on
9622 ** all schemas ("main", "temp", and any ATTACH-ed databases) whenever the
9623 ** virtual table is used.
9624 ** </dd>
9625 ** </dl>
9626 */
9627 #define SQLITE_VTAB_CONSTRAINT_SUPPORT 1
9628 #define SQLITE_VTAB_INNOCUOUS 2
9629 #define SQLITE_VTAB_DIRECTONLY 3
9630 #define SQLITE_VTAB_USES_ALL_SCHEMAS 4
9631
9632 /*
9633 ** CAPI3REF: Determine The Virtual Table Conflict Policy
9634 **
9635 ** This function may only be called from within a call to the [xUpdate] method
9636

Keyboard Shortcuts

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