Fossil SCM

Update the built-in SQLite to the latest 3.18.0 pre-release.

drh 2017-03-16 14:47 trunk
Commit 303a2084a35beec193bbd5367ea2ab376c0513edd029e08e953b064d1659853f
3 files changed +43 -18 +23 -18 +1 -1
+43 -18
--- src/shell.c
+++ src/shell.c
@@ -1488,36 +1488,56 @@
14881488
raw_printf(out,"'");
14891489
}
14901490
14911491
/*
14921492
** Output the given string as a quoted string using SQL quoting conventions.
1493
+**
1494
+** The "\n" and "\r" characters are converted to char(10) and char(13)
1495
+** to prevent them from being transformed by end-of-line translators.
14931496
*/
14941497
static void output_quoted_string(FILE *out, const char *z){
14951498
int i;
1496
- int nSingle = 0;
1499
+ char c;
14971500
setBinaryMode(out, 1);
1498
- for(i=0; z[i]; i++){
1499
- if( z[i]=='\'' ) nSingle++;
1500
- }
1501
- if( nSingle==0 ){
1501
+ for(i=0; (c = z[i])!=0 && c!='\'' && c!='\n' && c!='\r'; i++){}
1502
+ if( c==0 ){
15021503
utf8_printf(out,"'%s'",z);
15031504
}else{
1504
- raw_printf(out,"'");
1505
+ int inQuote = 0;
1506
+ int bStarted = 0;
15051507
while( *z ){
1506
- for(i=0; z[i] && z[i]!='\''; i++){}
1507
- if( i==0 ){
1508
- raw_printf(out,"''");
1509
- z++;
1510
- }else if( z[i]=='\'' ){
1511
- utf8_printf(out,"%.*s''",i,z);
1512
- z += i+1;
1513
- }else{
1514
- utf8_printf(out,"%s",z);
1508
+ for(i=0; (c = z[i])!=0 && c!='\n' && c!='\r' && c!='\''; i++){}
1509
+ if( c=='\'' ) i++;
1510
+ if( i ){
1511
+ if( !inQuote ){
1512
+ if( bStarted ) raw_printf(out, "||");
1513
+ raw_printf(out, "'");
1514
+ inQuote = 1;
1515
+ }
1516
+ utf8_printf(out, "%.*s", i, z);
1517
+ z += i;
1518
+ bStarted = 1;
1519
+ }
1520
+ if( c=='\'' ){
1521
+ raw_printf(out, "'");
1522
+ continue;
1523
+ }
1524
+ if( inQuote ){
1525
+ raw_printf(out, "'");
1526
+ inQuote = 0;
1527
+ }
1528
+ if( c==0 ){
15151529
break;
15161530
}
1531
+ for(i=0; (c = z[i])=='\r' || c=='\n'; i++){
1532
+ if( bStarted ) raw_printf(out, "||");
1533
+ raw_printf(out, "char(%d)", c);
1534
+ bStarted = 1;
1535
+ }
1536
+ z += i;
15171537
}
1518
- raw_printf(out,"'");
1538
+ if( inQuote ) raw_printf(out, "'");
15191539
}
15201540
setTextMode(out, 1);
15211541
}
15221542
15231543
/*
@@ -2005,13 +2025,17 @@
20052025
if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
20062026
utf8_printf(p->out,"%sNULL",zSep);
20072027
}else if( aiType && aiType[i]==SQLITE_TEXT ){
20082028
if( zSep[0] ) utf8_printf(p->out,"%s",zSep);
20092029
output_quoted_string(p->out, azArg[i]);
2010
- }else if( aiType && (aiType[i]==SQLITE_INTEGER
2011
- || aiType[i]==SQLITE_FLOAT) ){
2030
+ }else if( aiType && aiType[i]==SQLITE_INTEGER ){
20122031
utf8_printf(p->out,"%s%s",zSep, azArg[i]);
2032
+ }else if( aiType && aiType[i]==SQLITE_FLOAT ){
2033
+ char z[50];
2034
+ double r = sqlite3_column_double(p->pStmt, i);
2035
+ sqlite3_snprintf(50,z,"%!.20g", r);
2036
+ raw_printf(p->out, "%s%s", zSep, z);
20132037
}else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
20142038
const void *pBlob = sqlite3_column_blob(p->pStmt, i);
20152039
int nBlob = sqlite3_column_bytes(p->pStmt, i);
20162040
if( zSep[0] ) utf8_printf(p->out,"%s",zSep);
20172041
output_hex_blob(p->out, pBlob, nBlob);
@@ -3143,10 +3167,11 @@
31433167
".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n"
31443168
".save FILE Write in-memory database into FILE\n"
31453169
".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off\n"
31463170
".schema ?PATTERN? Show the CREATE statements matching PATTERN\n"
31473171
" Add --indent for pretty-printing\n"
3172
+ ".selftest ?--init? Run tests defined in the SELFTEST table\n"
31483173
".separator COL ?ROW? Change the column separator and optionally the row\n"
31493174
" separator for both the output mode and .import\n"
31503175
#if defined(SQLITE_ENABLE_SESSION)
31513176
".session CMD ... Create or control sessions\n"
31523177
#endif
31533178
--- src/shell.c
+++ src/shell.c
@@ -1488,36 +1488,56 @@
1488 raw_printf(out,"'");
1489 }
1490
1491 /*
1492 ** Output the given string as a quoted string using SQL quoting conventions.
 
 
 
1493 */
1494 static void output_quoted_string(FILE *out, const char *z){
1495 int i;
1496 int nSingle = 0;
1497 setBinaryMode(out, 1);
1498 for(i=0; z[i]; i++){
1499 if( z[i]=='\'' ) nSingle++;
1500 }
1501 if( nSingle==0 ){
1502 utf8_printf(out,"'%s'",z);
1503 }else{
1504 raw_printf(out,"'");
 
1505 while( *z ){
1506 for(i=0; z[i] && z[i]!='\''; i++){}
1507 if( i==0 ){
1508 raw_printf(out,"''");
1509 z++;
1510 }else if( z[i]=='\'' ){
1511 utf8_printf(out,"%.*s''",i,z);
1512 z += i+1;
1513 }else{
1514 utf8_printf(out,"%s",z);
 
 
 
 
 
 
 
 
 
 
 
 
1515 break;
1516 }
 
 
 
 
 
 
1517 }
1518 raw_printf(out,"'");
1519 }
1520 setTextMode(out, 1);
1521 }
1522
1523 /*
@@ -2005,13 +2025,17 @@
2005 if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
2006 utf8_printf(p->out,"%sNULL",zSep);
2007 }else if( aiType && aiType[i]==SQLITE_TEXT ){
2008 if( zSep[0] ) utf8_printf(p->out,"%s",zSep);
2009 output_quoted_string(p->out, azArg[i]);
2010 }else if( aiType && (aiType[i]==SQLITE_INTEGER
2011 || aiType[i]==SQLITE_FLOAT) ){
2012 utf8_printf(p->out,"%s%s",zSep, azArg[i]);
 
 
 
 
 
2013 }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
2014 const void *pBlob = sqlite3_column_blob(p->pStmt, i);
2015 int nBlob = sqlite3_column_bytes(p->pStmt, i);
2016 if( zSep[0] ) utf8_printf(p->out,"%s",zSep);
2017 output_hex_blob(p->out, pBlob, nBlob);
@@ -3143,10 +3167,11 @@
3143 ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n"
3144 ".save FILE Write in-memory database into FILE\n"
3145 ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off\n"
3146 ".schema ?PATTERN? Show the CREATE statements matching PATTERN\n"
3147 " Add --indent for pretty-printing\n"
 
3148 ".separator COL ?ROW? Change the column separator and optionally the row\n"
3149 " separator for both the output mode and .import\n"
3150 #if defined(SQLITE_ENABLE_SESSION)
3151 ".session CMD ... Create or control sessions\n"
3152 #endif
3153
--- src/shell.c
+++ src/shell.c
@@ -1488,36 +1488,56 @@
1488 raw_printf(out,"'");
1489 }
1490
1491 /*
1492 ** Output the given string as a quoted string using SQL quoting conventions.
1493 **
1494 ** The "\n" and "\r" characters are converted to char(10) and char(13)
1495 ** to prevent them from being transformed by end-of-line translators.
1496 */
1497 static void output_quoted_string(FILE *out, const char *z){
1498 int i;
1499 char c;
1500 setBinaryMode(out, 1);
1501 for(i=0; (c = z[i])!=0 && c!='\'' && c!='\n' && c!='\r'; i++){}
1502 if( c==0 ){
 
 
1503 utf8_printf(out,"'%s'",z);
1504 }else{
1505 int inQuote = 0;
1506 int bStarted = 0;
1507 while( *z ){
1508 for(i=0; (c = z[i])!=0 && c!='\n' && c!='\r' && c!='\''; i++){}
1509 if( c=='\'' ) i++;
1510 if( i ){
1511 if( !inQuote ){
1512 if( bStarted ) raw_printf(out, "||");
1513 raw_printf(out, "'");
1514 inQuote = 1;
1515 }
1516 utf8_printf(out, "%.*s", i, z);
1517 z += i;
1518 bStarted = 1;
1519 }
1520 if( c=='\'' ){
1521 raw_printf(out, "'");
1522 continue;
1523 }
1524 if( inQuote ){
1525 raw_printf(out, "'");
1526 inQuote = 0;
1527 }
1528 if( c==0 ){
1529 break;
1530 }
1531 for(i=0; (c = z[i])=='\r' || c=='\n'; i++){
1532 if( bStarted ) raw_printf(out, "||");
1533 raw_printf(out, "char(%d)", c);
1534 bStarted = 1;
1535 }
1536 z += i;
1537 }
1538 if( inQuote ) raw_printf(out, "'");
1539 }
1540 setTextMode(out, 1);
1541 }
1542
1543 /*
@@ -2005,13 +2025,17 @@
2025 if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
2026 utf8_printf(p->out,"%sNULL",zSep);
2027 }else if( aiType && aiType[i]==SQLITE_TEXT ){
2028 if( zSep[0] ) utf8_printf(p->out,"%s",zSep);
2029 output_quoted_string(p->out, azArg[i]);
2030 }else if( aiType && aiType[i]==SQLITE_INTEGER ){
 
2031 utf8_printf(p->out,"%s%s",zSep, azArg[i]);
2032 }else if( aiType && aiType[i]==SQLITE_FLOAT ){
2033 char z[50];
2034 double r = sqlite3_column_double(p->pStmt, i);
2035 sqlite3_snprintf(50,z,"%!.20g", r);
2036 raw_printf(p->out, "%s%s", zSep, z);
2037 }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
2038 const void *pBlob = sqlite3_column_blob(p->pStmt, i);
2039 int nBlob = sqlite3_column_bytes(p->pStmt, i);
2040 if( zSep[0] ) utf8_printf(p->out,"%s",zSep);
2041 output_hex_blob(p->out, pBlob, nBlob);
@@ -3143,10 +3167,11 @@
3167 ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n"
3168 ".save FILE Write in-memory database into FILE\n"
3169 ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off\n"
3170 ".schema ?PATTERN? Show the CREATE statements matching PATTERN\n"
3171 " Add --indent for pretty-printing\n"
3172 ".selftest ?--init? Run tests defined in the SELFTEST table\n"
3173 ".separator COL ?ROW? Change the column separator and optionally the row\n"
3174 " separator for both the output mode and .import\n"
3175 #if defined(SQLITE_ENABLE_SESSION)
3176 ".session CMD ... Create or control sessions\n"
3177 #endif
3178
+23 -18
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,11 +398,11 @@
398398
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399399
** [sqlite_version()] and [sqlite_source_id()].
400400
*/
401401
#define SQLITE_VERSION "3.18.0"
402402
#define SQLITE_VERSION_NUMBER 3018000
403
-#define SQLITE_SOURCE_ID "2017-03-10 17:03:11 f8560c60d10c0365b33342ab05b5a953987b0471"
403
+#define SQLITE_SOURCE_ID "2017-03-16 14:28:52 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f"
404404
405405
/*
406406
** CAPI3REF: Run-Time Library Version Numbers
407407
** KEYWORDS: sqlite3_version sqlite3_sourceid
408408
**
@@ -26264,10 +26264,14 @@
2626426264
** Generate a human-readable description of a Select object.
2626526265
*/
2626626266
SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){
2626726267
int n = 0;
2626826268
int cnt = 0;
26269
+ if( p==0 ){
26270
+ sqlite3TreeViewLine(pView, "nil-SELECT");
26271
+ return;
26272
+ }
2626926273
pView = sqlite3TreeViewPush(pView, moreToFollow);
2627026274
if( p->pWith ){
2627126275
sqlite3TreeViewWith(pView, p->pWith, 1);
2627226276
cnt = 1;
2627326277
sqlite3TreeViewPush(pView, 1);
@@ -78469,13 +78473,11 @@
7846978473
c = 'e';
7847078474
assert( (f & (MEM_Static|MEM_Dyn))==0 );
7847178475
}else{
7847278476
c = 's';
7847378477
}
78474
-
78475
- sqlite3_snprintf(100, zCsr, "%c", c);
78476
- zCsr += sqlite3Strlen30(zCsr);
78478
+ *(zCsr++) = c;
7847778479
sqlite3_snprintf(100, zCsr, "%d[", pMem->n);
7847878480
zCsr += sqlite3Strlen30(zCsr);
7847978481
for(i=0; i<16 && i<pMem->n; i++){
7848078482
sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem->z[i] & 0xFF));
7848178483
zCsr += sqlite3Strlen30(zCsr);
@@ -78483,13 +78485,11 @@
7848378485
for(i=0; i<16 && i<pMem->n; i++){
7848478486
char z = pMem->z[i];
7848578487
if( z<32 || z>126 ) *zCsr++ = '.';
7848678488
else *zCsr++ = z;
7848778489
}
78488
-
78489
- sqlite3_snprintf(100, zCsr, "]%s", encnames[pMem->enc]);
78490
- zCsr += sqlite3Strlen30(zCsr);
78490
+ *(zCsr++) = ']';
7849178491
if( f & MEM_Zero ){
7849278492
sqlite3_snprintf(100, zCsr,"+%dz",pMem->u.nZero);
7849378493
zCsr += sqlite3Strlen30(zCsr);
7849478494
}
7849578495
*zCsr = '\0';
@@ -92537,10 +92537,11 @@
9253792537
** in *pValue. If the expression is not an integer or if it is too big
9253892538
** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged.
9253992539
*/
9254092540
SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){
9254192541
int rc = 0;
92542
+ if( p==0 ) return 0; /* Can only happen following on OOM */
9254292543
9254392544
/* If an expression is an integer literal that fits in a signed 32-bit
9254492545
** integer, then the EP_IntValue flag will have already been set */
9254592546
assert( p->op!=TK_INTEGER || (p->flags & EP_IntValue)!=0
9254692547
|| sqlite3GetInt32(p->u.zToken, &rc)==0 );
@@ -93209,11 +93210,10 @@
9320993210
if( ALWAYS(pEList->nExpr==nVal) ){
9321093211
SelectDest dest;
9321193212
int i;
9321293213
sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
9321393214
dest.zAffSdst = exprINAffinity(pParse, pExpr);
93214
- assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
9321593215
pSelect->iLimit = 0;
9321693216
testcase( pSelect->selFlags & SF_Distinct );
9321793217
testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
9321893218
if( sqlite3Select(pParse, pSelect, &dest) ){
9321993219
sqlite3DbFree(pParse->db, dest.zAffSdst);
@@ -105435,19 +105435,17 @@
105435105435
nNeedle = sqlite3_value_bytes(argv[1]);
105436105436
if( nNeedle>0 ){
105437105437
if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){
105438105438
zHaystack = sqlite3_value_blob(argv[0]);
105439105439
zNeedle = sqlite3_value_blob(argv[1]);
105440
- assert( zNeedle!=0 );
105441
- assert( zHaystack!=0 || nHaystack==0 );
105442105440
isText = 0;
105443105441
}else{
105444105442
zHaystack = sqlite3_value_text(argv[0]);
105445105443
zNeedle = sqlite3_value_text(argv[1]);
105446105444
isText = 1;
105447
- if( zHaystack==0 || zNeedle==0 ) return;
105448105445
}
105446
+ if( zNeedle==0 || (nHaystack && zHaystack==0) ) return;
105449105447
while( nNeedle<=nHaystack && memcmp(zHaystack, zNeedle, nNeedle)!=0 ){
105450105448
N++;
105451105449
do{
105452105450
nHaystack--;
105453105451
zHaystack++;
@@ -113916,11 +113914,11 @@
113916113914
returnSingleInt(v, pDb->safety_level-1);
113917113915
}else{
113918113916
if( !db->autoCommit ){
113919113917
sqlite3ErrorMsg(pParse,
113920113918
"Safety level may not be changed inside a transaction");
113921
- }else{
113919
+ }else if( iDb!=1 ){
113922113920
int iLevel = (getSafetyLevel(zRight,0,1)+1) & PAGER_SYNCHRONOUS_MASK;
113923113921
if( iLevel==0 ) iLevel = 1;
113924113922
pDb->safety_level = iLevel;
113925113923
pDb->bSyncSet = 1;
113926113924
setAllPagerFlags(db);
@@ -119936,11 +119934,13 @@
119936119934
assert( pParent->pGroupBy==0 );
119937119935
pParent->pGroupBy = sqlite3ExprListDup(db, pSub->pGroupBy, 0);
119938119936
}else{
119939119937
pParent->pWhere = sqlite3ExprAnd(db, pWhere, pParent->pWhere);
119940119938
}
119941
- substSelect(pParse, pParent, iParent, pSub->pEList, 0);
119939
+ if( db->mallocFailed==0 ){
119940
+ substSelect(pParse, pParent, iParent, pSub->pEList, 0);
119941
+ }
119942119942
119943119943
/* The flattened query is distinct if either the inner or the
119944119944
** outer query is distinct.
119945119945
*/
119946119946
pParent->selFlags |= pSub->selFlags & SF_Distinct;
@@ -130289,18 +130289,20 @@
130289130289
** cursor iTabCur are transformed into OP_Null. Or, if bIncrRowid is non-zero,
130290130290
** then each OP_Rowid is transformed into an instruction to increment the
130291130291
** value stored in its output register.
130292130292
*/
130293130293
static void translateColumnToCopy(
130294
- Vdbe *v, /* The VDBE containing code to translate */
130294
+ Parse *pParse, /* Parsing context */
130295130295
int iStart, /* Translate from this opcode to the end */
130296130296
int iTabCur, /* OP_Column/OP_Rowid references to this table */
130297130297
int iRegister, /* The first column is in this register */
130298130298
int bIncrRowid /* If non-zero, transform OP_rowid to OP_AddImm(1) */
130299130299
){
130300
+ Vdbe *v = pParse->pVdbe;
130300130301
VdbeOp *pOp = sqlite3VdbeGetOp(v, iStart);
130301130302
int iEnd = sqlite3VdbeCurrentAddr(v);
130303
+ if( pParse->db->mallocFailed ) return;
130302130304
for(; iStart<iEnd; iStart++, pOp++){
130303130305
if( pOp->p1!=iTabCur ) continue;
130304130306
if( pOp->opcode==OP_Column ){
130305130307
pOp->opcode = OP_Copy;
130306130308
pOp->p1 = pOp->p2 + iRegister;
@@ -130574,11 +130576,13 @@
130574130576
sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
130575130577
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
130576130578
if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);
130577130579
if( pTabItem->fg.viaCoroutine ){
130578130580
sqlite3VdbeChangeP2(v, addrCounter, regBase+n);
130579
- translateColumnToCopy(v, addrTop, pLevel->iTabCur, pTabItem->regResult, 1);
130581
+ testcase( pParse->db->mallocFailed );
130582
+ translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
130583
+ pTabItem->regResult, 1);
130580130584
sqlite3VdbeGoto(v, addrTop);
130581130585
pTabItem->fg.viaCoroutine = 0;
130582130586
}else{
130583130587
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
130584130588
}
@@ -134692,12 +134696,13 @@
134692134696
134693134697
/* For a co-routine, change all OP_Column references to the table of
134694134698
** the co-routine into OP_Copy of result contained in a register.
134695134699
** OP_Rowid becomes OP_Null.
134696134700
*/
134697
- if( pTabItem->fg.viaCoroutine && !db->mallocFailed ){
134698
- translateColumnToCopy(v, pLevel->addrBody, pLevel->iTabCur,
134701
+ if( pTabItem->fg.viaCoroutine ){
134702
+ testcase( pParse->db->mallocFailed );
134703
+ translateColumnToCopy(pParse, pLevel->addrBody, pLevel->iTabCur,
134699134704
pTabItem->regResult, 0);
134700134705
continue;
134701134706
}
134702134707
134703134708
/* If this scan uses an index, make VDBE code substitutions to read data
@@ -198067,11 +198072,11 @@
198067198072
int nArg, /* Number of args */
198068198073
sqlite3_value **apUnused /* Function arguments */
198069198074
){
198070198075
assert( nArg==0 );
198071198076
UNUSED_PARAM2(nArg, apUnused);
198072
- sqlite3_result_text(pCtx, "fts5: 2017-03-10 17:03:11 f8560c60d10c0365b33342ab05b5a953987b0471", -1, SQLITE_TRANSIENT);
198077
+ sqlite3_result_text(pCtx, "fts5: 2017-03-16 14:28:52 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f", -1, SQLITE_TRANSIENT);
198073198078
}
198074198079
198075198080
static int fts5Init(sqlite3 *db){
198076198081
static const sqlite3_module fts5Mod = {
198077198082
/* iVersion */ 2,
198078198083
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,11 +398,11 @@
398 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399 ** [sqlite_version()] and [sqlite_source_id()].
400 */
401 #define SQLITE_VERSION "3.18.0"
402 #define SQLITE_VERSION_NUMBER 3018000
403 #define SQLITE_SOURCE_ID "2017-03-10 17:03:11 f8560c60d10c0365b33342ab05b5a953987b0471"
404
405 /*
406 ** CAPI3REF: Run-Time Library Version Numbers
407 ** KEYWORDS: sqlite3_version sqlite3_sourceid
408 **
@@ -26264,10 +26264,14 @@
26264 ** Generate a human-readable description of a Select object.
26265 */
26266 SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){
26267 int n = 0;
26268 int cnt = 0;
 
 
 
 
26269 pView = sqlite3TreeViewPush(pView, moreToFollow);
26270 if( p->pWith ){
26271 sqlite3TreeViewWith(pView, p->pWith, 1);
26272 cnt = 1;
26273 sqlite3TreeViewPush(pView, 1);
@@ -78469,13 +78473,11 @@
78469 c = 'e';
78470 assert( (f & (MEM_Static|MEM_Dyn))==0 );
78471 }else{
78472 c = 's';
78473 }
78474
78475 sqlite3_snprintf(100, zCsr, "%c", c);
78476 zCsr += sqlite3Strlen30(zCsr);
78477 sqlite3_snprintf(100, zCsr, "%d[", pMem->n);
78478 zCsr += sqlite3Strlen30(zCsr);
78479 for(i=0; i<16 && i<pMem->n; i++){
78480 sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem->z[i] & 0xFF));
78481 zCsr += sqlite3Strlen30(zCsr);
@@ -78483,13 +78485,11 @@
78483 for(i=0; i<16 && i<pMem->n; i++){
78484 char z = pMem->z[i];
78485 if( z<32 || z>126 ) *zCsr++ = '.';
78486 else *zCsr++ = z;
78487 }
78488
78489 sqlite3_snprintf(100, zCsr, "]%s", encnames[pMem->enc]);
78490 zCsr += sqlite3Strlen30(zCsr);
78491 if( f & MEM_Zero ){
78492 sqlite3_snprintf(100, zCsr,"+%dz",pMem->u.nZero);
78493 zCsr += sqlite3Strlen30(zCsr);
78494 }
78495 *zCsr = '\0';
@@ -92537,10 +92537,11 @@
92537 ** in *pValue. If the expression is not an integer or if it is too big
92538 ** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged.
92539 */
92540 SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){
92541 int rc = 0;
 
92542
92543 /* If an expression is an integer literal that fits in a signed 32-bit
92544 ** integer, then the EP_IntValue flag will have already been set */
92545 assert( p->op!=TK_INTEGER || (p->flags & EP_IntValue)!=0
92546 || sqlite3GetInt32(p->u.zToken, &rc)==0 );
@@ -93209,11 +93210,10 @@
93209 if( ALWAYS(pEList->nExpr==nVal) ){
93210 SelectDest dest;
93211 int i;
93212 sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
93213 dest.zAffSdst = exprINAffinity(pParse, pExpr);
93214 assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
93215 pSelect->iLimit = 0;
93216 testcase( pSelect->selFlags & SF_Distinct );
93217 testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
93218 if( sqlite3Select(pParse, pSelect, &dest) ){
93219 sqlite3DbFree(pParse->db, dest.zAffSdst);
@@ -105435,19 +105435,17 @@
105435 nNeedle = sqlite3_value_bytes(argv[1]);
105436 if( nNeedle>0 ){
105437 if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){
105438 zHaystack = sqlite3_value_blob(argv[0]);
105439 zNeedle = sqlite3_value_blob(argv[1]);
105440 assert( zNeedle!=0 );
105441 assert( zHaystack!=0 || nHaystack==0 );
105442 isText = 0;
105443 }else{
105444 zHaystack = sqlite3_value_text(argv[0]);
105445 zNeedle = sqlite3_value_text(argv[1]);
105446 isText = 1;
105447 if( zHaystack==0 || zNeedle==0 ) return;
105448 }
 
105449 while( nNeedle<=nHaystack && memcmp(zHaystack, zNeedle, nNeedle)!=0 ){
105450 N++;
105451 do{
105452 nHaystack--;
105453 zHaystack++;
@@ -113916,11 +113914,11 @@
113916 returnSingleInt(v, pDb->safety_level-1);
113917 }else{
113918 if( !db->autoCommit ){
113919 sqlite3ErrorMsg(pParse,
113920 "Safety level may not be changed inside a transaction");
113921 }else{
113922 int iLevel = (getSafetyLevel(zRight,0,1)+1) & PAGER_SYNCHRONOUS_MASK;
113923 if( iLevel==0 ) iLevel = 1;
113924 pDb->safety_level = iLevel;
113925 pDb->bSyncSet = 1;
113926 setAllPagerFlags(db);
@@ -119936,11 +119934,13 @@
119936 assert( pParent->pGroupBy==0 );
119937 pParent->pGroupBy = sqlite3ExprListDup(db, pSub->pGroupBy, 0);
119938 }else{
119939 pParent->pWhere = sqlite3ExprAnd(db, pWhere, pParent->pWhere);
119940 }
119941 substSelect(pParse, pParent, iParent, pSub->pEList, 0);
 
 
119942
119943 /* The flattened query is distinct if either the inner or the
119944 ** outer query is distinct.
119945 */
119946 pParent->selFlags |= pSub->selFlags & SF_Distinct;
@@ -130289,18 +130289,20 @@
130289 ** cursor iTabCur are transformed into OP_Null. Or, if bIncrRowid is non-zero,
130290 ** then each OP_Rowid is transformed into an instruction to increment the
130291 ** value stored in its output register.
130292 */
130293 static void translateColumnToCopy(
130294 Vdbe *v, /* The VDBE containing code to translate */
130295 int iStart, /* Translate from this opcode to the end */
130296 int iTabCur, /* OP_Column/OP_Rowid references to this table */
130297 int iRegister, /* The first column is in this register */
130298 int bIncrRowid /* If non-zero, transform OP_rowid to OP_AddImm(1) */
130299 ){
 
130300 VdbeOp *pOp = sqlite3VdbeGetOp(v, iStart);
130301 int iEnd = sqlite3VdbeCurrentAddr(v);
 
130302 for(; iStart<iEnd; iStart++, pOp++){
130303 if( pOp->p1!=iTabCur ) continue;
130304 if( pOp->opcode==OP_Column ){
130305 pOp->opcode = OP_Copy;
130306 pOp->p1 = pOp->p2 + iRegister;
@@ -130574,11 +130576,13 @@
130574 sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
130575 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
130576 if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);
130577 if( pTabItem->fg.viaCoroutine ){
130578 sqlite3VdbeChangeP2(v, addrCounter, regBase+n);
130579 translateColumnToCopy(v, addrTop, pLevel->iTabCur, pTabItem->regResult, 1);
 
 
130580 sqlite3VdbeGoto(v, addrTop);
130581 pTabItem->fg.viaCoroutine = 0;
130582 }else{
130583 sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
130584 }
@@ -134692,12 +134696,13 @@
134692
134693 /* For a co-routine, change all OP_Column references to the table of
134694 ** the co-routine into OP_Copy of result contained in a register.
134695 ** OP_Rowid becomes OP_Null.
134696 */
134697 if( pTabItem->fg.viaCoroutine && !db->mallocFailed ){
134698 translateColumnToCopy(v, pLevel->addrBody, pLevel->iTabCur,
 
134699 pTabItem->regResult, 0);
134700 continue;
134701 }
134702
134703 /* If this scan uses an index, make VDBE code substitutions to read data
@@ -198067,11 +198072,11 @@
198067 int nArg, /* Number of args */
198068 sqlite3_value **apUnused /* Function arguments */
198069 ){
198070 assert( nArg==0 );
198071 UNUSED_PARAM2(nArg, apUnused);
198072 sqlite3_result_text(pCtx, "fts5: 2017-03-10 17:03:11 f8560c60d10c0365b33342ab05b5a953987b0471", -1, SQLITE_TRANSIENT);
198073 }
198074
198075 static int fts5Init(sqlite3 *db){
198076 static const sqlite3_module fts5Mod = {
198077 /* iVersion */ 2,
198078
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -398,11 +398,11 @@
398 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399 ** [sqlite_version()] and [sqlite_source_id()].
400 */
401 #define SQLITE_VERSION "3.18.0"
402 #define SQLITE_VERSION_NUMBER 3018000
403 #define SQLITE_SOURCE_ID "2017-03-16 14:28:52 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f"
404
405 /*
406 ** CAPI3REF: Run-Time Library Version Numbers
407 ** KEYWORDS: sqlite3_version sqlite3_sourceid
408 **
@@ -26264,10 +26264,14 @@
26264 ** Generate a human-readable description of a Select object.
26265 */
26266 SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){
26267 int n = 0;
26268 int cnt = 0;
26269 if( p==0 ){
26270 sqlite3TreeViewLine(pView, "nil-SELECT");
26271 return;
26272 }
26273 pView = sqlite3TreeViewPush(pView, moreToFollow);
26274 if( p->pWith ){
26275 sqlite3TreeViewWith(pView, p->pWith, 1);
26276 cnt = 1;
26277 sqlite3TreeViewPush(pView, 1);
@@ -78469,13 +78473,11 @@
78473 c = 'e';
78474 assert( (f & (MEM_Static|MEM_Dyn))==0 );
78475 }else{
78476 c = 's';
78477 }
78478 *(zCsr++) = c;
 
 
78479 sqlite3_snprintf(100, zCsr, "%d[", pMem->n);
78480 zCsr += sqlite3Strlen30(zCsr);
78481 for(i=0; i<16 && i<pMem->n; i++){
78482 sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem->z[i] & 0xFF));
78483 zCsr += sqlite3Strlen30(zCsr);
@@ -78483,13 +78485,11 @@
78485 for(i=0; i<16 && i<pMem->n; i++){
78486 char z = pMem->z[i];
78487 if( z<32 || z>126 ) *zCsr++ = '.';
78488 else *zCsr++ = z;
78489 }
78490 *(zCsr++) = ']';
 
 
78491 if( f & MEM_Zero ){
78492 sqlite3_snprintf(100, zCsr,"+%dz",pMem->u.nZero);
78493 zCsr += sqlite3Strlen30(zCsr);
78494 }
78495 *zCsr = '\0';
@@ -92537,10 +92537,11 @@
92537 ** in *pValue. If the expression is not an integer or if it is too big
92538 ** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged.
92539 */
92540 SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){
92541 int rc = 0;
92542 if( p==0 ) return 0; /* Can only happen following on OOM */
92543
92544 /* If an expression is an integer literal that fits in a signed 32-bit
92545 ** integer, then the EP_IntValue flag will have already been set */
92546 assert( p->op!=TK_INTEGER || (p->flags & EP_IntValue)!=0
92547 || sqlite3GetInt32(p->u.zToken, &rc)==0 );
@@ -93209,11 +93210,10 @@
93210 if( ALWAYS(pEList->nExpr==nVal) ){
93211 SelectDest dest;
93212 int i;
93213 sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
93214 dest.zAffSdst = exprINAffinity(pParse, pExpr);
 
93215 pSelect->iLimit = 0;
93216 testcase( pSelect->selFlags & SF_Distinct );
93217 testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
93218 if( sqlite3Select(pParse, pSelect, &dest) ){
93219 sqlite3DbFree(pParse->db, dest.zAffSdst);
@@ -105435,19 +105435,17 @@
105435 nNeedle = sqlite3_value_bytes(argv[1]);
105436 if( nNeedle>0 ){
105437 if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){
105438 zHaystack = sqlite3_value_blob(argv[0]);
105439 zNeedle = sqlite3_value_blob(argv[1]);
 
 
105440 isText = 0;
105441 }else{
105442 zHaystack = sqlite3_value_text(argv[0]);
105443 zNeedle = sqlite3_value_text(argv[1]);
105444 isText = 1;
 
105445 }
105446 if( zNeedle==0 || (nHaystack && zHaystack==0) ) return;
105447 while( nNeedle<=nHaystack && memcmp(zHaystack, zNeedle, nNeedle)!=0 ){
105448 N++;
105449 do{
105450 nHaystack--;
105451 zHaystack++;
@@ -113916,11 +113914,11 @@
113914 returnSingleInt(v, pDb->safety_level-1);
113915 }else{
113916 if( !db->autoCommit ){
113917 sqlite3ErrorMsg(pParse,
113918 "Safety level may not be changed inside a transaction");
113919 }else if( iDb!=1 ){
113920 int iLevel = (getSafetyLevel(zRight,0,1)+1) & PAGER_SYNCHRONOUS_MASK;
113921 if( iLevel==0 ) iLevel = 1;
113922 pDb->safety_level = iLevel;
113923 pDb->bSyncSet = 1;
113924 setAllPagerFlags(db);
@@ -119936,11 +119934,13 @@
119934 assert( pParent->pGroupBy==0 );
119935 pParent->pGroupBy = sqlite3ExprListDup(db, pSub->pGroupBy, 0);
119936 }else{
119937 pParent->pWhere = sqlite3ExprAnd(db, pWhere, pParent->pWhere);
119938 }
119939 if( db->mallocFailed==0 ){
119940 substSelect(pParse, pParent, iParent, pSub->pEList, 0);
119941 }
119942
119943 /* The flattened query is distinct if either the inner or the
119944 ** outer query is distinct.
119945 */
119946 pParent->selFlags |= pSub->selFlags & SF_Distinct;
@@ -130289,18 +130289,20 @@
130289 ** cursor iTabCur are transformed into OP_Null. Or, if bIncrRowid is non-zero,
130290 ** then each OP_Rowid is transformed into an instruction to increment the
130291 ** value stored in its output register.
130292 */
130293 static void translateColumnToCopy(
130294 Parse *pParse, /* Parsing context */
130295 int iStart, /* Translate from this opcode to the end */
130296 int iTabCur, /* OP_Column/OP_Rowid references to this table */
130297 int iRegister, /* The first column is in this register */
130298 int bIncrRowid /* If non-zero, transform OP_rowid to OP_AddImm(1) */
130299 ){
130300 Vdbe *v = pParse->pVdbe;
130301 VdbeOp *pOp = sqlite3VdbeGetOp(v, iStart);
130302 int iEnd = sqlite3VdbeCurrentAddr(v);
130303 if( pParse->db->mallocFailed ) return;
130304 for(; iStart<iEnd; iStart++, pOp++){
130305 if( pOp->p1!=iTabCur ) continue;
130306 if( pOp->opcode==OP_Column ){
130307 pOp->opcode = OP_Copy;
130308 pOp->p1 = pOp->p2 + iRegister;
@@ -130574,11 +130576,13 @@
130576 sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
130577 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
130578 if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);
130579 if( pTabItem->fg.viaCoroutine ){
130580 sqlite3VdbeChangeP2(v, addrCounter, regBase+n);
130581 testcase( pParse->db->mallocFailed );
130582 translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
130583 pTabItem->regResult, 1);
130584 sqlite3VdbeGoto(v, addrTop);
130585 pTabItem->fg.viaCoroutine = 0;
130586 }else{
130587 sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
130588 }
@@ -134692,12 +134696,13 @@
134696
134697 /* For a co-routine, change all OP_Column references to the table of
134698 ** the co-routine into OP_Copy of result contained in a register.
134699 ** OP_Rowid becomes OP_Null.
134700 */
134701 if( pTabItem->fg.viaCoroutine ){
134702 testcase( pParse->db->mallocFailed );
134703 translateColumnToCopy(pParse, pLevel->addrBody, pLevel->iTabCur,
134704 pTabItem->regResult, 0);
134705 continue;
134706 }
134707
134708 /* If this scan uses an index, make VDBE code substitutions to read data
@@ -198067,11 +198072,11 @@
198072 int nArg, /* Number of args */
198073 sqlite3_value **apUnused /* Function arguments */
198074 ){
198075 assert( nArg==0 );
198076 UNUSED_PARAM2(nArg, apUnused);
198077 sqlite3_result_text(pCtx, "fts5: 2017-03-16 14:28:52 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f", -1, SQLITE_TRANSIENT);
198078 }
198079
198080 static int fts5Init(sqlite3 *db){
198081 static const sqlite3_module fts5Mod = {
198082 /* iVersion */ 2,
198083
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121121
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122122
** [sqlite_version()] and [sqlite_source_id()].
123123
*/
124124
#define SQLITE_VERSION "3.18.0"
125125
#define SQLITE_VERSION_NUMBER 3018000
126
-#define SQLITE_SOURCE_ID "2017-03-10 17:03:11 f8560c60d10c0365b33342ab05b5a953987b0471"
126
+#define SQLITE_SOURCE_ID "2017-03-16 14:28:52 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f"
127127
128128
/*
129129
** CAPI3REF: Run-Time Library Version Numbers
130130
** KEYWORDS: sqlite3_version sqlite3_sourceid
131131
**
132132
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.18.0"
125 #define SQLITE_VERSION_NUMBER 3018000
126 #define SQLITE_SOURCE_ID "2017-03-10 17:03:11 f8560c60d10c0365b33342ab05b5a953987b0471"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
132
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,11 +121,11 @@
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.18.0"
125 #define SQLITE_VERSION_NUMBER 3018000
126 #define SQLITE_SOURCE_ID "2017-03-16 14:28:52 6d85eb5736781b43aa674d9544c7523b849b4e634f371702f8764b33e22e1e9f"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
132

Keyboard Shortcuts

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