Fossil SCM

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

drh 2026-03-18 23:00 trunk
Commit 17f98784c2d62cb9795fed0b234272bf005d8c266b9f53cb93b7c8152b0e27d7
--- extsrc/qrf.h
+++ extsrc/qrf.h
@@ -54,10 +54,12 @@
5454
char *(*xRender)(void*,sqlite3_value*); /* Render a value */
5555
int (*xWrite)(void*,const char*,sqlite3_int64); /* Write output */
5656
void *pRenderArg; /* First argument to the xRender callback */
5757
void *pWriteArg; /* First argument to the xWrite callback */
5858
char **pzOutput; /* Storage location for output string */
59
+ /* Fields below are only available if iVersion>=2 */
60
+ unsigned int nMultiInsert; /* Add rows to one INSERT until size exceeds */
5961
/* Additional fields may be added in the future */
6062
};
6163
6264
/*
6365
** Interfaces
6466
--- extsrc/qrf.h
+++ extsrc/qrf.h
@@ -54,10 +54,12 @@
54 char *(*xRender)(void*,sqlite3_value*); /* Render a value */
55 int (*xWrite)(void*,const char*,sqlite3_int64); /* Write output */
56 void *pRenderArg; /* First argument to the xRender callback */
57 void *pWriteArg; /* First argument to the xWrite callback */
58 char **pzOutput; /* Storage location for output string */
 
 
59 /* Additional fields may be added in the future */
60 };
61
62 /*
63 ** Interfaces
64
--- extsrc/qrf.h
+++ extsrc/qrf.h
@@ -54,10 +54,12 @@
54 char *(*xRender)(void*,sqlite3_value*); /* Render a value */
55 int (*xWrite)(void*,const char*,sqlite3_int64); /* Write output */
56 void *pRenderArg; /* First argument to the xRender callback */
57 void *pWriteArg; /* First argument to the xWrite callback */
58 char **pzOutput; /* Storage location for output string */
59 /* Fields below are only available if iVersion>=2 */
60 unsigned int nMultiInsert; /* Add rows to one INSERT until size exceeds */
61 /* Additional fields may be added in the future */
62 };
63
64 /*
65 ** Interfaces
66
+262 -138
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -712,10 +712,12 @@
712712
char *(*xRender)(void*,sqlite3_value*); /* Render a value */
713713
int (*xWrite)(void*,const char*,sqlite3_int64); /* Write output */
714714
void *pRenderArg; /* First argument to the xRender callback */
715715
void *pWriteArg; /* First argument to the xWrite callback */
716716
char **pzOutput; /* Storage location for output string */
717
+ /* Fields below are only available if iVersion>=2 */
718
+ unsigned int nMultiInsert; /* Add rows to one INSERT until size exceeds */
717719
/* Additional fields may be added in the future */
718720
};
719721
720722
/*
721723
** Interfaces
@@ -925,10 +927,11 @@
925927
struct { /* Content for QRF_STYLE_Explain */
926928
int nIndent; /* Slots allocated for aiIndent */
927929
int iIndent; /* Current slot */
928930
int *aiIndent; /* Indentation for each opcode */
929931
} sExpln;
932
+ unsigned int nIns; /* Bytes used for current INSERT stmt */
930933
} u;
931934
sqlite3_int64 nRow; /* Number of rows handled so far */
932935
int *actualWidth; /* Actual width of each column */
933936
sqlite3_qrf_spec spec; /* Copy of the original spec */
934937
};
@@ -3422,34 +3425,50 @@
34223425
sqlite3_str_append(p->pOut, "\n</TR>\n", 7);
34233426
qrfWrite(p);
34243427
break;
34253428
}
34263429
case QRF_STYLE_Insert: {
3427
- if( qrf_need_quote(p->spec.zTableName) ){
3428
- sqlite3_str_appendf(p->pOut,"INSERT INTO \"%w\"",p->spec.zTableName);
3429
- }else{
3430
- sqlite3_str_appendf(p->pOut,"INSERT INTO %s",p->spec.zTableName);
3431
- }
3432
- if( p->spec.bTitles==QRF_Yes ){
3433
- for(i=0; i<p->nCol; i++){
3434
- const char *zCName = sqlite3_column_name(p->pStmt, i);
3435
- if( qrf_need_quote(zCName) ){
3436
- sqlite3_str_appendf(p->pOut, "%c\"%w\"",
3437
- i==0 ? '(' : ',', zCName);
3438
- }else{
3439
- sqlite3_str_appendf(p->pOut, "%c%s",
3440
- i==0 ? '(' : ',', zCName);
3441
- }
3442
- }
3443
- sqlite3_str_append(p->pOut, ")", 1);
3444
- }
3445
- sqlite3_str_append(p->pOut," VALUES(", 8);
3430
+ unsigned int mxIns = p->spec.iVersion>=2 ? p->spec.nMultiInsert : 0;
3431
+ int szStart = sqlite3_str_length(p->pOut);
3432
+ if( p->u.nIns==0 || p->u.nIns>=mxIns ){
3433
+ if( p->u.nIns ){
3434
+ sqlite3_str_append(p->pOut, ";\n", 2);
3435
+ p->u.nIns = 0;
3436
+ }
3437
+ if( qrf_need_quote(p->spec.zTableName) ){
3438
+ sqlite3_str_appendf(p->pOut,"INSERT INTO \"%w\"",p->spec.zTableName);
3439
+ }else{
3440
+ sqlite3_str_appendf(p->pOut,"INSERT INTO %s",p->spec.zTableName);
3441
+ }
3442
+ if( p->spec.bTitles==QRF_Yes ){
3443
+ for(i=0; i<p->nCol; i++){
3444
+ const char *zCName = sqlite3_column_name(p->pStmt, i);
3445
+ if( qrf_need_quote(zCName) ){
3446
+ sqlite3_str_appendf(p->pOut, "%c\"%w\"",
3447
+ i==0 ? '(' : ',', zCName);
3448
+ }else{
3449
+ sqlite3_str_appendf(p->pOut, "%c%s",
3450
+ i==0 ? '(' : ',', zCName);
3451
+ }
3452
+ }
3453
+ sqlite3_str_append(p->pOut, ")", 1);
3454
+ }
3455
+ sqlite3_str_append(p->pOut," VALUES(", 8);
3456
+ }else{
3457
+ sqlite3_str_append(p->pOut,",\n (", 5);
3458
+ }
34463459
for(i=0; i<p->nCol; i++){
34473460
if( i>0 ) sqlite3_str_append(p->pOut, ",", 1);
34483461
qrfRenderValue(p, p->pOut, i);
34493462
}
3450
- sqlite3_str_append(p->pOut, ");\n", 3);
3463
+ p->u.nIns += sqlite3_str_length(p->pOut) + 2 - szStart;
3464
+ if( p->u.nIns>=mxIns ){
3465
+ sqlite3_str_append(p->pOut, ");\n", 3);
3466
+ p->u.nIns = 0;
3467
+ }else{
3468
+ sqlite3_str_append(p->pOut, ")", 1);
3469
+ }
34513470
qrfWrite(p);
34523471
break;
34533472
}
34543473
case QRF_STYLE_Line: {
34553474
sqlite3_str *pVal;
@@ -3489,11 +3508,13 @@
34893508
zVal = sqlite3_str_value(pVal);
34903509
if( zVal==0 ) zVal = "";
34913510
do{
34923511
int nThis, nWide, iNext;
34933512
qrfWrapLine(zVal, mxW, bWW, &nThis, &nWide, &iNext);
3494
- if( cnt ) sqlite3_str_appendchar(p->pOut,p->u.sLine.mxColWth+2,' ');
3513
+ if( cnt ){
3514
+ sqlite3_str_appendchar(p->pOut,p->u.sLine.mxColWth+nSep,' ');
3515
+ }
34953516
cnt++;
34963517
if( cnt>p->mxHeight ){
34973518
zVal = "...";
34983519
nThis = iNext = 3;
34993520
}
@@ -3552,11 +3573,11 @@
35523573
char **pzErr /* Write errors here */
35533574
){
35543575
size_t sz; /* Size of pSpec[], based on pSpec->iVersion */
35553576
memset(p, 0, sizeof(*p));
35563577
p->pzErr = pzErr;
3557
- if( pSpec->iVersion!=1 ){
3578
+ if( pSpec->iVersion>2 ){
35583579
qrfError(p, SQLITE_ERROR,
35593580
"unusable sqlite3_qrf_spec.iVersion (%d)",
35603581
pSpec->iVersion);
35613582
return;
35623583
}
@@ -3612,10 +3633,11 @@
36123633
p->spec.eText = QRF_TEXT_Sql;
36133634
p->spec.zNull = "NULL";
36143635
if( p->spec.zTableName==0 || p->spec.zTableName[0]==0 ){
36153636
p->spec.zTableName = "tab";
36163637
}
3638
+ p->u.nIns = 0;
36173639
break;
36183640
}
36193641
case QRF_STYLE_Line: {
36203642
if( p->spec.zColumnSep==0 ){
36213643
p->spec.zColumnSep = ": ";
@@ -3710,24 +3732,27 @@
37103732
*/
37113733
static void qrfFinalize(Qrf *p){
37123734
switch( p->spec.eStyle ){
37133735
case QRF_STYLE_Count: {
37143736
sqlite3_str_appendf(p->pOut, "%lld\n", p->nRow);
3715
- qrfWrite(p);
37163737
break;
37173738
}
37183739
case QRF_STYLE_Json: {
37193740
if( p->nRow>0 ){
37203741
sqlite3_str_append(p->pOut, "}]\n", 3);
3721
- qrfWrite(p);
37223742
}
37233743
break;
37243744
}
37253745
case QRF_STYLE_JObject: {
37263746
if( p->nRow>0 ){
37273747
sqlite3_str_append(p->pOut, "}\n", 2);
3728
- qrfWrite(p);
3748
+ }
3749
+ break;
3750
+ }
3751
+ case QRF_STYLE_Insert: {
3752
+ if( p->u.nIns ){
3753
+ sqlite3_str_append(p->pOut, ";\n", 2);
37293754
}
37303755
break;
37313756
}
37323757
case QRF_STYLE_Line: {
37333758
if( p->u.sLine.azCol ){
@@ -3743,19 +3768,18 @@
37433768
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
37443769
sqlite3_stmt_scanstatus_v2(p->pStmt, -1, SQLITE_SCANSTAT_NCYCLE,
37453770
SQLITE_SCANSTAT_COMPLEX, (void*)&nCycle);
37463771
#endif
37473772
qrfEqpRender(p, nCycle);
3748
- qrfWrite(p);
37493773
break;
37503774
}
37513775
case QRF_STYLE_Eqp: {
37523776
qrfEqpRender(p, 0);
3753
- qrfWrite(p);
37543777
break;
37553778
}
37563779
}
3780
+ qrfWrite(p);
37573781
qrfStrErr(p, p->pOut);
37583782
if( p->spec.pzOutput ){
37593783
if( p->spec.pzOutput[0] ){
37603784
sqlite3_int64 n, sz;
37613785
char *zCombined;
@@ -6196,20 +6220,23 @@
61966220
sqlite3_value **argv
61976221
){
61986222
SHA1Context cx;
61996223
int eType = sqlite3_value_type(argv[0]);
62006224
int nByte = sqlite3_value_bytes(argv[0]);
6225
+ const unsigned char *pData;
62016226
char zOut[44];
62026227
62036228
assert( argc==1 );
62046229
if( eType==SQLITE_NULL ) return;
62056230
hash_init(&cx);
62066231
if( eType==SQLITE_BLOB ){
6207
- hash_step(&cx, sqlite3_value_blob(argv[0]), nByte);
6232
+ pData = (const unsigned char*)sqlite3_value_blob(argv[0]);
62086233
}else{
6209
- hash_step(&cx, sqlite3_value_text(argv[0]), nByte);
6234
+ pData = (const unsigned char*)sqlite3_value_text(argv[0]);
62106235
}
6236
+ if( pData==0 ) return;
6237
+ hash_step(&cx, pData, nByte);
62116238
if( sqlite3_user_data(context)!=0 ){
62126239
/* sha1b() - binary result */
62136240
hash_finish(&cx, zOut, 1);
62146241
sqlite3_result_blob(context, zOut, 20, SQLITE_TRANSIENT);
62156242
}else{
@@ -6267,10 +6294,11 @@
62676294
sqlite3_free(zMsg);
62686295
return;
62696296
}
62706297
nCol = sqlite3_column_count(pStmt);
62716298
z = sqlite3_sql(pStmt);
6299
+ if( z==0 ) z = "";
62726300
n = (int)strlen(z);
62736301
hash_step_vformat(&cx,"S%d:",n);
62746302
hash_step(&cx,(unsigned char*)z,n);
62756303
62766304
/* Compute a hash over the result of the query */
@@ -6489,10 +6517,14 @@
64896517
#endif
64906518
64916519
#ifndef IsSpace
64926520
#define IsSpace(X) isspace((unsigned char)X)
64936521
#endif
6522
+
6523
+#ifndef SQLITE_DECIMAL_MAX_DIGIT
6524
+# define SQLITE_DECIMAL_MAX_DIGIT 10000000
6525
+#endif
64946526
64956527
/* A decimal object */
64966528
typedef struct Decimal Decimal;
64976529
struct Decimal {
64986530
char sign; /* 0 for positive, 1 for negative */
@@ -6528,10 +6560,11 @@
65286560
static Decimal *decimalNewFromText(const char *zIn, int n){
65296561
Decimal *p = 0;
65306562
int i;
65316563
int iExp = 0;
65326564
6565
+ if( zIn==0 ) goto new_from_text_failed;
65336566
p = sqlite3_malloc( sizeof(*p) );
65346567
if( p==0 ) goto new_from_text_failed;
65356568
p->sign = 0;
65366569
p->oom = 0;
65376570
p->isInit = 1;
@@ -6587,13 +6620,14 @@
65876620
iExp -= p->nFrac;
65886621
p->nFrac = 0;
65896622
}
65906623
}
65916624
if( iExp>0 ){
6592
- p->a = sqlite3_realloc64(p->a, (sqlite3_int64)p->nDigit
6625
+ signed char *a = sqlite3_realloc64(p->a, (sqlite3_int64)p->nDigit
65936626
+ (sqlite3_int64)iExp + 1 );
6594
- if( p->a==0 ) goto new_from_text_failed;
6627
+ if( a==0 ) goto new_from_text_failed;
6628
+ p->a = a;
65956629
memset(p->a+p->nDigit, 0, iExp);
65966630
p->nDigit += iExp;
65976631
}
65986632
}else if( iExp<0 ){
65996633
int nExtra;
@@ -6607,13 +6641,14 @@
66076641
iExp -= nExtra;
66086642
p->nFrac = p->nDigit - 1;
66096643
}
66106644
}
66116645
if( iExp>0 ){
6612
- p->a = sqlite3_realloc64(p->a, (sqlite3_int64)p->nDigit
6646
+ signed char *a = sqlite3_realloc64(p->a, (sqlite3_int64)p->nDigit
66136647
+ (sqlite3_int64)iExp + 1 );
6614
- if( p->a==0 ) goto new_from_text_failed;
6648
+ if( a==0 ) goto new_from_text_failed;
6649
+ p->a = a;
66156650
memmove(p->a+iExp, p->a, p->nDigit);
66166651
memset(p->a, 0, iExp);
66176652
p->nDigit += iExp;
66186653
p->nFrac += iExp;
66196654
}
@@ -6620,10 +6655,11 @@
66206655
}
66216656
if( p->sign ){
66226657
for(i=0; i<p->nDigit && p->a[i]==0; i++){}
66236658
if( i>=p->nDigit ) p->sign = 0;
66246659
}
6660
+ if( p->nDigit>SQLITE_DECIMAL_MAX_DIGIT ) goto new_from_text_failed;
66256661
return p;
66266662
66276663
new_from_text_failed:
66286664
if( p ){
66296665
if( p->a ) sqlite3_free(p->a);
@@ -6757,10 +6793,12 @@
67576793
*/
67586794
static void decimal_round(Decimal *p, int N){
67596795
int i;
67606796
int nZero;
67616797
if( N<1 ) return;
6798
+ if( p==0 ) return;
6799
+ if( p->nDigit<=N ) return;
67626800
for(nZero=0; nZero<p->nDigit && p->a[nZero]==0; nZero++){}
67636801
N += nZero;
67646802
if( p->nDigit<=N ) return;
67656803
if( p->a[N]>4 ){
67666804
p->a[N-1]++;
@@ -6914,19 +6952,22 @@
69146952
** digits to the right of the decimal point.
69156953
*/
69166954
static void decimal_expand(Decimal *p, int nDigit, int nFrac){
69176955
int nAddSig;
69186956
int nAddFrac;
6957
+ signed char *a;
69196958
if( p==0 ) return;
69206959
nAddFrac = nFrac - p->nFrac;
69216960
nAddSig = (nDigit - p->nDigit) - nAddFrac;
69226961
if( nAddFrac==0 && nAddSig==0 ) return;
6923
- p->a = sqlite3_realloc64(p->a, nDigit+1);
6924
- if( p->a==0 ){
6962
+ if( nDigit+1>SQLITE_DECIMAL_MAX_DIGIT ){ p->oom = 1; return; }
6963
+ a = sqlite3_realloc64(p->a, nDigit+1);
6964
+ if( a==0 ){
69256965
p->oom = 1;
69266966
return;
69276967
}
6968
+ p->a = a;
69286969
if( nAddSig ){
69296970
memmove(p->a+nAddSig, p->a, p->nDigit);
69306971
memset(p->a, 0, nAddSig);
69316972
p->nDigit += nAddSig;
69326973
}
@@ -7017,18 +7058,22 @@
70177058
*/
70187059
static void decimalMul(Decimal *pA, Decimal *pB){
70197060
signed char *acc = 0;
70207061
int i, j, k;
70217062
int minFrac;
7063
+ sqlite3_int64 sumDigit;
70227064
70237065
if( pA==0 || pA->oom || pA->isNull
70247066
|| pB==0 || pB->oom || pB->isNull
70257067
){
70267068
goto mul_end;
70277069
}
7028
- acc = sqlite3_malloc64( (sqlite3_int64)pA->nDigit +
7029
- (sqlite3_int64)pB->nDigit + 2 );
7070
+ sumDigit = pA->nDigit;
7071
+ sumDigit += pB->nDigit;
7072
+ sumDigit += 2;
7073
+ if( sumDigit>SQLITE_DECIMAL_MAX_DIGIT ){ pA->oom = 1; return; }
7074
+ acc = sqlite3_malloc64( sumDigit );
70307075
if( acc==0 ){
70317076
pA->oom = 1;
70327077
goto mul_end;
70337078
}
70347079
memset(acc, 0, pA->nDigit + pB->nDigit + 2);
@@ -7394,12 +7439,10 @@
73947439
}
73957440
return rc;
73967441
}
73977442
73987443
/************************* End ext/misc/decimal.c ********************/
7399
-#undef sqlite3_base_init
7400
-#define sqlite3_base_init sqlite3_base64_init
74017444
/************************* Begin ext/misc/base64.c ******************/
74027445
/*
74037446
** 2022-11-18
74047447
**
74057448
** The author disclaims copyright to this source code. In place of
@@ -7674,11 +7717,11 @@
76747717
*/
76757718
#ifndef SQLITE_SHELL_EXTFUNCS
76767719
#ifdef _WIN32
76777720
76787721
#endif
7679
-int sqlite3_base_init
7722
+int sqlite3_base64_init
76807723
#else
76817724
static int sqlite3_base64_init
76827725
#endif
76837726
(sqlite3 *db, char **pzErr, const sqlite3_api_routines *pApi){
76847727
SQLITE_EXTENSION_INIT2(pApi);
@@ -7696,13 +7739,10 @@
76967739
*/
76977740
#define BASE64_INIT(db) sqlite3_base64_init(db, 0, 0)
76987741
#define BASE64_EXPOSE(db, pzErr) /* Not needed, ..._init() does this. */
76997742
77007743
/************************* End ext/misc/base64.c ********************/
7701
-#undef sqlite3_base_init
7702
-#define sqlite3_base_init sqlite3_base85_init
7703
-#define OMIT_BASE85_CHECKER
77047744
/************************* Begin ext/misc/base85.c ******************/
77057745
/*
77067746
** 2022-11-16
77077747
**
77087748
** The author disclaims copyright to this source code. In place of
@@ -7964,11 +8004,11 @@
79648004
}
79658005
#endif
79668006
79678007
#ifndef BASE85_STANDALONE
79688008
7969
-# ifndef OMIT_BASE85_CHECKER
8009
+#ifndef OMIT_BASE85_CHECKER
79708010
/* This function does the work for the SQLite is_base85(t) UDF. */
79718011
static void is_base85(sqlite3_context *context, int na, sqlite3_value *av[]){
79728012
assert(na==1);
79738013
switch( sqlite3_value_type(av[0]) ){
79748014
case SQLITE_TEXT:
@@ -7984,11 +8024,11 @@
79848024
default:
79858025
sqlite3_result_error(context, "is_base85 accepts only text or NULL", -1);
79868026
return;
79878027
}
79888028
}
7989
-# endif
8029
+#endif
79908030
79918031
/* This function does the work for the SQLite base85(x) UDF. */
79928032
static void base85(sqlite3_context *context, int na, sqlite3_value *av[]){
79938033
sqlite3_int64 nb, nc, nv = sqlite3_value_bytes(av[0]);
79948034
int nvMax = sqlite3_limit(sqlite3_context_db_handle(context),
@@ -8054,26 +8094,26 @@
80548094
*/
80558095
#ifndef SQLITE_SHELL_EXTFUNCS
80568096
#ifdef _WIN32
80578097
80588098
#endif
8059
-int sqlite3_base_init
8099
+int sqlite3_base85_init
80608100
#else
80618101
static int sqlite3_base85_init
80628102
#endif
80638103
(sqlite3 *db, char **pzErr, const sqlite3_api_routines *pApi){
80648104
SQLITE_EXTENSION_INIT2(pApi);
80658105
(void)pzErr;
8066
-# ifndef OMIT_BASE85_CHECKER
8106
+#ifndef OMIT_BASE85_CHECKER
80678107
{
80688108
int rc = sqlite3_create_function
80698109
(db, "is_base85", 1,
80708110
SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS|SQLITE_UTF8,
80718111
0, is_base85, 0, 0);
80728112
if( rc!=SQLITE_OK ) return rc;
80738113
}
8074
-# endif
8114
+#endif
80758115
return sqlite3_create_function
80768116
(db, "base85", 1,
80778117
SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS|SQLITE_DIRECTONLY|SQLITE_UTF8,
80788118
0, base85, 0, 0);
80798119
}
@@ -8134,13 +8174,13 @@
81348174
case 'w':
81358175
while( 0 != fgets(cBuf, sizeof(cBuf), stdin) ){
81368176
int nc = strlen(cBuf);
81378177
size_t nbo = fromBase85( cBuf, nc, bBuf ) - bBuf;
81388178
if( 1 != fwrite(bBuf, nbo, 1, fb) ) rc = 1;
8139
-# ifndef OMIT_BASE85_CHECKER
8179
+#ifndef OMIT_BASE85_CHECKER
81408180
b85Clean &= allBase85( cBuf, nc );
8141
-# endif
8181
+#endif
81428182
}
81438183
break;
81448184
default:
81458185
sayHelp();
81468186
rc = 1;
@@ -10291,11 +10331,10 @@
1029110331
ReCompiled *pRe;
1029210332
sqlite3_str *pStr;
1029310333
int i;
1029410334
int n;
1029510335
char *z;
10296
- (void)argc;
1029710336
static const char *ReOpName[] = {
1029810337
"EOF",
1029910338
"MATCH",
1030010339
"ANY",
1030110340
"ANYSTAR",
@@ -10314,10 +10353,11 @@
1031410353
"NOTSPACE",
1031510354
"BOUNDARY",
1031610355
"ATSTART",
1031710356
};
1031810357
10358
+ (void)argc;
1031910359
zPattern = (const char*)sqlite3_value_text(argv[0]);
1032010360
if( zPattern==0 ) return;
1032110361
zErr = re_compile(&pRe, zPattern, re_maxnfa(re_maxlen(context)),
1032210362
sqlite3_user_data(context)!=0);
1032310363
if( zErr ){
@@ -10468,15 +10508,10 @@
1046810508
**
1046910509
** If a non-NULL value is specified for the optional $dir parameter and
1047010510
** $path is a relative path, then $path is interpreted relative to $dir.
1047110511
** And the paths returned in the "name" column of the table are also
1047210512
** relative to directory $dir.
10473
-**
10474
-** Notes on building this extension for Windows:
10475
-** Unless linked statically with the SQLite library, a preprocessor
10476
-** symbol, FILEIO_WIN32_DLL, must be #define'd to create a stand-alone
10477
-** DLL form of this extension for WIN32. See its use below for details.
1047810513
*/
1047910514
/* #include "sqlite3ext.h" */
1048010515
SQLITE_EXTENSION_INIT1
1048110516
#include <stdio.h>
1048210517
#include <string.h>
@@ -11836,10 +11871,11 @@
1183611871
*/
1183711872
static int completionNext(sqlite3_vtab_cursor *cur){
1183811873
completion_cursor *pCur = (completion_cursor*)cur;
1183911874
int eNextPhase = 0; /* Next phase to try if current phase reaches end */
1184011875
int iCol = -1; /* If >=0, step pCur->pStmt and use the i-th column */
11876
+ int rc;
1184111877
pCur->iRowid++;
1184211878
while( pCur->ePhase!=COMPLETION_EOF ){
1184311879
switch( pCur->ePhase ){
1184411880
case COMPLETION_KEYWORDS: {
1184511881
if( pCur->j >= sqlite3_keyword_count() ){
@@ -11861,52 +11897,62 @@
1186111897
break;
1186211898
}
1186311899
case COMPLETION_TABLES: {
1186411900
if( pCur->pStmt==0 ){
1186511901
sqlite3_stmt *pS2;
11902
+ sqlite3_str* pStr = sqlite3_str_new(pCur->db);
1186611903
char *zSql = 0;
1186711904
const char *zSep = "";
1186811905
sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pS2, 0);
1186911906
while( sqlite3_step(pS2)==SQLITE_ROW ){
1187011907
const char *zDb = (const char*)sqlite3_column_text(pS2, 1);
11871
- zSql = sqlite3_mprintf(
11872
- "%z%s"
11908
+ sqlite3_str_appendf(pStr,
11909
+ "%s"
1187311910
"SELECT name FROM \"%w\".sqlite_schema",
11874
- zSql, zSep, zDb
11911
+ zSep, zDb
1187511912
);
11876
- if( zSql==0 ) return SQLITE_NOMEM;
1187711913
zSep = " UNION ";
1187811914
}
11879
- sqlite3_finalize(pS2);
11880
- sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
11915
+ rc = sqlite3_finalize(pS2);
11916
+ zSql = sqlite3_str_finish(pStr);
11917
+ if( zSql==0 ) return SQLITE_NOMEM;
11918
+ if( rc==SQLITE_OK ){
11919
+ sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
11920
+ }
1188111921
sqlite3_free(zSql);
11922
+ if( rc ) return rc;
1188211923
}
1188311924
iCol = 0;
1188411925
eNextPhase = COMPLETION_COLUMNS;
1188511926
break;
1188611927
}
1188711928
case COMPLETION_COLUMNS: {
1188811929
if( pCur->pStmt==0 ){
1188911930
sqlite3_stmt *pS2;
11931
+ sqlite3_str *pStr = sqlite3_str_new(pCur->db);
1189011932
char *zSql = 0;
1189111933
const char *zSep = "";
1189211934
sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pS2, 0);
1189311935
while( sqlite3_step(pS2)==SQLITE_ROW ){
1189411936
const char *zDb = (const char*)sqlite3_column_text(pS2, 1);
11895
- zSql = sqlite3_mprintf(
11896
- "%z%s"
11937
+ sqlite3_str_appendf(pStr,
11938
+ "%s"
1189711939
"SELECT pti.name FROM \"%w\".sqlite_schema AS sm"
1189811940
" JOIN pragma_table_xinfo(sm.name,%Q) AS pti"
1189911941
" WHERE sm.type='table'",
11900
- zSql, zSep, zDb, zDb
11942
+ zSep, zDb, zDb
1190111943
);
11902
- if( zSql==0 ) return SQLITE_NOMEM;
1190311944
zSep = " UNION ";
1190411945
}
11905
- sqlite3_finalize(pS2);
11906
- sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
11946
+ rc = sqlite3_finalize(pS2);
11947
+ zSql = sqlite3_str_finish(pStr);
11948
+ if( zSql==0 ) return SQLITE_NOMEM;
11949
+ if( rc==SQLITE_OK ){
11950
+ sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
11951
+ }
1190711952
sqlite3_free(zSql);
11953
+ if( rc ) return rc;
1190811954
}
1190911955
iCol = 0;
1191011956
eNextPhase = COMPLETION_EOF;
1191111957
break;
1191211958
}
@@ -11919,13 +11965,14 @@
1191911965
/* Extract the next row of content */
1192011966
pCur->zCurrentRow = (const char*)sqlite3_column_text(pCur->pStmt, iCol);
1192111967
pCur->szRow = sqlite3_column_bytes(pCur->pStmt, iCol);
1192211968
}else{
1192311969
/* When all rows are finished, advance to the next phase */
11924
- sqlite3_finalize(pCur->pStmt);
11970
+ rc = sqlite3_finalize(pCur->pStmt);
1192511971
pCur->pStmt = 0;
1192611972
pCur->ePhase = eNextPhase;
11973
+ if( rc ) return rc;
1192711974
continue;
1192811975
}
1192911976
}
1193011977
if( pCur->nPrefix==0 ) break;
1193111978
if( pCur->nPrefix<=pCur->szRow
@@ -15207,11 +15254,11 @@
1520715254
){
1520815255
uLong nData;
1520915256
sqlite3_int64 sz;
1521015257
1521115258
assert( argc==2 );
15212
- sz = sqlite3_value_int(argv[1]);
15259
+ sz = sqlite3_value_int64(argv[1]);
1521315260
1521415261
if( sz<=0 || sz==(nData = sqlite3_value_bytes(argv[0])) ){
1521515262
sqlite3_result_value(context, argv[0]);
1521615263
}else{
1521715264
uLongf szf = sz;
@@ -24602,10 +24649,13 @@
2460224649
# define DFLT_LINE_LIMIT 5
2460324650
#endif
2460424651
#ifndef DFLT_TITLE_LIMIT
2460524652
# define DFLT_TITLE_LIMIT 20
2460624653
#endif
24654
+#ifndef DFLT_MULTI_INSERT
24655
+# define DFLT_MULTI_INSERT 3000
24656
+#endif
2460724657
2460824658
/*
2460924659
** Limit input nesting via .read or any other input redirect.
2461024660
** It's not too expensive, so a generous allowance can be made.
2461124661
*/
@@ -24798,11 +24848,11 @@
2479824848
free(p->spec.zColumnSep);
2479924849
free(p->spec.zRowSep);
2480024850
free(p->spec.zTableName);
2480124851
free(p->spec.zNull);
2480224852
memset(p, 0, sizeof(*p));
24803
- p->spec.iVersion = 1;
24853
+ p->spec.iVersion = 2;
2480424854
p->autoExplain = autoExplain;
2480524855
}
2480624856
2480724857
/*
2480824858
** Duplicate Mode pSrc into pDest. pDest is assumed to be
@@ -24904,20 +24954,21 @@
2490424954
p->mode.spec.eText = QRF_TEXT_Relaxed;
2490524955
p->mode.spec.nCharLimit = DFLT_CHAR_LIMIT;
2490624956
p->mode.spec.nLineLimit = DFLT_LINE_LIMIT;
2490724957
p->mode.spec.bTextJsonb = QRF_Yes;
2490824958
p->mode.spec.nTitleLimit = DFLT_TITLE_LIMIT;
24959
+ p->mode.spec.nMultiInsert = DFLT_MULTI_INSERT;
2490924960
p->mode.mFlags = mFlags;
2491024961
}
2491124962
}
2491224963
2491324964
/*
2491424965
** Set the mode to the default. It assumed that the mode has
2491524966
** already been freed and zeroed prior to calling this routine.
2491624967
*/
2491724968
static void modeDefault(ShellState *p){
24918
- p->mode.spec.iVersion = 1;
24969
+ p->mode.spec.iVersion = 2;
2491924970
p->mode.autoExplain = 1;
2492024971
if( stdin_is_interactive || stdout_is_console ){
2492124972
modeChange(p, MODE_TTY);
2492224973
}else{
2492324974
modeChange(p, MODE_BATCH);
@@ -26860,10 +26911,11 @@
2686026911
p->mode.spec.zTableName = (char*)zTable;
2686126912
p->mode.eMode = MODE_Insert;
2686226913
p->mode.spec.eText = QRF_TEXT_Sql;
2686326914
p->mode.spec.eBlob = QRF_BLOB_Sql;
2686426915
p->mode.spec.bTitles = QRF_No;
26916
+ p->mode.spec.nCharLimit = 0;
2686526917
rc = shell_exec(p, sSelect.zTxt, 0);
2686626918
if( (rc&0xff)==SQLITE_CORRUPT ){
2686726919
cli_puts("/****** CORRUPTION ERROR *******/\n", p->out);
2686826920
toggleSelectOrder(p->db);
2686926921
shell_exec(p, sSelect.zTxt, 0);
@@ -27012,13 +27064,14 @@
2701227064
".import FILE TABLE Import data from FILE into TABLE",
2701327065
#endif
2701427066
#ifndef SQLITE_OMIT_TEST_CONTROL
2701527067
".imposter INDEX TABLE Create imposter table TABLE on index INDEX",
2701627068
#endif
27017
- ".indexes ?TABLE? Show names of indexes",
27018
- " If TABLE is specified, only show indexes for",
27019
- " tables matching TABLE using the LIKE operator.",
27069
+ ".indexes ?PATTERN? Show names of indexes matching PATTERN",
27070
+ " -a|--all Also show system-generated indexes",
27071
+ " --expr Show only expression indexes",
27072
+ " --sys Show only system-generated indexes",
2702027073
".intck ?STEPS_PER_UNLOCK? Run an incremental integrity check on the db",
2702127074
#ifdef SQLITE_ENABLE_IOTRACE
2702227075
",iotrace FILE Enable I/O diagnostic logging to FILE",
2702327076
#endif
2702427077
".limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT",
@@ -27252,10 +27305,12 @@
2725227305
" --titlelimit T\". The \",T\" can be omitted in which\n"
2725327306
" case the --titlelimit is unchanged. The argument\n"
2725427307
" can also be \"off\" to mean \"0,0,0\" or \"on\" to\n"
2725527308
" mean \"5,300,20\".\n"
2725627309
" --list List available modes\n"
27310
+" --multiinsert N In \"insert\" mode, put multiple rows on a single\n"
27311
+" INSERT statement until the size exceeds N bytes.\n"
2725727312
" --null STRING Render SQL NULL values as the given string\n"
2725827313
" --once Setting changes to the right are reverted after\n"
2725927314
" the next SQL command.\n"
2726027315
" --quote ARG Enable/disable quoting of text. ARG can be\n"
2726127316
" \"off\", \"on\", \"sql\", \"relaxed\", \"csv\", \"html\",\n"
@@ -30750,11 +30805,11 @@
3075030805
static int outputDumpWarning(ShellState *p, const char *zLike){
3075130806
int rc = SQLITE_OK;
3075230807
sqlite3_stmt *pStmt = 0;
3075330808
shellPreparePrintf(p->db, &rc, &pStmt,
3075430809
"SELECT 1 FROM sqlite_schema o WHERE "
30755
- "sql LIKE 'CREATE VIRTUAL TABLE%%' AND %s", zLike ? zLike : "true"
30810
+ "sql LIKE 'CREATE VIRTUAL TABLE%%' AND (%s)", zLike ? zLike : "true"
3075630811
);
3075730812
if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
3075830813
cli_puts("/* WARNING: "
3075930814
"Script requires that SQLITE_DBCONFIG_DEFENSIVE be disabled */\n",
3076030815
p->out
@@ -31330,10 +31385,12 @@
3133031385
** --titlelimit T". The ",T" can be omitted in which
3133131386
** case the --titlelimit is unchanged. The argument
3133231387
** can also be "off" to mean "0,0,0" or "on" to
3133331388
** mean "5,300,20".
3133431389
** --list List available modes
31390
+** --multiinsert N In "insert" mode, put multiple rows on a single
31391
+** INSERT statement until the size exceeds N bytes.
3133531392
** --null STRING Render SQL NULL values as the given string
3133631393
** --once Setting changes to the right are reverted after
3133731394
** the next SQL command.
3133831395
** --quote ARG Enable/disable quoting of text. ARG can be
3133931396
** "off", "on", "sql", "relaxed", "csv", "html",
@@ -31445,21 +31502,23 @@
3144531502
k = pickStr(azArg[i], 0, "auto", "off", "on", "");
3144631503
if( k>=0 ){
3144731504
p->mode.spec.bBorder = k & 0x3;
3144831505
}
3144931506
chng = 1;
31450
- }else if( 0<=(k=pickStr(z,0,"-charlimit","-linelimit","-titlelimit","")) ){
31451
- int w; /* 0 1 */
31507
+ }else if( 0<=(k=pickStr(z,0,
31508
+ "-charlimit","-linelimit","-titlelimit","-multiinsert","")) ){
31509
+ int w; /* 0 1 2 3 */
3145231510
if( i+1>=nArg ){
3145331511
dotCmdError(p, i, "missing argument", 0);
3145431512
return 1;
3145531513
}
3145631514
w = integerValue(azArg[++i]);
3145731515
switch( k ){
31458
- case 0: p->mode.spec.nCharLimit = w; break;
31459
- case 1: p->mode.spec.nLineLimit = w; break;
31460
- default: p->mode.spec.nTitleLimit = w; break;
31516
+ case 0: p->mode.spec.nCharLimit = w; break;
31517
+ case 1: p->mode.spec.nLineLimit = w; break;
31518
+ case 2: p->mode.spec.nTitleLimit = w; break;
31519
+ default: p->mode.spec.nMultiInsert = w; break;
3146131520
}
3146231521
chng = 1;
3146331522
}else if( 0<=(k=pickStr(z,0,"-tablename","-rowsep","-colsep","-null","")) ){
3146431523
/* 0 1 2 3 */
3146531524
if( i+1>=nArg ){
@@ -31798,10 +31857,16 @@
3179831857
sqlite3_str_appendf(pDesc, " --limits %d,%d,%d",
3179931858
p->mode.spec.nLineLimit, p->mode.spec.nCharLimit,
3180031859
p->mode.spec.nTitleLimit);
3180131860
}
3180231861
}
31862
+ if( bAll
31863
+ || (p->mode.spec.nMultiInsert && p->mode.spec.eStyle==QRF_STYLE_Insert)
31864
+ ){
31865
+ sqlite3_str_appendf(pDesc, " --multiinsert %u",
31866
+ p->mode.spec.nMultiInsert);
31867
+ }
3180331868
zSetting = aModeStr[pI->eNull];
3180431869
if( bAll || (zSetting && cli_strcmp(zSetting,p->mode.spec.zNull)!=0) ){
3180531870
sqlite3_str_appendf(pDesc, " --null ");
3180631871
append_c_string(pDesc, p->mode.spec.zNull);
3180731872
}
@@ -33263,10 +33328,96 @@
3326333328
rc = 1;
3326433329
}
3326533330
sqlite3_free(zSql);
3326633331
}else
3326733332
#endif /* !defined(SQLITE_OMIT_TEST_CONTROL) */
33333
+
33334
+ if( c=='i' && (cli_strncmp(azArg[0], "indices", n)==0
33335
+ || cli_strncmp(azArg[0], "indexes", n)==0)
33336
+ ){
33337
+ sqlite3_str *pSql;
33338
+ int i;
33339
+ int allFlag = 0;
33340
+ int sysFlag = 0;
33341
+ int exprFlag = 0;
33342
+ int debugFlag = 0; /* Undocument --debug flag */
33343
+ const char *zPattern = 0;
33344
+ const char *zSep = "WHERE";
33345
+
33346
+ for(i=1; i<nArg; i++){
33347
+ if( azArg[i][0]=='-' ){
33348
+ const char *z = azArg[i]+1;
33349
+ if( z[0]=='-' ) z++;
33350
+ if( cli_strcmp(z,"all")==0 || cli_strcmp(z,"a")==0 ){
33351
+ allFlag = 1;
33352
+ }else
33353
+ if( cli_strcmp(z,"sys")==0 ){
33354
+ sysFlag = 1;
33355
+ allFlag = 0;
33356
+ }else
33357
+ if( cli_strcmp(z,"expr")==0 ){
33358
+ exprFlag = 1;
33359
+ allFlag = 0;
33360
+ }else
33361
+ if( cli_strcmp(z,"debug")==0 ){
33362
+ debugFlag = 1;
33363
+ }else
33364
+ {
33365
+ dotCmdError(p, i, "unknown option", 0);
33366
+ rc = 1;
33367
+ goto meta_command_exit;
33368
+ }
33369
+ }else if( zPattern==0 ){
33370
+ zPattern = azArg[i];
33371
+ }else{
33372
+ dotCmdError(p, i, "unknown argument", 0);
33373
+ rc = 1;
33374
+ goto meta_command_exit;
33375
+ }
33376
+ }
33377
+
33378
+ open_db(p, 0);
33379
+ pSql = sqlite3_str_new(p->db);
33380
+ sqlite3_str_appendf(pSql,
33381
+ "SELECT if(t.schema='main',i.name,t.schema||'.'||i.name)\n"
33382
+ "FROM pragma_table_list t, pragma_index_list(t.name,t.schema) i\n"
33383
+ );
33384
+ if( exprFlag ){
33385
+ allFlag = 0;
33386
+ sqlite3_str_appendf(pSql,
33387
+ "%s (EXISTS(SELECT 1 FROM pragma_index_xinfo(i.name) WHERE cid=-2)\n"
33388
+ " OR\n"
33389
+ " EXISTS(SELECT cid FROM pragma_table_xinfo(t.name) WHERE hidden=2"
33390
+ " INTERSECT "
33391
+ " SELECT cid FROM pragma_index_info(i.name)))\n", zSep);
33392
+ zSep = "AND";
33393
+ }
33394
+ if( sysFlag ){
33395
+ sqlite3_str_appendf(pSql,
33396
+ "%s i.name LIKE 'sqlite__autoindex__%%' ESCAPE '_'\n", zSep);
33397
+ zSep = "AND";
33398
+ }else if( !allFlag ){
33399
+ sqlite3_str_appendf(pSql,
33400
+ "%s i.name NOT LIKE 'sqlite__%%' ESCAPE '_'\n", zSep);
33401
+ zSep = "AND";
33402
+ }
33403
+ if( zPattern ){
33404
+ sqlite3_str_appendf(pSql, "%s i.name LIKE '%%%q%%'\n", zSep, zPattern);
33405
+ }
33406
+ sqlite3_str_appendf(pSql, "ORDER BY 1");
33407
+
33408
+ /* Run the SQL statement in "split" mode. */
33409
+ if( debugFlag ){
33410
+ cli_printf(stdout,"%s;\n", sqlite3_str_value(pSql));
33411
+ }else{
33412
+ modePush(p);
33413
+ modeChange(p, MODE_Split);
33414
+ shell_exec(p, sqlite3_str_value(pSql), 0);
33415
+ modePop(p);
33416
+ }
33417
+ sqlite3_str_free(pSql);
33418
+ }else
3326833419
3326933420
if( c=='i' && cli_strncmp(azArg[0], "intck", n)==0 ){
3327033421
i64 iArg = 0;
3327133422
if( nArg==2 ){
3327233423
iArg = integerValue(azArg[1]);
@@ -34641,14 +34792,11 @@
3464134792
eputz("Usage: .stats ?on|off|stmt|vmstep?\n");
3464234793
rc = 1;
3464334794
}
3464434795
}else
3464534796
34646
- if( (c=='t' && n>1 && cli_strncmp(azArg[0], "tables", n)==0)
34647
- || (c=='i' && (cli_strncmp(azArg[0], "indices", n)==0
34648
- || cli_strncmp(azArg[0], "indexes", n)==0) )
34649
- ){
34797
+ if( (c=='t' && n>1 && cli_strncmp(azArg[0], "tables", n)==0) ){
3465034798
sqlite3_stmt *pStmt;
3465134799
sqlite3_str *pSql;
3465234800
const char *zPattern = nArg>1 ? azArg[1] : 0;
3465334801
3465434802
open_db(p, 0);
@@ -34656,19 +34804,10 @@
3465634804
if( rc ){
3465734805
sqlite3_finalize(pStmt);
3465834806
return shellDatabaseError(p->db);
3465934807
}
3466034808
34661
- if( nArg>2 && c=='i' ){
34662
- /* It is an historical accident that the .indexes command shows an error
34663
- ** when called with the wrong number of arguments whereas the .tables
34664
- ** command does not. */
34665
- eputz("Usage: .indexes ?LIKE-PATTERN?\n");
34666
- rc = 1;
34667
- sqlite3_finalize(pStmt);
34668
- goto meta_command_exit;
34669
- }
3467034809
pSql = sqlite3_str_new(p->db);
3467134810
while( sqlite3_step(pStmt)==SQLITE_ROW ){
3467234811
const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1);
3467334812
if( zDbName==0 ) continue;
3467434813
if( sqlite3_str_length(pSql) ){
@@ -34678,23 +34817,16 @@
3467834817
sqlite3_str_appendall(pSql, "SELECT name FROM ");
3467934818
}else{
3468034819
sqlite3_str_appendf(pSql, "SELECT %Q||'.'||name FROM ", zDbName);
3468134820
}
3468234821
sqlite3_str_appendf(pSql, "\"%w\".sqlite_schema", zDbName);
34683
- if( c=='t' ){
34684
- sqlite3_str_appendf(pSql,
34685
- " WHERE type IN ('table','view')"
34686
- " AND name NOT LIKE 'sqlite__%%' ESCAPE '_'"
34687
- );
34688
- if( zPattern ){
34689
- sqlite3_str_appendf(pSql," AND name LIKE %Q", zPattern);
34690
- }
34691
- }else{
34692
- sqlite3_str_appendf(pSql, " WHERE type='index'");
34693
- if( zPattern ){
34694
- sqlite3_str_appendf(pSql," AND tbl_name LIKE %Q", zPattern);
34695
- }
34822
+ sqlite3_str_appendf(pSql,
34823
+ " WHERE type IN ('table','view')"
34824
+ " AND name NOT LIKE 'sqlite__%%' ESCAPE '_'"
34825
+ );
34826
+ if( zPattern ){
34827
+ sqlite3_str_appendf(pSql," AND name LIKE %Q", zPattern);
3469634828
}
3469734829
}
3469834830
rc = sqlite3_finalize(pStmt);
3469934831
if( rc==SQLITE_OK ){
3470034832
sqlite3_str_appendall(pSql, " ORDER BY 1");
@@ -35622,11 +35754,16 @@
3562235754
}
3562335755
3562435756
/*
3562535757
** Run a single line of SQL. Return the number of errors.
3562635758
*/
35627
-static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
35759
+static int runOneSqlLine(
35760
+ ShellState *p, /* Execution context */
35761
+ char *zSql, /* SQL to be run */
35762
+ const char *zFilename, /* Source file of the sql */
35763
+ int startline /* linenumber */
35764
+){
3562835765
int rc;
3562935766
char *zErrMsg = 0;
3563035767
3563135768
open_db(p, 0);
3563235769
if( ShellHasFlag(p,SHFLG_Backslash) ) resolve_backslashes(zSql);
@@ -35649,13 +35786,21 @@
3564935786
zErrorTail = &zErrMsg[10];
3565035787
}else{
3565135788
zErrorType = "Error";
3565235789
zErrorTail = zErrMsg;
3565335790
}
35654
- if( in!=0 || !stdin_is_interactive ){
35655
- sqlite3_snprintf(sizeof(zPrefix), zPrefix,
35656
- "%s near line %d:", zErrorType, startline);
35791
+ if( zFilename || !stdin_is_interactive ){
35792
+ if( cli_strcmp(zFilename,"cmdline")==0 ){
35793
+ sqlite3_snprintf(sizeof(zPrefix), zPrefix,
35794
+ "%s in %r command line argument:", zErrorType, startline);
35795
+ }else if( cli_strcmp(zFilename,"<stdin>")==0 ){
35796
+ sqlite3_snprintf(sizeof(zPrefix), zPrefix,
35797
+ "%s near line %d:", zErrorType, startline);
35798
+ }else{
35799
+ sqlite3_snprintf(sizeof(zPrefix), zPrefix,
35800
+ "%s near line %d of %s:", zErrorType, startline, zFilename);
35801
+ }
3565735802
}else{
3565835803
sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%s:", zErrorType);
3565935804
}
3566035805
cli_printf(stderr,"%s %s\n", zPrefix, zErrorTail);
3566135806
sqlite3_free(zErrMsg);
@@ -35814,11 +35959,11 @@
3581435959
nSql = 0;
3581535960
errCnt++;
3581635961
break;
3581735962
}else if( nSql && QSS_SEMITERM(qss) && sqlite3_complete(zSql) ){
3581835963
echo_group_input(p, zSql);
35819
- errCnt += runOneSqlLine(p, zSql, p->in, startline);
35964
+ errCnt += runOneSqlLine(p, zSql, p->zInFile, startline);
3582035965
CONTINUE_PROMPT_RESET;
3582135966
nSql = 0;
3582235967
if( p->nPopOutput ){
3582335968
output_reset(p);
3582435969
p->nPopOutput = 0;
@@ -35838,11 +35983,11 @@
3583835983
}
3583935984
}
3584035985
if( nSql ){
3584135986
/* This may be incomplete. Let the SQL parser deal with that. */
3584235987
echo_group_input(p, zSql);
35843
- errCnt += runOneSqlLine(p, zSql, p->in, startline);
35988
+ errCnt += runOneSqlLine(p, zSql, p->zInFile, startline);
3584435989
CONTINUE_PROMPT_RESET;
3584535990
}
3584635991
free(zSql);
3584735992
free(zLine);
3584835993
--p->inputNesting;
@@ -36186,11 +36331,11 @@
3618636331
3618736332
/* Use the wmain() entry point on Windows. Translate arguments to
3618836333
** UTF8, then invoke the traditional main() entry point which is
3618936334
** renamed using a #define to utf8_main() .
3619036335
*/
36191
-#if defined(_WIN32) && !defined(main)
36336
+#if defined(_WIN32) && !defined(__MINGW32__) && !defined(main)
3619236337
# define main utf8_main /* Rename entry point to utf_main() */
3619336338
int SQLITE_CDECL utf8_main(int,char**); /* Forward declaration */
3619436339
int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
3619536340
int rc, i;
3619636341
char **argv = malloc( sizeof(char*) * (argc+1) );
@@ -36235,11 +36380,10 @@
3623536380
*/
3623636381
int SQLITE_CDECL main(int argc, char **argv){
3623736382
#ifdef SQLITE_DEBUG
3623836383
sqlite3_int64 mem_main_enter = 0;
3623936384
#endif
36240
- char *zErrMsg = 0;
3624136385
#ifdef SQLITE_SHELL_FIDDLE
3624236386
# define data shellState
3624336387
#else
3624436388
ShellState data;
3624536389
#endif
@@ -36774,19 +36918,11 @@
3677436918
if( rc && (bail_on_error || rc==2) ){
3677536919
if( rc==2 ) rc = 0;
3677636920
goto shell_main_exit;
3677736921
}
3677836922
}else{
36779
- open_db(&data, 0);
36780
- rc = shell_exec(&data, z, &zErrMsg);
36781
- if( zErrMsg!=0 ){
36782
- shellEmitError(zErrMsg);
36783
- sqlite3_free(zErrMsg);
36784
- if( !rc ) rc = 1;
36785
- }else if( rc!=0 ){
36786
- cli_printf(stderr,"Error: unable to process SQL \"%s\"\n", z);
36787
- }
36923
+ rc = runOneSqlLine(&data, z, "cmdline", i);
3678836924
if( bail_on_error ) goto shell_main_exit;
3678936925
}
3679036926
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
3679136927
}else if( cli_strncmp(z, "-A", 2)==0 ){
3679236928
if( nCmd>0 ){
@@ -36848,29 +36984,17 @@
3684836984
if( rc ){
3684936985
if( rc==2 ) rc = 0;
3685036986
goto shell_main_exit;
3685136987
}
3685236988
}else{
36853
- open_db(&data, 0);
36854
- rc = shell_exec(&data, azCmd[i], &zErrMsg);
36855
- if( zErrMsg || rc ){
36856
- if( zErrMsg!=0 ){
36857
- shellEmitError(zErrMsg);
36858
- }else{
36859
- cli_printf(stderr,
36860
- "Error: unable to process SQL: %s\n", azCmd[i]);
36861
- }
36862
- sqlite3_free(zErrMsg);
36863
- if( rc==0 ) rc = 1;
36864
- goto shell_main_exit;
36865
- }
36989
+ rc = runOneSqlLine(&data, azCmd[i], "cmdline", aiCmd[i]);
3686636990
if( data.nPopMode ){
3686736991
modePop(&data);
3686836992
data.nPopMode = 0;
3686936993
}
3687036994
}
36871
- if( data.nPopOutput ){
36995
+ if( data.nPopOutput && azCmd[i][0]!='.' ){
3687236996
output_reset(&data);
3687336997
data.nPopOutput = 0;
3687436998
}else{
3687536999
clearTempFile(&data);
3687637000
}
3687737001
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -712,10 +712,12 @@
712 char *(*xRender)(void*,sqlite3_value*); /* Render a value */
713 int (*xWrite)(void*,const char*,sqlite3_int64); /* Write output */
714 void *pRenderArg; /* First argument to the xRender callback */
715 void *pWriteArg; /* First argument to the xWrite callback */
716 char **pzOutput; /* Storage location for output string */
 
 
717 /* Additional fields may be added in the future */
718 };
719
720 /*
721 ** Interfaces
@@ -925,10 +927,11 @@
925 struct { /* Content for QRF_STYLE_Explain */
926 int nIndent; /* Slots allocated for aiIndent */
927 int iIndent; /* Current slot */
928 int *aiIndent; /* Indentation for each opcode */
929 } sExpln;
 
930 } u;
931 sqlite3_int64 nRow; /* Number of rows handled so far */
932 int *actualWidth; /* Actual width of each column */
933 sqlite3_qrf_spec spec; /* Copy of the original spec */
934 };
@@ -3422,34 +3425,50 @@
3422 sqlite3_str_append(p->pOut, "\n</TR>\n", 7);
3423 qrfWrite(p);
3424 break;
3425 }
3426 case QRF_STYLE_Insert: {
3427 if( qrf_need_quote(p->spec.zTableName) ){
3428 sqlite3_str_appendf(p->pOut,"INSERT INTO \"%w\"",p->spec.zTableName);
3429 }else{
3430 sqlite3_str_appendf(p->pOut,"INSERT INTO %s",p->spec.zTableName);
3431 }
3432 if( p->spec.bTitles==QRF_Yes ){
3433 for(i=0; i<p->nCol; i++){
3434 const char *zCName = sqlite3_column_name(p->pStmt, i);
3435 if( qrf_need_quote(zCName) ){
3436 sqlite3_str_appendf(p->pOut, "%c\"%w\"",
3437 i==0 ? '(' : ',', zCName);
3438 }else{
3439 sqlite3_str_appendf(p->pOut, "%c%s",
3440 i==0 ? '(' : ',', zCName);
3441 }
3442 }
3443 sqlite3_str_append(p->pOut, ")", 1);
3444 }
3445 sqlite3_str_append(p->pOut," VALUES(", 8);
 
 
 
 
 
 
 
 
 
 
3446 for(i=0; i<p->nCol; i++){
3447 if( i>0 ) sqlite3_str_append(p->pOut, ",", 1);
3448 qrfRenderValue(p, p->pOut, i);
3449 }
3450 sqlite3_str_append(p->pOut, ");\n", 3);
 
 
 
 
 
 
3451 qrfWrite(p);
3452 break;
3453 }
3454 case QRF_STYLE_Line: {
3455 sqlite3_str *pVal;
@@ -3489,11 +3508,13 @@
3489 zVal = sqlite3_str_value(pVal);
3490 if( zVal==0 ) zVal = "";
3491 do{
3492 int nThis, nWide, iNext;
3493 qrfWrapLine(zVal, mxW, bWW, &nThis, &nWide, &iNext);
3494 if( cnt ) sqlite3_str_appendchar(p->pOut,p->u.sLine.mxColWth+2,' ');
 
 
3495 cnt++;
3496 if( cnt>p->mxHeight ){
3497 zVal = "...";
3498 nThis = iNext = 3;
3499 }
@@ -3552,11 +3573,11 @@
3552 char **pzErr /* Write errors here */
3553 ){
3554 size_t sz; /* Size of pSpec[], based on pSpec->iVersion */
3555 memset(p, 0, sizeof(*p));
3556 p->pzErr = pzErr;
3557 if( pSpec->iVersion!=1 ){
3558 qrfError(p, SQLITE_ERROR,
3559 "unusable sqlite3_qrf_spec.iVersion (%d)",
3560 pSpec->iVersion);
3561 return;
3562 }
@@ -3612,10 +3633,11 @@
3612 p->spec.eText = QRF_TEXT_Sql;
3613 p->spec.zNull = "NULL";
3614 if( p->spec.zTableName==0 || p->spec.zTableName[0]==0 ){
3615 p->spec.zTableName = "tab";
3616 }
 
3617 break;
3618 }
3619 case QRF_STYLE_Line: {
3620 if( p->spec.zColumnSep==0 ){
3621 p->spec.zColumnSep = ": ";
@@ -3710,24 +3732,27 @@
3710 */
3711 static void qrfFinalize(Qrf *p){
3712 switch( p->spec.eStyle ){
3713 case QRF_STYLE_Count: {
3714 sqlite3_str_appendf(p->pOut, "%lld\n", p->nRow);
3715 qrfWrite(p);
3716 break;
3717 }
3718 case QRF_STYLE_Json: {
3719 if( p->nRow>0 ){
3720 sqlite3_str_append(p->pOut, "}]\n", 3);
3721 qrfWrite(p);
3722 }
3723 break;
3724 }
3725 case QRF_STYLE_JObject: {
3726 if( p->nRow>0 ){
3727 sqlite3_str_append(p->pOut, "}\n", 2);
3728 qrfWrite(p);
 
 
 
 
 
3729 }
3730 break;
3731 }
3732 case QRF_STYLE_Line: {
3733 if( p->u.sLine.azCol ){
@@ -3743,19 +3768,18 @@
3743 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
3744 sqlite3_stmt_scanstatus_v2(p->pStmt, -1, SQLITE_SCANSTAT_NCYCLE,
3745 SQLITE_SCANSTAT_COMPLEX, (void*)&nCycle);
3746 #endif
3747 qrfEqpRender(p, nCycle);
3748 qrfWrite(p);
3749 break;
3750 }
3751 case QRF_STYLE_Eqp: {
3752 qrfEqpRender(p, 0);
3753 qrfWrite(p);
3754 break;
3755 }
3756 }
 
3757 qrfStrErr(p, p->pOut);
3758 if( p->spec.pzOutput ){
3759 if( p->spec.pzOutput[0] ){
3760 sqlite3_int64 n, sz;
3761 char *zCombined;
@@ -6196,20 +6220,23 @@
6196 sqlite3_value **argv
6197 ){
6198 SHA1Context cx;
6199 int eType = sqlite3_value_type(argv[0]);
6200 int nByte = sqlite3_value_bytes(argv[0]);
 
6201 char zOut[44];
6202
6203 assert( argc==1 );
6204 if( eType==SQLITE_NULL ) return;
6205 hash_init(&cx);
6206 if( eType==SQLITE_BLOB ){
6207 hash_step(&cx, sqlite3_value_blob(argv[0]), nByte);
6208 }else{
6209 hash_step(&cx, sqlite3_value_text(argv[0]), nByte);
6210 }
 
 
6211 if( sqlite3_user_data(context)!=0 ){
6212 /* sha1b() - binary result */
6213 hash_finish(&cx, zOut, 1);
6214 sqlite3_result_blob(context, zOut, 20, SQLITE_TRANSIENT);
6215 }else{
@@ -6267,10 +6294,11 @@
6267 sqlite3_free(zMsg);
6268 return;
6269 }
6270 nCol = sqlite3_column_count(pStmt);
6271 z = sqlite3_sql(pStmt);
 
6272 n = (int)strlen(z);
6273 hash_step_vformat(&cx,"S%d:",n);
6274 hash_step(&cx,(unsigned char*)z,n);
6275
6276 /* Compute a hash over the result of the query */
@@ -6489,10 +6517,14 @@
6489 #endif
6490
6491 #ifndef IsSpace
6492 #define IsSpace(X) isspace((unsigned char)X)
6493 #endif
 
 
 
 
6494
6495 /* A decimal object */
6496 typedef struct Decimal Decimal;
6497 struct Decimal {
6498 char sign; /* 0 for positive, 1 for negative */
@@ -6528,10 +6560,11 @@
6528 static Decimal *decimalNewFromText(const char *zIn, int n){
6529 Decimal *p = 0;
6530 int i;
6531 int iExp = 0;
6532
 
6533 p = sqlite3_malloc( sizeof(*p) );
6534 if( p==0 ) goto new_from_text_failed;
6535 p->sign = 0;
6536 p->oom = 0;
6537 p->isInit = 1;
@@ -6587,13 +6620,14 @@
6587 iExp -= p->nFrac;
6588 p->nFrac = 0;
6589 }
6590 }
6591 if( iExp>0 ){
6592 p->a = sqlite3_realloc64(p->a, (sqlite3_int64)p->nDigit
6593 + (sqlite3_int64)iExp + 1 );
6594 if( p->a==0 ) goto new_from_text_failed;
 
6595 memset(p->a+p->nDigit, 0, iExp);
6596 p->nDigit += iExp;
6597 }
6598 }else if( iExp<0 ){
6599 int nExtra;
@@ -6607,13 +6641,14 @@
6607 iExp -= nExtra;
6608 p->nFrac = p->nDigit - 1;
6609 }
6610 }
6611 if( iExp>0 ){
6612 p->a = sqlite3_realloc64(p->a, (sqlite3_int64)p->nDigit
6613 + (sqlite3_int64)iExp + 1 );
6614 if( p->a==0 ) goto new_from_text_failed;
 
6615 memmove(p->a+iExp, p->a, p->nDigit);
6616 memset(p->a, 0, iExp);
6617 p->nDigit += iExp;
6618 p->nFrac += iExp;
6619 }
@@ -6620,10 +6655,11 @@
6620 }
6621 if( p->sign ){
6622 for(i=0; i<p->nDigit && p->a[i]==0; i++){}
6623 if( i>=p->nDigit ) p->sign = 0;
6624 }
 
6625 return p;
6626
6627 new_from_text_failed:
6628 if( p ){
6629 if( p->a ) sqlite3_free(p->a);
@@ -6757,10 +6793,12 @@
6757 */
6758 static void decimal_round(Decimal *p, int N){
6759 int i;
6760 int nZero;
6761 if( N<1 ) return;
 
 
6762 for(nZero=0; nZero<p->nDigit && p->a[nZero]==0; nZero++){}
6763 N += nZero;
6764 if( p->nDigit<=N ) return;
6765 if( p->a[N]>4 ){
6766 p->a[N-1]++;
@@ -6914,19 +6952,22 @@
6914 ** digits to the right of the decimal point.
6915 */
6916 static void decimal_expand(Decimal *p, int nDigit, int nFrac){
6917 int nAddSig;
6918 int nAddFrac;
 
6919 if( p==0 ) return;
6920 nAddFrac = nFrac - p->nFrac;
6921 nAddSig = (nDigit - p->nDigit) - nAddFrac;
6922 if( nAddFrac==0 && nAddSig==0 ) return;
6923 p->a = sqlite3_realloc64(p->a, nDigit+1);
6924 if( p->a==0 ){
 
6925 p->oom = 1;
6926 return;
6927 }
 
6928 if( nAddSig ){
6929 memmove(p->a+nAddSig, p->a, p->nDigit);
6930 memset(p->a, 0, nAddSig);
6931 p->nDigit += nAddSig;
6932 }
@@ -7017,18 +7058,22 @@
7017 */
7018 static void decimalMul(Decimal *pA, Decimal *pB){
7019 signed char *acc = 0;
7020 int i, j, k;
7021 int minFrac;
 
7022
7023 if( pA==0 || pA->oom || pA->isNull
7024 || pB==0 || pB->oom || pB->isNull
7025 ){
7026 goto mul_end;
7027 }
7028 acc = sqlite3_malloc64( (sqlite3_int64)pA->nDigit +
7029 (sqlite3_int64)pB->nDigit + 2 );
 
 
 
7030 if( acc==0 ){
7031 pA->oom = 1;
7032 goto mul_end;
7033 }
7034 memset(acc, 0, pA->nDigit + pB->nDigit + 2);
@@ -7394,12 +7439,10 @@
7394 }
7395 return rc;
7396 }
7397
7398 /************************* End ext/misc/decimal.c ********************/
7399 #undef sqlite3_base_init
7400 #define sqlite3_base_init sqlite3_base64_init
7401 /************************* Begin ext/misc/base64.c ******************/
7402 /*
7403 ** 2022-11-18
7404 **
7405 ** The author disclaims copyright to this source code. In place of
@@ -7674,11 +7717,11 @@
7674 */
7675 #ifndef SQLITE_SHELL_EXTFUNCS
7676 #ifdef _WIN32
7677
7678 #endif
7679 int sqlite3_base_init
7680 #else
7681 static int sqlite3_base64_init
7682 #endif
7683 (sqlite3 *db, char **pzErr, const sqlite3_api_routines *pApi){
7684 SQLITE_EXTENSION_INIT2(pApi);
@@ -7696,13 +7739,10 @@
7696 */
7697 #define BASE64_INIT(db) sqlite3_base64_init(db, 0, 0)
7698 #define BASE64_EXPOSE(db, pzErr) /* Not needed, ..._init() does this. */
7699
7700 /************************* End ext/misc/base64.c ********************/
7701 #undef sqlite3_base_init
7702 #define sqlite3_base_init sqlite3_base85_init
7703 #define OMIT_BASE85_CHECKER
7704 /************************* Begin ext/misc/base85.c ******************/
7705 /*
7706 ** 2022-11-16
7707 **
7708 ** The author disclaims copyright to this source code. In place of
@@ -7964,11 +8004,11 @@
7964 }
7965 #endif
7966
7967 #ifndef BASE85_STANDALONE
7968
7969 # ifndef OMIT_BASE85_CHECKER
7970 /* This function does the work for the SQLite is_base85(t) UDF. */
7971 static void is_base85(sqlite3_context *context, int na, sqlite3_value *av[]){
7972 assert(na==1);
7973 switch( sqlite3_value_type(av[0]) ){
7974 case SQLITE_TEXT:
@@ -7984,11 +8024,11 @@
7984 default:
7985 sqlite3_result_error(context, "is_base85 accepts only text or NULL", -1);
7986 return;
7987 }
7988 }
7989 # endif
7990
7991 /* This function does the work for the SQLite base85(x) UDF. */
7992 static void base85(sqlite3_context *context, int na, sqlite3_value *av[]){
7993 sqlite3_int64 nb, nc, nv = sqlite3_value_bytes(av[0]);
7994 int nvMax = sqlite3_limit(sqlite3_context_db_handle(context),
@@ -8054,26 +8094,26 @@
8054 */
8055 #ifndef SQLITE_SHELL_EXTFUNCS
8056 #ifdef _WIN32
8057
8058 #endif
8059 int sqlite3_base_init
8060 #else
8061 static int sqlite3_base85_init
8062 #endif
8063 (sqlite3 *db, char **pzErr, const sqlite3_api_routines *pApi){
8064 SQLITE_EXTENSION_INIT2(pApi);
8065 (void)pzErr;
8066 # ifndef OMIT_BASE85_CHECKER
8067 {
8068 int rc = sqlite3_create_function
8069 (db, "is_base85", 1,
8070 SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS|SQLITE_UTF8,
8071 0, is_base85, 0, 0);
8072 if( rc!=SQLITE_OK ) return rc;
8073 }
8074 # endif
8075 return sqlite3_create_function
8076 (db, "base85", 1,
8077 SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS|SQLITE_DIRECTONLY|SQLITE_UTF8,
8078 0, base85, 0, 0);
8079 }
@@ -8134,13 +8174,13 @@
8134 case 'w':
8135 while( 0 != fgets(cBuf, sizeof(cBuf), stdin) ){
8136 int nc = strlen(cBuf);
8137 size_t nbo = fromBase85( cBuf, nc, bBuf ) - bBuf;
8138 if( 1 != fwrite(bBuf, nbo, 1, fb) ) rc = 1;
8139 # ifndef OMIT_BASE85_CHECKER
8140 b85Clean &= allBase85( cBuf, nc );
8141 # endif
8142 }
8143 break;
8144 default:
8145 sayHelp();
8146 rc = 1;
@@ -10291,11 +10331,10 @@
10291 ReCompiled *pRe;
10292 sqlite3_str *pStr;
10293 int i;
10294 int n;
10295 char *z;
10296 (void)argc;
10297 static const char *ReOpName[] = {
10298 "EOF",
10299 "MATCH",
10300 "ANY",
10301 "ANYSTAR",
@@ -10314,10 +10353,11 @@
10314 "NOTSPACE",
10315 "BOUNDARY",
10316 "ATSTART",
10317 };
10318
 
10319 zPattern = (const char*)sqlite3_value_text(argv[0]);
10320 if( zPattern==0 ) return;
10321 zErr = re_compile(&pRe, zPattern, re_maxnfa(re_maxlen(context)),
10322 sqlite3_user_data(context)!=0);
10323 if( zErr ){
@@ -10468,15 +10508,10 @@
10468 **
10469 ** If a non-NULL value is specified for the optional $dir parameter and
10470 ** $path is a relative path, then $path is interpreted relative to $dir.
10471 ** And the paths returned in the "name" column of the table are also
10472 ** relative to directory $dir.
10473 **
10474 ** Notes on building this extension for Windows:
10475 ** Unless linked statically with the SQLite library, a preprocessor
10476 ** symbol, FILEIO_WIN32_DLL, must be #define'd to create a stand-alone
10477 ** DLL form of this extension for WIN32. See its use below for details.
10478 */
10479 /* #include "sqlite3ext.h" */
10480 SQLITE_EXTENSION_INIT1
10481 #include <stdio.h>
10482 #include <string.h>
@@ -11836,10 +11871,11 @@
11836 */
11837 static int completionNext(sqlite3_vtab_cursor *cur){
11838 completion_cursor *pCur = (completion_cursor*)cur;
11839 int eNextPhase = 0; /* Next phase to try if current phase reaches end */
11840 int iCol = -1; /* If >=0, step pCur->pStmt and use the i-th column */
 
11841 pCur->iRowid++;
11842 while( pCur->ePhase!=COMPLETION_EOF ){
11843 switch( pCur->ePhase ){
11844 case COMPLETION_KEYWORDS: {
11845 if( pCur->j >= sqlite3_keyword_count() ){
@@ -11861,52 +11897,62 @@
11861 break;
11862 }
11863 case COMPLETION_TABLES: {
11864 if( pCur->pStmt==0 ){
11865 sqlite3_stmt *pS2;
 
11866 char *zSql = 0;
11867 const char *zSep = "";
11868 sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pS2, 0);
11869 while( sqlite3_step(pS2)==SQLITE_ROW ){
11870 const char *zDb = (const char*)sqlite3_column_text(pS2, 1);
11871 zSql = sqlite3_mprintf(
11872 "%z%s"
11873 "SELECT name FROM \"%w\".sqlite_schema",
11874 zSql, zSep, zDb
11875 );
11876 if( zSql==0 ) return SQLITE_NOMEM;
11877 zSep = " UNION ";
11878 }
11879 sqlite3_finalize(pS2);
11880 sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
 
 
 
 
11881 sqlite3_free(zSql);
 
11882 }
11883 iCol = 0;
11884 eNextPhase = COMPLETION_COLUMNS;
11885 break;
11886 }
11887 case COMPLETION_COLUMNS: {
11888 if( pCur->pStmt==0 ){
11889 sqlite3_stmt *pS2;
 
11890 char *zSql = 0;
11891 const char *zSep = "";
11892 sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pS2, 0);
11893 while( sqlite3_step(pS2)==SQLITE_ROW ){
11894 const char *zDb = (const char*)sqlite3_column_text(pS2, 1);
11895 zSql = sqlite3_mprintf(
11896 "%z%s"
11897 "SELECT pti.name FROM \"%w\".sqlite_schema AS sm"
11898 " JOIN pragma_table_xinfo(sm.name,%Q) AS pti"
11899 " WHERE sm.type='table'",
11900 zSql, zSep, zDb, zDb
11901 );
11902 if( zSql==0 ) return SQLITE_NOMEM;
11903 zSep = " UNION ";
11904 }
11905 sqlite3_finalize(pS2);
11906 sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
 
 
 
 
11907 sqlite3_free(zSql);
 
11908 }
11909 iCol = 0;
11910 eNextPhase = COMPLETION_EOF;
11911 break;
11912 }
@@ -11919,13 +11965,14 @@
11919 /* Extract the next row of content */
11920 pCur->zCurrentRow = (const char*)sqlite3_column_text(pCur->pStmt, iCol);
11921 pCur->szRow = sqlite3_column_bytes(pCur->pStmt, iCol);
11922 }else{
11923 /* When all rows are finished, advance to the next phase */
11924 sqlite3_finalize(pCur->pStmt);
11925 pCur->pStmt = 0;
11926 pCur->ePhase = eNextPhase;
 
11927 continue;
11928 }
11929 }
11930 if( pCur->nPrefix==0 ) break;
11931 if( pCur->nPrefix<=pCur->szRow
@@ -15207,11 +15254,11 @@
15207 ){
15208 uLong nData;
15209 sqlite3_int64 sz;
15210
15211 assert( argc==2 );
15212 sz = sqlite3_value_int(argv[1]);
15213
15214 if( sz<=0 || sz==(nData = sqlite3_value_bytes(argv[0])) ){
15215 sqlite3_result_value(context, argv[0]);
15216 }else{
15217 uLongf szf = sz;
@@ -24602,10 +24649,13 @@
24602 # define DFLT_LINE_LIMIT 5
24603 #endif
24604 #ifndef DFLT_TITLE_LIMIT
24605 # define DFLT_TITLE_LIMIT 20
24606 #endif
 
 
 
24607
24608 /*
24609 ** Limit input nesting via .read or any other input redirect.
24610 ** It's not too expensive, so a generous allowance can be made.
24611 */
@@ -24798,11 +24848,11 @@
24798 free(p->spec.zColumnSep);
24799 free(p->spec.zRowSep);
24800 free(p->spec.zTableName);
24801 free(p->spec.zNull);
24802 memset(p, 0, sizeof(*p));
24803 p->spec.iVersion = 1;
24804 p->autoExplain = autoExplain;
24805 }
24806
24807 /*
24808 ** Duplicate Mode pSrc into pDest. pDest is assumed to be
@@ -24904,20 +24954,21 @@
24904 p->mode.spec.eText = QRF_TEXT_Relaxed;
24905 p->mode.spec.nCharLimit = DFLT_CHAR_LIMIT;
24906 p->mode.spec.nLineLimit = DFLT_LINE_LIMIT;
24907 p->mode.spec.bTextJsonb = QRF_Yes;
24908 p->mode.spec.nTitleLimit = DFLT_TITLE_LIMIT;
 
24909 p->mode.mFlags = mFlags;
24910 }
24911 }
24912
24913 /*
24914 ** Set the mode to the default. It assumed that the mode has
24915 ** already been freed and zeroed prior to calling this routine.
24916 */
24917 static void modeDefault(ShellState *p){
24918 p->mode.spec.iVersion = 1;
24919 p->mode.autoExplain = 1;
24920 if( stdin_is_interactive || stdout_is_console ){
24921 modeChange(p, MODE_TTY);
24922 }else{
24923 modeChange(p, MODE_BATCH);
@@ -26860,10 +26911,11 @@
26860 p->mode.spec.zTableName = (char*)zTable;
26861 p->mode.eMode = MODE_Insert;
26862 p->mode.spec.eText = QRF_TEXT_Sql;
26863 p->mode.spec.eBlob = QRF_BLOB_Sql;
26864 p->mode.spec.bTitles = QRF_No;
 
26865 rc = shell_exec(p, sSelect.zTxt, 0);
26866 if( (rc&0xff)==SQLITE_CORRUPT ){
26867 cli_puts("/****** CORRUPTION ERROR *******/\n", p->out);
26868 toggleSelectOrder(p->db);
26869 shell_exec(p, sSelect.zTxt, 0);
@@ -27012,13 +27064,14 @@
27012 ".import FILE TABLE Import data from FILE into TABLE",
27013 #endif
27014 #ifndef SQLITE_OMIT_TEST_CONTROL
27015 ".imposter INDEX TABLE Create imposter table TABLE on index INDEX",
27016 #endif
27017 ".indexes ?TABLE? Show names of indexes",
27018 " If TABLE is specified, only show indexes for",
27019 " tables matching TABLE using the LIKE operator.",
 
27020 ".intck ?STEPS_PER_UNLOCK? Run an incremental integrity check on the db",
27021 #ifdef SQLITE_ENABLE_IOTRACE
27022 ",iotrace FILE Enable I/O diagnostic logging to FILE",
27023 #endif
27024 ".limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT",
@@ -27252,10 +27305,12 @@
27252 " --titlelimit T\". The \",T\" can be omitted in which\n"
27253 " case the --titlelimit is unchanged. The argument\n"
27254 " can also be \"off\" to mean \"0,0,0\" or \"on\" to\n"
27255 " mean \"5,300,20\".\n"
27256 " --list List available modes\n"
 
 
27257 " --null STRING Render SQL NULL values as the given string\n"
27258 " --once Setting changes to the right are reverted after\n"
27259 " the next SQL command.\n"
27260 " --quote ARG Enable/disable quoting of text. ARG can be\n"
27261 " \"off\", \"on\", \"sql\", \"relaxed\", \"csv\", \"html\",\n"
@@ -30750,11 +30805,11 @@
30750 static int outputDumpWarning(ShellState *p, const char *zLike){
30751 int rc = SQLITE_OK;
30752 sqlite3_stmt *pStmt = 0;
30753 shellPreparePrintf(p->db, &rc, &pStmt,
30754 "SELECT 1 FROM sqlite_schema o WHERE "
30755 "sql LIKE 'CREATE VIRTUAL TABLE%%' AND %s", zLike ? zLike : "true"
30756 );
30757 if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
30758 cli_puts("/* WARNING: "
30759 "Script requires that SQLITE_DBCONFIG_DEFENSIVE be disabled */\n",
30760 p->out
@@ -31330,10 +31385,12 @@
31330 ** --titlelimit T". The ",T" can be omitted in which
31331 ** case the --titlelimit is unchanged. The argument
31332 ** can also be "off" to mean "0,0,0" or "on" to
31333 ** mean "5,300,20".
31334 ** --list List available modes
 
 
31335 ** --null STRING Render SQL NULL values as the given string
31336 ** --once Setting changes to the right are reverted after
31337 ** the next SQL command.
31338 ** --quote ARG Enable/disable quoting of text. ARG can be
31339 ** "off", "on", "sql", "relaxed", "csv", "html",
@@ -31445,21 +31502,23 @@
31445 k = pickStr(azArg[i], 0, "auto", "off", "on", "");
31446 if( k>=0 ){
31447 p->mode.spec.bBorder = k & 0x3;
31448 }
31449 chng = 1;
31450 }else if( 0<=(k=pickStr(z,0,"-charlimit","-linelimit","-titlelimit","")) ){
31451 int w; /* 0 1 */
 
31452 if( i+1>=nArg ){
31453 dotCmdError(p, i, "missing argument", 0);
31454 return 1;
31455 }
31456 w = integerValue(azArg[++i]);
31457 switch( k ){
31458 case 0: p->mode.spec.nCharLimit = w; break;
31459 case 1: p->mode.spec.nLineLimit = w; break;
31460 default: p->mode.spec.nTitleLimit = w; break;
 
31461 }
31462 chng = 1;
31463 }else if( 0<=(k=pickStr(z,0,"-tablename","-rowsep","-colsep","-null","")) ){
31464 /* 0 1 2 3 */
31465 if( i+1>=nArg ){
@@ -31798,10 +31857,16 @@
31798 sqlite3_str_appendf(pDesc, " --limits %d,%d,%d",
31799 p->mode.spec.nLineLimit, p->mode.spec.nCharLimit,
31800 p->mode.spec.nTitleLimit);
31801 }
31802 }
 
 
 
 
 
 
31803 zSetting = aModeStr[pI->eNull];
31804 if( bAll || (zSetting && cli_strcmp(zSetting,p->mode.spec.zNull)!=0) ){
31805 sqlite3_str_appendf(pDesc, " --null ");
31806 append_c_string(pDesc, p->mode.spec.zNull);
31807 }
@@ -33263,10 +33328,96 @@
33263 rc = 1;
33264 }
33265 sqlite3_free(zSql);
33266 }else
33267 #endif /* !defined(SQLITE_OMIT_TEST_CONTROL) */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33268
33269 if( c=='i' && cli_strncmp(azArg[0], "intck", n)==0 ){
33270 i64 iArg = 0;
33271 if( nArg==2 ){
33272 iArg = integerValue(azArg[1]);
@@ -34641,14 +34792,11 @@
34641 eputz("Usage: .stats ?on|off|stmt|vmstep?\n");
34642 rc = 1;
34643 }
34644 }else
34645
34646 if( (c=='t' && n>1 && cli_strncmp(azArg[0], "tables", n)==0)
34647 || (c=='i' && (cli_strncmp(azArg[0], "indices", n)==0
34648 || cli_strncmp(azArg[0], "indexes", n)==0) )
34649 ){
34650 sqlite3_stmt *pStmt;
34651 sqlite3_str *pSql;
34652 const char *zPattern = nArg>1 ? azArg[1] : 0;
34653
34654 open_db(p, 0);
@@ -34656,19 +34804,10 @@
34656 if( rc ){
34657 sqlite3_finalize(pStmt);
34658 return shellDatabaseError(p->db);
34659 }
34660
34661 if( nArg>2 && c=='i' ){
34662 /* It is an historical accident that the .indexes command shows an error
34663 ** when called with the wrong number of arguments whereas the .tables
34664 ** command does not. */
34665 eputz("Usage: .indexes ?LIKE-PATTERN?\n");
34666 rc = 1;
34667 sqlite3_finalize(pStmt);
34668 goto meta_command_exit;
34669 }
34670 pSql = sqlite3_str_new(p->db);
34671 while( sqlite3_step(pStmt)==SQLITE_ROW ){
34672 const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1);
34673 if( zDbName==0 ) continue;
34674 if( sqlite3_str_length(pSql) ){
@@ -34678,23 +34817,16 @@
34678 sqlite3_str_appendall(pSql, "SELECT name FROM ");
34679 }else{
34680 sqlite3_str_appendf(pSql, "SELECT %Q||'.'||name FROM ", zDbName);
34681 }
34682 sqlite3_str_appendf(pSql, "\"%w\".sqlite_schema", zDbName);
34683 if( c=='t' ){
34684 sqlite3_str_appendf(pSql,
34685 " WHERE type IN ('table','view')"
34686 " AND name NOT LIKE 'sqlite__%%' ESCAPE '_'"
34687 );
34688 if( zPattern ){
34689 sqlite3_str_appendf(pSql," AND name LIKE %Q", zPattern);
34690 }
34691 }else{
34692 sqlite3_str_appendf(pSql, " WHERE type='index'");
34693 if( zPattern ){
34694 sqlite3_str_appendf(pSql," AND tbl_name LIKE %Q", zPattern);
34695 }
34696 }
34697 }
34698 rc = sqlite3_finalize(pStmt);
34699 if( rc==SQLITE_OK ){
34700 sqlite3_str_appendall(pSql, " ORDER BY 1");
@@ -35622,11 +35754,16 @@
35622 }
35623
35624 /*
35625 ** Run a single line of SQL. Return the number of errors.
35626 */
35627 static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
 
 
 
 
 
35628 int rc;
35629 char *zErrMsg = 0;
35630
35631 open_db(p, 0);
35632 if( ShellHasFlag(p,SHFLG_Backslash) ) resolve_backslashes(zSql);
@@ -35649,13 +35786,21 @@
35649 zErrorTail = &zErrMsg[10];
35650 }else{
35651 zErrorType = "Error";
35652 zErrorTail = zErrMsg;
35653 }
35654 if( in!=0 || !stdin_is_interactive ){
35655 sqlite3_snprintf(sizeof(zPrefix), zPrefix,
35656 "%s near line %d:", zErrorType, startline);
 
 
 
 
 
 
 
 
35657 }else{
35658 sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%s:", zErrorType);
35659 }
35660 cli_printf(stderr,"%s %s\n", zPrefix, zErrorTail);
35661 sqlite3_free(zErrMsg);
@@ -35814,11 +35959,11 @@
35814 nSql = 0;
35815 errCnt++;
35816 break;
35817 }else if( nSql && QSS_SEMITERM(qss) && sqlite3_complete(zSql) ){
35818 echo_group_input(p, zSql);
35819 errCnt += runOneSqlLine(p, zSql, p->in, startline);
35820 CONTINUE_PROMPT_RESET;
35821 nSql = 0;
35822 if( p->nPopOutput ){
35823 output_reset(p);
35824 p->nPopOutput = 0;
@@ -35838,11 +35983,11 @@
35838 }
35839 }
35840 if( nSql ){
35841 /* This may be incomplete. Let the SQL parser deal with that. */
35842 echo_group_input(p, zSql);
35843 errCnt += runOneSqlLine(p, zSql, p->in, startline);
35844 CONTINUE_PROMPT_RESET;
35845 }
35846 free(zSql);
35847 free(zLine);
35848 --p->inputNesting;
@@ -36186,11 +36331,11 @@
36186
36187 /* Use the wmain() entry point on Windows. Translate arguments to
36188 ** UTF8, then invoke the traditional main() entry point which is
36189 ** renamed using a #define to utf8_main() .
36190 */
36191 #if defined(_WIN32) && !defined(main)
36192 # define main utf8_main /* Rename entry point to utf_main() */
36193 int SQLITE_CDECL utf8_main(int,char**); /* Forward declaration */
36194 int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
36195 int rc, i;
36196 char **argv = malloc( sizeof(char*) * (argc+1) );
@@ -36235,11 +36380,10 @@
36235 */
36236 int SQLITE_CDECL main(int argc, char **argv){
36237 #ifdef SQLITE_DEBUG
36238 sqlite3_int64 mem_main_enter = 0;
36239 #endif
36240 char *zErrMsg = 0;
36241 #ifdef SQLITE_SHELL_FIDDLE
36242 # define data shellState
36243 #else
36244 ShellState data;
36245 #endif
@@ -36774,19 +36918,11 @@
36774 if( rc && (bail_on_error || rc==2) ){
36775 if( rc==2 ) rc = 0;
36776 goto shell_main_exit;
36777 }
36778 }else{
36779 open_db(&data, 0);
36780 rc = shell_exec(&data, z, &zErrMsg);
36781 if( zErrMsg!=0 ){
36782 shellEmitError(zErrMsg);
36783 sqlite3_free(zErrMsg);
36784 if( !rc ) rc = 1;
36785 }else if( rc!=0 ){
36786 cli_printf(stderr,"Error: unable to process SQL \"%s\"\n", z);
36787 }
36788 if( bail_on_error ) goto shell_main_exit;
36789 }
36790 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
36791 }else if( cli_strncmp(z, "-A", 2)==0 ){
36792 if( nCmd>0 ){
@@ -36848,29 +36984,17 @@
36848 if( rc ){
36849 if( rc==2 ) rc = 0;
36850 goto shell_main_exit;
36851 }
36852 }else{
36853 open_db(&data, 0);
36854 rc = shell_exec(&data, azCmd[i], &zErrMsg);
36855 if( zErrMsg || rc ){
36856 if( zErrMsg!=0 ){
36857 shellEmitError(zErrMsg);
36858 }else{
36859 cli_printf(stderr,
36860 "Error: unable to process SQL: %s\n", azCmd[i]);
36861 }
36862 sqlite3_free(zErrMsg);
36863 if( rc==0 ) rc = 1;
36864 goto shell_main_exit;
36865 }
36866 if( data.nPopMode ){
36867 modePop(&data);
36868 data.nPopMode = 0;
36869 }
36870 }
36871 if( data.nPopOutput ){
36872 output_reset(&data);
36873 data.nPopOutput = 0;
36874 }else{
36875 clearTempFile(&data);
36876 }
36877
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -712,10 +712,12 @@
712 char *(*xRender)(void*,sqlite3_value*); /* Render a value */
713 int (*xWrite)(void*,const char*,sqlite3_int64); /* Write output */
714 void *pRenderArg; /* First argument to the xRender callback */
715 void *pWriteArg; /* First argument to the xWrite callback */
716 char **pzOutput; /* Storage location for output string */
717 /* Fields below are only available if iVersion>=2 */
718 unsigned int nMultiInsert; /* Add rows to one INSERT until size exceeds */
719 /* Additional fields may be added in the future */
720 };
721
722 /*
723 ** Interfaces
@@ -925,10 +927,11 @@
927 struct { /* Content for QRF_STYLE_Explain */
928 int nIndent; /* Slots allocated for aiIndent */
929 int iIndent; /* Current slot */
930 int *aiIndent; /* Indentation for each opcode */
931 } sExpln;
932 unsigned int nIns; /* Bytes used for current INSERT stmt */
933 } u;
934 sqlite3_int64 nRow; /* Number of rows handled so far */
935 int *actualWidth; /* Actual width of each column */
936 sqlite3_qrf_spec spec; /* Copy of the original spec */
937 };
@@ -3422,34 +3425,50 @@
3425 sqlite3_str_append(p->pOut, "\n</TR>\n", 7);
3426 qrfWrite(p);
3427 break;
3428 }
3429 case QRF_STYLE_Insert: {
3430 unsigned int mxIns = p->spec.iVersion>=2 ? p->spec.nMultiInsert : 0;
3431 int szStart = sqlite3_str_length(p->pOut);
3432 if( p->u.nIns==0 || p->u.nIns>=mxIns ){
3433 if( p->u.nIns ){
3434 sqlite3_str_append(p->pOut, ";\n", 2);
3435 p->u.nIns = 0;
3436 }
3437 if( qrf_need_quote(p->spec.zTableName) ){
3438 sqlite3_str_appendf(p->pOut,"INSERT INTO \"%w\"",p->spec.zTableName);
3439 }else{
3440 sqlite3_str_appendf(p->pOut,"INSERT INTO %s",p->spec.zTableName);
3441 }
3442 if( p->spec.bTitles==QRF_Yes ){
3443 for(i=0; i<p->nCol; i++){
3444 const char *zCName = sqlite3_column_name(p->pStmt, i);
3445 if( qrf_need_quote(zCName) ){
3446 sqlite3_str_appendf(p->pOut, "%c\"%w\"",
3447 i==0 ? '(' : ',', zCName);
3448 }else{
3449 sqlite3_str_appendf(p->pOut, "%c%s",
3450 i==0 ? '(' : ',', zCName);
3451 }
3452 }
3453 sqlite3_str_append(p->pOut, ")", 1);
3454 }
3455 sqlite3_str_append(p->pOut," VALUES(", 8);
3456 }else{
3457 sqlite3_str_append(p->pOut,",\n (", 5);
3458 }
3459 for(i=0; i<p->nCol; i++){
3460 if( i>0 ) sqlite3_str_append(p->pOut, ",", 1);
3461 qrfRenderValue(p, p->pOut, i);
3462 }
3463 p->u.nIns += sqlite3_str_length(p->pOut) + 2 - szStart;
3464 if( p->u.nIns>=mxIns ){
3465 sqlite3_str_append(p->pOut, ");\n", 3);
3466 p->u.nIns = 0;
3467 }else{
3468 sqlite3_str_append(p->pOut, ")", 1);
3469 }
3470 qrfWrite(p);
3471 break;
3472 }
3473 case QRF_STYLE_Line: {
3474 sqlite3_str *pVal;
@@ -3489,11 +3508,13 @@
3508 zVal = sqlite3_str_value(pVal);
3509 if( zVal==0 ) zVal = "";
3510 do{
3511 int nThis, nWide, iNext;
3512 qrfWrapLine(zVal, mxW, bWW, &nThis, &nWide, &iNext);
3513 if( cnt ){
3514 sqlite3_str_appendchar(p->pOut,p->u.sLine.mxColWth+nSep,' ');
3515 }
3516 cnt++;
3517 if( cnt>p->mxHeight ){
3518 zVal = "...";
3519 nThis = iNext = 3;
3520 }
@@ -3552,11 +3573,11 @@
3573 char **pzErr /* Write errors here */
3574 ){
3575 size_t sz; /* Size of pSpec[], based on pSpec->iVersion */
3576 memset(p, 0, sizeof(*p));
3577 p->pzErr = pzErr;
3578 if( pSpec->iVersion>2 ){
3579 qrfError(p, SQLITE_ERROR,
3580 "unusable sqlite3_qrf_spec.iVersion (%d)",
3581 pSpec->iVersion);
3582 return;
3583 }
@@ -3612,10 +3633,11 @@
3633 p->spec.eText = QRF_TEXT_Sql;
3634 p->spec.zNull = "NULL";
3635 if( p->spec.zTableName==0 || p->spec.zTableName[0]==0 ){
3636 p->spec.zTableName = "tab";
3637 }
3638 p->u.nIns = 0;
3639 break;
3640 }
3641 case QRF_STYLE_Line: {
3642 if( p->spec.zColumnSep==0 ){
3643 p->spec.zColumnSep = ": ";
@@ -3710,24 +3732,27 @@
3732 */
3733 static void qrfFinalize(Qrf *p){
3734 switch( p->spec.eStyle ){
3735 case QRF_STYLE_Count: {
3736 sqlite3_str_appendf(p->pOut, "%lld\n", p->nRow);
 
3737 break;
3738 }
3739 case QRF_STYLE_Json: {
3740 if( p->nRow>0 ){
3741 sqlite3_str_append(p->pOut, "}]\n", 3);
 
3742 }
3743 break;
3744 }
3745 case QRF_STYLE_JObject: {
3746 if( p->nRow>0 ){
3747 sqlite3_str_append(p->pOut, "}\n", 2);
3748 }
3749 break;
3750 }
3751 case QRF_STYLE_Insert: {
3752 if( p->u.nIns ){
3753 sqlite3_str_append(p->pOut, ";\n", 2);
3754 }
3755 break;
3756 }
3757 case QRF_STYLE_Line: {
3758 if( p->u.sLine.azCol ){
@@ -3743,19 +3768,18 @@
3768 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
3769 sqlite3_stmt_scanstatus_v2(p->pStmt, -1, SQLITE_SCANSTAT_NCYCLE,
3770 SQLITE_SCANSTAT_COMPLEX, (void*)&nCycle);
3771 #endif
3772 qrfEqpRender(p, nCycle);
 
3773 break;
3774 }
3775 case QRF_STYLE_Eqp: {
3776 qrfEqpRender(p, 0);
 
3777 break;
3778 }
3779 }
3780 qrfWrite(p);
3781 qrfStrErr(p, p->pOut);
3782 if( p->spec.pzOutput ){
3783 if( p->spec.pzOutput[0] ){
3784 sqlite3_int64 n, sz;
3785 char *zCombined;
@@ -6196,20 +6220,23 @@
6220 sqlite3_value **argv
6221 ){
6222 SHA1Context cx;
6223 int eType = sqlite3_value_type(argv[0]);
6224 int nByte = sqlite3_value_bytes(argv[0]);
6225 const unsigned char *pData;
6226 char zOut[44];
6227
6228 assert( argc==1 );
6229 if( eType==SQLITE_NULL ) return;
6230 hash_init(&cx);
6231 if( eType==SQLITE_BLOB ){
6232 pData = (const unsigned char*)sqlite3_value_blob(argv[0]);
6233 }else{
6234 pData = (const unsigned char*)sqlite3_value_text(argv[0]);
6235 }
6236 if( pData==0 ) return;
6237 hash_step(&cx, pData, nByte);
6238 if( sqlite3_user_data(context)!=0 ){
6239 /* sha1b() - binary result */
6240 hash_finish(&cx, zOut, 1);
6241 sqlite3_result_blob(context, zOut, 20, SQLITE_TRANSIENT);
6242 }else{
@@ -6267,10 +6294,11 @@
6294 sqlite3_free(zMsg);
6295 return;
6296 }
6297 nCol = sqlite3_column_count(pStmt);
6298 z = sqlite3_sql(pStmt);
6299 if( z==0 ) z = "";
6300 n = (int)strlen(z);
6301 hash_step_vformat(&cx,"S%d:",n);
6302 hash_step(&cx,(unsigned char*)z,n);
6303
6304 /* Compute a hash over the result of the query */
@@ -6489,10 +6517,14 @@
6517 #endif
6518
6519 #ifndef IsSpace
6520 #define IsSpace(X) isspace((unsigned char)X)
6521 #endif
6522
6523 #ifndef SQLITE_DECIMAL_MAX_DIGIT
6524 # define SQLITE_DECIMAL_MAX_DIGIT 10000000
6525 #endif
6526
6527 /* A decimal object */
6528 typedef struct Decimal Decimal;
6529 struct Decimal {
6530 char sign; /* 0 for positive, 1 for negative */
@@ -6528,10 +6560,11 @@
6560 static Decimal *decimalNewFromText(const char *zIn, int n){
6561 Decimal *p = 0;
6562 int i;
6563 int iExp = 0;
6564
6565 if( zIn==0 ) goto new_from_text_failed;
6566 p = sqlite3_malloc( sizeof(*p) );
6567 if( p==0 ) goto new_from_text_failed;
6568 p->sign = 0;
6569 p->oom = 0;
6570 p->isInit = 1;
@@ -6587,13 +6620,14 @@
6620 iExp -= p->nFrac;
6621 p->nFrac = 0;
6622 }
6623 }
6624 if( iExp>0 ){
6625 signed char *a = sqlite3_realloc64(p->a, (sqlite3_int64)p->nDigit
6626 + (sqlite3_int64)iExp + 1 );
6627 if( a==0 ) goto new_from_text_failed;
6628 p->a = a;
6629 memset(p->a+p->nDigit, 0, iExp);
6630 p->nDigit += iExp;
6631 }
6632 }else if( iExp<0 ){
6633 int nExtra;
@@ -6607,13 +6641,14 @@
6641 iExp -= nExtra;
6642 p->nFrac = p->nDigit - 1;
6643 }
6644 }
6645 if( iExp>0 ){
6646 signed char *a = sqlite3_realloc64(p->a, (sqlite3_int64)p->nDigit
6647 + (sqlite3_int64)iExp + 1 );
6648 if( a==0 ) goto new_from_text_failed;
6649 p->a = a;
6650 memmove(p->a+iExp, p->a, p->nDigit);
6651 memset(p->a, 0, iExp);
6652 p->nDigit += iExp;
6653 p->nFrac += iExp;
6654 }
@@ -6620,10 +6655,11 @@
6655 }
6656 if( p->sign ){
6657 for(i=0; i<p->nDigit && p->a[i]==0; i++){}
6658 if( i>=p->nDigit ) p->sign = 0;
6659 }
6660 if( p->nDigit>SQLITE_DECIMAL_MAX_DIGIT ) goto new_from_text_failed;
6661 return p;
6662
6663 new_from_text_failed:
6664 if( p ){
6665 if( p->a ) sqlite3_free(p->a);
@@ -6757,10 +6793,12 @@
6793 */
6794 static void decimal_round(Decimal *p, int N){
6795 int i;
6796 int nZero;
6797 if( N<1 ) return;
6798 if( p==0 ) return;
6799 if( p->nDigit<=N ) return;
6800 for(nZero=0; nZero<p->nDigit && p->a[nZero]==0; nZero++){}
6801 N += nZero;
6802 if( p->nDigit<=N ) return;
6803 if( p->a[N]>4 ){
6804 p->a[N-1]++;
@@ -6914,19 +6952,22 @@
6952 ** digits to the right of the decimal point.
6953 */
6954 static void decimal_expand(Decimal *p, int nDigit, int nFrac){
6955 int nAddSig;
6956 int nAddFrac;
6957 signed char *a;
6958 if( p==0 ) return;
6959 nAddFrac = nFrac - p->nFrac;
6960 nAddSig = (nDigit - p->nDigit) - nAddFrac;
6961 if( nAddFrac==0 && nAddSig==0 ) return;
6962 if( nDigit+1>SQLITE_DECIMAL_MAX_DIGIT ){ p->oom = 1; return; }
6963 a = sqlite3_realloc64(p->a, nDigit+1);
6964 if( a==0 ){
6965 p->oom = 1;
6966 return;
6967 }
6968 p->a = a;
6969 if( nAddSig ){
6970 memmove(p->a+nAddSig, p->a, p->nDigit);
6971 memset(p->a, 0, nAddSig);
6972 p->nDigit += nAddSig;
6973 }
@@ -7017,18 +7058,22 @@
7058 */
7059 static void decimalMul(Decimal *pA, Decimal *pB){
7060 signed char *acc = 0;
7061 int i, j, k;
7062 int minFrac;
7063 sqlite3_int64 sumDigit;
7064
7065 if( pA==0 || pA->oom || pA->isNull
7066 || pB==0 || pB->oom || pB->isNull
7067 ){
7068 goto mul_end;
7069 }
7070 sumDigit = pA->nDigit;
7071 sumDigit += pB->nDigit;
7072 sumDigit += 2;
7073 if( sumDigit>SQLITE_DECIMAL_MAX_DIGIT ){ pA->oom = 1; return; }
7074 acc = sqlite3_malloc64( sumDigit );
7075 if( acc==0 ){
7076 pA->oom = 1;
7077 goto mul_end;
7078 }
7079 memset(acc, 0, pA->nDigit + pB->nDigit + 2);
@@ -7394,12 +7439,10 @@
7439 }
7440 return rc;
7441 }
7442
7443 /************************* End ext/misc/decimal.c ********************/
 
 
7444 /************************* Begin ext/misc/base64.c ******************/
7445 /*
7446 ** 2022-11-18
7447 **
7448 ** The author disclaims copyright to this source code. In place of
@@ -7674,11 +7717,11 @@
7717 */
7718 #ifndef SQLITE_SHELL_EXTFUNCS
7719 #ifdef _WIN32
7720
7721 #endif
7722 int sqlite3_base64_init
7723 #else
7724 static int sqlite3_base64_init
7725 #endif
7726 (sqlite3 *db, char **pzErr, const sqlite3_api_routines *pApi){
7727 SQLITE_EXTENSION_INIT2(pApi);
@@ -7696,13 +7739,10 @@
7739 */
7740 #define BASE64_INIT(db) sqlite3_base64_init(db, 0, 0)
7741 #define BASE64_EXPOSE(db, pzErr) /* Not needed, ..._init() does this. */
7742
7743 /************************* End ext/misc/base64.c ********************/
 
 
 
7744 /************************* Begin ext/misc/base85.c ******************/
7745 /*
7746 ** 2022-11-16
7747 **
7748 ** The author disclaims copyright to this source code. In place of
@@ -7964,11 +8004,11 @@
8004 }
8005 #endif
8006
8007 #ifndef BASE85_STANDALONE
8008
8009 #ifndef OMIT_BASE85_CHECKER
8010 /* This function does the work for the SQLite is_base85(t) UDF. */
8011 static void is_base85(sqlite3_context *context, int na, sqlite3_value *av[]){
8012 assert(na==1);
8013 switch( sqlite3_value_type(av[0]) ){
8014 case SQLITE_TEXT:
@@ -7984,11 +8024,11 @@
8024 default:
8025 sqlite3_result_error(context, "is_base85 accepts only text or NULL", -1);
8026 return;
8027 }
8028 }
8029 #endif
8030
8031 /* This function does the work for the SQLite base85(x) UDF. */
8032 static void base85(sqlite3_context *context, int na, sqlite3_value *av[]){
8033 sqlite3_int64 nb, nc, nv = sqlite3_value_bytes(av[0]);
8034 int nvMax = sqlite3_limit(sqlite3_context_db_handle(context),
@@ -8054,26 +8094,26 @@
8094 */
8095 #ifndef SQLITE_SHELL_EXTFUNCS
8096 #ifdef _WIN32
8097
8098 #endif
8099 int sqlite3_base85_init
8100 #else
8101 static int sqlite3_base85_init
8102 #endif
8103 (sqlite3 *db, char **pzErr, const sqlite3_api_routines *pApi){
8104 SQLITE_EXTENSION_INIT2(pApi);
8105 (void)pzErr;
8106 #ifndef OMIT_BASE85_CHECKER
8107 {
8108 int rc = sqlite3_create_function
8109 (db, "is_base85", 1,
8110 SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS|SQLITE_UTF8,
8111 0, is_base85, 0, 0);
8112 if( rc!=SQLITE_OK ) return rc;
8113 }
8114 #endif
8115 return sqlite3_create_function
8116 (db, "base85", 1,
8117 SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS|SQLITE_DIRECTONLY|SQLITE_UTF8,
8118 0, base85, 0, 0);
8119 }
@@ -8134,13 +8174,13 @@
8174 case 'w':
8175 while( 0 != fgets(cBuf, sizeof(cBuf), stdin) ){
8176 int nc = strlen(cBuf);
8177 size_t nbo = fromBase85( cBuf, nc, bBuf ) - bBuf;
8178 if( 1 != fwrite(bBuf, nbo, 1, fb) ) rc = 1;
8179 #ifndef OMIT_BASE85_CHECKER
8180 b85Clean &= allBase85( cBuf, nc );
8181 #endif
8182 }
8183 break;
8184 default:
8185 sayHelp();
8186 rc = 1;
@@ -10291,11 +10331,10 @@
10331 ReCompiled *pRe;
10332 sqlite3_str *pStr;
10333 int i;
10334 int n;
10335 char *z;
 
10336 static const char *ReOpName[] = {
10337 "EOF",
10338 "MATCH",
10339 "ANY",
10340 "ANYSTAR",
@@ -10314,10 +10353,11 @@
10353 "NOTSPACE",
10354 "BOUNDARY",
10355 "ATSTART",
10356 };
10357
10358 (void)argc;
10359 zPattern = (const char*)sqlite3_value_text(argv[0]);
10360 if( zPattern==0 ) return;
10361 zErr = re_compile(&pRe, zPattern, re_maxnfa(re_maxlen(context)),
10362 sqlite3_user_data(context)!=0);
10363 if( zErr ){
@@ -10468,15 +10508,10 @@
10508 **
10509 ** If a non-NULL value is specified for the optional $dir parameter and
10510 ** $path is a relative path, then $path is interpreted relative to $dir.
10511 ** And the paths returned in the "name" column of the table are also
10512 ** relative to directory $dir.
 
 
 
 
 
10513 */
10514 /* #include "sqlite3ext.h" */
10515 SQLITE_EXTENSION_INIT1
10516 #include <stdio.h>
10517 #include <string.h>
@@ -11836,10 +11871,11 @@
11871 */
11872 static int completionNext(sqlite3_vtab_cursor *cur){
11873 completion_cursor *pCur = (completion_cursor*)cur;
11874 int eNextPhase = 0; /* Next phase to try if current phase reaches end */
11875 int iCol = -1; /* If >=0, step pCur->pStmt and use the i-th column */
11876 int rc;
11877 pCur->iRowid++;
11878 while( pCur->ePhase!=COMPLETION_EOF ){
11879 switch( pCur->ePhase ){
11880 case COMPLETION_KEYWORDS: {
11881 if( pCur->j >= sqlite3_keyword_count() ){
@@ -11861,52 +11897,62 @@
11897 break;
11898 }
11899 case COMPLETION_TABLES: {
11900 if( pCur->pStmt==0 ){
11901 sqlite3_stmt *pS2;
11902 sqlite3_str* pStr = sqlite3_str_new(pCur->db);
11903 char *zSql = 0;
11904 const char *zSep = "";
11905 sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pS2, 0);
11906 while( sqlite3_step(pS2)==SQLITE_ROW ){
11907 const char *zDb = (const char*)sqlite3_column_text(pS2, 1);
11908 sqlite3_str_appendf(pStr,
11909 "%s"
11910 "SELECT name FROM \"%w\".sqlite_schema",
11911 zSep, zDb
11912 );
 
11913 zSep = " UNION ";
11914 }
11915 rc = sqlite3_finalize(pS2);
11916 zSql = sqlite3_str_finish(pStr);
11917 if( zSql==0 ) return SQLITE_NOMEM;
11918 if( rc==SQLITE_OK ){
11919 sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
11920 }
11921 sqlite3_free(zSql);
11922 if( rc ) return rc;
11923 }
11924 iCol = 0;
11925 eNextPhase = COMPLETION_COLUMNS;
11926 break;
11927 }
11928 case COMPLETION_COLUMNS: {
11929 if( pCur->pStmt==0 ){
11930 sqlite3_stmt *pS2;
11931 sqlite3_str *pStr = sqlite3_str_new(pCur->db);
11932 char *zSql = 0;
11933 const char *zSep = "";
11934 sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pS2, 0);
11935 while( sqlite3_step(pS2)==SQLITE_ROW ){
11936 const char *zDb = (const char*)sqlite3_column_text(pS2, 1);
11937 sqlite3_str_appendf(pStr,
11938 "%s"
11939 "SELECT pti.name FROM \"%w\".sqlite_schema AS sm"
11940 " JOIN pragma_table_xinfo(sm.name,%Q) AS pti"
11941 " WHERE sm.type='table'",
11942 zSep, zDb, zDb
11943 );
 
11944 zSep = " UNION ";
11945 }
11946 rc = sqlite3_finalize(pS2);
11947 zSql = sqlite3_str_finish(pStr);
11948 if( zSql==0 ) return SQLITE_NOMEM;
11949 if( rc==SQLITE_OK ){
11950 sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
11951 }
11952 sqlite3_free(zSql);
11953 if( rc ) return rc;
11954 }
11955 iCol = 0;
11956 eNextPhase = COMPLETION_EOF;
11957 break;
11958 }
@@ -11919,13 +11965,14 @@
11965 /* Extract the next row of content */
11966 pCur->zCurrentRow = (const char*)sqlite3_column_text(pCur->pStmt, iCol);
11967 pCur->szRow = sqlite3_column_bytes(pCur->pStmt, iCol);
11968 }else{
11969 /* When all rows are finished, advance to the next phase */
11970 rc = sqlite3_finalize(pCur->pStmt);
11971 pCur->pStmt = 0;
11972 pCur->ePhase = eNextPhase;
11973 if( rc ) return rc;
11974 continue;
11975 }
11976 }
11977 if( pCur->nPrefix==0 ) break;
11978 if( pCur->nPrefix<=pCur->szRow
@@ -15207,11 +15254,11 @@
15254 ){
15255 uLong nData;
15256 sqlite3_int64 sz;
15257
15258 assert( argc==2 );
15259 sz = sqlite3_value_int64(argv[1]);
15260
15261 if( sz<=0 || sz==(nData = sqlite3_value_bytes(argv[0])) ){
15262 sqlite3_result_value(context, argv[0]);
15263 }else{
15264 uLongf szf = sz;
@@ -24602,10 +24649,13 @@
24649 # define DFLT_LINE_LIMIT 5
24650 #endif
24651 #ifndef DFLT_TITLE_LIMIT
24652 # define DFLT_TITLE_LIMIT 20
24653 #endif
24654 #ifndef DFLT_MULTI_INSERT
24655 # define DFLT_MULTI_INSERT 3000
24656 #endif
24657
24658 /*
24659 ** Limit input nesting via .read or any other input redirect.
24660 ** It's not too expensive, so a generous allowance can be made.
24661 */
@@ -24798,11 +24848,11 @@
24848 free(p->spec.zColumnSep);
24849 free(p->spec.zRowSep);
24850 free(p->spec.zTableName);
24851 free(p->spec.zNull);
24852 memset(p, 0, sizeof(*p));
24853 p->spec.iVersion = 2;
24854 p->autoExplain = autoExplain;
24855 }
24856
24857 /*
24858 ** Duplicate Mode pSrc into pDest. pDest is assumed to be
@@ -24904,20 +24954,21 @@
24954 p->mode.spec.eText = QRF_TEXT_Relaxed;
24955 p->mode.spec.nCharLimit = DFLT_CHAR_LIMIT;
24956 p->mode.spec.nLineLimit = DFLT_LINE_LIMIT;
24957 p->mode.spec.bTextJsonb = QRF_Yes;
24958 p->mode.spec.nTitleLimit = DFLT_TITLE_LIMIT;
24959 p->mode.spec.nMultiInsert = DFLT_MULTI_INSERT;
24960 p->mode.mFlags = mFlags;
24961 }
24962 }
24963
24964 /*
24965 ** Set the mode to the default. It assumed that the mode has
24966 ** already been freed and zeroed prior to calling this routine.
24967 */
24968 static void modeDefault(ShellState *p){
24969 p->mode.spec.iVersion = 2;
24970 p->mode.autoExplain = 1;
24971 if( stdin_is_interactive || stdout_is_console ){
24972 modeChange(p, MODE_TTY);
24973 }else{
24974 modeChange(p, MODE_BATCH);
@@ -26860,10 +26911,11 @@
26911 p->mode.spec.zTableName = (char*)zTable;
26912 p->mode.eMode = MODE_Insert;
26913 p->mode.spec.eText = QRF_TEXT_Sql;
26914 p->mode.spec.eBlob = QRF_BLOB_Sql;
26915 p->mode.spec.bTitles = QRF_No;
26916 p->mode.spec.nCharLimit = 0;
26917 rc = shell_exec(p, sSelect.zTxt, 0);
26918 if( (rc&0xff)==SQLITE_CORRUPT ){
26919 cli_puts("/****** CORRUPTION ERROR *******/\n", p->out);
26920 toggleSelectOrder(p->db);
26921 shell_exec(p, sSelect.zTxt, 0);
@@ -27012,13 +27064,14 @@
27064 ".import FILE TABLE Import data from FILE into TABLE",
27065 #endif
27066 #ifndef SQLITE_OMIT_TEST_CONTROL
27067 ".imposter INDEX TABLE Create imposter table TABLE on index INDEX",
27068 #endif
27069 ".indexes ?PATTERN? Show names of indexes matching PATTERN",
27070 " -a|--all Also show system-generated indexes",
27071 " --expr Show only expression indexes",
27072 " --sys Show only system-generated indexes",
27073 ".intck ?STEPS_PER_UNLOCK? Run an incremental integrity check on the db",
27074 #ifdef SQLITE_ENABLE_IOTRACE
27075 ",iotrace FILE Enable I/O diagnostic logging to FILE",
27076 #endif
27077 ".limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT",
@@ -27252,10 +27305,12 @@
27305 " --titlelimit T\". The \",T\" can be omitted in which\n"
27306 " case the --titlelimit is unchanged. The argument\n"
27307 " can also be \"off\" to mean \"0,0,0\" or \"on\" to\n"
27308 " mean \"5,300,20\".\n"
27309 " --list List available modes\n"
27310 " --multiinsert N In \"insert\" mode, put multiple rows on a single\n"
27311 " INSERT statement until the size exceeds N bytes.\n"
27312 " --null STRING Render SQL NULL values as the given string\n"
27313 " --once Setting changes to the right are reverted after\n"
27314 " the next SQL command.\n"
27315 " --quote ARG Enable/disable quoting of text. ARG can be\n"
27316 " \"off\", \"on\", \"sql\", \"relaxed\", \"csv\", \"html\",\n"
@@ -30750,11 +30805,11 @@
30805 static int outputDumpWarning(ShellState *p, const char *zLike){
30806 int rc = SQLITE_OK;
30807 sqlite3_stmt *pStmt = 0;
30808 shellPreparePrintf(p->db, &rc, &pStmt,
30809 "SELECT 1 FROM sqlite_schema o WHERE "
30810 "sql LIKE 'CREATE VIRTUAL TABLE%%' AND (%s)", zLike ? zLike : "true"
30811 );
30812 if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
30813 cli_puts("/* WARNING: "
30814 "Script requires that SQLITE_DBCONFIG_DEFENSIVE be disabled */\n",
30815 p->out
@@ -31330,10 +31385,12 @@
31385 ** --titlelimit T". The ",T" can be omitted in which
31386 ** case the --titlelimit is unchanged. The argument
31387 ** can also be "off" to mean "0,0,0" or "on" to
31388 ** mean "5,300,20".
31389 ** --list List available modes
31390 ** --multiinsert N In "insert" mode, put multiple rows on a single
31391 ** INSERT statement until the size exceeds N bytes.
31392 ** --null STRING Render SQL NULL values as the given string
31393 ** --once Setting changes to the right are reverted after
31394 ** the next SQL command.
31395 ** --quote ARG Enable/disable quoting of text. ARG can be
31396 ** "off", "on", "sql", "relaxed", "csv", "html",
@@ -31445,21 +31502,23 @@
31502 k = pickStr(azArg[i], 0, "auto", "off", "on", "");
31503 if( k>=0 ){
31504 p->mode.spec.bBorder = k & 0x3;
31505 }
31506 chng = 1;
31507 }else if( 0<=(k=pickStr(z,0,
31508 "-charlimit","-linelimit","-titlelimit","-multiinsert","")) ){
31509 int w; /* 0 1 2 3 */
31510 if( i+1>=nArg ){
31511 dotCmdError(p, i, "missing argument", 0);
31512 return 1;
31513 }
31514 w = integerValue(azArg[++i]);
31515 switch( k ){
31516 case 0: p->mode.spec.nCharLimit = w; break;
31517 case 1: p->mode.spec.nLineLimit = w; break;
31518 case 2: p->mode.spec.nTitleLimit = w; break;
31519 default: p->mode.spec.nMultiInsert = w; break;
31520 }
31521 chng = 1;
31522 }else if( 0<=(k=pickStr(z,0,"-tablename","-rowsep","-colsep","-null","")) ){
31523 /* 0 1 2 3 */
31524 if( i+1>=nArg ){
@@ -31798,10 +31857,16 @@
31857 sqlite3_str_appendf(pDesc, " --limits %d,%d,%d",
31858 p->mode.spec.nLineLimit, p->mode.spec.nCharLimit,
31859 p->mode.spec.nTitleLimit);
31860 }
31861 }
31862 if( bAll
31863 || (p->mode.spec.nMultiInsert && p->mode.spec.eStyle==QRF_STYLE_Insert)
31864 ){
31865 sqlite3_str_appendf(pDesc, " --multiinsert %u",
31866 p->mode.spec.nMultiInsert);
31867 }
31868 zSetting = aModeStr[pI->eNull];
31869 if( bAll || (zSetting && cli_strcmp(zSetting,p->mode.spec.zNull)!=0) ){
31870 sqlite3_str_appendf(pDesc, " --null ");
31871 append_c_string(pDesc, p->mode.spec.zNull);
31872 }
@@ -33263,10 +33328,96 @@
33328 rc = 1;
33329 }
33330 sqlite3_free(zSql);
33331 }else
33332 #endif /* !defined(SQLITE_OMIT_TEST_CONTROL) */
33333
33334 if( c=='i' && (cli_strncmp(azArg[0], "indices", n)==0
33335 || cli_strncmp(azArg[0], "indexes", n)==0)
33336 ){
33337 sqlite3_str *pSql;
33338 int i;
33339 int allFlag = 0;
33340 int sysFlag = 0;
33341 int exprFlag = 0;
33342 int debugFlag = 0; /* Undocument --debug flag */
33343 const char *zPattern = 0;
33344 const char *zSep = "WHERE";
33345
33346 for(i=1; i<nArg; i++){
33347 if( azArg[i][0]=='-' ){
33348 const char *z = azArg[i]+1;
33349 if( z[0]=='-' ) z++;
33350 if( cli_strcmp(z,"all")==0 || cli_strcmp(z,"a")==0 ){
33351 allFlag = 1;
33352 }else
33353 if( cli_strcmp(z,"sys")==0 ){
33354 sysFlag = 1;
33355 allFlag = 0;
33356 }else
33357 if( cli_strcmp(z,"expr")==0 ){
33358 exprFlag = 1;
33359 allFlag = 0;
33360 }else
33361 if( cli_strcmp(z,"debug")==0 ){
33362 debugFlag = 1;
33363 }else
33364 {
33365 dotCmdError(p, i, "unknown option", 0);
33366 rc = 1;
33367 goto meta_command_exit;
33368 }
33369 }else if( zPattern==0 ){
33370 zPattern = azArg[i];
33371 }else{
33372 dotCmdError(p, i, "unknown argument", 0);
33373 rc = 1;
33374 goto meta_command_exit;
33375 }
33376 }
33377
33378 open_db(p, 0);
33379 pSql = sqlite3_str_new(p->db);
33380 sqlite3_str_appendf(pSql,
33381 "SELECT if(t.schema='main',i.name,t.schema||'.'||i.name)\n"
33382 "FROM pragma_table_list t, pragma_index_list(t.name,t.schema) i\n"
33383 );
33384 if( exprFlag ){
33385 allFlag = 0;
33386 sqlite3_str_appendf(pSql,
33387 "%s (EXISTS(SELECT 1 FROM pragma_index_xinfo(i.name) WHERE cid=-2)\n"
33388 " OR\n"
33389 " EXISTS(SELECT cid FROM pragma_table_xinfo(t.name) WHERE hidden=2"
33390 " INTERSECT "
33391 " SELECT cid FROM pragma_index_info(i.name)))\n", zSep);
33392 zSep = "AND";
33393 }
33394 if( sysFlag ){
33395 sqlite3_str_appendf(pSql,
33396 "%s i.name LIKE 'sqlite__autoindex__%%' ESCAPE '_'\n", zSep);
33397 zSep = "AND";
33398 }else if( !allFlag ){
33399 sqlite3_str_appendf(pSql,
33400 "%s i.name NOT LIKE 'sqlite__%%' ESCAPE '_'\n", zSep);
33401 zSep = "AND";
33402 }
33403 if( zPattern ){
33404 sqlite3_str_appendf(pSql, "%s i.name LIKE '%%%q%%'\n", zSep, zPattern);
33405 }
33406 sqlite3_str_appendf(pSql, "ORDER BY 1");
33407
33408 /* Run the SQL statement in "split" mode. */
33409 if( debugFlag ){
33410 cli_printf(stdout,"%s;\n", sqlite3_str_value(pSql));
33411 }else{
33412 modePush(p);
33413 modeChange(p, MODE_Split);
33414 shell_exec(p, sqlite3_str_value(pSql), 0);
33415 modePop(p);
33416 }
33417 sqlite3_str_free(pSql);
33418 }else
33419
33420 if( c=='i' && cli_strncmp(azArg[0], "intck", n)==0 ){
33421 i64 iArg = 0;
33422 if( nArg==2 ){
33423 iArg = integerValue(azArg[1]);
@@ -34641,14 +34792,11 @@
34792 eputz("Usage: .stats ?on|off|stmt|vmstep?\n");
34793 rc = 1;
34794 }
34795 }else
34796
34797 if( (c=='t' && n>1 && cli_strncmp(azArg[0], "tables", n)==0) ){
 
 
 
34798 sqlite3_stmt *pStmt;
34799 sqlite3_str *pSql;
34800 const char *zPattern = nArg>1 ? azArg[1] : 0;
34801
34802 open_db(p, 0);
@@ -34656,19 +34804,10 @@
34804 if( rc ){
34805 sqlite3_finalize(pStmt);
34806 return shellDatabaseError(p->db);
34807 }
34808
 
 
 
 
 
 
 
 
 
34809 pSql = sqlite3_str_new(p->db);
34810 while( sqlite3_step(pStmt)==SQLITE_ROW ){
34811 const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1);
34812 if( zDbName==0 ) continue;
34813 if( sqlite3_str_length(pSql) ){
@@ -34678,23 +34817,16 @@
34817 sqlite3_str_appendall(pSql, "SELECT name FROM ");
34818 }else{
34819 sqlite3_str_appendf(pSql, "SELECT %Q||'.'||name FROM ", zDbName);
34820 }
34821 sqlite3_str_appendf(pSql, "\"%w\".sqlite_schema", zDbName);
34822 sqlite3_str_appendf(pSql,
34823 " WHERE type IN ('table','view')"
34824 " AND name NOT LIKE 'sqlite__%%' ESCAPE '_'"
34825 );
34826 if( zPattern ){
34827 sqlite3_str_appendf(pSql," AND name LIKE %Q", zPattern);
 
 
 
 
 
 
 
34828 }
34829 }
34830 rc = sqlite3_finalize(pStmt);
34831 if( rc==SQLITE_OK ){
34832 sqlite3_str_appendall(pSql, " ORDER BY 1");
@@ -35622,11 +35754,16 @@
35754 }
35755
35756 /*
35757 ** Run a single line of SQL. Return the number of errors.
35758 */
35759 static int runOneSqlLine(
35760 ShellState *p, /* Execution context */
35761 char *zSql, /* SQL to be run */
35762 const char *zFilename, /* Source file of the sql */
35763 int startline /* linenumber */
35764 ){
35765 int rc;
35766 char *zErrMsg = 0;
35767
35768 open_db(p, 0);
35769 if( ShellHasFlag(p,SHFLG_Backslash) ) resolve_backslashes(zSql);
@@ -35649,13 +35786,21 @@
35786 zErrorTail = &zErrMsg[10];
35787 }else{
35788 zErrorType = "Error";
35789 zErrorTail = zErrMsg;
35790 }
35791 if( zFilename || !stdin_is_interactive ){
35792 if( cli_strcmp(zFilename,"cmdline")==0 ){
35793 sqlite3_snprintf(sizeof(zPrefix), zPrefix,
35794 "%s in %r command line argument:", zErrorType, startline);
35795 }else if( cli_strcmp(zFilename,"<stdin>")==0 ){
35796 sqlite3_snprintf(sizeof(zPrefix), zPrefix,
35797 "%s near line %d:", zErrorType, startline);
35798 }else{
35799 sqlite3_snprintf(sizeof(zPrefix), zPrefix,
35800 "%s near line %d of %s:", zErrorType, startline, zFilename);
35801 }
35802 }else{
35803 sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%s:", zErrorType);
35804 }
35805 cli_printf(stderr,"%s %s\n", zPrefix, zErrorTail);
35806 sqlite3_free(zErrMsg);
@@ -35814,11 +35959,11 @@
35959 nSql = 0;
35960 errCnt++;
35961 break;
35962 }else if( nSql && QSS_SEMITERM(qss) && sqlite3_complete(zSql) ){
35963 echo_group_input(p, zSql);
35964 errCnt += runOneSqlLine(p, zSql, p->zInFile, startline);
35965 CONTINUE_PROMPT_RESET;
35966 nSql = 0;
35967 if( p->nPopOutput ){
35968 output_reset(p);
35969 p->nPopOutput = 0;
@@ -35838,11 +35983,11 @@
35983 }
35984 }
35985 if( nSql ){
35986 /* This may be incomplete. Let the SQL parser deal with that. */
35987 echo_group_input(p, zSql);
35988 errCnt += runOneSqlLine(p, zSql, p->zInFile, startline);
35989 CONTINUE_PROMPT_RESET;
35990 }
35991 free(zSql);
35992 free(zLine);
35993 --p->inputNesting;
@@ -36186,11 +36331,11 @@
36331
36332 /* Use the wmain() entry point on Windows. Translate arguments to
36333 ** UTF8, then invoke the traditional main() entry point which is
36334 ** renamed using a #define to utf8_main() .
36335 */
36336 #if defined(_WIN32) && !defined(__MINGW32__) && !defined(main)
36337 # define main utf8_main /* Rename entry point to utf_main() */
36338 int SQLITE_CDECL utf8_main(int,char**); /* Forward declaration */
36339 int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
36340 int rc, i;
36341 char **argv = malloc( sizeof(char*) * (argc+1) );
@@ -36235,11 +36380,10 @@
36380 */
36381 int SQLITE_CDECL main(int argc, char **argv){
36382 #ifdef SQLITE_DEBUG
36383 sqlite3_int64 mem_main_enter = 0;
36384 #endif
 
36385 #ifdef SQLITE_SHELL_FIDDLE
36386 # define data shellState
36387 #else
36388 ShellState data;
36389 #endif
@@ -36774,19 +36918,11 @@
36918 if( rc && (bail_on_error || rc==2) ){
36919 if( rc==2 ) rc = 0;
36920 goto shell_main_exit;
36921 }
36922 }else{
36923 rc = runOneSqlLine(&data, z, "cmdline", i);
 
 
 
 
 
 
 
 
36924 if( bail_on_error ) goto shell_main_exit;
36925 }
36926 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
36927 }else if( cli_strncmp(z, "-A", 2)==0 ){
36928 if( nCmd>0 ){
@@ -36848,29 +36984,17 @@
36984 if( rc ){
36985 if( rc==2 ) rc = 0;
36986 goto shell_main_exit;
36987 }
36988 }else{
36989 rc = runOneSqlLine(&data, azCmd[i], "cmdline", aiCmd[i]);
 
 
 
 
 
 
 
 
 
 
 
 
36990 if( data.nPopMode ){
36991 modePop(&data);
36992 data.nPopMode = 0;
36993 }
36994 }
36995 if( data.nPopOutput && azCmd[i][0]!='.' ){
36996 output_reset(&data);
36997 data.nPopOutput = 0;
36998 }else{
36999 clearTempFile(&data);
37000 }
37001
+871 -449
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.52.0. By combining all the individual C code files into this
3
+** version 3.53.0. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -16,11 +16,11 @@
1616
** if you want a wrapper to interface SQLite with your choice of programming
1717
** language. The code for the "sqlite3" command-line shell is also in a
1818
** separate file. This file contains only code for the core SQLite library.
1919
**
2020
** The content in this amalgamation comes from Fossil check-in
21
-** 557aeb43869d3585137b17690cb3b64f7de6 with changes in files:
21
+** 5c237f1f863a32cf229010d2024d0d1e76a0 with changes in files:
2222
**
2323
**
2424
*/
2525
#ifndef SQLITE_AMALGAMATION
2626
#define SQLITE_CORE 1
@@ -465,16 +465,16 @@
465465
**
466466
** See also: [sqlite3_libversion()],
467467
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468468
** [sqlite_version()] and [sqlite_source_id()].
469469
*/
470
-#define SQLITE_VERSION "3.52.0"
471
-#define SQLITE_VERSION_NUMBER 3052000
472
-#define SQLITE_SOURCE_ID "2026-03-06 16:01:44 557aeb43869d3585137b17690cb3b64f7de6921774daae9e56403c3717dceab6"
470
+#define SQLITE_VERSION "3.53.0"
471
+#define SQLITE_VERSION_NUMBER 3053000
472
+#define SQLITE_SOURCE_ID "2026-03-18 22:31:56 5c237f1f863a32cf229010d2024d0d1e76a07a4d8b9492b26503b959f1c32485"
473473
#define SQLITE_SCM_BRANCH "trunk"
474
-#define SQLITE_SCM_TAGS "release major-release version-3.52.0"
475
-#define SQLITE_SCM_DATETIME "2026-03-06T16:01:44.367Z"
474
+#define SQLITE_SCM_TAGS ""
475
+#define SQLITE_SCM_DATETIME "2026-03-18T22:31:56.220Z"
476476
477477
/*
478478
** CAPI3REF: Run-Time Library Version Numbers
479479
** KEYWORDS: sqlite3_version sqlite3_sourceid
480480
**
@@ -2977,11 +2977,11 @@
29772977
** default value 17, as of SQLite version 3.52.0. The value was 15 in all
29782978
** prior versions.<p>
29792979
** This option takes two arguments which are an integer and a pointer
29802980
** to an integer. The first argument is a small integer, between 3 and 23, or
29812981
** zero. The FP_DIGITS setting is changed to that small integer, or left
2982
-** altered if the first argument is zero or out of range. The second argument
2982
+** unaltered if the first argument is zero or out of range. The second argument
29832983
** is a pointer to an integer. If the pointer is not NULL, then the value of
29842984
** the FP_DIGITS setting, after possibly being modified by the first
29852985
** arguments, is written into the integer to which the second argument points.
29862986
** </dd>
29872987
**
@@ -4807,11 +4807,11 @@
48074807
** are constructors for the [prepared statement] object.
48084808
**
48094809
** The preferred routine to use is [sqlite3_prepare_v2()]. The
48104810
** [sqlite3_prepare()] interface is legacy and should be avoided.
48114811
** [sqlite3_prepare_v3()] has an extra
4812
-** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is some times
4812
+** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is sometimes
48134813
** needed for special purpose or to pass along security restrictions.
48144814
**
48154815
** The use of the UTF-8 interfaces is preferred, as SQLite currently
48164816
** does all parsing using UTF-8. The UTF-16 interfaces are provided
48174817
** as a convenience. The UTF-16 interfaces work by converting the
@@ -6814,11 +6814,11 @@
68146814
** application-defined function to be a text string in an encoding
68156815
** specified the E parameter, which must be one
68166816
** of [SQLITE_UTF8], [SQLITE_UTF8_ZT], [SQLITE_UTF16], [SQLITE_UTF16BE],
68176817
** or [SQLITE_UTF16LE]. ^The special value [SQLITE_UTF8_ZT] means that
68186818
** the result text is both UTF-8 and zero-terminated. In other words,
6819
-** SQLITE_UTF8_ZT means that the Z array holds at least N+1 byes and that
6819
+** SQLITE_UTF8_ZT means that the Z array holds at least N+1 bytes and that
68206820
** the Z&#91;N&#93; is zero.
68216821
** ^SQLite takes the text result from the application from
68226822
** the 2nd parameter of the sqlite3_result_text* interfaces.
68236823
** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
68246824
** other than sqlite3_result_text64() is negative, then SQLite computes
@@ -9184,11 +9184,11 @@
91849184
**
91859185
** ^The [sqlite3_str_reset(X)] method resets the string under construction
91869186
** inside [sqlite3_str] object X back to zero bytes in length.
91879187
**
91889188
** ^The [sqlite3_str_truncate(X,N)] method changes the length of the string
9189
-** under construction to be N bytes are less. This routine is a no-op if
9189
+** under construction to be N bytes or less. This routine is a no-op if
91909190
** N is negative or if the string is already N bytes or smaller in size.
91919191
**
91929192
** These methods do not return a result code. ^If an error occurs, that fact
91939193
** is recorded in the [sqlite3_str] object and can be recovered by a
91949194
** subsequent call to [sqlite3_str_errcode(X)].
@@ -11048,11 +11048,11 @@
1104811048
** - less than -1 or greater than or equal to the total number of query
1104911049
** elements used to implement the statement - a non-zero value is returned and
1105011050
** the variable that pOut points to is unchanged.
1105111051
**
1105211052
** See also: [sqlite3_stmt_scanstatus_reset()] and the
11053
-** [nexec and ncycle] columnes of the [bytecode virtual table].
11053
+** [nexec and ncycle] columns of the [bytecode virtual table].
1105411054
*/
1105511055
SQLITE_API int sqlite3_stmt_scanstatus(
1105611056
sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
1105711057
int idx, /* Index of loop to report on */
1105811058
int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
@@ -11604,21 +11604,21 @@
1160411604
**
1160511605
** If the X argument is not a NULL pointer or one of the special
1160611606
** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke
1160711607
** the function X with argument D when it is finished using the data in P.
1160811608
** The call to X(D) is a destructor for the array P. The destructor X(D)
11609
-** is invoked even if the call to sqlite3_carray_bind() fails. If the X
11609
+** is invoked even if the call to sqlite3_carray_bind_v2() fails. If the X
1161011610
** parameter is the special-case value [SQLITE_STATIC], then SQLite assumes
1161111611
** that the data static and the destructor is never invoked. If the X
1161211612
** parameter is the special-case value [SQLITE_TRANSIENT], then
1161311613
** sqlite3_carray_bind_v2() makes its own private copy of the data prior
1161411614
** to returning and never invokes the destructor X.
1161511615
**
11616
-** The sqlite3_carray_bind() function works the same as sqlite_carray_bind_v2()
11616
+** The sqlite3_carray_bind() function works the same as sqlite3_carray_bind_v2()
1161711617
** with a D parameter set to P. In other words,
1161811618
** sqlite3_carray_bind(S,I,P,N,F,X) is same as
11619
-** sqlite3_carray_bind(S,I,P,N,F,X,P).
11619
+** sqlite3_carray_bind_v2(S,I,P,N,F,X,P).
1162011620
*/
1162111621
SQLITE_API int sqlite3_carray_bind_v2(
1162211622
sqlite3_stmt *pStmt, /* Statement to be bound */
1162311623
int i, /* Parameter index */
1162411624
void *aData, /* Pointer to array data */
@@ -14740,13 +14740,11 @@
1474014740
#endif
1474114741
1474214742
/*
1474314743
** Include standard header files as necessary
1474414744
*/
14745
-#ifdef HAVE_STDINT_H
1474614745
#include <stdint.h>
14747
-#endif
1474814746
#ifdef HAVE_INTTYPES_H
1474914747
#include <inttypes.h>
1475014748
#endif
1475114749
1475214750
/*
@@ -17315,10 +17313,11 @@
1731517313
KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
1731617314
u32 *ai; /* Used when p4type is P4_INTARRAY */
1731717315
SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */
1731817316
Table *pTab; /* Used when p4type is P4_TABLE */
1731917317
SubrtnSig *pSubrtnSig; /* Used when p4type is P4_SUBRTNSIG */
17318
+ Index *pIdx; /* Used when p4type is P4_INDEX */
1732017319
#ifdef SQLITE_ENABLE_CURSOR_HINTS
1732117320
Expr *pExpr; /* Used when p4type is P4_EXPR */
1732217321
#endif
1732317322
} p4;
1732417323
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
@@ -17369,24 +17368,25 @@
1736917368
#define P4_STATIC (-1) /* Pointer to a static string */
1737017369
#define P4_COLLSEQ (-2) /* P4 is a pointer to a CollSeq structure */
1737117370
#define P4_INT32 (-3) /* P4 is a 32-bit signed integer */
1737217371
#define P4_SUBPROGRAM (-4) /* P4 is a pointer to a SubProgram structure */
1737317372
#define P4_TABLE (-5) /* P4 is a pointer to a Table structure */
17373
+#define P4_INDEX (-6) /* P4 is a pointer to an Index structure */
1737417374
/* Above do not own any resources. Must free those below */
17375
-#define P4_FREE_IF_LE (-6)
17376
-#define P4_DYNAMIC (-6) /* Pointer to memory from sqliteMalloc() */
17377
-#define P4_FUNCDEF (-7) /* P4 is a pointer to a FuncDef structure */
17378
-#define P4_KEYINFO (-8) /* P4 is a pointer to a KeyInfo structure */
17379
-#define P4_EXPR (-9) /* P4 is a pointer to an Expr tree */
17380
-#define P4_MEM (-10) /* P4 is a pointer to a Mem* structure */
17381
-#define P4_VTAB (-11) /* P4 is a pointer to an sqlite3_vtab structure */
17382
-#define P4_REAL (-12) /* P4 is a 64-bit floating point value */
17383
-#define P4_INT64 (-13) /* P4 is a 64-bit signed integer */
17384
-#define P4_INTARRAY (-14) /* P4 is a vector of 32-bit integers */
17385
-#define P4_FUNCCTX (-15) /* P4 is a pointer to an sqlite3_context object */
17386
-#define P4_TABLEREF (-16) /* Like P4_TABLE, but reference counted */
17387
-#define P4_SUBRTNSIG (-17) /* P4 is a SubrtnSig pointer */
17375
+#define P4_FREE_IF_LE (-7)
17376
+#define P4_DYNAMIC (-7) /* Pointer to memory from sqliteMalloc() */
17377
+#define P4_FUNCDEF (-8) /* P4 is a pointer to a FuncDef structure */
17378
+#define P4_KEYINFO (-9) /* P4 is a pointer to a KeyInfo structure */
17379
+#define P4_EXPR (-10) /* P4 is a pointer to an Expr tree */
17380
+#define P4_MEM (-11) /* P4 is a pointer to a Mem* structure */
17381
+#define P4_VTAB (-12) /* P4 is a pointer to an sqlite3_vtab structure */
17382
+#define P4_REAL (-13) /* P4 is a 64-bit floating point value */
17383
+#define P4_INT64 (-14) /* P4 is a 64-bit signed integer */
17384
+#define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */
17385
+#define P4_FUNCCTX (-16) /* P4 is a pointer to an sqlite3_context object */
17386
+#define P4_TABLEREF (-17) /* Like P4_TABLE, but reference counted */
17387
+#define P4_SUBRTNSIG (-18) /* P4 is a SubrtnSig pointer */
1738817388
1738917389
/* Error message codes for OP_Halt */
1739017390
#define P5_ConstraintNotNull 1
1739117391
#define P5_ConstraintUnique 2
1739217392
#define P5_ConstraintCheck 3
@@ -17471,66 +17471,66 @@
1747117471
#define OP_IdxGT 42 /* jump, synopsis: key=r[P3@P4] */
1747217472
#define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
1747317473
#define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
1747417474
#define OP_IdxLT 45 /* jump, synopsis: key=r[P3@P4] */
1747517475
#define OP_IdxGE 46 /* jump, synopsis: key=r[P3@P4] */
17476
-#define OP_RowSetRead 47 /* jump, synopsis: r[P3]=rowset(P1) */
17477
-#define OP_RowSetTest 48 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
17478
-#define OP_Program 49 /* jump0 */
17479
-#define OP_FkIfZero 50 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
17476
+#define OP_IFindKey 47 /* jump */
17477
+#define OP_RowSetRead 48 /* jump, synopsis: r[P3]=rowset(P1) */
17478
+#define OP_RowSetTest 49 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
17479
+#define OP_Program 50 /* jump0 */
1748017480
#define OP_IsNull 51 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
1748117481
#define OP_NotNull 52 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
1748217482
#define OP_Ne 53 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
1748317483
#define OP_Eq 54 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */
1748417484
#define OP_Gt 55 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */
1748517485
#define OP_Le 56 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
1748617486
#define OP_Lt 57 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
1748717487
#define OP_Ge 58 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
1748817488
#define OP_ElseEq 59 /* jump, same as TK_ESCAPE */
17489
-#define OP_IfPos 60 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
17490
-#define OP_IfNotZero 61 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
17491
-#define OP_DecrJumpZero 62 /* jump, synopsis: if (--r[P1])==0 goto P2 */
17492
-#define OP_IncrVacuum 63 /* jump */
17493
-#define OP_VNext 64 /* jump */
17494
-#define OP_Filter 65 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */
17495
-#define OP_PureFunc 66 /* synopsis: r[P3]=func(r[P2@NP]) */
17496
-#define OP_Function 67 /* synopsis: r[P3]=func(r[P2@NP]) */
17497
-#define OP_Return 68
17498
-#define OP_EndCoroutine 69
17499
-#define OP_HaltIfNull 70 /* synopsis: if r[P3]=null halt */
17500
-#define OP_Halt 71
17501
-#define OP_Integer 72 /* synopsis: r[P2]=P1 */
17502
-#define OP_Int64 73 /* synopsis: r[P2]=P4 */
17503
-#define OP_String 74 /* synopsis: r[P2]='P4' (len=P1) */
17504
-#define OP_BeginSubrtn 75 /* synopsis: r[P2]=NULL */
17505
-#define OP_Null 76 /* synopsis: r[P2..P3]=NULL */
17506
-#define OP_SoftNull 77 /* synopsis: r[P1]=NULL */
17507
-#define OP_Blob 78 /* synopsis: r[P2]=P4 (len=P1) */
17508
-#define OP_Variable 79 /* synopsis: r[P2]=parameter(P1) */
17509
-#define OP_Move 80 /* synopsis: r[P2@P3]=r[P1@P3] */
17510
-#define OP_Copy 81 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
17511
-#define OP_SCopy 82 /* synopsis: r[P2]=r[P1] */
17512
-#define OP_IntCopy 83 /* synopsis: r[P2]=r[P1] */
17513
-#define OP_FkCheck 84
17514
-#define OP_ResultRow 85 /* synopsis: output=r[P1@P2] */
17515
-#define OP_CollSeq 86
17516
-#define OP_AddImm 87 /* synopsis: r[P1]=r[P1]+P2 */
17517
-#define OP_RealAffinity 88
17518
-#define OP_Cast 89 /* synopsis: affinity(r[P1]) */
17519
-#define OP_Permutation 90
17520
-#define OP_Compare 91 /* synopsis: r[P1@P3] <-> r[P2@P3] */
17521
-#define OP_IsTrue 92 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
17522
-#define OP_ZeroOrNull 93 /* synopsis: r[P2] = 0 OR NULL */
17523
-#define OP_Offset 94 /* synopsis: r[P3] = sqlite_offset(P1) */
17524
-#define OP_Column 95 /* synopsis: r[P3]=PX cursor P1 column P2 */
17525
-#define OP_TypeCheck 96 /* synopsis: typecheck(r[P1@P2]) */
17526
-#define OP_Affinity 97 /* synopsis: affinity(r[P1@P2]) */
17527
-#define OP_MakeRecord 98 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
17528
-#define OP_Count 99 /* synopsis: r[P2]=count() */
17529
-#define OP_ReadCookie 100
17530
-#define OP_SetCookie 101
17531
-#define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */
17489
+#define OP_FkIfZero 60 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
17490
+#define OP_IfPos 61 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
17491
+#define OP_IfNotZero 62 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
17492
+#define OP_DecrJumpZero 63 /* jump, synopsis: if (--r[P1])==0 goto P2 */
17493
+#define OP_IncrVacuum 64 /* jump */
17494
+#define OP_VNext 65 /* jump */
17495
+#define OP_Filter 66 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */
17496
+#define OP_PureFunc 67 /* synopsis: r[P3]=func(r[P2@NP]) */
17497
+#define OP_Function 68 /* synopsis: r[P3]=func(r[P2@NP]) */
17498
+#define OP_Return 69
17499
+#define OP_EndCoroutine 70
17500
+#define OP_HaltIfNull 71 /* synopsis: if r[P3]=null halt */
17501
+#define OP_Halt 72
17502
+#define OP_Integer 73 /* synopsis: r[P2]=P1 */
17503
+#define OP_Int64 74 /* synopsis: r[P2]=P4 */
17504
+#define OP_String 75 /* synopsis: r[P2]='P4' (len=P1) */
17505
+#define OP_BeginSubrtn 76 /* synopsis: r[P2]=NULL */
17506
+#define OP_Null 77 /* synopsis: r[P2..P3]=NULL */
17507
+#define OP_SoftNull 78 /* synopsis: r[P1]=NULL */
17508
+#define OP_Blob 79 /* synopsis: r[P2]=P4 (len=P1) */
17509
+#define OP_Variable 80 /* synopsis: r[P2]=parameter(P1) */
17510
+#define OP_Move 81 /* synopsis: r[P2@P3]=r[P1@P3] */
17511
+#define OP_Copy 82 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
17512
+#define OP_SCopy 83 /* synopsis: r[P2]=r[P1] */
17513
+#define OP_IntCopy 84 /* synopsis: r[P2]=r[P1] */
17514
+#define OP_FkCheck 85
17515
+#define OP_ResultRow 86 /* synopsis: output=r[P1@P2] */
17516
+#define OP_CollSeq 87
17517
+#define OP_AddImm 88 /* synopsis: r[P1]=r[P1]+P2 */
17518
+#define OP_RealAffinity 89
17519
+#define OP_Cast 90 /* synopsis: affinity(r[P1]) */
17520
+#define OP_Permutation 91
17521
+#define OP_Compare 92 /* synopsis: r[P1@P3] <-> r[P2@P3] */
17522
+#define OP_IsTrue 93 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
17523
+#define OP_ZeroOrNull 94 /* synopsis: r[P2] = 0 OR NULL */
17524
+#define OP_Offset 95 /* synopsis: r[P3] = sqlite_offset(P1) */
17525
+#define OP_Column 96 /* synopsis: r[P3]=PX cursor P1 column P2 */
17526
+#define OP_TypeCheck 97 /* synopsis: typecheck(r[P1@P2]) */
17527
+#define OP_Affinity 98 /* synopsis: affinity(r[P1@P2]) */
17528
+#define OP_MakeRecord 99 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
17529
+#define OP_Count 100 /* synopsis: r[P2]=count() */
17530
+#define OP_ReadCookie 101
17531
+#define OP_SetCookie 102
1753217532
#define OP_BitAnd 103 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
1753317533
#define OP_BitOr 104 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
1753417534
#define OP_ShiftLeft 105 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
1753517535
#define OP_ShiftRight 106 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
1753617536
#define OP_Add 107 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -17537,88 +17537,89 @@
1753717537
#define OP_Subtract 108 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
1753817538
#define OP_Multiply 109 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
1753917539
#define OP_Divide 110 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
1754017540
#define OP_Remainder 111 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
1754117541
#define OP_Concat 112 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
17542
-#define OP_OpenRead 113 /* synopsis: root=P2 iDb=P3 */
17543
-#define OP_OpenWrite 114 /* synopsis: root=P2 iDb=P3 */
17542
+#define OP_ReopenIdx 113 /* synopsis: root=P2 iDb=P3 */
17543
+#define OP_OpenRead 114 /* synopsis: root=P2 iDb=P3 */
1754417544
#define OP_BitNot 115 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
17545
-#define OP_OpenDup 116
17546
-#define OP_OpenAutoindex 117 /* synopsis: nColumn=P2 */
17545
+#define OP_OpenWrite 116 /* synopsis: root=P2 iDb=P3 */
17546
+#define OP_OpenDup 117
1754717547
#define OP_String8 118 /* same as TK_STRING, synopsis: r[P2]='P4' */
17548
-#define OP_OpenEphemeral 119 /* synopsis: nColumn=P2 */
17549
-#define OP_SorterOpen 120
17550
-#define OP_SequenceTest 121 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
17551
-#define OP_OpenPseudo 122 /* synopsis: P3 columns in r[P2] */
17552
-#define OP_Close 123
17553
-#define OP_ColumnsUsed 124
17554
-#define OP_SeekScan 125 /* synopsis: Scan-ahead up to P1 rows */
17555
-#define OP_SeekHit 126 /* synopsis: set P2<=seekHit<=P3 */
17556
-#define OP_Sequence 127 /* synopsis: r[P2]=cursor[P1].ctr++ */
17557
-#define OP_NewRowid 128 /* synopsis: r[P2]=rowid */
17558
-#define OP_Insert 129 /* synopsis: intkey=r[P3] data=r[P2] */
17559
-#define OP_RowCell 130
17560
-#define OP_Delete 131
17561
-#define OP_ResetCount 132
17562
-#define OP_SorterCompare 133 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
17563
-#define OP_SorterData 134 /* synopsis: r[P2]=data */
17564
-#define OP_RowData 135 /* synopsis: r[P2]=data */
17565
-#define OP_Rowid 136 /* synopsis: r[P2]=PX rowid of P1 */
17566
-#define OP_NullRow 137
17567
-#define OP_SeekEnd 138
17568
-#define OP_IdxInsert 139 /* synopsis: key=r[P2] */
17569
-#define OP_SorterInsert 140 /* synopsis: key=r[P2] */
17570
-#define OP_IdxDelete 141 /* synopsis: key=r[P2@P3] */
17571
-#define OP_DeferredSeek 142 /* synopsis: Move P3 to P1.rowid if needed */
17572
-#define OP_IdxRowid 143 /* synopsis: r[P2]=rowid */
17573
-#define OP_FinishSeek 144
17574
-#define OP_Destroy 145
17575
-#define OP_Clear 146
17576
-#define OP_ResetSorter 147
17577
-#define OP_CreateBtree 148 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
17578
-#define OP_SqlExec 149
17579
-#define OP_ParseSchema 150
17580
-#define OP_LoadAnalysis 151
17581
-#define OP_DropTable 152
17582
-#define OP_DropIndex 153
17548
+#define OP_OpenAutoindex 119 /* synopsis: nColumn=P2 */
17549
+#define OP_OpenEphemeral 120 /* synopsis: nColumn=P2 */
17550
+#define OP_SorterOpen 121
17551
+#define OP_SequenceTest 122 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
17552
+#define OP_OpenPseudo 123 /* synopsis: P3 columns in r[P2] */
17553
+#define OP_Close 124
17554
+#define OP_ColumnsUsed 125
17555
+#define OP_SeekScan 126 /* synopsis: Scan-ahead up to P1 rows */
17556
+#define OP_SeekHit 127 /* synopsis: set P2<=seekHit<=P3 */
17557
+#define OP_Sequence 128 /* synopsis: r[P2]=cursor[P1].ctr++ */
17558
+#define OP_NewRowid 129 /* synopsis: r[P2]=rowid */
17559
+#define OP_Insert 130 /* synopsis: intkey=r[P3] data=r[P2] */
17560
+#define OP_RowCell 131
17561
+#define OP_Delete 132
17562
+#define OP_ResetCount 133
17563
+#define OP_SorterCompare 134 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
17564
+#define OP_SorterData 135 /* synopsis: r[P2]=data */
17565
+#define OP_RowData 136 /* synopsis: r[P2]=data */
17566
+#define OP_Rowid 137 /* synopsis: r[P2]=PX rowid of P1 */
17567
+#define OP_NullRow 138
17568
+#define OP_SeekEnd 139
17569
+#define OP_IdxInsert 140 /* synopsis: key=r[P2] */
17570
+#define OP_SorterInsert 141 /* synopsis: key=r[P2] */
17571
+#define OP_IdxDelete 142 /* synopsis: key=r[P2@P3] */
17572
+#define OP_DeferredSeek 143 /* synopsis: Move P3 to P1.rowid if needed */
17573
+#define OP_IdxRowid 144 /* synopsis: r[P2]=rowid */
17574
+#define OP_FinishSeek 145
17575
+#define OP_Destroy 146
17576
+#define OP_Clear 147
17577
+#define OP_ResetSorter 148
17578
+#define OP_CreateBtree 149 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
17579
+#define OP_SqlExec 150
17580
+#define OP_ParseSchema 151
17581
+#define OP_LoadAnalysis 152
17582
+#define OP_DropTable 153
1758317583
#define OP_Real 154 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
17584
-#define OP_DropTrigger 155
17585
-#define OP_IntegrityCk 156
17586
-#define OP_RowSetAdd 157 /* synopsis: rowset(P1)=r[P2] */
17587
-#define OP_Param 158
17588
-#define OP_FkCounter 159 /* synopsis: fkctr[P1]+=P2 */
17589
-#define OP_MemMax 160 /* synopsis: r[P1]=max(r[P1],r[P2]) */
17590
-#define OP_OffsetLimit 161 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
17591
-#define OP_AggInverse 162 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
17592
-#define OP_AggStep 163 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17593
-#define OP_AggStep1 164 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17594
-#define OP_AggValue 165 /* synopsis: r[P3]=value N=P2 */
17595
-#define OP_AggFinal 166 /* synopsis: accum=r[P1] N=P2 */
17596
-#define OP_Expire 167
17597
-#define OP_CursorLock 168
17598
-#define OP_CursorUnlock 169
17599
-#define OP_TableLock 170 /* synopsis: iDb=P1 root=P2 write=P3 */
17600
-#define OP_VBegin 171
17601
-#define OP_VCreate 172
17602
-#define OP_VDestroy 173
17603
-#define OP_VOpen 174
17604
-#define OP_VCheck 175
17605
-#define OP_VInitIn 176 /* synopsis: r[P2]=ValueList(P1,P3) */
17606
-#define OP_VColumn 177 /* synopsis: r[P3]=vcolumn(P2) */
17607
-#define OP_VRename 178
17608
-#define OP_Pagecount 179
17609
-#define OP_MaxPgcnt 180
17610
-#define OP_ClrSubtype 181 /* synopsis: r[P1].subtype = 0 */
17611
-#define OP_GetSubtype 182 /* synopsis: r[P2] = r[P1].subtype */
17612
-#define OP_SetSubtype 183 /* synopsis: r[P2].subtype = r[P1] */
17613
-#define OP_FilterAdd 184 /* synopsis: filter(P1) += key(P3@P4) */
17614
-#define OP_Trace 185
17615
-#define OP_CursorHint 186
17616
-#define OP_ReleaseReg 187 /* synopsis: release r[P1@P2] mask P3 */
17617
-#define OP_Noop 188
17618
-#define OP_Explain 189
17619
-#define OP_Abortable 190
17584
+#define OP_DropIndex 155
17585
+#define OP_DropTrigger 156
17586
+#define OP_IntegrityCk 157
17587
+#define OP_RowSetAdd 158 /* synopsis: rowset(P1)=r[P2] */
17588
+#define OP_Param 159
17589
+#define OP_FkCounter 160 /* synopsis: fkctr[P1]+=P2 */
17590
+#define OP_MemMax 161 /* synopsis: r[P1]=max(r[P1],r[P2]) */
17591
+#define OP_OffsetLimit 162 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
17592
+#define OP_AggInverse 163 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
17593
+#define OP_AggStep 164 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17594
+#define OP_AggStep1 165 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17595
+#define OP_AggValue 166 /* synopsis: r[P3]=value N=P2 */
17596
+#define OP_AggFinal 167 /* synopsis: accum=r[P1] N=P2 */
17597
+#define OP_Expire 168
17598
+#define OP_CursorLock 169
17599
+#define OP_CursorUnlock 170
17600
+#define OP_TableLock 171 /* synopsis: iDb=P1 root=P2 write=P3 */
17601
+#define OP_VBegin 172
17602
+#define OP_VCreate 173
17603
+#define OP_VDestroy 174
17604
+#define OP_VOpen 175
17605
+#define OP_VCheck 176
17606
+#define OP_VInitIn 177 /* synopsis: r[P2]=ValueList(P1,P3) */
17607
+#define OP_VColumn 178 /* synopsis: r[P3]=vcolumn(P2) */
17608
+#define OP_VRename 179
17609
+#define OP_Pagecount 180
17610
+#define OP_MaxPgcnt 181
17611
+#define OP_ClrSubtype 182 /* synopsis: r[P1].subtype = 0 */
17612
+#define OP_GetSubtype 183 /* synopsis: r[P2] = r[P1].subtype */
17613
+#define OP_SetSubtype 184 /* synopsis: r[P2].subtype = r[P1] */
17614
+#define OP_FilterAdd 185 /* synopsis: filter(P1) += key(P3@P4) */
17615
+#define OP_Trace 186
17616
+#define OP_CursorHint 187
17617
+#define OP_ReleaseReg 188 /* synopsis: release r[P1@P2] mask P3 */
17618
+#define OP_Noop 189
17619
+#define OP_Explain 190
17620
+#define OP_Abortable 191
1762017621
1762117622
/* Properties such as "out2" or "jump" that are specified in
1762217623
** comments following the "case" for each opcode in the vdbe.c
1762317624
** are encoded into bitvectors as follows:
1762417625
*/
@@ -17634,37 +17635,38 @@
1763417635
/* 0 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x41, 0x00,\
1763517636
/* 8 */ 0x81, 0x01, 0x01, 0x81, 0x83, 0x83, 0x01, 0x01,\
1763617637
/* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0xc9, 0xc9, 0xc9,\
1763717638
/* 24 */ 0xc9, 0x01, 0x49, 0x49, 0x49, 0x49, 0xc9, 0x49,\
1763817639
/* 32 */ 0xc1, 0x01, 0x41, 0x41, 0xc1, 0x01, 0x01, 0x41,\
17639
-/* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x41, 0x23,\
17640
-/* 48 */ 0x0b, 0x81, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\
17641
-/* 56 */ 0x0b, 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x03, 0x01,\
17642
-/* 64 */ 0x41, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00,\
17643
-/* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10,\
17644
-/* 80 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02,\
17645
-/* 88 */ 0x02, 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x40,\
17646
-/* 96 */ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x26,\
17640
+/* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x41, 0x09,\
17641
+/* 48 */ 0x23, 0x0b, 0x81, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\
17642
+/* 56 */ 0x0b, 0x0b, 0x0b, 0x01, 0x01, 0x03, 0x03, 0x03,\
17643
+/* 64 */ 0x01, 0x41, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08,\
17644
+/* 72 */ 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10,\
17645
+/* 80 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
17646
+/* 88 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20,\
17647
+/* 96 */ 0x40, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x26,\
1764717648
/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
17648
-/* 112 */ 0x26, 0x40, 0x00, 0x12, 0x40, 0x40, 0x10, 0x40,\
17649
-/* 120 */ 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x40, 0x10,\
17650
-/* 128 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,\
17651
-/* 136 */ 0x50, 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50,\
17652
-/* 144 */ 0x40, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\
17653
-/* 152 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00,\
17654
-/* 160 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
17655
-/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10,\
17656
-/* 176 */ 0x50, 0x40, 0x00, 0x10, 0x10, 0x02, 0x12, 0x12,\
17657
-/* 184 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}
17649
+/* 112 */ 0x26, 0x40, 0x40, 0x12, 0x00, 0x40, 0x10, 0x40,\
17650
+/* 120 */ 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x40,\
17651
+/* 128 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,\
17652
+/* 136 */ 0x00, 0x50, 0x00, 0x40, 0x04, 0x04, 0x00, 0x40,\
17653
+/* 144 */ 0x50, 0x40, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00,\
17654
+/* 152 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x06, 0x10,\
17655
+/* 160 */ 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00,\
17656
+/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,\
17657
+/* 176 */ 0x10, 0x50, 0x40, 0x00, 0x10, 0x10, 0x02, 0x12,\
17658
+/* 184 */ 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
17659
+}
1765817660
1765917661
/* The resolve3P2Values() routine is able to run faster if it knows
1766017662
** the value of the largest JUMP opcode. The smaller the maximum
1766117663
** JUMP opcode the better, so the mkopcodeh.tcl script that
1766217664
** generated this include file strives to group all JUMP opcodes
1766317665
** together near the beginning of the list.
1766417666
*/
17665
-#define SQLITE_MX_JUMP_OPCODE 65 /* Maximum JUMP opcode */
17667
+#define SQLITE_MX_JUMP_OPCODE 66 /* Maximum JUMP opcode */
1766617668
1766717669
/************** End of opcodes.h *********************************************/
1766817670
/************** Continuing where we left off in vdbe.h ***********************/
1766917671
1767017672
/*
@@ -24682,10 +24684,11 @@
2468224684
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
2468324685
SQLITE_PRIVATE void sqlite3VdbePreUpdateHook(
2468424686
Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int,int);
2468524687
#endif
2468624688
SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p);
24689
+SQLITE_PRIVATE int sqlite3VdbeFindIndexKey(BtCursor*, Index*, UnpackedRecord*, int*, int);
2468724690
2468824691
SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *);
2468924692
SQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *);
2469024693
SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
2469124694
SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
@@ -35367,10 +35370,11 @@
3536735370
}else{
3536835371
assert( p->id!=0 && p->id!=GetCurrentThreadId() );
3536935372
rc = sqlite3Win32Wait((HANDLE)p->tid);
3537035373
assert( rc!=WAIT_IO_COMPLETION );
3537135374
bRc = CloseHandle((HANDLE)p->tid);
35375
+ (void)bRc; /* Prevent warning when assert() is a no-op */
3537235376
assert( bRc );
3537335377
}
3537435378
if( rc==WAIT_OBJECT_0 ) *ppOut = p->pResult;
3537535379
sqlite3_free(p);
3537635380
return (rc==WAIT_OBJECT_0) ? SQLITE_OK : SQLITE_ERROR;
@@ -36507,32 +36511,72 @@
3650736511
}
3650836512
return h;
3650936513
}
3651036514
3651136515
/*
36512
-** Two inputs are multiplied to get a 128-bit result. Return
36513
-** the high-order 64 bits of that result.
36516
+** Two inputs are multiplied to get a 128-bit result. Write the
36517
+** lower 64-bits of the result into *pLo, and return the high-order
36518
+** 64 bits.
3651436519
*/
36515
-static u64 sqlite3Multiply128(u64 a, u64 b){
36520
+static u64 sqlite3Multiply128(u64 a, u64 b, u64 *pLo){
3651636521
#if (defined(__GNUC__) || defined(__clang__)) \
3651736522
&& (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv))
36518
- return ((__uint128_t)a * b) >> 64;
36523
+ __uint128_t r = (__uint128_t)a * b;
36524
+ *pLo = (u64)r;
36525
+ return (u64)(r>>64);
3651936526
#elif defined(_MSC_VER) && defined(_M_X64)
36527
+ *pLo = a*b;
3652036528
return __umulh(a, b);
3652136529
#else
36522
- u64 a1 = (u32)a;
36523
- u64 a2 = a >> 32;
36524
- u64 b1 = (u32)b;
36525
- u64 b2 = b >> 32;
36526
- u64 p0 = a1 * b1;
36527
- u64 p1 = a1 * b2;
36528
- u64 p2 = a2 * b1;
36529
- u64 p3 = a2 * b2;
36530
- u64 carry = ((p0 >> 32) + (u32)p1 + (u32)p2) >> 32;
36531
- return p3 + (p1 >> 32) + (p2 >> 32) + carry;
36530
+ u64 a0 = (u32)a;
36531
+ u64 a1 = a >> 32;
36532
+ u64 b0 = (u32)b;
36533
+ u64 b1 = b >> 32;
36534
+ u64 a0b0 = a0 * b0;
36535
+ u64 a1b1 = a1 * b1;
36536
+ u64 a0b1 = a0 * b1;
36537
+ u64 a1b0 = a1 * b0;
36538
+ u64 t = (a0b0 >> 32) + (u32)a0b1 + (u32)a1b0;
36539
+ *pLo = (a0b0 & UINT64_C(0xffffffff)) | (t << 32);
36540
+ return a1b1 + (a0b1>>32) + (a1b0>>32) + (t>>32);
3653236541
#endif
3653336542
}
36543
+
36544
+/*
36545
+** A is an unsigned 96-bit integer formed by (a<<32)+aLo.
36546
+** B is an unsigned 64-bit integer.
36547
+**
36548
+** Compute the upper 96 bits of 160-bit result of A*B.
36549
+**
36550
+** Write ((A*B)>>64 & 0xffffffff) (the middle 32 bits of A*B)
36551
+** into *pLo. Return the upper 64 bits of A*B.
36552
+**
36553
+** The lower 64 bits of A*B are discarded.
36554
+*/
36555
+static u64 sqlite3Multiply160(u64 a, u32 aLo, u64 b, u32 *pLo){
36556
+ u64 x2 = a>>32;
36557
+ u64 x1 = a&0xffffffff;
36558
+ u64 x0 = aLo;
36559
+ u64 y1 = b>>32;
36560
+ u64 y0 = b&0xffffffff;
36561
+ u64 x2y1 = x2*y1;
36562
+ u64 r4 = x2y1>>32;
36563
+ u64 x2y0 = x2*y0;
36564
+ u64 x1y1 = x1*y1;
36565
+ u64 r3 = (x2y1 & 0xffffffff) + (x2y0 >>32) + (x1y1 >>32);
36566
+ u64 x1y0 = x1*y0;
36567
+ u64 x0y1 = x0*y1;
36568
+ u64 r2 = (x2y0 & 0xffffffff) + (x1y1 & 0xffffffff) +
36569
+ (x1y0 >>32) + (x0y1>>32);
36570
+ u64 x0y0 = x0*y0;
36571
+ u64 r1 = (x1y0 & 0xffffffff) + (x0y1 & 0xffffffff) +
36572
+ (x0y0 >>32);
36573
+ r2 += r1>>32;
36574
+ r3 += r2>>32;
36575
+ *pLo = r2&0xffffffff;
36576
+ return (r4<<32) + r3;
36577
+}
3653436578
3653536579
/*
3653636580
** Return a u64 with the N-th bit set.
3653736581
*/
3653836582
#define U64_BIT(N) (((u64)1)<<(N))
@@ -36552,102 +36596,145 @@
3655236596
** Or, in other words, for any p in range, return the most significant
3655336597
** 64 bits of pow(10,p). The pow(10,p) value is shifted left or right,
3655436598
** as appropriate so the most significant 64 bits fit exactly into a
3655536599
** 64-bit unsigned integer.
3655636600
**
36601
+** Write into *pLo the next 32 significant bits of the answer after
36602
+** the first 64.
36603
+**
3655736604
** Algorithm:
3655836605
**
3655936606
** (1) For p between 0 and 26, return the value directly from the aBase[]
3656036607
** lookup table.
3656136608
**
3656236609
** (2) For p outside the range 0 to 26, use aScale[] for the initial value
3656336610
** then refine that result (if necessary) by a single multiplication
3656436611
** against aBase[].
36612
+**
36613
+** The constant tables aBase[], aScale[], and aScaleLo[] are generated
36614
+** by the C program at ../tool/mkfptab.c run with the --round option.
3656536615
*/
36566
-static u64 powerOfTen(int p){
36616
+static u64 powerOfTen(int p, u32 *pLo){
3656736617
static const u64 aBase[] = {
36568
- 0x8000000000000000LLU, /* 0: 1.0e+0 << 63 */
36569
- 0xa000000000000000LLU, /* 1: 1.0e+1 << 60 */
36570
- 0xc800000000000000LLU, /* 2: 1.0e+2 << 57 */
36571
- 0xfa00000000000000LLU, /* 3: 1.0e+3 << 54 */
36572
- 0x9c40000000000000LLU, /* 4: 1.0e+4 << 50 */
36573
- 0xc350000000000000LLU, /* 5: 1.0e+5 << 47 */
36574
- 0xf424000000000000LLU, /* 6: 1.0e+6 << 44 */
36575
- 0x9896800000000000LLU, /* 7: 1.0e+7 << 40 */
36576
- 0xbebc200000000000LLU, /* 8: 1.0e+8 << 37 */
36577
- 0xee6b280000000000LLU, /* 9: 1.0e+9 << 34 */
36578
- 0x9502f90000000000LLU, /* 10: 1.0e+10 << 30 */
36579
- 0xba43b74000000000LLU, /* 11: 1.0e+11 << 27 */
36580
- 0xe8d4a51000000000LLU, /* 12: 1.0e+12 << 24 */
36581
- 0x9184e72a00000000LLU, /* 13: 1.0e+13 << 20 */
36582
- 0xb5e620f480000000LLU, /* 14: 1.0e+14 << 17 */
36583
- 0xe35fa931a0000000LLU, /* 15: 1.0e+15 << 14 */
36584
- 0x8e1bc9bf04000000LLU, /* 16: 1.0e+16 << 10 */
36585
- 0xb1a2bc2ec5000000LLU, /* 17: 1.0e+17 << 7 */
36586
- 0xde0b6b3a76400000LLU, /* 18: 1.0e+18 << 4 */
36587
- 0x8ac7230489e80000LLU, /* 19: 1.0e+19 >> 0 */
36588
- 0xad78ebc5ac620000LLU, /* 20: 1.0e+20 >> 3 */
36589
- 0xd8d726b7177a8000LLU, /* 21: 1.0e+21 >> 6 */
36590
- 0x878678326eac9000LLU, /* 22: 1.0e+22 >> 10 */
36591
- 0xa968163f0a57b400LLU, /* 23: 1.0e+23 >> 13 */
36592
- 0xd3c21bcecceda100LLU, /* 24: 1.0e+24 >> 16 */
36593
- 0x84595161401484a0LLU, /* 25: 1.0e+25 >> 20 */
36594
- 0xa56fa5b99019a5c8LLU, /* 26: 1.0e+26 >> 23 */
36618
+ UINT64_C(0x8000000000000000), /* 0: 1.0e+0 << 63 */
36619
+ UINT64_C(0xa000000000000000), /* 1: 1.0e+1 << 60 */
36620
+ UINT64_C(0xc800000000000000), /* 2: 1.0e+2 << 57 */
36621
+ UINT64_C(0xfa00000000000000), /* 3: 1.0e+3 << 54 */
36622
+ UINT64_C(0x9c40000000000000), /* 4: 1.0e+4 << 50 */
36623
+ UINT64_C(0xc350000000000000), /* 5: 1.0e+5 << 47 */
36624
+ UINT64_C(0xf424000000000000), /* 6: 1.0e+6 << 44 */
36625
+ UINT64_C(0x9896800000000000), /* 7: 1.0e+7 << 40 */
36626
+ UINT64_C(0xbebc200000000000), /* 8: 1.0e+8 << 37 */
36627
+ UINT64_C(0xee6b280000000000), /* 9: 1.0e+9 << 34 */
36628
+ UINT64_C(0x9502f90000000000), /* 10: 1.0e+10 << 30 */
36629
+ UINT64_C(0xba43b74000000000), /* 11: 1.0e+11 << 27 */
36630
+ UINT64_C(0xe8d4a51000000000), /* 12: 1.0e+12 << 24 */
36631
+ UINT64_C(0x9184e72a00000000), /* 13: 1.0e+13 << 20 */
36632
+ UINT64_C(0xb5e620f480000000), /* 14: 1.0e+14 << 17 */
36633
+ UINT64_C(0xe35fa931a0000000), /* 15: 1.0e+15 << 14 */
36634
+ UINT64_C(0x8e1bc9bf04000000), /* 16: 1.0e+16 << 10 */
36635
+ UINT64_C(0xb1a2bc2ec5000000), /* 17: 1.0e+17 << 7 */
36636
+ UINT64_C(0xde0b6b3a76400000), /* 18: 1.0e+18 << 4 */
36637
+ UINT64_C(0x8ac7230489e80000), /* 19: 1.0e+19 >> 0 */
36638
+ UINT64_C(0xad78ebc5ac620000), /* 20: 1.0e+20 >> 3 */
36639
+ UINT64_C(0xd8d726b7177a8000), /* 21: 1.0e+21 >> 6 */
36640
+ UINT64_C(0x878678326eac9000), /* 22: 1.0e+22 >> 10 */
36641
+ UINT64_C(0xa968163f0a57b400), /* 23: 1.0e+23 >> 13 */
36642
+ UINT64_C(0xd3c21bcecceda100), /* 24: 1.0e+24 >> 16 */
36643
+ UINT64_C(0x84595161401484a0), /* 25: 1.0e+25 >> 20 */
36644
+ UINT64_C(0xa56fa5b99019a5c8), /* 26: 1.0e+26 >> 23 */
3659536645
};
3659636646
static const u64 aScale[] = {
36597
- 0x8049a4ac0c5811aeLLU, /* 0: 1.0e-351 << 1229 */
36598
- 0xcf42894a5dce35eaLLU, /* 1: 1.0e-324 << 1140 */
36599
- 0xa76c582338ed2622LLU, /* 2: 1.0e-297 << 1050 */
36600
- 0x873e4f75e2224e68LLU, /* 3: 1.0e-270 << 960 */
36601
- 0xda7f5bf590966849LLU, /* 4: 1.0e-243 << 871 */
36602
- 0xb080392cc4349dedLLU, /* 5: 1.0e-216 << 781 */
36603
- 0x8e938662882af53eLLU, /* 6: 1.0e-189 << 691 */
36604
- 0xe65829b3046b0afaLLU, /* 7: 1.0e-162 << 602 */
36605
- 0xba121a4650e4ddecLLU, /* 8: 1.0e-135 << 512 */
36606
- 0x964e858c91ba2655LLU, /* 9: 1.0e-108 << 422 */
36607
- 0xf2d56790ab41c2a3LLU, /* 10: 1.0e-81 << 333 */
36608
- 0xc428d05aa4751e4dLLU, /* 11: 1.0e-54 << 243 */
36609
- 0x9e74d1b791e07e48LLU, /* 12: 1.0e-27 << 153 */
36610
- 0x8000000000000000LLU, /* 13: 1.0e+0 << 63 */
36611
- 0xcecb8f27f4200f3aLLU, /* 14: 1.0e+27 >> 26 */
36612
- 0xa70c3c40a64e6c52LLU, /* 15: 1.0e+54 >> 116 */
36613
- 0x86f0ac99b4e8dafdLLU, /* 16: 1.0e+81 >> 206 */
36614
- 0xda01ee641a708deaLLU, /* 17: 1.0e+108 >> 295 */
36615
- 0xb01ae745b101e9e4LLU, /* 18: 1.0e+135 >> 385 */
36616
- 0x8e41ade9fbebc27dLLU, /* 19: 1.0e+162 >> 475 */
36617
- 0xe5d3ef282a242e82LLU, /* 20: 1.0e+189 >> 564 */
36618
- 0xb9a74a0637ce2ee1LLU, /* 21: 1.0e+216 >> 654 */
36619
- 0x95f83d0a1fb69cd9LLU, /* 22: 1.0e+243 >> 744 */
36620
- 0xf24a01a73cf2dcd0LLU, /* 23: 1.0e+270 >> 833 */
36621
- 0xc3b8358109e84f07LLU, /* 24: 1.0e+297 >> 923 */
36622
- 0x9e19db92b4e31ba9LLU, /* 25: 1.0e+324 >> 1013 */
36647
+ UINT64_C(0x8049a4ac0c5811ae), /* 0: 1.0e-351 << 1229 */
36648
+ UINT64_C(0xcf42894a5dce35ea), /* 1: 1.0e-324 << 1140 */
36649
+ UINT64_C(0xa76c582338ed2621), /* 2: 1.0e-297 << 1050 */
36650
+ UINT64_C(0x873e4f75e2224e68), /* 3: 1.0e-270 << 960 */
36651
+ UINT64_C(0xda7f5bf590966848), /* 4: 1.0e-243 << 871 */
36652
+ UINT64_C(0xb080392cc4349dec), /* 5: 1.0e-216 << 781 */
36653
+ UINT64_C(0x8e938662882af53e), /* 6: 1.0e-189 << 691 */
36654
+ UINT64_C(0xe65829b3046b0afa), /* 7: 1.0e-162 << 602 */
36655
+ UINT64_C(0xba121a4650e4ddeb), /* 8: 1.0e-135 << 512 */
36656
+ UINT64_C(0x964e858c91ba2655), /* 9: 1.0e-108 << 422 */
36657
+ UINT64_C(0xf2d56790ab41c2a2), /* 10: 1.0e-81 << 333 */
36658
+ UINT64_C(0xc428d05aa4751e4c), /* 11: 1.0e-54 << 243 */
36659
+ UINT64_C(0x9e74d1b791e07e48), /* 12: 1.0e-27 << 153 */
36660
+ UINT64_C(0xcccccccccccccccc), /* 13: 1.0e-1 << 67 (special case) */
36661
+ UINT64_C(0xcecb8f27f4200f3a), /* 14: 1.0e+27 >> 26 */
36662
+ UINT64_C(0xa70c3c40a64e6c51), /* 15: 1.0e+54 >> 116 */
36663
+ UINT64_C(0x86f0ac99b4e8dafd), /* 16: 1.0e+81 >> 206 */
36664
+ UINT64_C(0xda01ee641a708de9), /* 17: 1.0e+108 >> 295 */
36665
+ UINT64_C(0xb01ae745b101e9e4), /* 18: 1.0e+135 >> 385 */
36666
+ UINT64_C(0x8e41ade9fbebc27d), /* 19: 1.0e+162 >> 475 */
36667
+ UINT64_C(0xe5d3ef282a242e81), /* 20: 1.0e+189 >> 564 */
36668
+ UINT64_C(0xb9a74a0637ce2ee1), /* 21: 1.0e+216 >> 654 */
36669
+ UINT64_C(0x95f83d0a1fb69cd9), /* 22: 1.0e+243 >> 744 */
36670
+ UINT64_C(0xf24a01a73cf2dccf), /* 23: 1.0e+270 >> 833 */
36671
+ UINT64_C(0xc3b8358109e84f07), /* 24: 1.0e+297 >> 923 */
36672
+ UINT64_C(0x9e19db92b4e31ba9), /* 25: 1.0e+324 >> 1013 */
36673
+ };
36674
+ static const unsigned int aScaleLo[] = {
36675
+ 0x205b896d, /* 0: 1.0e-351 << 1229 */
36676
+ 0x52064cad, /* 1: 1.0e-324 << 1140 */
36677
+ 0xaf2af2b8, /* 2: 1.0e-297 << 1050 */
36678
+ 0x5a7744a7, /* 3: 1.0e-270 << 960 */
36679
+ 0xaf39a475, /* 4: 1.0e-243 << 871 */
36680
+ 0xbd8d794e, /* 5: 1.0e-216 << 781 */
36681
+ 0x547eb47b, /* 6: 1.0e-189 << 691 */
36682
+ 0x0cb4a5a3, /* 7: 1.0e-162 << 602 */
36683
+ 0x92f34d62, /* 8: 1.0e-135 << 512 */
36684
+ 0x3a6a07f9, /* 9: 1.0e-108 << 422 */
36685
+ 0xfae27299, /* 10: 1.0e-81 << 333 */
36686
+ 0xaa97e14c, /* 11: 1.0e-54 << 243 */
36687
+ 0x775ea265, /* 12: 1.0e-27 << 153 */
36688
+ 0xcccccccc, /* 13: 1.0e-1 << 67 (special case) */
36689
+ 0x00000000, /* 14: 1.0e+27 >> 26 */
36690
+ 0x999090b6, /* 15: 1.0e+54 >> 116 */
36691
+ 0x69a028bb, /* 16: 1.0e+81 >> 206 */
36692
+ 0xe80e6f48, /* 17: 1.0e+108 >> 295 */
36693
+ 0x5ec05dd0, /* 18: 1.0e+135 >> 385 */
36694
+ 0x14588f14, /* 19: 1.0e+162 >> 475 */
36695
+ 0x8f1668c9, /* 20: 1.0e+189 >> 564 */
36696
+ 0x6d953e2c, /* 21: 1.0e+216 >> 654 */
36697
+ 0x4abdaf10, /* 22: 1.0e+243 >> 744 */
36698
+ 0xbc633b39, /* 23: 1.0e+270 >> 833 */
36699
+ 0x0a862f81, /* 24: 1.0e+297 >> 923 */
36700
+ 0x6c07a2c2, /* 25: 1.0e+324 >> 1013 */
3662336701
};
3662436702
int g, n;
36625
- u64 x, y;
36703
+ u64 s, x;
36704
+ u32 lo;
3662636705
3662736706
assert( p>=POWERSOF10_FIRST && p<=POWERSOF10_LAST );
3662836707
if( p<0 ){
36708
+ if( p==(-1) ){
36709
+ *pLo = aScaleLo[13];
36710
+ return aScale[13];
36711
+ }
3662936712
g = p/27;
3663036713
n = p%27;
3663136714
if( n ){
3663236715
g--;
3663336716
n += 27;
3663436717
}
3663536718
}else if( p<27 ){
36719
+ *pLo = 0;
3663636720
return aBase[p];
3663736721
}else{
3663836722
g = p/27;
3663936723
n = p%27;
3664036724
}
36641
- y = aScale[g+13];
36725
+ s = aScale[g+13];
3664236726
if( n==0 ){
36643
- return y;
36727
+ *pLo = aScaleLo[g+13];
36728
+ return s;
3664436729
}
36645
- x = sqlite3Multiply128(aBase[n],y);
36730
+ x = sqlite3Multiply160(s,aScaleLo[g+13],aBase[n],&lo);
3664636731
if( (U64_BIT(63) & x)==0 ){
36647
- x = (x<<1)|1;
36732
+ x = x<<1 | ((lo>>31)&1);
36733
+ lo = (lo<<1) | 1;
3664836734
}
36735
+ *pLo = lo;
3664936736
return x;
3665036737
}
3665136738
3665236739
/*
3665336740
** pow10to2(x) computes floor(log2(pow(10,x))).
@@ -36696,14 +36783,15 @@
3669636783
** The input m is required to have its highest bit set. In other words,
3669736784
** m should be left-shifted, and e decremented, to maximize the value of m.
3669836785
*/
3669936786
static void sqlite3Fp2Convert10(u64 m, int e, int n, u64 *pD, int *pP){
3670036787
int p;
36701
- u64 h;
36788
+ u64 h, d1;
36789
+ u32 d2;
3670236790
assert( n>=1 && n<=18 );
3670336791
p = n - 1 - pwr2to10(e+63);
36704
- h = sqlite3Multiply128(m, powerOfTen(p));
36792
+ h = sqlite3Multiply128(m, powerOfTen(p,&d2), &d1);
3670536793
assert( -(e + pwr10to2(p) + 2) >= 0 );
3670636794
assert( -(e + pwr10to2(p) + 1) <= 63 );
3670736795
if( n==18 ){
3670836796
h >>= -(e + pwr10to2(p) + 2);
3670936797
*pD = (h + ((h<<1)&2))>>1;
@@ -36715,49 +36803,50 @@
3671536803
3671636804
/*
3671736805
** Return an IEEE754 floating point value that approximates d*pow(10,p).
3671836806
*/
3671936807
static double sqlite3Fp10Convert2(u64 d, int p){
36720
- u64 out;
36721
- int e1;
36722
- int lz;
36723
- int lp;
36724
- int x;
36725
- u64 h;
36808
+ int b, lp, e, adj, s;
36809
+ u32 pwr10l, mid1;
36810
+ u64 pwr10h, x, hi, lo, sticky, u, m;
3672636811
double r;
36727
- assert( (d & U64_BIT(63))==0 );
36728
- assert( d!=0 );
36729
- if( p<POWERSOF10_FIRST ){
36730
- return 0.0;
36731
- }
36732
- if( p>POWERSOF10_LAST ){
36733
- return INFINITY;
36734
- }
36735
- lz = countLeadingZeros(d);
36812
+ if( p<POWERSOF10_FIRST ) return 0.0;
36813
+ if( p>POWERSOF10_LAST ) return INFINITY;
36814
+ b = 64 - countLeadingZeros(d);
3673636815
lp = pwr10to2(p);
36737
- e1 = lz - (lp + 11);
36738
- if( e1>1074 ){
36739
- if( e1>=1130 ) return 0.0;
36740
- e1 = 1074;
36741
- }
36742
- h = sqlite3Multiply128(d<<lz, powerOfTen(p));
36743
- x = lz - (e1 + lp + 3);
36744
- assert( x >= 0 );
36745
- assert( x <= 63 );
36746
- out = h >> x;
36747
- if( out >= U64_BIT(55)-2 ){
36748
- out >>= 1;
36749
- e1--;
36750
- }
36751
- if( e1<=(-972) ){
36752
- return INFINITY;
36753
- }
36754
- out = (out + 2) >> 2;
36755
- if( (out & U64_BIT(52))!=0 ){
36756
- out = (out & ~U64_BIT(52)) | ((u64)(1075-e1)<<52);
36757
- }
36758
- memcpy(&r, &out, 8);
36816
+ e = 53 - b - lp;
36817
+ if( e > 1074 ){
36818
+ if( e>=1130 ) return 0.0;
36819
+ e = 1074;
36820
+ }
36821
+ s = -(e-(64-b) + lp + 3);
36822
+ pwr10h = powerOfTen(p, &pwr10l);
36823
+ if( pwr10l!=0 ){
36824
+ pwr10h++;
36825
+ pwr10l = ~pwr10l;
36826
+ }
36827
+ x = d<<(64-b);
36828
+ hi = sqlite3Multiply128(x,pwr10h,&lo);
36829
+ mid1 = lo>>32;
36830
+ sticky = 1;
36831
+ if( (hi & (U64_BIT(s)-1))==0 ) {
36832
+ u32 mid2 = sqlite3Multiply128(x,((u64)pwr10l)<<32,&lo)>>32;
36833
+ sticky = (mid1-mid2 > 1);
36834
+ hi -= mid1 < mid2;
36835
+ }
36836
+ u = (hi>>s) | sticky;
36837
+ adj = (u >= U64_BIT(55)-2);
36838
+ if( adj ){
36839
+ u = (u>>adj) | (u&1);
36840
+ e -= adj;
36841
+ }
36842
+ m = (u + 1 + ((u>>2)&1)) >> 2;
36843
+ if( e<=(-972) ) return INFINITY;
36844
+ if((m & U64_BIT(52)) != 0){
36845
+ m = (m & ~U64_BIT(52)) | ((u64)(1075-e)<<52);
36846
+ }
36847
+ memcpy(&r,&m,8);
3675936848
return r;
3676036849
}
3676136850
3676236851
/*
3676336852
** The string z[] is an text representation of a real number.
@@ -38424,66 +38513,66 @@
3842438513
/* 42 */ "IdxGT" OpHelp("key=r[P3@P4]"),
3842538514
/* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
3842638515
/* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
3842738516
/* 45 */ "IdxLT" OpHelp("key=r[P3@P4]"),
3842838517
/* 46 */ "IdxGE" OpHelp("key=r[P3@P4]"),
38429
- /* 47 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
38430
- /* 48 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
38431
- /* 49 */ "Program" OpHelp(""),
38432
- /* 50 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
38518
+ /* 47 */ "IFindKey" OpHelp(""),
38519
+ /* 48 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
38520
+ /* 49 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
38521
+ /* 50 */ "Program" OpHelp(""),
3843338522
/* 51 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
3843438523
/* 52 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
3843538524
/* 53 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
3843638525
/* 54 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
3843738526
/* 55 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
3843838527
/* 56 */ "Le" OpHelp("IF r[P3]<=r[P1]"),
3843938528
/* 57 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
3844038529
/* 58 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
3844138530
/* 59 */ "ElseEq" OpHelp(""),
38442
- /* 60 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
38443
- /* 61 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
38444
- /* 62 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
38445
- /* 63 */ "IncrVacuum" OpHelp(""),
38446
- /* 64 */ "VNext" OpHelp(""),
38447
- /* 65 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"),
38448
- /* 66 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"),
38449
- /* 67 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
38450
- /* 68 */ "Return" OpHelp(""),
38451
- /* 69 */ "EndCoroutine" OpHelp(""),
38452
- /* 70 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
38453
- /* 71 */ "Halt" OpHelp(""),
38454
- /* 72 */ "Integer" OpHelp("r[P2]=P1"),
38455
- /* 73 */ "Int64" OpHelp("r[P2]=P4"),
38456
- /* 74 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
38457
- /* 75 */ "BeginSubrtn" OpHelp("r[P2]=NULL"),
38458
- /* 76 */ "Null" OpHelp("r[P2..P3]=NULL"),
38459
- /* 77 */ "SoftNull" OpHelp("r[P1]=NULL"),
38460
- /* 78 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
38461
- /* 79 */ "Variable" OpHelp("r[P2]=parameter(P1)"),
38462
- /* 80 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
38463
- /* 81 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
38464
- /* 82 */ "SCopy" OpHelp("r[P2]=r[P1]"),
38465
- /* 83 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
38466
- /* 84 */ "FkCheck" OpHelp(""),
38467
- /* 85 */ "ResultRow" OpHelp("output=r[P1@P2]"),
38468
- /* 86 */ "CollSeq" OpHelp(""),
38469
- /* 87 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
38470
- /* 88 */ "RealAffinity" OpHelp(""),
38471
- /* 89 */ "Cast" OpHelp("affinity(r[P1])"),
38472
- /* 90 */ "Permutation" OpHelp(""),
38473
- /* 91 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
38474
- /* 92 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
38475
- /* 93 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
38476
- /* 94 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
38477
- /* 95 */ "Column" OpHelp("r[P3]=PX cursor P1 column P2"),
38478
- /* 96 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
38479
- /* 97 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
38480
- /* 98 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
38481
- /* 99 */ "Count" OpHelp("r[P2]=count()"),
38482
- /* 100 */ "ReadCookie" OpHelp(""),
38483
- /* 101 */ "SetCookie" OpHelp(""),
38484
- /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
38531
+ /* 60 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
38532
+ /* 61 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
38533
+ /* 62 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
38534
+ /* 63 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
38535
+ /* 64 */ "IncrVacuum" OpHelp(""),
38536
+ /* 65 */ "VNext" OpHelp(""),
38537
+ /* 66 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"),
38538
+ /* 67 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"),
38539
+ /* 68 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
38540
+ /* 69 */ "Return" OpHelp(""),
38541
+ /* 70 */ "EndCoroutine" OpHelp(""),
38542
+ /* 71 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
38543
+ /* 72 */ "Halt" OpHelp(""),
38544
+ /* 73 */ "Integer" OpHelp("r[P2]=P1"),
38545
+ /* 74 */ "Int64" OpHelp("r[P2]=P4"),
38546
+ /* 75 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
38547
+ /* 76 */ "BeginSubrtn" OpHelp("r[P2]=NULL"),
38548
+ /* 77 */ "Null" OpHelp("r[P2..P3]=NULL"),
38549
+ /* 78 */ "SoftNull" OpHelp("r[P1]=NULL"),
38550
+ /* 79 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
38551
+ /* 80 */ "Variable" OpHelp("r[P2]=parameter(P1)"),
38552
+ /* 81 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
38553
+ /* 82 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
38554
+ /* 83 */ "SCopy" OpHelp("r[P2]=r[P1]"),
38555
+ /* 84 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
38556
+ /* 85 */ "FkCheck" OpHelp(""),
38557
+ /* 86 */ "ResultRow" OpHelp("output=r[P1@P2]"),
38558
+ /* 87 */ "CollSeq" OpHelp(""),
38559
+ /* 88 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
38560
+ /* 89 */ "RealAffinity" OpHelp(""),
38561
+ /* 90 */ "Cast" OpHelp("affinity(r[P1])"),
38562
+ /* 91 */ "Permutation" OpHelp(""),
38563
+ /* 92 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
38564
+ /* 93 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
38565
+ /* 94 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
38566
+ /* 95 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
38567
+ /* 96 */ "Column" OpHelp("r[P3]=PX cursor P1 column P2"),
38568
+ /* 97 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
38569
+ /* 98 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
38570
+ /* 99 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
38571
+ /* 100 */ "Count" OpHelp("r[P2]=count()"),
38572
+ /* 101 */ "ReadCookie" OpHelp(""),
38573
+ /* 102 */ "SetCookie" OpHelp(""),
3848538574
/* 103 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
3848638575
/* 104 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
3848738576
/* 105 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
3848838577
/* 106 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
3848938578
/* 107 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -38490,88 +38579,89 @@
3849038579
/* 108 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
3849138580
/* 109 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
3849238581
/* 110 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
3849338582
/* 111 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
3849438583
/* 112 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
38495
- /* 113 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
38496
- /* 114 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
38584
+ /* 113 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
38585
+ /* 114 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
3849738586
/* 115 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
38498
- /* 116 */ "OpenDup" OpHelp(""),
38499
- /* 117 */ "OpenAutoindex" OpHelp("nColumn=P2"),
38587
+ /* 116 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
38588
+ /* 117 */ "OpenDup" OpHelp(""),
3850038589
/* 118 */ "String8" OpHelp("r[P2]='P4'"),
38501
- /* 119 */ "OpenEphemeral" OpHelp("nColumn=P2"),
38502
- /* 120 */ "SorterOpen" OpHelp(""),
38503
- /* 121 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
38504
- /* 122 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
38505
- /* 123 */ "Close" OpHelp(""),
38506
- /* 124 */ "ColumnsUsed" OpHelp(""),
38507
- /* 125 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
38508
- /* 126 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
38509
- /* 127 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
38510
- /* 128 */ "NewRowid" OpHelp("r[P2]=rowid"),
38511
- /* 129 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
38512
- /* 130 */ "RowCell" OpHelp(""),
38513
- /* 131 */ "Delete" OpHelp(""),
38514
- /* 132 */ "ResetCount" OpHelp(""),
38515
- /* 133 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
38516
- /* 134 */ "SorterData" OpHelp("r[P2]=data"),
38517
- /* 135 */ "RowData" OpHelp("r[P2]=data"),
38518
- /* 136 */ "Rowid" OpHelp("r[P2]=PX rowid of P1"),
38519
- /* 137 */ "NullRow" OpHelp(""),
38520
- /* 138 */ "SeekEnd" OpHelp(""),
38521
- /* 139 */ "IdxInsert" OpHelp("key=r[P2]"),
38522
- /* 140 */ "SorterInsert" OpHelp("key=r[P2]"),
38523
- /* 141 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
38524
- /* 142 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
38525
- /* 143 */ "IdxRowid" OpHelp("r[P2]=rowid"),
38526
- /* 144 */ "FinishSeek" OpHelp(""),
38527
- /* 145 */ "Destroy" OpHelp(""),
38528
- /* 146 */ "Clear" OpHelp(""),
38529
- /* 147 */ "ResetSorter" OpHelp(""),
38530
- /* 148 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
38531
- /* 149 */ "SqlExec" OpHelp(""),
38532
- /* 150 */ "ParseSchema" OpHelp(""),
38533
- /* 151 */ "LoadAnalysis" OpHelp(""),
38534
- /* 152 */ "DropTable" OpHelp(""),
38535
- /* 153 */ "DropIndex" OpHelp(""),
38590
+ /* 119 */ "OpenAutoindex" OpHelp("nColumn=P2"),
38591
+ /* 120 */ "OpenEphemeral" OpHelp("nColumn=P2"),
38592
+ /* 121 */ "SorterOpen" OpHelp(""),
38593
+ /* 122 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
38594
+ /* 123 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
38595
+ /* 124 */ "Close" OpHelp(""),
38596
+ /* 125 */ "ColumnsUsed" OpHelp(""),
38597
+ /* 126 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
38598
+ /* 127 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
38599
+ /* 128 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
38600
+ /* 129 */ "NewRowid" OpHelp("r[P2]=rowid"),
38601
+ /* 130 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
38602
+ /* 131 */ "RowCell" OpHelp(""),
38603
+ /* 132 */ "Delete" OpHelp(""),
38604
+ /* 133 */ "ResetCount" OpHelp(""),
38605
+ /* 134 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
38606
+ /* 135 */ "SorterData" OpHelp("r[P2]=data"),
38607
+ /* 136 */ "RowData" OpHelp("r[P2]=data"),
38608
+ /* 137 */ "Rowid" OpHelp("r[P2]=PX rowid of P1"),
38609
+ /* 138 */ "NullRow" OpHelp(""),
38610
+ /* 139 */ "SeekEnd" OpHelp(""),
38611
+ /* 140 */ "IdxInsert" OpHelp("key=r[P2]"),
38612
+ /* 141 */ "SorterInsert" OpHelp("key=r[P2]"),
38613
+ /* 142 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
38614
+ /* 143 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
38615
+ /* 144 */ "IdxRowid" OpHelp("r[P2]=rowid"),
38616
+ /* 145 */ "FinishSeek" OpHelp(""),
38617
+ /* 146 */ "Destroy" OpHelp(""),
38618
+ /* 147 */ "Clear" OpHelp(""),
38619
+ /* 148 */ "ResetSorter" OpHelp(""),
38620
+ /* 149 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
38621
+ /* 150 */ "SqlExec" OpHelp(""),
38622
+ /* 151 */ "ParseSchema" OpHelp(""),
38623
+ /* 152 */ "LoadAnalysis" OpHelp(""),
38624
+ /* 153 */ "DropTable" OpHelp(""),
3853638625
/* 154 */ "Real" OpHelp("r[P2]=P4"),
38537
- /* 155 */ "DropTrigger" OpHelp(""),
38538
- /* 156 */ "IntegrityCk" OpHelp(""),
38539
- /* 157 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
38540
- /* 158 */ "Param" OpHelp(""),
38541
- /* 159 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
38542
- /* 160 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
38543
- /* 161 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
38544
- /* 162 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
38545
- /* 163 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
38546
- /* 164 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
38547
- /* 165 */ "AggValue" OpHelp("r[P3]=value N=P2"),
38548
- /* 166 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
38549
- /* 167 */ "Expire" OpHelp(""),
38550
- /* 168 */ "CursorLock" OpHelp(""),
38551
- /* 169 */ "CursorUnlock" OpHelp(""),
38552
- /* 170 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
38553
- /* 171 */ "VBegin" OpHelp(""),
38554
- /* 172 */ "VCreate" OpHelp(""),
38555
- /* 173 */ "VDestroy" OpHelp(""),
38556
- /* 174 */ "VOpen" OpHelp(""),
38557
- /* 175 */ "VCheck" OpHelp(""),
38558
- /* 176 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
38559
- /* 177 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
38560
- /* 178 */ "VRename" OpHelp(""),
38561
- /* 179 */ "Pagecount" OpHelp(""),
38562
- /* 180 */ "MaxPgcnt" OpHelp(""),
38563
- /* 181 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"),
38564
- /* 182 */ "GetSubtype" OpHelp("r[P2] = r[P1].subtype"),
38565
- /* 183 */ "SetSubtype" OpHelp("r[P2].subtype = r[P1]"),
38566
- /* 184 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
38567
- /* 185 */ "Trace" OpHelp(""),
38568
- /* 186 */ "CursorHint" OpHelp(""),
38569
- /* 187 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
38570
- /* 188 */ "Noop" OpHelp(""),
38571
- /* 189 */ "Explain" OpHelp(""),
38572
- /* 190 */ "Abortable" OpHelp(""),
38626
+ /* 155 */ "DropIndex" OpHelp(""),
38627
+ /* 156 */ "DropTrigger" OpHelp(""),
38628
+ /* 157 */ "IntegrityCk" OpHelp(""),
38629
+ /* 158 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
38630
+ /* 159 */ "Param" OpHelp(""),
38631
+ /* 160 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
38632
+ /* 161 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
38633
+ /* 162 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
38634
+ /* 163 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
38635
+ /* 164 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
38636
+ /* 165 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
38637
+ /* 166 */ "AggValue" OpHelp("r[P3]=value N=P2"),
38638
+ /* 167 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
38639
+ /* 168 */ "Expire" OpHelp(""),
38640
+ /* 169 */ "CursorLock" OpHelp(""),
38641
+ /* 170 */ "CursorUnlock" OpHelp(""),
38642
+ /* 171 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
38643
+ /* 172 */ "VBegin" OpHelp(""),
38644
+ /* 173 */ "VCreate" OpHelp(""),
38645
+ /* 174 */ "VDestroy" OpHelp(""),
38646
+ /* 175 */ "VOpen" OpHelp(""),
38647
+ /* 176 */ "VCheck" OpHelp(""),
38648
+ /* 177 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
38649
+ /* 178 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
38650
+ /* 179 */ "VRename" OpHelp(""),
38651
+ /* 180 */ "Pagecount" OpHelp(""),
38652
+ /* 181 */ "MaxPgcnt" OpHelp(""),
38653
+ /* 182 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"),
38654
+ /* 183 */ "GetSubtype" OpHelp("r[P2] = r[P1].subtype"),
38655
+ /* 184 */ "SetSubtype" OpHelp("r[P2].subtype = r[P1]"),
38656
+ /* 185 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
38657
+ /* 186 */ "Trace" OpHelp(""),
38658
+ /* 187 */ "CursorHint" OpHelp(""),
38659
+ /* 188 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
38660
+ /* 189 */ "Noop" OpHelp(""),
38661
+ /* 190 */ "Explain" OpHelp(""),
38662
+ /* 191 */ "Abortable" OpHelp(""),
3857338663
};
3857438664
return azName[i];
3857538665
}
3857638666
#endif
3857738667
@@ -73855,11 +73945,11 @@
7385573945
MemPage *pPage, /* Page containing the cell */
7385673946
u8 *pCell, /* Pointer to the cell text. */
7385773947
CellInfo *pInfo /* Fill in this structure */
7385873948
){
7385973949
u8 *pIter; /* For scanning through pCell */
73860
- u32 nPayload; /* Number of bytes of cell payload */
73950
+ u64 nPayload; /* Number of bytes of cell payload */
7386173951
u64 iKey; /* Extracted Key value */
7386273952
7386373953
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
7386473954
assert( pPage->leaf==0 || pPage->leaf==1 );
7386573955
assert( pPage->intKeyLeaf );
@@ -73877,10 +73967,11 @@
7387773967
u8 *pEnd = &pIter[8];
7387873968
nPayload &= 0x7f;
7387973969
do{
7388073970
nPayload = (nPayload<<7) | (*++pIter & 0x7f);
7388173971
}while( (*pIter)>=0x80 && pIter<pEnd );
73972
+ nPayload &= 0xffffffff;
7388273973
}
7388373974
pIter++;
7388473975
7388573976
/* The next block of code is equivalent to:
7388673977
**
@@ -73920,15 +74011,14 @@
7392074011
}
7392174012
}
7392274013
pIter++;
7392374014
7392474015
pInfo->nKey = *(i64*)&iKey;
73925
- pInfo->nPayload = nPayload;
74016
+ pInfo->nPayload = (u32)nPayload;
7392674017
pInfo->pPayload = pIter;
7392774018
testcase( nPayload==pPage->maxLocal );
7392874019
testcase( nPayload==(u32)pPage->maxLocal+1 );
73929
- assert( nPayload>=0 );
7393074020
assert( pPage->maxLocal <= BT_MAX_LOCAL );
7393174021
if( nPayload<=pPage->maxLocal ){
7393274022
/* This is the (easy) common case where the entire payload fits
7393374023
** on the local page. No overflow is required.
7393474024
*/
@@ -89149,10 +89239,14 @@
8914989239
break;
8915089240
}
8915189241
case P4_TABLE: {
8915289242
zP4 = pOp->p4.pTab->zName;
8915389243
break;
89244
+ }
89245
+ case P4_INDEX: {
89246
+ zP4 = pOp->p4.pIdx->zName;
89247
+ break;
8915489248
}
8915589249
case P4_SUBRTNSIG: {
8915689250
SubrtnSig *pSig = pOp->p4.pSubrtnSig;
8915789251
sqlite3_str_appendf(&x, "subrtnsig:%d,%s", pSig->selId, pSig->zAff);
8915889252
break;
@@ -92539,10 +92633,227 @@
9253992633
v->expmask |= 0x80000000;
9254092634
}else{
9254192635
v->expmask |= ((u32)1 << (iVar-1));
9254292636
}
9254392637
}
92638
+
92639
+/*
92640
+** Helper function for vdbeIsMatchingIndexKey(). Return true if column
92641
+** iCol should be ignored when comparing a record with a record from
92642
+** an index on disk. The field should be ignored if:
92643
+**
92644
+** * the corresponding bit in mask is set, and
92645
+** * either:
92646
+** - bIntegrity is false, or
92647
+** - the two Mem values are both real values that differ by
92648
+** BTREE_ULPDISTORTION or fewer ULPs.
92649
+*/
92650
+static int vdbeSkipField(
92651
+ Bitmask mask, /* Mask of indexed expression fields */
92652
+ int iCol, /* Column of index being considered */
92653
+ Mem *pMem1, /* Expected index value */
92654
+ Mem *pMem2, /* Actual indexed value */
92655
+ int bIntegrity /* True if running PRAGMA integrity_check */
92656
+){
92657
+#define BTREE_ULPDISTORTION 2
92658
+ if( iCol>=BMS || (mask & MASKBIT(iCol))==0 ) return 0;
92659
+ if( bIntegrity==0 ) return 1;
92660
+ if( (pMem1->flags & MEM_Real) && (pMem2->flags & MEM_Real) ){
92661
+ u64 m1, m2;
92662
+ memcpy(&m1,&pMem1->u.r,8);
92663
+ memcpy(&m2,&pMem2->u.r,8);
92664
+ if( (m1<m2 ? m2-m1 : m1-m2) <= BTREE_ULPDISTORTION ){
92665
+ return 1;
92666
+ }
92667
+ }
92668
+ return 0;
92669
+}
92670
+
92671
+/*
92672
+** This function compares the unpacked record with the current key that
92673
+** cursor pCur points to. If bInt is false, all fields for which the
92674
+** corresponding bit in parameter "mask" is set are ignored. Or, if
92675
+** bInt is true, then a difference of BTREE_ULPDISTORTION or fewer ULPs
92676
+** in real values is overlooked for fields with the corresponding bit
92677
+** set in mask.
92678
+**
92679
+** Return the usual less than zero, zero, or greater than zero if the
92680
+** remaining fields of the cursor cursor key are less than, equal to or
92681
+** greater than those in (*p).
92682
+*/
92683
+static int vdbeIsMatchingIndexKey(
92684
+ BtCursor *pCur, /* Cursor open on index */
92685
+ int bInt, /* True for integrity_check-style search */
92686
+ Bitmask mask, /* Mask of columns to skip */
92687
+ UnpackedRecord *p, /* Index key being deleted */
92688
+ int *piRes /* 0 for a match, non-zero for not a match */
92689
+){
92690
+ u8 *aRec = 0;
92691
+ u32 nRec = 0;
92692
+ Mem mem;
92693
+ int rc = SQLITE_OK;
92694
+
92695
+ memset(&mem, 0, sizeof(mem));
92696
+ mem.enc = p->pKeyInfo->enc;
92697
+ mem.db = p->pKeyInfo->db;
92698
+ nRec = sqlite3BtreePayloadSize(pCur);
92699
+ if( nRec>0x7fffffff ){
92700
+ return SQLITE_CORRUPT_BKPT;
92701
+ }
92702
+
92703
+ /* Allocate 5 extra bytes at the end of the buffer. This allows the
92704
+ ** getVarint32() call below to read slightly past the end of the buffer
92705
+ ** if the record is corrupt. */
92706
+ aRec = sqlite3MallocZero(nRec+5);
92707
+ if( aRec==0 ){
92708
+ rc = SQLITE_NOMEM_BKPT;
92709
+ }else{
92710
+ rc = sqlite3BtreePayload(pCur, 0, nRec, aRec);
92711
+ }
92712
+
92713
+ if( rc==SQLITE_OK ){
92714
+ u32 szHdr = 0; /* Size of record header in bytes */
92715
+ u32 idxHdr = 0; /* Current index in header */
92716
+
92717
+ idxHdr = getVarint32(aRec, szHdr);
92718
+ if( szHdr>98307 ){
92719
+ rc = SQLITE_CORRUPT;
92720
+ }else{
92721
+ int res = 0; /* Result of this function call */
92722
+ u32 idxRec = szHdr; /* Index of next field in record body */
92723
+ int ii = 0; /* Iterator variable */
92724
+
92725
+ int nCol = p->pKeyInfo->nAllField;
92726
+ for(ii=0; ii<nCol && rc==SQLITE_OK; ii++){
92727
+ u32 iSerial = 0;
92728
+ int nSerial = 0;
92729
+
92730
+ if( idxHdr>=szHdr ){
92731
+ rc = SQLITE_CORRUPT_BKPT;
92732
+ break;
92733
+ }
92734
+ idxHdr += getVarint32(&aRec[idxHdr], iSerial);
92735
+ nSerial = sqlite3VdbeSerialTypeLen(iSerial);
92736
+ if( (idxRec+nSerial)>nRec ){
92737
+ rc = SQLITE_CORRUPT_BKPT;
92738
+ }else{
92739
+ sqlite3VdbeSerialGet(&aRec[idxRec], iSerial, &mem);
92740
+ if( vdbeSkipField(mask, ii, &p->aMem[ii], &mem, bInt)==0 ){
92741
+ res = sqlite3MemCompare(&mem, &p->aMem[ii], p->pKeyInfo->aColl[ii]);
92742
+ if( res!=0 ) break;
92743
+ }
92744
+ }
92745
+ idxRec += sqlite3VdbeSerialTypeLen(iSerial);
92746
+ }
92747
+
92748
+ *piRes = res;
92749
+ }
92750
+ }
92751
+
92752
+ sqlite3_free(aRec);
92753
+ return rc;
92754
+}
92755
+
92756
+/*
92757
+** This is called when the record in (*p) should be found in the index
92758
+** opened by cursor pCur, but was not. This may happen as part of a DELETE
92759
+** operation or an integrity check.
92760
+**
92761
+** One reason that an exact match was not found may be the EIIB bug - that
92762
+** a text-to-float conversion may have caused a real value in record (*p)
92763
+** to be slightly different from its counterpart on disk. This function
92764
+** attempts to find the right index record. If it does find the right
92765
+** record, it leaves *pCur pointing to it and sets (*pRes) to 0 before
92766
+** returning. Otherwise, (*pRes) is set to non-zero and an SQLite error
92767
+** code returned.
92768
+**
92769
+** The algorithm used to find the correct record is:
92770
+**
92771
+** * Scan up to BTREE_FDK_RANGE entries either side of the current entry.
92772
+** If parameter bIntegrity is false, then all fields that are indexed
92773
+** expressions or virtual table columns are omitted from the comparison.
92774
+** If bIntegrity is true, then small differences in real values in
92775
+** such fields are overlooked, but they are not omitted from the comparison
92776
+** altogether.
92777
+**
92778
+** * If the above fails to find an entry and bIntegrity is false, search
92779
+** the entire index.
92780
+*/
92781
+SQLITE_PRIVATE int sqlite3VdbeFindIndexKey(
92782
+ BtCursor *pCur,
92783
+ Index *pIdx,
92784
+ UnpackedRecord *p,
92785
+ int *pRes,
92786
+ int bIntegrity
92787
+){
92788
+#define BTREE_FDK_RANGE 10
92789
+ int nStep = 0;
92790
+ int res = 1;
92791
+ int rc = SQLITE_OK;
92792
+ int ii = 0;
92793
+
92794
+ /* Calculate a mask based on the first 64 columns of the index. The mask
92795
+ ** bit is set if the corresponding index field is either an expression
92796
+ ** or a virtual column of the table. */
92797
+ Bitmask mask = 0;
92798
+ for(ii=0; ii<MIN(pIdx->nColumn, BMS); ii++){
92799
+ int iCol = pIdx->aiColumn[ii];
92800
+ if( (iCol==XN_EXPR)
92801
+ || (iCol>=0 && (pIdx->pTable->aCol[iCol].colFlags & COLFLAG_VIRTUAL))
92802
+ ){
92803
+ mask |= MASKBIT(ii);
92804
+ }
92805
+ }
92806
+
92807
+ /* If the mask is 0 at this point, then the index contains no expressions
92808
+ ** or virtual columns. So do not search for a match - return so that the
92809
+ ** caller may declare the db corrupt immediately. Or, if mask is non-zero,
92810
+ ** proceed. */
92811
+ if( mask!=0 ){
92812
+
92813
+ /* Move the cursor back BTREE_FDK_RANGE entries. If this hits an EOF,
92814
+ ** position the cursor at the first entry in the index and set nStep
92815
+ ** to -1 so that the first loop below scans the entire index. Otherwise,
92816
+ ** set nStep to BTREE_FDK_RANGE*2 so that the first loop below scans
92817
+ ** just that many entries. */
92818
+ for(ii=0; sqlite3BtreeEof(pCur)==0 && ii<BTREE_FDK_RANGE; ii++){
92819
+ rc = sqlite3BtreePrevious(pCur, 0);
92820
+ }
92821
+ if( rc==SQLITE_DONE ){
92822
+ rc = sqlite3BtreeFirst(pCur, &res);
92823
+ nStep = -1;
92824
+ }else{
92825
+ nStep = BTREE_FDK_RANGE*2;
92826
+ }
92827
+
92828
+ /* This loop runs at most twice to search for a key with matching PK
92829
+ ** fields in the index. The second iteration always searches the entire
92830
+ ** index. The first iteration searches nStep entries starting with the
92831
+ ** current cursor entry if (nStep>=0), or the entire index if (nStep<0). */
92832
+ while( sqlite3BtreeCursorIsValidNN(pCur) ){
92833
+ for(ii=0; rc==SQLITE_OK && (ii<nStep || nStep<0); ii++){
92834
+ rc = vdbeIsMatchingIndexKey(pCur, bIntegrity, mask, p, &res);
92835
+ if( res==0 || rc!=SQLITE_OK ) break;
92836
+ rc = sqlite3BtreeNext(pCur, 0);
92837
+ }
92838
+ if( rc==SQLITE_DONE ){
92839
+ rc = SQLITE_OK;
92840
+ assert( res!=0 );
92841
+ }
92842
+ if( nStep<0 || rc!=SQLITE_OK || res==0 || bIntegrity ) break;
92843
+
92844
+ /* The first, non-exhaustive, search failed to find an entry with
92845
+ ** matching PK fields. So restart for an exhaustive search of the
92846
+ ** entire index. */
92847
+ nStep = -1;
92848
+ rc = sqlite3BtreeFirst(pCur, &res);
92849
+ }
92850
+ }
92851
+
92852
+ *pRes = res;
92853
+ return rc;
92854
+}
9254492855
9254592856
#ifndef SQLITE_OMIT_DATETIME_FUNCS
9254692857
/*
9254792858
** Cause a function to throw an error if it was call from OP_PureFunc
9254892859
** rather than OP_Function.
@@ -102274,16 +102585,18 @@
102274102585
rc = sqlite3VdbeSorterWrite(pC, pIn2);
102275102586
if( rc) goto abort_due_to_error;
102276102587
break;
102277102588
}
102278102589
102279
-/* Opcode: IdxDelete P1 P2 P3 * *
102590
+/* Opcode: IdxDelete P1 P2 P3 P4 *
102280102591
** Synopsis: key=r[P2@P3]
102281102592
**
102282102593
** The content of P3 registers starting at register P2 form
102283102594
** an unpacked index key. This opcode removes that entry from the
102284102595
** index opened by cursor P1.
102596
+**
102597
+** P4 is a pointer to an Index structure.
102285102598
**
102286102599
** Raise an SQLITE_CORRUPT_INDEX error if no matching index entry is found
102287102600
** and not in writable_schema mode.
102288102601
*/
102289102602
case OP_IdxDelete: {
@@ -102305,17 +102618,26 @@
102305102618
r.nField = (u16)pOp->p3;
102306102619
r.default_rc = 0;
102307102620
r.aMem = &aMem[pOp->p2];
102308102621
rc = sqlite3BtreeIndexMoveto(pCrsr, &r, &res);
102309102622
if( rc ) goto abort_due_to_error;
102310
- if( res==0 ){
102311
- rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
102312
- if( rc ) goto abort_due_to_error;
102313
- }else if( !sqlite3WritableSchema(db) ){
102314
- rc = sqlite3ReportError(SQLITE_CORRUPT_INDEX, __LINE__, "index corruption");
102315
- goto abort_due_to_error;
102623
+ if( res!=0 ){
102624
+ rc = sqlite3VdbeFindIndexKey(pCrsr, pOp->p4.pIdx, &r, &res, 0);
102625
+ if( rc!=SQLITE_OK ) goto abort_due_to_error;
102626
+ if( res!=0 ){
102627
+ if( !sqlite3WritableSchema(db) ){
102628
+ rc = sqlite3ReportError(
102629
+ SQLITE_CORRUPT_INDEX, __LINE__, "index corruption");
102630
+ goto abort_due_to_error;
102631
+ }
102632
+ pC->cacheStatus = CACHE_STALE;
102633
+ pC->seekResult = 0;
102634
+ break;
102635
+ }
102316102636
}
102637
+ rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
102638
+ if( rc ) goto abort_due_to_error;
102317102639
assert( pC->deferredMoveto==0 );
102318102640
pC->cacheStatus = CACHE_STALE;
102319102641
pC->seekResult = 0;
102320102642
break;
102321102643
}
@@ -102938,10 +103260,62 @@
102938103260
}
102939103261
UPDATE_MAX_BLOBSIZE(pIn1);
102940103262
sqlite3VdbeChangeEncoding(pIn1, encoding);
102941103263
goto check_for_interrupt;
102942103264
}
103265
+
103266
+/* Opcode: IFindKey P1 P2 P3 P4 *
103267
+**
103268
+** This instruction always follows an OP_Found with the same P1, P2 and P3
103269
+** values as this instruction and a non-zero P4 value. The P4 value to
103270
+** this opcode is of type P4_INDEX and contains a pointer to the Index
103271
+** object of for the index being searched.
103272
+**
103273
+** This opcode uses sqlite3VdbeFindIndexKey() to search around the current
103274
+** cursor location for an index key that exactly matches all fields that
103275
+** are not indexed expressions or references to VIRTUAL generated columns,
103276
+** and either exactly match or are real numbers that are within 2 ULPs of
103277
+** each other if the don't match.
103278
+**
103279
+** To put it another way, this opcode looks for nearby index entries that
103280
+** are very close to the search key, but which might have small differences
103281
+** in floating-point values that come via an expression.
103282
+**
103283
+** If no nearby alternative entry is found in cursor P1, then jump to P2.
103284
+** But if a close match is found, fall through.
103285
+**
103286
+** This opcode is used by PRAGMA integrity_check to help distinguish
103287
+** between truely corrupt indexes and expression indexes that are holding
103288
+** floating-point values that are off by one or two ULPs.
103289
+*/
103290
+case OP_IFindKey: { /* jump, in3 */
103291
+ VdbeCursor *pC;
103292
+ int res;
103293
+ UnpackedRecord r;
103294
+
103295
+ assert( pOp[-1].opcode==OP_Found );
103296
+ assert( pOp[-1].p1==pOp->p1 );
103297
+ assert( pOp[-1].p3==pOp->p3 );
103298
+ pC = p->apCsr[pOp->p1];
103299
+ assert( pOp->p4type==P4_INDEX );
103300
+ assert( pC->eCurType==CURTYPE_BTREE );
103301
+ assert( pC->uc.pCursor!=0 );
103302
+ assert( pC->isTable==0 );
103303
+
103304
+ memset(&r, 0, sizeof(r));
103305
+ r.aMem = &aMem[pOp->p3];
103306
+ r.nField = pOp->p4.pIdx->nColumn;
103307
+ r.pKeyInfo = pC->pKeyInfo;
103308
+
103309
+ rc = sqlite3VdbeFindIndexKey(pC->uc.pCursor, pOp->p4.pIdx, &r, &res, 1);
103310
+ if( rc || res!=0 ){
103311
+ rc = SQLITE_OK;
103312
+ goto jump_to_p2;
103313
+ }
103314
+ pC->nullRow = 0;
103315
+ break;
103316
+};
102943103317
#endif /* SQLITE_OMIT_INTEGRITY_CHECK */
102944103318
102945103319
/* Opcode: RowSetAdd P1 P2 * * *
102946103320
** Synopsis: rowset(P1)=r[P2]
102947103321
**
@@ -116950,11 +117324,11 @@
116950117324
#endif /* SQLITE_OMIT_CAST */
116951117325
case TK_IS:
116952117326
case TK_ISNOT:
116953117327
op = (op==TK_IS) ? TK_EQ : TK_NE;
116954117328
p5 = SQLITE_NULLEQ;
116955
- /* fall-through */
117329
+ /* no break */ deliberate_fall_through
116956117330
case TK_LT:
116957117331
case TK_LE:
116958117332
case TK_GT:
116959117333
case TK_GE:
116960117334
case TK_NE:
@@ -132751,11 +133125,13 @@
132751133125
if( iIdxCur+i==iIdxNoSeek ) continue;
132752133126
VdbeModuleComment((v, "GenRowIdxDel for %s", pIdx->zName));
132753133127
r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 1,
132754133128
&iPartIdxLabel, pPrior, r1);
132755133129
sqlite3VdbeAddOp3(v, OP_IdxDelete, iIdxCur+i, r1,
132756
- pIdx->uniqNotNull ? pIdx->nKeyCol : pIdx->nColumn);
133130
+ pIdx->uniqNotNull ? pIdx->nKeyCol : pIdx->nColumn
133131
+ );
133132
+ sqlite3VdbeChangeP4(v, -1, (const char*)pIdx, P4_INDEX);
132757133133
sqlite3ResolvePartIdxLabel(pParse, iPartIdxLabel);
132758133134
pPrior = pIdx;
132759133135
}
132760133136
}
132761133137
@@ -137652,11 +138028,10 @@
137652138028
137653138029
zFrom = pFKey->pFrom->zName;
137654138030
nFrom = sqlite3Strlen30(zFrom);
137655138031
137656138032
if( action==OE_Restrict ){
137657
- int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
137658138033
SrcList *pSrc;
137659138034
Expr *pRaise;
137660138035
137661138036
pRaise = sqlite3Expr(db, TK_STRING, "FOREIGN KEY constraint failed"),
137662138037
pRaise = sqlite3PExpr(pParse, TK_RAISE, pRaise, 0);
@@ -137663,14 +138038,14 @@
137663138038
if( pRaise ){
137664138039
pRaise->affExpr = OE_Abort;
137665138040
}
137666138041
pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
137667138042
if( pSrc ){
137668
- assert( pSrc->nSrc==1 );
137669
- pSrc->a[0].zName = sqlite3DbStrDup(db, zFrom);
137670
- assert( pSrc->a[0].fg.fixedSchema==0 && pSrc->a[0].fg.isSubquery==0 );
137671
- pSrc->a[0].u4.zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName);
138043
+ SrcItem *pItem = &pSrc->a[0];
138044
+ pItem->zName = sqlite3DbStrDup(db, zFrom);
138045
+ pItem->fg.fixedSchema = 1;
138046
+ pItem->u4.pSchema = pTab->pSchema;
137672138047
}
137673138048
pSelect = sqlite3SelectNew(pParse,
137674138049
sqlite3ExprListAppend(pParse, 0, pRaise),
137675138050
pSrc,
137676138051
pWhere,
@@ -137688,11 +138063,14 @@
137688138063
);
137689138064
if( pTrigger ){
137690138065
pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1];
137691138066
pStep->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
137692138067
if( pStep->pSrc ){
137693
- pStep->pSrc->a[0].zName = sqlite3DbStrNDup(db, zFrom, nFrom);
138068
+ SrcItem *pItem = &pStep->pSrc->a[0];
138069
+ pItem->zName = sqlite3DbStrNDup(db, zFrom, nFrom);
138070
+ pItem->u4.pSchema = pTab->pSchema;
138071
+ pItem->fg.fixedSchema = 1;
137694138072
}
137695138073
pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
137696138074
pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE);
137697138075
pStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
137698138076
if( pWhen ){
@@ -145777,20 +146155,32 @@
145777146155
r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
145778146156
pPrior, r1);
145779146157
pPrior = pIdx;
145780146158
sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1);/* increment entry count */
145781146159
/* Verify that an index entry exists for the current table row */
145782
- jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1,
146160
+ sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1,
145783146161
pIdx->nColumn); VdbeCoverage(v);
146162
+ jmp2 = sqlite3VdbeAddOp3(v, OP_IFindKey, iIdxCur+j, ckUniq, r1);
146163
+ VdbeCoverage(v);
146164
+ sqlite3VdbeChangeP4(v, -1, (const char*)pIdx, P4_INDEX);
146165
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
146166
+ sqlite3MPrintf(db, "index %s stores an imprecise floating-point "
146167
+ "value for row ", pIdx->zName),
146168
+ P4_DYNAMIC);
146169
+ sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);
146170
+ integrityCheckResultRow(v);
146171
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, ckUniq);
146172
+
146173
+ sqlite3VdbeJumpHere(v, jmp2);
145784146174
sqlite3VdbeLoadString(v, 3, "row ");
145785146175
sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);
145786146176
sqlite3VdbeLoadString(v, 4, " missing from index ");
145787146177
sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
145788146178
jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName);
145789146179
sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
145790146180
jmp4 = integrityCheckResultRow(v);
145791
- sqlite3VdbeJumpHere(v, jmp2);
146181
+ sqlite3VdbeResolveLabel(v, ckUniq);
145792146182
145793146183
/* The OP_IdxRowid opcode is an optimized version of OP_Column
145794146184
** that extracts the rowid off the end of the index record.
145795146185
** But it only works correctly if index record does not have
145796146186
** any extra bytes at the end. Verify that this is the case. */
@@ -165710,10 +166100,19 @@
165710166100
if( ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) ) continue;
165711166101
pSubWhere = sqlite3ExprAnd(pParse, pSubWhere,
165712166102
sqlite3ExprDup(pParse->db, pTerm->pExpr, 0));
165713166103
}
165714166104
}
166105
+ if( pLevel->iIdxCur ){
166106
+ /* pSubWhere may contain expressions that read from an index on the
166107
+ ** table on the RHS of the right join. All such expressions first test
166108
+ ** if the index is pointing at a NULL row, and if so, read from the
166109
+ ** table cursor instead. So ensure that the index cursor really is
166110
+ ** pointing at a NULL row here, so that no values are read from it during
166111
+ ** the scan of the RHS of the RIGHT join below. */
166112
+ sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);
166113
+ }
165715166114
pFrom = &uSrc.sSrc;
165716166115
pFrom->nSrc = 1;
165717166116
pFrom->nAlloc = 1;
165718166117
memcpy(&pFrom->a[0], pTabItem, sizeof(SrcItem));
165719166118
pFrom->a[0].fg.jointype = 0;
@@ -170153,15 +170552,20 @@
170153170552
** 1.002.001 t2.t2xy 2 f 010241 N 2 cost 0,56,31
170154170553
*/
170155170554
SQLITE_PRIVATE void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC){
170156170555
WhereInfo *pWInfo;
170157170556
if( pWC ){
170557
+ int nb;
170558
+ SrcItem *pItem;
170559
+ Table *pTab;
170560
+ Bitmask mAll;
170561
+
170158170562
pWInfo = pWC->pWInfo;
170159
- int nb = 1+(pWInfo->pTabList->nSrc+3)/4;
170160
- SrcItem *pItem = pWInfo->pTabList->a + p->iTab;
170161
- Table *pTab = pItem->pSTab;
170162
- Bitmask mAll = (((Bitmask)1)<<(nb*4)) - 1;
170563
+ nb = 1+(pWInfo->pTabList->nSrc+3)/4;
170564
+ pItem = pWInfo->pTabList->a + p->iTab;
170565
+ pTab = pItem->pSTab;
170566
+ mAll = (((Bitmask)1)<<(nb*4)) - 1;
170163170567
sqlite3DebugPrintf("%c%2d.%0*llx.%0*llx", p->cId,
170164170568
p->iTab, nb, p->maskSelf, nb, p->prereq & mAll);
170165170569
sqlite3DebugPrintf(" %12s",
170166170570
pItem->zAlias ? pItem->zAlias : pTab->zName);
170167170571
}else{
@@ -175258,19 +175662,26 @@
175258175662
&& (n = pLoop->u.btree.nDistinctCol)>0
175259175663
&& pIdx->aiRowLogEst[n]>=36
175260175664
){
175261175665
int r1 = pParse->nMem+1;
175262175666
int j, op;
175667
+ int addrIfNull = 0; /* Init to avoid false-positive compiler warning */
175668
+ if( pLevel->iLeftJoin ){
175669
+ addrIfNull = sqlite3VdbeAddOp2(v, OP_IfNullRow, pLevel->iIdxCur, r1);
175670
+ }
175263175671
for(j=0; j<n; j++){
175264175672
sqlite3VdbeAddOp3(v, OP_Column, pLevel->iIdxCur, j, r1+j);
175265175673
}
175266175674
pParse->nMem += n+1;
175267175675
op = pLevel->op==OP_Prev ? OP_SeekLT : OP_SeekGT;
175268175676
addrSeek = sqlite3VdbeAddOp4Int(v, op, pLevel->iIdxCur, 0, r1, n);
175269175677
VdbeCoverageIf(v, op==OP_SeekLT);
175270175678
VdbeCoverageIf(v, op==OP_SeekGT);
175271175679
sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2);
175680
+ if( pLevel->iLeftJoin ){
175681
+ sqlite3VdbeJumpHere(v, addrIfNull);
175682
+ }
175272175683
}
175273175684
#endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */
175274175685
}
175275175686
if( pTabList->a[pLevel->iFrom].fg.fromExists
175276175687
&& (i==pWInfo->nLevel-1
@@ -185745,11 +186156,11 @@
185745186156
case TK_NULL: {
185746186157
if( prevType==TK_IS || prevType==TK_NOT ){
185747186158
sqlite3_str_append(pStr, " NULL", 5);
185748186159
break;
185749186160
}
185750
- /* Fall through */
186161
+ /* no break */ deliberate_fall_through
185751186162
}
185752186163
case TK_STRING:
185753186164
case TK_INTEGER:
185754186165
case TK_FLOAT:
185755186166
case TK_VARIABLE:
@@ -185809,11 +186220,11 @@
185809186220
}
185810186221
break;
185811186222
}
185812186223
case TK_SELECT: {
185813186224
iStartIN = 0;
185814
- /* fall through */
186225
+ /* no break */ deliberate_fall_through
185815186226
}
185816186227
default: {
185817186228
if( sqlite3IsIdChar(zSql[i]) ) addSpaceSeparator(pStr);
185818186229
j = pStr->nChar;
185819186230
sqlite3_str_append(pStr, zSql+i, n);
@@ -192525,11 +192936,20 @@
192525192936
#endif
192526192937
192527192938
#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32))
192528192939
#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
192529192940
192530
-#define deliberate_fall_through
192941
+#if !defined(deliberate_fall_through)
192942
+# if defined(__has_attribute)
192943
+# if __has_attribute(fallthrough)
192944
+# define deliberate_fall_through __attribute__((fallthrough));
192945
+# endif
192946
+# endif
192947
+#endif
192948
+#if !defined(deliberate_fall_through)
192949
+# define deliberate_fall_through
192950
+#endif
192531192951
192532192952
/*
192533192953
** Macros needed to provide flexible arrays in a portable way
192534192954
*/
192535192955
#ifndef offsetof
@@ -199254,11 +199674,11 @@
199254199674
assert( iCol==0 );
199255199675
if( v>1 ){
199256199676
pCsr->aStat[1].nDoc++;
199257199677
}
199258199678
eState = 2;
199259
- /* fall through */
199679
+ /* no break */ deliberate_fall_through
199260199680
199261199681
case 2:
199262199682
if( v==0 ){ /* 0x00. Next integer will be a docid. */
199263199683
eState = 0;
199264199684
}else if( v==1 ){ /* 0x01. Next integer will be a column number. */
@@ -212711,15 +213131,15 @@
212711213131
}
212712213132
212713213133
/* Slow version of jsonBlobAppendNode() that first resizes the
212714213134
** pParse->aBlob structure.
212715213135
*/
212716
-static void jsonBlobAppendNode(JsonParse*,u8,u32,const void*);
213136
+static void jsonBlobAppendNode(JsonParse*,u8,u64,const void*);
212717213137
static SQLITE_NOINLINE void jsonBlobExpandAndAppendNode(
212718213138
JsonParse *pParse,
212719213139
u8 eType,
212720
- u32 szPayload,
213140
+ u64 szPayload,
212721213141
const void *aPayload
212722213142
){
212723213143
if( jsonBlobExpand(pParse, pParse->nBlob+szPayload+9) ) return;
212724213144
jsonBlobAppendNode(pParse, eType, szPayload, aPayload);
212725213145
}
@@ -212735,11 +213155,11 @@
212735213155
** pointing to where the first byte of payload will eventually be.
212736213156
*/
212737213157
static void jsonBlobAppendNode(
212738213158
JsonParse *pParse, /* The JsonParse object under construction */
212739213159
u8 eType, /* Node type. One of JSONB_* */
212740
- u32 szPayload, /* Number of bytes of payload */
213160
+ u64 szPayload, /* Number of bytes of payload */
212741213161
const void *aPayload /* The payload. Might be NULL */
212742213162
){
212743213163
u8 *a;
212744213164
if( pParse->nBlob+szPayload+9 > pParse->nBlobAlloc ){
212745213165
jsonBlobExpandAndAppendNode(pParse,eType,szPayload,aPayload);
@@ -214135,10 +214555,11 @@
214135214555
u32 nDel, /* Number of bytes to remove */
214136214556
const u8 *aIns, /* Content to insert */
214137214557
u32 nIns /* Bytes of content to insert */
214138214558
){
214139214559
i64 d = (i64)nIns - (i64)nDel;
214560
+ assert( pParse->nBlob >= (u64)iDel + (u64)nDel );
214140214561
if( d<0 && d>=(-8) && aIns!=0
214141214562
&& jsonBlobOverwrite(&pParse->aBlob[iDel], aIns, nIns, (int)-d)
214142214563
){
214143214564
return;
214144214565
}
@@ -218177,11 +218598,21 @@
218177218598
pRtree->nBusy--;
218178218599
if( pRtree->nBusy==0 ){
218179218600
pRtree->inWrTrans = 0;
218180218601
assert( pRtree->nCursor==0 );
218181218602
nodeBlobReset(pRtree);
218182
- assert( pRtree->nNodeRef==0 || pRtree->bCorrupt );
218603
+ if( pRtree->nNodeRef ){
218604
+ int i;
218605
+ assert( pRtree->bCorrupt );
218606
+ for(i=0; i<HASHSIZE; i++){
218607
+ while( pRtree->aHash[i] ){
218608
+ RtreeNode *pNext = pRtree->aHash[i]->pNext;
218609
+ sqlite3_free(pRtree->aHash[i]);
218610
+ pRtree->aHash[i] = pNext;
218611
+ }
218612
+ }
218613
+ }
218183218614
sqlite3_finalize(pRtree->pWriteNode);
218184218615
sqlite3_finalize(pRtree->pDeleteNode);
218185218616
sqlite3_finalize(pRtree->pReadRowid);
218186218617
sqlite3_finalize(pRtree->pWriteRowid);
218187218618
sqlite3_finalize(pRtree->pDeleteRowid);
@@ -219469,11 +219900,11 @@
219469219900
RtreeNode *pParent = p->pParent;
219470219901
RtreeCell cell;
219471219902
int iCell;
219472219903
219473219904
cnt++;
219474
- if( NEVER(cnt>100) ){
219905
+ if( cnt>100 ){
219475219906
RTREE_IS_CORRUPT(pRtree);
219476219907
return SQLITE_CORRUPT_VTAB;
219477219908
}
219478219909
rc = nodeParentIndex(pRtree, p, &iCell);
219479219910
if( NEVER(rc!=SQLITE_OK) ){
@@ -219827,19 +220258,10 @@
219827220258
}
219828220259
}else if( newCellIsRight==0 ){
219829220260
rc = updateMapping(pRtree, pCell->iRowid, pLeft, iHeight);
219830220261
}
219831220262
219832
- if( rc==SQLITE_OK ){
219833
- rc = nodeRelease(pRtree, pRight);
219834
- pRight = 0;
219835
- }
219836
- if( rc==SQLITE_OK ){
219837
- rc = nodeRelease(pRtree, pLeft);
219838
- pLeft = 0;
219839
- }
219840
-
219841220263
splitnode_out:
219842220264
nodeRelease(pRtree, pRight);
219843220265
nodeRelease(pRtree, pLeft);
219844220266
sqlite3_free(aCell);
219845220267
return rc;
@@ -220020,11 +220442,11 @@
220020220442
}
220021220443
if( nodeInsertCell(pRtree, pNode, pCell) ){
220022220444
rc = SplitNode(pRtree, pNode, pCell, iHeight);
220023220445
}else{
220024220446
rc = AdjustTree(pRtree, pNode, pCell);
220025
- if( ALWAYS(rc==SQLITE_OK) ){
220447
+ if( rc==SQLITE_OK ){
220026220448
if( iHeight==0 ){
220027220449
rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);
220028220450
}else{
220029220451
rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);
220030220452
}
@@ -261855,11 +262277,11 @@
261855262277
int nArg, /* Number of args */
261856262278
sqlite3_value **apUnused /* Function arguments */
261857262279
){
261858262280
assert( nArg==0 );
261859262281
UNUSED_PARAM2(nArg, apUnused);
261860
- sqlite3_result_text(pCtx, "fts5: 2026-03-06 16:01:44 557aeb43869d3585137b17690cb3b64f7de6921774daae9e56403c3717dceab6", -1, SQLITE_TRANSIENT);
262282
+ sqlite3_result_text(pCtx, "fts5: 2026-03-18 15:40:26 971aa34b3fd86ba30fe170886d9f83c17159b1638c4bd4fb6cdef79b1c9a88e2", -1, SQLITE_TRANSIENT);
261861262283
}
261862262284
261863262285
/*
261864262286
** Implementation of fts5_locale(LOCALE, TEXT) function.
261865262287
**
261866262288
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.52.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 557aeb43869d3585137b17690cb3b64f7de6 with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -465,16 +465,16 @@
465 **
466 ** See also: [sqlite3_libversion()],
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.52.0"
471 #define SQLITE_VERSION_NUMBER 3052000
472 #define SQLITE_SOURCE_ID "2026-03-06 16:01:44 557aeb43869d3585137b17690cb3b64f7de6921774daae9e56403c3717dceab6"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS "release major-release version-3.52.0"
475 #define SQLITE_SCM_DATETIME "2026-03-06T16:01:44.367Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -2977,11 +2977,11 @@
2977 ** default value 17, as of SQLite version 3.52.0. The value was 15 in all
2978 ** prior versions.<p>
2979 ** This option takes two arguments which are an integer and a pointer
2980 ** to an integer. The first argument is a small integer, between 3 and 23, or
2981 ** zero. The FP_DIGITS setting is changed to that small integer, or left
2982 ** altered if the first argument is zero or out of range. The second argument
2983 ** is a pointer to an integer. If the pointer is not NULL, then the value of
2984 ** the FP_DIGITS setting, after possibly being modified by the first
2985 ** arguments, is written into the integer to which the second argument points.
2986 ** </dd>
2987 **
@@ -4807,11 +4807,11 @@
4807 ** are constructors for the [prepared statement] object.
4808 **
4809 ** The preferred routine to use is [sqlite3_prepare_v2()]. The
4810 ** [sqlite3_prepare()] interface is legacy and should be avoided.
4811 ** [sqlite3_prepare_v3()] has an extra
4812 ** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is some times
4813 ** needed for special purpose or to pass along security restrictions.
4814 **
4815 ** The use of the UTF-8 interfaces is preferred, as SQLite currently
4816 ** does all parsing using UTF-8. The UTF-16 interfaces are provided
4817 ** as a convenience. The UTF-16 interfaces work by converting the
@@ -6814,11 +6814,11 @@
6814 ** application-defined function to be a text string in an encoding
6815 ** specified the E parameter, which must be one
6816 ** of [SQLITE_UTF8], [SQLITE_UTF8_ZT], [SQLITE_UTF16], [SQLITE_UTF16BE],
6817 ** or [SQLITE_UTF16LE]. ^The special value [SQLITE_UTF8_ZT] means that
6818 ** the result text is both UTF-8 and zero-terminated. In other words,
6819 ** SQLITE_UTF8_ZT means that the Z array holds at least N+1 byes and that
6820 ** the Z&#91;N&#93; is zero.
6821 ** ^SQLite takes the text result from the application from
6822 ** the 2nd parameter of the sqlite3_result_text* interfaces.
6823 ** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
6824 ** other than sqlite3_result_text64() is negative, then SQLite computes
@@ -9184,11 +9184,11 @@
9184 **
9185 ** ^The [sqlite3_str_reset(X)] method resets the string under construction
9186 ** inside [sqlite3_str] object X back to zero bytes in length.
9187 **
9188 ** ^The [sqlite3_str_truncate(X,N)] method changes the length of the string
9189 ** under construction to be N bytes are less. This routine is a no-op if
9190 ** N is negative or if the string is already N bytes or smaller in size.
9191 **
9192 ** These methods do not return a result code. ^If an error occurs, that fact
9193 ** is recorded in the [sqlite3_str] object and can be recovered by a
9194 ** subsequent call to [sqlite3_str_errcode(X)].
@@ -11048,11 +11048,11 @@
11048 ** - less than -1 or greater than or equal to the total number of query
11049 ** elements used to implement the statement - a non-zero value is returned and
11050 ** the variable that pOut points to is unchanged.
11051 **
11052 ** See also: [sqlite3_stmt_scanstatus_reset()] and the
11053 ** [nexec and ncycle] columnes of the [bytecode virtual table].
11054 */
11055 SQLITE_API int sqlite3_stmt_scanstatus(
11056 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
11057 int idx, /* Index of loop to report on */
11058 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
@@ -11604,21 +11604,21 @@
11604 **
11605 ** If the X argument is not a NULL pointer or one of the special
11606 ** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke
11607 ** the function X with argument D when it is finished using the data in P.
11608 ** The call to X(D) is a destructor for the array P. The destructor X(D)
11609 ** is invoked even if the call to sqlite3_carray_bind() fails. If the X
11610 ** parameter is the special-case value [SQLITE_STATIC], then SQLite assumes
11611 ** that the data static and the destructor is never invoked. If the X
11612 ** parameter is the special-case value [SQLITE_TRANSIENT], then
11613 ** sqlite3_carray_bind_v2() makes its own private copy of the data prior
11614 ** to returning and never invokes the destructor X.
11615 **
11616 ** The sqlite3_carray_bind() function works the same as sqlite_carray_bind_v2()
11617 ** with a D parameter set to P. In other words,
11618 ** sqlite3_carray_bind(S,I,P,N,F,X) is same as
11619 ** sqlite3_carray_bind(S,I,P,N,F,X,P).
11620 */
11621 SQLITE_API int sqlite3_carray_bind_v2(
11622 sqlite3_stmt *pStmt, /* Statement to be bound */
11623 int i, /* Parameter index */
11624 void *aData, /* Pointer to array data */
@@ -14740,13 +14740,11 @@
14740 #endif
14741
14742 /*
14743 ** Include standard header files as necessary
14744 */
14745 #ifdef HAVE_STDINT_H
14746 #include <stdint.h>
14747 #endif
14748 #ifdef HAVE_INTTYPES_H
14749 #include <inttypes.h>
14750 #endif
14751
14752 /*
@@ -17315,10 +17313,11 @@
17315 KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
17316 u32 *ai; /* Used when p4type is P4_INTARRAY */
17317 SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */
17318 Table *pTab; /* Used when p4type is P4_TABLE */
17319 SubrtnSig *pSubrtnSig; /* Used when p4type is P4_SUBRTNSIG */
 
17320 #ifdef SQLITE_ENABLE_CURSOR_HINTS
17321 Expr *pExpr; /* Used when p4type is P4_EXPR */
17322 #endif
17323 } p4;
17324 #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
@@ -17369,24 +17368,25 @@
17369 #define P4_STATIC (-1) /* Pointer to a static string */
17370 #define P4_COLLSEQ (-2) /* P4 is a pointer to a CollSeq structure */
17371 #define P4_INT32 (-3) /* P4 is a 32-bit signed integer */
17372 #define P4_SUBPROGRAM (-4) /* P4 is a pointer to a SubProgram structure */
17373 #define P4_TABLE (-5) /* P4 is a pointer to a Table structure */
 
17374 /* Above do not own any resources. Must free those below */
17375 #define P4_FREE_IF_LE (-6)
17376 #define P4_DYNAMIC (-6) /* Pointer to memory from sqliteMalloc() */
17377 #define P4_FUNCDEF (-7) /* P4 is a pointer to a FuncDef structure */
17378 #define P4_KEYINFO (-8) /* P4 is a pointer to a KeyInfo structure */
17379 #define P4_EXPR (-9) /* P4 is a pointer to an Expr tree */
17380 #define P4_MEM (-10) /* P4 is a pointer to a Mem* structure */
17381 #define P4_VTAB (-11) /* P4 is a pointer to an sqlite3_vtab structure */
17382 #define P4_REAL (-12) /* P4 is a 64-bit floating point value */
17383 #define P4_INT64 (-13) /* P4 is a 64-bit signed integer */
17384 #define P4_INTARRAY (-14) /* P4 is a vector of 32-bit integers */
17385 #define P4_FUNCCTX (-15) /* P4 is a pointer to an sqlite3_context object */
17386 #define P4_TABLEREF (-16) /* Like P4_TABLE, but reference counted */
17387 #define P4_SUBRTNSIG (-17) /* P4 is a SubrtnSig pointer */
17388
17389 /* Error message codes for OP_Halt */
17390 #define P5_ConstraintNotNull 1
17391 #define P5_ConstraintUnique 2
17392 #define P5_ConstraintCheck 3
@@ -17471,66 +17471,66 @@
17471 #define OP_IdxGT 42 /* jump, synopsis: key=r[P3@P4] */
17472 #define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
17473 #define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
17474 #define OP_IdxLT 45 /* jump, synopsis: key=r[P3@P4] */
17475 #define OP_IdxGE 46 /* jump, synopsis: key=r[P3@P4] */
17476 #define OP_RowSetRead 47 /* jump, synopsis: r[P3]=rowset(P1) */
17477 #define OP_RowSetTest 48 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
17478 #define OP_Program 49 /* jump0 */
17479 #define OP_FkIfZero 50 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
17480 #define OP_IsNull 51 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
17481 #define OP_NotNull 52 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
17482 #define OP_Ne 53 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
17483 #define OP_Eq 54 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */
17484 #define OP_Gt 55 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */
17485 #define OP_Le 56 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
17486 #define OP_Lt 57 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
17487 #define OP_Ge 58 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
17488 #define OP_ElseEq 59 /* jump, same as TK_ESCAPE */
17489 #define OP_IfPos 60 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
17490 #define OP_IfNotZero 61 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
17491 #define OP_DecrJumpZero 62 /* jump, synopsis: if (--r[P1])==0 goto P2 */
17492 #define OP_IncrVacuum 63 /* jump */
17493 #define OP_VNext 64 /* jump */
17494 #define OP_Filter 65 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */
17495 #define OP_PureFunc 66 /* synopsis: r[P3]=func(r[P2@NP]) */
17496 #define OP_Function 67 /* synopsis: r[P3]=func(r[P2@NP]) */
17497 #define OP_Return 68
17498 #define OP_EndCoroutine 69
17499 #define OP_HaltIfNull 70 /* synopsis: if r[P3]=null halt */
17500 #define OP_Halt 71
17501 #define OP_Integer 72 /* synopsis: r[P2]=P1 */
17502 #define OP_Int64 73 /* synopsis: r[P2]=P4 */
17503 #define OP_String 74 /* synopsis: r[P2]='P4' (len=P1) */
17504 #define OP_BeginSubrtn 75 /* synopsis: r[P2]=NULL */
17505 #define OP_Null 76 /* synopsis: r[P2..P3]=NULL */
17506 #define OP_SoftNull 77 /* synopsis: r[P1]=NULL */
17507 #define OP_Blob 78 /* synopsis: r[P2]=P4 (len=P1) */
17508 #define OP_Variable 79 /* synopsis: r[P2]=parameter(P1) */
17509 #define OP_Move 80 /* synopsis: r[P2@P3]=r[P1@P3] */
17510 #define OP_Copy 81 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
17511 #define OP_SCopy 82 /* synopsis: r[P2]=r[P1] */
17512 #define OP_IntCopy 83 /* synopsis: r[P2]=r[P1] */
17513 #define OP_FkCheck 84
17514 #define OP_ResultRow 85 /* synopsis: output=r[P1@P2] */
17515 #define OP_CollSeq 86
17516 #define OP_AddImm 87 /* synopsis: r[P1]=r[P1]+P2 */
17517 #define OP_RealAffinity 88
17518 #define OP_Cast 89 /* synopsis: affinity(r[P1]) */
17519 #define OP_Permutation 90
17520 #define OP_Compare 91 /* synopsis: r[P1@P3] <-> r[P2@P3] */
17521 #define OP_IsTrue 92 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
17522 #define OP_ZeroOrNull 93 /* synopsis: r[P2] = 0 OR NULL */
17523 #define OP_Offset 94 /* synopsis: r[P3] = sqlite_offset(P1) */
17524 #define OP_Column 95 /* synopsis: r[P3]=PX cursor P1 column P2 */
17525 #define OP_TypeCheck 96 /* synopsis: typecheck(r[P1@P2]) */
17526 #define OP_Affinity 97 /* synopsis: affinity(r[P1@P2]) */
17527 #define OP_MakeRecord 98 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
17528 #define OP_Count 99 /* synopsis: r[P2]=count() */
17529 #define OP_ReadCookie 100
17530 #define OP_SetCookie 101
17531 #define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */
17532 #define OP_BitAnd 103 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
17533 #define OP_BitOr 104 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
17534 #define OP_ShiftLeft 105 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
17535 #define OP_ShiftRight 106 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
17536 #define OP_Add 107 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -17537,88 +17537,89 @@
17537 #define OP_Subtract 108 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
17538 #define OP_Multiply 109 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
17539 #define OP_Divide 110 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
17540 #define OP_Remainder 111 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
17541 #define OP_Concat 112 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
17542 #define OP_OpenRead 113 /* synopsis: root=P2 iDb=P3 */
17543 #define OP_OpenWrite 114 /* synopsis: root=P2 iDb=P3 */
17544 #define OP_BitNot 115 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
17545 #define OP_OpenDup 116
17546 #define OP_OpenAutoindex 117 /* synopsis: nColumn=P2 */
17547 #define OP_String8 118 /* same as TK_STRING, synopsis: r[P2]='P4' */
17548 #define OP_OpenEphemeral 119 /* synopsis: nColumn=P2 */
17549 #define OP_SorterOpen 120
17550 #define OP_SequenceTest 121 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
17551 #define OP_OpenPseudo 122 /* synopsis: P3 columns in r[P2] */
17552 #define OP_Close 123
17553 #define OP_ColumnsUsed 124
17554 #define OP_SeekScan 125 /* synopsis: Scan-ahead up to P1 rows */
17555 #define OP_SeekHit 126 /* synopsis: set P2<=seekHit<=P3 */
17556 #define OP_Sequence 127 /* synopsis: r[P2]=cursor[P1].ctr++ */
17557 #define OP_NewRowid 128 /* synopsis: r[P2]=rowid */
17558 #define OP_Insert 129 /* synopsis: intkey=r[P3] data=r[P2] */
17559 #define OP_RowCell 130
17560 #define OP_Delete 131
17561 #define OP_ResetCount 132
17562 #define OP_SorterCompare 133 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
17563 #define OP_SorterData 134 /* synopsis: r[P2]=data */
17564 #define OP_RowData 135 /* synopsis: r[P2]=data */
17565 #define OP_Rowid 136 /* synopsis: r[P2]=PX rowid of P1 */
17566 #define OP_NullRow 137
17567 #define OP_SeekEnd 138
17568 #define OP_IdxInsert 139 /* synopsis: key=r[P2] */
17569 #define OP_SorterInsert 140 /* synopsis: key=r[P2] */
17570 #define OP_IdxDelete 141 /* synopsis: key=r[P2@P3] */
17571 #define OP_DeferredSeek 142 /* synopsis: Move P3 to P1.rowid if needed */
17572 #define OP_IdxRowid 143 /* synopsis: r[P2]=rowid */
17573 #define OP_FinishSeek 144
17574 #define OP_Destroy 145
17575 #define OP_Clear 146
17576 #define OP_ResetSorter 147
17577 #define OP_CreateBtree 148 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
17578 #define OP_SqlExec 149
17579 #define OP_ParseSchema 150
17580 #define OP_LoadAnalysis 151
17581 #define OP_DropTable 152
17582 #define OP_DropIndex 153
17583 #define OP_Real 154 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
17584 #define OP_DropTrigger 155
17585 #define OP_IntegrityCk 156
17586 #define OP_RowSetAdd 157 /* synopsis: rowset(P1)=r[P2] */
17587 #define OP_Param 158
17588 #define OP_FkCounter 159 /* synopsis: fkctr[P1]+=P2 */
17589 #define OP_MemMax 160 /* synopsis: r[P1]=max(r[P1],r[P2]) */
17590 #define OP_OffsetLimit 161 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
17591 #define OP_AggInverse 162 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
17592 #define OP_AggStep 163 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17593 #define OP_AggStep1 164 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17594 #define OP_AggValue 165 /* synopsis: r[P3]=value N=P2 */
17595 #define OP_AggFinal 166 /* synopsis: accum=r[P1] N=P2 */
17596 #define OP_Expire 167
17597 #define OP_CursorLock 168
17598 #define OP_CursorUnlock 169
17599 #define OP_TableLock 170 /* synopsis: iDb=P1 root=P2 write=P3 */
17600 #define OP_VBegin 171
17601 #define OP_VCreate 172
17602 #define OP_VDestroy 173
17603 #define OP_VOpen 174
17604 #define OP_VCheck 175
17605 #define OP_VInitIn 176 /* synopsis: r[P2]=ValueList(P1,P3) */
17606 #define OP_VColumn 177 /* synopsis: r[P3]=vcolumn(P2) */
17607 #define OP_VRename 178
17608 #define OP_Pagecount 179
17609 #define OP_MaxPgcnt 180
17610 #define OP_ClrSubtype 181 /* synopsis: r[P1].subtype = 0 */
17611 #define OP_GetSubtype 182 /* synopsis: r[P2] = r[P1].subtype */
17612 #define OP_SetSubtype 183 /* synopsis: r[P2].subtype = r[P1] */
17613 #define OP_FilterAdd 184 /* synopsis: filter(P1) += key(P3@P4) */
17614 #define OP_Trace 185
17615 #define OP_CursorHint 186
17616 #define OP_ReleaseReg 187 /* synopsis: release r[P1@P2] mask P3 */
17617 #define OP_Noop 188
17618 #define OP_Explain 189
17619 #define OP_Abortable 190
 
17620
17621 /* Properties such as "out2" or "jump" that are specified in
17622 ** comments following the "case" for each opcode in the vdbe.c
17623 ** are encoded into bitvectors as follows:
17624 */
@@ -17634,37 +17635,38 @@
17634 /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x41, 0x00,\
17635 /* 8 */ 0x81, 0x01, 0x01, 0x81, 0x83, 0x83, 0x01, 0x01,\
17636 /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0xc9, 0xc9, 0xc9,\
17637 /* 24 */ 0xc9, 0x01, 0x49, 0x49, 0x49, 0x49, 0xc9, 0x49,\
17638 /* 32 */ 0xc1, 0x01, 0x41, 0x41, 0xc1, 0x01, 0x01, 0x41,\
17639 /* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x41, 0x23,\
17640 /* 48 */ 0x0b, 0x81, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\
17641 /* 56 */ 0x0b, 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x03, 0x01,\
17642 /* 64 */ 0x41, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00,\
17643 /* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10,\
17644 /* 80 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02,\
17645 /* 88 */ 0x02, 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x40,\
17646 /* 96 */ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x26,\
17647 /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
17648 /* 112 */ 0x26, 0x40, 0x00, 0x12, 0x40, 0x40, 0x10, 0x40,\
17649 /* 120 */ 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x40, 0x10,\
17650 /* 128 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,\
17651 /* 136 */ 0x50, 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50,\
17652 /* 144 */ 0x40, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\
17653 /* 152 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00,\
17654 /* 160 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
17655 /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10,\
17656 /* 176 */ 0x50, 0x40, 0x00, 0x10, 0x10, 0x02, 0x12, 0x12,\
17657 /* 184 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}
 
17658
17659 /* The resolve3P2Values() routine is able to run faster if it knows
17660 ** the value of the largest JUMP opcode. The smaller the maximum
17661 ** JUMP opcode the better, so the mkopcodeh.tcl script that
17662 ** generated this include file strives to group all JUMP opcodes
17663 ** together near the beginning of the list.
17664 */
17665 #define SQLITE_MX_JUMP_OPCODE 65 /* Maximum JUMP opcode */
17666
17667 /************** End of opcodes.h *********************************************/
17668 /************** Continuing where we left off in vdbe.h ***********************/
17669
17670 /*
@@ -24682,10 +24684,11 @@
24682 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
24683 SQLITE_PRIVATE void sqlite3VdbePreUpdateHook(
24684 Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int,int);
24685 #endif
24686 SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p);
 
24687
24688 SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *);
24689 SQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *);
24690 SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
24691 SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
@@ -35367,10 +35370,11 @@
35367 }else{
35368 assert( p->id!=0 && p->id!=GetCurrentThreadId() );
35369 rc = sqlite3Win32Wait((HANDLE)p->tid);
35370 assert( rc!=WAIT_IO_COMPLETION );
35371 bRc = CloseHandle((HANDLE)p->tid);
 
35372 assert( bRc );
35373 }
35374 if( rc==WAIT_OBJECT_0 ) *ppOut = p->pResult;
35375 sqlite3_free(p);
35376 return (rc==WAIT_OBJECT_0) ? SQLITE_OK : SQLITE_ERROR;
@@ -36507,32 +36511,72 @@
36507 }
36508 return h;
36509 }
36510
36511 /*
36512 ** Two inputs are multiplied to get a 128-bit result. Return
36513 ** the high-order 64 bits of that result.
 
36514 */
36515 static u64 sqlite3Multiply128(u64 a, u64 b){
36516 #if (defined(__GNUC__) || defined(__clang__)) \
36517 && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv))
36518 return ((__uint128_t)a * b) >> 64;
 
 
36519 #elif defined(_MSC_VER) && defined(_M_X64)
 
36520 return __umulh(a, b);
36521 #else
36522 u64 a1 = (u32)a;
36523 u64 a2 = a >> 32;
36524 u64 b1 = (u32)b;
36525 u64 b2 = b >> 32;
36526 u64 p0 = a1 * b1;
36527 u64 p1 = a1 * b2;
36528 u64 p2 = a2 * b1;
36529 u64 p3 = a2 * b2;
36530 u64 carry = ((p0 >> 32) + (u32)p1 + (u32)p2) >> 32;
36531 return p3 + (p1 >> 32) + (p2 >> 32) + carry;
 
36532 #endif
36533 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36534
36535 /*
36536 ** Return a u64 with the N-th bit set.
36537 */
36538 #define U64_BIT(N) (((u64)1)<<(N))
@@ -36552,102 +36596,145 @@
36552 ** Or, in other words, for any p in range, return the most significant
36553 ** 64 bits of pow(10,p). The pow(10,p) value is shifted left or right,
36554 ** as appropriate so the most significant 64 bits fit exactly into a
36555 ** 64-bit unsigned integer.
36556 **
 
 
 
36557 ** Algorithm:
36558 **
36559 ** (1) For p between 0 and 26, return the value directly from the aBase[]
36560 ** lookup table.
36561 **
36562 ** (2) For p outside the range 0 to 26, use aScale[] for the initial value
36563 ** then refine that result (if necessary) by a single multiplication
36564 ** against aBase[].
 
 
 
36565 */
36566 static u64 powerOfTen(int p){
36567 static const u64 aBase[] = {
36568 0x8000000000000000LLU, /* 0: 1.0e+0 << 63 */
36569 0xa000000000000000LLU, /* 1: 1.0e+1 << 60 */
36570 0xc800000000000000LLU, /* 2: 1.0e+2 << 57 */
36571 0xfa00000000000000LLU, /* 3: 1.0e+3 << 54 */
36572 0x9c40000000000000LLU, /* 4: 1.0e+4 << 50 */
36573 0xc350000000000000LLU, /* 5: 1.0e+5 << 47 */
36574 0xf424000000000000LLU, /* 6: 1.0e+6 << 44 */
36575 0x9896800000000000LLU, /* 7: 1.0e+7 << 40 */
36576 0xbebc200000000000LLU, /* 8: 1.0e+8 << 37 */
36577 0xee6b280000000000LLU, /* 9: 1.0e+9 << 34 */
36578 0x9502f90000000000LLU, /* 10: 1.0e+10 << 30 */
36579 0xba43b74000000000LLU, /* 11: 1.0e+11 << 27 */
36580 0xe8d4a51000000000LLU, /* 12: 1.0e+12 << 24 */
36581 0x9184e72a00000000LLU, /* 13: 1.0e+13 << 20 */
36582 0xb5e620f480000000LLU, /* 14: 1.0e+14 << 17 */
36583 0xe35fa931a0000000LLU, /* 15: 1.0e+15 << 14 */
36584 0x8e1bc9bf04000000LLU, /* 16: 1.0e+16 << 10 */
36585 0xb1a2bc2ec5000000LLU, /* 17: 1.0e+17 << 7 */
36586 0xde0b6b3a76400000LLU, /* 18: 1.0e+18 << 4 */
36587 0x8ac7230489e80000LLU, /* 19: 1.0e+19 >> 0 */
36588 0xad78ebc5ac620000LLU, /* 20: 1.0e+20 >> 3 */
36589 0xd8d726b7177a8000LLU, /* 21: 1.0e+21 >> 6 */
36590 0x878678326eac9000LLU, /* 22: 1.0e+22 >> 10 */
36591 0xa968163f0a57b400LLU, /* 23: 1.0e+23 >> 13 */
36592 0xd3c21bcecceda100LLU, /* 24: 1.0e+24 >> 16 */
36593 0x84595161401484a0LLU, /* 25: 1.0e+25 >> 20 */
36594 0xa56fa5b99019a5c8LLU, /* 26: 1.0e+26 >> 23 */
36595 };
36596 static const u64 aScale[] = {
36597 0x8049a4ac0c5811aeLLU, /* 0: 1.0e-351 << 1229 */
36598 0xcf42894a5dce35eaLLU, /* 1: 1.0e-324 << 1140 */
36599 0xa76c582338ed2622LLU, /* 2: 1.0e-297 << 1050 */
36600 0x873e4f75e2224e68LLU, /* 3: 1.0e-270 << 960 */
36601 0xda7f5bf590966849LLU, /* 4: 1.0e-243 << 871 */
36602 0xb080392cc4349dedLLU, /* 5: 1.0e-216 << 781 */
36603 0x8e938662882af53eLLU, /* 6: 1.0e-189 << 691 */
36604 0xe65829b3046b0afaLLU, /* 7: 1.0e-162 << 602 */
36605 0xba121a4650e4ddecLLU, /* 8: 1.0e-135 << 512 */
36606 0x964e858c91ba2655LLU, /* 9: 1.0e-108 << 422 */
36607 0xf2d56790ab41c2a3LLU, /* 10: 1.0e-81 << 333 */
36608 0xc428d05aa4751e4dLLU, /* 11: 1.0e-54 << 243 */
36609 0x9e74d1b791e07e48LLU, /* 12: 1.0e-27 << 153 */
36610 0x8000000000000000LLU, /* 13: 1.0e+0 << 63 */
36611 0xcecb8f27f4200f3aLLU, /* 14: 1.0e+27 >> 26 */
36612 0xa70c3c40a64e6c52LLU, /* 15: 1.0e+54 >> 116 */
36613 0x86f0ac99b4e8dafdLLU, /* 16: 1.0e+81 >> 206 */
36614 0xda01ee641a708deaLLU, /* 17: 1.0e+108 >> 295 */
36615 0xb01ae745b101e9e4LLU, /* 18: 1.0e+135 >> 385 */
36616 0x8e41ade9fbebc27dLLU, /* 19: 1.0e+162 >> 475 */
36617 0xe5d3ef282a242e82LLU, /* 20: 1.0e+189 >> 564 */
36618 0xb9a74a0637ce2ee1LLU, /* 21: 1.0e+216 >> 654 */
36619 0x95f83d0a1fb69cd9LLU, /* 22: 1.0e+243 >> 744 */
36620 0xf24a01a73cf2dcd0LLU, /* 23: 1.0e+270 >> 833 */
36621 0xc3b8358109e84f07LLU, /* 24: 1.0e+297 >> 923 */
36622 0x9e19db92b4e31ba9LLU, /* 25: 1.0e+324 >> 1013 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36623 };
36624 int g, n;
36625 u64 x, y;
 
36626
36627 assert( p>=POWERSOF10_FIRST && p<=POWERSOF10_LAST );
36628 if( p<0 ){
 
 
 
 
36629 g = p/27;
36630 n = p%27;
36631 if( n ){
36632 g--;
36633 n += 27;
36634 }
36635 }else if( p<27 ){
 
36636 return aBase[p];
36637 }else{
36638 g = p/27;
36639 n = p%27;
36640 }
36641 y = aScale[g+13];
36642 if( n==0 ){
36643 return y;
 
36644 }
36645 x = sqlite3Multiply128(aBase[n],y);
36646 if( (U64_BIT(63) & x)==0 ){
36647 x = (x<<1)|1;
 
36648 }
 
36649 return x;
36650 }
36651
36652 /*
36653 ** pow10to2(x) computes floor(log2(pow(10,x))).
@@ -36696,14 +36783,15 @@
36696 ** The input m is required to have its highest bit set. In other words,
36697 ** m should be left-shifted, and e decremented, to maximize the value of m.
36698 */
36699 static void sqlite3Fp2Convert10(u64 m, int e, int n, u64 *pD, int *pP){
36700 int p;
36701 u64 h;
 
36702 assert( n>=1 && n<=18 );
36703 p = n - 1 - pwr2to10(e+63);
36704 h = sqlite3Multiply128(m, powerOfTen(p));
36705 assert( -(e + pwr10to2(p) + 2) >= 0 );
36706 assert( -(e + pwr10to2(p) + 1) <= 63 );
36707 if( n==18 ){
36708 h >>= -(e + pwr10to2(p) + 2);
36709 *pD = (h + ((h<<1)&2))>>1;
@@ -36715,49 +36803,50 @@
36715
36716 /*
36717 ** Return an IEEE754 floating point value that approximates d*pow(10,p).
36718 */
36719 static double sqlite3Fp10Convert2(u64 d, int p){
36720 u64 out;
36721 int e1;
36722 int lz;
36723 int lp;
36724 int x;
36725 u64 h;
36726 double r;
36727 assert( (d & U64_BIT(63))==0 );
36728 assert( d!=0 );
36729 if( p<POWERSOF10_FIRST ){
36730 return 0.0;
36731 }
36732 if( p>POWERSOF10_LAST ){
36733 return INFINITY;
36734 }
36735 lz = countLeadingZeros(d);
36736 lp = pwr10to2(p);
36737 e1 = lz - (lp + 11);
36738 if( e1>1074 ){
36739 if( e1>=1130 ) return 0.0;
36740 e1 = 1074;
36741 }
36742 h = sqlite3Multiply128(d<<lz, powerOfTen(p));
36743 x = lz - (e1 + lp + 3);
36744 assert( x >= 0 );
36745 assert( x <= 63 );
36746 out = h >> x;
36747 if( out >= U64_BIT(55)-2 ){
36748 out >>= 1;
36749 e1--;
36750 }
36751 if( e1<=(-972) ){
36752 return INFINITY;
36753 }
36754 out = (out + 2) >> 2;
36755 if( (out & U64_BIT(52))!=0 ){
36756 out = (out & ~U64_BIT(52)) | ((u64)(1075-e1)<<52);
36757 }
36758 memcpy(&r, &out, 8);
 
 
 
 
 
 
 
 
 
 
36759 return r;
36760 }
36761
36762 /*
36763 ** The string z[] is an text representation of a real number.
@@ -38424,66 +38513,66 @@
38424 /* 42 */ "IdxGT" OpHelp("key=r[P3@P4]"),
38425 /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
38426 /* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
38427 /* 45 */ "IdxLT" OpHelp("key=r[P3@P4]"),
38428 /* 46 */ "IdxGE" OpHelp("key=r[P3@P4]"),
38429 /* 47 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
38430 /* 48 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
38431 /* 49 */ "Program" OpHelp(""),
38432 /* 50 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
38433 /* 51 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
38434 /* 52 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
38435 /* 53 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
38436 /* 54 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
38437 /* 55 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
38438 /* 56 */ "Le" OpHelp("IF r[P3]<=r[P1]"),
38439 /* 57 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
38440 /* 58 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
38441 /* 59 */ "ElseEq" OpHelp(""),
38442 /* 60 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
38443 /* 61 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
38444 /* 62 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
38445 /* 63 */ "IncrVacuum" OpHelp(""),
38446 /* 64 */ "VNext" OpHelp(""),
38447 /* 65 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"),
38448 /* 66 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"),
38449 /* 67 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
38450 /* 68 */ "Return" OpHelp(""),
38451 /* 69 */ "EndCoroutine" OpHelp(""),
38452 /* 70 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
38453 /* 71 */ "Halt" OpHelp(""),
38454 /* 72 */ "Integer" OpHelp("r[P2]=P1"),
38455 /* 73 */ "Int64" OpHelp("r[P2]=P4"),
38456 /* 74 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
38457 /* 75 */ "BeginSubrtn" OpHelp("r[P2]=NULL"),
38458 /* 76 */ "Null" OpHelp("r[P2..P3]=NULL"),
38459 /* 77 */ "SoftNull" OpHelp("r[P1]=NULL"),
38460 /* 78 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
38461 /* 79 */ "Variable" OpHelp("r[P2]=parameter(P1)"),
38462 /* 80 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
38463 /* 81 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
38464 /* 82 */ "SCopy" OpHelp("r[P2]=r[P1]"),
38465 /* 83 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
38466 /* 84 */ "FkCheck" OpHelp(""),
38467 /* 85 */ "ResultRow" OpHelp("output=r[P1@P2]"),
38468 /* 86 */ "CollSeq" OpHelp(""),
38469 /* 87 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
38470 /* 88 */ "RealAffinity" OpHelp(""),
38471 /* 89 */ "Cast" OpHelp("affinity(r[P1])"),
38472 /* 90 */ "Permutation" OpHelp(""),
38473 /* 91 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
38474 /* 92 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
38475 /* 93 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
38476 /* 94 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
38477 /* 95 */ "Column" OpHelp("r[P3]=PX cursor P1 column P2"),
38478 /* 96 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
38479 /* 97 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
38480 /* 98 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
38481 /* 99 */ "Count" OpHelp("r[P2]=count()"),
38482 /* 100 */ "ReadCookie" OpHelp(""),
38483 /* 101 */ "SetCookie" OpHelp(""),
38484 /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
38485 /* 103 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
38486 /* 104 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
38487 /* 105 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
38488 /* 106 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
38489 /* 107 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -38490,88 +38579,89 @@
38490 /* 108 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
38491 /* 109 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
38492 /* 110 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
38493 /* 111 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
38494 /* 112 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
38495 /* 113 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
38496 /* 114 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
38497 /* 115 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
38498 /* 116 */ "OpenDup" OpHelp(""),
38499 /* 117 */ "OpenAutoindex" OpHelp("nColumn=P2"),
38500 /* 118 */ "String8" OpHelp("r[P2]='P4'"),
38501 /* 119 */ "OpenEphemeral" OpHelp("nColumn=P2"),
38502 /* 120 */ "SorterOpen" OpHelp(""),
38503 /* 121 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
38504 /* 122 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
38505 /* 123 */ "Close" OpHelp(""),
38506 /* 124 */ "ColumnsUsed" OpHelp(""),
38507 /* 125 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
38508 /* 126 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
38509 /* 127 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
38510 /* 128 */ "NewRowid" OpHelp("r[P2]=rowid"),
38511 /* 129 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
38512 /* 130 */ "RowCell" OpHelp(""),
38513 /* 131 */ "Delete" OpHelp(""),
38514 /* 132 */ "ResetCount" OpHelp(""),
38515 /* 133 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
38516 /* 134 */ "SorterData" OpHelp("r[P2]=data"),
38517 /* 135 */ "RowData" OpHelp("r[P2]=data"),
38518 /* 136 */ "Rowid" OpHelp("r[P2]=PX rowid of P1"),
38519 /* 137 */ "NullRow" OpHelp(""),
38520 /* 138 */ "SeekEnd" OpHelp(""),
38521 /* 139 */ "IdxInsert" OpHelp("key=r[P2]"),
38522 /* 140 */ "SorterInsert" OpHelp("key=r[P2]"),
38523 /* 141 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
38524 /* 142 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
38525 /* 143 */ "IdxRowid" OpHelp("r[P2]=rowid"),
38526 /* 144 */ "FinishSeek" OpHelp(""),
38527 /* 145 */ "Destroy" OpHelp(""),
38528 /* 146 */ "Clear" OpHelp(""),
38529 /* 147 */ "ResetSorter" OpHelp(""),
38530 /* 148 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
38531 /* 149 */ "SqlExec" OpHelp(""),
38532 /* 150 */ "ParseSchema" OpHelp(""),
38533 /* 151 */ "LoadAnalysis" OpHelp(""),
38534 /* 152 */ "DropTable" OpHelp(""),
38535 /* 153 */ "DropIndex" OpHelp(""),
38536 /* 154 */ "Real" OpHelp("r[P2]=P4"),
38537 /* 155 */ "DropTrigger" OpHelp(""),
38538 /* 156 */ "IntegrityCk" OpHelp(""),
38539 /* 157 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
38540 /* 158 */ "Param" OpHelp(""),
38541 /* 159 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
38542 /* 160 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
38543 /* 161 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
38544 /* 162 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
38545 /* 163 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
38546 /* 164 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
38547 /* 165 */ "AggValue" OpHelp("r[P3]=value N=P2"),
38548 /* 166 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
38549 /* 167 */ "Expire" OpHelp(""),
38550 /* 168 */ "CursorLock" OpHelp(""),
38551 /* 169 */ "CursorUnlock" OpHelp(""),
38552 /* 170 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
38553 /* 171 */ "VBegin" OpHelp(""),
38554 /* 172 */ "VCreate" OpHelp(""),
38555 /* 173 */ "VDestroy" OpHelp(""),
38556 /* 174 */ "VOpen" OpHelp(""),
38557 /* 175 */ "VCheck" OpHelp(""),
38558 /* 176 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
38559 /* 177 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
38560 /* 178 */ "VRename" OpHelp(""),
38561 /* 179 */ "Pagecount" OpHelp(""),
38562 /* 180 */ "MaxPgcnt" OpHelp(""),
38563 /* 181 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"),
38564 /* 182 */ "GetSubtype" OpHelp("r[P2] = r[P1].subtype"),
38565 /* 183 */ "SetSubtype" OpHelp("r[P2].subtype = r[P1]"),
38566 /* 184 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
38567 /* 185 */ "Trace" OpHelp(""),
38568 /* 186 */ "CursorHint" OpHelp(""),
38569 /* 187 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
38570 /* 188 */ "Noop" OpHelp(""),
38571 /* 189 */ "Explain" OpHelp(""),
38572 /* 190 */ "Abortable" OpHelp(""),
 
38573 };
38574 return azName[i];
38575 }
38576 #endif
38577
@@ -73855,11 +73945,11 @@
73855 MemPage *pPage, /* Page containing the cell */
73856 u8 *pCell, /* Pointer to the cell text. */
73857 CellInfo *pInfo /* Fill in this structure */
73858 ){
73859 u8 *pIter; /* For scanning through pCell */
73860 u32 nPayload; /* Number of bytes of cell payload */
73861 u64 iKey; /* Extracted Key value */
73862
73863 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
73864 assert( pPage->leaf==0 || pPage->leaf==1 );
73865 assert( pPage->intKeyLeaf );
@@ -73877,10 +73967,11 @@
73877 u8 *pEnd = &pIter[8];
73878 nPayload &= 0x7f;
73879 do{
73880 nPayload = (nPayload<<7) | (*++pIter & 0x7f);
73881 }while( (*pIter)>=0x80 && pIter<pEnd );
 
73882 }
73883 pIter++;
73884
73885 /* The next block of code is equivalent to:
73886 **
@@ -73920,15 +74011,14 @@
73920 }
73921 }
73922 pIter++;
73923
73924 pInfo->nKey = *(i64*)&iKey;
73925 pInfo->nPayload = nPayload;
73926 pInfo->pPayload = pIter;
73927 testcase( nPayload==pPage->maxLocal );
73928 testcase( nPayload==(u32)pPage->maxLocal+1 );
73929 assert( nPayload>=0 );
73930 assert( pPage->maxLocal <= BT_MAX_LOCAL );
73931 if( nPayload<=pPage->maxLocal ){
73932 /* This is the (easy) common case where the entire payload fits
73933 ** on the local page. No overflow is required.
73934 */
@@ -89149,10 +89239,14 @@
89149 break;
89150 }
89151 case P4_TABLE: {
89152 zP4 = pOp->p4.pTab->zName;
89153 break;
 
 
 
 
89154 }
89155 case P4_SUBRTNSIG: {
89156 SubrtnSig *pSig = pOp->p4.pSubrtnSig;
89157 sqlite3_str_appendf(&x, "subrtnsig:%d,%s", pSig->selId, pSig->zAff);
89158 break;
@@ -92539,10 +92633,227 @@
92539 v->expmask |= 0x80000000;
92540 }else{
92541 v->expmask |= ((u32)1 << (iVar-1));
92542 }
92543 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92544
92545 #ifndef SQLITE_OMIT_DATETIME_FUNCS
92546 /*
92547 ** Cause a function to throw an error if it was call from OP_PureFunc
92548 ** rather than OP_Function.
@@ -102274,16 +102585,18 @@
102274 rc = sqlite3VdbeSorterWrite(pC, pIn2);
102275 if( rc) goto abort_due_to_error;
102276 break;
102277 }
102278
102279 /* Opcode: IdxDelete P1 P2 P3 * *
102280 ** Synopsis: key=r[P2@P3]
102281 **
102282 ** The content of P3 registers starting at register P2 form
102283 ** an unpacked index key. This opcode removes that entry from the
102284 ** index opened by cursor P1.
 
 
102285 **
102286 ** Raise an SQLITE_CORRUPT_INDEX error if no matching index entry is found
102287 ** and not in writable_schema mode.
102288 */
102289 case OP_IdxDelete: {
@@ -102305,17 +102618,26 @@
102305 r.nField = (u16)pOp->p3;
102306 r.default_rc = 0;
102307 r.aMem = &aMem[pOp->p2];
102308 rc = sqlite3BtreeIndexMoveto(pCrsr, &r, &res);
102309 if( rc ) goto abort_due_to_error;
102310 if( res==0 ){
102311 rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
102312 if( rc ) goto abort_due_to_error;
102313 }else if( !sqlite3WritableSchema(db) ){
102314 rc = sqlite3ReportError(SQLITE_CORRUPT_INDEX, __LINE__, "index corruption");
102315 goto abort_due_to_error;
 
 
 
 
 
 
 
102316 }
 
 
102317 assert( pC->deferredMoveto==0 );
102318 pC->cacheStatus = CACHE_STALE;
102319 pC->seekResult = 0;
102320 break;
102321 }
@@ -102938,10 +103260,62 @@
102938 }
102939 UPDATE_MAX_BLOBSIZE(pIn1);
102940 sqlite3VdbeChangeEncoding(pIn1, encoding);
102941 goto check_for_interrupt;
102942 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102943 #endif /* SQLITE_OMIT_INTEGRITY_CHECK */
102944
102945 /* Opcode: RowSetAdd P1 P2 * * *
102946 ** Synopsis: rowset(P1)=r[P2]
102947 **
@@ -116950,11 +117324,11 @@
116950 #endif /* SQLITE_OMIT_CAST */
116951 case TK_IS:
116952 case TK_ISNOT:
116953 op = (op==TK_IS) ? TK_EQ : TK_NE;
116954 p5 = SQLITE_NULLEQ;
116955 /* fall-through */
116956 case TK_LT:
116957 case TK_LE:
116958 case TK_GT:
116959 case TK_GE:
116960 case TK_NE:
@@ -132751,11 +133125,13 @@
132751 if( iIdxCur+i==iIdxNoSeek ) continue;
132752 VdbeModuleComment((v, "GenRowIdxDel for %s", pIdx->zName));
132753 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 1,
132754 &iPartIdxLabel, pPrior, r1);
132755 sqlite3VdbeAddOp3(v, OP_IdxDelete, iIdxCur+i, r1,
132756 pIdx->uniqNotNull ? pIdx->nKeyCol : pIdx->nColumn);
 
 
132757 sqlite3ResolvePartIdxLabel(pParse, iPartIdxLabel);
132758 pPrior = pIdx;
132759 }
132760 }
132761
@@ -137652,11 +138028,10 @@
137652
137653 zFrom = pFKey->pFrom->zName;
137654 nFrom = sqlite3Strlen30(zFrom);
137655
137656 if( action==OE_Restrict ){
137657 int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
137658 SrcList *pSrc;
137659 Expr *pRaise;
137660
137661 pRaise = sqlite3Expr(db, TK_STRING, "FOREIGN KEY constraint failed"),
137662 pRaise = sqlite3PExpr(pParse, TK_RAISE, pRaise, 0);
@@ -137663,14 +138038,14 @@
137663 if( pRaise ){
137664 pRaise->affExpr = OE_Abort;
137665 }
137666 pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
137667 if( pSrc ){
137668 assert( pSrc->nSrc==1 );
137669 pSrc->a[0].zName = sqlite3DbStrDup(db, zFrom);
137670 assert( pSrc->a[0].fg.fixedSchema==0 && pSrc->a[0].fg.isSubquery==0 );
137671 pSrc->a[0].u4.zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName);
137672 }
137673 pSelect = sqlite3SelectNew(pParse,
137674 sqlite3ExprListAppend(pParse, 0, pRaise),
137675 pSrc,
137676 pWhere,
@@ -137688,11 +138063,14 @@
137688 );
137689 if( pTrigger ){
137690 pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1];
137691 pStep->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
137692 if( pStep->pSrc ){
137693 pStep->pSrc->a[0].zName = sqlite3DbStrNDup(db, zFrom, nFrom);
 
 
 
137694 }
137695 pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
137696 pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE);
137697 pStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
137698 if( pWhen ){
@@ -145777,20 +146155,32 @@
145777 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
145778 pPrior, r1);
145779 pPrior = pIdx;
145780 sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1);/* increment entry count */
145781 /* Verify that an index entry exists for the current table row */
145782 jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1,
145783 pIdx->nColumn); VdbeCoverage(v);
 
 
 
 
 
 
 
 
 
 
 
 
145784 sqlite3VdbeLoadString(v, 3, "row ");
145785 sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);
145786 sqlite3VdbeLoadString(v, 4, " missing from index ");
145787 sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
145788 jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName);
145789 sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
145790 jmp4 = integrityCheckResultRow(v);
145791 sqlite3VdbeJumpHere(v, jmp2);
145792
145793 /* The OP_IdxRowid opcode is an optimized version of OP_Column
145794 ** that extracts the rowid off the end of the index record.
145795 ** But it only works correctly if index record does not have
145796 ** any extra bytes at the end. Verify that this is the case. */
@@ -165710,10 +166100,19 @@
165710 if( ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) ) continue;
165711 pSubWhere = sqlite3ExprAnd(pParse, pSubWhere,
165712 sqlite3ExprDup(pParse->db, pTerm->pExpr, 0));
165713 }
165714 }
 
 
 
 
 
 
 
 
 
165715 pFrom = &uSrc.sSrc;
165716 pFrom->nSrc = 1;
165717 pFrom->nAlloc = 1;
165718 memcpy(&pFrom->a[0], pTabItem, sizeof(SrcItem));
165719 pFrom->a[0].fg.jointype = 0;
@@ -170153,15 +170552,20 @@
170153 ** 1.002.001 t2.t2xy 2 f 010241 N 2 cost 0,56,31
170154 */
170155 SQLITE_PRIVATE void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC){
170156 WhereInfo *pWInfo;
170157 if( pWC ){
 
 
 
 
 
170158 pWInfo = pWC->pWInfo;
170159 int nb = 1+(pWInfo->pTabList->nSrc+3)/4;
170160 SrcItem *pItem = pWInfo->pTabList->a + p->iTab;
170161 Table *pTab = pItem->pSTab;
170162 Bitmask mAll = (((Bitmask)1)<<(nb*4)) - 1;
170163 sqlite3DebugPrintf("%c%2d.%0*llx.%0*llx", p->cId,
170164 p->iTab, nb, p->maskSelf, nb, p->prereq & mAll);
170165 sqlite3DebugPrintf(" %12s",
170166 pItem->zAlias ? pItem->zAlias : pTab->zName);
170167 }else{
@@ -175258,19 +175662,26 @@
175258 && (n = pLoop->u.btree.nDistinctCol)>0
175259 && pIdx->aiRowLogEst[n]>=36
175260 ){
175261 int r1 = pParse->nMem+1;
175262 int j, op;
 
 
 
 
175263 for(j=0; j<n; j++){
175264 sqlite3VdbeAddOp3(v, OP_Column, pLevel->iIdxCur, j, r1+j);
175265 }
175266 pParse->nMem += n+1;
175267 op = pLevel->op==OP_Prev ? OP_SeekLT : OP_SeekGT;
175268 addrSeek = sqlite3VdbeAddOp4Int(v, op, pLevel->iIdxCur, 0, r1, n);
175269 VdbeCoverageIf(v, op==OP_SeekLT);
175270 VdbeCoverageIf(v, op==OP_SeekGT);
175271 sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2);
 
 
 
175272 }
175273 #endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */
175274 }
175275 if( pTabList->a[pLevel->iFrom].fg.fromExists
175276 && (i==pWInfo->nLevel-1
@@ -185745,11 +186156,11 @@
185745 case TK_NULL: {
185746 if( prevType==TK_IS || prevType==TK_NOT ){
185747 sqlite3_str_append(pStr, " NULL", 5);
185748 break;
185749 }
185750 /* Fall through */
185751 }
185752 case TK_STRING:
185753 case TK_INTEGER:
185754 case TK_FLOAT:
185755 case TK_VARIABLE:
@@ -185809,11 +186220,11 @@
185809 }
185810 break;
185811 }
185812 case TK_SELECT: {
185813 iStartIN = 0;
185814 /* fall through */
185815 }
185816 default: {
185817 if( sqlite3IsIdChar(zSql[i]) ) addSpaceSeparator(pStr);
185818 j = pStr->nChar;
185819 sqlite3_str_append(pStr, zSql+i, n);
@@ -192525,11 +192936,20 @@
192525 #endif
192526
192527 #define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32))
192528 #define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
192529
192530 #define deliberate_fall_through
 
 
 
 
 
 
 
 
 
192531
192532 /*
192533 ** Macros needed to provide flexible arrays in a portable way
192534 */
192535 #ifndef offsetof
@@ -199254,11 +199674,11 @@
199254 assert( iCol==0 );
199255 if( v>1 ){
199256 pCsr->aStat[1].nDoc++;
199257 }
199258 eState = 2;
199259 /* fall through */
199260
199261 case 2:
199262 if( v==0 ){ /* 0x00. Next integer will be a docid. */
199263 eState = 0;
199264 }else if( v==1 ){ /* 0x01. Next integer will be a column number. */
@@ -212711,15 +213131,15 @@
212711 }
212712
212713 /* Slow version of jsonBlobAppendNode() that first resizes the
212714 ** pParse->aBlob structure.
212715 */
212716 static void jsonBlobAppendNode(JsonParse*,u8,u32,const void*);
212717 static SQLITE_NOINLINE void jsonBlobExpandAndAppendNode(
212718 JsonParse *pParse,
212719 u8 eType,
212720 u32 szPayload,
212721 const void *aPayload
212722 ){
212723 if( jsonBlobExpand(pParse, pParse->nBlob+szPayload+9) ) return;
212724 jsonBlobAppendNode(pParse, eType, szPayload, aPayload);
212725 }
@@ -212735,11 +213155,11 @@
212735 ** pointing to where the first byte of payload will eventually be.
212736 */
212737 static void jsonBlobAppendNode(
212738 JsonParse *pParse, /* The JsonParse object under construction */
212739 u8 eType, /* Node type. One of JSONB_* */
212740 u32 szPayload, /* Number of bytes of payload */
212741 const void *aPayload /* The payload. Might be NULL */
212742 ){
212743 u8 *a;
212744 if( pParse->nBlob+szPayload+9 > pParse->nBlobAlloc ){
212745 jsonBlobExpandAndAppendNode(pParse,eType,szPayload,aPayload);
@@ -214135,10 +214555,11 @@
214135 u32 nDel, /* Number of bytes to remove */
214136 const u8 *aIns, /* Content to insert */
214137 u32 nIns /* Bytes of content to insert */
214138 ){
214139 i64 d = (i64)nIns - (i64)nDel;
 
214140 if( d<0 && d>=(-8) && aIns!=0
214141 && jsonBlobOverwrite(&pParse->aBlob[iDel], aIns, nIns, (int)-d)
214142 ){
214143 return;
214144 }
@@ -218177,11 +218598,21 @@
218177 pRtree->nBusy--;
218178 if( pRtree->nBusy==0 ){
218179 pRtree->inWrTrans = 0;
218180 assert( pRtree->nCursor==0 );
218181 nodeBlobReset(pRtree);
218182 assert( pRtree->nNodeRef==0 || pRtree->bCorrupt );
 
 
 
 
 
 
 
 
 
 
218183 sqlite3_finalize(pRtree->pWriteNode);
218184 sqlite3_finalize(pRtree->pDeleteNode);
218185 sqlite3_finalize(pRtree->pReadRowid);
218186 sqlite3_finalize(pRtree->pWriteRowid);
218187 sqlite3_finalize(pRtree->pDeleteRowid);
@@ -219469,11 +219900,11 @@
219469 RtreeNode *pParent = p->pParent;
219470 RtreeCell cell;
219471 int iCell;
219472
219473 cnt++;
219474 if( NEVER(cnt>100) ){
219475 RTREE_IS_CORRUPT(pRtree);
219476 return SQLITE_CORRUPT_VTAB;
219477 }
219478 rc = nodeParentIndex(pRtree, p, &iCell);
219479 if( NEVER(rc!=SQLITE_OK) ){
@@ -219827,19 +220258,10 @@
219827 }
219828 }else if( newCellIsRight==0 ){
219829 rc = updateMapping(pRtree, pCell->iRowid, pLeft, iHeight);
219830 }
219831
219832 if( rc==SQLITE_OK ){
219833 rc = nodeRelease(pRtree, pRight);
219834 pRight = 0;
219835 }
219836 if( rc==SQLITE_OK ){
219837 rc = nodeRelease(pRtree, pLeft);
219838 pLeft = 0;
219839 }
219840
219841 splitnode_out:
219842 nodeRelease(pRtree, pRight);
219843 nodeRelease(pRtree, pLeft);
219844 sqlite3_free(aCell);
219845 return rc;
@@ -220020,11 +220442,11 @@
220020 }
220021 if( nodeInsertCell(pRtree, pNode, pCell) ){
220022 rc = SplitNode(pRtree, pNode, pCell, iHeight);
220023 }else{
220024 rc = AdjustTree(pRtree, pNode, pCell);
220025 if( ALWAYS(rc==SQLITE_OK) ){
220026 if( iHeight==0 ){
220027 rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);
220028 }else{
220029 rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);
220030 }
@@ -261855,11 +262277,11 @@
261855 int nArg, /* Number of args */
261856 sqlite3_value **apUnused /* Function arguments */
261857 ){
261858 assert( nArg==0 );
261859 UNUSED_PARAM2(nArg, apUnused);
261860 sqlite3_result_text(pCtx, "fts5: 2026-03-06 16:01:44 557aeb43869d3585137b17690cb3b64f7de6921774daae9e56403c3717dceab6", -1, SQLITE_TRANSIENT);
261861 }
261862
261863 /*
261864 ** Implementation of fts5_locale(LOCALE, TEXT) function.
261865 **
261866
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.53.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 5c237f1f863a32cf229010d2024d0d1e76a0 with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -465,16 +465,16 @@
465 **
466 ** See also: [sqlite3_libversion()],
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.53.0"
471 #define SQLITE_VERSION_NUMBER 3053000
472 #define SQLITE_SOURCE_ID "2026-03-18 22:31:56 5c237f1f863a32cf229010d2024d0d1e76a07a4d8b9492b26503b959f1c32485"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2026-03-18T22:31:56.220Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -2977,11 +2977,11 @@
2977 ** default value 17, as of SQLite version 3.52.0. The value was 15 in all
2978 ** prior versions.<p>
2979 ** This option takes two arguments which are an integer and a pointer
2980 ** to an integer. The first argument is a small integer, between 3 and 23, or
2981 ** zero. The FP_DIGITS setting is changed to that small integer, or left
2982 ** unaltered if the first argument is zero or out of range. The second argument
2983 ** is a pointer to an integer. If the pointer is not NULL, then the value of
2984 ** the FP_DIGITS setting, after possibly being modified by the first
2985 ** arguments, is written into the integer to which the second argument points.
2986 ** </dd>
2987 **
@@ -4807,11 +4807,11 @@
4807 ** are constructors for the [prepared statement] object.
4808 **
4809 ** The preferred routine to use is [sqlite3_prepare_v2()]. The
4810 ** [sqlite3_prepare()] interface is legacy and should be avoided.
4811 ** [sqlite3_prepare_v3()] has an extra
4812 ** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is sometimes
4813 ** needed for special purpose or to pass along security restrictions.
4814 **
4815 ** The use of the UTF-8 interfaces is preferred, as SQLite currently
4816 ** does all parsing using UTF-8. The UTF-16 interfaces are provided
4817 ** as a convenience. The UTF-16 interfaces work by converting the
@@ -6814,11 +6814,11 @@
6814 ** application-defined function to be a text string in an encoding
6815 ** specified the E parameter, which must be one
6816 ** of [SQLITE_UTF8], [SQLITE_UTF8_ZT], [SQLITE_UTF16], [SQLITE_UTF16BE],
6817 ** or [SQLITE_UTF16LE]. ^The special value [SQLITE_UTF8_ZT] means that
6818 ** the result text is both UTF-8 and zero-terminated. In other words,
6819 ** SQLITE_UTF8_ZT means that the Z array holds at least N+1 bytes and that
6820 ** the Z&#91;N&#93; is zero.
6821 ** ^SQLite takes the text result from the application from
6822 ** the 2nd parameter of the sqlite3_result_text* interfaces.
6823 ** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
6824 ** other than sqlite3_result_text64() is negative, then SQLite computes
@@ -9184,11 +9184,11 @@
9184 **
9185 ** ^The [sqlite3_str_reset(X)] method resets the string under construction
9186 ** inside [sqlite3_str] object X back to zero bytes in length.
9187 **
9188 ** ^The [sqlite3_str_truncate(X,N)] method changes the length of the string
9189 ** under construction to be N bytes or less. This routine is a no-op if
9190 ** N is negative or if the string is already N bytes or smaller in size.
9191 **
9192 ** These methods do not return a result code. ^If an error occurs, that fact
9193 ** is recorded in the [sqlite3_str] object and can be recovered by a
9194 ** subsequent call to [sqlite3_str_errcode(X)].
@@ -11048,11 +11048,11 @@
11048 ** - less than -1 or greater than or equal to the total number of query
11049 ** elements used to implement the statement - a non-zero value is returned and
11050 ** the variable that pOut points to is unchanged.
11051 **
11052 ** See also: [sqlite3_stmt_scanstatus_reset()] and the
11053 ** [nexec and ncycle] columns of the [bytecode virtual table].
11054 */
11055 SQLITE_API int sqlite3_stmt_scanstatus(
11056 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
11057 int idx, /* Index of loop to report on */
11058 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
@@ -11604,21 +11604,21 @@
11604 **
11605 ** If the X argument is not a NULL pointer or one of the special
11606 ** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke
11607 ** the function X with argument D when it is finished using the data in P.
11608 ** The call to X(D) is a destructor for the array P. The destructor X(D)
11609 ** is invoked even if the call to sqlite3_carray_bind_v2() fails. If the X
11610 ** parameter is the special-case value [SQLITE_STATIC], then SQLite assumes
11611 ** that the data static and the destructor is never invoked. If the X
11612 ** parameter is the special-case value [SQLITE_TRANSIENT], then
11613 ** sqlite3_carray_bind_v2() makes its own private copy of the data prior
11614 ** to returning and never invokes the destructor X.
11615 **
11616 ** The sqlite3_carray_bind() function works the same as sqlite3_carray_bind_v2()
11617 ** with a D parameter set to P. In other words,
11618 ** sqlite3_carray_bind(S,I,P,N,F,X) is same as
11619 ** sqlite3_carray_bind_v2(S,I,P,N,F,X,P).
11620 */
11621 SQLITE_API int sqlite3_carray_bind_v2(
11622 sqlite3_stmt *pStmt, /* Statement to be bound */
11623 int i, /* Parameter index */
11624 void *aData, /* Pointer to array data */
@@ -14740,13 +14740,11 @@
14740 #endif
14741
14742 /*
14743 ** Include standard header files as necessary
14744 */
 
14745 #include <stdint.h>
 
14746 #ifdef HAVE_INTTYPES_H
14747 #include <inttypes.h>
14748 #endif
14749
14750 /*
@@ -17315,10 +17313,11 @@
17313 KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */
17314 u32 *ai; /* Used when p4type is P4_INTARRAY */
17315 SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */
17316 Table *pTab; /* Used when p4type is P4_TABLE */
17317 SubrtnSig *pSubrtnSig; /* Used when p4type is P4_SUBRTNSIG */
17318 Index *pIdx; /* Used when p4type is P4_INDEX */
17319 #ifdef SQLITE_ENABLE_CURSOR_HINTS
17320 Expr *pExpr; /* Used when p4type is P4_EXPR */
17321 #endif
17322 } p4;
17323 #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
@@ -17369,24 +17368,25 @@
17368 #define P4_STATIC (-1) /* Pointer to a static string */
17369 #define P4_COLLSEQ (-2) /* P4 is a pointer to a CollSeq structure */
17370 #define P4_INT32 (-3) /* P4 is a 32-bit signed integer */
17371 #define P4_SUBPROGRAM (-4) /* P4 is a pointer to a SubProgram structure */
17372 #define P4_TABLE (-5) /* P4 is a pointer to a Table structure */
17373 #define P4_INDEX (-6) /* P4 is a pointer to an Index structure */
17374 /* Above do not own any resources. Must free those below */
17375 #define P4_FREE_IF_LE (-7)
17376 #define P4_DYNAMIC (-7) /* Pointer to memory from sqliteMalloc() */
17377 #define P4_FUNCDEF (-8) /* P4 is a pointer to a FuncDef structure */
17378 #define P4_KEYINFO (-9) /* P4 is a pointer to a KeyInfo structure */
17379 #define P4_EXPR (-10) /* P4 is a pointer to an Expr tree */
17380 #define P4_MEM (-11) /* P4 is a pointer to a Mem* structure */
17381 #define P4_VTAB (-12) /* P4 is a pointer to an sqlite3_vtab structure */
17382 #define P4_REAL (-13) /* P4 is a 64-bit floating point value */
17383 #define P4_INT64 (-14) /* P4 is a 64-bit signed integer */
17384 #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */
17385 #define P4_FUNCCTX (-16) /* P4 is a pointer to an sqlite3_context object */
17386 #define P4_TABLEREF (-17) /* Like P4_TABLE, but reference counted */
17387 #define P4_SUBRTNSIG (-18) /* P4 is a SubrtnSig pointer */
17388
17389 /* Error message codes for OP_Halt */
17390 #define P5_ConstraintNotNull 1
17391 #define P5_ConstraintUnique 2
17392 #define P5_ConstraintCheck 3
@@ -17471,66 +17471,66 @@
17471 #define OP_IdxGT 42 /* jump, synopsis: key=r[P3@P4] */
17472 #define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
17473 #define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
17474 #define OP_IdxLT 45 /* jump, synopsis: key=r[P3@P4] */
17475 #define OP_IdxGE 46 /* jump, synopsis: key=r[P3@P4] */
17476 #define OP_IFindKey 47 /* jump */
17477 #define OP_RowSetRead 48 /* jump, synopsis: r[P3]=rowset(P1) */
17478 #define OP_RowSetTest 49 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
17479 #define OP_Program 50 /* jump0 */
17480 #define OP_IsNull 51 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
17481 #define OP_NotNull 52 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
17482 #define OP_Ne 53 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
17483 #define OP_Eq 54 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */
17484 #define OP_Gt 55 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */
17485 #define OP_Le 56 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
17486 #define OP_Lt 57 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
17487 #define OP_Ge 58 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
17488 #define OP_ElseEq 59 /* jump, same as TK_ESCAPE */
17489 #define OP_FkIfZero 60 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
17490 #define OP_IfPos 61 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
17491 #define OP_IfNotZero 62 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
17492 #define OP_DecrJumpZero 63 /* jump, synopsis: if (--r[P1])==0 goto P2 */
17493 #define OP_IncrVacuum 64 /* jump */
17494 #define OP_VNext 65 /* jump */
17495 #define OP_Filter 66 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */
17496 #define OP_PureFunc 67 /* synopsis: r[P3]=func(r[P2@NP]) */
17497 #define OP_Function 68 /* synopsis: r[P3]=func(r[P2@NP]) */
17498 #define OP_Return 69
17499 #define OP_EndCoroutine 70
17500 #define OP_HaltIfNull 71 /* synopsis: if r[P3]=null halt */
17501 #define OP_Halt 72
17502 #define OP_Integer 73 /* synopsis: r[P2]=P1 */
17503 #define OP_Int64 74 /* synopsis: r[P2]=P4 */
17504 #define OP_String 75 /* synopsis: r[P2]='P4' (len=P1) */
17505 #define OP_BeginSubrtn 76 /* synopsis: r[P2]=NULL */
17506 #define OP_Null 77 /* synopsis: r[P2..P3]=NULL */
17507 #define OP_SoftNull 78 /* synopsis: r[P1]=NULL */
17508 #define OP_Blob 79 /* synopsis: r[P2]=P4 (len=P1) */
17509 #define OP_Variable 80 /* synopsis: r[P2]=parameter(P1) */
17510 #define OP_Move 81 /* synopsis: r[P2@P3]=r[P1@P3] */
17511 #define OP_Copy 82 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
17512 #define OP_SCopy 83 /* synopsis: r[P2]=r[P1] */
17513 #define OP_IntCopy 84 /* synopsis: r[P2]=r[P1] */
17514 #define OP_FkCheck 85
17515 #define OP_ResultRow 86 /* synopsis: output=r[P1@P2] */
17516 #define OP_CollSeq 87
17517 #define OP_AddImm 88 /* synopsis: r[P1]=r[P1]+P2 */
17518 #define OP_RealAffinity 89
17519 #define OP_Cast 90 /* synopsis: affinity(r[P1]) */
17520 #define OP_Permutation 91
17521 #define OP_Compare 92 /* synopsis: r[P1@P3] <-> r[P2@P3] */
17522 #define OP_IsTrue 93 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
17523 #define OP_ZeroOrNull 94 /* synopsis: r[P2] = 0 OR NULL */
17524 #define OP_Offset 95 /* synopsis: r[P3] = sqlite_offset(P1) */
17525 #define OP_Column 96 /* synopsis: r[P3]=PX cursor P1 column P2 */
17526 #define OP_TypeCheck 97 /* synopsis: typecheck(r[P1@P2]) */
17527 #define OP_Affinity 98 /* synopsis: affinity(r[P1@P2]) */
17528 #define OP_MakeRecord 99 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
17529 #define OP_Count 100 /* synopsis: r[P2]=count() */
17530 #define OP_ReadCookie 101
17531 #define OP_SetCookie 102
17532 #define OP_BitAnd 103 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
17533 #define OP_BitOr 104 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
17534 #define OP_ShiftLeft 105 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
17535 #define OP_ShiftRight 106 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
17536 #define OP_Add 107 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
@@ -17537,88 +17537,89 @@
17537 #define OP_Subtract 108 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
17538 #define OP_Multiply 109 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
17539 #define OP_Divide 110 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
17540 #define OP_Remainder 111 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
17541 #define OP_Concat 112 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
17542 #define OP_ReopenIdx 113 /* synopsis: root=P2 iDb=P3 */
17543 #define OP_OpenRead 114 /* synopsis: root=P2 iDb=P3 */
17544 #define OP_BitNot 115 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
17545 #define OP_OpenWrite 116 /* synopsis: root=P2 iDb=P3 */
17546 #define OP_OpenDup 117
17547 #define OP_String8 118 /* same as TK_STRING, synopsis: r[P2]='P4' */
17548 #define OP_OpenAutoindex 119 /* synopsis: nColumn=P2 */
17549 #define OP_OpenEphemeral 120 /* synopsis: nColumn=P2 */
17550 #define OP_SorterOpen 121
17551 #define OP_SequenceTest 122 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
17552 #define OP_OpenPseudo 123 /* synopsis: P3 columns in r[P2] */
17553 #define OP_Close 124
17554 #define OP_ColumnsUsed 125
17555 #define OP_SeekScan 126 /* synopsis: Scan-ahead up to P1 rows */
17556 #define OP_SeekHit 127 /* synopsis: set P2<=seekHit<=P3 */
17557 #define OP_Sequence 128 /* synopsis: r[P2]=cursor[P1].ctr++ */
17558 #define OP_NewRowid 129 /* synopsis: r[P2]=rowid */
17559 #define OP_Insert 130 /* synopsis: intkey=r[P3] data=r[P2] */
17560 #define OP_RowCell 131
17561 #define OP_Delete 132
17562 #define OP_ResetCount 133
17563 #define OP_SorterCompare 134 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
17564 #define OP_SorterData 135 /* synopsis: r[P2]=data */
17565 #define OP_RowData 136 /* synopsis: r[P2]=data */
17566 #define OP_Rowid 137 /* synopsis: r[P2]=PX rowid of P1 */
17567 #define OP_NullRow 138
17568 #define OP_SeekEnd 139
17569 #define OP_IdxInsert 140 /* synopsis: key=r[P2] */
17570 #define OP_SorterInsert 141 /* synopsis: key=r[P2] */
17571 #define OP_IdxDelete 142 /* synopsis: key=r[P2@P3] */
17572 #define OP_DeferredSeek 143 /* synopsis: Move P3 to P1.rowid if needed */
17573 #define OP_IdxRowid 144 /* synopsis: r[P2]=rowid */
17574 #define OP_FinishSeek 145
17575 #define OP_Destroy 146
17576 #define OP_Clear 147
17577 #define OP_ResetSorter 148
17578 #define OP_CreateBtree 149 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
17579 #define OP_SqlExec 150
17580 #define OP_ParseSchema 151
17581 #define OP_LoadAnalysis 152
17582 #define OP_DropTable 153
17583 #define OP_Real 154 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
17584 #define OP_DropIndex 155
17585 #define OP_DropTrigger 156
17586 #define OP_IntegrityCk 157
17587 #define OP_RowSetAdd 158 /* synopsis: rowset(P1)=r[P2] */
17588 #define OP_Param 159
17589 #define OP_FkCounter 160 /* synopsis: fkctr[P1]+=P2 */
17590 #define OP_MemMax 161 /* synopsis: r[P1]=max(r[P1],r[P2]) */
17591 #define OP_OffsetLimit 162 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
17592 #define OP_AggInverse 163 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
17593 #define OP_AggStep 164 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17594 #define OP_AggStep1 165 /* synopsis: accum=r[P3] step(r[P2@P5]) */
17595 #define OP_AggValue 166 /* synopsis: r[P3]=value N=P2 */
17596 #define OP_AggFinal 167 /* synopsis: accum=r[P1] N=P2 */
17597 #define OP_Expire 168
17598 #define OP_CursorLock 169
17599 #define OP_CursorUnlock 170
17600 #define OP_TableLock 171 /* synopsis: iDb=P1 root=P2 write=P3 */
17601 #define OP_VBegin 172
17602 #define OP_VCreate 173
17603 #define OP_VDestroy 174
17604 #define OP_VOpen 175
17605 #define OP_VCheck 176
17606 #define OP_VInitIn 177 /* synopsis: r[P2]=ValueList(P1,P3) */
17607 #define OP_VColumn 178 /* synopsis: r[P3]=vcolumn(P2) */
17608 #define OP_VRename 179
17609 #define OP_Pagecount 180
17610 #define OP_MaxPgcnt 181
17611 #define OP_ClrSubtype 182 /* synopsis: r[P1].subtype = 0 */
17612 #define OP_GetSubtype 183 /* synopsis: r[P2] = r[P1].subtype */
17613 #define OP_SetSubtype 184 /* synopsis: r[P2].subtype = r[P1] */
17614 #define OP_FilterAdd 185 /* synopsis: filter(P1) += key(P3@P4) */
17615 #define OP_Trace 186
17616 #define OP_CursorHint 187
17617 #define OP_ReleaseReg 188 /* synopsis: release r[P1@P2] mask P3 */
17618 #define OP_Noop 189
17619 #define OP_Explain 190
17620 #define OP_Abortable 191
17621
17622 /* Properties such as "out2" or "jump" that are specified in
17623 ** comments following the "case" for each opcode in the vdbe.c
17624 ** are encoded into bitvectors as follows:
17625 */
@@ -17634,37 +17635,38 @@
17635 /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x41, 0x00,\
17636 /* 8 */ 0x81, 0x01, 0x01, 0x81, 0x83, 0x83, 0x01, 0x01,\
17637 /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0xc9, 0xc9, 0xc9,\
17638 /* 24 */ 0xc9, 0x01, 0x49, 0x49, 0x49, 0x49, 0xc9, 0x49,\
17639 /* 32 */ 0xc1, 0x01, 0x41, 0x41, 0xc1, 0x01, 0x01, 0x41,\
17640 /* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x41, 0x09,\
17641 /* 48 */ 0x23, 0x0b, 0x81, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\
17642 /* 56 */ 0x0b, 0x0b, 0x0b, 0x01, 0x01, 0x03, 0x03, 0x03,\
17643 /* 64 */ 0x01, 0x41, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08,\
17644 /* 72 */ 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10,\
17645 /* 80 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\
17646 /* 88 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20,\
17647 /* 96 */ 0x40, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x26,\
17648 /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
17649 /* 112 */ 0x26, 0x40, 0x40, 0x12, 0x00, 0x40, 0x10, 0x40,\
17650 /* 120 */ 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x40,\
17651 /* 128 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,\
17652 /* 136 */ 0x00, 0x50, 0x00, 0x40, 0x04, 0x04, 0x00, 0x40,\
17653 /* 144 */ 0x50, 0x40, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00,\
17654 /* 152 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x06, 0x10,\
17655 /* 160 */ 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00,\
17656 /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,\
17657 /* 176 */ 0x10, 0x50, 0x40, 0x00, 0x10, 0x10, 0x02, 0x12,\
17658 /* 184 */ 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
17659 }
17660
17661 /* The resolve3P2Values() routine is able to run faster if it knows
17662 ** the value of the largest JUMP opcode. The smaller the maximum
17663 ** JUMP opcode the better, so the mkopcodeh.tcl script that
17664 ** generated this include file strives to group all JUMP opcodes
17665 ** together near the beginning of the list.
17666 */
17667 #define SQLITE_MX_JUMP_OPCODE 66 /* Maximum JUMP opcode */
17668
17669 /************** End of opcodes.h *********************************************/
17670 /************** Continuing where we left off in vdbe.h ***********************/
17671
17672 /*
@@ -24682,10 +24684,11 @@
24684 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
24685 SQLITE_PRIVATE void sqlite3VdbePreUpdateHook(
24686 Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int,int);
24687 #endif
24688 SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p);
24689 SQLITE_PRIVATE int sqlite3VdbeFindIndexKey(BtCursor*, Index*, UnpackedRecord*, int*, int);
24690
24691 SQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *);
24692 SQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *);
24693 SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);
24694 SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);
@@ -35367,10 +35370,11 @@
35370 }else{
35371 assert( p->id!=0 && p->id!=GetCurrentThreadId() );
35372 rc = sqlite3Win32Wait((HANDLE)p->tid);
35373 assert( rc!=WAIT_IO_COMPLETION );
35374 bRc = CloseHandle((HANDLE)p->tid);
35375 (void)bRc; /* Prevent warning when assert() is a no-op */
35376 assert( bRc );
35377 }
35378 if( rc==WAIT_OBJECT_0 ) *ppOut = p->pResult;
35379 sqlite3_free(p);
35380 return (rc==WAIT_OBJECT_0) ? SQLITE_OK : SQLITE_ERROR;
@@ -36507,32 +36511,72 @@
36511 }
36512 return h;
36513 }
36514
36515 /*
36516 ** Two inputs are multiplied to get a 128-bit result. Write the
36517 ** lower 64-bits of the result into *pLo, and return the high-order
36518 ** 64 bits.
36519 */
36520 static u64 sqlite3Multiply128(u64 a, u64 b, u64 *pLo){
36521 #if (defined(__GNUC__) || defined(__clang__)) \
36522 && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv))
36523 __uint128_t r = (__uint128_t)a * b;
36524 *pLo = (u64)r;
36525 return (u64)(r>>64);
36526 #elif defined(_MSC_VER) && defined(_M_X64)
36527 *pLo = a*b;
36528 return __umulh(a, b);
36529 #else
36530 u64 a0 = (u32)a;
36531 u64 a1 = a >> 32;
36532 u64 b0 = (u32)b;
36533 u64 b1 = b >> 32;
36534 u64 a0b0 = a0 * b0;
36535 u64 a1b1 = a1 * b1;
36536 u64 a0b1 = a0 * b1;
36537 u64 a1b0 = a1 * b0;
36538 u64 t = (a0b0 >> 32) + (u32)a0b1 + (u32)a1b0;
36539 *pLo = (a0b0 & UINT64_C(0xffffffff)) | (t << 32);
36540 return a1b1 + (a0b1>>32) + (a1b0>>32) + (t>>32);
36541 #endif
36542 }
36543
36544 /*
36545 ** A is an unsigned 96-bit integer formed by (a<<32)+aLo.
36546 ** B is an unsigned 64-bit integer.
36547 **
36548 ** Compute the upper 96 bits of 160-bit result of A*B.
36549 **
36550 ** Write ((A*B)>>64 & 0xffffffff) (the middle 32 bits of A*B)
36551 ** into *pLo. Return the upper 64 bits of A*B.
36552 **
36553 ** The lower 64 bits of A*B are discarded.
36554 */
36555 static u64 sqlite3Multiply160(u64 a, u32 aLo, u64 b, u32 *pLo){
36556 u64 x2 = a>>32;
36557 u64 x1 = a&0xffffffff;
36558 u64 x0 = aLo;
36559 u64 y1 = b>>32;
36560 u64 y0 = b&0xffffffff;
36561 u64 x2y1 = x2*y1;
36562 u64 r4 = x2y1>>32;
36563 u64 x2y0 = x2*y0;
36564 u64 x1y1 = x1*y1;
36565 u64 r3 = (x2y1 & 0xffffffff) + (x2y0 >>32) + (x1y1 >>32);
36566 u64 x1y0 = x1*y0;
36567 u64 x0y1 = x0*y1;
36568 u64 r2 = (x2y0 & 0xffffffff) + (x1y1 & 0xffffffff) +
36569 (x1y0 >>32) + (x0y1>>32);
36570 u64 x0y0 = x0*y0;
36571 u64 r1 = (x1y0 & 0xffffffff) + (x0y1 & 0xffffffff) +
36572 (x0y0 >>32);
36573 r2 += r1>>32;
36574 r3 += r2>>32;
36575 *pLo = r2&0xffffffff;
36576 return (r4<<32) + r3;
36577 }
36578
36579 /*
36580 ** Return a u64 with the N-th bit set.
36581 */
36582 #define U64_BIT(N) (((u64)1)<<(N))
@@ -36552,102 +36596,145 @@
36596 ** Or, in other words, for any p in range, return the most significant
36597 ** 64 bits of pow(10,p). The pow(10,p) value is shifted left or right,
36598 ** as appropriate so the most significant 64 bits fit exactly into a
36599 ** 64-bit unsigned integer.
36600 **
36601 ** Write into *pLo the next 32 significant bits of the answer after
36602 ** the first 64.
36603 **
36604 ** Algorithm:
36605 **
36606 ** (1) For p between 0 and 26, return the value directly from the aBase[]
36607 ** lookup table.
36608 **
36609 ** (2) For p outside the range 0 to 26, use aScale[] for the initial value
36610 ** then refine that result (if necessary) by a single multiplication
36611 ** against aBase[].
36612 **
36613 ** The constant tables aBase[], aScale[], and aScaleLo[] are generated
36614 ** by the C program at ../tool/mkfptab.c run with the --round option.
36615 */
36616 static u64 powerOfTen(int p, u32 *pLo){
36617 static const u64 aBase[] = {
36618 UINT64_C(0x8000000000000000), /* 0: 1.0e+0 << 63 */
36619 UINT64_C(0xa000000000000000), /* 1: 1.0e+1 << 60 */
36620 UINT64_C(0xc800000000000000), /* 2: 1.0e+2 << 57 */
36621 UINT64_C(0xfa00000000000000), /* 3: 1.0e+3 << 54 */
36622 UINT64_C(0x9c40000000000000), /* 4: 1.0e+4 << 50 */
36623 UINT64_C(0xc350000000000000), /* 5: 1.0e+5 << 47 */
36624 UINT64_C(0xf424000000000000), /* 6: 1.0e+6 << 44 */
36625 UINT64_C(0x9896800000000000), /* 7: 1.0e+7 << 40 */
36626 UINT64_C(0xbebc200000000000), /* 8: 1.0e+8 << 37 */
36627 UINT64_C(0xee6b280000000000), /* 9: 1.0e+9 << 34 */
36628 UINT64_C(0x9502f90000000000), /* 10: 1.0e+10 << 30 */
36629 UINT64_C(0xba43b74000000000), /* 11: 1.0e+11 << 27 */
36630 UINT64_C(0xe8d4a51000000000), /* 12: 1.0e+12 << 24 */
36631 UINT64_C(0x9184e72a00000000), /* 13: 1.0e+13 << 20 */
36632 UINT64_C(0xb5e620f480000000), /* 14: 1.0e+14 << 17 */
36633 UINT64_C(0xe35fa931a0000000), /* 15: 1.0e+15 << 14 */
36634 UINT64_C(0x8e1bc9bf04000000), /* 16: 1.0e+16 << 10 */
36635 UINT64_C(0xb1a2bc2ec5000000), /* 17: 1.0e+17 << 7 */
36636 UINT64_C(0xde0b6b3a76400000), /* 18: 1.0e+18 << 4 */
36637 UINT64_C(0x8ac7230489e80000), /* 19: 1.0e+19 >> 0 */
36638 UINT64_C(0xad78ebc5ac620000), /* 20: 1.0e+20 >> 3 */
36639 UINT64_C(0xd8d726b7177a8000), /* 21: 1.0e+21 >> 6 */
36640 UINT64_C(0x878678326eac9000), /* 22: 1.0e+22 >> 10 */
36641 UINT64_C(0xa968163f0a57b400), /* 23: 1.0e+23 >> 13 */
36642 UINT64_C(0xd3c21bcecceda100), /* 24: 1.0e+24 >> 16 */
36643 UINT64_C(0x84595161401484a0), /* 25: 1.0e+25 >> 20 */
36644 UINT64_C(0xa56fa5b99019a5c8), /* 26: 1.0e+26 >> 23 */
36645 };
36646 static const u64 aScale[] = {
36647 UINT64_C(0x8049a4ac0c5811ae), /* 0: 1.0e-351 << 1229 */
36648 UINT64_C(0xcf42894a5dce35ea), /* 1: 1.0e-324 << 1140 */
36649 UINT64_C(0xa76c582338ed2621), /* 2: 1.0e-297 << 1050 */
36650 UINT64_C(0x873e4f75e2224e68), /* 3: 1.0e-270 << 960 */
36651 UINT64_C(0xda7f5bf590966848), /* 4: 1.0e-243 << 871 */
36652 UINT64_C(0xb080392cc4349dec), /* 5: 1.0e-216 << 781 */
36653 UINT64_C(0x8e938662882af53e), /* 6: 1.0e-189 << 691 */
36654 UINT64_C(0xe65829b3046b0afa), /* 7: 1.0e-162 << 602 */
36655 UINT64_C(0xba121a4650e4ddeb), /* 8: 1.0e-135 << 512 */
36656 UINT64_C(0x964e858c91ba2655), /* 9: 1.0e-108 << 422 */
36657 UINT64_C(0xf2d56790ab41c2a2), /* 10: 1.0e-81 << 333 */
36658 UINT64_C(0xc428d05aa4751e4c), /* 11: 1.0e-54 << 243 */
36659 UINT64_C(0x9e74d1b791e07e48), /* 12: 1.0e-27 << 153 */
36660 UINT64_C(0xcccccccccccccccc), /* 13: 1.0e-1 << 67 (special case) */
36661 UINT64_C(0xcecb8f27f4200f3a), /* 14: 1.0e+27 >> 26 */
36662 UINT64_C(0xa70c3c40a64e6c51), /* 15: 1.0e+54 >> 116 */
36663 UINT64_C(0x86f0ac99b4e8dafd), /* 16: 1.0e+81 >> 206 */
36664 UINT64_C(0xda01ee641a708de9), /* 17: 1.0e+108 >> 295 */
36665 UINT64_C(0xb01ae745b101e9e4), /* 18: 1.0e+135 >> 385 */
36666 UINT64_C(0x8e41ade9fbebc27d), /* 19: 1.0e+162 >> 475 */
36667 UINT64_C(0xe5d3ef282a242e81), /* 20: 1.0e+189 >> 564 */
36668 UINT64_C(0xb9a74a0637ce2ee1), /* 21: 1.0e+216 >> 654 */
36669 UINT64_C(0x95f83d0a1fb69cd9), /* 22: 1.0e+243 >> 744 */
36670 UINT64_C(0xf24a01a73cf2dccf), /* 23: 1.0e+270 >> 833 */
36671 UINT64_C(0xc3b8358109e84f07), /* 24: 1.0e+297 >> 923 */
36672 UINT64_C(0x9e19db92b4e31ba9), /* 25: 1.0e+324 >> 1013 */
36673 };
36674 static const unsigned int aScaleLo[] = {
36675 0x205b896d, /* 0: 1.0e-351 << 1229 */
36676 0x52064cad, /* 1: 1.0e-324 << 1140 */
36677 0xaf2af2b8, /* 2: 1.0e-297 << 1050 */
36678 0x5a7744a7, /* 3: 1.0e-270 << 960 */
36679 0xaf39a475, /* 4: 1.0e-243 << 871 */
36680 0xbd8d794e, /* 5: 1.0e-216 << 781 */
36681 0x547eb47b, /* 6: 1.0e-189 << 691 */
36682 0x0cb4a5a3, /* 7: 1.0e-162 << 602 */
36683 0x92f34d62, /* 8: 1.0e-135 << 512 */
36684 0x3a6a07f9, /* 9: 1.0e-108 << 422 */
36685 0xfae27299, /* 10: 1.0e-81 << 333 */
36686 0xaa97e14c, /* 11: 1.0e-54 << 243 */
36687 0x775ea265, /* 12: 1.0e-27 << 153 */
36688 0xcccccccc, /* 13: 1.0e-1 << 67 (special case) */
36689 0x00000000, /* 14: 1.0e+27 >> 26 */
36690 0x999090b6, /* 15: 1.0e+54 >> 116 */
36691 0x69a028bb, /* 16: 1.0e+81 >> 206 */
36692 0xe80e6f48, /* 17: 1.0e+108 >> 295 */
36693 0x5ec05dd0, /* 18: 1.0e+135 >> 385 */
36694 0x14588f14, /* 19: 1.0e+162 >> 475 */
36695 0x8f1668c9, /* 20: 1.0e+189 >> 564 */
36696 0x6d953e2c, /* 21: 1.0e+216 >> 654 */
36697 0x4abdaf10, /* 22: 1.0e+243 >> 744 */
36698 0xbc633b39, /* 23: 1.0e+270 >> 833 */
36699 0x0a862f81, /* 24: 1.0e+297 >> 923 */
36700 0x6c07a2c2, /* 25: 1.0e+324 >> 1013 */
36701 };
36702 int g, n;
36703 u64 s, x;
36704 u32 lo;
36705
36706 assert( p>=POWERSOF10_FIRST && p<=POWERSOF10_LAST );
36707 if( p<0 ){
36708 if( p==(-1) ){
36709 *pLo = aScaleLo[13];
36710 return aScale[13];
36711 }
36712 g = p/27;
36713 n = p%27;
36714 if( n ){
36715 g--;
36716 n += 27;
36717 }
36718 }else if( p<27 ){
36719 *pLo = 0;
36720 return aBase[p];
36721 }else{
36722 g = p/27;
36723 n = p%27;
36724 }
36725 s = aScale[g+13];
36726 if( n==0 ){
36727 *pLo = aScaleLo[g+13];
36728 return s;
36729 }
36730 x = sqlite3Multiply160(s,aScaleLo[g+13],aBase[n],&lo);
36731 if( (U64_BIT(63) & x)==0 ){
36732 x = x<<1 | ((lo>>31)&1);
36733 lo = (lo<<1) | 1;
36734 }
36735 *pLo = lo;
36736 return x;
36737 }
36738
36739 /*
36740 ** pow10to2(x) computes floor(log2(pow(10,x))).
@@ -36696,14 +36783,15 @@
36783 ** The input m is required to have its highest bit set. In other words,
36784 ** m should be left-shifted, and e decremented, to maximize the value of m.
36785 */
36786 static void sqlite3Fp2Convert10(u64 m, int e, int n, u64 *pD, int *pP){
36787 int p;
36788 u64 h, d1;
36789 u32 d2;
36790 assert( n>=1 && n<=18 );
36791 p = n - 1 - pwr2to10(e+63);
36792 h = sqlite3Multiply128(m, powerOfTen(p,&d2), &d1);
36793 assert( -(e + pwr10to2(p) + 2) >= 0 );
36794 assert( -(e + pwr10to2(p) + 1) <= 63 );
36795 if( n==18 ){
36796 h >>= -(e + pwr10to2(p) + 2);
36797 *pD = (h + ((h<<1)&2))>>1;
@@ -36715,49 +36803,50 @@
36803
36804 /*
36805 ** Return an IEEE754 floating point value that approximates d*pow(10,p).
36806 */
36807 static double sqlite3Fp10Convert2(u64 d, int p){
36808 int b, lp, e, adj, s;
36809 u32 pwr10l, mid1;
36810 u64 pwr10h, x, hi, lo, sticky, u, m;
 
 
 
36811 double r;
36812 if( p<POWERSOF10_FIRST ) return 0.0;
36813 if( p>POWERSOF10_LAST ) return INFINITY;
36814 b = 64 - countLeadingZeros(d);
 
 
 
 
 
 
36815 lp = pwr10to2(p);
36816 e = 53 - b - lp;
36817 if( e > 1074 ){
36818 if( e>=1130 ) return 0.0;
36819 e = 1074;
36820 }
36821 s = -(e-(64-b) + lp + 3);
36822 pwr10h = powerOfTen(p, &pwr10l);
36823 if( pwr10l!=0 ){
36824 pwr10h++;
36825 pwr10l = ~pwr10l;
36826 }
36827 x = d<<(64-b);
36828 hi = sqlite3Multiply128(x,pwr10h,&lo);
36829 mid1 = lo>>32;
36830 sticky = 1;
36831 if( (hi & (U64_BIT(s)-1))==0 ) {
36832 u32 mid2 = sqlite3Multiply128(x,((u64)pwr10l)<<32,&lo)>>32;
36833 sticky = (mid1-mid2 > 1);
36834 hi -= mid1 < mid2;
36835 }
36836 u = (hi>>s) | sticky;
36837 adj = (u >= U64_BIT(55)-2);
36838 if( adj ){
36839 u = (u>>adj) | (u&1);
36840 e -= adj;
36841 }
36842 m = (u + 1 + ((u>>2)&1)) >> 2;
36843 if( e<=(-972) ) return INFINITY;
36844 if((m & U64_BIT(52)) != 0){
36845 m = (m & ~U64_BIT(52)) | ((u64)(1075-e)<<52);
36846 }
36847 memcpy(&r,&m,8);
36848 return r;
36849 }
36850
36851 /*
36852 ** The string z[] is an text representation of a real number.
@@ -38424,66 +38513,66 @@
38513 /* 42 */ "IdxGT" OpHelp("key=r[P3@P4]"),
38514 /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
38515 /* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
38516 /* 45 */ "IdxLT" OpHelp("key=r[P3@P4]"),
38517 /* 46 */ "IdxGE" OpHelp("key=r[P3@P4]"),
38518 /* 47 */ "IFindKey" OpHelp(""),
38519 /* 48 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
38520 /* 49 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
38521 /* 50 */ "Program" OpHelp(""),
38522 /* 51 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
38523 /* 52 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
38524 /* 53 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
38525 /* 54 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
38526 /* 55 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
38527 /* 56 */ "Le" OpHelp("IF r[P3]<=r[P1]"),
38528 /* 57 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
38529 /* 58 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
38530 /* 59 */ "ElseEq" OpHelp(""),
38531 /* 60 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
38532 /* 61 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
38533 /* 62 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
38534 /* 63 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
38535 /* 64 */ "IncrVacuum" OpHelp(""),
38536 /* 65 */ "VNext" OpHelp(""),
38537 /* 66 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"),
38538 /* 67 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"),
38539 /* 68 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
38540 /* 69 */ "Return" OpHelp(""),
38541 /* 70 */ "EndCoroutine" OpHelp(""),
38542 /* 71 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
38543 /* 72 */ "Halt" OpHelp(""),
38544 /* 73 */ "Integer" OpHelp("r[P2]=P1"),
38545 /* 74 */ "Int64" OpHelp("r[P2]=P4"),
38546 /* 75 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
38547 /* 76 */ "BeginSubrtn" OpHelp("r[P2]=NULL"),
38548 /* 77 */ "Null" OpHelp("r[P2..P3]=NULL"),
38549 /* 78 */ "SoftNull" OpHelp("r[P1]=NULL"),
38550 /* 79 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
38551 /* 80 */ "Variable" OpHelp("r[P2]=parameter(P1)"),
38552 /* 81 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
38553 /* 82 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
38554 /* 83 */ "SCopy" OpHelp("r[P2]=r[P1]"),
38555 /* 84 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
38556 /* 85 */ "FkCheck" OpHelp(""),
38557 /* 86 */ "ResultRow" OpHelp("output=r[P1@P2]"),
38558 /* 87 */ "CollSeq" OpHelp(""),
38559 /* 88 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
38560 /* 89 */ "RealAffinity" OpHelp(""),
38561 /* 90 */ "Cast" OpHelp("affinity(r[P1])"),
38562 /* 91 */ "Permutation" OpHelp(""),
38563 /* 92 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
38564 /* 93 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
38565 /* 94 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
38566 /* 95 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
38567 /* 96 */ "Column" OpHelp("r[P3]=PX cursor P1 column P2"),
38568 /* 97 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
38569 /* 98 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
38570 /* 99 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
38571 /* 100 */ "Count" OpHelp("r[P2]=count()"),
38572 /* 101 */ "ReadCookie" OpHelp(""),
38573 /* 102 */ "SetCookie" OpHelp(""),
38574 /* 103 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
38575 /* 104 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
38576 /* 105 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
38577 /* 106 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
38578 /* 107 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
@@ -38490,88 +38579,89 @@
38579 /* 108 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
38580 /* 109 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
38581 /* 110 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
38582 /* 111 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
38583 /* 112 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
38584 /* 113 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
38585 /* 114 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
38586 /* 115 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
38587 /* 116 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
38588 /* 117 */ "OpenDup" OpHelp(""),
38589 /* 118 */ "String8" OpHelp("r[P2]='P4'"),
38590 /* 119 */ "OpenAutoindex" OpHelp("nColumn=P2"),
38591 /* 120 */ "OpenEphemeral" OpHelp("nColumn=P2"),
38592 /* 121 */ "SorterOpen" OpHelp(""),
38593 /* 122 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
38594 /* 123 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
38595 /* 124 */ "Close" OpHelp(""),
38596 /* 125 */ "ColumnsUsed" OpHelp(""),
38597 /* 126 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
38598 /* 127 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
38599 /* 128 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
38600 /* 129 */ "NewRowid" OpHelp("r[P2]=rowid"),
38601 /* 130 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
38602 /* 131 */ "RowCell" OpHelp(""),
38603 /* 132 */ "Delete" OpHelp(""),
38604 /* 133 */ "ResetCount" OpHelp(""),
38605 /* 134 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
38606 /* 135 */ "SorterData" OpHelp("r[P2]=data"),
38607 /* 136 */ "RowData" OpHelp("r[P2]=data"),
38608 /* 137 */ "Rowid" OpHelp("r[P2]=PX rowid of P1"),
38609 /* 138 */ "NullRow" OpHelp(""),
38610 /* 139 */ "SeekEnd" OpHelp(""),
38611 /* 140 */ "IdxInsert" OpHelp("key=r[P2]"),
38612 /* 141 */ "SorterInsert" OpHelp("key=r[P2]"),
38613 /* 142 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
38614 /* 143 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
38615 /* 144 */ "IdxRowid" OpHelp("r[P2]=rowid"),
38616 /* 145 */ "FinishSeek" OpHelp(""),
38617 /* 146 */ "Destroy" OpHelp(""),
38618 /* 147 */ "Clear" OpHelp(""),
38619 /* 148 */ "ResetSorter" OpHelp(""),
38620 /* 149 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
38621 /* 150 */ "SqlExec" OpHelp(""),
38622 /* 151 */ "ParseSchema" OpHelp(""),
38623 /* 152 */ "LoadAnalysis" OpHelp(""),
38624 /* 153 */ "DropTable" OpHelp(""),
38625 /* 154 */ "Real" OpHelp("r[P2]=P4"),
38626 /* 155 */ "DropIndex" OpHelp(""),
38627 /* 156 */ "DropTrigger" OpHelp(""),
38628 /* 157 */ "IntegrityCk" OpHelp(""),
38629 /* 158 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
38630 /* 159 */ "Param" OpHelp(""),
38631 /* 160 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
38632 /* 161 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
38633 /* 162 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
38634 /* 163 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
38635 /* 164 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
38636 /* 165 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
38637 /* 166 */ "AggValue" OpHelp("r[P3]=value N=P2"),
38638 /* 167 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
38639 /* 168 */ "Expire" OpHelp(""),
38640 /* 169 */ "CursorLock" OpHelp(""),
38641 /* 170 */ "CursorUnlock" OpHelp(""),
38642 /* 171 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
38643 /* 172 */ "VBegin" OpHelp(""),
38644 /* 173 */ "VCreate" OpHelp(""),
38645 /* 174 */ "VDestroy" OpHelp(""),
38646 /* 175 */ "VOpen" OpHelp(""),
38647 /* 176 */ "VCheck" OpHelp(""),
38648 /* 177 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
38649 /* 178 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
38650 /* 179 */ "VRename" OpHelp(""),
38651 /* 180 */ "Pagecount" OpHelp(""),
38652 /* 181 */ "MaxPgcnt" OpHelp(""),
38653 /* 182 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"),
38654 /* 183 */ "GetSubtype" OpHelp("r[P2] = r[P1].subtype"),
38655 /* 184 */ "SetSubtype" OpHelp("r[P2].subtype = r[P1]"),
38656 /* 185 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
38657 /* 186 */ "Trace" OpHelp(""),
38658 /* 187 */ "CursorHint" OpHelp(""),
38659 /* 188 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
38660 /* 189 */ "Noop" OpHelp(""),
38661 /* 190 */ "Explain" OpHelp(""),
38662 /* 191 */ "Abortable" OpHelp(""),
38663 };
38664 return azName[i];
38665 }
38666 #endif
38667
@@ -73855,11 +73945,11 @@
73945 MemPage *pPage, /* Page containing the cell */
73946 u8 *pCell, /* Pointer to the cell text. */
73947 CellInfo *pInfo /* Fill in this structure */
73948 ){
73949 u8 *pIter; /* For scanning through pCell */
73950 u64 nPayload; /* Number of bytes of cell payload */
73951 u64 iKey; /* Extracted Key value */
73952
73953 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
73954 assert( pPage->leaf==0 || pPage->leaf==1 );
73955 assert( pPage->intKeyLeaf );
@@ -73877,10 +73967,11 @@
73967 u8 *pEnd = &pIter[8];
73968 nPayload &= 0x7f;
73969 do{
73970 nPayload = (nPayload<<7) | (*++pIter & 0x7f);
73971 }while( (*pIter)>=0x80 && pIter<pEnd );
73972 nPayload &= 0xffffffff;
73973 }
73974 pIter++;
73975
73976 /* The next block of code is equivalent to:
73977 **
@@ -73920,15 +74011,14 @@
74011 }
74012 }
74013 pIter++;
74014
74015 pInfo->nKey = *(i64*)&iKey;
74016 pInfo->nPayload = (u32)nPayload;
74017 pInfo->pPayload = pIter;
74018 testcase( nPayload==pPage->maxLocal );
74019 testcase( nPayload==(u32)pPage->maxLocal+1 );
 
74020 assert( pPage->maxLocal <= BT_MAX_LOCAL );
74021 if( nPayload<=pPage->maxLocal ){
74022 /* This is the (easy) common case where the entire payload fits
74023 ** on the local page. No overflow is required.
74024 */
@@ -89149,10 +89239,14 @@
89239 break;
89240 }
89241 case P4_TABLE: {
89242 zP4 = pOp->p4.pTab->zName;
89243 break;
89244 }
89245 case P4_INDEX: {
89246 zP4 = pOp->p4.pIdx->zName;
89247 break;
89248 }
89249 case P4_SUBRTNSIG: {
89250 SubrtnSig *pSig = pOp->p4.pSubrtnSig;
89251 sqlite3_str_appendf(&x, "subrtnsig:%d,%s", pSig->selId, pSig->zAff);
89252 break;
@@ -92539,10 +92633,227 @@
92633 v->expmask |= 0x80000000;
92634 }else{
92635 v->expmask |= ((u32)1 << (iVar-1));
92636 }
92637 }
92638
92639 /*
92640 ** Helper function for vdbeIsMatchingIndexKey(). Return true if column
92641 ** iCol should be ignored when comparing a record with a record from
92642 ** an index on disk. The field should be ignored if:
92643 **
92644 ** * the corresponding bit in mask is set, and
92645 ** * either:
92646 ** - bIntegrity is false, or
92647 ** - the two Mem values are both real values that differ by
92648 ** BTREE_ULPDISTORTION or fewer ULPs.
92649 */
92650 static int vdbeSkipField(
92651 Bitmask mask, /* Mask of indexed expression fields */
92652 int iCol, /* Column of index being considered */
92653 Mem *pMem1, /* Expected index value */
92654 Mem *pMem2, /* Actual indexed value */
92655 int bIntegrity /* True if running PRAGMA integrity_check */
92656 ){
92657 #define BTREE_ULPDISTORTION 2
92658 if( iCol>=BMS || (mask & MASKBIT(iCol))==0 ) return 0;
92659 if( bIntegrity==0 ) return 1;
92660 if( (pMem1->flags & MEM_Real) && (pMem2->flags & MEM_Real) ){
92661 u64 m1, m2;
92662 memcpy(&m1,&pMem1->u.r,8);
92663 memcpy(&m2,&pMem2->u.r,8);
92664 if( (m1<m2 ? m2-m1 : m1-m2) <= BTREE_ULPDISTORTION ){
92665 return 1;
92666 }
92667 }
92668 return 0;
92669 }
92670
92671 /*
92672 ** This function compares the unpacked record with the current key that
92673 ** cursor pCur points to. If bInt is false, all fields for which the
92674 ** corresponding bit in parameter "mask" is set are ignored. Or, if
92675 ** bInt is true, then a difference of BTREE_ULPDISTORTION or fewer ULPs
92676 ** in real values is overlooked for fields with the corresponding bit
92677 ** set in mask.
92678 **
92679 ** Return the usual less than zero, zero, or greater than zero if the
92680 ** remaining fields of the cursor cursor key are less than, equal to or
92681 ** greater than those in (*p).
92682 */
92683 static int vdbeIsMatchingIndexKey(
92684 BtCursor *pCur, /* Cursor open on index */
92685 int bInt, /* True for integrity_check-style search */
92686 Bitmask mask, /* Mask of columns to skip */
92687 UnpackedRecord *p, /* Index key being deleted */
92688 int *piRes /* 0 for a match, non-zero for not a match */
92689 ){
92690 u8 *aRec = 0;
92691 u32 nRec = 0;
92692 Mem mem;
92693 int rc = SQLITE_OK;
92694
92695 memset(&mem, 0, sizeof(mem));
92696 mem.enc = p->pKeyInfo->enc;
92697 mem.db = p->pKeyInfo->db;
92698 nRec = sqlite3BtreePayloadSize(pCur);
92699 if( nRec>0x7fffffff ){
92700 return SQLITE_CORRUPT_BKPT;
92701 }
92702
92703 /* Allocate 5 extra bytes at the end of the buffer. This allows the
92704 ** getVarint32() call below to read slightly past the end of the buffer
92705 ** if the record is corrupt. */
92706 aRec = sqlite3MallocZero(nRec+5);
92707 if( aRec==0 ){
92708 rc = SQLITE_NOMEM_BKPT;
92709 }else{
92710 rc = sqlite3BtreePayload(pCur, 0, nRec, aRec);
92711 }
92712
92713 if( rc==SQLITE_OK ){
92714 u32 szHdr = 0; /* Size of record header in bytes */
92715 u32 idxHdr = 0; /* Current index in header */
92716
92717 idxHdr = getVarint32(aRec, szHdr);
92718 if( szHdr>98307 ){
92719 rc = SQLITE_CORRUPT;
92720 }else{
92721 int res = 0; /* Result of this function call */
92722 u32 idxRec = szHdr; /* Index of next field in record body */
92723 int ii = 0; /* Iterator variable */
92724
92725 int nCol = p->pKeyInfo->nAllField;
92726 for(ii=0; ii<nCol && rc==SQLITE_OK; ii++){
92727 u32 iSerial = 0;
92728 int nSerial = 0;
92729
92730 if( idxHdr>=szHdr ){
92731 rc = SQLITE_CORRUPT_BKPT;
92732 break;
92733 }
92734 idxHdr += getVarint32(&aRec[idxHdr], iSerial);
92735 nSerial = sqlite3VdbeSerialTypeLen(iSerial);
92736 if( (idxRec+nSerial)>nRec ){
92737 rc = SQLITE_CORRUPT_BKPT;
92738 }else{
92739 sqlite3VdbeSerialGet(&aRec[idxRec], iSerial, &mem);
92740 if( vdbeSkipField(mask, ii, &p->aMem[ii], &mem, bInt)==0 ){
92741 res = sqlite3MemCompare(&mem, &p->aMem[ii], p->pKeyInfo->aColl[ii]);
92742 if( res!=0 ) break;
92743 }
92744 }
92745 idxRec += sqlite3VdbeSerialTypeLen(iSerial);
92746 }
92747
92748 *piRes = res;
92749 }
92750 }
92751
92752 sqlite3_free(aRec);
92753 return rc;
92754 }
92755
92756 /*
92757 ** This is called when the record in (*p) should be found in the index
92758 ** opened by cursor pCur, but was not. This may happen as part of a DELETE
92759 ** operation or an integrity check.
92760 **
92761 ** One reason that an exact match was not found may be the EIIB bug - that
92762 ** a text-to-float conversion may have caused a real value in record (*p)
92763 ** to be slightly different from its counterpart on disk. This function
92764 ** attempts to find the right index record. If it does find the right
92765 ** record, it leaves *pCur pointing to it and sets (*pRes) to 0 before
92766 ** returning. Otherwise, (*pRes) is set to non-zero and an SQLite error
92767 ** code returned.
92768 **
92769 ** The algorithm used to find the correct record is:
92770 **
92771 ** * Scan up to BTREE_FDK_RANGE entries either side of the current entry.
92772 ** If parameter bIntegrity is false, then all fields that are indexed
92773 ** expressions or virtual table columns are omitted from the comparison.
92774 ** If bIntegrity is true, then small differences in real values in
92775 ** such fields are overlooked, but they are not omitted from the comparison
92776 ** altogether.
92777 **
92778 ** * If the above fails to find an entry and bIntegrity is false, search
92779 ** the entire index.
92780 */
92781 SQLITE_PRIVATE int sqlite3VdbeFindIndexKey(
92782 BtCursor *pCur,
92783 Index *pIdx,
92784 UnpackedRecord *p,
92785 int *pRes,
92786 int bIntegrity
92787 ){
92788 #define BTREE_FDK_RANGE 10
92789 int nStep = 0;
92790 int res = 1;
92791 int rc = SQLITE_OK;
92792 int ii = 0;
92793
92794 /* Calculate a mask based on the first 64 columns of the index. The mask
92795 ** bit is set if the corresponding index field is either an expression
92796 ** or a virtual column of the table. */
92797 Bitmask mask = 0;
92798 for(ii=0; ii<MIN(pIdx->nColumn, BMS); ii++){
92799 int iCol = pIdx->aiColumn[ii];
92800 if( (iCol==XN_EXPR)
92801 || (iCol>=0 && (pIdx->pTable->aCol[iCol].colFlags & COLFLAG_VIRTUAL))
92802 ){
92803 mask |= MASKBIT(ii);
92804 }
92805 }
92806
92807 /* If the mask is 0 at this point, then the index contains no expressions
92808 ** or virtual columns. So do not search for a match - return so that the
92809 ** caller may declare the db corrupt immediately. Or, if mask is non-zero,
92810 ** proceed. */
92811 if( mask!=0 ){
92812
92813 /* Move the cursor back BTREE_FDK_RANGE entries. If this hits an EOF,
92814 ** position the cursor at the first entry in the index and set nStep
92815 ** to -1 so that the first loop below scans the entire index. Otherwise,
92816 ** set nStep to BTREE_FDK_RANGE*2 so that the first loop below scans
92817 ** just that many entries. */
92818 for(ii=0; sqlite3BtreeEof(pCur)==0 && ii<BTREE_FDK_RANGE; ii++){
92819 rc = sqlite3BtreePrevious(pCur, 0);
92820 }
92821 if( rc==SQLITE_DONE ){
92822 rc = sqlite3BtreeFirst(pCur, &res);
92823 nStep = -1;
92824 }else{
92825 nStep = BTREE_FDK_RANGE*2;
92826 }
92827
92828 /* This loop runs at most twice to search for a key with matching PK
92829 ** fields in the index. The second iteration always searches the entire
92830 ** index. The first iteration searches nStep entries starting with the
92831 ** current cursor entry if (nStep>=0), or the entire index if (nStep<0). */
92832 while( sqlite3BtreeCursorIsValidNN(pCur) ){
92833 for(ii=0; rc==SQLITE_OK && (ii<nStep || nStep<0); ii++){
92834 rc = vdbeIsMatchingIndexKey(pCur, bIntegrity, mask, p, &res);
92835 if( res==0 || rc!=SQLITE_OK ) break;
92836 rc = sqlite3BtreeNext(pCur, 0);
92837 }
92838 if( rc==SQLITE_DONE ){
92839 rc = SQLITE_OK;
92840 assert( res!=0 );
92841 }
92842 if( nStep<0 || rc!=SQLITE_OK || res==0 || bIntegrity ) break;
92843
92844 /* The first, non-exhaustive, search failed to find an entry with
92845 ** matching PK fields. So restart for an exhaustive search of the
92846 ** entire index. */
92847 nStep = -1;
92848 rc = sqlite3BtreeFirst(pCur, &res);
92849 }
92850 }
92851
92852 *pRes = res;
92853 return rc;
92854 }
92855
92856 #ifndef SQLITE_OMIT_DATETIME_FUNCS
92857 /*
92858 ** Cause a function to throw an error if it was call from OP_PureFunc
92859 ** rather than OP_Function.
@@ -102274,16 +102585,18 @@
102585 rc = sqlite3VdbeSorterWrite(pC, pIn2);
102586 if( rc) goto abort_due_to_error;
102587 break;
102588 }
102589
102590 /* Opcode: IdxDelete P1 P2 P3 P4 *
102591 ** Synopsis: key=r[P2@P3]
102592 **
102593 ** The content of P3 registers starting at register P2 form
102594 ** an unpacked index key. This opcode removes that entry from the
102595 ** index opened by cursor P1.
102596 **
102597 ** P4 is a pointer to an Index structure.
102598 **
102599 ** Raise an SQLITE_CORRUPT_INDEX error if no matching index entry is found
102600 ** and not in writable_schema mode.
102601 */
102602 case OP_IdxDelete: {
@@ -102305,17 +102618,26 @@
102618 r.nField = (u16)pOp->p3;
102619 r.default_rc = 0;
102620 r.aMem = &aMem[pOp->p2];
102621 rc = sqlite3BtreeIndexMoveto(pCrsr, &r, &res);
102622 if( rc ) goto abort_due_to_error;
102623 if( res!=0 ){
102624 rc = sqlite3VdbeFindIndexKey(pCrsr, pOp->p4.pIdx, &r, &res, 0);
102625 if( rc!=SQLITE_OK ) goto abort_due_to_error;
102626 if( res!=0 ){
102627 if( !sqlite3WritableSchema(db) ){
102628 rc = sqlite3ReportError(
102629 SQLITE_CORRUPT_INDEX, __LINE__, "index corruption");
102630 goto abort_due_to_error;
102631 }
102632 pC->cacheStatus = CACHE_STALE;
102633 pC->seekResult = 0;
102634 break;
102635 }
102636 }
102637 rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
102638 if( rc ) goto abort_due_to_error;
102639 assert( pC->deferredMoveto==0 );
102640 pC->cacheStatus = CACHE_STALE;
102641 pC->seekResult = 0;
102642 break;
102643 }
@@ -102938,10 +103260,62 @@
103260 }
103261 UPDATE_MAX_BLOBSIZE(pIn1);
103262 sqlite3VdbeChangeEncoding(pIn1, encoding);
103263 goto check_for_interrupt;
103264 }
103265
103266 /* Opcode: IFindKey P1 P2 P3 P4 *
103267 **
103268 ** This instruction always follows an OP_Found with the same P1, P2 and P3
103269 ** values as this instruction and a non-zero P4 value. The P4 value to
103270 ** this opcode is of type P4_INDEX and contains a pointer to the Index
103271 ** object of for the index being searched.
103272 **
103273 ** This opcode uses sqlite3VdbeFindIndexKey() to search around the current
103274 ** cursor location for an index key that exactly matches all fields that
103275 ** are not indexed expressions or references to VIRTUAL generated columns,
103276 ** and either exactly match or are real numbers that are within 2 ULPs of
103277 ** each other if the don't match.
103278 **
103279 ** To put it another way, this opcode looks for nearby index entries that
103280 ** are very close to the search key, but which might have small differences
103281 ** in floating-point values that come via an expression.
103282 **
103283 ** If no nearby alternative entry is found in cursor P1, then jump to P2.
103284 ** But if a close match is found, fall through.
103285 **
103286 ** This opcode is used by PRAGMA integrity_check to help distinguish
103287 ** between truely corrupt indexes and expression indexes that are holding
103288 ** floating-point values that are off by one or two ULPs.
103289 */
103290 case OP_IFindKey: { /* jump, in3 */
103291 VdbeCursor *pC;
103292 int res;
103293 UnpackedRecord r;
103294
103295 assert( pOp[-1].opcode==OP_Found );
103296 assert( pOp[-1].p1==pOp->p1 );
103297 assert( pOp[-1].p3==pOp->p3 );
103298 pC = p->apCsr[pOp->p1];
103299 assert( pOp->p4type==P4_INDEX );
103300 assert( pC->eCurType==CURTYPE_BTREE );
103301 assert( pC->uc.pCursor!=0 );
103302 assert( pC->isTable==0 );
103303
103304 memset(&r, 0, sizeof(r));
103305 r.aMem = &aMem[pOp->p3];
103306 r.nField = pOp->p4.pIdx->nColumn;
103307 r.pKeyInfo = pC->pKeyInfo;
103308
103309 rc = sqlite3VdbeFindIndexKey(pC->uc.pCursor, pOp->p4.pIdx, &r, &res, 1);
103310 if( rc || res!=0 ){
103311 rc = SQLITE_OK;
103312 goto jump_to_p2;
103313 }
103314 pC->nullRow = 0;
103315 break;
103316 };
103317 #endif /* SQLITE_OMIT_INTEGRITY_CHECK */
103318
103319 /* Opcode: RowSetAdd P1 P2 * * *
103320 ** Synopsis: rowset(P1)=r[P2]
103321 **
@@ -116950,11 +117324,11 @@
117324 #endif /* SQLITE_OMIT_CAST */
117325 case TK_IS:
117326 case TK_ISNOT:
117327 op = (op==TK_IS) ? TK_EQ : TK_NE;
117328 p5 = SQLITE_NULLEQ;
117329 /* no break */ deliberate_fall_through
117330 case TK_LT:
117331 case TK_LE:
117332 case TK_GT:
117333 case TK_GE:
117334 case TK_NE:
@@ -132751,11 +133125,13 @@
133125 if( iIdxCur+i==iIdxNoSeek ) continue;
133126 VdbeModuleComment((v, "GenRowIdxDel for %s", pIdx->zName));
133127 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 1,
133128 &iPartIdxLabel, pPrior, r1);
133129 sqlite3VdbeAddOp3(v, OP_IdxDelete, iIdxCur+i, r1,
133130 pIdx->uniqNotNull ? pIdx->nKeyCol : pIdx->nColumn
133131 );
133132 sqlite3VdbeChangeP4(v, -1, (const char*)pIdx, P4_INDEX);
133133 sqlite3ResolvePartIdxLabel(pParse, iPartIdxLabel);
133134 pPrior = pIdx;
133135 }
133136 }
133137
@@ -137652,11 +138028,10 @@
138028
138029 zFrom = pFKey->pFrom->zName;
138030 nFrom = sqlite3Strlen30(zFrom);
138031
138032 if( action==OE_Restrict ){
 
138033 SrcList *pSrc;
138034 Expr *pRaise;
138035
138036 pRaise = sqlite3Expr(db, TK_STRING, "FOREIGN KEY constraint failed"),
138037 pRaise = sqlite3PExpr(pParse, TK_RAISE, pRaise, 0);
@@ -137663,14 +138038,14 @@
138038 if( pRaise ){
138039 pRaise->affExpr = OE_Abort;
138040 }
138041 pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
138042 if( pSrc ){
138043 SrcItem *pItem = &pSrc->a[0];
138044 pItem->zName = sqlite3DbStrDup(db, zFrom);
138045 pItem->fg.fixedSchema = 1;
138046 pItem->u4.pSchema = pTab->pSchema;
138047 }
138048 pSelect = sqlite3SelectNew(pParse,
138049 sqlite3ExprListAppend(pParse, 0, pRaise),
138050 pSrc,
138051 pWhere,
@@ -137688,11 +138063,14 @@
138063 );
138064 if( pTrigger ){
138065 pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1];
138066 pStep->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
138067 if( pStep->pSrc ){
138068 SrcItem *pItem = &pStep->pSrc->a[0];
138069 pItem->zName = sqlite3DbStrNDup(db, zFrom, nFrom);
138070 pItem->u4.pSchema = pTab->pSchema;
138071 pItem->fg.fixedSchema = 1;
138072 }
138073 pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
138074 pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE);
138075 pStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
138076 if( pWhen ){
@@ -145777,20 +146155,32 @@
146155 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
146156 pPrior, r1);
146157 pPrior = pIdx;
146158 sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1);/* increment entry count */
146159 /* Verify that an index entry exists for the current table row */
146160 sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1,
146161 pIdx->nColumn); VdbeCoverage(v);
146162 jmp2 = sqlite3VdbeAddOp3(v, OP_IFindKey, iIdxCur+j, ckUniq, r1);
146163 VdbeCoverage(v);
146164 sqlite3VdbeChangeP4(v, -1, (const char*)pIdx, P4_INDEX);
146165 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
146166 sqlite3MPrintf(db, "index %s stores an imprecise floating-point "
146167 "value for row ", pIdx->zName),
146168 P4_DYNAMIC);
146169 sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);
146170 integrityCheckResultRow(v);
146171 sqlite3VdbeAddOp2(v, OP_Goto, 0, ckUniq);
146172
146173 sqlite3VdbeJumpHere(v, jmp2);
146174 sqlite3VdbeLoadString(v, 3, "row ");
146175 sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);
146176 sqlite3VdbeLoadString(v, 4, " missing from index ");
146177 sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
146178 jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName);
146179 sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
146180 jmp4 = integrityCheckResultRow(v);
146181 sqlite3VdbeResolveLabel(v, ckUniq);
146182
146183 /* The OP_IdxRowid opcode is an optimized version of OP_Column
146184 ** that extracts the rowid off the end of the index record.
146185 ** But it only works correctly if index record does not have
146186 ** any extra bytes at the end. Verify that this is the case. */
@@ -165710,10 +166100,19 @@
166100 if( ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) ) continue;
166101 pSubWhere = sqlite3ExprAnd(pParse, pSubWhere,
166102 sqlite3ExprDup(pParse->db, pTerm->pExpr, 0));
166103 }
166104 }
166105 if( pLevel->iIdxCur ){
166106 /* pSubWhere may contain expressions that read from an index on the
166107 ** table on the RHS of the right join. All such expressions first test
166108 ** if the index is pointing at a NULL row, and if so, read from the
166109 ** table cursor instead. So ensure that the index cursor really is
166110 ** pointing at a NULL row here, so that no values are read from it during
166111 ** the scan of the RHS of the RIGHT join below. */
166112 sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);
166113 }
166114 pFrom = &uSrc.sSrc;
166115 pFrom->nSrc = 1;
166116 pFrom->nAlloc = 1;
166117 memcpy(&pFrom->a[0], pTabItem, sizeof(SrcItem));
166118 pFrom->a[0].fg.jointype = 0;
@@ -170153,15 +170552,20 @@
170552 ** 1.002.001 t2.t2xy 2 f 010241 N 2 cost 0,56,31
170553 */
170554 SQLITE_PRIVATE void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC){
170555 WhereInfo *pWInfo;
170556 if( pWC ){
170557 int nb;
170558 SrcItem *pItem;
170559 Table *pTab;
170560 Bitmask mAll;
170561
170562 pWInfo = pWC->pWInfo;
170563 nb = 1+(pWInfo->pTabList->nSrc+3)/4;
170564 pItem = pWInfo->pTabList->a + p->iTab;
170565 pTab = pItem->pSTab;
170566 mAll = (((Bitmask)1)<<(nb*4)) - 1;
170567 sqlite3DebugPrintf("%c%2d.%0*llx.%0*llx", p->cId,
170568 p->iTab, nb, p->maskSelf, nb, p->prereq & mAll);
170569 sqlite3DebugPrintf(" %12s",
170570 pItem->zAlias ? pItem->zAlias : pTab->zName);
170571 }else{
@@ -175258,19 +175662,26 @@
175662 && (n = pLoop->u.btree.nDistinctCol)>0
175663 && pIdx->aiRowLogEst[n]>=36
175664 ){
175665 int r1 = pParse->nMem+1;
175666 int j, op;
175667 int addrIfNull = 0; /* Init to avoid false-positive compiler warning */
175668 if( pLevel->iLeftJoin ){
175669 addrIfNull = sqlite3VdbeAddOp2(v, OP_IfNullRow, pLevel->iIdxCur, r1);
175670 }
175671 for(j=0; j<n; j++){
175672 sqlite3VdbeAddOp3(v, OP_Column, pLevel->iIdxCur, j, r1+j);
175673 }
175674 pParse->nMem += n+1;
175675 op = pLevel->op==OP_Prev ? OP_SeekLT : OP_SeekGT;
175676 addrSeek = sqlite3VdbeAddOp4Int(v, op, pLevel->iIdxCur, 0, r1, n);
175677 VdbeCoverageIf(v, op==OP_SeekLT);
175678 VdbeCoverageIf(v, op==OP_SeekGT);
175679 sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2);
175680 if( pLevel->iLeftJoin ){
175681 sqlite3VdbeJumpHere(v, addrIfNull);
175682 }
175683 }
175684 #endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */
175685 }
175686 if( pTabList->a[pLevel->iFrom].fg.fromExists
175687 && (i==pWInfo->nLevel-1
@@ -185745,11 +186156,11 @@
186156 case TK_NULL: {
186157 if( prevType==TK_IS || prevType==TK_NOT ){
186158 sqlite3_str_append(pStr, " NULL", 5);
186159 break;
186160 }
186161 /* no break */ deliberate_fall_through
186162 }
186163 case TK_STRING:
186164 case TK_INTEGER:
186165 case TK_FLOAT:
186166 case TK_VARIABLE:
@@ -185809,11 +186220,11 @@
186220 }
186221 break;
186222 }
186223 case TK_SELECT: {
186224 iStartIN = 0;
186225 /* no break */ deliberate_fall_through
186226 }
186227 default: {
186228 if( sqlite3IsIdChar(zSql[i]) ) addSpaceSeparator(pStr);
186229 j = pStr->nChar;
186230 sqlite3_str_append(pStr, zSql+i, n);
@@ -192525,11 +192936,20 @@
192936 #endif
192937
192938 #define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32))
192939 #define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
192940
192941 #if !defined(deliberate_fall_through)
192942 # if defined(__has_attribute)
192943 # if __has_attribute(fallthrough)
192944 # define deliberate_fall_through __attribute__((fallthrough));
192945 # endif
192946 # endif
192947 #endif
192948 #if !defined(deliberate_fall_through)
192949 # define deliberate_fall_through
192950 #endif
192951
192952 /*
192953 ** Macros needed to provide flexible arrays in a portable way
192954 */
192955 #ifndef offsetof
@@ -199254,11 +199674,11 @@
199674 assert( iCol==0 );
199675 if( v>1 ){
199676 pCsr->aStat[1].nDoc++;
199677 }
199678 eState = 2;
199679 /* no break */ deliberate_fall_through
199680
199681 case 2:
199682 if( v==0 ){ /* 0x00. Next integer will be a docid. */
199683 eState = 0;
199684 }else if( v==1 ){ /* 0x01. Next integer will be a column number. */
@@ -212711,15 +213131,15 @@
213131 }
213132
213133 /* Slow version of jsonBlobAppendNode() that first resizes the
213134 ** pParse->aBlob structure.
213135 */
213136 static void jsonBlobAppendNode(JsonParse*,u8,u64,const void*);
213137 static SQLITE_NOINLINE void jsonBlobExpandAndAppendNode(
213138 JsonParse *pParse,
213139 u8 eType,
213140 u64 szPayload,
213141 const void *aPayload
213142 ){
213143 if( jsonBlobExpand(pParse, pParse->nBlob+szPayload+9) ) return;
213144 jsonBlobAppendNode(pParse, eType, szPayload, aPayload);
213145 }
@@ -212735,11 +213155,11 @@
213155 ** pointing to where the first byte of payload will eventually be.
213156 */
213157 static void jsonBlobAppendNode(
213158 JsonParse *pParse, /* The JsonParse object under construction */
213159 u8 eType, /* Node type. One of JSONB_* */
213160 u64 szPayload, /* Number of bytes of payload */
213161 const void *aPayload /* The payload. Might be NULL */
213162 ){
213163 u8 *a;
213164 if( pParse->nBlob+szPayload+9 > pParse->nBlobAlloc ){
213165 jsonBlobExpandAndAppendNode(pParse,eType,szPayload,aPayload);
@@ -214135,10 +214555,11 @@
214555 u32 nDel, /* Number of bytes to remove */
214556 const u8 *aIns, /* Content to insert */
214557 u32 nIns /* Bytes of content to insert */
214558 ){
214559 i64 d = (i64)nIns - (i64)nDel;
214560 assert( pParse->nBlob >= (u64)iDel + (u64)nDel );
214561 if( d<0 && d>=(-8) && aIns!=0
214562 && jsonBlobOverwrite(&pParse->aBlob[iDel], aIns, nIns, (int)-d)
214563 ){
214564 return;
214565 }
@@ -218177,11 +218598,21 @@
218598 pRtree->nBusy--;
218599 if( pRtree->nBusy==0 ){
218600 pRtree->inWrTrans = 0;
218601 assert( pRtree->nCursor==0 );
218602 nodeBlobReset(pRtree);
218603 if( pRtree->nNodeRef ){
218604 int i;
218605 assert( pRtree->bCorrupt );
218606 for(i=0; i<HASHSIZE; i++){
218607 while( pRtree->aHash[i] ){
218608 RtreeNode *pNext = pRtree->aHash[i]->pNext;
218609 sqlite3_free(pRtree->aHash[i]);
218610 pRtree->aHash[i] = pNext;
218611 }
218612 }
218613 }
218614 sqlite3_finalize(pRtree->pWriteNode);
218615 sqlite3_finalize(pRtree->pDeleteNode);
218616 sqlite3_finalize(pRtree->pReadRowid);
218617 sqlite3_finalize(pRtree->pWriteRowid);
218618 sqlite3_finalize(pRtree->pDeleteRowid);
@@ -219469,11 +219900,11 @@
219900 RtreeNode *pParent = p->pParent;
219901 RtreeCell cell;
219902 int iCell;
219903
219904 cnt++;
219905 if( cnt>100 ){
219906 RTREE_IS_CORRUPT(pRtree);
219907 return SQLITE_CORRUPT_VTAB;
219908 }
219909 rc = nodeParentIndex(pRtree, p, &iCell);
219910 if( NEVER(rc!=SQLITE_OK) ){
@@ -219827,19 +220258,10 @@
220258 }
220259 }else if( newCellIsRight==0 ){
220260 rc = updateMapping(pRtree, pCell->iRowid, pLeft, iHeight);
220261 }
220262
 
 
 
 
 
 
 
 
 
220263 splitnode_out:
220264 nodeRelease(pRtree, pRight);
220265 nodeRelease(pRtree, pLeft);
220266 sqlite3_free(aCell);
220267 return rc;
@@ -220020,11 +220442,11 @@
220442 }
220443 if( nodeInsertCell(pRtree, pNode, pCell) ){
220444 rc = SplitNode(pRtree, pNode, pCell, iHeight);
220445 }else{
220446 rc = AdjustTree(pRtree, pNode, pCell);
220447 if( rc==SQLITE_OK ){
220448 if( iHeight==0 ){
220449 rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);
220450 }else{
220451 rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);
220452 }
@@ -261855,11 +262277,11 @@
262277 int nArg, /* Number of args */
262278 sqlite3_value **apUnused /* Function arguments */
262279 ){
262280 assert( nArg==0 );
262281 UNUSED_PARAM2(nArg, apUnused);
262282 sqlite3_result_text(pCtx, "fts5: 2026-03-18 15:40:26 971aa34b3fd86ba30fe170886d9f83c17159b1638c4bd4fb6cdef79b1c9a88e2", -1, SQLITE_TRANSIENT);
262283 }
262284
262285 /*
262286 ** Implementation of fts5_locale(LOCALE, TEXT) function.
262287 **
262288
+13 -13
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -144,16 +144,16 @@
144144
**
145145
** See also: [sqlite3_libversion()],
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149
-#define SQLITE_VERSION "3.52.0"
150
-#define SQLITE_VERSION_NUMBER 3052000
151
-#define SQLITE_SOURCE_ID "2026-03-06 16:01:44 557aeb43869d3585137b17690cb3b64f7de6921774daae9e56403c3717dceab6"
149
+#define SQLITE_VERSION "3.53.0"
150
+#define SQLITE_VERSION_NUMBER 3053000
151
+#define SQLITE_SOURCE_ID "2026-03-18 22:31:56 5c237f1f863a32cf229010d2024d0d1e76a07a4d8b9492b26503b959f1c32485"
152152
#define SQLITE_SCM_BRANCH "trunk"
153
-#define SQLITE_SCM_TAGS "release major-release version-3.52.0"
154
-#define SQLITE_SCM_DATETIME "2026-03-06T16:01:44.367Z"
153
+#define SQLITE_SCM_TAGS ""
154
+#define SQLITE_SCM_DATETIME "2026-03-18T22:31:56.220Z"
155155
156156
/*
157157
** CAPI3REF: Run-Time Library Version Numbers
158158
** KEYWORDS: sqlite3_version sqlite3_sourceid
159159
**
@@ -2656,11 +2656,11 @@
26562656
** default value 17, as of SQLite version 3.52.0. The value was 15 in all
26572657
** prior versions.<p>
26582658
** This option takes two arguments which are an integer and a pointer
26592659
** to an integer. The first argument is a small integer, between 3 and 23, or
26602660
** zero. The FP_DIGITS setting is changed to that small integer, or left
2661
-** altered if the first argument is zero or out of range. The second argument
2661
+** unaltered if the first argument is zero or out of range. The second argument
26622662
** is a pointer to an integer. If the pointer is not NULL, then the value of
26632663
** the FP_DIGITS setting, after possibly being modified by the first
26642664
** arguments, is written into the integer to which the second argument points.
26652665
** </dd>
26662666
**
@@ -4486,11 +4486,11 @@
44864486
** are constructors for the [prepared statement] object.
44874487
**
44884488
** The preferred routine to use is [sqlite3_prepare_v2()]. The
44894489
** [sqlite3_prepare()] interface is legacy and should be avoided.
44904490
** [sqlite3_prepare_v3()] has an extra
4491
-** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is some times
4491
+** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is sometimes
44924492
** needed for special purpose or to pass along security restrictions.
44934493
**
44944494
** The use of the UTF-8 interfaces is preferred, as SQLite currently
44954495
** does all parsing using UTF-8. The UTF-16 interfaces are provided
44964496
** as a convenience. The UTF-16 interfaces work by converting the
@@ -6493,11 +6493,11 @@
64936493
** application-defined function to be a text string in an encoding
64946494
** specified the E parameter, which must be one
64956495
** of [SQLITE_UTF8], [SQLITE_UTF8_ZT], [SQLITE_UTF16], [SQLITE_UTF16BE],
64966496
** or [SQLITE_UTF16LE]. ^The special value [SQLITE_UTF8_ZT] means that
64976497
** the result text is both UTF-8 and zero-terminated. In other words,
6498
-** SQLITE_UTF8_ZT means that the Z array holds at least N+1 byes and that
6498
+** SQLITE_UTF8_ZT means that the Z array holds at least N+1 bytes and that
64996499
** the Z&#91;N&#93; is zero.
65006500
** ^SQLite takes the text result from the application from
65016501
** the 2nd parameter of the sqlite3_result_text* interfaces.
65026502
** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
65036503
** other than sqlite3_result_text64() is negative, then SQLite computes
@@ -8863,11 +8863,11 @@
88638863
**
88648864
** ^The [sqlite3_str_reset(X)] method resets the string under construction
88658865
** inside [sqlite3_str] object X back to zero bytes in length.
88668866
**
88678867
** ^The [sqlite3_str_truncate(X,N)] method changes the length of the string
8868
-** under construction to be N bytes are less. This routine is a no-op if
8868
+** under construction to be N bytes or less. This routine is a no-op if
88698869
** N is negative or if the string is already N bytes or smaller in size.
88708870
**
88718871
** These methods do not return a result code. ^If an error occurs, that fact
88728872
** is recorded in the [sqlite3_str] object and can be recovered by a
88738873
** subsequent call to [sqlite3_str_errcode(X)].
@@ -10727,11 +10727,11 @@
1072710727
** - less than -1 or greater than or equal to the total number of query
1072810728
** elements used to implement the statement - a non-zero value is returned and
1072910729
** the variable that pOut points to is unchanged.
1073010730
**
1073110731
** See also: [sqlite3_stmt_scanstatus_reset()] and the
10732
-** [nexec and ncycle] columnes of the [bytecode virtual table].
10732
+** [nexec and ncycle] columns of the [bytecode virtual table].
1073310733
*/
1073410734
SQLITE_API int sqlite3_stmt_scanstatus(
1073510735
sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
1073610736
int idx, /* Index of loop to report on */
1073710737
int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
@@ -11283,21 +11283,21 @@
1128311283
**
1128411284
** If the X argument is not a NULL pointer or one of the special
1128511285
** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke
1128611286
** the function X with argument D when it is finished using the data in P.
1128711287
** The call to X(D) is a destructor for the array P. The destructor X(D)
11288
-** is invoked even if the call to sqlite3_carray_bind() fails. If the X
11288
+** is invoked even if the call to sqlite3_carray_bind_v2() fails. If the X
1128911289
** parameter is the special-case value [SQLITE_STATIC], then SQLite assumes
1129011290
** that the data static and the destructor is never invoked. If the X
1129111291
** parameter is the special-case value [SQLITE_TRANSIENT], then
1129211292
** sqlite3_carray_bind_v2() makes its own private copy of the data prior
1129311293
** to returning and never invokes the destructor X.
1129411294
**
11295
-** The sqlite3_carray_bind() function works the same as sqlite_carray_bind_v2()
11295
+** The sqlite3_carray_bind() function works the same as sqlite3_carray_bind_v2()
1129611296
** with a D parameter set to P. In other words,
1129711297
** sqlite3_carray_bind(S,I,P,N,F,X) is same as
11298
-** sqlite3_carray_bind(S,I,P,N,F,X,P).
11298
+** sqlite3_carray_bind_v2(S,I,P,N,F,X,P).
1129911299
*/
1130011300
SQLITE_API int sqlite3_carray_bind_v2(
1130111301
sqlite3_stmt *pStmt, /* Statement to be bound */
1130211302
int i, /* Parameter index */
1130311303
void *aData, /* Pointer to array data */
1130411304
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -144,16 +144,16 @@
144 **
145 ** See also: [sqlite3_libversion()],
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.52.0"
150 #define SQLITE_VERSION_NUMBER 3052000
151 #define SQLITE_SOURCE_ID "2026-03-06 16:01:44 557aeb43869d3585137b17690cb3b64f7de6921774daae9e56403c3717dceab6"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS "release major-release version-3.52.0"
154 #define SQLITE_SCM_DATETIME "2026-03-06T16:01:44.367Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
@@ -2656,11 +2656,11 @@
2656 ** default value 17, as of SQLite version 3.52.0. The value was 15 in all
2657 ** prior versions.<p>
2658 ** This option takes two arguments which are an integer and a pointer
2659 ** to an integer. The first argument is a small integer, between 3 and 23, or
2660 ** zero. The FP_DIGITS setting is changed to that small integer, or left
2661 ** altered if the first argument is zero or out of range. The second argument
2662 ** is a pointer to an integer. If the pointer is not NULL, then the value of
2663 ** the FP_DIGITS setting, after possibly being modified by the first
2664 ** arguments, is written into the integer to which the second argument points.
2665 ** </dd>
2666 **
@@ -4486,11 +4486,11 @@
4486 ** are constructors for the [prepared statement] object.
4487 **
4488 ** The preferred routine to use is [sqlite3_prepare_v2()]. The
4489 ** [sqlite3_prepare()] interface is legacy and should be avoided.
4490 ** [sqlite3_prepare_v3()] has an extra
4491 ** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is some times
4492 ** needed for special purpose or to pass along security restrictions.
4493 **
4494 ** The use of the UTF-8 interfaces is preferred, as SQLite currently
4495 ** does all parsing using UTF-8. The UTF-16 interfaces are provided
4496 ** as a convenience. The UTF-16 interfaces work by converting the
@@ -6493,11 +6493,11 @@
6493 ** application-defined function to be a text string in an encoding
6494 ** specified the E parameter, which must be one
6495 ** of [SQLITE_UTF8], [SQLITE_UTF8_ZT], [SQLITE_UTF16], [SQLITE_UTF16BE],
6496 ** or [SQLITE_UTF16LE]. ^The special value [SQLITE_UTF8_ZT] means that
6497 ** the result text is both UTF-8 and zero-terminated. In other words,
6498 ** SQLITE_UTF8_ZT means that the Z array holds at least N+1 byes and that
6499 ** the Z&#91;N&#93; is zero.
6500 ** ^SQLite takes the text result from the application from
6501 ** the 2nd parameter of the sqlite3_result_text* interfaces.
6502 ** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
6503 ** other than sqlite3_result_text64() is negative, then SQLite computes
@@ -8863,11 +8863,11 @@
8863 **
8864 ** ^The [sqlite3_str_reset(X)] method resets the string under construction
8865 ** inside [sqlite3_str] object X back to zero bytes in length.
8866 **
8867 ** ^The [sqlite3_str_truncate(X,N)] method changes the length of the string
8868 ** under construction to be N bytes are less. This routine is a no-op if
8869 ** N is negative or if the string is already N bytes or smaller in size.
8870 **
8871 ** These methods do not return a result code. ^If an error occurs, that fact
8872 ** is recorded in the [sqlite3_str] object and can be recovered by a
8873 ** subsequent call to [sqlite3_str_errcode(X)].
@@ -10727,11 +10727,11 @@
10727 ** - less than -1 or greater than or equal to the total number of query
10728 ** elements used to implement the statement - a non-zero value is returned and
10729 ** the variable that pOut points to is unchanged.
10730 **
10731 ** See also: [sqlite3_stmt_scanstatus_reset()] and the
10732 ** [nexec and ncycle] columnes of the [bytecode virtual table].
10733 */
10734 SQLITE_API int sqlite3_stmt_scanstatus(
10735 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
10736 int idx, /* Index of loop to report on */
10737 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
@@ -11283,21 +11283,21 @@
11283 **
11284 ** If the X argument is not a NULL pointer or one of the special
11285 ** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke
11286 ** the function X with argument D when it is finished using the data in P.
11287 ** The call to X(D) is a destructor for the array P. The destructor X(D)
11288 ** is invoked even if the call to sqlite3_carray_bind() fails. If the X
11289 ** parameter is the special-case value [SQLITE_STATIC], then SQLite assumes
11290 ** that the data static and the destructor is never invoked. If the X
11291 ** parameter is the special-case value [SQLITE_TRANSIENT], then
11292 ** sqlite3_carray_bind_v2() makes its own private copy of the data prior
11293 ** to returning and never invokes the destructor X.
11294 **
11295 ** The sqlite3_carray_bind() function works the same as sqlite_carray_bind_v2()
11296 ** with a D parameter set to P. In other words,
11297 ** sqlite3_carray_bind(S,I,P,N,F,X) is same as
11298 ** sqlite3_carray_bind(S,I,P,N,F,X,P).
11299 */
11300 SQLITE_API int sqlite3_carray_bind_v2(
11301 sqlite3_stmt *pStmt, /* Statement to be bound */
11302 int i, /* Parameter index */
11303 void *aData, /* Pointer to array data */
11304
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -144,16 +144,16 @@
144 **
145 ** See also: [sqlite3_libversion()],
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.53.0"
150 #define SQLITE_VERSION_NUMBER 3053000
151 #define SQLITE_SOURCE_ID "2026-03-18 22:31:56 5c237f1f863a32cf229010d2024d0d1e76a07a4d8b9492b26503b959f1c32485"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2026-03-18T22:31:56.220Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
@@ -2656,11 +2656,11 @@
2656 ** default value 17, as of SQLite version 3.52.0. The value was 15 in all
2657 ** prior versions.<p>
2658 ** This option takes two arguments which are an integer and a pointer
2659 ** to an integer. The first argument is a small integer, between 3 and 23, or
2660 ** zero. The FP_DIGITS setting is changed to that small integer, or left
2661 ** unaltered if the first argument is zero or out of range. The second argument
2662 ** is a pointer to an integer. If the pointer is not NULL, then the value of
2663 ** the FP_DIGITS setting, after possibly being modified by the first
2664 ** arguments, is written into the integer to which the second argument points.
2665 ** </dd>
2666 **
@@ -4486,11 +4486,11 @@
4486 ** are constructors for the [prepared statement] object.
4487 **
4488 ** The preferred routine to use is [sqlite3_prepare_v2()]. The
4489 ** [sqlite3_prepare()] interface is legacy and should be avoided.
4490 ** [sqlite3_prepare_v3()] has an extra
4491 ** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is sometimes
4492 ** needed for special purpose or to pass along security restrictions.
4493 **
4494 ** The use of the UTF-8 interfaces is preferred, as SQLite currently
4495 ** does all parsing using UTF-8. The UTF-16 interfaces are provided
4496 ** as a convenience. The UTF-16 interfaces work by converting the
@@ -6493,11 +6493,11 @@
6493 ** application-defined function to be a text string in an encoding
6494 ** specified the E parameter, which must be one
6495 ** of [SQLITE_UTF8], [SQLITE_UTF8_ZT], [SQLITE_UTF16], [SQLITE_UTF16BE],
6496 ** or [SQLITE_UTF16LE]. ^The special value [SQLITE_UTF8_ZT] means that
6497 ** the result text is both UTF-8 and zero-terminated. In other words,
6498 ** SQLITE_UTF8_ZT means that the Z array holds at least N+1 bytes and that
6499 ** the Z&#91;N&#93; is zero.
6500 ** ^SQLite takes the text result from the application from
6501 ** the 2nd parameter of the sqlite3_result_text* interfaces.
6502 ** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
6503 ** other than sqlite3_result_text64() is negative, then SQLite computes
@@ -8863,11 +8863,11 @@
8863 **
8864 ** ^The [sqlite3_str_reset(X)] method resets the string under construction
8865 ** inside [sqlite3_str] object X back to zero bytes in length.
8866 **
8867 ** ^The [sqlite3_str_truncate(X,N)] method changes the length of the string
8868 ** under construction to be N bytes or less. This routine is a no-op if
8869 ** N is negative or if the string is already N bytes or smaller in size.
8870 **
8871 ** These methods do not return a result code. ^If an error occurs, that fact
8872 ** is recorded in the [sqlite3_str] object and can be recovered by a
8873 ** subsequent call to [sqlite3_str_errcode(X)].
@@ -10727,11 +10727,11 @@
10727 ** - less than -1 or greater than or equal to the total number of query
10728 ** elements used to implement the statement - a non-zero value is returned and
10729 ** the variable that pOut points to is unchanged.
10730 **
10731 ** See also: [sqlite3_stmt_scanstatus_reset()] and the
10732 ** [nexec and ncycle] columns of the [bytecode virtual table].
10733 */
10734 SQLITE_API int sqlite3_stmt_scanstatus(
10735 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
10736 int idx, /* Index of loop to report on */
10737 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
@@ -11283,21 +11283,21 @@
11283 **
11284 ** If the X argument is not a NULL pointer or one of the special
11285 ** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke
11286 ** the function X with argument D when it is finished using the data in P.
11287 ** The call to X(D) is a destructor for the array P. The destructor X(D)
11288 ** is invoked even if the call to sqlite3_carray_bind_v2() fails. If the X
11289 ** parameter is the special-case value [SQLITE_STATIC], then SQLite assumes
11290 ** that the data static and the destructor is never invoked. If the X
11291 ** parameter is the special-case value [SQLITE_TRANSIENT], then
11292 ** sqlite3_carray_bind_v2() makes its own private copy of the data prior
11293 ** to returning and never invokes the destructor X.
11294 **
11295 ** The sqlite3_carray_bind() function works the same as sqlite3_carray_bind_v2()
11296 ** with a D parameter set to P. In other words,
11297 ** sqlite3_carray_bind(S,I,P,N,F,X) is same as
11298 ** sqlite3_carray_bind_v2(S,I,P,N,F,X,P).
11299 */
11300 SQLITE_API int sqlite3_carray_bind_v2(
11301 sqlite3_stmt *pStmt, /* Statement to be bound */
11302 int i, /* Parameter index */
11303 void *aData, /* Pointer to array data */
11304

Keyboard Shortcuts

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