Fossil SCM

Update to the latest SQLite 3.39.0 alpha with its performance enhancements and bug fixes.

drh 2022-03-07 19:01 trunk
Commit 14da62eeb5641bf95ac5fa17bf5fef0cd98a9a6eab9d6713aa3b4b7f6a486dc7
+23 -21
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -19904,19 +19904,20 @@
1990419904
}
1990519905
}else
1990619906
1990719907
if( c=='i' && strncmp(azArg[0], "import", n)==0 ){
1990819908
char *zTable = 0; /* Insert data into this table */
19909
- char *zSchema = "main"; /* within this schema */
19909
+ char *zSchema = 0; /* within this schema (may default to "main") */
1991019910
char *zFile = 0; /* Name of file to extra content from */
1991119911
sqlite3_stmt *pStmt = NULL; /* A statement */
1991219912
int nCol; /* Number of columns in the table */
1991319913
int nByte; /* Number of bytes in an SQL string */
1991419914
int i, j; /* Loop counters */
1991519915
int needCommit; /* True to COMMIT or ROLLBACK at end */
1991619916
int nSep; /* Number of bytes in p->colSeparator[] */
1991719917
char *zSql; /* An SQL statement */
19918
+ char *zFullTabName; /* Table name with schema if applicable */
1991819919
ImportCtx sCtx; /* Reader context */
1991919920
char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
1992019921
int eVerbose = 0; /* Larger for more console output */
1992119922
int nSkip = 0; /* Initial lines to skip */
1992219923
int useOutputMode = 1; /* Use output mode to determine separators */
@@ -20040,11 +20041,10 @@
2004020041
utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile);
2004120042
rc = 1;
2004220043
import_cleanup(&sCtx);
2004320044
goto meta_command_exit;
2004420045
}
20045
- /* Below, resources must be freed before exit. */
2004620046
if( eVerbose>=2 || (eVerbose>=1 && useOutputMode) ){
2004720047
char zSep[2];
2004820048
zSep[1] = 0;
2004920049
zSep[0] = sCtx.cColSep;
2005020050
utf8_printf(p->out, "Column separator ");
@@ -20052,24 +20052,29 @@
2005220052
utf8_printf(p->out, ", row separator ");
2005320053
zSep[0] = sCtx.cRowSep;
2005420054
output_c_string(p->out, zSep);
2005520055
utf8_printf(p->out, "\n");
2005620056
}
20057
+ /* Below, resources must be freed before exit. */
2005720058
while( (nSkip--)>0 ){
2005820059
while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){}
2005920060
}
20060
- zSql = sqlite3_mprintf("SELECT * FROM \"%w\".\"%w\"", zSchema, zTable);
20061
- if( zSql==0 ){
20061
+ if( zSchema!=0 ){
20062
+ zFullTabName = sqlite3_mprintf("\"%w\".\"%w\"", zSchema, zTable);
20063
+ }else{
20064
+ zFullTabName = sqlite3_mprintf("\"%w\"", zTable);
20065
+ }
20066
+ zSql = sqlite3_mprintf("SELECT * FROM %s", zFullTabName);
20067
+ if( zSql==0 || zFullTabName==0 ){
2006220068
import_cleanup(&sCtx);
2006320069
shell_out_of_memory();
2006420070
}
2006520071
nByte = strlen30(zSql);
2006620072
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
2006720073
import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
2006820074
if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
20069
- char *zCreate = sqlite3_mprintf("CREATE TABLE \"%w\".\"%w\"",
20070
- zSchema, zTable);
20075
+ char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zFullTabName);
2007120076
sqlite3 *dbCols = 0;
2007220077
char *zRenames = 0;
2007320078
char *zColDefs;
2007420079
while( xRead(&sCtx) ){
2007520080
zAutoColumn(sCtx.z, &dbCols, 0);
@@ -20082,13 +20087,16 @@
2008220087
"%s\n", sCtx.zFile, zRenames);
2008320088
sqlite3_free(zRenames);
2008420089
}
2008520090
assert(dbCols==0);
2008620091
if( zColDefs==0 ){
20092
+ utf8_printf(stderr,"%s: empty file\n", sCtx.zFile);
20093
+ import_fail:
2008720094
sqlite3_free(zCreate);
20095
+ sqlite3_free(zSql);
20096
+ sqlite3_free(zFullTabName);
2008820097
import_cleanup(&sCtx);
20089
- utf8_printf(stderr,"%s: empty file\n", sCtx.zFile);
2009020098
rc = 1;
2009120099
goto meta_command_exit;
2009220100
}
2009320101
zCreate = sqlite3_mprintf("%z%z\n", zCreate, zColDefs);
2009420102
if( eVerbose>=1 ){
@@ -20095,37 +20103,32 @@
2009520103
utf8_printf(p->out, "%s\n", zCreate);
2009620104
}
2009720105
rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
2009820106
if( rc ){
2009920107
utf8_printf(stderr, "%s failed:\n%s\n", zCreate, sqlite3_errmsg(p->db));
20100
- sqlite3_free(zCreate);
20101
- import_cleanup(&sCtx);
20102
- rc = 1;
20103
- goto meta_command_exit;
20108
+ goto import_fail;
2010420109
}
2010520110
sqlite3_free(zCreate);
20111
+ zCreate = 0;
2010620112
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
2010720113
}
20108
- sqlite3_free(zSql);
2010920114
if( rc ){
2011020115
if (pStmt) sqlite3_finalize(pStmt);
2011120116
utf8_printf(stderr,"Error: %s\n", sqlite3_errmsg(p->db));
20112
- import_cleanup(&sCtx);
20113
- rc = 1;
20114
- goto meta_command_exit;
20117
+ goto import_fail;
2011520118
}
20119
+ sqlite3_free(zSql);
2011620120
nCol = sqlite3_column_count(pStmt);
2011720121
sqlite3_finalize(pStmt);
2011820122
pStmt = 0;
2011920123
if( nCol==0 ) return 0; /* no columns, no error */
2012020124
zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 );
2012120125
if( zSql==0 ){
2012220126
import_cleanup(&sCtx);
2012320127
shell_out_of_memory();
2012420128
}
20125
- sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\".\"%w\" VALUES(?",
20126
- zSchema, zTable);
20129
+ sqlite3_snprintf(nByte+20, zSql, "INSERT INTO %s VALUES(?", zFullTabName);
2012720130
j = strlen30(zSql);
2012820131
for(i=1; i<nCol; i++){
2012920132
zSql[j++] = ',';
2013020133
zSql[j++] = '?';
2013120134
}
@@ -20133,18 +20136,17 @@
2013320136
zSql[j] = 0;
2013420137
if( eVerbose>=2 ){
2013520138
utf8_printf(p->out, "Insert using: %s\n", zSql);
2013620139
}
2013720140
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
20138
- sqlite3_free(zSql);
2013920141
if( rc ){
2014020142
utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
2014120143
if (pStmt) sqlite3_finalize(pStmt);
20142
- import_cleanup(&sCtx);
20143
- rc = 1;
20144
- goto meta_command_exit;
20144
+ goto import_fail;
2014520145
}
20146
+ sqlite3_free(zSql);
20147
+ sqlite3_free(zFullTabName);
2014620148
needCommit = sqlite3_get_autocommit(p->db);
2014720149
if( needCommit ) sqlite3_exec(p->db, "BEGIN", 0, 0, 0);
2014820150
do{
2014920151
int startLine = sCtx.nLine;
2015020152
for(i=0; i<nCol; i++){
2015120153
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -19904,19 +19904,20 @@
19904 }
19905 }else
19906
19907 if( c=='i' && strncmp(azArg[0], "import", n)==0 ){
19908 char *zTable = 0; /* Insert data into this table */
19909 char *zSchema = "main"; /* within this schema */
19910 char *zFile = 0; /* Name of file to extra content from */
19911 sqlite3_stmt *pStmt = NULL; /* A statement */
19912 int nCol; /* Number of columns in the table */
19913 int nByte; /* Number of bytes in an SQL string */
19914 int i, j; /* Loop counters */
19915 int needCommit; /* True to COMMIT or ROLLBACK at end */
19916 int nSep; /* Number of bytes in p->colSeparator[] */
19917 char *zSql; /* An SQL statement */
 
19918 ImportCtx sCtx; /* Reader context */
19919 char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
19920 int eVerbose = 0; /* Larger for more console output */
19921 int nSkip = 0; /* Initial lines to skip */
19922 int useOutputMode = 1; /* Use output mode to determine separators */
@@ -20040,11 +20041,10 @@
20040 utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile);
20041 rc = 1;
20042 import_cleanup(&sCtx);
20043 goto meta_command_exit;
20044 }
20045 /* Below, resources must be freed before exit. */
20046 if( eVerbose>=2 || (eVerbose>=1 && useOutputMode) ){
20047 char zSep[2];
20048 zSep[1] = 0;
20049 zSep[0] = sCtx.cColSep;
20050 utf8_printf(p->out, "Column separator ");
@@ -20052,24 +20052,29 @@
20052 utf8_printf(p->out, ", row separator ");
20053 zSep[0] = sCtx.cRowSep;
20054 output_c_string(p->out, zSep);
20055 utf8_printf(p->out, "\n");
20056 }
 
20057 while( (nSkip--)>0 ){
20058 while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){}
20059 }
20060 zSql = sqlite3_mprintf("SELECT * FROM \"%w\".\"%w\"", zSchema, zTable);
20061 if( zSql==0 ){
 
 
 
 
 
20062 import_cleanup(&sCtx);
20063 shell_out_of_memory();
20064 }
20065 nByte = strlen30(zSql);
20066 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
20067 import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
20068 if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
20069 char *zCreate = sqlite3_mprintf("CREATE TABLE \"%w\".\"%w\"",
20070 zSchema, zTable);
20071 sqlite3 *dbCols = 0;
20072 char *zRenames = 0;
20073 char *zColDefs;
20074 while( xRead(&sCtx) ){
20075 zAutoColumn(sCtx.z, &dbCols, 0);
@@ -20082,13 +20087,16 @@
20082 "%s\n", sCtx.zFile, zRenames);
20083 sqlite3_free(zRenames);
20084 }
20085 assert(dbCols==0);
20086 if( zColDefs==0 ){
 
 
20087 sqlite3_free(zCreate);
 
 
20088 import_cleanup(&sCtx);
20089 utf8_printf(stderr,"%s: empty file\n", sCtx.zFile);
20090 rc = 1;
20091 goto meta_command_exit;
20092 }
20093 zCreate = sqlite3_mprintf("%z%z\n", zCreate, zColDefs);
20094 if( eVerbose>=1 ){
@@ -20095,37 +20103,32 @@
20095 utf8_printf(p->out, "%s\n", zCreate);
20096 }
20097 rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
20098 if( rc ){
20099 utf8_printf(stderr, "%s failed:\n%s\n", zCreate, sqlite3_errmsg(p->db));
20100 sqlite3_free(zCreate);
20101 import_cleanup(&sCtx);
20102 rc = 1;
20103 goto meta_command_exit;
20104 }
20105 sqlite3_free(zCreate);
 
20106 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
20107 }
20108 sqlite3_free(zSql);
20109 if( rc ){
20110 if (pStmt) sqlite3_finalize(pStmt);
20111 utf8_printf(stderr,"Error: %s\n", sqlite3_errmsg(p->db));
20112 import_cleanup(&sCtx);
20113 rc = 1;
20114 goto meta_command_exit;
20115 }
 
20116 nCol = sqlite3_column_count(pStmt);
20117 sqlite3_finalize(pStmt);
20118 pStmt = 0;
20119 if( nCol==0 ) return 0; /* no columns, no error */
20120 zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 );
20121 if( zSql==0 ){
20122 import_cleanup(&sCtx);
20123 shell_out_of_memory();
20124 }
20125 sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\".\"%w\" VALUES(?",
20126 zSchema, zTable);
20127 j = strlen30(zSql);
20128 for(i=1; i<nCol; i++){
20129 zSql[j++] = ',';
20130 zSql[j++] = '?';
20131 }
@@ -20133,18 +20136,17 @@
20133 zSql[j] = 0;
20134 if( eVerbose>=2 ){
20135 utf8_printf(p->out, "Insert using: %s\n", zSql);
20136 }
20137 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
20138 sqlite3_free(zSql);
20139 if( rc ){
20140 utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
20141 if (pStmt) sqlite3_finalize(pStmt);
20142 import_cleanup(&sCtx);
20143 rc = 1;
20144 goto meta_command_exit;
20145 }
 
 
20146 needCommit = sqlite3_get_autocommit(p->db);
20147 if( needCommit ) sqlite3_exec(p->db, "BEGIN", 0, 0, 0);
20148 do{
20149 int startLine = sCtx.nLine;
20150 for(i=0; i<nCol; i++){
20151
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -19904,19 +19904,20 @@
19904 }
19905 }else
19906
19907 if( c=='i' && strncmp(azArg[0], "import", n)==0 ){
19908 char *zTable = 0; /* Insert data into this table */
19909 char *zSchema = 0; /* within this schema (may default to "main") */
19910 char *zFile = 0; /* Name of file to extra content from */
19911 sqlite3_stmt *pStmt = NULL; /* A statement */
19912 int nCol; /* Number of columns in the table */
19913 int nByte; /* Number of bytes in an SQL string */
19914 int i, j; /* Loop counters */
19915 int needCommit; /* True to COMMIT or ROLLBACK at end */
19916 int nSep; /* Number of bytes in p->colSeparator[] */
19917 char *zSql; /* An SQL statement */
19918 char *zFullTabName; /* Table name with schema if applicable */
19919 ImportCtx sCtx; /* Reader context */
19920 char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
19921 int eVerbose = 0; /* Larger for more console output */
19922 int nSkip = 0; /* Initial lines to skip */
19923 int useOutputMode = 1; /* Use output mode to determine separators */
@@ -20040,11 +20041,10 @@
20041 utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile);
20042 rc = 1;
20043 import_cleanup(&sCtx);
20044 goto meta_command_exit;
20045 }
 
20046 if( eVerbose>=2 || (eVerbose>=1 && useOutputMode) ){
20047 char zSep[2];
20048 zSep[1] = 0;
20049 zSep[0] = sCtx.cColSep;
20050 utf8_printf(p->out, "Column separator ");
@@ -20052,24 +20052,29 @@
20052 utf8_printf(p->out, ", row separator ");
20053 zSep[0] = sCtx.cRowSep;
20054 output_c_string(p->out, zSep);
20055 utf8_printf(p->out, "\n");
20056 }
20057 /* Below, resources must be freed before exit. */
20058 while( (nSkip--)>0 ){
20059 while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){}
20060 }
20061 if( zSchema!=0 ){
20062 zFullTabName = sqlite3_mprintf("\"%w\".\"%w\"", zSchema, zTable);
20063 }else{
20064 zFullTabName = sqlite3_mprintf("\"%w\"", zTable);
20065 }
20066 zSql = sqlite3_mprintf("SELECT * FROM %s", zFullTabName);
20067 if( zSql==0 || zFullTabName==0 ){
20068 import_cleanup(&sCtx);
20069 shell_out_of_memory();
20070 }
20071 nByte = strlen30(zSql);
20072 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
20073 import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
20074 if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
20075 char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zFullTabName);
 
20076 sqlite3 *dbCols = 0;
20077 char *zRenames = 0;
20078 char *zColDefs;
20079 while( xRead(&sCtx) ){
20080 zAutoColumn(sCtx.z, &dbCols, 0);
@@ -20082,13 +20087,16 @@
20087 "%s\n", sCtx.zFile, zRenames);
20088 sqlite3_free(zRenames);
20089 }
20090 assert(dbCols==0);
20091 if( zColDefs==0 ){
20092 utf8_printf(stderr,"%s: empty file\n", sCtx.zFile);
20093 import_fail:
20094 sqlite3_free(zCreate);
20095 sqlite3_free(zSql);
20096 sqlite3_free(zFullTabName);
20097 import_cleanup(&sCtx);
 
20098 rc = 1;
20099 goto meta_command_exit;
20100 }
20101 zCreate = sqlite3_mprintf("%z%z\n", zCreate, zColDefs);
20102 if( eVerbose>=1 ){
@@ -20095,37 +20103,32 @@
20103 utf8_printf(p->out, "%s\n", zCreate);
20104 }
20105 rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
20106 if( rc ){
20107 utf8_printf(stderr, "%s failed:\n%s\n", zCreate, sqlite3_errmsg(p->db));
20108 goto import_fail;
 
 
 
20109 }
20110 sqlite3_free(zCreate);
20111 zCreate = 0;
20112 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
20113 }
 
20114 if( rc ){
20115 if (pStmt) sqlite3_finalize(pStmt);
20116 utf8_printf(stderr,"Error: %s\n", sqlite3_errmsg(p->db));
20117 goto import_fail;
 
 
20118 }
20119 sqlite3_free(zSql);
20120 nCol = sqlite3_column_count(pStmt);
20121 sqlite3_finalize(pStmt);
20122 pStmt = 0;
20123 if( nCol==0 ) return 0; /* no columns, no error */
20124 zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 );
20125 if( zSql==0 ){
20126 import_cleanup(&sCtx);
20127 shell_out_of_memory();
20128 }
20129 sqlite3_snprintf(nByte+20, zSql, "INSERT INTO %s VALUES(?", zFullTabName);
 
20130 j = strlen30(zSql);
20131 for(i=1; i<nCol; i++){
20132 zSql[j++] = ',';
20133 zSql[j++] = '?';
20134 }
@@ -20133,18 +20136,17 @@
20136 zSql[j] = 0;
20137 if( eVerbose>=2 ){
20138 utf8_printf(p->out, "Insert using: %s\n", zSql);
20139 }
20140 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
 
20141 if( rc ){
20142 utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
20143 if (pStmt) sqlite3_finalize(pStmt);
20144 goto import_fail;
 
 
20145 }
20146 sqlite3_free(zSql);
20147 sqlite3_free(zFullTabName);
20148 needCommit = sqlite3_get_autocommit(p->db);
20149 if( needCommit ) sqlite3_exec(p->db, "BEGIN", 0, 0, 0);
20150 do{
20151 int startLine = sCtx.nLine;
20152 for(i=0; i<nCol; i++){
20153
+451 -284
--- 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.39.0"
456456
#define SQLITE_VERSION_NUMBER 3039000
457
-#define SQLITE_SOURCE_ID "2022-03-02 01:02:16 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b"
457
+#define SQLITE_SOURCE_ID "2022-03-07 18:32:08 ae464a18d74bf44fc95bc335e75e6a57dc974f6d6a3d603133594039fb589af2"
458458
459459
/*
460460
** CAPI3REF: Run-Time Library Version Numbers
461461
** KEYWORDS: sqlite3_version sqlite3_sourceid
462462
**
@@ -15569,41 +15569,41 @@
1556915569
#define OP_Function 66 /* synopsis: r[P3]=func(r[P2@NP]) */
1557015570
#define OP_Return 67
1557115571
#define OP_EndCoroutine 68
1557215572
#define OP_HaltIfNull 69 /* synopsis: if r[P3]=null halt */
1557315573
#define OP_Halt 70
15574
-#define OP_Integer 71 /* synopsis: r[P2]=P1 */
15575
-#define OP_Int64 72 /* synopsis: r[P2]=P4 */
15576
-#define OP_String 73 /* synopsis: r[P2]='P4' (len=P1) */
15577
-#define OP_Null 74 /* synopsis: r[P2..P3]=NULL */
15578
-#define OP_SoftNull 75 /* synopsis: r[P1]=NULL */
15579
-#define OP_Blob 76 /* synopsis: r[P2]=P4 (len=P1) */
15580
-#define OP_Variable 77 /* synopsis: r[P2]=parameter(P1,P4) */
15581
-#define OP_Move 78 /* synopsis: r[P2@P3]=r[P1@P3] */
15582
-#define OP_Copy 79 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
15583
-#define OP_SCopy 80 /* synopsis: r[P2]=r[P1] */
15584
-#define OP_IntCopy 81 /* synopsis: r[P2]=r[P1] */
15585
-#define OP_FkCheck 82
15586
-#define OP_ResultRow 83 /* synopsis: output=r[P1@P2] */
15587
-#define OP_CollSeq 84
15588
-#define OP_AddImm 85 /* synopsis: r[P1]=r[P1]+P2 */
15589
-#define OP_RealAffinity 86
15590
-#define OP_Cast 87 /* synopsis: affinity(r[P1]) */
15591
-#define OP_Permutation 88
15592
-#define OP_Compare 89 /* synopsis: r[P1@P3] <-> r[P2@P3] */
15593
-#define OP_IsTrue 90 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
15594
-#define OP_ZeroOrNull 91 /* synopsis: r[P2] = 0 OR NULL */
15595
-#define OP_Offset 92 /* synopsis: r[P3] = sqlite_offset(P1) */
15596
-#define OP_Column 93 /* synopsis: r[P3]=PX */
15597
-#define OP_TypeCheck 94 /* synopsis: typecheck(r[P1@P2]) */
15598
-#define OP_Affinity 95 /* synopsis: affinity(r[P1@P2]) */
15599
-#define OP_MakeRecord 96 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
15600
-#define OP_Count 97 /* synopsis: r[P2]=count() */
15601
-#define OP_ReadCookie 98
15602
-#define OP_SetCookie 99
15603
-#define OP_ReopenIdx 100 /* synopsis: root=P2 iDb=P3 */
15604
-#define OP_OpenRead 101 /* synopsis: root=P2 iDb=P3 */
15574
+#define OP_BeginSubrtn 71 /* synopsis: r[P2]=P1 */
15575
+#define OP_Integer 72 /* synopsis: r[P2]=P1 */
15576
+#define OP_Int64 73 /* synopsis: r[P2]=P4 */
15577
+#define OP_String 74 /* synopsis: r[P2]='P4' (len=P1) */
15578
+#define OP_Null 75 /* synopsis: r[P2..P3]=NULL */
15579
+#define OP_SoftNull 76 /* synopsis: r[P1]=NULL */
15580
+#define OP_Blob 77 /* synopsis: r[P2]=P4 (len=P1) */
15581
+#define OP_Variable 78 /* synopsis: r[P2]=parameter(P1,P4) */
15582
+#define OP_Move 79 /* synopsis: r[P2@P3]=r[P1@P3] */
15583
+#define OP_Copy 80 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
15584
+#define OP_SCopy 81 /* synopsis: r[P2]=r[P1] */
15585
+#define OP_IntCopy 82 /* synopsis: r[P2]=r[P1] */
15586
+#define OP_FkCheck 83
15587
+#define OP_ResultRow 84 /* synopsis: output=r[P1@P2] */
15588
+#define OP_CollSeq 85
15589
+#define OP_AddImm 86 /* synopsis: r[P1]=r[P1]+P2 */
15590
+#define OP_RealAffinity 87
15591
+#define OP_Cast 88 /* synopsis: affinity(r[P1]) */
15592
+#define OP_Permutation 89
15593
+#define OP_Compare 90 /* synopsis: r[P1@P3] <-> r[P2@P3] */
15594
+#define OP_IsTrue 91 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
15595
+#define OP_ZeroOrNull 92 /* synopsis: r[P2] = 0 OR NULL */
15596
+#define OP_Offset 93 /* synopsis: r[P3] = sqlite_offset(P1) */
15597
+#define OP_Column 94 /* synopsis: r[P3]=PX */
15598
+#define OP_TypeCheck 95 /* synopsis: typecheck(r[P1@P2]) */
15599
+#define OP_Affinity 96 /* synopsis: affinity(r[P1@P2]) */
15600
+#define OP_MakeRecord 97 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
15601
+#define OP_Count 98 /* synopsis: r[P2]=count() */
15602
+#define OP_ReadCookie 99
15603
+#define OP_SetCookie 100
15604
+#define OP_ReopenIdx 101 /* synopsis: root=P2 iDb=P3 */
1560515605
#define OP_BitAnd 102 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
1560615606
#define OP_BitOr 103 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
1560715607
#define OP_ShiftLeft 104 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
1560815608
#define OP_ShiftRight 105 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
1560915609
#define OP_Add 106 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -15610,83 +15610,84 @@
1561015610
#define OP_Subtract 107 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
1561115611
#define OP_Multiply 108 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
1561215612
#define OP_Divide 109 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
1561315613
#define OP_Remainder 110 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
1561415614
#define OP_Concat 111 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
15615
-#define OP_OpenWrite 112 /* synopsis: root=P2 iDb=P3 */
15616
-#define OP_OpenDup 113
15615
+#define OP_OpenRead 112 /* synopsis: root=P2 iDb=P3 */
15616
+#define OP_OpenWrite 113 /* synopsis: root=P2 iDb=P3 */
1561715617
#define OP_BitNot 114 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
15618
-#define OP_OpenAutoindex 115 /* synopsis: nColumn=P2 */
15619
-#define OP_OpenEphemeral 116 /* synopsis: nColumn=P2 */
15618
+#define OP_OpenDup 115
15619
+#define OP_OpenAutoindex 116 /* synopsis: nColumn=P2 */
1562015620
#define OP_String8 117 /* same as TK_STRING, synopsis: r[P2]='P4' */
15621
-#define OP_SorterOpen 118
15622
-#define OP_SequenceTest 119 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
15623
-#define OP_OpenPseudo 120 /* synopsis: P3 columns in r[P2] */
15624
-#define OP_Close 121
15625
-#define OP_ColumnsUsed 122
15626
-#define OP_SeekScan 123 /* synopsis: Scan-ahead up to P1 rows */
15627
-#define OP_SeekHit 124 /* synopsis: set P2<=seekHit<=P3 */
15628
-#define OP_Sequence 125 /* synopsis: r[P2]=cursor[P1].ctr++ */
15629
-#define OP_NewRowid 126 /* synopsis: r[P2]=rowid */
15630
-#define OP_Insert 127 /* synopsis: intkey=r[P3] data=r[P2] */
15631
-#define OP_RowCell 128
15632
-#define OP_Delete 129
15633
-#define OP_ResetCount 130
15634
-#define OP_SorterCompare 131 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
15635
-#define OP_SorterData 132 /* synopsis: r[P2]=data */
15636
-#define OP_RowData 133 /* synopsis: r[P2]=data */
15637
-#define OP_Rowid 134 /* synopsis: r[P2]=rowid */
15638
-#define OP_NullRow 135
15639
-#define OP_SeekEnd 136
15640
-#define OP_IdxInsert 137 /* synopsis: key=r[P2] */
15641
-#define OP_SorterInsert 138 /* synopsis: key=r[P2] */
15642
-#define OP_IdxDelete 139 /* synopsis: key=r[P2@P3] */
15643
-#define OP_DeferredSeek 140 /* synopsis: Move P3 to P1.rowid if needed */
15644
-#define OP_IdxRowid 141 /* synopsis: r[P2]=rowid */
15645
-#define OP_FinishSeek 142
15646
-#define OP_Destroy 143
15647
-#define OP_Clear 144
15648
-#define OP_ResetSorter 145
15649
-#define OP_CreateBtree 146 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
15650
-#define OP_SqlExec 147
15651
-#define OP_ParseSchema 148
15652
-#define OP_LoadAnalysis 149
15653
-#define OP_DropTable 150
15654
-#define OP_DropIndex 151
15655
-#define OP_DropTrigger 152
15621
+#define OP_OpenEphemeral 118 /* synopsis: nColumn=P2 */
15622
+#define OP_SorterOpen 119
15623
+#define OP_SequenceTest 120 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
15624
+#define OP_OpenPseudo 121 /* synopsis: P3 columns in r[P2] */
15625
+#define OP_Close 122
15626
+#define OP_ColumnsUsed 123
15627
+#define OP_SeekScan 124 /* synopsis: Scan-ahead up to P1 rows */
15628
+#define OP_SeekHit 125 /* synopsis: set P2<=seekHit<=P3 */
15629
+#define OP_Sequence 126 /* synopsis: r[P2]=cursor[P1].ctr++ */
15630
+#define OP_NewRowid 127 /* synopsis: r[P2]=rowid */
15631
+#define OP_Insert 128 /* synopsis: intkey=r[P3] data=r[P2] */
15632
+#define OP_RowCell 129
15633
+#define OP_Delete 130
15634
+#define OP_ResetCount 131
15635
+#define OP_SorterCompare 132 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
15636
+#define OP_SorterData 133 /* synopsis: r[P2]=data */
15637
+#define OP_RowData 134 /* synopsis: r[P2]=data */
15638
+#define OP_Rowid 135 /* synopsis: r[P2]=rowid */
15639
+#define OP_NullRow 136
15640
+#define OP_SeekEnd 137
15641
+#define OP_IdxInsert 138 /* synopsis: key=r[P2] */
15642
+#define OP_SorterInsert 139 /* synopsis: key=r[P2] */
15643
+#define OP_IdxDelete 140 /* synopsis: key=r[P2@P3] */
15644
+#define OP_DeferredSeek 141 /* synopsis: Move P3 to P1.rowid if needed */
15645
+#define OP_IdxRowid 142 /* synopsis: r[P2]=rowid */
15646
+#define OP_FinishSeek 143
15647
+#define OP_Destroy 144
15648
+#define OP_Clear 145
15649
+#define OP_ResetSorter 146
15650
+#define OP_CreateBtree 147 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
15651
+#define OP_SqlExec 148
15652
+#define OP_ParseSchema 149
15653
+#define OP_LoadAnalysis 150
15654
+#define OP_DropTable 151
15655
+#define OP_DropIndex 152
1565615656
#define OP_Real 153 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15657
-#define OP_IntegrityCk 154
15658
-#define OP_RowSetAdd 155 /* synopsis: rowset(P1)=r[P2] */
15659
-#define OP_Param 156
15660
-#define OP_FkCounter 157 /* synopsis: fkctr[P1]+=P2 */
15661
-#define OP_MemMax 158 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15662
-#define OP_OffsetLimit 159 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15663
-#define OP_AggInverse 160 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
15664
-#define OP_AggStep 161 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15665
-#define OP_AggStep1 162 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15666
-#define OP_AggValue 163 /* synopsis: r[P3]=value N=P2 */
15667
-#define OP_AggFinal 164 /* synopsis: accum=r[P1] N=P2 */
15668
-#define OP_Expire 165
15669
-#define OP_CursorLock 166
15670
-#define OP_CursorUnlock 167
15671
-#define OP_TableLock 168 /* synopsis: iDb=P1 root=P2 write=P3 */
15672
-#define OP_VBegin 169
15673
-#define OP_VCreate 170
15674
-#define OP_VDestroy 171
15675
-#define OP_VOpen 172
15676
-#define OP_VInitIn 173 /* synopsis: r[P2]=ValueList(P1,P3) */
15677
-#define OP_VColumn 174 /* synopsis: r[P3]=vcolumn(P2) */
15678
-#define OP_VRename 175
15679
-#define OP_Pagecount 176
15680
-#define OP_MaxPgcnt 177
15681
-#define OP_FilterAdd 178 /* synopsis: filter(P1) += key(P3@P4) */
15682
-#define OP_Trace 179
15683
-#define OP_CursorHint 180
15684
-#define OP_ReleaseReg 181 /* synopsis: release r[P1@P2] mask P3 */
15685
-#define OP_Noop 182
15686
-#define OP_Explain 183
15687
-#define OP_Abortable 184
15657
+#define OP_DropTrigger 154
15658
+#define OP_IntegrityCk 155
15659
+#define OP_RowSetAdd 156 /* synopsis: rowset(P1)=r[P2] */
15660
+#define OP_Param 157
15661
+#define OP_FkCounter 158 /* synopsis: fkctr[P1]+=P2 */
15662
+#define OP_MemMax 159 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15663
+#define OP_OffsetLimit 160 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15664
+#define OP_AggInverse 161 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
15665
+#define OP_AggStep 162 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15666
+#define OP_AggStep1 163 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15667
+#define OP_AggValue 164 /* synopsis: r[P3]=value N=P2 */
15668
+#define OP_AggFinal 165 /* synopsis: accum=r[P1] N=P2 */
15669
+#define OP_Expire 166
15670
+#define OP_CursorLock 167
15671
+#define OP_CursorUnlock 168
15672
+#define OP_TableLock 169 /* synopsis: iDb=P1 root=P2 write=P3 */
15673
+#define OP_VBegin 170
15674
+#define OP_VCreate 171
15675
+#define OP_VDestroy 172
15676
+#define OP_VOpen 173
15677
+#define OP_VInitIn 174 /* synopsis: r[P2]=ValueList(P1,P3) */
15678
+#define OP_VColumn 175 /* synopsis: r[P3]=vcolumn(P2) */
15679
+#define OP_VRename 176
15680
+#define OP_Pagecount 177
15681
+#define OP_MaxPgcnt 178
15682
+#define OP_FilterAdd 179 /* synopsis: filter(P1) += key(P3@P4) */
15683
+#define OP_Trace 180
15684
+#define OP_CursorHint 181
15685
+#define OP_ReleaseReg 182 /* synopsis: release r[P1@P2] mask P3 */
15686
+#define OP_Noop 183
15687
+#define OP_Explain 184
15688
+#define OP_Abortable 185
1568815689
1568915690
/* Properties such as "out2" or "jump" that are specified in
1569015691
** comments following the "case" for each opcode in the vdbe.c
1569115692
** are encoded into bitvectors as follows:
1569215693
*/
@@ -15703,26 +15704,26 @@
1570315704
/* 24 */ 0x01, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x01,\
1570415705
/* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
1570515706
/* 40 */ 0x01, 0x01, 0x01, 0x26, 0x26, 0x23, 0x0b, 0x01,\
1570615707
/* 48 */ 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
1570715708
/* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x01, 0x01,\
15708
-/* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\
15709
-/* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00,\
15710
-/* 80 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02,\
15711
-/* 88 */ 0x00, 0x00, 0x12, 0x1e, 0x20, 0x00, 0x00, 0x00,\
15712
-/* 96 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x26, 0x26,\
15709
+/* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x00,\
15710
+/* 72 */ 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00,\
15711
+/* 80 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02,\
15712
+/* 88 */ 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x00, 0x00,\
15713
+/* 96 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x26, 0x26,\
1571315714
/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
1571415715
/* 112 */ 0x00, 0x00, 0x12, 0x00, 0x00, 0x10, 0x00, 0x00,\
15715
-/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
15716
-/* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\
15717
-/* 136 */ 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x00, 0x10,\
15718
-/* 144 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
15719
-/* 152 */ 0x00, 0x10, 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a,\
15720
-/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15721
-/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
15722
-/* 176 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15723
-/* 184 */ 0x00,}
15716
+/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\
15717
+/* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
15718
+/* 136 */ 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x00,\
15719
+/* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
15720
+/* 152 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\
15721
+/* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15722
+/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\
15723
+/* 176 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
15724
+/* 184 */ 0x00, 0x00,}
1572415725
1572515726
/* The resolve3P2Values() routine is able to run faster if it knows
1572615727
** the value of the largest JUMP opcode. The smaller the maximum
1572715728
** JUMP opcode the better, so the mkopcodeh.tcl script that
1572815729
** generated this include file strives to group all JUMP opcodes
@@ -22622,10 +22623,11 @@
2262222623
SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
2262322624
SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem*,u8,u8);
2262422625
SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*);
2262522626
SQLITE_PRIVATE int sqlite3VdbeMemFromBtreeZeroOffset(BtCursor*,u32,Mem*);
2262622627
SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
22628
+SQLITE_PRIVATE void sqlite3VdbeMemReleaseMalloc(Mem*p);
2262722629
SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
2262822630
#ifndef SQLITE_OMIT_WINDOWFUNC
2262922631
SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem*, Mem*, FuncDef*);
2263022632
#endif
2263122633
#if !defined(SQLITE_OMIT_EXPLAIN) || defined(SQLITE_ENABLE_BYTECODE_VTAB)
@@ -23688,11 +23690,11 @@
2368823690
p->Y = sLocal.tm_year + 1900 - iYearDiff;
2368923691
p->M = sLocal.tm_mon + 1;
2369023692
p->D = sLocal.tm_mday;
2369123693
p->h = sLocal.tm_hour;
2369223694
p->m = sLocal.tm_min;
23693
- p->s = sLocal.tm_sec;
23695
+ p->s = sLocal.tm_sec + (p->iJD%1000)*0.001;
2369423696
p->validYMD = 1;
2369523697
p->validHMS = 1;
2369623698
p->validJD = 0;
2369723699
p->rawS = 0;
2369823700
p->validTZ = 0;
@@ -34683,41 +34685,41 @@
3468334685
/* 66 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
3468434686
/* 67 */ "Return" OpHelp(""),
3468534687
/* 68 */ "EndCoroutine" OpHelp(""),
3468634688
/* 69 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
3468734689
/* 70 */ "Halt" OpHelp(""),
34688
- /* 71 */ "Integer" OpHelp("r[P2]=P1"),
34689
- /* 72 */ "Int64" OpHelp("r[P2]=P4"),
34690
- /* 73 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
34691
- /* 74 */ "Null" OpHelp("r[P2..P3]=NULL"),
34692
- /* 75 */ "SoftNull" OpHelp("r[P1]=NULL"),
34693
- /* 76 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
34694
- /* 77 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
34695
- /* 78 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
34696
- /* 79 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
34697
- /* 80 */ "SCopy" OpHelp("r[P2]=r[P1]"),
34698
- /* 81 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
34699
- /* 82 */ "FkCheck" OpHelp(""),
34700
- /* 83 */ "ResultRow" OpHelp("output=r[P1@P2]"),
34701
- /* 84 */ "CollSeq" OpHelp(""),
34702
- /* 85 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
34703
- /* 86 */ "RealAffinity" OpHelp(""),
34704
- /* 87 */ "Cast" OpHelp("affinity(r[P1])"),
34705
- /* 88 */ "Permutation" OpHelp(""),
34706
- /* 89 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
34707
- /* 90 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
34708
- /* 91 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
34709
- /* 92 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
34710
- /* 93 */ "Column" OpHelp("r[P3]=PX"),
34711
- /* 94 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
34712
- /* 95 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
34713
- /* 96 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
34714
- /* 97 */ "Count" OpHelp("r[P2]=count()"),
34715
- /* 98 */ "ReadCookie" OpHelp(""),
34716
- /* 99 */ "SetCookie" OpHelp(""),
34717
- /* 100 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
34718
- /* 101 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
34690
+ /* 71 */ "BeginSubrtn" OpHelp("r[P2]=P1"),
34691
+ /* 72 */ "Integer" OpHelp("r[P2]=P1"),
34692
+ /* 73 */ "Int64" OpHelp("r[P2]=P4"),
34693
+ /* 74 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
34694
+ /* 75 */ "Null" OpHelp("r[P2..P3]=NULL"),
34695
+ /* 76 */ "SoftNull" OpHelp("r[P1]=NULL"),
34696
+ /* 77 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
34697
+ /* 78 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
34698
+ /* 79 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
34699
+ /* 80 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
34700
+ /* 81 */ "SCopy" OpHelp("r[P2]=r[P1]"),
34701
+ /* 82 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
34702
+ /* 83 */ "FkCheck" OpHelp(""),
34703
+ /* 84 */ "ResultRow" OpHelp("output=r[P1@P2]"),
34704
+ /* 85 */ "CollSeq" OpHelp(""),
34705
+ /* 86 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
34706
+ /* 87 */ "RealAffinity" OpHelp(""),
34707
+ /* 88 */ "Cast" OpHelp("affinity(r[P1])"),
34708
+ /* 89 */ "Permutation" OpHelp(""),
34709
+ /* 90 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
34710
+ /* 91 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
34711
+ /* 92 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
34712
+ /* 93 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
34713
+ /* 94 */ "Column" OpHelp("r[P3]=PX"),
34714
+ /* 95 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
34715
+ /* 96 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
34716
+ /* 97 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
34717
+ /* 98 */ "Count" OpHelp("r[P2]=count()"),
34718
+ /* 99 */ "ReadCookie" OpHelp(""),
34719
+ /* 100 */ "SetCookie" OpHelp(""),
34720
+ /* 101 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
3471934721
/* 102 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
3472034722
/* 103 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
3472134723
/* 104 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
3472234724
/* 105 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
3472334725
/* 106 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -34724,83 +34726,84 @@
3472434726
/* 107 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
3472534727
/* 108 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
3472634728
/* 109 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
3472734729
/* 110 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
3472834730
/* 111 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
34729
- /* 112 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
34730
- /* 113 */ "OpenDup" OpHelp(""),
34731
+ /* 112 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
34732
+ /* 113 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
3473134733
/* 114 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
34732
- /* 115 */ "OpenAutoindex" OpHelp("nColumn=P2"),
34733
- /* 116 */ "OpenEphemeral" OpHelp("nColumn=P2"),
34734
+ /* 115 */ "OpenDup" OpHelp(""),
34735
+ /* 116 */ "OpenAutoindex" OpHelp("nColumn=P2"),
3473434736
/* 117 */ "String8" OpHelp("r[P2]='P4'"),
34735
- /* 118 */ "SorterOpen" OpHelp(""),
34736
- /* 119 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
34737
- /* 120 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
34738
- /* 121 */ "Close" OpHelp(""),
34739
- /* 122 */ "ColumnsUsed" OpHelp(""),
34740
- /* 123 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
34741
- /* 124 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
34742
- /* 125 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
34743
- /* 126 */ "NewRowid" OpHelp("r[P2]=rowid"),
34744
- /* 127 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
34745
- /* 128 */ "RowCell" OpHelp(""),
34746
- /* 129 */ "Delete" OpHelp(""),
34747
- /* 130 */ "ResetCount" OpHelp(""),
34748
- /* 131 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
34749
- /* 132 */ "SorterData" OpHelp("r[P2]=data"),
34750
- /* 133 */ "RowData" OpHelp("r[P2]=data"),
34751
- /* 134 */ "Rowid" OpHelp("r[P2]=rowid"),
34752
- /* 135 */ "NullRow" OpHelp(""),
34753
- /* 136 */ "SeekEnd" OpHelp(""),
34754
- /* 137 */ "IdxInsert" OpHelp("key=r[P2]"),
34755
- /* 138 */ "SorterInsert" OpHelp("key=r[P2]"),
34756
- /* 139 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
34757
- /* 140 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
34758
- /* 141 */ "IdxRowid" OpHelp("r[P2]=rowid"),
34759
- /* 142 */ "FinishSeek" OpHelp(""),
34760
- /* 143 */ "Destroy" OpHelp(""),
34761
- /* 144 */ "Clear" OpHelp(""),
34762
- /* 145 */ "ResetSorter" OpHelp(""),
34763
- /* 146 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
34764
- /* 147 */ "SqlExec" OpHelp(""),
34765
- /* 148 */ "ParseSchema" OpHelp(""),
34766
- /* 149 */ "LoadAnalysis" OpHelp(""),
34767
- /* 150 */ "DropTable" OpHelp(""),
34768
- /* 151 */ "DropIndex" OpHelp(""),
34769
- /* 152 */ "DropTrigger" OpHelp(""),
34737
+ /* 118 */ "OpenEphemeral" OpHelp("nColumn=P2"),
34738
+ /* 119 */ "SorterOpen" OpHelp(""),
34739
+ /* 120 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
34740
+ /* 121 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
34741
+ /* 122 */ "Close" OpHelp(""),
34742
+ /* 123 */ "ColumnsUsed" OpHelp(""),
34743
+ /* 124 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
34744
+ /* 125 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
34745
+ /* 126 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
34746
+ /* 127 */ "NewRowid" OpHelp("r[P2]=rowid"),
34747
+ /* 128 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
34748
+ /* 129 */ "RowCell" OpHelp(""),
34749
+ /* 130 */ "Delete" OpHelp(""),
34750
+ /* 131 */ "ResetCount" OpHelp(""),
34751
+ /* 132 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
34752
+ /* 133 */ "SorterData" OpHelp("r[P2]=data"),
34753
+ /* 134 */ "RowData" OpHelp("r[P2]=data"),
34754
+ /* 135 */ "Rowid" OpHelp("r[P2]=rowid"),
34755
+ /* 136 */ "NullRow" OpHelp(""),
34756
+ /* 137 */ "SeekEnd" OpHelp(""),
34757
+ /* 138 */ "IdxInsert" OpHelp("key=r[P2]"),
34758
+ /* 139 */ "SorterInsert" OpHelp("key=r[P2]"),
34759
+ /* 140 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
34760
+ /* 141 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
34761
+ /* 142 */ "IdxRowid" OpHelp("r[P2]=rowid"),
34762
+ /* 143 */ "FinishSeek" OpHelp(""),
34763
+ /* 144 */ "Destroy" OpHelp(""),
34764
+ /* 145 */ "Clear" OpHelp(""),
34765
+ /* 146 */ "ResetSorter" OpHelp(""),
34766
+ /* 147 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
34767
+ /* 148 */ "SqlExec" OpHelp(""),
34768
+ /* 149 */ "ParseSchema" OpHelp(""),
34769
+ /* 150 */ "LoadAnalysis" OpHelp(""),
34770
+ /* 151 */ "DropTable" OpHelp(""),
34771
+ /* 152 */ "DropIndex" OpHelp(""),
3477034772
/* 153 */ "Real" OpHelp("r[P2]=P4"),
34771
- /* 154 */ "IntegrityCk" OpHelp(""),
34772
- /* 155 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
34773
- /* 156 */ "Param" OpHelp(""),
34774
- /* 157 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
34775
- /* 158 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
34776
- /* 159 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
34777
- /* 160 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
34778
- /* 161 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
34779
- /* 162 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
34780
- /* 163 */ "AggValue" OpHelp("r[P3]=value N=P2"),
34781
- /* 164 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
34782
- /* 165 */ "Expire" OpHelp(""),
34783
- /* 166 */ "CursorLock" OpHelp(""),
34784
- /* 167 */ "CursorUnlock" OpHelp(""),
34785
- /* 168 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
34786
- /* 169 */ "VBegin" OpHelp(""),
34787
- /* 170 */ "VCreate" OpHelp(""),
34788
- /* 171 */ "VDestroy" OpHelp(""),
34789
- /* 172 */ "VOpen" OpHelp(""),
34790
- /* 173 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
34791
- /* 174 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
34792
- /* 175 */ "VRename" OpHelp(""),
34793
- /* 176 */ "Pagecount" OpHelp(""),
34794
- /* 177 */ "MaxPgcnt" OpHelp(""),
34795
- /* 178 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
34796
- /* 179 */ "Trace" OpHelp(""),
34797
- /* 180 */ "CursorHint" OpHelp(""),
34798
- /* 181 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
34799
- /* 182 */ "Noop" OpHelp(""),
34800
- /* 183 */ "Explain" OpHelp(""),
34801
- /* 184 */ "Abortable" OpHelp(""),
34773
+ /* 154 */ "DropTrigger" OpHelp(""),
34774
+ /* 155 */ "IntegrityCk" OpHelp(""),
34775
+ /* 156 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
34776
+ /* 157 */ "Param" OpHelp(""),
34777
+ /* 158 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
34778
+ /* 159 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
34779
+ /* 160 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
34780
+ /* 161 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
34781
+ /* 162 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
34782
+ /* 163 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
34783
+ /* 164 */ "AggValue" OpHelp("r[P3]=value N=P2"),
34784
+ /* 165 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
34785
+ /* 166 */ "Expire" OpHelp(""),
34786
+ /* 167 */ "CursorLock" OpHelp(""),
34787
+ /* 168 */ "CursorUnlock" OpHelp(""),
34788
+ /* 169 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
34789
+ /* 170 */ "VBegin" OpHelp(""),
34790
+ /* 171 */ "VCreate" OpHelp(""),
34791
+ /* 172 */ "VDestroy" OpHelp(""),
34792
+ /* 173 */ "VOpen" OpHelp(""),
34793
+ /* 174 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
34794
+ /* 175 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
34795
+ /* 176 */ "VRename" OpHelp(""),
34796
+ /* 177 */ "Pagecount" OpHelp(""),
34797
+ /* 178 */ "MaxPgcnt" OpHelp(""),
34798
+ /* 179 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
34799
+ /* 180 */ "Trace" OpHelp(""),
34800
+ /* 181 */ "CursorHint" OpHelp(""),
34801
+ /* 182 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
34802
+ /* 183 */ "Noop" OpHelp(""),
34803
+ /* 184 */ "Explain" OpHelp(""),
34804
+ /* 185 */ "Abortable" OpHelp(""),
3480234805
};
3480334806
return azName[i];
3480434807
}
3480534808
#endif
3480634809
@@ -58724,10 +58727,11 @@
5872458727
assert( pPager->errCode==SQLITE_OK );
5872558728
assert( pPager->eState>=PAGER_READER );
5872658729
assert( assert_pager_state(pPager) );
5872758730
assert( pPager->hasHeldSharedLock==1 );
5872858731
58732
+ if( pgno==0 ) return SQLITE_CORRUPT_BKPT;
5872958733
pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3);
5873058734
if( pBase==0 ){
5873158735
pPg = 0;
5873258736
rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase);
5873358737
if( rc!=SQLITE_OK ) goto pager_acquire_err;
@@ -58751,14 +58755,14 @@
5875158755
5875258756
}else{
5875358757
/* The pager cache has created a new page. Its content needs to
5875458758
** be initialized. But first some error checks:
5875558759
**
58756
- ** (1) Never try to fetch the locking page
58757
- ** (2) Never try to fetch page 0, which does not exist
58760
+ ** (*) obsolete. Was: maximum page number is 2^31
58761
+ ** (2) Never try to fetch the locking page
5875858762
*/
58759
- if( pgno==PAGER_SJ_PGNO(pPager) || pgno==0 ){
58763
+ if( pgno==PAGER_SJ_PGNO(pPager) ){
5876058764
rc = SQLITE_CORRUPT_BKPT;
5876158765
goto pager_acquire_err;
5876258766
}
5876358767
5876458768
pPg->pPager = pPager;
@@ -66978,11 +66982,11 @@
6697866982
}
6697966983
6698066984
/*
6698166985
** In this version of BtreeMoveto, pKey is a packed index record
6698266986
** such as is generated by the OP_MakeRecord opcode. Unpack the
66983
-** record and then call BtreeMovetoUnpacked() to do the work.
66987
+** record and then call sqlite3BtreeIndexMoveto() to do the work.
6698466988
*/
6698566989
static int btreeMoveto(
6698666990
BtCursor *pCur, /* Cursor open on the btree to be searched */
6698766991
const void *pKey, /* Packed key if the btree is an index */
6698866992
i64 nKey, /* Integer key for tables. Size of pKey for indices */
@@ -68085,11 +68089,10 @@
6808568089
assert( pPage->hdrOffset==(pPage->pgno==1 ? 100 : 0) );
6808668090
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
6808768091
pPage->leaf = (u8)(flagByte>>3); assert( PTF_LEAF == 1<<3 );
6808868092
flagByte &= ~PTF_LEAF;
6808968093
pPage->childPtrSize = 4-4*pPage->leaf;
68090
- pPage->xCellSize = cellSizePtr;
6809168094
pBt = pPage->pBt;
6809268095
if( flagByte==(PTF_LEAFDATA | PTF_INTKEY) ){
6809368096
/* EVIDENCE-OF: R-07291-35328 A value of 5 (0x05) means the page is an
6809468097
** interior table b-tree page. */
6809568098
assert( (PTF_LEAFDATA|PTF_INTKEY)==5 );
@@ -68115,16 +68118,21 @@
6811568118
/* EVIDENCE-OF: R-59615-42828 A value of 10 (0x0a) means the page is a
6811668119
** leaf index b-tree page. */
6811768120
assert( (PTF_ZERODATA|PTF_LEAF)==10 );
6811868121
pPage->intKey = 0;
6811968122
pPage->intKeyLeaf = 0;
68123
+ pPage->xCellSize = cellSizePtr;
6812068124
pPage->xParseCell = btreeParseCellPtrIndex;
6812168125
pPage->maxLocal = pBt->maxLocal;
6812268126
pPage->minLocal = pBt->minLocal;
6812368127
}else{
6812468128
/* EVIDENCE-OF: R-47608-56469 Any other value for the b-tree page type is
6812568129
** an error. */
68130
+ pPage->intKey = 0;
68131
+ pPage->intKeyLeaf = 0;
68132
+ pPage->xCellSize = cellSizePtr;
68133
+ pPage->xParseCell = btreeParseCellPtrIndex;
6812668134
return SQLITE_CORRUPT_PAGE(pPage);
6812768135
}
6812868136
pPage->max1bytePayload = pBt->max1bytePayload;
6812968137
return SQLITE_OK;
6813068138
}
@@ -71544,11 +71552,11 @@
7154471552
}
7154571553
pCur->iPage = 0;
7154671554
pCur->curIntKey = pCur->pPage->intKey;
7154771555
}
7154871556
pRoot = pCur->pPage;
71549
- assert( pRoot->pgno==pCur->pgnoRoot );
71557
+ assert( pRoot->pgno==pCur->pgnoRoot || CORRUPT_DB );
7155071558
7155171559
/* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor
7155271560
** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
7155371561
** NULL, the caller expects a table b-tree. If this is not the case,
7155471562
** return an SQLITE_CORRUPT error.
@@ -71864,10 +71872,73 @@
7186471872
moveto_table_finish:
7186571873
pCur->info.nSize = 0;
7186671874
assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );
7186771875
return rc;
7186871876
}
71877
+
71878
+/*
71879
+** Compare the "idx"-th cell on the page the cursor pCur is currently
71880
+** pointing to to pIdxKey using xRecordCompare. Return negative or
71881
+** zero if the cell is less than or equal pIdxKey. Return positive
71882
+** if unknown.
71883
+**
71884
+** Return value negative: Cell at pCur[idx] less than pIdxKey
71885
+**
71886
+** Return value is zero: Cell at pCur[idx] equals pIdxKey
71887
+**
71888
+** Return value positive: Nothing is known about the relationship
71889
+** of the cell at pCur[idx] and pIdxKey.
71890
+**
71891
+** This routine is part of an optimization. It is always safe to return
71892
+** a positive value as that will cause the optimization to be skipped.
71893
+*/
71894
+static int indexCellCompare(
71895
+ BtCursor *pCur,
71896
+ int idx,
71897
+ UnpackedRecord *pIdxKey,
71898
+ RecordCompare xRecordCompare
71899
+){
71900
+ MemPage *pPage = pCur->pPage;
71901
+ int c;
71902
+ int nCell; /* Size of the pCell cell in bytes */
71903
+ u8 *pCell = findCellPastPtr(pPage, idx);
71904
+
71905
+ nCell = pCell[0];
71906
+ if( nCell<=pPage->max1bytePayload ){
71907
+ /* This branch runs if the record-size field of the cell is a
71908
+ ** single byte varint and the record fits entirely on the main
71909
+ ** b-tree page. */
71910
+ testcase( pCell+nCell+1==pPage->aDataEnd );
71911
+ c = xRecordCompare(nCell, (void*)&pCell[1], pIdxKey);
71912
+ }else if( !(pCell[1] & 0x80)
71913
+ && (nCell = ((nCell&0x7f)<<7) + pCell[1])<=pPage->maxLocal
71914
+ ){
71915
+ /* The record-size field is a 2 byte varint and the record
71916
+ ** fits entirely on the main b-tree page. */
71917
+ testcase( pCell+nCell+2==pPage->aDataEnd );
71918
+ c = xRecordCompare(nCell, (void*)&pCell[2], pIdxKey);
71919
+ }else{
71920
+ /* If the record extends into overflow pages, do not attempt
71921
+ ** the optimization. */
71922
+ c = 99;
71923
+ }
71924
+ return c;
71925
+}
71926
+
71927
+/*
71928
+** Return true (non-zero) if pCur is current pointing to the last
71929
+** page of a table.
71930
+*/
71931
+static int cursorOnLastPage(BtCursor *pCur){
71932
+ int i;
71933
+ assert( pCur->eState==CURSOR_VALID );
71934
+ for(i=0; i<pCur->iPage; i++){
71935
+ MemPage *pPage = pCur->apPage[i];
71936
+ if( pCur->aiIdx[i]<pPage->nCell ) return 0;
71937
+ }
71938
+ return 1;
71939
+}
7186971940
7187071941
/* Move the cursor so that it points to an entry in an index table
7187171942
** near the key pIdxKey. Return a success code.
7187271943
**
7187371944
** If an exact match is not found, then the cursor is always
@@ -71915,25 +71986,58 @@
7191571986
assert( pIdxKey->default_rc==1
7191671987
|| pIdxKey->default_rc==0
7191771988
|| pIdxKey->default_rc==-1
7191871989
);
7191971990
71991
+
71992
+ /* Check to see if we can skip a lot of work. Two cases:
71993
+ **
71994
+ ** (1) If the cursor is already pointing to the very last cell
71995
+ ** in the table and the pIdxKey search key is greater than or
71996
+ ** equal to that last cell, then no movement is required.
71997
+ **
71998
+ ** (2) If the cursor is on the last page of the table and the first
71999
+ ** cell on that last page is less than or equal to the pIdxKey
72000
+ ** search key, then we can start the search on the current page
72001
+ ** without needing to go back to root.
72002
+ */
72003
+ if( pCur->eState==CURSOR_VALID
72004
+ && pCur->pPage->leaf
72005
+ && cursorOnLastPage(pCur)
72006
+ ){
72007
+ int c;
72008
+ if( pCur->ix==pCur->pPage->nCell-1
72009
+ && (c = indexCellCompare(pCur, pCur->ix, pIdxKey, xRecordCompare))<=0
72010
+ ){
72011
+ *pRes = c;
72012
+ return SQLITE_OK; /* Cursor already pointing at the correct spot */
72013
+ }
72014
+ if( pCur->iPage>0
72015
+ && (c = indexCellCompare(pCur, 0, pIdxKey, xRecordCompare))<=0
72016
+ ){
72017
+ pCur->curFlags &= ~BTCF_ValidOvfl;
72018
+ goto bypass_moveto_root; /* Start search on the current page */
72019
+ }
72020
+ }
72021
+
7192072022
rc = moveToRoot(pCur);
7192172023
if( rc ){
7192272024
if( rc==SQLITE_EMPTY ){
7192372025
assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );
7192472026
*pRes = -1;
7192572027
return SQLITE_OK;
7192672028
}
7192772029
return rc;
7192872030
}
72031
+
72032
+bypass_moveto_root:
7192972033
assert( pCur->pPage );
7193072034
assert( pCur->pPage->isInit );
7193172035
assert( pCur->eState==CURSOR_VALID );
7193272036
assert( pCur->pPage->nCell > 0 );
71933
- assert( pCur->iPage==0 || pCur->apPage[0]->intKey==pCur->curIntKey );
71934
- assert( pCur->curIntKey || pIdxKey );
72037
+ assert( pCur->curIntKey==0 );
72038
+ assert( pIdxKey!=0 );
7193572039
for(;;){
7193672040
int lwr, upr, idx, c;
7193772041
Pgno chldPg;
7193872042
MemPage *pPage = pCur->pPage;
7193972043
u8 *pCell; /* Pointer to current cell in pPage */
@@ -71943,11 +72047,11 @@
7194372047
** not run. If this is not the root-page, then the moveToChild() routine
7194472048
** would have already detected db corruption. Similarly, pPage must
7194572049
** be the right kind (index or table) of b-tree page. Otherwise
7194672050
** a moveToChild() or moveToRoot() call would have detected corruption. */
7194772051
assert( pPage->nCell>0 );
71948
- assert( pPage->intKey==(pIdxKey==0) );
72052
+ assert( pPage->intKey==0 );
7194972053
lwr = 0;
7195072054
upr = pPage->nCell-1;
7195172055
idx = upr>>1; /* idx = (lwr+upr)/2; */
7195272056
for(;;){
7195372057
int nCell; /* Size of the pCell cell in bytes */
@@ -75042,11 +75146,11 @@
7504275146
** For an index btree (used for indexes and WITHOUT ROWID tables), the
7504375147
** key is an arbitrary byte sequence stored in pX.pKey,nKey. The
7504475148
** pX.pData,nData,nZero fields must be zero.
7504575149
**
7504675150
** If the seekResult parameter is non-zero, then a successful call to
75047
-** MovetoUnpacked() to seek cursor pCur to (pKey,nKey) has already
75151
+** sqlite3BtreeIndexMoveto() to seek cursor pCur to (pKey,nKey) has already
7504875152
** been performed. In other words, if seekResult!=0 then the cursor
7504975153
** is currently pointing to a cell that will be adjacent to the cell
7505075154
** to be inserted. If seekResult<0 then pCur points to a cell that is
7505175155
** smaller then (pKey,nKey). If seekResult>0 then pCur points to a cell
7505275156
** that is larger than (pKey,nKey).
@@ -75060,11 +75164,11 @@
7506075164
*/
7506175165
SQLITE_PRIVATE int sqlite3BtreeInsert(
7506275166
BtCursor *pCur, /* Insert data into the table of this cursor */
7506375167
const BtreePayload *pX, /* Content of the row to be inserted */
7506475168
int flags, /* True if this is likely an append */
75065
- int seekResult /* Result of prior MovetoUnpacked() call */
75169
+ int seekResult /* Result of prior IndexMoveto() call */
7506675170
){
7506775171
int rc;
7506875172
int loc = seekResult; /* -1: before desired location +1: after */
7506975173
int szNew = 0;
7507075174
int idx;
@@ -78471,10 +78575,18 @@
7847178575
assert( sqlite3VdbeCheckMemInvariants(p) );
7847278576
if( VdbeMemDynamic(p) || p->szMalloc ){
7847378577
vdbeMemClear(p);
7847478578
}
7847578579
}
78580
+
78581
+/* Like sqlite3VdbeMemRelease() but faster for cases where we
78582
+** know in advance that the Mem is not MEM_Dyn or MEM_Agg.
78583
+*/
78584
+SQLITE_PRIVATE void sqlite3VdbeMemReleaseMalloc(Mem *p){
78585
+ assert( !VdbeMemDynamic(p) );
78586
+ if( p->szMalloc ) vdbeMemClear(p);
78587
+}
7847678588
7847778589
/*
7847878590
** Convert a 64-bit IEEE double into a 64-bit signed integer.
7847978591
** If the double is out of range of a 64-bit signed integer then
7848078592
** return the closest available 64-bit signed integer.
@@ -78833,10 +78945,11 @@
7883378945
void *pPtr,
7883478946
const char *zPType,
7883578947
void (*xDestructor)(void*)
7883678948
){
7883778949
assert( pMem->flags==MEM_Null );
78950
+ vdbeMemClear(pMem);
7883878951
pMem->u.zPType = zPType ? zPType : "";
7883978952
pMem->z = pPtr;
7884078953
pMem->flags = MEM_Null|MEM_Dyn|MEM_Subtype|MEM_Term;
7884178954
pMem->eSubtype = 'p';
7884278955
pMem->xDel = xDestructor ? xDestructor : sqlite3NoopDestructor;
@@ -81728,11 +81841,16 @@
8172881841
}while( (--N)>0 );
8172981842
}
8173081843
}
8173181844
8173281845
/*
81733
-** Release an array of N Mem elements
81846
+** Release auxiliary memory held in an array of N Mem elements.
81847
+**
81848
+** After this routine returns, all Mem elements in the array will still
81849
+** be valid. Those Mem elements that were not holding auxiliary resources
81850
+** will be unchanged. Mem elements which had something freed will be
81851
+** set to MEM_Undefined.
8173481852
*/
8173581853
static void releaseMemArray(Mem *p, int N){
8173681854
if( p && N ){
8173781855
Mem *pEnd = &p[N];
8173881856
sqlite3 *db = p->db;
@@ -81761,16 +81879,21 @@
8176181879
testcase( p->flags & MEM_Agg );
8176281880
testcase( p->flags & MEM_Dyn );
8176381881
if( p->flags&(MEM_Agg|MEM_Dyn) ){
8176481882
testcase( (p->flags & MEM_Dyn)!=0 && p->xDel==sqlite3VdbeFrameMemDel );
8176581883
sqlite3VdbeMemRelease(p);
81884
+ p->flags = MEM_Undefined;
8176681885
}else if( p->szMalloc ){
8176781886
sqlite3DbFreeNN(db, p->zMalloc);
8176881887
p->szMalloc = 0;
81888
+ p->flags = MEM_Undefined;
8176981889
}
81770
-
81771
- p->flags = MEM_Undefined;
81890
+#ifdef SQLITE_DEBUG
81891
+ else{
81892
+ p->flags = MEM_Undefined;
81893
+ }
81894
+#endif
8177281895
}while( (++p)<pEnd );
8177381896
}
8177481897
}
8177581898
8177681899
#ifdef SQLITE_DEBUG
@@ -84061,12 +84184,12 @@
8406184184
if( prcErr ) *prcErr = SQLITE_NOMEM_BKPT;
8406284185
rc = 0;
8406384186
}else{
8406484187
rc = pColl->xCmp(pColl->pUser, c1.n, v1, c2.n, v2);
8406584188
}
84066
- sqlite3VdbeMemRelease(&c1);
84067
- sqlite3VdbeMemRelease(&c2);
84189
+ sqlite3VdbeMemReleaseMalloc(&c1);
84190
+ sqlite3VdbeMemReleaseMalloc(&c2);
8406884191
return rc;
8406984192
}
8407084193
}
8407184194
8407284195
/*
@@ -84794,18 +84917,18 @@
8479484917
}
8479584918
8479684919
/* Fetch the integer off the end of the index record */
8479784920
sqlite3VdbeSerialGet((u8*)&m.z[m.n-lenRowid], typeRowid, &v);
8479884921
*rowid = v.u.i;
84799
- sqlite3VdbeMemRelease(&m);
84922
+ sqlite3VdbeMemReleaseMalloc(&m);
8480084923
return SQLITE_OK;
8480184924
8480284925
/* Jump here if database corruption is detected after m has been
8480384926
** allocated. Free the m object and return SQLITE_CORRUPT. */
8480484927
idx_rowid_corruption:
8480584928
testcase( m.szMalloc!=0 );
84806
- sqlite3VdbeMemRelease(&m);
84929
+ sqlite3VdbeMemReleaseMalloc(&m);
8480784930
return SQLITE_CORRUPT_BKPT;
8480884931
}
8480984932
8481084933
/*
8481184934
** Compare the key of the index entry that cursor pC is pointing to against
@@ -84843,11 +84966,11 @@
8484384966
rc = sqlite3VdbeMemFromBtreeZeroOffset(pCur, (u32)nCellKey, &m);
8484484967
if( rc ){
8484584968
return rc;
8484684969
}
8484784970
*res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, pUnpacked, 0);
84848
- sqlite3VdbeMemRelease(&m);
84971
+ sqlite3VdbeMemReleaseMalloc(&m);
8484984972
return SQLITE_OK;
8485084973
}
8485184974
8485284975
/*
8485384976
** This routine sets the value to be returned by subsequent calls to
@@ -85010,11 +85133,11 @@
8501085133
static void vdbeFreeUnpacked(sqlite3 *db, int nField, UnpackedRecord *p){
8501185134
if( p ){
8501285135
int i;
8501385136
for(i=0; i<nField; i++){
8501485137
Mem *pMem = &p->aMem[i];
85015
- if( pMem->zMalloc ) sqlite3VdbeMemRelease(pMem);
85138
+ if( pMem->zMalloc ) sqlite3VdbeMemReleaseMalloc(pMem);
8501685139
}
8501785140
sqlite3DbFreeNN(db, p);
8501885141
}
8501985142
}
8502085143
#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
@@ -88419,14 +88542,18 @@
8841988542
jump_to_p2:
8842088543
pOp = &aOp[pOp->p2 - 1];
8842188544
break;
8842288545
}
8842388546
88424
-/* Opcode: Return P1 * * * *
88547
+/* Opcode: Return P1 * P3 * *
8842588548
**
8842688549
** Jump to the next instruction after the address in register P1. After
8842788550
** the jump, register P1 becomes undefined.
88551
+**
88552
+** P3 is not used by the byte-code engine. However, the code generator
88553
+** sets P3 to address of the associated OP_BeginSubrtn opcode, if there is
88554
+** one.
8842888555
*/
8842988556
case OP_Return: { /* in1 */
8843088557
pIn1 = &aMem[pOp->p1];
8843188558
assert( pIn1->flags==MEM_Int );
8843288559
pOp = &aOp[pIn1->u.i];
@@ -88610,15 +88737,26 @@
8861088737
rc = p->rc ? SQLITE_ERROR : SQLITE_DONE;
8861188738
}
8861288739
goto vdbe_return;
8861388740
}
8861488741
88742
+/* Opcode: BeginSubrtn P1 P2 * * *
88743
+** Synopsis: r[P2]=P1
88744
+**
88745
+** Mark the beginning of a subroutine by loading the integer value P1
88746
+** into register r[P2]. The P2 register is used to store the return
88747
+** address of the subroutine call.
88748
+**
88749
+** This opcode is identical to OP_Integer. It has a different name
88750
+** only to make the byte code easier to read and verify.
88751
+*/
8861588752
/* Opcode: Integer P1 P2 * * *
8861688753
** Synopsis: r[P2]=P1
8861788754
**
8861888755
** The 32-bit integer value P1 is written into register P2.
8861988756
*/
88757
+case OP_BeginSubrtn:
8862088758
case OP_Integer: { /* out2 */
8862188759
pOut = out2Prerelease(p, pOp);
8862288760
pOut->u.i = pOp->p1;
8862388761
break;
8862488762
}
@@ -90055,14 +90193,22 @@
9005590193
case OP_Offset: { /* out3 */
9005690194
VdbeCursor *pC; /* The VDBE cursor */
9005790195
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
9005890196
pC = p->apCsr[pOp->p1];
9005990197
pOut = &p->aMem[pOp->p3];
90060
- if( NEVER(pC==0) || pC->eCurType!=CURTYPE_BTREE ){
90198
+ if( pC==0 || pC->eCurType!=CURTYPE_BTREE ){
9006190199
sqlite3VdbeMemSetNull(pOut);
9006290200
}else{
90063
- sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));
90201
+ if( pC->deferredMoveto ){
90202
+ rc = sqlite3VdbeFinishMoveto(pC);
90203
+ if( rc ) goto abort_due_to_error;
90204
+ }
90205
+ if( sqlite3BtreeEof(pC->uc.pCursor) ){
90206
+ sqlite3VdbeMemSetNull(pOut);
90207
+ }else{
90208
+ sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));
90209
+ }
9006490210
}
9006590211
break;
9006690212
}
9006790213
#endif /* SQLITE_ENABLE_OFFSET_SQL_FUNC */
9006890214
@@ -93773,11 +93919,11 @@
9377393919
}
9377493920
sqlite3VdbeMemInit(&m, db, 0);
9377593921
rc = sqlite3VdbeMemFromBtreeZeroOffset(pCur, (u32)nCellKey, &m);
9377693922
if( rc ) goto abort_due_to_error;
9377793923
res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, &r, 0);
93778
- sqlite3VdbeMemRelease(&m);
93924
+ sqlite3VdbeMemReleaseMalloc(&m);
9377993925
}
9378093926
/* End of inlined sqlite3VdbeIdxKeyCompare() */
9378193927
9378293928
assert( (OP_IdxLE&1)==(OP_IdxLT&1) && (OP_IdxGE&1)==(OP_IdxGT&1) );
9378393929
if( (pOp->opcode&1)==(OP_IdxLT&1) ){
@@ -105554,12 +105700,11 @@
105554105700
assert( !ExprUseYWin(pExpr) );
105555105701
ExprSetProperty(pExpr, EP_Subrtn);
105556105702
assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
105557105703
pExpr->y.sub.regReturn = ++pParse->nMem;
105558105704
pExpr->y.sub.iAddr =
105559
- sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
105560
- VdbeComment((v, "return address"));
105705
+ sqlite3VdbeAddOp2(v, OP_BeginSubrtn, 0, pExpr->y.sub.regReturn) + 1;
105561105706
105562105707
addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
105563105708
}
105564105709
105565105710
/* Check to see if this is a vector IN operator */
@@ -105657,10 +105802,11 @@
105657105802
** disable the test that was generated above that makes sure
105658105803
** this code only executes once. Because for a non-constant
105659105804
** expression we need to rerun this code each time.
105660105805
*/
105661105806
if( addrOnce && !sqlite3ExprIsConstant(pE2) ){
105807
+ sqlite3VdbeChangeToNoop(v, addrOnce-1);
105662105808
sqlite3VdbeChangeToNoop(v, addrOnce);
105663105809
ExprClearProperty(pExpr, EP_Subrtn);
105664105810
addrOnce = 0;
105665105811
}
105666105812
@@ -105677,11 +105823,14 @@
105677105823
}
105678105824
if( addrOnce ){
105679105825
sqlite3VdbeJumpHere(v, addrOnce);
105680105826
/* Subroutine return */
105681105827
assert( ExprUseYSub(pExpr) );
105682
- sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
105828
+ assert( sqlite3VdbeGetOp(v,pExpr->y.sub.iAddr-1)->opcode==OP_BeginSubrtn
105829
+ || pParse->nErr );
105830
+ sqlite3VdbeAddOp3(v, OP_Return, pExpr->y.sub.regReturn, 0,
105831
+ pExpr->y.sub.iAddr-1);
105683105832
sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
105684105833
sqlite3ClearTempRegCache(pParse);
105685105834
}
105686105835
}
105687105836
#endif /* SQLITE_OMIT_SUBQUERY */
@@ -105732,13 +105881,11 @@
105732105881
assert( !ExprUseYWin(pExpr) );
105733105882
assert( !ExprHasProperty(pExpr, EP_Reduced|EP_TokenOnly) );
105734105883
ExprSetProperty(pExpr, EP_Subrtn);
105735105884
pExpr->y.sub.regReturn = ++pParse->nMem;
105736105885
pExpr->y.sub.iAddr =
105737
- sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
105738
- VdbeComment((v, "return address"));
105739
-
105886
+ sqlite3VdbeAddOp2(v, OP_BeginSubrtn, 0, pExpr->y.sub.regReturn) + 1;
105740105887
105741105888
/* The evaluation of the EXISTS/SELECT must be repeated every time it
105742105889
** is encountered if any of the following is true:
105743105890
**
105744105891
** * The right-hand side is a correlated subquery
@@ -105807,11 +105954,14 @@
105807105954
sqlite3VdbeJumpHere(v, addrOnce);
105808105955
}
105809105956
105810105957
/* Subroutine return */
105811105958
assert( ExprUseYSub(pExpr) );
105812
- sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
105959
+ assert( sqlite3VdbeGetOp(v,pExpr->y.sub.iAddr-1)->opcode==OP_BeginSubrtn
105960
+ || pParse->nErr );
105961
+ sqlite3VdbeAddOp3(v, OP_Return, pExpr->y.sub.regReturn, 0,
105962
+ pExpr->y.sub.iAddr-1);
105813105963
sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
105814105964
sqlite3ClearTempRegCache(pParse);
105815105965
return rReg;
105816105966
}
105817105967
#endif /* SQLITE_OMIT_SUBQUERY */
@@ -123338,12 +123488,12 @@
123338123488
#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
123339123489
INLINE_FUNC(unlikely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
123340123490
INLINE_FUNC(likelihood, 2, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
123341123491
INLINE_FUNC(likely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
123342123492
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
123343
- FUNCTION2(sqlite_offset, 1, 0, 0, noopFunc, SQLITE_FUNC_OFFSET|
123344
- SQLITE_FUNC_TYPEOF),
123493
+ {1, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|SQLITE_FUNC_OFFSET|SQLITE_FUNC_TYPEOF,
123494
+ 0, 0, noopFunc, 0, 0, 0, "sqlite_offset", {0} },
123345123495
#endif
123346123496
FUNCTION(ltrim, 1, 1, 0, trimFunc ),
123347123497
FUNCTION(ltrim, 2, 1, 0, trimFunc ),
123348123498
FUNCTION(rtrim, 1, 2, 0, trimFunc ),
123349123499
FUNCTION(rtrim, 2, 2, 0, trimFunc ),
@@ -142452,10 +142602,11 @@
142452142602
const char *zEnd /* End of SQL text */
142453142603
){
142454142604
sqlite3 *db = pParse->db;
142455142605
TriggerStep *pTriggerStep;
142456142606
142607
+ if( pParse->nErr ) return 0;
142457142608
pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);
142458142609
if( pTriggerStep ){
142459142610
char *z = (char*)&pTriggerStep[1];
142460142611
memcpy(z, pName->z, pName->n);
142461142612
sqlite3Dequote(z);
@@ -148265,10 +148416,11 @@
148265148416
sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur);
148266148417
VdbeCoverageIf(v, bRev==0);
148267148418
VdbeCoverageIf(v, bRev!=0);
148268148419
VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
148269148420
j = sqlite3VdbeAddOp0(v, OP_Goto);
148421
+ assert( pLevel->addrSkip==0 );
148270148422
pLevel->addrSkip = sqlite3VdbeAddOp4Int(v, (bRev?OP_SeekLT:OP_SeekGT),
148271148423
iIdxCur, 0, regBase, nSkip);
148272148424
VdbeCoverageIf(v, bRev==0);
148273148425
VdbeCoverageIf(v, bRev!=0);
148274148426
sqlite3VdbeJumpHere(v, j);
@@ -148870,10 +149022,11 @@
148870149022
){
148871149023
while( ++iLevel < pWInfo->nLevel ){
148872149024
WhereLevel *pLevel = &pWInfo->a[iLevel];
148873149025
WhereLoop *pLoop = pLevel->pWLoop;
148874149026
if( pLevel->regFilter==0 ) continue;
149027
+ if( pLevel->pWLoop->nSkip ) continue;
148875149028
/* ,--- Because sqlite3ConstructBloomFilter() has will not have set
148876149029
** vvvvv--' pLevel->regFilter if this were true. */
148877149030
if( NEVER(pLoop->prereq & notReady) ) continue;
148878149031
if( pLoop->wsFlags & WHERE_IPK ){
148879149032
WhereTerm *pTerm = pLoop->aLTerm[0];
@@ -149004,11 +149157,10 @@
149004149157
** to access the data.
149005149158
*/
149006149159
int iReg; /* P3 Value for OP_VFilter */
149007149160
int addrNotFound;
149008149161
int nConstraint = pLoop->nLTerm;
149009
- int iIn; /* Counter for IN constraints */
149010149162
149011149163
iReg = sqlite3GetTempRange(pParse, nConstraint+2);
149012149164
addrNotFound = pLevel->addrBrk;
149013149165
for(j=0; j<nConstraint; j++){
149014149166
int iTarget = iReg+j+2;
@@ -149050,67 +149202,71 @@
149050149202
if( db->mallocFailed ) pLoop->u.vtab.idxStr = 0;
149051149203
pLevel->p1 = iCur;
149052149204
pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext;
149053149205
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
149054149206
assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 );
149055
- if( pLoop->wsFlags & WHERE_IN_ABLE ){
149056
- iIn = pLevel->u.in.nIn;
149057
- }else{
149058
- iIn = 0;
149059
- }
149060
- for(j=nConstraint-1; j>=0; j--){
149061
- int bIn; /* True to generate byte code to loop over RHS IN values */
149207
+
149208
+ for(j=0; j<nConstraint; j++){
149062149209
pTerm = pLoop->aLTerm[j];
149210
+ if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){
149211
+ disableTerm(pLevel, pTerm);
149212
+ continue;
149213
+ }
149063149214
if( (pTerm->eOperator & WO_IN)!=0
149064149215
&& (SMASKBIT32(j) & pLoop->u.vtab.mHandleIn)==0
149216
+ && !db->mallocFailed
149065149217
){
149066
- bIn = 1;
149067
- }else{
149068
- bIn = 0;
149069
- }
149070
- if( bIn ) iIn--;
149071
- if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){
149072
- disableTerm(pLevel, pTerm);
149073
- }else if( bIn && sqlite3ExprVectorSize(pTerm->pExpr->pLeft)==1 ){
149074149218
Expr *pCompare; /* The comparison operator */
149075149219
Expr *pRight; /* RHS of the comparison */
149076149220
VdbeOp *pOp; /* Opcode to access the value of the IN constraint */
149221
+ int iIn; /* IN loop corresponding to the j-th constraint */
149077149222
149078149223
/* Reload the constraint value into reg[iReg+j+2]. The same value
149079149224
** was loaded into the same register prior to the OP_VFilter, but
149080149225
** the xFilter implementation might have changed the datatype or
149081
- ** encoding of the value in the register, so it *must* be reloaded. */
149082
- assert( pLevel->u.in.aInLoop!=0 || db->mallocFailed );
149083
- if( !db->mallocFailed ){
149084
- assert( iIn>=0 && iIn<pLevel->u.in.nIn );
149226
+ ** encoding of the value in the register, so it *must* be reloaded.
149227
+ */
149228
+ for(iIn=0; ALWAYS(iIn<pLevel->u.in.nIn); iIn++){
149085149229
pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[iIn].addrInTop);
149086
- assert( pOp->opcode==OP_Column || pOp->opcode==OP_Rowid );
149087
- assert( pOp->opcode!=OP_Column || pOp->p3==iReg+j+2 );
149088
- assert( pOp->opcode!=OP_Rowid || pOp->p2==iReg+j+2 );
149089
- testcase( pOp->opcode==OP_Rowid );
149090
- sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
149230
+ if( (pOp->opcode==OP_Column && pOp->p3==iReg+j+2)
149231
+ || (pOp->opcode==OP_Rowid && pOp->p2==iReg+j+2)
149232
+ ){
149233
+ testcase( pOp->opcode==OP_Rowid );
149234
+ sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
149235
+ break;
149236
+ }
149091149237
}
149092149238
149093149239
/* Generate code that will continue to the next row if
149094
- ** the IN constraint is not satisfied */
149240
+ ** the IN constraint is not satisfied
149241
+ */
149095149242
pCompare = sqlite3PExpr(pParse, TK_EQ, 0, 0);
149096
- assert( pCompare!=0 || db->mallocFailed );
149097
- if( pCompare ){
149098
- pCompare->pLeft = pTerm->pExpr->pLeft;
149243
+ if( !db->mallocFailed ){
149244
+ int iFld = pTerm->u.x.iField;
149245
+ Expr *pLeft = pTerm->pExpr->pLeft;
149246
+ assert( pLeft!=0 );
149247
+ if( iFld>0 ){
149248
+ assert( pLeft->op==TK_VECTOR );
149249
+ assert( ExprUseXList(pLeft) );
149250
+ assert( iFld<=pLeft->x.pList->nExpr );
149251
+ pCompare->pLeft = pLeft->x.pList->a[iFld-1].pExpr;
149252
+ }else{
149253
+ pCompare->pLeft = pLeft;
149254
+ }
149099149255
pCompare->pRight = pRight = sqlite3Expr(db, TK_REGISTER, 0);
149100149256
if( pRight ){
149101149257
pRight->iTable = iReg+j+2;
149102149258
sqlite3ExprIfFalse(
149103149259
pParse, pCompare, pLevel->addrCont, SQLITE_JUMPIFNULL
149104149260
);
149105149261
}
149106149262
pCompare->pLeft = 0;
149107
- sqlite3ExprDelete(db, pCompare);
149108149263
}
149264
+ sqlite3ExprDelete(db, pCompare);
149109149265
}
149110149266
}
149111
- assert( iIn==0 || db->mallocFailed );
149267
+
149112149268
/* These registers need to be preserved in case there is an IN operator
149113149269
** loop. So we could deallocate the registers here (and potentially
149114149270
** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0. But it seems
149115149271
** simpler and safer to simply not reuse the registers.
149116149272
**
@@ -149816,10 +149972,18 @@
149816149972
** 2022-02-04: Do not push down slices of a row-value comparison.
149817149973
** In other words, "w" or "y" may not be a slice of a vector. Otherwise,
149818149974
** the initialization of the right-hand operand of the vector comparison
149819149975
** might not occur, or might occur only in an OR branch that is not
149820149976
** taken. dbsqlfuzz 80a9fade844b4fb43564efc972bcb2c68270f5d1.
149977
+ **
149978
+ ** 2022-03-03: Do not push down expressions that involve subqueries.
149979
+ ** The subquery might get coded as a subroutine. Any table-references
149980
+ ** in the subquery might be resolved to index-references for the index on
149981
+ ** the OR branch in which the subroutine is coded. But if the subroutine
149982
+ ** is invoked from a different OR branch that uses a different index, such
149983
+ ** index-references will not work. tag-20220303a
149984
+ ** https://sqlite.org/forum/forumpost/36937b197273d403
149821149985
*/
149822149986
if( pWC->nTerm>1 ){
149823149987
int iTerm;
149824149988
for(iTerm=0; iTerm<pWC->nTerm; iTerm++){
149825149989
Expr *pExpr = pWC->a[iTerm].pExpr;
@@ -149829,11 +149993,11 @@
149829149993
testcase( pWC->a[iTerm].wtFlags & TERM_SLICE );
149830149994
if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED|TERM_SLICE))!=0 ){
149831149995
continue;
149832149996
}
149833149997
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
149834
- testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );
149998
+ if( ExprHasProperty(pExpr, EP_Subquery) ) continue; /* tag-20220303a */
149835149999
pExpr = sqlite3ExprDup(db, pExpr, 0);
149836150000
pAndExpr = sqlite3ExprAnd(pParse, pAndExpr, pExpr);
149837150001
}
149838150002
if( pAndExpr ){
149839150003
/* The extra 0x10000 bit on the opcode is masked off and does not
@@ -153106,11 +153270,14 @@
153106153270
VdbeCoverage(v);
153107153271
sqlite3VdbeJumpHere(v, addrTop);
153108153272
pLoop->wsFlags &= ~WHERE_BLOOMFILTER;
153109153273
if( OptimizationDisabled(pParse->db, SQLITE_BloomPulldown) ) break;
153110153274
while( ++iLevel < pWInfo->nLevel ){
153275
+ const SrcItem *pTabItem;
153111153276
pLevel = &pWInfo->a[iLevel];
153277
+ pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
153278
+ if( pTabItem->fg.jointype & JT_LEFT ) continue;
153112153279
pLoop = pLevel->pWLoop;
153113153280
if( NEVER(pLoop==0) ) continue;
153114153281
if( pLoop->prereq & notReady ) continue;
153115153282
if( (pLoop->wsFlags & (WHERE_BLOOMFILTER|WHERE_COLUMN_IN))
153116153283
==WHERE_BLOOMFILTER
@@ -234388,11 +234555,11 @@
234388234555
int nArg, /* Number of args */
234389234556
sqlite3_value **apUnused /* Function arguments */
234390234557
){
234391234558
assert( nArg==0 );
234392234559
UNUSED_PARAM2(nArg, apUnused);
234393
- sqlite3_result_text(pCtx, "fts5: 2022-03-02 01:02:16 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b", -1, SQLITE_TRANSIENT);
234560
+ sqlite3_result_text(pCtx, "fts5: 2022-03-07 18:32:08 ae464a18d74bf44fc95bc335e75e6a57dc974f6d6a3d603133594039fb589af2", -1, SQLITE_TRANSIENT);
234394234561
}
234395234562
234396234563
/*
234397234564
** Return true if zName is the extension on one of the shadow tables used
234398234565
** by this module.
234399234566
--- 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.39.0"
456 #define SQLITE_VERSION_NUMBER 3039000
457 #define SQLITE_SOURCE_ID "2022-03-02 01:02:16 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -15569,41 +15569,41 @@
15569 #define OP_Function 66 /* synopsis: r[P3]=func(r[P2@NP]) */
15570 #define OP_Return 67
15571 #define OP_EndCoroutine 68
15572 #define OP_HaltIfNull 69 /* synopsis: if r[P3]=null halt */
15573 #define OP_Halt 70
15574 #define OP_Integer 71 /* synopsis: r[P2]=P1 */
15575 #define OP_Int64 72 /* synopsis: r[P2]=P4 */
15576 #define OP_String 73 /* synopsis: r[P2]='P4' (len=P1) */
15577 #define OP_Null 74 /* synopsis: r[P2..P3]=NULL */
15578 #define OP_SoftNull 75 /* synopsis: r[P1]=NULL */
15579 #define OP_Blob 76 /* synopsis: r[P2]=P4 (len=P1) */
15580 #define OP_Variable 77 /* synopsis: r[P2]=parameter(P1,P4) */
15581 #define OP_Move 78 /* synopsis: r[P2@P3]=r[P1@P3] */
15582 #define OP_Copy 79 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
15583 #define OP_SCopy 80 /* synopsis: r[P2]=r[P1] */
15584 #define OP_IntCopy 81 /* synopsis: r[P2]=r[P1] */
15585 #define OP_FkCheck 82
15586 #define OP_ResultRow 83 /* synopsis: output=r[P1@P2] */
15587 #define OP_CollSeq 84
15588 #define OP_AddImm 85 /* synopsis: r[P1]=r[P1]+P2 */
15589 #define OP_RealAffinity 86
15590 #define OP_Cast 87 /* synopsis: affinity(r[P1]) */
15591 #define OP_Permutation 88
15592 #define OP_Compare 89 /* synopsis: r[P1@P3] <-> r[P2@P3] */
15593 #define OP_IsTrue 90 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
15594 #define OP_ZeroOrNull 91 /* synopsis: r[P2] = 0 OR NULL */
15595 #define OP_Offset 92 /* synopsis: r[P3] = sqlite_offset(P1) */
15596 #define OP_Column 93 /* synopsis: r[P3]=PX */
15597 #define OP_TypeCheck 94 /* synopsis: typecheck(r[P1@P2]) */
15598 #define OP_Affinity 95 /* synopsis: affinity(r[P1@P2]) */
15599 #define OP_MakeRecord 96 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
15600 #define OP_Count 97 /* synopsis: r[P2]=count() */
15601 #define OP_ReadCookie 98
15602 #define OP_SetCookie 99
15603 #define OP_ReopenIdx 100 /* synopsis: root=P2 iDb=P3 */
15604 #define OP_OpenRead 101 /* synopsis: root=P2 iDb=P3 */
15605 #define OP_BitAnd 102 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
15606 #define OP_BitOr 103 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
15607 #define OP_ShiftLeft 104 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
15608 #define OP_ShiftRight 105 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
15609 #define OP_Add 106 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -15610,83 +15610,84 @@
15610 #define OP_Subtract 107 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
15611 #define OP_Multiply 108 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
15612 #define OP_Divide 109 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
15613 #define OP_Remainder 110 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
15614 #define OP_Concat 111 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
15615 #define OP_OpenWrite 112 /* synopsis: root=P2 iDb=P3 */
15616 #define OP_OpenDup 113
15617 #define OP_BitNot 114 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
15618 #define OP_OpenAutoindex 115 /* synopsis: nColumn=P2 */
15619 #define OP_OpenEphemeral 116 /* synopsis: nColumn=P2 */
15620 #define OP_String8 117 /* same as TK_STRING, synopsis: r[P2]='P4' */
15621 #define OP_SorterOpen 118
15622 #define OP_SequenceTest 119 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
15623 #define OP_OpenPseudo 120 /* synopsis: P3 columns in r[P2] */
15624 #define OP_Close 121
15625 #define OP_ColumnsUsed 122
15626 #define OP_SeekScan 123 /* synopsis: Scan-ahead up to P1 rows */
15627 #define OP_SeekHit 124 /* synopsis: set P2<=seekHit<=P3 */
15628 #define OP_Sequence 125 /* synopsis: r[P2]=cursor[P1].ctr++ */
15629 #define OP_NewRowid 126 /* synopsis: r[P2]=rowid */
15630 #define OP_Insert 127 /* synopsis: intkey=r[P3] data=r[P2] */
15631 #define OP_RowCell 128
15632 #define OP_Delete 129
15633 #define OP_ResetCount 130
15634 #define OP_SorterCompare 131 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
15635 #define OP_SorterData 132 /* synopsis: r[P2]=data */
15636 #define OP_RowData 133 /* synopsis: r[P2]=data */
15637 #define OP_Rowid 134 /* synopsis: r[P2]=rowid */
15638 #define OP_NullRow 135
15639 #define OP_SeekEnd 136
15640 #define OP_IdxInsert 137 /* synopsis: key=r[P2] */
15641 #define OP_SorterInsert 138 /* synopsis: key=r[P2] */
15642 #define OP_IdxDelete 139 /* synopsis: key=r[P2@P3] */
15643 #define OP_DeferredSeek 140 /* synopsis: Move P3 to P1.rowid if needed */
15644 #define OP_IdxRowid 141 /* synopsis: r[P2]=rowid */
15645 #define OP_FinishSeek 142
15646 #define OP_Destroy 143
15647 #define OP_Clear 144
15648 #define OP_ResetSorter 145
15649 #define OP_CreateBtree 146 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
15650 #define OP_SqlExec 147
15651 #define OP_ParseSchema 148
15652 #define OP_LoadAnalysis 149
15653 #define OP_DropTable 150
15654 #define OP_DropIndex 151
15655 #define OP_DropTrigger 152
15656 #define OP_Real 153 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15657 #define OP_IntegrityCk 154
15658 #define OP_RowSetAdd 155 /* synopsis: rowset(P1)=r[P2] */
15659 #define OP_Param 156
15660 #define OP_FkCounter 157 /* synopsis: fkctr[P1]+=P2 */
15661 #define OP_MemMax 158 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15662 #define OP_OffsetLimit 159 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15663 #define OP_AggInverse 160 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
15664 #define OP_AggStep 161 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15665 #define OP_AggStep1 162 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15666 #define OP_AggValue 163 /* synopsis: r[P3]=value N=P2 */
15667 #define OP_AggFinal 164 /* synopsis: accum=r[P1] N=P2 */
15668 #define OP_Expire 165
15669 #define OP_CursorLock 166
15670 #define OP_CursorUnlock 167
15671 #define OP_TableLock 168 /* synopsis: iDb=P1 root=P2 write=P3 */
15672 #define OP_VBegin 169
15673 #define OP_VCreate 170
15674 #define OP_VDestroy 171
15675 #define OP_VOpen 172
15676 #define OP_VInitIn 173 /* synopsis: r[P2]=ValueList(P1,P3) */
15677 #define OP_VColumn 174 /* synopsis: r[P3]=vcolumn(P2) */
15678 #define OP_VRename 175
15679 #define OP_Pagecount 176
15680 #define OP_MaxPgcnt 177
15681 #define OP_FilterAdd 178 /* synopsis: filter(P1) += key(P3@P4) */
15682 #define OP_Trace 179
15683 #define OP_CursorHint 180
15684 #define OP_ReleaseReg 181 /* synopsis: release r[P1@P2] mask P3 */
15685 #define OP_Noop 182
15686 #define OP_Explain 183
15687 #define OP_Abortable 184
 
15688
15689 /* Properties such as "out2" or "jump" that are specified in
15690 ** comments following the "case" for each opcode in the vdbe.c
15691 ** are encoded into bitvectors as follows:
15692 */
@@ -15703,26 +15704,26 @@
15703 /* 24 */ 0x01, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x01,\
15704 /* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
15705 /* 40 */ 0x01, 0x01, 0x01, 0x26, 0x26, 0x23, 0x0b, 0x01,\
15706 /* 48 */ 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
15707 /* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x01, 0x01,\
15708 /* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\
15709 /* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00,\
15710 /* 80 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02,\
15711 /* 88 */ 0x00, 0x00, 0x12, 0x1e, 0x20, 0x00, 0x00, 0x00,\
15712 /* 96 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x26, 0x26,\
15713 /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
15714 /* 112 */ 0x00, 0x00, 0x12, 0x00, 0x00, 0x10, 0x00, 0x00,\
15715 /* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
15716 /* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\
15717 /* 136 */ 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x00, 0x10,\
15718 /* 144 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
15719 /* 152 */ 0x00, 0x10, 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a,\
15720 /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15721 /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
15722 /* 176 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15723 /* 184 */ 0x00,}
15724
15725 /* The resolve3P2Values() routine is able to run faster if it knows
15726 ** the value of the largest JUMP opcode. The smaller the maximum
15727 ** JUMP opcode the better, so the mkopcodeh.tcl script that
15728 ** generated this include file strives to group all JUMP opcodes
@@ -22622,10 +22623,11 @@
22622 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
22623 SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem*,u8,u8);
22624 SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*);
22625 SQLITE_PRIVATE int sqlite3VdbeMemFromBtreeZeroOffset(BtCursor*,u32,Mem*);
22626 SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
 
22627 SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
22628 #ifndef SQLITE_OMIT_WINDOWFUNC
22629 SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem*, Mem*, FuncDef*);
22630 #endif
22631 #if !defined(SQLITE_OMIT_EXPLAIN) || defined(SQLITE_ENABLE_BYTECODE_VTAB)
@@ -23688,11 +23690,11 @@
23688 p->Y = sLocal.tm_year + 1900 - iYearDiff;
23689 p->M = sLocal.tm_mon + 1;
23690 p->D = sLocal.tm_mday;
23691 p->h = sLocal.tm_hour;
23692 p->m = sLocal.tm_min;
23693 p->s = sLocal.tm_sec;
23694 p->validYMD = 1;
23695 p->validHMS = 1;
23696 p->validJD = 0;
23697 p->rawS = 0;
23698 p->validTZ = 0;
@@ -34683,41 +34685,41 @@
34683 /* 66 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
34684 /* 67 */ "Return" OpHelp(""),
34685 /* 68 */ "EndCoroutine" OpHelp(""),
34686 /* 69 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
34687 /* 70 */ "Halt" OpHelp(""),
34688 /* 71 */ "Integer" OpHelp("r[P2]=P1"),
34689 /* 72 */ "Int64" OpHelp("r[P2]=P4"),
34690 /* 73 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
34691 /* 74 */ "Null" OpHelp("r[P2..P3]=NULL"),
34692 /* 75 */ "SoftNull" OpHelp("r[P1]=NULL"),
34693 /* 76 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
34694 /* 77 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
34695 /* 78 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
34696 /* 79 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
34697 /* 80 */ "SCopy" OpHelp("r[P2]=r[P1]"),
34698 /* 81 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
34699 /* 82 */ "FkCheck" OpHelp(""),
34700 /* 83 */ "ResultRow" OpHelp("output=r[P1@P2]"),
34701 /* 84 */ "CollSeq" OpHelp(""),
34702 /* 85 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
34703 /* 86 */ "RealAffinity" OpHelp(""),
34704 /* 87 */ "Cast" OpHelp("affinity(r[P1])"),
34705 /* 88 */ "Permutation" OpHelp(""),
34706 /* 89 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
34707 /* 90 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
34708 /* 91 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
34709 /* 92 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
34710 /* 93 */ "Column" OpHelp("r[P3]=PX"),
34711 /* 94 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
34712 /* 95 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
34713 /* 96 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
34714 /* 97 */ "Count" OpHelp("r[P2]=count()"),
34715 /* 98 */ "ReadCookie" OpHelp(""),
34716 /* 99 */ "SetCookie" OpHelp(""),
34717 /* 100 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
34718 /* 101 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
34719 /* 102 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
34720 /* 103 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
34721 /* 104 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
34722 /* 105 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
34723 /* 106 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -34724,83 +34726,84 @@
34724 /* 107 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
34725 /* 108 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
34726 /* 109 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
34727 /* 110 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
34728 /* 111 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
34729 /* 112 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
34730 /* 113 */ "OpenDup" OpHelp(""),
34731 /* 114 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
34732 /* 115 */ "OpenAutoindex" OpHelp("nColumn=P2"),
34733 /* 116 */ "OpenEphemeral" OpHelp("nColumn=P2"),
34734 /* 117 */ "String8" OpHelp("r[P2]='P4'"),
34735 /* 118 */ "SorterOpen" OpHelp(""),
34736 /* 119 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
34737 /* 120 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
34738 /* 121 */ "Close" OpHelp(""),
34739 /* 122 */ "ColumnsUsed" OpHelp(""),
34740 /* 123 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
34741 /* 124 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
34742 /* 125 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
34743 /* 126 */ "NewRowid" OpHelp("r[P2]=rowid"),
34744 /* 127 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
34745 /* 128 */ "RowCell" OpHelp(""),
34746 /* 129 */ "Delete" OpHelp(""),
34747 /* 130 */ "ResetCount" OpHelp(""),
34748 /* 131 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
34749 /* 132 */ "SorterData" OpHelp("r[P2]=data"),
34750 /* 133 */ "RowData" OpHelp("r[P2]=data"),
34751 /* 134 */ "Rowid" OpHelp("r[P2]=rowid"),
34752 /* 135 */ "NullRow" OpHelp(""),
34753 /* 136 */ "SeekEnd" OpHelp(""),
34754 /* 137 */ "IdxInsert" OpHelp("key=r[P2]"),
34755 /* 138 */ "SorterInsert" OpHelp("key=r[P2]"),
34756 /* 139 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
34757 /* 140 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
34758 /* 141 */ "IdxRowid" OpHelp("r[P2]=rowid"),
34759 /* 142 */ "FinishSeek" OpHelp(""),
34760 /* 143 */ "Destroy" OpHelp(""),
34761 /* 144 */ "Clear" OpHelp(""),
34762 /* 145 */ "ResetSorter" OpHelp(""),
34763 /* 146 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
34764 /* 147 */ "SqlExec" OpHelp(""),
34765 /* 148 */ "ParseSchema" OpHelp(""),
34766 /* 149 */ "LoadAnalysis" OpHelp(""),
34767 /* 150 */ "DropTable" OpHelp(""),
34768 /* 151 */ "DropIndex" OpHelp(""),
34769 /* 152 */ "DropTrigger" OpHelp(""),
34770 /* 153 */ "Real" OpHelp("r[P2]=P4"),
34771 /* 154 */ "IntegrityCk" OpHelp(""),
34772 /* 155 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
34773 /* 156 */ "Param" OpHelp(""),
34774 /* 157 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
34775 /* 158 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
34776 /* 159 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
34777 /* 160 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
34778 /* 161 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
34779 /* 162 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
34780 /* 163 */ "AggValue" OpHelp("r[P3]=value N=P2"),
34781 /* 164 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
34782 /* 165 */ "Expire" OpHelp(""),
34783 /* 166 */ "CursorLock" OpHelp(""),
34784 /* 167 */ "CursorUnlock" OpHelp(""),
34785 /* 168 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
34786 /* 169 */ "VBegin" OpHelp(""),
34787 /* 170 */ "VCreate" OpHelp(""),
34788 /* 171 */ "VDestroy" OpHelp(""),
34789 /* 172 */ "VOpen" OpHelp(""),
34790 /* 173 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
34791 /* 174 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
34792 /* 175 */ "VRename" OpHelp(""),
34793 /* 176 */ "Pagecount" OpHelp(""),
34794 /* 177 */ "MaxPgcnt" OpHelp(""),
34795 /* 178 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
34796 /* 179 */ "Trace" OpHelp(""),
34797 /* 180 */ "CursorHint" OpHelp(""),
34798 /* 181 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
34799 /* 182 */ "Noop" OpHelp(""),
34800 /* 183 */ "Explain" OpHelp(""),
34801 /* 184 */ "Abortable" OpHelp(""),
 
34802 };
34803 return azName[i];
34804 }
34805 #endif
34806
@@ -58724,10 +58727,11 @@
58724 assert( pPager->errCode==SQLITE_OK );
58725 assert( pPager->eState>=PAGER_READER );
58726 assert( assert_pager_state(pPager) );
58727 assert( pPager->hasHeldSharedLock==1 );
58728
 
58729 pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3);
58730 if( pBase==0 ){
58731 pPg = 0;
58732 rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase);
58733 if( rc!=SQLITE_OK ) goto pager_acquire_err;
@@ -58751,14 +58755,14 @@
58751
58752 }else{
58753 /* The pager cache has created a new page. Its content needs to
58754 ** be initialized. But first some error checks:
58755 **
58756 ** (1) Never try to fetch the locking page
58757 ** (2) Never try to fetch page 0, which does not exist
58758 */
58759 if( pgno==PAGER_SJ_PGNO(pPager) || pgno==0 ){
58760 rc = SQLITE_CORRUPT_BKPT;
58761 goto pager_acquire_err;
58762 }
58763
58764 pPg->pPager = pPager;
@@ -66978,11 +66982,11 @@
66978 }
66979
66980 /*
66981 ** In this version of BtreeMoveto, pKey is a packed index record
66982 ** such as is generated by the OP_MakeRecord opcode. Unpack the
66983 ** record and then call BtreeMovetoUnpacked() to do the work.
66984 */
66985 static int btreeMoveto(
66986 BtCursor *pCur, /* Cursor open on the btree to be searched */
66987 const void *pKey, /* Packed key if the btree is an index */
66988 i64 nKey, /* Integer key for tables. Size of pKey for indices */
@@ -68085,11 +68089,10 @@
68085 assert( pPage->hdrOffset==(pPage->pgno==1 ? 100 : 0) );
68086 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
68087 pPage->leaf = (u8)(flagByte>>3); assert( PTF_LEAF == 1<<3 );
68088 flagByte &= ~PTF_LEAF;
68089 pPage->childPtrSize = 4-4*pPage->leaf;
68090 pPage->xCellSize = cellSizePtr;
68091 pBt = pPage->pBt;
68092 if( flagByte==(PTF_LEAFDATA | PTF_INTKEY) ){
68093 /* EVIDENCE-OF: R-07291-35328 A value of 5 (0x05) means the page is an
68094 ** interior table b-tree page. */
68095 assert( (PTF_LEAFDATA|PTF_INTKEY)==5 );
@@ -68115,16 +68118,21 @@
68115 /* EVIDENCE-OF: R-59615-42828 A value of 10 (0x0a) means the page is a
68116 ** leaf index b-tree page. */
68117 assert( (PTF_ZERODATA|PTF_LEAF)==10 );
68118 pPage->intKey = 0;
68119 pPage->intKeyLeaf = 0;
 
68120 pPage->xParseCell = btreeParseCellPtrIndex;
68121 pPage->maxLocal = pBt->maxLocal;
68122 pPage->minLocal = pBt->minLocal;
68123 }else{
68124 /* EVIDENCE-OF: R-47608-56469 Any other value for the b-tree page type is
68125 ** an error. */
 
 
 
 
68126 return SQLITE_CORRUPT_PAGE(pPage);
68127 }
68128 pPage->max1bytePayload = pBt->max1bytePayload;
68129 return SQLITE_OK;
68130 }
@@ -71544,11 +71552,11 @@
71544 }
71545 pCur->iPage = 0;
71546 pCur->curIntKey = pCur->pPage->intKey;
71547 }
71548 pRoot = pCur->pPage;
71549 assert( pRoot->pgno==pCur->pgnoRoot );
71550
71551 /* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor
71552 ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
71553 ** NULL, the caller expects a table b-tree. If this is not the case,
71554 ** return an SQLITE_CORRUPT error.
@@ -71864,10 +71872,73 @@
71864 moveto_table_finish:
71865 pCur->info.nSize = 0;
71866 assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );
71867 return rc;
71868 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71869
71870 /* Move the cursor so that it points to an entry in an index table
71871 ** near the key pIdxKey. Return a success code.
71872 **
71873 ** If an exact match is not found, then the cursor is always
@@ -71915,25 +71986,58 @@
71915 assert( pIdxKey->default_rc==1
71916 || pIdxKey->default_rc==0
71917 || pIdxKey->default_rc==-1
71918 );
71919
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71920 rc = moveToRoot(pCur);
71921 if( rc ){
71922 if( rc==SQLITE_EMPTY ){
71923 assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );
71924 *pRes = -1;
71925 return SQLITE_OK;
71926 }
71927 return rc;
71928 }
 
 
71929 assert( pCur->pPage );
71930 assert( pCur->pPage->isInit );
71931 assert( pCur->eState==CURSOR_VALID );
71932 assert( pCur->pPage->nCell > 0 );
71933 assert( pCur->iPage==0 || pCur->apPage[0]->intKey==pCur->curIntKey );
71934 assert( pCur->curIntKey || pIdxKey );
71935 for(;;){
71936 int lwr, upr, idx, c;
71937 Pgno chldPg;
71938 MemPage *pPage = pCur->pPage;
71939 u8 *pCell; /* Pointer to current cell in pPage */
@@ -71943,11 +72047,11 @@
71943 ** not run. If this is not the root-page, then the moveToChild() routine
71944 ** would have already detected db corruption. Similarly, pPage must
71945 ** be the right kind (index or table) of b-tree page. Otherwise
71946 ** a moveToChild() or moveToRoot() call would have detected corruption. */
71947 assert( pPage->nCell>0 );
71948 assert( pPage->intKey==(pIdxKey==0) );
71949 lwr = 0;
71950 upr = pPage->nCell-1;
71951 idx = upr>>1; /* idx = (lwr+upr)/2; */
71952 for(;;){
71953 int nCell; /* Size of the pCell cell in bytes */
@@ -75042,11 +75146,11 @@
75042 ** For an index btree (used for indexes and WITHOUT ROWID tables), the
75043 ** key is an arbitrary byte sequence stored in pX.pKey,nKey. The
75044 ** pX.pData,nData,nZero fields must be zero.
75045 **
75046 ** If the seekResult parameter is non-zero, then a successful call to
75047 ** MovetoUnpacked() to seek cursor pCur to (pKey,nKey) has already
75048 ** been performed. In other words, if seekResult!=0 then the cursor
75049 ** is currently pointing to a cell that will be adjacent to the cell
75050 ** to be inserted. If seekResult<0 then pCur points to a cell that is
75051 ** smaller then (pKey,nKey). If seekResult>0 then pCur points to a cell
75052 ** that is larger than (pKey,nKey).
@@ -75060,11 +75164,11 @@
75060 */
75061 SQLITE_PRIVATE int sqlite3BtreeInsert(
75062 BtCursor *pCur, /* Insert data into the table of this cursor */
75063 const BtreePayload *pX, /* Content of the row to be inserted */
75064 int flags, /* True if this is likely an append */
75065 int seekResult /* Result of prior MovetoUnpacked() call */
75066 ){
75067 int rc;
75068 int loc = seekResult; /* -1: before desired location +1: after */
75069 int szNew = 0;
75070 int idx;
@@ -78471,10 +78575,18 @@
78471 assert( sqlite3VdbeCheckMemInvariants(p) );
78472 if( VdbeMemDynamic(p) || p->szMalloc ){
78473 vdbeMemClear(p);
78474 }
78475 }
 
 
 
 
 
 
 
 
78476
78477 /*
78478 ** Convert a 64-bit IEEE double into a 64-bit signed integer.
78479 ** If the double is out of range of a 64-bit signed integer then
78480 ** return the closest available 64-bit signed integer.
@@ -78833,10 +78945,11 @@
78833 void *pPtr,
78834 const char *zPType,
78835 void (*xDestructor)(void*)
78836 ){
78837 assert( pMem->flags==MEM_Null );
 
78838 pMem->u.zPType = zPType ? zPType : "";
78839 pMem->z = pPtr;
78840 pMem->flags = MEM_Null|MEM_Dyn|MEM_Subtype|MEM_Term;
78841 pMem->eSubtype = 'p';
78842 pMem->xDel = xDestructor ? xDestructor : sqlite3NoopDestructor;
@@ -81728,11 +81841,16 @@
81728 }while( (--N)>0 );
81729 }
81730 }
81731
81732 /*
81733 ** Release an array of N Mem elements
 
 
 
 
 
81734 */
81735 static void releaseMemArray(Mem *p, int N){
81736 if( p && N ){
81737 Mem *pEnd = &p[N];
81738 sqlite3 *db = p->db;
@@ -81761,16 +81879,21 @@
81761 testcase( p->flags & MEM_Agg );
81762 testcase( p->flags & MEM_Dyn );
81763 if( p->flags&(MEM_Agg|MEM_Dyn) ){
81764 testcase( (p->flags & MEM_Dyn)!=0 && p->xDel==sqlite3VdbeFrameMemDel );
81765 sqlite3VdbeMemRelease(p);
 
81766 }else if( p->szMalloc ){
81767 sqlite3DbFreeNN(db, p->zMalloc);
81768 p->szMalloc = 0;
 
81769 }
81770
81771 p->flags = MEM_Undefined;
 
 
 
81772 }while( (++p)<pEnd );
81773 }
81774 }
81775
81776 #ifdef SQLITE_DEBUG
@@ -84061,12 +84184,12 @@
84061 if( prcErr ) *prcErr = SQLITE_NOMEM_BKPT;
84062 rc = 0;
84063 }else{
84064 rc = pColl->xCmp(pColl->pUser, c1.n, v1, c2.n, v2);
84065 }
84066 sqlite3VdbeMemRelease(&c1);
84067 sqlite3VdbeMemRelease(&c2);
84068 return rc;
84069 }
84070 }
84071
84072 /*
@@ -84794,18 +84917,18 @@
84794 }
84795
84796 /* Fetch the integer off the end of the index record */
84797 sqlite3VdbeSerialGet((u8*)&m.z[m.n-lenRowid], typeRowid, &v);
84798 *rowid = v.u.i;
84799 sqlite3VdbeMemRelease(&m);
84800 return SQLITE_OK;
84801
84802 /* Jump here if database corruption is detected after m has been
84803 ** allocated. Free the m object and return SQLITE_CORRUPT. */
84804 idx_rowid_corruption:
84805 testcase( m.szMalloc!=0 );
84806 sqlite3VdbeMemRelease(&m);
84807 return SQLITE_CORRUPT_BKPT;
84808 }
84809
84810 /*
84811 ** Compare the key of the index entry that cursor pC is pointing to against
@@ -84843,11 +84966,11 @@
84843 rc = sqlite3VdbeMemFromBtreeZeroOffset(pCur, (u32)nCellKey, &m);
84844 if( rc ){
84845 return rc;
84846 }
84847 *res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, pUnpacked, 0);
84848 sqlite3VdbeMemRelease(&m);
84849 return SQLITE_OK;
84850 }
84851
84852 /*
84853 ** This routine sets the value to be returned by subsequent calls to
@@ -85010,11 +85133,11 @@
85010 static void vdbeFreeUnpacked(sqlite3 *db, int nField, UnpackedRecord *p){
85011 if( p ){
85012 int i;
85013 for(i=0; i<nField; i++){
85014 Mem *pMem = &p->aMem[i];
85015 if( pMem->zMalloc ) sqlite3VdbeMemRelease(pMem);
85016 }
85017 sqlite3DbFreeNN(db, p);
85018 }
85019 }
85020 #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
@@ -88419,14 +88542,18 @@
88419 jump_to_p2:
88420 pOp = &aOp[pOp->p2 - 1];
88421 break;
88422 }
88423
88424 /* Opcode: Return P1 * * * *
88425 **
88426 ** Jump to the next instruction after the address in register P1. After
88427 ** the jump, register P1 becomes undefined.
 
 
 
 
88428 */
88429 case OP_Return: { /* in1 */
88430 pIn1 = &aMem[pOp->p1];
88431 assert( pIn1->flags==MEM_Int );
88432 pOp = &aOp[pIn1->u.i];
@@ -88610,15 +88737,26 @@
88610 rc = p->rc ? SQLITE_ERROR : SQLITE_DONE;
88611 }
88612 goto vdbe_return;
88613 }
88614
 
 
 
 
 
 
 
 
 
 
88615 /* Opcode: Integer P1 P2 * * *
88616 ** Synopsis: r[P2]=P1
88617 **
88618 ** The 32-bit integer value P1 is written into register P2.
88619 */
 
88620 case OP_Integer: { /* out2 */
88621 pOut = out2Prerelease(p, pOp);
88622 pOut->u.i = pOp->p1;
88623 break;
88624 }
@@ -90055,14 +90193,22 @@
90055 case OP_Offset: { /* out3 */
90056 VdbeCursor *pC; /* The VDBE cursor */
90057 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
90058 pC = p->apCsr[pOp->p1];
90059 pOut = &p->aMem[pOp->p3];
90060 if( NEVER(pC==0) || pC->eCurType!=CURTYPE_BTREE ){
90061 sqlite3VdbeMemSetNull(pOut);
90062 }else{
90063 sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));
 
 
 
 
 
 
 
 
90064 }
90065 break;
90066 }
90067 #endif /* SQLITE_ENABLE_OFFSET_SQL_FUNC */
90068
@@ -93773,11 +93919,11 @@
93773 }
93774 sqlite3VdbeMemInit(&m, db, 0);
93775 rc = sqlite3VdbeMemFromBtreeZeroOffset(pCur, (u32)nCellKey, &m);
93776 if( rc ) goto abort_due_to_error;
93777 res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, &r, 0);
93778 sqlite3VdbeMemRelease(&m);
93779 }
93780 /* End of inlined sqlite3VdbeIdxKeyCompare() */
93781
93782 assert( (OP_IdxLE&1)==(OP_IdxLT&1) && (OP_IdxGE&1)==(OP_IdxGT&1) );
93783 if( (pOp->opcode&1)==(OP_IdxLT&1) ){
@@ -105554,12 +105700,11 @@
105554 assert( !ExprUseYWin(pExpr) );
105555 ExprSetProperty(pExpr, EP_Subrtn);
105556 assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
105557 pExpr->y.sub.regReturn = ++pParse->nMem;
105558 pExpr->y.sub.iAddr =
105559 sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
105560 VdbeComment((v, "return address"));
105561
105562 addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
105563 }
105564
105565 /* Check to see if this is a vector IN operator */
@@ -105657,10 +105802,11 @@
105657 ** disable the test that was generated above that makes sure
105658 ** this code only executes once. Because for a non-constant
105659 ** expression we need to rerun this code each time.
105660 */
105661 if( addrOnce && !sqlite3ExprIsConstant(pE2) ){
 
105662 sqlite3VdbeChangeToNoop(v, addrOnce);
105663 ExprClearProperty(pExpr, EP_Subrtn);
105664 addrOnce = 0;
105665 }
105666
@@ -105677,11 +105823,14 @@
105677 }
105678 if( addrOnce ){
105679 sqlite3VdbeJumpHere(v, addrOnce);
105680 /* Subroutine return */
105681 assert( ExprUseYSub(pExpr) );
105682 sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
 
 
 
105683 sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
105684 sqlite3ClearTempRegCache(pParse);
105685 }
105686 }
105687 #endif /* SQLITE_OMIT_SUBQUERY */
@@ -105732,13 +105881,11 @@
105732 assert( !ExprUseYWin(pExpr) );
105733 assert( !ExprHasProperty(pExpr, EP_Reduced|EP_TokenOnly) );
105734 ExprSetProperty(pExpr, EP_Subrtn);
105735 pExpr->y.sub.regReturn = ++pParse->nMem;
105736 pExpr->y.sub.iAddr =
105737 sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
105738 VdbeComment((v, "return address"));
105739
105740
105741 /* The evaluation of the EXISTS/SELECT must be repeated every time it
105742 ** is encountered if any of the following is true:
105743 **
105744 ** * The right-hand side is a correlated subquery
@@ -105807,11 +105954,14 @@
105807 sqlite3VdbeJumpHere(v, addrOnce);
105808 }
105809
105810 /* Subroutine return */
105811 assert( ExprUseYSub(pExpr) );
105812 sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
 
 
 
105813 sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
105814 sqlite3ClearTempRegCache(pParse);
105815 return rReg;
105816 }
105817 #endif /* SQLITE_OMIT_SUBQUERY */
@@ -123338,12 +123488,12 @@
123338 #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
123339 INLINE_FUNC(unlikely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
123340 INLINE_FUNC(likelihood, 2, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
123341 INLINE_FUNC(likely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
123342 #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
123343 FUNCTION2(sqlite_offset, 1, 0, 0, noopFunc, SQLITE_FUNC_OFFSET|
123344 SQLITE_FUNC_TYPEOF),
123345 #endif
123346 FUNCTION(ltrim, 1, 1, 0, trimFunc ),
123347 FUNCTION(ltrim, 2, 1, 0, trimFunc ),
123348 FUNCTION(rtrim, 1, 2, 0, trimFunc ),
123349 FUNCTION(rtrim, 2, 2, 0, trimFunc ),
@@ -142452,10 +142602,11 @@
142452 const char *zEnd /* End of SQL text */
142453 ){
142454 sqlite3 *db = pParse->db;
142455 TriggerStep *pTriggerStep;
142456
 
142457 pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);
142458 if( pTriggerStep ){
142459 char *z = (char*)&pTriggerStep[1];
142460 memcpy(z, pName->z, pName->n);
142461 sqlite3Dequote(z);
@@ -148265,10 +148416,11 @@
148265 sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur);
148266 VdbeCoverageIf(v, bRev==0);
148267 VdbeCoverageIf(v, bRev!=0);
148268 VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
148269 j = sqlite3VdbeAddOp0(v, OP_Goto);
 
148270 pLevel->addrSkip = sqlite3VdbeAddOp4Int(v, (bRev?OP_SeekLT:OP_SeekGT),
148271 iIdxCur, 0, regBase, nSkip);
148272 VdbeCoverageIf(v, bRev==0);
148273 VdbeCoverageIf(v, bRev!=0);
148274 sqlite3VdbeJumpHere(v, j);
@@ -148870,10 +149022,11 @@
148870 ){
148871 while( ++iLevel < pWInfo->nLevel ){
148872 WhereLevel *pLevel = &pWInfo->a[iLevel];
148873 WhereLoop *pLoop = pLevel->pWLoop;
148874 if( pLevel->regFilter==0 ) continue;
 
148875 /* ,--- Because sqlite3ConstructBloomFilter() has will not have set
148876 ** vvvvv--' pLevel->regFilter if this were true. */
148877 if( NEVER(pLoop->prereq & notReady) ) continue;
148878 if( pLoop->wsFlags & WHERE_IPK ){
148879 WhereTerm *pTerm = pLoop->aLTerm[0];
@@ -149004,11 +149157,10 @@
149004 ** to access the data.
149005 */
149006 int iReg; /* P3 Value for OP_VFilter */
149007 int addrNotFound;
149008 int nConstraint = pLoop->nLTerm;
149009 int iIn; /* Counter for IN constraints */
149010
149011 iReg = sqlite3GetTempRange(pParse, nConstraint+2);
149012 addrNotFound = pLevel->addrBrk;
149013 for(j=0; j<nConstraint; j++){
149014 int iTarget = iReg+j+2;
@@ -149050,67 +149202,71 @@
149050 if( db->mallocFailed ) pLoop->u.vtab.idxStr = 0;
149051 pLevel->p1 = iCur;
149052 pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext;
149053 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
149054 assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 );
149055 if( pLoop->wsFlags & WHERE_IN_ABLE ){
149056 iIn = pLevel->u.in.nIn;
149057 }else{
149058 iIn = 0;
149059 }
149060 for(j=nConstraint-1; j>=0; j--){
149061 int bIn; /* True to generate byte code to loop over RHS IN values */
149062 pTerm = pLoop->aLTerm[j];
 
 
 
 
149063 if( (pTerm->eOperator & WO_IN)!=0
149064 && (SMASKBIT32(j) & pLoop->u.vtab.mHandleIn)==0
 
149065 ){
149066 bIn = 1;
149067 }else{
149068 bIn = 0;
149069 }
149070 if( bIn ) iIn--;
149071 if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){
149072 disableTerm(pLevel, pTerm);
149073 }else if( bIn && sqlite3ExprVectorSize(pTerm->pExpr->pLeft)==1 ){
149074 Expr *pCompare; /* The comparison operator */
149075 Expr *pRight; /* RHS of the comparison */
149076 VdbeOp *pOp; /* Opcode to access the value of the IN constraint */
 
149077
149078 /* Reload the constraint value into reg[iReg+j+2]. The same value
149079 ** was loaded into the same register prior to the OP_VFilter, but
149080 ** the xFilter implementation might have changed the datatype or
149081 ** encoding of the value in the register, so it *must* be reloaded. */
149082 assert( pLevel->u.in.aInLoop!=0 || db->mallocFailed );
149083 if( !db->mallocFailed ){
149084 assert( iIn>=0 && iIn<pLevel->u.in.nIn );
149085 pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[iIn].addrInTop);
149086 assert( pOp->opcode==OP_Column || pOp->opcode==OP_Rowid );
149087 assert( pOp->opcode!=OP_Column || pOp->p3==iReg+j+2 );
149088 assert( pOp->opcode!=OP_Rowid || pOp->p2==iReg+j+2 );
149089 testcase( pOp->opcode==OP_Rowid );
149090 sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
 
 
149091 }
149092
149093 /* Generate code that will continue to the next row if
149094 ** the IN constraint is not satisfied */
 
149095 pCompare = sqlite3PExpr(pParse, TK_EQ, 0, 0);
149096 assert( pCompare!=0 || db->mallocFailed );
149097 if( pCompare ){
149098 pCompare->pLeft = pTerm->pExpr->pLeft;
 
 
 
 
 
 
 
 
 
149099 pCompare->pRight = pRight = sqlite3Expr(db, TK_REGISTER, 0);
149100 if( pRight ){
149101 pRight->iTable = iReg+j+2;
149102 sqlite3ExprIfFalse(
149103 pParse, pCompare, pLevel->addrCont, SQLITE_JUMPIFNULL
149104 );
149105 }
149106 pCompare->pLeft = 0;
149107 sqlite3ExprDelete(db, pCompare);
149108 }
 
149109 }
149110 }
149111 assert( iIn==0 || db->mallocFailed );
149112 /* These registers need to be preserved in case there is an IN operator
149113 ** loop. So we could deallocate the registers here (and potentially
149114 ** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0. But it seems
149115 ** simpler and safer to simply not reuse the registers.
149116 **
@@ -149816,10 +149972,18 @@
149816 ** 2022-02-04: Do not push down slices of a row-value comparison.
149817 ** In other words, "w" or "y" may not be a slice of a vector. Otherwise,
149818 ** the initialization of the right-hand operand of the vector comparison
149819 ** might not occur, or might occur only in an OR branch that is not
149820 ** taken. dbsqlfuzz 80a9fade844b4fb43564efc972bcb2c68270f5d1.
 
 
 
 
 
 
 
 
149821 */
149822 if( pWC->nTerm>1 ){
149823 int iTerm;
149824 for(iTerm=0; iTerm<pWC->nTerm; iTerm++){
149825 Expr *pExpr = pWC->a[iTerm].pExpr;
@@ -149829,11 +149993,11 @@
149829 testcase( pWC->a[iTerm].wtFlags & TERM_SLICE );
149830 if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED|TERM_SLICE))!=0 ){
149831 continue;
149832 }
149833 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
149834 testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );
149835 pExpr = sqlite3ExprDup(db, pExpr, 0);
149836 pAndExpr = sqlite3ExprAnd(pParse, pAndExpr, pExpr);
149837 }
149838 if( pAndExpr ){
149839 /* The extra 0x10000 bit on the opcode is masked off and does not
@@ -153106,11 +153270,14 @@
153106 VdbeCoverage(v);
153107 sqlite3VdbeJumpHere(v, addrTop);
153108 pLoop->wsFlags &= ~WHERE_BLOOMFILTER;
153109 if( OptimizationDisabled(pParse->db, SQLITE_BloomPulldown) ) break;
153110 while( ++iLevel < pWInfo->nLevel ){
 
153111 pLevel = &pWInfo->a[iLevel];
 
 
153112 pLoop = pLevel->pWLoop;
153113 if( NEVER(pLoop==0) ) continue;
153114 if( pLoop->prereq & notReady ) continue;
153115 if( (pLoop->wsFlags & (WHERE_BLOOMFILTER|WHERE_COLUMN_IN))
153116 ==WHERE_BLOOMFILTER
@@ -234388,11 +234555,11 @@
234388 int nArg, /* Number of args */
234389 sqlite3_value **apUnused /* Function arguments */
234390 ){
234391 assert( nArg==0 );
234392 UNUSED_PARAM2(nArg, apUnused);
234393 sqlite3_result_text(pCtx, "fts5: 2022-03-02 01:02:16 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b", -1, SQLITE_TRANSIENT);
234394 }
234395
234396 /*
234397 ** Return true if zName is the extension on one of the shadow tables used
234398 ** by this module.
234399
--- 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.39.0"
456 #define SQLITE_VERSION_NUMBER 3039000
457 #define SQLITE_SOURCE_ID "2022-03-07 18:32:08 ae464a18d74bf44fc95bc335e75e6a57dc974f6d6a3d603133594039fb589af2"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -15569,41 +15569,41 @@
15569 #define OP_Function 66 /* synopsis: r[P3]=func(r[P2@NP]) */
15570 #define OP_Return 67
15571 #define OP_EndCoroutine 68
15572 #define OP_HaltIfNull 69 /* synopsis: if r[P3]=null halt */
15573 #define OP_Halt 70
15574 #define OP_BeginSubrtn 71 /* synopsis: r[P2]=P1 */
15575 #define OP_Integer 72 /* synopsis: r[P2]=P1 */
15576 #define OP_Int64 73 /* synopsis: r[P2]=P4 */
15577 #define OP_String 74 /* synopsis: r[P2]='P4' (len=P1) */
15578 #define OP_Null 75 /* synopsis: r[P2..P3]=NULL */
15579 #define OP_SoftNull 76 /* synopsis: r[P1]=NULL */
15580 #define OP_Blob 77 /* synopsis: r[P2]=P4 (len=P1) */
15581 #define OP_Variable 78 /* synopsis: r[P2]=parameter(P1,P4) */
15582 #define OP_Move 79 /* synopsis: r[P2@P3]=r[P1@P3] */
15583 #define OP_Copy 80 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
15584 #define OP_SCopy 81 /* synopsis: r[P2]=r[P1] */
15585 #define OP_IntCopy 82 /* synopsis: r[P2]=r[P1] */
15586 #define OP_FkCheck 83
15587 #define OP_ResultRow 84 /* synopsis: output=r[P1@P2] */
15588 #define OP_CollSeq 85
15589 #define OP_AddImm 86 /* synopsis: r[P1]=r[P1]+P2 */
15590 #define OP_RealAffinity 87
15591 #define OP_Cast 88 /* synopsis: affinity(r[P1]) */
15592 #define OP_Permutation 89
15593 #define OP_Compare 90 /* synopsis: r[P1@P3] <-> r[P2@P3] */
15594 #define OP_IsTrue 91 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
15595 #define OP_ZeroOrNull 92 /* synopsis: r[P2] = 0 OR NULL */
15596 #define OP_Offset 93 /* synopsis: r[P3] = sqlite_offset(P1) */
15597 #define OP_Column 94 /* synopsis: r[P3]=PX */
15598 #define OP_TypeCheck 95 /* synopsis: typecheck(r[P1@P2]) */
15599 #define OP_Affinity 96 /* synopsis: affinity(r[P1@P2]) */
15600 #define OP_MakeRecord 97 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
15601 #define OP_Count 98 /* synopsis: r[P2]=count() */
15602 #define OP_ReadCookie 99
15603 #define OP_SetCookie 100
15604 #define OP_ReopenIdx 101 /* synopsis: root=P2 iDb=P3 */
15605 #define OP_BitAnd 102 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
15606 #define OP_BitOr 103 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
15607 #define OP_ShiftLeft 104 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
15608 #define OP_ShiftRight 105 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
15609 #define OP_Add 106 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -15610,83 +15610,84 @@
15610 #define OP_Subtract 107 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
15611 #define OP_Multiply 108 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
15612 #define OP_Divide 109 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
15613 #define OP_Remainder 110 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
15614 #define OP_Concat 111 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
15615 #define OP_OpenRead 112 /* synopsis: root=P2 iDb=P3 */
15616 #define OP_OpenWrite 113 /* synopsis: root=P2 iDb=P3 */
15617 #define OP_BitNot 114 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
15618 #define OP_OpenDup 115
15619 #define OP_OpenAutoindex 116 /* synopsis: nColumn=P2 */
15620 #define OP_String8 117 /* same as TK_STRING, synopsis: r[P2]='P4' */
15621 #define OP_OpenEphemeral 118 /* synopsis: nColumn=P2 */
15622 #define OP_SorterOpen 119
15623 #define OP_SequenceTest 120 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
15624 #define OP_OpenPseudo 121 /* synopsis: P3 columns in r[P2] */
15625 #define OP_Close 122
15626 #define OP_ColumnsUsed 123
15627 #define OP_SeekScan 124 /* synopsis: Scan-ahead up to P1 rows */
15628 #define OP_SeekHit 125 /* synopsis: set P2<=seekHit<=P3 */
15629 #define OP_Sequence 126 /* synopsis: r[P2]=cursor[P1].ctr++ */
15630 #define OP_NewRowid 127 /* synopsis: r[P2]=rowid */
15631 #define OP_Insert 128 /* synopsis: intkey=r[P3] data=r[P2] */
15632 #define OP_RowCell 129
15633 #define OP_Delete 130
15634 #define OP_ResetCount 131
15635 #define OP_SorterCompare 132 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
15636 #define OP_SorterData 133 /* synopsis: r[P2]=data */
15637 #define OP_RowData 134 /* synopsis: r[P2]=data */
15638 #define OP_Rowid 135 /* synopsis: r[P2]=rowid */
15639 #define OP_NullRow 136
15640 #define OP_SeekEnd 137
15641 #define OP_IdxInsert 138 /* synopsis: key=r[P2] */
15642 #define OP_SorterInsert 139 /* synopsis: key=r[P2] */
15643 #define OP_IdxDelete 140 /* synopsis: key=r[P2@P3] */
15644 #define OP_DeferredSeek 141 /* synopsis: Move P3 to P1.rowid if needed */
15645 #define OP_IdxRowid 142 /* synopsis: r[P2]=rowid */
15646 #define OP_FinishSeek 143
15647 #define OP_Destroy 144
15648 #define OP_Clear 145
15649 #define OP_ResetSorter 146
15650 #define OP_CreateBtree 147 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
15651 #define OP_SqlExec 148
15652 #define OP_ParseSchema 149
15653 #define OP_LoadAnalysis 150
15654 #define OP_DropTable 151
15655 #define OP_DropIndex 152
15656 #define OP_Real 153 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15657 #define OP_DropTrigger 154
15658 #define OP_IntegrityCk 155
15659 #define OP_RowSetAdd 156 /* synopsis: rowset(P1)=r[P2] */
15660 #define OP_Param 157
15661 #define OP_FkCounter 158 /* synopsis: fkctr[P1]+=P2 */
15662 #define OP_MemMax 159 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15663 #define OP_OffsetLimit 160 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15664 #define OP_AggInverse 161 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
15665 #define OP_AggStep 162 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15666 #define OP_AggStep1 163 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15667 #define OP_AggValue 164 /* synopsis: r[P3]=value N=P2 */
15668 #define OP_AggFinal 165 /* synopsis: accum=r[P1] N=P2 */
15669 #define OP_Expire 166
15670 #define OP_CursorLock 167
15671 #define OP_CursorUnlock 168
15672 #define OP_TableLock 169 /* synopsis: iDb=P1 root=P2 write=P3 */
15673 #define OP_VBegin 170
15674 #define OP_VCreate 171
15675 #define OP_VDestroy 172
15676 #define OP_VOpen 173
15677 #define OP_VInitIn 174 /* synopsis: r[P2]=ValueList(P1,P3) */
15678 #define OP_VColumn 175 /* synopsis: r[P3]=vcolumn(P2) */
15679 #define OP_VRename 176
15680 #define OP_Pagecount 177
15681 #define OP_MaxPgcnt 178
15682 #define OP_FilterAdd 179 /* synopsis: filter(P1) += key(P3@P4) */
15683 #define OP_Trace 180
15684 #define OP_CursorHint 181
15685 #define OP_ReleaseReg 182 /* synopsis: release r[P1@P2] mask P3 */
15686 #define OP_Noop 183
15687 #define OP_Explain 184
15688 #define OP_Abortable 185
15689
15690 /* Properties such as "out2" or "jump" that are specified in
15691 ** comments following the "case" for each opcode in the vdbe.c
15692 ** are encoded into bitvectors as follows:
15693 */
@@ -15703,26 +15704,26 @@
15704 /* 24 */ 0x01, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x01,\
15705 /* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
15706 /* 40 */ 0x01, 0x01, 0x01, 0x26, 0x26, 0x23, 0x0b, 0x01,\
15707 /* 48 */ 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
15708 /* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x01, 0x01,\
15709 /* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x00,\
15710 /* 72 */ 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00,\
15711 /* 80 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02,\
15712 /* 88 */ 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x00, 0x00,\
15713 /* 96 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x26, 0x26,\
15714 /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
15715 /* 112 */ 0x00, 0x00, 0x12, 0x00, 0x00, 0x10, 0x00, 0x00,\
15716 /* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\
15717 /* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
15718 /* 136 */ 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x00,\
15719 /* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
15720 /* 152 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\
15721 /* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15722 /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\
15723 /* 176 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
15724 /* 184 */ 0x00, 0x00,}
15725
15726 /* The resolve3P2Values() routine is able to run faster if it knows
15727 ** the value of the largest JUMP opcode. The smaller the maximum
15728 ** JUMP opcode the better, so the mkopcodeh.tcl script that
15729 ** generated this include file strives to group all JUMP opcodes
@@ -22622,10 +22623,11 @@
22623 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
22624 SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem*,u8,u8);
22625 SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*);
22626 SQLITE_PRIVATE int sqlite3VdbeMemFromBtreeZeroOffset(BtCursor*,u32,Mem*);
22627 SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
22628 SQLITE_PRIVATE void sqlite3VdbeMemReleaseMalloc(Mem*p);
22629 SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
22630 #ifndef SQLITE_OMIT_WINDOWFUNC
22631 SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem*, Mem*, FuncDef*);
22632 #endif
22633 #if !defined(SQLITE_OMIT_EXPLAIN) || defined(SQLITE_ENABLE_BYTECODE_VTAB)
@@ -23688,11 +23690,11 @@
23690 p->Y = sLocal.tm_year + 1900 - iYearDiff;
23691 p->M = sLocal.tm_mon + 1;
23692 p->D = sLocal.tm_mday;
23693 p->h = sLocal.tm_hour;
23694 p->m = sLocal.tm_min;
23695 p->s = sLocal.tm_sec + (p->iJD%1000)*0.001;
23696 p->validYMD = 1;
23697 p->validHMS = 1;
23698 p->validJD = 0;
23699 p->rawS = 0;
23700 p->validTZ = 0;
@@ -34683,41 +34685,41 @@
34685 /* 66 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
34686 /* 67 */ "Return" OpHelp(""),
34687 /* 68 */ "EndCoroutine" OpHelp(""),
34688 /* 69 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
34689 /* 70 */ "Halt" OpHelp(""),
34690 /* 71 */ "BeginSubrtn" OpHelp("r[P2]=P1"),
34691 /* 72 */ "Integer" OpHelp("r[P2]=P1"),
34692 /* 73 */ "Int64" OpHelp("r[P2]=P4"),
34693 /* 74 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
34694 /* 75 */ "Null" OpHelp("r[P2..P3]=NULL"),
34695 /* 76 */ "SoftNull" OpHelp("r[P1]=NULL"),
34696 /* 77 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
34697 /* 78 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
34698 /* 79 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
34699 /* 80 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
34700 /* 81 */ "SCopy" OpHelp("r[P2]=r[P1]"),
34701 /* 82 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
34702 /* 83 */ "FkCheck" OpHelp(""),
34703 /* 84 */ "ResultRow" OpHelp("output=r[P1@P2]"),
34704 /* 85 */ "CollSeq" OpHelp(""),
34705 /* 86 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
34706 /* 87 */ "RealAffinity" OpHelp(""),
34707 /* 88 */ "Cast" OpHelp("affinity(r[P1])"),
34708 /* 89 */ "Permutation" OpHelp(""),
34709 /* 90 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
34710 /* 91 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
34711 /* 92 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
34712 /* 93 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
34713 /* 94 */ "Column" OpHelp("r[P3]=PX"),
34714 /* 95 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
34715 /* 96 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
34716 /* 97 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
34717 /* 98 */ "Count" OpHelp("r[P2]=count()"),
34718 /* 99 */ "ReadCookie" OpHelp(""),
34719 /* 100 */ "SetCookie" OpHelp(""),
34720 /* 101 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
34721 /* 102 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
34722 /* 103 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
34723 /* 104 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
34724 /* 105 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
34725 /* 106 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -34724,83 +34726,84 @@
34726 /* 107 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
34727 /* 108 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
34728 /* 109 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
34729 /* 110 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
34730 /* 111 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
34731 /* 112 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
34732 /* 113 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
34733 /* 114 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
34734 /* 115 */ "OpenDup" OpHelp(""),
34735 /* 116 */ "OpenAutoindex" OpHelp("nColumn=P2"),
34736 /* 117 */ "String8" OpHelp("r[P2]='P4'"),
34737 /* 118 */ "OpenEphemeral" OpHelp("nColumn=P2"),
34738 /* 119 */ "SorterOpen" OpHelp(""),
34739 /* 120 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
34740 /* 121 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
34741 /* 122 */ "Close" OpHelp(""),
34742 /* 123 */ "ColumnsUsed" OpHelp(""),
34743 /* 124 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
34744 /* 125 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
34745 /* 126 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
34746 /* 127 */ "NewRowid" OpHelp("r[P2]=rowid"),
34747 /* 128 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
34748 /* 129 */ "RowCell" OpHelp(""),
34749 /* 130 */ "Delete" OpHelp(""),
34750 /* 131 */ "ResetCount" OpHelp(""),
34751 /* 132 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
34752 /* 133 */ "SorterData" OpHelp("r[P2]=data"),
34753 /* 134 */ "RowData" OpHelp("r[P2]=data"),
34754 /* 135 */ "Rowid" OpHelp("r[P2]=rowid"),
34755 /* 136 */ "NullRow" OpHelp(""),
34756 /* 137 */ "SeekEnd" OpHelp(""),
34757 /* 138 */ "IdxInsert" OpHelp("key=r[P2]"),
34758 /* 139 */ "SorterInsert" OpHelp("key=r[P2]"),
34759 /* 140 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
34760 /* 141 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
34761 /* 142 */ "IdxRowid" OpHelp("r[P2]=rowid"),
34762 /* 143 */ "FinishSeek" OpHelp(""),
34763 /* 144 */ "Destroy" OpHelp(""),
34764 /* 145 */ "Clear" OpHelp(""),
34765 /* 146 */ "ResetSorter" OpHelp(""),
34766 /* 147 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
34767 /* 148 */ "SqlExec" OpHelp(""),
34768 /* 149 */ "ParseSchema" OpHelp(""),
34769 /* 150 */ "LoadAnalysis" OpHelp(""),
34770 /* 151 */ "DropTable" OpHelp(""),
34771 /* 152 */ "DropIndex" OpHelp(""),
34772 /* 153 */ "Real" OpHelp("r[P2]=P4"),
34773 /* 154 */ "DropTrigger" OpHelp(""),
34774 /* 155 */ "IntegrityCk" OpHelp(""),
34775 /* 156 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
34776 /* 157 */ "Param" OpHelp(""),
34777 /* 158 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
34778 /* 159 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
34779 /* 160 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
34780 /* 161 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
34781 /* 162 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
34782 /* 163 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
34783 /* 164 */ "AggValue" OpHelp("r[P3]=value N=P2"),
34784 /* 165 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
34785 /* 166 */ "Expire" OpHelp(""),
34786 /* 167 */ "CursorLock" OpHelp(""),
34787 /* 168 */ "CursorUnlock" OpHelp(""),
34788 /* 169 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
34789 /* 170 */ "VBegin" OpHelp(""),
34790 /* 171 */ "VCreate" OpHelp(""),
34791 /* 172 */ "VDestroy" OpHelp(""),
34792 /* 173 */ "VOpen" OpHelp(""),
34793 /* 174 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
34794 /* 175 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
34795 /* 176 */ "VRename" OpHelp(""),
34796 /* 177 */ "Pagecount" OpHelp(""),
34797 /* 178 */ "MaxPgcnt" OpHelp(""),
34798 /* 179 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
34799 /* 180 */ "Trace" OpHelp(""),
34800 /* 181 */ "CursorHint" OpHelp(""),
34801 /* 182 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
34802 /* 183 */ "Noop" OpHelp(""),
34803 /* 184 */ "Explain" OpHelp(""),
34804 /* 185 */ "Abortable" OpHelp(""),
34805 };
34806 return azName[i];
34807 }
34808 #endif
34809
@@ -58724,10 +58727,11 @@
58727 assert( pPager->errCode==SQLITE_OK );
58728 assert( pPager->eState>=PAGER_READER );
58729 assert( assert_pager_state(pPager) );
58730 assert( pPager->hasHeldSharedLock==1 );
58731
58732 if( pgno==0 ) return SQLITE_CORRUPT_BKPT;
58733 pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3);
58734 if( pBase==0 ){
58735 pPg = 0;
58736 rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase);
58737 if( rc!=SQLITE_OK ) goto pager_acquire_err;
@@ -58751,14 +58755,14 @@
58755
58756 }else{
58757 /* The pager cache has created a new page. Its content needs to
58758 ** be initialized. But first some error checks:
58759 **
58760 ** (*) obsolete. Was: maximum page number is 2^31
58761 ** (2) Never try to fetch the locking page
58762 */
58763 if( pgno==PAGER_SJ_PGNO(pPager) ){
58764 rc = SQLITE_CORRUPT_BKPT;
58765 goto pager_acquire_err;
58766 }
58767
58768 pPg->pPager = pPager;
@@ -66978,11 +66982,11 @@
66982 }
66983
66984 /*
66985 ** In this version of BtreeMoveto, pKey is a packed index record
66986 ** such as is generated by the OP_MakeRecord opcode. Unpack the
66987 ** record and then call sqlite3BtreeIndexMoveto() to do the work.
66988 */
66989 static int btreeMoveto(
66990 BtCursor *pCur, /* Cursor open on the btree to be searched */
66991 const void *pKey, /* Packed key if the btree is an index */
66992 i64 nKey, /* Integer key for tables. Size of pKey for indices */
@@ -68085,11 +68089,10 @@
68089 assert( pPage->hdrOffset==(pPage->pgno==1 ? 100 : 0) );
68090 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
68091 pPage->leaf = (u8)(flagByte>>3); assert( PTF_LEAF == 1<<3 );
68092 flagByte &= ~PTF_LEAF;
68093 pPage->childPtrSize = 4-4*pPage->leaf;
 
68094 pBt = pPage->pBt;
68095 if( flagByte==(PTF_LEAFDATA | PTF_INTKEY) ){
68096 /* EVIDENCE-OF: R-07291-35328 A value of 5 (0x05) means the page is an
68097 ** interior table b-tree page. */
68098 assert( (PTF_LEAFDATA|PTF_INTKEY)==5 );
@@ -68115,16 +68118,21 @@
68118 /* EVIDENCE-OF: R-59615-42828 A value of 10 (0x0a) means the page is a
68119 ** leaf index b-tree page. */
68120 assert( (PTF_ZERODATA|PTF_LEAF)==10 );
68121 pPage->intKey = 0;
68122 pPage->intKeyLeaf = 0;
68123 pPage->xCellSize = cellSizePtr;
68124 pPage->xParseCell = btreeParseCellPtrIndex;
68125 pPage->maxLocal = pBt->maxLocal;
68126 pPage->minLocal = pBt->minLocal;
68127 }else{
68128 /* EVIDENCE-OF: R-47608-56469 Any other value for the b-tree page type is
68129 ** an error. */
68130 pPage->intKey = 0;
68131 pPage->intKeyLeaf = 0;
68132 pPage->xCellSize = cellSizePtr;
68133 pPage->xParseCell = btreeParseCellPtrIndex;
68134 return SQLITE_CORRUPT_PAGE(pPage);
68135 }
68136 pPage->max1bytePayload = pBt->max1bytePayload;
68137 return SQLITE_OK;
68138 }
@@ -71544,11 +71552,11 @@
71552 }
71553 pCur->iPage = 0;
71554 pCur->curIntKey = pCur->pPage->intKey;
71555 }
71556 pRoot = pCur->pPage;
71557 assert( pRoot->pgno==pCur->pgnoRoot || CORRUPT_DB );
71558
71559 /* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor
71560 ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
71561 ** NULL, the caller expects a table b-tree. If this is not the case,
71562 ** return an SQLITE_CORRUPT error.
@@ -71864,10 +71872,73 @@
71872 moveto_table_finish:
71873 pCur->info.nSize = 0;
71874 assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );
71875 return rc;
71876 }
71877
71878 /*
71879 ** Compare the "idx"-th cell on the page the cursor pCur is currently
71880 ** pointing to to pIdxKey using xRecordCompare. Return negative or
71881 ** zero if the cell is less than or equal pIdxKey. Return positive
71882 ** if unknown.
71883 **
71884 ** Return value negative: Cell at pCur[idx] less than pIdxKey
71885 **
71886 ** Return value is zero: Cell at pCur[idx] equals pIdxKey
71887 **
71888 ** Return value positive: Nothing is known about the relationship
71889 ** of the cell at pCur[idx] and pIdxKey.
71890 **
71891 ** This routine is part of an optimization. It is always safe to return
71892 ** a positive value as that will cause the optimization to be skipped.
71893 */
71894 static int indexCellCompare(
71895 BtCursor *pCur,
71896 int idx,
71897 UnpackedRecord *pIdxKey,
71898 RecordCompare xRecordCompare
71899 ){
71900 MemPage *pPage = pCur->pPage;
71901 int c;
71902 int nCell; /* Size of the pCell cell in bytes */
71903 u8 *pCell = findCellPastPtr(pPage, idx);
71904
71905 nCell = pCell[0];
71906 if( nCell<=pPage->max1bytePayload ){
71907 /* This branch runs if the record-size field of the cell is a
71908 ** single byte varint and the record fits entirely on the main
71909 ** b-tree page. */
71910 testcase( pCell+nCell+1==pPage->aDataEnd );
71911 c = xRecordCompare(nCell, (void*)&pCell[1], pIdxKey);
71912 }else if( !(pCell[1] & 0x80)
71913 && (nCell = ((nCell&0x7f)<<7) + pCell[1])<=pPage->maxLocal
71914 ){
71915 /* The record-size field is a 2 byte varint and the record
71916 ** fits entirely on the main b-tree page. */
71917 testcase( pCell+nCell+2==pPage->aDataEnd );
71918 c = xRecordCompare(nCell, (void*)&pCell[2], pIdxKey);
71919 }else{
71920 /* If the record extends into overflow pages, do not attempt
71921 ** the optimization. */
71922 c = 99;
71923 }
71924 return c;
71925 }
71926
71927 /*
71928 ** Return true (non-zero) if pCur is current pointing to the last
71929 ** page of a table.
71930 */
71931 static int cursorOnLastPage(BtCursor *pCur){
71932 int i;
71933 assert( pCur->eState==CURSOR_VALID );
71934 for(i=0; i<pCur->iPage; i++){
71935 MemPage *pPage = pCur->apPage[i];
71936 if( pCur->aiIdx[i]<pPage->nCell ) return 0;
71937 }
71938 return 1;
71939 }
71940
71941 /* Move the cursor so that it points to an entry in an index table
71942 ** near the key pIdxKey. Return a success code.
71943 **
71944 ** If an exact match is not found, then the cursor is always
@@ -71915,25 +71986,58 @@
71986 assert( pIdxKey->default_rc==1
71987 || pIdxKey->default_rc==0
71988 || pIdxKey->default_rc==-1
71989 );
71990
71991
71992 /* Check to see if we can skip a lot of work. Two cases:
71993 **
71994 ** (1) If the cursor is already pointing to the very last cell
71995 ** in the table and the pIdxKey search key is greater than or
71996 ** equal to that last cell, then no movement is required.
71997 **
71998 ** (2) If the cursor is on the last page of the table and the first
71999 ** cell on that last page is less than or equal to the pIdxKey
72000 ** search key, then we can start the search on the current page
72001 ** without needing to go back to root.
72002 */
72003 if( pCur->eState==CURSOR_VALID
72004 && pCur->pPage->leaf
72005 && cursorOnLastPage(pCur)
72006 ){
72007 int c;
72008 if( pCur->ix==pCur->pPage->nCell-1
72009 && (c = indexCellCompare(pCur, pCur->ix, pIdxKey, xRecordCompare))<=0
72010 ){
72011 *pRes = c;
72012 return SQLITE_OK; /* Cursor already pointing at the correct spot */
72013 }
72014 if( pCur->iPage>0
72015 && (c = indexCellCompare(pCur, 0, pIdxKey, xRecordCompare))<=0
72016 ){
72017 pCur->curFlags &= ~BTCF_ValidOvfl;
72018 goto bypass_moveto_root; /* Start search on the current page */
72019 }
72020 }
72021
72022 rc = moveToRoot(pCur);
72023 if( rc ){
72024 if( rc==SQLITE_EMPTY ){
72025 assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );
72026 *pRes = -1;
72027 return SQLITE_OK;
72028 }
72029 return rc;
72030 }
72031
72032 bypass_moveto_root:
72033 assert( pCur->pPage );
72034 assert( pCur->pPage->isInit );
72035 assert( pCur->eState==CURSOR_VALID );
72036 assert( pCur->pPage->nCell > 0 );
72037 assert( pCur->curIntKey==0 );
72038 assert( pIdxKey!=0 );
72039 for(;;){
72040 int lwr, upr, idx, c;
72041 Pgno chldPg;
72042 MemPage *pPage = pCur->pPage;
72043 u8 *pCell; /* Pointer to current cell in pPage */
@@ -71943,11 +72047,11 @@
72047 ** not run. If this is not the root-page, then the moveToChild() routine
72048 ** would have already detected db corruption. Similarly, pPage must
72049 ** be the right kind (index or table) of b-tree page. Otherwise
72050 ** a moveToChild() or moveToRoot() call would have detected corruption. */
72051 assert( pPage->nCell>0 );
72052 assert( pPage->intKey==0 );
72053 lwr = 0;
72054 upr = pPage->nCell-1;
72055 idx = upr>>1; /* idx = (lwr+upr)/2; */
72056 for(;;){
72057 int nCell; /* Size of the pCell cell in bytes */
@@ -75042,11 +75146,11 @@
75146 ** For an index btree (used for indexes and WITHOUT ROWID tables), the
75147 ** key is an arbitrary byte sequence stored in pX.pKey,nKey. The
75148 ** pX.pData,nData,nZero fields must be zero.
75149 **
75150 ** If the seekResult parameter is non-zero, then a successful call to
75151 ** sqlite3BtreeIndexMoveto() to seek cursor pCur to (pKey,nKey) has already
75152 ** been performed. In other words, if seekResult!=0 then the cursor
75153 ** is currently pointing to a cell that will be adjacent to the cell
75154 ** to be inserted. If seekResult<0 then pCur points to a cell that is
75155 ** smaller then (pKey,nKey). If seekResult>0 then pCur points to a cell
75156 ** that is larger than (pKey,nKey).
@@ -75060,11 +75164,11 @@
75164 */
75165 SQLITE_PRIVATE int sqlite3BtreeInsert(
75166 BtCursor *pCur, /* Insert data into the table of this cursor */
75167 const BtreePayload *pX, /* Content of the row to be inserted */
75168 int flags, /* True if this is likely an append */
75169 int seekResult /* Result of prior IndexMoveto() call */
75170 ){
75171 int rc;
75172 int loc = seekResult; /* -1: before desired location +1: after */
75173 int szNew = 0;
75174 int idx;
@@ -78471,10 +78575,18 @@
78575 assert( sqlite3VdbeCheckMemInvariants(p) );
78576 if( VdbeMemDynamic(p) || p->szMalloc ){
78577 vdbeMemClear(p);
78578 }
78579 }
78580
78581 /* Like sqlite3VdbeMemRelease() but faster for cases where we
78582 ** know in advance that the Mem is not MEM_Dyn or MEM_Agg.
78583 */
78584 SQLITE_PRIVATE void sqlite3VdbeMemReleaseMalloc(Mem *p){
78585 assert( !VdbeMemDynamic(p) );
78586 if( p->szMalloc ) vdbeMemClear(p);
78587 }
78588
78589 /*
78590 ** Convert a 64-bit IEEE double into a 64-bit signed integer.
78591 ** If the double is out of range of a 64-bit signed integer then
78592 ** return the closest available 64-bit signed integer.
@@ -78833,10 +78945,11 @@
78945 void *pPtr,
78946 const char *zPType,
78947 void (*xDestructor)(void*)
78948 ){
78949 assert( pMem->flags==MEM_Null );
78950 vdbeMemClear(pMem);
78951 pMem->u.zPType = zPType ? zPType : "";
78952 pMem->z = pPtr;
78953 pMem->flags = MEM_Null|MEM_Dyn|MEM_Subtype|MEM_Term;
78954 pMem->eSubtype = 'p';
78955 pMem->xDel = xDestructor ? xDestructor : sqlite3NoopDestructor;
@@ -81728,11 +81841,16 @@
81841 }while( (--N)>0 );
81842 }
81843 }
81844
81845 /*
81846 ** Release auxiliary memory held in an array of N Mem elements.
81847 **
81848 ** After this routine returns, all Mem elements in the array will still
81849 ** be valid. Those Mem elements that were not holding auxiliary resources
81850 ** will be unchanged. Mem elements which had something freed will be
81851 ** set to MEM_Undefined.
81852 */
81853 static void releaseMemArray(Mem *p, int N){
81854 if( p && N ){
81855 Mem *pEnd = &p[N];
81856 sqlite3 *db = p->db;
@@ -81761,16 +81879,21 @@
81879 testcase( p->flags & MEM_Agg );
81880 testcase( p->flags & MEM_Dyn );
81881 if( p->flags&(MEM_Agg|MEM_Dyn) ){
81882 testcase( (p->flags & MEM_Dyn)!=0 && p->xDel==sqlite3VdbeFrameMemDel );
81883 sqlite3VdbeMemRelease(p);
81884 p->flags = MEM_Undefined;
81885 }else if( p->szMalloc ){
81886 sqlite3DbFreeNN(db, p->zMalloc);
81887 p->szMalloc = 0;
81888 p->flags = MEM_Undefined;
81889 }
81890 #ifdef SQLITE_DEBUG
81891 else{
81892 p->flags = MEM_Undefined;
81893 }
81894 #endif
81895 }while( (++p)<pEnd );
81896 }
81897 }
81898
81899 #ifdef SQLITE_DEBUG
@@ -84061,12 +84184,12 @@
84184 if( prcErr ) *prcErr = SQLITE_NOMEM_BKPT;
84185 rc = 0;
84186 }else{
84187 rc = pColl->xCmp(pColl->pUser, c1.n, v1, c2.n, v2);
84188 }
84189 sqlite3VdbeMemReleaseMalloc(&c1);
84190 sqlite3VdbeMemReleaseMalloc(&c2);
84191 return rc;
84192 }
84193 }
84194
84195 /*
@@ -84794,18 +84917,18 @@
84917 }
84918
84919 /* Fetch the integer off the end of the index record */
84920 sqlite3VdbeSerialGet((u8*)&m.z[m.n-lenRowid], typeRowid, &v);
84921 *rowid = v.u.i;
84922 sqlite3VdbeMemReleaseMalloc(&m);
84923 return SQLITE_OK;
84924
84925 /* Jump here if database corruption is detected after m has been
84926 ** allocated. Free the m object and return SQLITE_CORRUPT. */
84927 idx_rowid_corruption:
84928 testcase( m.szMalloc!=0 );
84929 sqlite3VdbeMemReleaseMalloc(&m);
84930 return SQLITE_CORRUPT_BKPT;
84931 }
84932
84933 /*
84934 ** Compare the key of the index entry that cursor pC is pointing to against
@@ -84843,11 +84966,11 @@
84966 rc = sqlite3VdbeMemFromBtreeZeroOffset(pCur, (u32)nCellKey, &m);
84967 if( rc ){
84968 return rc;
84969 }
84970 *res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, pUnpacked, 0);
84971 sqlite3VdbeMemReleaseMalloc(&m);
84972 return SQLITE_OK;
84973 }
84974
84975 /*
84976 ** This routine sets the value to be returned by subsequent calls to
@@ -85010,11 +85133,11 @@
85133 static void vdbeFreeUnpacked(sqlite3 *db, int nField, UnpackedRecord *p){
85134 if( p ){
85135 int i;
85136 for(i=0; i<nField; i++){
85137 Mem *pMem = &p->aMem[i];
85138 if( pMem->zMalloc ) sqlite3VdbeMemReleaseMalloc(pMem);
85139 }
85140 sqlite3DbFreeNN(db, p);
85141 }
85142 }
85143 #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
@@ -88419,14 +88542,18 @@
88542 jump_to_p2:
88543 pOp = &aOp[pOp->p2 - 1];
88544 break;
88545 }
88546
88547 /* Opcode: Return P1 * P3 * *
88548 **
88549 ** Jump to the next instruction after the address in register P1. After
88550 ** the jump, register P1 becomes undefined.
88551 **
88552 ** P3 is not used by the byte-code engine. However, the code generator
88553 ** sets P3 to address of the associated OP_BeginSubrtn opcode, if there is
88554 ** one.
88555 */
88556 case OP_Return: { /* in1 */
88557 pIn1 = &aMem[pOp->p1];
88558 assert( pIn1->flags==MEM_Int );
88559 pOp = &aOp[pIn1->u.i];
@@ -88610,15 +88737,26 @@
88737 rc = p->rc ? SQLITE_ERROR : SQLITE_DONE;
88738 }
88739 goto vdbe_return;
88740 }
88741
88742 /* Opcode: BeginSubrtn P1 P2 * * *
88743 ** Synopsis: r[P2]=P1
88744 **
88745 ** Mark the beginning of a subroutine by loading the integer value P1
88746 ** into register r[P2]. The P2 register is used to store the return
88747 ** address of the subroutine call.
88748 **
88749 ** This opcode is identical to OP_Integer. It has a different name
88750 ** only to make the byte code easier to read and verify.
88751 */
88752 /* Opcode: Integer P1 P2 * * *
88753 ** Synopsis: r[P2]=P1
88754 **
88755 ** The 32-bit integer value P1 is written into register P2.
88756 */
88757 case OP_BeginSubrtn:
88758 case OP_Integer: { /* out2 */
88759 pOut = out2Prerelease(p, pOp);
88760 pOut->u.i = pOp->p1;
88761 break;
88762 }
@@ -90055,14 +90193,22 @@
90193 case OP_Offset: { /* out3 */
90194 VdbeCursor *pC; /* The VDBE cursor */
90195 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
90196 pC = p->apCsr[pOp->p1];
90197 pOut = &p->aMem[pOp->p3];
90198 if( pC==0 || pC->eCurType!=CURTYPE_BTREE ){
90199 sqlite3VdbeMemSetNull(pOut);
90200 }else{
90201 if( pC->deferredMoveto ){
90202 rc = sqlite3VdbeFinishMoveto(pC);
90203 if( rc ) goto abort_due_to_error;
90204 }
90205 if( sqlite3BtreeEof(pC->uc.pCursor) ){
90206 sqlite3VdbeMemSetNull(pOut);
90207 }else{
90208 sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));
90209 }
90210 }
90211 break;
90212 }
90213 #endif /* SQLITE_ENABLE_OFFSET_SQL_FUNC */
90214
@@ -93773,11 +93919,11 @@
93919 }
93920 sqlite3VdbeMemInit(&m, db, 0);
93921 rc = sqlite3VdbeMemFromBtreeZeroOffset(pCur, (u32)nCellKey, &m);
93922 if( rc ) goto abort_due_to_error;
93923 res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, &r, 0);
93924 sqlite3VdbeMemReleaseMalloc(&m);
93925 }
93926 /* End of inlined sqlite3VdbeIdxKeyCompare() */
93927
93928 assert( (OP_IdxLE&1)==(OP_IdxLT&1) && (OP_IdxGE&1)==(OP_IdxGT&1) );
93929 if( (pOp->opcode&1)==(OP_IdxLT&1) ){
@@ -105554,12 +105700,11 @@
105700 assert( !ExprUseYWin(pExpr) );
105701 ExprSetProperty(pExpr, EP_Subrtn);
105702 assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
105703 pExpr->y.sub.regReturn = ++pParse->nMem;
105704 pExpr->y.sub.iAddr =
105705 sqlite3VdbeAddOp2(v, OP_BeginSubrtn, 0, pExpr->y.sub.regReturn) + 1;
 
105706
105707 addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
105708 }
105709
105710 /* Check to see if this is a vector IN operator */
@@ -105657,10 +105802,11 @@
105802 ** disable the test that was generated above that makes sure
105803 ** this code only executes once. Because for a non-constant
105804 ** expression we need to rerun this code each time.
105805 */
105806 if( addrOnce && !sqlite3ExprIsConstant(pE2) ){
105807 sqlite3VdbeChangeToNoop(v, addrOnce-1);
105808 sqlite3VdbeChangeToNoop(v, addrOnce);
105809 ExprClearProperty(pExpr, EP_Subrtn);
105810 addrOnce = 0;
105811 }
105812
@@ -105677,11 +105823,14 @@
105823 }
105824 if( addrOnce ){
105825 sqlite3VdbeJumpHere(v, addrOnce);
105826 /* Subroutine return */
105827 assert( ExprUseYSub(pExpr) );
105828 assert( sqlite3VdbeGetOp(v,pExpr->y.sub.iAddr-1)->opcode==OP_BeginSubrtn
105829 || pParse->nErr );
105830 sqlite3VdbeAddOp3(v, OP_Return, pExpr->y.sub.regReturn, 0,
105831 pExpr->y.sub.iAddr-1);
105832 sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
105833 sqlite3ClearTempRegCache(pParse);
105834 }
105835 }
105836 #endif /* SQLITE_OMIT_SUBQUERY */
@@ -105732,13 +105881,11 @@
105881 assert( !ExprUseYWin(pExpr) );
105882 assert( !ExprHasProperty(pExpr, EP_Reduced|EP_TokenOnly) );
105883 ExprSetProperty(pExpr, EP_Subrtn);
105884 pExpr->y.sub.regReturn = ++pParse->nMem;
105885 pExpr->y.sub.iAddr =
105886 sqlite3VdbeAddOp2(v, OP_BeginSubrtn, 0, pExpr->y.sub.regReturn) + 1;
 
 
105887
105888 /* The evaluation of the EXISTS/SELECT must be repeated every time it
105889 ** is encountered if any of the following is true:
105890 **
105891 ** * The right-hand side is a correlated subquery
@@ -105807,11 +105954,14 @@
105954 sqlite3VdbeJumpHere(v, addrOnce);
105955 }
105956
105957 /* Subroutine return */
105958 assert( ExprUseYSub(pExpr) );
105959 assert( sqlite3VdbeGetOp(v,pExpr->y.sub.iAddr-1)->opcode==OP_BeginSubrtn
105960 || pParse->nErr );
105961 sqlite3VdbeAddOp3(v, OP_Return, pExpr->y.sub.regReturn, 0,
105962 pExpr->y.sub.iAddr-1);
105963 sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
105964 sqlite3ClearTempRegCache(pParse);
105965 return rReg;
105966 }
105967 #endif /* SQLITE_OMIT_SUBQUERY */
@@ -123338,12 +123488,12 @@
123488 #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
123489 INLINE_FUNC(unlikely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
123490 INLINE_FUNC(likelihood, 2, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
123491 INLINE_FUNC(likely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
123492 #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
123493 {1, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|SQLITE_FUNC_OFFSET|SQLITE_FUNC_TYPEOF,
123494 0, 0, noopFunc, 0, 0, 0, "sqlite_offset", {0} },
123495 #endif
123496 FUNCTION(ltrim, 1, 1, 0, trimFunc ),
123497 FUNCTION(ltrim, 2, 1, 0, trimFunc ),
123498 FUNCTION(rtrim, 1, 2, 0, trimFunc ),
123499 FUNCTION(rtrim, 2, 2, 0, trimFunc ),
@@ -142452,10 +142602,11 @@
142602 const char *zEnd /* End of SQL text */
142603 ){
142604 sqlite3 *db = pParse->db;
142605 TriggerStep *pTriggerStep;
142606
142607 if( pParse->nErr ) return 0;
142608 pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);
142609 if( pTriggerStep ){
142610 char *z = (char*)&pTriggerStep[1];
142611 memcpy(z, pName->z, pName->n);
142612 sqlite3Dequote(z);
@@ -148265,10 +148416,11 @@
148416 sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur);
148417 VdbeCoverageIf(v, bRev==0);
148418 VdbeCoverageIf(v, bRev!=0);
148419 VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
148420 j = sqlite3VdbeAddOp0(v, OP_Goto);
148421 assert( pLevel->addrSkip==0 );
148422 pLevel->addrSkip = sqlite3VdbeAddOp4Int(v, (bRev?OP_SeekLT:OP_SeekGT),
148423 iIdxCur, 0, regBase, nSkip);
148424 VdbeCoverageIf(v, bRev==0);
148425 VdbeCoverageIf(v, bRev!=0);
148426 sqlite3VdbeJumpHere(v, j);
@@ -148870,10 +149022,11 @@
149022 ){
149023 while( ++iLevel < pWInfo->nLevel ){
149024 WhereLevel *pLevel = &pWInfo->a[iLevel];
149025 WhereLoop *pLoop = pLevel->pWLoop;
149026 if( pLevel->regFilter==0 ) continue;
149027 if( pLevel->pWLoop->nSkip ) continue;
149028 /* ,--- Because sqlite3ConstructBloomFilter() has will not have set
149029 ** vvvvv--' pLevel->regFilter if this were true. */
149030 if( NEVER(pLoop->prereq & notReady) ) continue;
149031 if( pLoop->wsFlags & WHERE_IPK ){
149032 WhereTerm *pTerm = pLoop->aLTerm[0];
@@ -149004,11 +149157,10 @@
149157 ** to access the data.
149158 */
149159 int iReg; /* P3 Value for OP_VFilter */
149160 int addrNotFound;
149161 int nConstraint = pLoop->nLTerm;
 
149162
149163 iReg = sqlite3GetTempRange(pParse, nConstraint+2);
149164 addrNotFound = pLevel->addrBrk;
149165 for(j=0; j<nConstraint; j++){
149166 int iTarget = iReg+j+2;
@@ -149050,67 +149202,71 @@
149202 if( db->mallocFailed ) pLoop->u.vtab.idxStr = 0;
149203 pLevel->p1 = iCur;
149204 pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext;
149205 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
149206 assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 );
149207
149208 for(j=0; j<nConstraint; j++){
 
 
 
 
 
149209 pTerm = pLoop->aLTerm[j];
149210 if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){
149211 disableTerm(pLevel, pTerm);
149212 continue;
149213 }
149214 if( (pTerm->eOperator & WO_IN)!=0
149215 && (SMASKBIT32(j) & pLoop->u.vtab.mHandleIn)==0
149216 && !db->mallocFailed
149217 ){
 
 
 
 
 
 
 
 
149218 Expr *pCompare; /* The comparison operator */
149219 Expr *pRight; /* RHS of the comparison */
149220 VdbeOp *pOp; /* Opcode to access the value of the IN constraint */
149221 int iIn; /* IN loop corresponding to the j-th constraint */
149222
149223 /* Reload the constraint value into reg[iReg+j+2]. The same value
149224 ** was loaded into the same register prior to the OP_VFilter, but
149225 ** the xFilter implementation might have changed the datatype or
149226 ** encoding of the value in the register, so it *must* be reloaded.
149227 */
149228 for(iIn=0; ALWAYS(iIn<pLevel->u.in.nIn); iIn++){
 
149229 pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[iIn].addrInTop);
149230 if( (pOp->opcode==OP_Column && pOp->p3==iReg+j+2)
149231 || (pOp->opcode==OP_Rowid && pOp->p2==iReg+j+2)
149232 ){
149233 testcase( pOp->opcode==OP_Rowid );
149234 sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
149235 break;
149236 }
149237 }
149238
149239 /* Generate code that will continue to the next row if
149240 ** the IN constraint is not satisfied
149241 */
149242 pCompare = sqlite3PExpr(pParse, TK_EQ, 0, 0);
149243 if( !db->mallocFailed ){
149244 int iFld = pTerm->u.x.iField;
149245 Expr *pLeft = pTerm->pExpr->pLeft;
149246 assert( pLeft!=0 );
149247 if( iFld>0 ){
149248 assert( pLeft->op==TK_VECTOR );
149249 assert( ExprUseXList(pLeft) );
149250 assert( iFld<=pLeft->x.pList->nExpr );
149251 pCompare->pLeft = pLeft->x.pList->a[iFld-1].pExpr;
149252 }else{
149253 pCompare->pLeft = pLeft;
149254 }
149255 pCompare->pRight = pRight = sqlite3Expr(db, TK_REGISTER, 0);
149256 if( pRight ){
149257 pRight->iTable = iReg+j+2;
149258 sqlite3ExprIfFalse(
149259 pParse, pCompare, pLevel->addrCont, SQLITE_JUMPIFNULL
149260 );
149261 }
149262 pCompare->pLeft = 0;
 
149263 }
149264 sqlite3ExprDelete(db, pCompare);
149265 }
149266 }
149267
149268 /* These registers need to be preserved in case there is an IN operator
149269 ** loop. So we could deallocate the registers here (and potentially
149270 ** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0. But it seems
149271 ** simpler and safer to simply not reuse the registers.
149272 **
@@ -149816,10 +149972,18 @@
149972 ** 2022-02-04: Do not push down slices of a row-value comparison.
149973 ** In other words, "w" or "y" may not be a slice of a vector. Otherwise,
149974 ** the initialization of the right-hand operand of the vector comparison
149975 ** might not occur, or might occur only in an OR branch that is not
149976 ** taken. dbsqlfuzz 80a9fade844b4fb43564efc972bcb2c68270f5d1.
149977 **
149978 ** 2022-03-03: Do not push down expressions that involve subqueries.
149979 ** The subquery might get coded as a subroutine. Any table-references
149980 ** in the subquery might be resolved to index-references for the index on
149981 ** the OR branch in which the subroutine is coded. But if the subroutine
149982 ** is invoked from a different OR branch that uses a different index, such
149983 ** index-references will not work. tag-20220303a
149984 ** https://sqlite.org/forum/forumpost/36937b197273d403
149985 */
149986 if( pWC->nTerm>1 ){
149987 int iTerm;
149988 for(iTerm=0; iTerm<pWC->nTerm; iTerm++){
149989 Expr *pExpr = pWC->a[iTerm].pExpr;
@@ -149829,11 +149993,11 @@
149993 testcase( pWC->a[iTerm].wtFlags & TERM_SLICE );
149994 if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED|TERM_SLICE))!=0 ){
149995 continue;
149996 }
149997 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
149998 if( ExprHasProperty(pExpr, EP_Subquery) ) continue; /* tag-20220303a */
149999 pExpr = sqlite3ExprDup(db, pExpr, 0);
150000 pAndExpr = sqlite3ExprAnd(pParse, pAndExpr, pExpr);
150001 }
150002 if( pAndExpr ){
150003 /* The extra 0x10000 bit on the opcode is masked off and does not
@@ -153106,11 +153270,14 @@
153270 VdbeCoverage(v);
153271 sqlite3VdbeJumpHere(v, addrTop);
153272 pLoop->wsFlags &= ~WHERE_BLOOMFILTER;
153273 if( OptimizationDisabled(pParse->db, SQLITE_BloomPulldown) ) break;
153274 while( ++iLevel < pWInfo->nLevel ){
153275 const SrcItem *pTabItem;
153276 pLevel = &pWInfo->a[iLevel];
153277 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
153278 if( pTabItem->fg.jointype & JT_LEFT ) continue;
153279 pLoop = pLevel->pWLoop;
153280 if( NEVER(pLoop==0) ) continue;
153281 if( pLoop->prereq & notReady ) continue;
153282 if( (pLoop->wsFlags & (WHERE_BLOOMFILTER|WHERE_COLUMN_IN))
153283 ==WHERE_BLOOMFILTER
@@ -234388,11 +234555,11 @@
234555 int nArg, /* Number of args */
234556 sqlite3_value **apUnused /* Function arguments */
234557 ){
234558 assert( nArg==0 );
234559 UNUSED_PARAM2(nArg, apUnused);
234560 sqlite3_result_text(pCtx, "fts5: 2022-03-07 18:32:08 ae464a18d74bf44fc95bc335e75e6a57dc974f6d6a3d603133594039fb589af2", -1, SQLITE_TRANSIENT);
234561 }
234562
234563 /*
234564 ** Return true if zName is the extension on one of the shadow tables used
234565 ** by this module.
234566
--- 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.39.0"
150150
#define SQLITE_VERSION_NUMBER 3039000
151
-#define SQLITE_SOURCE_ID "2022-03-02 01:02:16 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b"
151
+#define SQLITE_SOURCE_ID "2022-03-07 18:32:08 ae464a18d74bf44fc95bc335e75e6a57dc974f6d6a3d603133594039fb589af2"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
157157
--- 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.39.0"
150 #define SQLITE_VERSION_NUMBER 3039000
151 #define SQLITE_SOURCE_ID "2022-03-02 01:02:16 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
157
--- 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.39.0"
150 #define SQLITE_VERSION_NUMBER 3039000
151 #define SQLITE_SOURCE_ID "2022-03-07 18:32:08 ae464a18d74bf44fc95bc335e75e6a57dc974f6d6a3d603133594039fb589af2"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
157

Keyboard Shortcuts

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