Fossil SCM

Bring in the latest SQLite 3.8.0 alpha version from upstream, for testing.

drh 2013-06-29 15:26 trunk
Commit c3e723e308bbd4f23cd543da869e8a39640f8dde
3 files changed +38 -12 +139 -66 +3 -1
+38 -12
--- src/shell.c
+++ src/shell.c
@@ -1490,10 +1490,11 @@
14901490
** Do C-language style dequoting.
14911491
**
14921492
** \t -> tab
14931493
** \n -> newline
14941494
** \r -> carriage return
1495
+** \" -> "
14951496
** \NNN -> ascii character NNN in octal
14961497
** \\ -> backslash
14971498
*/
14981499
static void resolve_backslashes(char *z){
14991500
int i, j;
@@ -1505,10 +1506,12 @@
15051506
c = '\n';
15061507
}else if( c=='t' ){
15071508
c = '\t';
15081509
}else if( c=='r' ){
15091510
c = '\r';
1511
+ }else if( c=='\\' ){
1512
+ c = '\\';
15101513
}else if( c>='0' && c<='7' ){
15111514
c -= '0';
15121515
if( z[i+1]>='0' && z[i+1]<='7' ){
15131516
i++;
15141517
c = (c<<3) + z[i] - '0';
@@ -1770,11 +1773,14 @@
17701773
while( IsSpace(zLine[i]) ){ i++; }
17711774
if( zLine[i]==0 ) break;
17721775
if( zLine[i]=='\'' || zLine[i]=='"' ){
17731776
int delim = zLine[i++];
17741777
azArg[nArg++] = &zLine[i];
1775
- while( zLine[i] && zLine[i]!=delim ){ i++; }
1778
+ while( zLine[i] && zLine[i]!=delim ){
1779
+ if( zLine[i]=='\\' && delim=='"' && zLine[i+1]!=0 ) i++;
1780
+ i++;
1781
+ }
17761782
if( zLine[i]==delim ){
17771783
zLine[i++] = 0;
17781784
}
17791785
if( delim=='"' ) resolve_backslashes(azArg[nArg-1]);
17801786
}else{
@@ -1987,22 +1993,22 @@
19871993
}
19881994
}else
19891995
19901996
if( c=='i' && strncmp(azArg[0], "import", n)==0 && nArg==3 ){
19911997
char *zTable = azArg[2]; /* Insert data into this table */
1998
+ char *zFile = azArg[1]; /* Name of file to extra content from */
19921999
sqlite3_stmt *pStmt = NULL; /* A statement */
19932000
int nCol; /* Number of columns in the table */
19942001
int nByte; /* Number of bytes in an SQL string */
19952002
int i, j; /* Loop counters */
19962003
int nSep; /* Number of bytes in p->separator[] */
19972004
char *zSql; /* An SQL statement */
19982005
CSVReader sCsv; /* Reader context */
2006
+ int (*xCloser)(FILE*); /* Procedure to close th3 connection */
19992007
20002008
seenInterrupt = 0;
20012009
memset(&sCsv, 0, sizeof(sCsv));
2002
- sCsv.zFile = azArg[1];
2003
- sCsv.nLine = 1;
20042010
open_db(p);
20052011
nSep = strlen30(p->separator);
20062012
if( nSep==0 ){
20072013
fprintf(stderr, "Error: non-null separator required for import\n");
20082014
return 1;
@@ -2010,20 +2016,29 @@
20102016
if( nSep>1 ){
20112017
fprintf(stderr, "Error: multi-character separators not allowed"
20122018
" for import\n");
20132019
return 1;
20142020
}
2015
- sCsv.in = fopen(sCsv.zFile, "rb");
2021
+ sCsv.zFile = zFile;
2022
+ sCsv.nLine = 1;
2023
+ if( sCsv.zFile[0]=='|' ){
2024
+ sCsv.in = popen(sCsv.zFile+1, "r");
2025
+ sCsv.zFile = "<pipe>";
2026
+ xCloser = pclose;
2027
+ }else{
2028
+ sCsv.in = fopen(sCsv.zFile, "rb");
2029
+ xCloser = fclose;
2030
+ }
20162031
if( sCsv.in==0 ){
2017
- fprintf(stderr, "Error: cannot open \"%s\"\n", sCsv.zFile);
2032
+ fprintf(stderr, "Error: cannot open \"%s\"\n", zFile);
20182033
return 1;
20192034
}
20202035
sCsv.cSeparator = p->separator[0];
20212036
zSql = sqlite3_mprintf("SELECT * FROM %s", zTable);
20222037
if( zSql==0 ){
20232038
fprintf(stderr, "Error: out of memory\n");
2024
- fclose(sCsv.in);
2039
+ xCloser(sCsv.in);
20252040
return 1;
20262041
}
20272042
nByte = strlen30(zSql);
20282043
rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
20292044
if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){
@@ -2031,38 +2046,45 @@
20312046
char cSep = '(';
20322047
while( csv_read_one_field(&sCsv) ){
20332048
zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCsv.z);
20342049
cSep = ',';
20352050
if( sCsv.cTerm!=sCsv.cSeparator ) break;
2051
+ }
2052
+ if( cSep=='(' ){
2053
+ sqlite3_free(zCreate);
2054
+ sqlite3_free(sCsv.z);
2055
+ xCloser(sCsv.in);
2056
+ fprintf(stderr,"%s: empty file\n", sCsv.zFile);
2057
+ return 1;
20362058
}
20372059
zCreate = sqlite3_mprintf("%z\n)", zCreate);
20382060
rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
20392061
sqlite3_free(zCreate);
20402062
if( rc ){
20412063
fprintf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable,
20422064
sqlite3_errmsg(db));
20432065
sqlite3_free(sCsv.z);
2044
- fclose(sCsv.in);
2066
+ xCloser(sCsv.in);
20452067
return 1;
20462068
}
20472069
rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
20482070
}
20492071
sqlite3_free(zSql);
20502072
if( rc ){
20512073
if (pStmt) sqlite3_finalize(pStmt);
20522074
fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db));
2053
- fclose(sCsv.in);
2075
+ xCloser(sCsv.in);
20542076
return 1;
20552077
}
20562078
nCol = sqlite3_column_count(pStmt);
20572079
sqlite3_finalize(pStmt);
20582080
pStmt = 0;
20592081
if( nCol==0 ) return 0; /* no columns, no error */
20602082
zSql = sqlite3_malloc( nByte*2 + 20 + nCol*2 );
20612083
if( zSql==0 ){
20622084
fprintf(stderr, "Error: out of memory\n");
2063
- fclose(sCsv.in);
2085
+ xCloser(sCsv.in);
20642086
return 1;
20652087
}
20662088
sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable);
20672089
j = strlen30(zSql);
20682090
for(i=1; i<nCol; i++){
@@ -2074,11 +2096,11 @@
20742096
rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
20752097
sqlite3_free(zSql);
20762098
if( rc ){
20772099
fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
20782100
if (pStmt) sqlite3_finalize(pStmt);
2079
- fclose(sCsv.in);
2101
+ xCloser(sCsv.in);
20802102
return 1;
20812103
}
20822104
do{
20832105
int startLine = sCsv.nLine;
20842106
for(i=0; i<nCol; i++){
@@ -2110,11 +2132,11 @@
21102132
sqlite3_errmsg(db));
21112133
}
21122134
}
21132135
}while( sCsv.cTerm!=EOF );
21142136
2115
- fclose(sCsv.in);
2137
+ xCloser(sCsv.in);
21162138
sqlite3_free(sCsv.z);
21172139
sqlite3_finalize(pStmt);
21182140
sqlite3_exec(p->db, "COMMIT", 0, 0, 0);
21192141
}else
21202142
@@ -2435,10 +2457,11 @@
24352457
}else{
24362458
rc = 0;
24372459
}
24382460
}else
24392461
2462
+#ifdef SQLITE_DEBUG
24402463
/* Undocumented commands for internal testing. Subject to change
24412464
** without notice. */
24422465
if( c=='s' && n>=10 && strncmp(azArg[0], "selftest-", 9)==0 ){
24432466
if( strncmp(azArg[0]+9, "boolean", n-9)==0 ){
24442467
int i, v;
@@ -2448,15 +2471,18 @@
24482471
}
24492472
}
24502473
if( strncmp(azArg[0]+9, "integer", n-9)==0 ){
24512474
int i; sqlite3_int64 v;
24522475
for(i=1; i<nArg; i++){
2476
+ char zBuf[200];
24532477
v = integerValue(azArg[i]);
2454
- fprintf(p->out, "%s: %lld 0x%llx\n", azArg[i], v, v);
2478
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%s: %lld 0x%llx\n", azArg[i], v, v);
2479
+ fprintf(p->out, "%s", zBuf);
24552480
}
24562481
}
24572482
}else
2483
+#endif
24582484
24592485
if( c=='s' && strncmp(azArg[0], "separator", n)==0 && nArg==2 ){
24602486
sqlite3_snprintf(sizeof(p->separator), p->separator,
24612487
"%.*s", (int)sizeof(p->separator)-1, azArg[1]);
24622488
}else
24632489
--- src/shell.c
+++ src/shell.c
@@ -1490,10 +1490,11 @@
1490 ** Do C-language style dequoting.
1491 **
1492 ** \t -> tab
1493 ** \n -> newline
1494 ** \r -> carriage return
 
1495 ** \NNN -> ascii character NNN in octal
1496 ** \\ -> backslash
1497 */
1498 static void resolve_backslashes(char *z){
1499 int i, j;
@@ -1505,10 +1506,12 @@
1505 c = '\n';
1506 }else if( c=='t' ){
1507 c = '\t';
1508 }else if( c=='r' ){
1509 c = '\r';
 
 
1510 }else if( c>='0' && c<='7' ){
1511 c -= '0';
1512 if( z[i+1]>='0' && z[i+1]<='7' ){
1513 i++;
1514 c = (c<<3) + z[i] - '0';
@@ -1770,11 +1773,14 @@
1770 while( IsSpace(zLine[i]) ){ i++; }
1771 if( zLine[i]==0 ) break;
1772 if( zLine[i]=='\'' || zLine[i]=='"' ){
1773 int delim = zLine[i++];
1774 azArg[nArg++] = &zLine[i];
1775 while( zLine[i] && zLine[i]!=delim ){ i++; }
 
 
 
1776 if( zLine[i]==delim ){
1777 zLine[i++] = 0;
1778 }
1779 if( delim=='"' ) resolve_backslashes(azArg[nArg-1]);
1780 }else{
@@ -1987,22 +1993,22 @@
1987 }
1988 }else
1989
1990 if( c=='i' && strncmp(azArg[0], "import", n)==0 && nArg==3 ){
1991 char *zTable = azArg[2]; /* Insert data into this table */
 
1992 sqlite3_stmt *pStmt = NULL; /* A statement */
1993 int nCol; /* Number of columns in the table */
1994 int nByte; /* Number of bytes in an SQL string */
1995 int i, j; /* Loop counters */
1996 int nSep; /* Number of bytes in p->separator[] */
1997 char *zSql; /* An SQL statement */
1998 CSVReader sCsv; /* Reader context */
 
1999
2000 seenInterrupt = 0;
2001 memset(&sCsv, 0, sizeof(sCsv));
2002 sCsv.zFile = azArg[1];
2003 sCsv.nLine = 1;
2004 open_db(p);
2005 nSep = strlen30(p->separator);
2006 if( nSep==0 ){
2007 fprintf(stderr, "Error: non-null separator required for import\n");
2008 return 1;
@@ -2010,20 +2016,29 @@
2010 if( nSep>1 ){
2011 fprintf(stderr, "Error: multi-character separators not allowed"
2012 " for import\n");
2013 return 1;
2014 }
2015 sCsv.in = fopen(sCsv.zFile, "rb");
 
 
 
 
 
 
 
 
 
2016 if( sCsv.in==0 ){
2017 fprintf(stderr, "Error: cannot open \"%s\"\n", sCsv.zFile);
2018 return 1;
2019 }
2020 sCsv.cSeparator = p->separator[0];
2021 zSql = sqlite3_mprintf("SELECT * FROM %s", zTable);
2022 if( zSql==0 ){
2023 fprintf(stderr, "Error: out of memory\n");
2024 fclose(sCsv.in);
2025 return 1;
2026 }
2027 nByte = strlen30(zSql);
2028 rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
2029 if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){
@@ -2031,38 +2046,45 @@
2031 char cSep = '(';
2032 while( csv_read_one_field(&sCsv) ){
2033 zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCsv.z);
2034 cSep = ',';
2035 if( sCsv.cTerm!=sCsv.cSeparator ) break;
 
 
 
 
 
 
 
2036 }
2037 zCreate = sqlite3_mprintf("%z\n)", zCreate);
2038 rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
2039 sqlite3_free(zCreate);
2040 if( rc ){
2041 fprintf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable,
2042 sqlite3_errmsg(db));
2043 sqlite3_free(sCsv.z);
2044 fclose(sCsv.in);
2045 return 1;
2046 }
2047 rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
2048 }
2049 sqlite3_free(zSql);
2050 if( rc ){
2051 if (pStmt) sqlite3_finalize(pStmt);
2052 fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db));
2053 fclose(sCsv.in);
2054 return 1;
2055 }
2056 nCol = sqlite3_column_count(pStmt);
2057 sqlite3_finalize(pStmt);
2058 pStmt = 0;
2059 if( nCol==0 ) return 0; /* no columns, no error */
2060 zSql = sqlite3_malloc( nByte*2 + 20 + nCol*2 );
2061 if( zSql==0 ){
2062 fprintf(stderr, "Error: out of memory\n");
2063 fclose(sCsv.in);
2064 return 1;
2065 }
2066 sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable);
2067 j = strlen30(zSql);
2068 for(i=1; i<nCol; i++){
@@ -2074,11 +2096,11 @@
2074 rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
2075 sqlite3_free(zSql);
2076 if( rc ){
2077 fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
2078 if (pStmt) sqlite3_finalize(pStmt);
2079 fclose(sCsv.in);
2080 return 1;
2081 }
2082 do{
2083 int startLine = sCsv.nLine;
2084 for(i=0; i<nCol; i++){
@@ -2110,11 +2132,11 @@
2110 sqlite3_errmsg(db));
2111 }
2112 }
2113 }while( sCsv.cTerm!=EOF );
2114
2115 fclose(sCsv.in);
2116 sqlite3_free(sCsv.z);
2117 sqlite3_finalize(pStmt);
2118 sqlite3_exec(p->db, "COMMIT", 0, 0, 0);
2119 }else
2120
@@ -2435,10 +2457,11 @@
2435 }else{
2436 rc = 0;
2437 }
2438 }else
2439
 
2440 /* Undocumented commands for internal testing. Subject to change
2441 ** without notice. */
2442 if( c=='s' && n>=10 && strncmp(azArg[0], "selftest-", 9)==0 ){
2443 if( strncmp(azArg[0]+9, "boolean", n-9)==0 ){
2444 int i, v;
@@ -2448,15 +2471,18 @@
2448 }
2449 }
2450 if( strncmp(azArg[0]+9, "integer", n-9)==0 ){
2451 int i; sqlite3_int64 v;
2452 for(i=1; i<nArg; i++){
 
2453 v = integerValue(azArg[i]);
2454 fprintf(p->out, "%s: %lld 0x%llx\n", azArg[i], v, v);
 
2455 }
2456 }
2457 }else
 
2458
2459 if( c=='s' && strncmp(azArg[0], "separator", n)==0 && nArg==2 ){
2460 sqlite3_snprintf(sizeof(p->separator), p->separator,
2461 "%.*s", (int)sizeof(p->separator)-1, azArg[1]);
2462 }else
2463
--- src/shell.c
+++ src/shell.c
@@ -1490,10 +1490,11 @@
1490 ** Do C-language style dequoting.
1491 **
1492 ** \t -> tab
1493 ** \n -> newline
1494 ** \r -> carriage return
1495 ** \" -> "
1496 ** \NNN -> ascii character NNN in octal
1497 ** \\ -> backslash
1498 */
1499 static void resolve_backslashes(char *z){
1500 int i, j;
@@ -1505,10 +1506,12 @@
1506 c = '\n';
1507 }else if( c=='t' ){
1508 c = '\t';
1509 }else if( c=='r' ){
1510 c = '\r';
1511 }else if( c=='\\' ){
1512 c = '\\';
1513 }else if( c>='0' && c<='7' ){
1514 c -= '0';
1515 if( z[i+1]>='0' && z[i+1]<='7' ){
1516 i++;
1517 c = (c<<3) + z[i] - '0';
@@ -1770,11 +1773,14 @@
1773 while( IsSpace(zLine[i]) ){ i++; }
1774 if( zLine[i]==0 ) break;
1775 if( zLine[i]=='\'' || zLine[i]=='"' ){
1776 int delim = zLine[i++];
1777 azArg[nArg++] = &zLine[i];
1778 while( zLine[i] && zLine[i]!=delim ){
1779 if( zLine[i]=='\\' && delim=='"' && zLine[i+1]!=0 ) i++;
1780 i++;
1781 }
1782 if( zLine[i]==delim ){
1783 zLine[i++] = 0;
1784 }
1785 if( delim=='"' ) resolve_backslashes(azArg[nArg-1]);
1786 }else{
@@ -1987,22 +1993,22 @@
1993 }
1994 }else
1995
1996 if( c=='i' && strncmp(azArg[0], "import", n)==0 && nArg==3 ){
1997 char *zTable = azArg[2]; /* Insert data into this table */
1998 char *zFile = azArg[1]; /* Name of file to extra content from */
1999 sqlite3_stmt *pStmt = NULL; /* A statement */
2000 int nCol; /* Number of columns in the table */
2001 int nByte; /* Number of bytes in an SQL string */
2002 int i, j; /* Loop counters */
2003 int nSep; /* Number of bytes in p->separator[] */
2004 char *zSql; /* An SQL statement */
2005 CSVReader sCsv; /* Reader context */
2006 int (*xCloser)(FILE*); /* Procedure to close th3 connection */
2007
2008 seenInterrupt = 0;
2009 memset(&sCsv, 0, sizeof(sCsv));
 
 
2010 open_db(p);
2011 nSep = strlen30(p->separator);
2012 if( nSep==0 ){
2013 fprintf(stderr, "Error: non-null separator required for import\n");
2014 return 1;
@@ -2010,20 +2016,29 @@
2016 if( nSep>1 ){
2017 fprintf(stderr, "Error: multi-character separators not allowed"
2018 " for import\n");
2019 return 1;
2020 }
2021 sCsv.zFile = zFile;
2022 sCsv.nLine = 1;
2023 if( sCsv.zFile[0]=='|' ){
2024 sCsv.in = popen(sCsv.zFile+1, "r");
2025 sCsv.zFile = "<pipe>";
2026 xCloser = pclose;
2027 }else{
2028 sCsv.in = fopen(sCsv.zFile, "rb");
2029 xCloser = fclose;
2030 }
2031 if( sCsv.in==0 ){
2032 fprintf(stderr, "Error: cannot open \"%s\"\n", zFile);
2033 return 1;
2034 }
2035 sCsv.cSeparator = p->separator[0];
2036 zSql = sqlite3_mprintf("SELECT * FROM %s", zTable);
2037 if( zSql==0 ){
2038 fprintf(stderr, "Error: out of memory\n");
2039 xCloser(sCsv.in);
2040 return 1;
2041 }
2042 nByte = strlen30(zSql);
2043 rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
2044 if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){
@@ -2031,38 +2046,45 @@
2046 char cSep = '(';
2047 while( csv_read_one_field(&sCsv) ){
2048 zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCsv.z);
2049 cSep = ',';
2050 if( sCsv.cTerm!=sCsv.cSeparator ) break;
2051 }
2052 if( cSep=='(' ){
2053 sqlite3_free(zCreate);
2054 sqlite3_free(sCsv.z);
2055 xCloser(sCsv.in);
2056 fprintf(stderr,"%s: empty file\n", sCsv.zFile);
2057 return 1;
2058 }
2059 zCreate = sqlite3_mprintf("%z\n)", zCreate);
2060 rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
2061 sqlite3_free(zCreate);
2062 if( rc ){
2063 fprintf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable,
2064 sqlite3_errmsg(db));
2065 sqlite3_free(sCsv.z);
2066 xCloser(sCsv.in);
2067 return 1;
2068 }
2069 rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
2070 }
2071 sqlite3_free(zSql);
2072 if( rc ){
2073 if (pStmt) sqlite3_finalize(pStmt);
2074 fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db));
2075 xCloser(sCsv.in);
2076 return 1;
2077 }
2078 nCol = sqlite3_column_count(pStmt);
2079 sqlite3_finalize(pStmt);
2080 pStmt = 0;
2081 if( nCol==0 ) return 0; /* no columns, no error */
2082 zSql = sqlite3_malloc( nByte*2 + 20 + nCol*2 );
2083 if( zSql==0 ){
2084 fprintf(stderr, "Error: out of memory\n");
2085 xCloser(sCsv.in);
2086 return 1;
2087 }
2088 sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable);
2089 j = strlen30(zSql);
2090 for(i=1; i<nCol; i++){
@@ -2074,11 +2096,11 @@
2096 rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
2097 sqlite3_free(zSql);
2098 if( rc ){
2099 fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
2100 if (pStmt) sqlite3_finalize(pStmt);
2101 xCloser(sCsv.in);
2102 return 1;
2103 }
2104 do{
2105 int startLine = sCsv.nLine;
2106 for(i=0; i<nCol; i++){
@@ -2110,11 +2132,11 @@
2132 sqlite3_errmsg(db));
2133 }
2134 }
2135 }while( sCsv.cTerm!=EOF );
2136
2137 xCloser(sCsv.in);
2138 sqlite3_free(sCsv.z);
2139 sqlite3_finalize(pStmt);
2140 sqlite3_exec(p->db, "COMMIT", 0, 0, 0);
2141 }else
2142
@@ -2435,10 +2457,11 @@
2457 }else{
2458 rc = 0;
2459 }
2460 }else
2461
2462 #ifdef SQLITE_DEBUG
2463 /* Undocumented commands for internal testing. Subject to change
2464 ** without notice. */
2465 if( c=='s' && n>=10 && strncmp(azArg[0], "selftest-", 9)==0 ){
2466 if( strncmp(azArg[0]+9, "boolean", n-9)==0 ){
2467 int i, v;
@@ -2448,15 +2471,18 @@
2471 }
2472 }
2473 if( strncmp(azArg[0]+9, "integer", n-9)==0 ){
2474 int i; sqlite3_int64 v;
2475 for(i=1; i<nArg; i++){
2476 char zBuf[200];
2477 v = integerValue(azArg[i]);
2478 sqlite3_snprintf(sizeof(zBuf), zBuf, "%s: %lld 0x%llx\n", azArg[i], v, v);
2479 fprintf(p->out, "%s", zBuf);
2480 }
2481 }
2482 }else
2483 #endif
2484
2485 if( c=='s' && strncmp(azArg[0], "separator", n)==0 && nArg==2 ){
2486 sqlite3_snprintf(sizeof(p->separator), p->separator,
2487 "%.*s", (int)sizeof(p->separator)-1, azArg[1]);
2488 }else
2489
+139 -66
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -670,11 +670,11 @@
670670
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671671
** [sqlite_version()] and [sqlite_source_id()].
672672
*/
673673
#define SQLITE_VERSION "3.8.0"
674674
#define SQLITE_VERSION_NUMBER 3008000
675
-#define SQLITE_SOURCE_ID "2013-06-26 22:46:00 93f632152e464a89322a0130adaf9f342411bf7d"
675
+#define SQLITE_SOURCE_ID "2013-06-28 23:55:45 338826ef3f8a209b14f8d42370855cab9ac9ed45"
676676
677677
/*
678678
** CAPI3REF: Run-Time Library Version Numbers
679679
** KEYWORDS: sqlite3_version, sqlite3_sourceid
680680
**
@@ -1041,10 +1041,11 @@
10411041
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
10421042
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
10431043
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
10441044
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
10451045
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1046
+#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
10461047
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
10471048
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
10481049
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
10491050
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
10501051
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
@@ -1060,10 +1061,11 @@
10601061
#define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8))
10611062
#define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8))
10621063
#define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8))
10631064
#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
10641065
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
1066
+#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
10651067
10661068
/*
10671069
** CAPI3REF: Flags For File Open Operations
10681070
**
10691071
** These bit values are intended for use in the
@@ -10076,13 +10078,14 @@
1007610078
int newTnum; /* Rootpage of table being initialized */
1007710079
u8 iDb; /* Which db file is being initialized */
1007810080
u8 busy; /* TRUE if currently initializing */
1007910081
u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */
1008010082
} init;
10081
- int activeVdbeCnt; /* Number of VDBEs currently executing */
10082
- int writeVdbeCnt; /* Number of active VDBEs that are writing */
10083
- int vdbeExecCnt; /* Number of nested calls to VdbeExec() */
10083
+ int nVdbeActive; /* Number of VDBEs currently running */
10084
+ int nVdbeRead; /* Number of active VDBEs that read or write */
10085
+ int nVdbeWrite; /* Number of active VDBEs that read and write */
10086
+ int nVdbeExec; /* Number of nested calls to VdbeExec() */
1008410087
int nExtension; /* Number of loaded extensions */
1008510088
void **aExtension; /* Array of shared library handles */
1008610089
void (*xTrace)(void*,const char*); /* Trace function */
1008710090
void *pTraceArg; /* Argument to the trace function */
1008810091
void (*xProfile)(void*,const char*,u64); /* Profiling function */
@@ -10204,10 +10207,11 @@
1020410207
#define SQLITE_CoverIdxScan 0x0040 /* Covering index scans */
1020510208
#define SQLITE_OrderByIdxJoin 0x0080 /* ORDER BY of joins via index */
1020610209
#define SQLITE_SubqCoroutine 0x0100 /* Evaluate subqueries as coroutines */
1020710210
#define SQLITE_Transitive 0x0200 /* Transitive constraints */
1020810211
#define SQLITE_OmitNoopJoin 0x0400 /* Omit unused tables in joins */
10212
+#define SQLITE_Stat3 0x0800 /* Use the SQLITE_STAT3 table */
1020910213
#define SQLITE_AllOpts 0xffff /* All optimizations */
1021010214
1021110215
/*
1021210216
** Macros for testing whether or not optimizations are enabled or disabled.
1021310217
*/
@@ -13512,11 +13516,12 @@
1351213516
bft inVtabMethod:2; /* See comments above */
1351313517
bft changeCntOn:1; /* True to update the change-counter */
1351413518
bft expired:1; /* True if the VM needs to be recompiled */
1351513519
bft runOnlyOnce:1; /* Automatically expire on reset */
1351613520
bft usesStmtJournal:1; /* True if uses a statement journal */
13517
- bft readOnly:1; /* True for read-only statements */
13521
+ bft readOnly:1; /* True for statements that do not write */
13522
+ bft bIsReader:1; /* True for statements that read */
1351813523
bft isPrepareV2:1; /* True if prepared with prepare_v2() */
1351913524
bft doingRerun:1; /* True if rerunning after an auto-reprepare */
1352013525
int nChange; /* Number of db changes made since last reset */
1352113526
yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
1352213527
yDbMask lockMask; /* Subset of btreeMask that requires a lock */
@@ -47891,11 +47896,11 @@
4789147896
** the write is disallowed.
4789247897
*/
4789347898
if( memcmp(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr))!=0 ){
4789447899
walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);
4789547900
pWal->writeLock = 0;
47896
- rc = SQLITE_BUSY;
47901
+ rc = SQLITE_BUSY_SNAPSHOT;
4789747902
}
4789847903
4789947904
return rc;
4790047905
}
4790147906
@@ -52751,16 +52756,17 @@
5275152756
** This function is called from both BtreeCommitPhaseTwo() and BtreeRollback()
5275252757
** at the conclusion of a transaction.
5275352758
*/
5275452759
static void btreeEndTransaction(Btree *p){
5275552760
BtShared *pBt = p->pBt;
52761
+ sqlite3 *db = p->db;
5275652762
assert( sqlite3BtreeHoldsMutex(p) );
5275752763
5275852764
#ifndef SQLITE_OMIT_AUTOVACUUM
5275952765
pBt->bDoTruncate = 0;
5276052766
#endif
52761
- if( p->inTrans>TRANS_NONE && p->db->activeVdbeCnt>1 ){
52767
+ if( p->inTrans>TRANS_NONE && db->nVdbeRead>1 ){
5276252768
/* If there are other active statements that belong to this database
5276352769
** handle, downgrade to a read-only transaction. The other statements
5276452770
** may still be reading from the database. */
5276552771
downgradeAllSharedCacheTableLocks(p);
5276652772
p->inTrans = TRANS_READ;
@@ -60277,18 +60283,30 @@
6027760283
int i;
6027860284
int nMaxArgs = *pMaxFuncArgs;
6027960285
Op *pOp;
6028060286
int *aLabel = p->aLabel;
6028160287
p->readOnly = 1;
60288
+ p->bIsReader = 0;
6028260289
for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
6028360290
u8 opcode = pOp->opcode;
6028460291
6028560292
pOp->opflags = sqlite3OpcodeProperty[opcode];
6028660293
if( opcode==OP_Function || opcode==OP_AggStep ){
6028760294
if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60288
- }else if( (opcode==OP_Transaction && pOp->p2!=0) || opcode==OP_Vacuum ){
60295
+ }else if( opcode==OP_Transaction ){
60296
+ if( pOp->p2!=0 ) p->readOnly = 0;
60297
+ p->bIsReader = 1;
60298
+ }else if( opcode==OP_AutoCommit || opcode==OP_Savepoint ){
60299
+ p->bIsReader = 1;
60300
+ }else if( opcode==OP_Vacuum
60301
+ || opcode==OP_JournalMode
60302
+#ifndef SQLITE_OMIT_VIRTUALTABLE
60303
+ || opcode==OP_Checkpoint
60304
+#endif
60305
+ ){
6028960306
p->readOnly = 0;
60307
+ p->bIsReader = 1;
6029060308
#ifndef SQLITE_OMIT_VIRTUALTABLE
6029160309
}else if( opcode==OP_VUpdate ){
6029260310
if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
6029360311
}else if( opcode==OP_VFilter ){
6029460312
int n;
@@ -60310,12 +60328,12 @@
6031060328
pOp->p2 = aLabel[-1-pOp->p2];
6031160329
}
6031260330
}
6031360331
sqlite3DbFree(p->db, p->aLabel);
6031460332
p->aLabel = 0;
60315
-
6031660333
*pMaxFuncArgs = nMaxArgs;
60334
+ assert( p->bIsReader!=0 || p->btreeMask==0 );
6031760335
}
6031860336
6031960337
/*
6032060338
** Return the address of the next instruction to be inserted.
6032160339
*/
@@ -61837,11 +61855,11 @@
6183761855
6183861856
return rc;
6183961857
}
6184061858
6184161859
/*
61842
-** This routine checks that the sqlite3.activeVdbeCnt count variable
61860
+** This routine checks that the sqlite3.nVdbeActive count variable
6184361861
** matches the number of vdbe's in the list sqlite3.pVdbe that are
6184461862
** currently active. An assertion fails if the two counts do not match.
6184561863
** This is an internal self-check only - it is not an essential processing
6184661864
** step.
6184761865
**
@@ -61850,20 +61868,23 @@
6185061868
#ifndef NDEBUG
6185161869
static void checkActiveVdbeCnt(sqlite3 *db){
6185261870
Vdbe *p;
6185361871
int cnt = 0;
6185461872
int nWrite = 0;
61873
+ int nRead = 0;
6185561874
p = db->pVdbe;
6185661875
while( p ){
6185761876
if( p->magic==VDBE_MAGIC_RUN && p->pc>=0 ){
6185861877
cnt++;
6185961878
if( p->readOnly==0 ) nWrite++;
61879
+ if( p->bIsReader ) nRead++;
6186061880
}
6186161881
p = p->pNext;
6186261882
}
61863
- assert( cnt==db->activeVdbeCnt );
61864
- assert( nWrite==db->writeVdbeCnt );
61883
+ assert( cnt==db->nVdbeActive );
61884
+ assert( nWrite==db->nVdbeWrite );
61885
+ assert( nRead==db->nVdbeRead );
6186561886
}
6186661887
#else
6186761888
#define checkActiveVdbeCnt(x)
6186861889
#endif
6186961890
@@ -61995,12 +62016,13 @@
6199562016
if( p->magic!=VDBE_MAGIC_RUN ){
6199662017
return SQLITE_OK;
6199762018
}
6199862019
checkActiveVdbeCnt(db);
6199962020
62000
- /* No commit or rollback needed if the program never started */
62001
- if( p->pc>=0 ){
62021
+ /* No commit or rollback needed if the program never started or if the
62022
+ ** SQL statement does not read or write a database file. */
62023
+ if( p->pc>=0 && p->bIsReader ){
6200262024
int mrc; /* Primary error code from p->rc */
6200362025
int eStatementOp = 0;
6200462026
int isSpecialError; /* Set to true if a 'special' error */
6200562027
6200662028
/* Lock all btrees used by the statement */
@@ -62049,11 +62071,11 @@
6204962071
** Note: This block also runs if one of the special errors handled
6205062072
** above has occurred.
6205162073
*/
6205262074
if( !sqlite3VtabInSync(db)
6205362075
&& db->autoCommit
62054
- && db->writeVdbeCnt==(p->readOnly==0)
62076
+ && db->nVdbeWrite==(p->readOnly==0)
6205562077
){
6205662078
if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
6205762079
rc = sqlite3VdbeCheckFk(p, 1);
6205862080
if( rc!=SQLITE_OK ){
6205962081
if( NEVER(p->readOnly) ){
@@ -62130,15 +62152,16 @@
6213062152
sqlite3VdbeLeave(p);
6213162153
}
6213262154
6213362155
/* We have successfully halted and closed the VM. Record this fact. */
6213462156
if( p->pc>=0 ){
62135
- db->activeVdbeCnt--;
62136
- if( !p->readOnly ){
62137
- db->writeVdbeCnt--;
62138
- }
62139
- assert( db->activeVdbeCnt>=db->writeVdbeCnt );
62157
+ db->nVdbeActive--;
62158
+ if( !p->readOnly ) db->nVdbeWrite--;
62159
+ if( p->bIsReader ) db->nVdbeRead--;
62160
+ assert( db->nVdbeActive>=db->nVdbeRead );
62161
+ assert( db->nVdbeRead>=db->nVdbeWrite );
62162
+ assert( db->nVdbeWrite>=0 );
6214062163
}
6214162164
p->magic = VDBE_MAGIC_HALT;
6214262165
checkActiveVdbeCnt(db);
6214362166
if( p->db->mallocFailed ){
6214462167
p->rc = SQLITE_NOMEM;
@@ -62150,11 +62173,11 @@
6215062173
*/
6215162174
if( db->autoCommit ){
6215262175
sqlite3ConnectionUnlocked(db);
6215362176
}
6215462177
62155
- assert( db->activeVdbeCnt>0 || db->autoCommit==0 || db->nStatement==0 );
62178
+ assert( db->nVdbeActive>0 || db->autoCommit==0 || db->nStatement==0 );
6215662179
return (p->rc==SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK);
6215762180
}
6215862181
6215962182
6216062183
/*
@@ -63508,35 +63531,36 @@
6350863531
if( p->pc<0 ){
6350963532
/* If there are no other statements currently running, then
6351063533
** reset the interrupt flag. This prevents a call to sqlite3_interrupt
6351163534
** from interrupting a statement that has not yet started.
6351263535
*/
63513
- if( db->activeVdbeCnt==0 ){
63536
+ if( db->nVdbeActive==0 ){
6351463537
db->u1.isInterrupted = 0;
6351563538
}
6351663539
63517
- assert( db->writeVdbeCnt>0 || db->autoCommit==0 || db->nDeferredCons==0 );
63540
+ assert( db->nVdbeWrite>0 || db->autoCommit==0 || db->nDeferredCons==0 );
6351863541
6351963542
#ifndef SQLITE_OMIT_TRACE
6352063543
if( db->xProfile && !db->init.busy ){
6352163544
sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
6352263545
}
6352363546
#endif
6352463547
63525
- db->activeVdbeCnt++;
63526
- if( p->readOnly==0 ) db->writeVdbeCnt++;
63548
+ db->nVdbeActive++;
63549
+ if( p->readOnly==0 ) db->nVdbeWrite++;
63550
+ if( p->bIsReader ) db->nVdbeRead++;
6352763551
p->pc = 0;
6352863552
}
6352963553
#ifndef SQLITE_OMIT_EXPLAIN
6353063554
if( p->explain ){
6353163555
rc = sqlite3VdbeList(p);
6353263556
}else
6353363557
#endif /* SQLITE_OMIT_EXPLAIN */
6353463558
{
63535
- db->vdbeExecCnt++;
63559
+ db->nVdbeExec++;
6353663560
rc = sqlite3VdbeExec(p);
63537
- db->vdbeExecCnt--;
63561
+ db->nVdbeExec--;
6353863562
}
6353963563
6354063564
#ifndef SQLITE_OMIT_TRACE
6354163565
/* Invoke the profile callback if there is one
6354263566
*/
@@ -64469,13 +64493,13 @@
6446964493
return nTotal;
6447064494
}
6447164495
6447264496
/*
6447364497
** This function returns a pointer to a nul-terminated string in memory
64474
-** obtained from sqlite3DbMalloc(). If sqlite3.vdbeExecCnt is 1, then the
64498
+** obtained from sqlite3DbMalloc(). If sqlite3.nVdbeExec is 1, then the
6447564499
** string contains a copy of zRawSql but with host parameters expanded to
64476
-** their current bindings. Or, if sqlite3.vdbeExecCnt is greater than 1,
64500
+** their current bindings. Or, if sqlite3.nVdbeExec is greater than 1,
6447764501
** then the returned string holds a copy of zRawSql with "-- " prepended
6447864502
** to each line of text.
6447964503
**
6448064504
** If the SQLITE_TRACE_SIZE_LIMIT macro is defined to an integer, then
6448164505
** then long strings and blobs are truncated to that many bytes. This
@@ -64509,11 +64533,11 @@
6450964533
6451064534
db = p->db;
6451164535
sqlite3StrAccumInit(&out, zBase, sizeof(zBase),
6451264536
db->aLimit[SQLITE_LIMIT_LENGTH]);
6451364537
out.db = db;
64514
- if( db->vdbeExecCnt>1 ){
64538
+ if( db->nVdbeExec>1 ){
6451564539
while( *zRawSql ){
6451664540
const char *zStart = zRawSql;
6451764541
while( *(zRawSql++)!='\n' && *zRawSql );
6451864542
sqlite3StrAccumAppend(&out, "-- ", 3);
6451964543
sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart));
@@ -65815,10 +65839,11 @@
6581565839
/* This happens if a malloc() inside a call to sqlite3_column_text() or
6581665840
** sqlite3_column_text16() failed. */
6581765841
goto no_mem;
6581865842
}
6581965843
assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY );
65844
+ assert( p->bIsReader || p->readOnly!=0 );
6582065845
p->rc = SQLITE_OK;
6582165846
assert( p->explain==0 );
6582265847
p->pResultSet = 0;
6582365848
db->busyHandler.nBusy = 0;
6582465849
CHECK_FOR_INTERRUPT;
@@ -67959,13 +67984,14 @@
6795967984
*/
6796067985
assert( db->pSavepoint==0 || db->autoCommit==0 );
6796167986
assert( u.as.p1==SAVEPOINT_BEGIN||u.as.p1==SAVEPOINT_RELEASE||u.as.p1==SAVEPOINT_ROLLBACK );
6796267987
assert( db->pSavepoint || db->isTransactionSavepoint==0 );
6796367988
assert( checkSavepointCount(db) );
67989
+ assert( p->bIsReader );
6796467990
6796567991
if( u.as.p1==SAVEPOINT_BEGIN ){
67966
- if( db->writeVdbeCnt>0 ){
67992
+ if( db->nVdbeWrite>0 ){
6796767993
/* A new savepoint cannot be created if there are active write
6796867994
** statements (i.e. open read/write incremental blob handles).
6796967995
*/
6797067996
sqlite3SetString(&p->zErrMsg, db, "cannot open savepoint - "
6797167997
"SQL statements in progress");
@@ -68018,11 +68044,11 @@
6801868044
u.as.iSavepoint++;
6801968045
}
6802068046
if( !u.as.pSavepoint ){
6802168047
sqlite3SetString(&p->zErrMsg, db, "no such savepoint: %s", u.as.zName);
6802268048
rc = SQLITE_ERROR;
68023
- }else if( db->writeVdbeCnt>0 && u.as.p1==SAVEPOINT_RELEASE ){
68049
+ }else if( db->nVdbeWrite>0 && u.as.p1==SAVEPOINT_RELEASE ){
6802468050
/* It is not possible to release (commit) a savepoint if there are
6802568051
** active write statements.
6802668052
*/
6802768053
sqlite3SetString(&p->zErrMsg, db,
6802868054
"cannot release savepoint - SQL statements in progress"
@@ -68121,24 +68147,25 @@
6812168147
u.at.desiredAutoCommit = pOp->p1;
6812268148
u.at.iRollback = pOp->p2;
6812368149
u.at.turnOnAC = u.at.desiredAutoCommit && !db->autoCommit;
6812468150
assert( u.at.desiredAutoCommit==1 || u.at.desiredAutoCommit==0 );
6812568151
assert( u.at.desiredAutoCommit==1 || u.at.iRollback==0 );
68126
- assert( db->activeVdbeCnt>0 ); /* At least this one VM is active */
68152
+ assert( db->nVdbeActive>0 ); /* At least this one VM is active */
68153
+ assert( p->bIsReader );
6812768154
6812868155
#if 0
68129
- if( u.at.turnOnAC && u.at.iRollback && db->activeVdbeCnt>1 ){
68156
+ if( u.at.turnOnAC && u.at.iRollback && db->nVdbeActive>1 ){
6813068157
/* If this instruction implements a ROLLBACK and other VMs are
6813168158
** still running, and a transaction is active, return an error indicating
6813268159
** that the other VMs must complete first.
6813368160
*/
6813468161
sqlite3SetString(&p->zErrMsg, db, "cannot rollback transaction - "
6813568162
"SQL statements in progress");
6813668163
rc = SQLITE_BUSY;
6813768164
}else
6813868165
#endif
68139
- if( u.at.turnOnAC && !u.at.iRollback && db->writeVdbeCnt>0 ){
68166
+ if( u.at.turnOnAC && !u.at.iRollback && db->nVdbeWrite>0 ){
6814068167
/* If this instruction implements a COMMIT and other VMs are writing
6814168168
** return an error indicating that the other VMs must complete first.
6814268169
*/
6814368170
sqlite3SetString(&p->zErrMsg, db, "cannot commit transaction - "
6814468171
"SQL statements in progress");
@@ -68212,10 +68239,12 @@
6821268239
case OP_Transaction: {
6821368240
#if 0 /* local variables moved into u.au */
6821468241
Btree *pBt;
6821568242
#endif /* local variables moved into u.au */
6821668243
68244
+ assert( p->bIsReader );
68245
+ assert( p->readOnly==0 || pOp->p2==0 );
6821768246
assert( pOp->p1>=0 && pOp->p1<db->nDb );
6821868247
assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
6821968248
u.au.pBt = db->aDb[pOp->p1].pBt;
6822068249
6822168250
if( u.au.pBt ){
@@ -68228,11 +68257,11 @@
6822868257
if( rc!=SQLITE_OK ){
6822968258
goto abort_due_to_error;
6823068259
}
6823168260
6823268261
if( pOp->p2 && p->usesStmtJournal
68233
- && (db->autoCommit==0 || db->activeVdbeCnt>1)
68262
+ && (db->autoCommit==0 || db->nVdbeRead>1)
6823468263
){
6823568264
assert( sqlite3BtreeIsInTrans(u.au.pBt) );
6823668265
if( p->iStatement==0 ){
6823768266
assert( db->nStatement>=0 && db->nSavepoint>=0 );
6823868267
db->nStatement++;
@@ -68270,10 +68299,11 @@
6827068299
int iMeta;
6827168300
int iDb;
6827268301
int iCookie;
6827368302
#endif /* local variables moved into u.av */
6827468303
68304
+ assert( p->bIsReader );
6827568305
u.av.iDb = pOp->p1;
6827668306
u.av.iCookie = pOp->p3;
6827768307
assert( pOp->p3<SQLITE_N_BTREE_META );
6827868308
assert( u.av.iDb>=0 && u.av.iDb<db->nDb );
6827968309
assert( db->aDb[u.av.iDb].pBt!=0 );
@@ -68299,10 +68329,11 @@
6829968329
Db *pDb;
6830068330
#endif /* local variables moved into u.aw */
6830168331
assert( pOp->p2<SQLITE_N_BTREE_META );
6830268332
assert( pOp->p1>=0 && pOp->p1<db->nDb );
6830368333
assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
68334
+ assert( p->readOnly==0 );
6830468335
u.aw.pDb = &db->aDb[pOp->p1];
6830568336
assert( u.aw.pDb->pBt!=0 );
6830668337
assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) );
6830768338
pIn3 = &aMem[pOp->p3];
6830868339
sqlite3VdbeMemIntegerify(pIn3);
@@ -68351,10 +68382,11 @@
6835168382
#endif /* local variables moved into u.ax */
6835268383
6835368384
assert( pOp->p1>=0 && pOp->p1<db->nDb );
6835468385
assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
6835568386
assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) );
68387
+ assert( p->bIsReader );
6835668388
u.ax.pBt = db->aDb[pOp->p1].pBt;
6835768389
if( u.ax.pBt ){
6835868390
sqlite3BtreeGetMeta(u.ax.pBt, BTREE_SCHEMA_VERSION, (u32 *)&u.ax.iMeta);
6835968391
u.ax.iGen = db->aDb[pOp->p1].pSchema->iGeneration;
6836068392
}else{
@@ -68448,10 +68480,12 @@
6844868480
Db *pDb;
6844968481
#endif /* local variables moved into u.ay */
6845068482
6845168483
assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR))==pOp->p5 );
6845268484
assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 );
68485
+ assert( p->bIsReader );
68486
+ assert( pOp->opcode==OP_OpenRead || p->readOnly==0 );
6845368487
6845468488
if( p->expired ){
6845568489
rc = SQLITE_ABORT;
6845668490
break;
6845768491
}
@@ -70066,19 +70100,22 @@
7006670100
int iCnt;
7006770101
Vdbe *pVdbe;
7006870102
int iDb;
7006970103
#endif /* local variables moved into u.bw */
7007070104
70105
+ assert( p->readOnly==0 );
7007170106
#ifndef SQLITE_OMIT_VIRTUALTABLE
7007270107
u.bw.iCnt = 0;
7007370108
for(u.bw.pVdbe=db->pVdbe; u.bw.pVdbe; u.bw.pVdbe = u.bw.pVdbe->pNext){
70074
- if( u.bw.pVdbe->magic==VDBE_MAGIC_RUN && u.bw.pVdbe->inVtabMethod<2 && u.bw.pVdbe->pc>=0 ){
70109
+ if( u.bw.pVdbe->magic==VDBE_MAGIC_RUN && u.bw.pVdbe->bIsReader
70110
+ && u.bw.pVdbe->inVtabMethod<2 && u.bw.pVdbe->pc>=0
70111
+ ){
7007570112
u.bw.iCnt++;
7007670113
}
7007770114
}
7007870115
#else
70079
- u.bw.iCnt = db->activeVdbeCnt;
70116
+ u.bw.iCnt = db->nVdbeRead;
7008070117
#endif
7008170118
pOut->flags = MEM_Null;
7008270119
if( u.bw.iCnt>1 ){
7008370120
rc = SQLITE_LOCKED;
7008470121
p->errorAction = OE_Abort;
@@ -70123,10 +70160,11 @@
7012370160
#if 0 /* local variables moved into u.bx */
7012470161
int nChange;
7012570162
#endif /* local variables moved into u.bx */
7012670163
7012770164
u.bx.nChange = 0;
70165
+ assert( p->readOnly==0 );
7012870166
assert( (p->btreeMask & (((yDbMask)1)<<pOp->p2))!=0 );
7012970167
rc = sqlite3BtreeClearTable(
7013070168
db->aDb[pOp->p2].pBt, pOp->p1, (pOp->p3 ? &u.bx.nChange : 0)
7013170169
);
7013270170
if( pOp->p3 ){
@@ -70171,10 +70209,11 @@
7017170209
#endif /* local variables moved into u.by */
7017270210
7017370211
u.by.pgno = 0;
7017470212
assert( pOp->p1>=0 && pOp->p1<db->nDb );
7017570213
assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
70214
+ assert( p->readOnly==0 );
7017670215
u.by.pDb = &db->aDb[pOp->p1];
7017770216
assert( u.by.pDb->pBt!=0 );
7017870217
if( pOp->opcode==OP_CreateTable ){
7017970218
/* u.by.flags = BTREE_INTKEY; */
7018070219
u.by.flags = BTREE_INTKEY;
@@ -70323,10 +70362,11 @@
7032370362
int nErr; /* Number of errors reported */
7032470363
char *z; /* Text of the error report */
7032570364
Mem *pnErr; /* Register keeping track of errors remaining */
7032670365
#endif /* local variables moved into u.ca */
7032770366
70367
+ assert( p->bIsReader );
7032870368
u.ca.nRoot = pOp->p2;
7032970369
assert( u.ca.nRoot>0 );
7033070370
u.ca.aRoot = sqlite3DbMallocRaw(db, sizeof(int)*(u.ca.nRoot+1) );
7033170371
if( u.ca.aRoot==0 ) goto no_mem;
7033270372
assert( pOp->p3>0 && pOp->p3<=p->nMem );
@@ -70844,10 +70884,11 @@
7084470884
int i; /* Loop counter */
7084570885
int aRes[3]; /* Results */
7084670886
Mem *pMem; /* Write results here */
7084770887
#endif /* local variables moved into u.ci */
7084870888
70889
+ assert( p->readOnly==0 );
7084970890
u.ci.aRes[0] = 0;
7085070891
u.ci.aRes[1] = u.ci.aRes[2] = -1;
7085170892
assert( pOp->p2==SQLITE_CHECKPOINT_PASSIVE
7085270893
|| pOp->p2==SQLITE_CHECKPOINT_FULL
7085370894
|| pOp->p2==SQLITE_CHECKPOINT_RESTART
@@ -70895,10 +70936,11 @@
7089570936
|| u.cj.eNew==PAGER_JOURNALMODE_MEMORY
7089670937
|| u.cj.eNew==PAGER_JOURNALMODE_WAL
7089770938
|| u.cj.eNew==PAGER_JOURNALMODE_QUERY
7089870939
);
7089970940
assert( pOp->p1>=0 && pOp->p1<db->nDb );
70941
+ assert( p->readOnly==0 );
7090070942
7090170943
u.cj.pBt = db->aDb[pOp->p1].pBt;
7090270944
u.cj.pPager = sqlite3BtreePager(u.cj.pBt);
7090370945
u.cj.eOld = sqlite3PagerGetJournalMode(u.cj.pPager);
7090470946
if( u.cj.eNew==PAGER_JOURNALMODE_QUERY ) u.cj.eNew = u.cj.eOld;
@@ -70918,11 +70960,11 @@
7091870960
}
7091970961
7092070962
if( (u.cj.eNew!=u.cj.eOld)
7092170963
&& (u.cj.eOld==PAGER_JOURNALMODE_WAL || u.cj.eNew==PAGER_JOURNALMODE_WAL)
7092270964
){
70923
- if( !db->autoCommit || db->activeVdbeCnt>1 ){
70965
+ if( !db->autoCommit || db->nVdbeRead>1 ){
7092470966
rc = SQLITE_ERROR;
7092570967
sqlite3SetString(&p->zErrMsg, db,
7092670968
"cannot change %s wal mode from within a transaction",
7092770969
(u.cj.eNew==PAGER_JOURNALMODE_WAL ? "into" : "out of")
7092870970
);
@@ -70977,10 +71019,11 @@
7097771019
** Vacuum the entire database. This opcode will cause other virtual
7097871020
** machines to be created and run. It may not be called from within
7097971021
** a transaction.
7098071022
*/
7098171023
case OP_Vacuum: {
71024
+ assert( p->readOnly==0 );
7098271025
rc = sqlite3RunVacuum(&p->zErrMsg, db);
7098371026
break;
7098471027
}
7098571028
#endif
7098671029
@@ -70996,10 +71039,11 @@
7099671039
Btree *pBt;
7099771040
#endif /* local variables moved into u.ck */
7099871041
7099971042
assert( pOp->p1>=0 && pOp->p1<db->nDb );
7100071043
assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
71044
+ assert( p->readOnly==0 );
7100171045
u.ck.pBt = db->aDb[pOp->p1].pBt;
7100271046
rc = sqlite3BtreeIncrVacuum(u.ck.pBt);
7100371047
if( rc==SQLITE_DONE ){
7100471048
pc = pOp->p2 - 1;
7100571049
rc = SQLITE_OK;
@@ -71118,10 +71162,11 @@
7111871162
sqlite3_vtab_cursor *pVtabCursor;
7111971163
sqlite3_vtab *pVtab;
7112071164
sqlite3_module *pModule;
7112171165
#endif /* local variables moved into u.cm */
7112271166
71167
+ assert( p->bIsReader );
7112371168
u.cm.pCur = 0;
7112471169
u.cm.pVtabCursor = 0;
7112571170
u.cm.pVtab = pOp->p4.pVtab->pVtab;
7112671171
u.cm.pModule = (sqlite3_module *)u.cm.pVtab->pModule;
7112771172
assert(u.cm.pVtab && u.cm.pModule);
@@ -71342,10 +71387,11 @@
7134271387
7134371388
u.cq.pVtab = pOp->p4.pVtab->pVtab;
7134471389
u.cq.pName = &aMem[pOp->p1];
7134571390
assert( u.cq.pVtab->pModule->xRename );
7134671391
assert( memIsValid(u.cq.pName) );
71392
+ assert( p->readOnly==0 );
7134771393
REGISTER_TRACE(pOp->p1, u.cq.pName);
7134871394
assert( u.cq.pName->flags & MEM_Str );
7134971395
testcase( u.cq.pName->enc==SQLITE_UTF8 );
7135071396
testcase( u.cq.pName->enc==SQLITE_UTF16BE );
7135171397
testcase( u.cq.pName->enc==SQLITE_UTF16LE );
@@ -71395,10 +71441,11 @@
7139571441
#endif /* local variables moved into u.cr */
7139671442
7139771443
assert( pOp->p2==1 || pOp->p5==OE_Fail || pOp->p5==OE_Rollback
7139871444
|| pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace
7139971445
);
71446
+ assert( p->readOnly==0 );
7140071447
u.cr.pVtab = pOp->p4.pVtab->pVtab;
7140171448
u.cr.pModule = (sqlite3_module *)u.cr.pVtab->pModule;
7140271449
u.cr.nArg = pOp->p2;
7140371450
assert( pOp->p4type==P4_VTAB );
7140471451
if( ALWAYS(u.cr.pModule->xUpdate) ){
@@ -102957,11 +103004,11 @@
102957103004
102958103005
if( !db->autoCommit ){
102959103006
sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction");
102960103007
return SQLITE_ERROR;
102961103008
}
102962
- if( db->activeVdbeCnt>1 ){
103009
+ if( db->nVdbeActive>1 ){
102963103010
sqlite3SetString(pzErrMsg, db,"cannot VACUUM - SQL statements in progress");
102964103011
return SQLITE_ERROR;
102965103012
}
102966103013
102967103014
/* Save the current value of the database flags so that it can be
@@ -104742,11 +104789,11 @@
104742104789
#define WHERE_INDEXED 0x00000200 /* WhereLoop.u.btree.pIndex is valid */
104743104790
#define WHERE_VIRTUALTABLE 0x00000400 /* WhereLoop.u.vtab is valid */
104744104791
#define WHERE_IN_ABLE 0x00000800 /* Able to support an IN operator */
104745104792
#define WHERE_ONEROW 0x00001000 /* Selects no more than one row */
104746104793
#define WHERE_MULTI_OR 0x00002000 /* OR using multiple indices */
104747
-#define WHERE_TEMP_INDEX 0x00004000 /* Uses an ephemeral index */
104794
+#define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
104748104795
104749104796
104750104797
/* Convert a WhereCost value (10 times log2(X)) into its integer value X.
104751104798
** A rough approximation is used. The value returned is not exact.
104752104799
*/
@@ -106036,10 +106083,11 @@
106036106083
** the start of the loop will prevent any results from being returned.
106037106084
*/
106038106085
if( pExpr->op==TK_NOTNULL
106039106086
&& pExpr->pLeft->op==TK_COLUMN
106040106087
&& pExpr->pLeft->iColumn>=0
106088
+ && OptimizationEnabled(db, SQLITE_Stat3)
106041106089
){
106042106090
Expr *pNewExpr;
106043106091
Expr *pLeft = pExpr->pLeft;
106044106092
int idxNew;
106045106093
WhereTerm *pNewTerm;
@@ -106339,10 +106387,11 @@
106339106387
int mxBitCol; /* Maximum column in pSrc->colUsed */
106340106388
CollSeq *pColl; /* Collating sequence to on a column */
106341106389
WhereLoop *pLoop; /* The Loop object */
106342106390
Bitmask idxCols; /* Bitmap of columns used for indexing */
106343106391
Bitmask extraCols; /* Bitmap of additional columns */
106392
+ u8 sentWarning = 0; /* True if a warnning has been issued */
106344106393
106345106394
/* Generate code to skip over the creation and initialization of the
106346106395
** transient index on 2nd and subsequent iterations of the loop. */
106347106396
v = pParse->pVdbe;
106348106397
assert( v!=0 );
@@ -106359,10 +106408,16 @@
106359106408
if( termCanDriveIndex(pTerm, pSrc, notReady) ){
106360106409
int iCol = pTerm->u.leftColumn;
106361106410
Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);
106362106411
testcase( iCol==BMS );
106363106412
testcase( iCol==BMS-1 );
106413
+ if( !sentWarning ){
106414
+ sqlite3_log(SQLITE_WARNING_AUTOINDEX,
106415
+ "automatic index on %s(%s)", pTable->zName,
106416
+ pTable->aCol[iCol].zName);
106417
+ sentWarning = 1;
106418
+ }
106364106419
if( (idxCols & cMask)==0 ){
106365106420
if( whereLoopResize(pParse->db, pLoop, nColumn+1) ) return;
106366106421
pLoop->aLTerm[nColumn++] = pTerm;
106367106422
idxCols |= cMask;
106368106423
}
@@ -106369,11 +106424,11 @@
106369106424
}
106370106425
}
106371106426
assert( nColumn>0 );
106372106427
pLoop->u.btree.nEq = pLoop->nLTerm = nColumn;
106373106428
pLoop->wsFlags = WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WHERE_INDEXED
106374
- | WHERE_TEMP_INDEX;
106429
+ | WHERE_AUTO_INDEX;
106375106430
106376106431
/* Count the number of additional columns needed to create a
106377106432
** covering index. A "covering index" is an index that contains all
106378106433
** columns that are needed by the query. With a covering index, the
106379106434
** original table never needs to be accessed. Automatic indices must
@@ -106869,11 +106924,11 @@
106869106924
){
106870106925
int rc = SQLITE_OK;
106871106926
106872106927
#ifdef SQLITE_ENABLE_STAT3
106873106928
106874
- if( nEq==0 && p->nSample ){
106929
+ if( nEq==0 && p->nSample && OptimizationEnabled(pParse->db, SQLITE_Stat3) ){
106875106930
sqlite3_value *pRangeVal;
106876106931
tRowcnt iLower = 0;
106877106932
tRowcnt iUpper = p->aiRowEst[0];
106878106933
tRowcnt a[2];
106879106934
u8 aff = p->pTable->aCol[p->aiColumn[0]].affinity;
@@ -107415,17 +107470,16 @@
107415107470
}
107416107471
if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0
107417107472
&& ALWAYS(pLoop->u.btree.pIndex!=0)
107418107473
){
107419107474
char *zWhere = explainIndexRange(db, pLoop, pItem->pTab);
107420
- zMsg = sqlite3MAppendf(db, zMsg, "%s USING %s%sINDEX%s%s%s", zMsg,
107421
- ((flags & WHERE_TEMP_INDEX)?"AUTOMATIC ":""),
107422
- ((flags & WHERE_IDX_ONLY)?"COVERING ":""),
107423
- ((flags & WHERE_TEMP_INDEX)?"":" "),
107424
- ((flags & WHERE_TEMP_INDEX)?"": pLoop->u.btree.pIndex->zName),
107425
- zWhere
107426
- );
107475
+ zMsg = sqlite3MAppendf(db, zMsg,
107476
+ ((flags & WHERE_AUTO_INDEX) ?
107477
+ "%s USING AUTOMATIC %sINDEX%.0s%s" :
107478
+ "%s USING %sINDEX %s%s"),
107479
+ zMsg, ((flags & WHERE_IDX_ONLY) ? "COVERING " : ""),
107480
+ pLoop->u.btree.pIndex->zName, zWhere);
107427107481
sqlite3DbFree(db, zWhere);
107428107482
}else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){
107429107483
zMsg = sqlite3MAppendf(db, zMsg, "%s USING INTEGER PRIMARY KEY", zMsg);
107430107484
107431107485
if( flags&(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) ){
@@ -108092,11 +108146,11 @@
108092108146
** terms, set pCov to the candidate covering index. Otherwise, set
108093108147
** pCov to NULL to indicate that no candidate covering index will
108094108148
** be available.
108095108149
*/
108096108150
pSubLoop = pSubWInfo->a[0].pWLoop;
108097
- assert( (pSubLoop->wsFlags & WHERE_TEMP_INDEX)==0 );
108151
+ assert( (pSubLoop->wsFlags & WHERE_AUTO_INDEX)==0 );
108098108152
if( (pSubLoop->wsFlags & WHERE_INDEXED)!=0
108099108153
&& (ii==0 || pSubLoop->u.btree.pIndex==pCov)
108100108154
){
108101108155
assert( pSubWInfo->a[0].iIdxCur==iCovCur );
108102108156
pCov = pSubLoop->u.btree.pIndex;
@@ -108274,16 +108328,16 @@
108274108328
108275108329
/*
108276108330
** Clear the WhereLoop.u union. Leave WhereLoop.pLTerm intact.
108277108331
*/
108278108332
static void whereLoopClearUnion(sqlite3 *db, WhereLoop *p){
108279
- if( p->wsFlags & (WHERE_VIRTUALTABLE|WHERE_TEMP_INDEX) ){
108333
+ if( p->wsFlags & (WHERE_VIRTUALTABLE|WHERE_AUTO_INDEX) ){
108280108334
if( (p->wsFlags & WHERE_VIRTUALTABLE)!=0 && p->u.vtab.needFree ){
108281108335
sqlite3_free(p->u.vtab.idxStr);
108282108336
p->u.vtab.needFree = 0;
108283108337
p->u.vtab.idxStr = 0;
108284
- }else if( (p->wsFlags & WHERE_TEMP_INDEX)!=0 && p->u.btree.pIndex!=0 ){
108338
+ }else if( (p->wsFlags & WHERE_AUTO_INDEX)!=0 && p->u.btree.pIndex!=0 ){
108285108339
sqlite3DbFree(db, p->u.btree.pIndex->zColAff);
108286108340
sqlite3DbFree(db, p->u.btree.pIndex);
108287108341
p->u.btree.pIndex = 0;
108288108342
}
108289108343
}
@@ -108322,11 +108376,11 @@
108322108376
whereLoopClearUnion(db, pTo);
108323108377
memcpy(pTo, pFrom, WHERE_LOOP_XFER_SZ);
108324108378
memcpy(pTo->aLTerm, pFrom->aLTerm, pTo->nLTerm*sizeof(pTo->aLTerm[0]));
108325108379
if( pFrom->wsFlags & WHERE_VIRTUALTABLE ){
108326108380
pFrom->u.vtab.needFree = 0;
108327
- }else if( (pFrom->wsFlags & WHERE_TEMP_INDEX)!=0 ){
108381
+ }else if( (pFrom->wsFlags & WHERE_AUTO_INDEX)!=0 ){
108328108382
pFrom->u.btree.pIndex = 0;
108329108383
}
108330108384
return SQLITE_OK;
108331108385
}
108332108386
@@ -108634,11 +108688,12 @@
108634108688
whereRangeScanEst(pParse, pProbe, pNew->u.btree.nEq,
108635108689
pBtm, pTop, &rDiv);
108636108690
pNew->nOut = saved_nOut>rDiv+10 ? saved_nOut - rDiv : 10;
108637108691
}
108638108692
#ifdef SQLITE_ENABLE_STAT3
108639
- if( pNew->u.btree.nEq==1 && pProbe->nSample ){
108693
+ if( pNew->u.btree.nEq==1 && pProbe->nSample
108694
+ && OptimizationEnabled(db, SQLITE_Stat3) ){
108640108695
tRowcnt nOut = 0;
108641108696
if( (pTerm->eOperator & (WO_EQ|WO_ISNULL))!=0 ){
108642108697
testcase( pTerm->eOperator & WO_EQ );
108643108698
testcase( pTerm->eOperator & WO_ISNULL );
108644108699
rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut);
@@ -108794,17 +108849,20 @@
108794108849
pNew->u.btree.nEq = 1;
108795108850
pNew->u.btree.pIndex = 0;
108796108851
pNew->nLTerm = 1;
108797108852
pNew->aLTerm[0] = pTerm;
108798108853
/* TUNING: One-time cost for computing the automatic index is
108799
- ** approximately 6*N*log2(N) where N is the number of rows in
108854
+ ** approximately 7*N*log2(N) where N is the number of rows in
108800108855
** the table being indexed. */
108801
- pNew->rSetup = rLogSize + rSize + 26; assert( 26==whereCost(6) );
108802
- /* TUNING: Each index lookup yields 10 rows in the table */
108803
- pNew->nOut = 33; assert( 33==whereCost(10) );
108856
+ pNew->rSetup = rLogSize + rSize + 28; assert( 28==whereCost(7) );
108857
+ /* TUNING: Each index lookup yields 20 rows in the table. This
108858
+ ** is more than the usual guess of 10 rows, since we have no way
108859
+ ** of knowning how selective the index will ultimately be. It would
108860
+ ** not be unreasonable to make this value much larger. */
108861
+ pNew->nOut = 43; assert( 43==whereCost(20) );
108804108862
pNew->rRun = whereCostAdd(rLogSize,pNew->nOut);
108805
- pNew->wsFlags = WHERE_TEMP_INDEX;
108863
+ pNew->wsFlags = WHERE_AUTO_INDEX;
108806108864
pNew->prereq = mExtra | pTerm->prereqRight;
108807108865
rc = whereLoopInsert(pBuilder, pNew);
108808108866
}
108809108867
}
108810108868
}
@@ -110094,18 +110152,28 @@
110094110152
&& OptimizationEnabled(db, SQLITE_OmitNoopJoin)
110095110153
){
110096110154
Bitmask tabUsed = exprListTableUsage(pMaskSet, pResultSet);
110097110155
if( pOrderBy ) tabUsed |= exprListTableUsage(pMaskSet, pOrderBy);
110098110156
while( pWInfo->nLevel>=2 ){
110157
+ WhereTerm *pTerm, *pEnd;
110099110158
pLoop = pWInfo->a[pWInfo->nLevel-1].pWLoop;
110100110159
if( (pWInfo->pTabList->a[pLoop->iTab].jointype & JT_LEFT)==0 ) break;
110101110160
if( (wctrlFlags & WHERE_WANT_DISTINCT)==0
110102110161
&& (pLoop->wsFlags & WHERE_ONEROW)==0
110103110162
){
110104110163
break;
110105110164
}
110106110165
if( (tabUsed & pLoop->maskSelf)!=0 ) break;
110166
+ pEnd = sWLB.pWC->a + sWLB.pWC->nTerm;
110167
+ for(pTerm=sWLB.pWC->a; pTerm<pEnd; pTerm++){
110168
+ if( (pTerm->prereqAll & pLoop->maskSelf)!=0
110169
+ && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
110170
+ ){
110171
+ break;
110172
+ }
110173
+ }
110174
+ if( pTerm<pEnd ) break;
110107110175
WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId));
110108110176
pWInfo->nLevel--;
110109110177
nTabList--;
110110110178
}
110111110179
}
@@ -110167,11 +110235,11 @@
110167110235
}
110168110236
}else{
110169110237
sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
110170110238
}
110171110239
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
110172
- if( (pLoop->wsFlags & WHERE_TEMP_INDEX)!=0 ){
110240
+ if( (pLoop->wsFlags & WHERE_AUTO_INDEX)!=0 ){
110173110241
constructAutomaticIndex(pParse, &pWInfo->sWC, pTabItem, notReady, pLevel);
110174110242
}else
110175110243
#endif
110176110244
if( pLoop->wsFlags & WHERE_INDEXED ){
110177110245
Index *pIx = pLoop->u.btree.pIndex;
@@ -110290,11 +110358,11 @@
110290110358
){
110291110359
int ws = pLoop->wsFlags;
110292110360
if( !pWInfo->okOnePass && (ws & WHERE_IDX_ONLY)==0 ){
110293110361
sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
110294110362
}
110295
- if( (ws & WHERE_INDEXED)!=0 && (ws & (WHERE_IPK|WHERE_TEMP_INDEX))==0 ){
110363
+ if( (ws & WHERE_INDEXED)!=0 && (ws & (WHERE_IPK|WHERE_AUTO_INDEX))==0 ){
110296110364
sqlite3VdbeAddOp1(v, OP_Close, pLevel->iIdxCur);
110297110365
}
110298110366
}
110299110367
110300110368
/* If this scan uses an index, make VDBE code substitutions to read data
@@ -114501,11 +114569,11 @@
114501114569
sqlite3 *db = pParse->db; /* The database connection */
114502114570
int mxSqlLen; /* Max length of an SQL string */
114503114571
114504114572
114505114573
mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
114506
- if( db->activeVdbeCnt==0 ){
114574
+ if( db->nVdbeActive==0 ){
114507114575
db->u1.isInterrupted = 0;
114508114576
}
114509114577
pParse->rc = SQLITE_OK;
114510114578
pParse->zTail = zSql;
114511114579
i = 0;
@@ -116069,10 +116137,11 @@
116069116137
case SQLITE_PERM: zName = "SQLITE_PERM"; break;
116070116138
case SQLITE_ABORT: zName = "SQLITE_ABORT"; break;
116071116139
case SQLITE_ABORT_ROLLBACK: zName = "SQLITE_ABORT_ROLLBACK"; break;
116072116140
case SQLITE_BUSY: zName = "SQLITE_BUSY"; break;
116073116141
case SQLITE_BUSY_RECOVERY: zName = "SQLITE_BUSY_RECOVERY"; break;
116142
+ case SQLITE_BUSY_SNAPSHOT: zName = "SQLITE_BUSY_SNAPSHOT"; break;
116074116143
case SQLITE_LOCKED: zName = "SQLITE_LOCKED"; break;
116075116144
case SQLITE_LOCKED_SHAREDCACHE: zName = "SQLITE_LOCKED_SHAREDCACHE";break;
116076116145
case SQLITE_NOMEM: zName = "SQLITE_NOMEM"; break;
116077116146
case SQLITE_READONLY: zName = "SQLITE_READONLY"; break;
116078116147
case SQLITE_READONLY_RECOVERY: zName = "SQLITE_READONLY_RECOVERY"; break;
@@ -116142,10 +116211,11 @@
116142116211
case SQLITE_NOTICE: zName = "SQLITE_NOTICE"; break;
116143116212
case SQLITE_NOTICE_RECOVER_WAL: zName = "SQLITE_NOTICE_RECOVER_WAL";break;
116144116213
case SQLITE_NOTICE_RECOVER_ROLLBACK:
116145116214
zName = "SQLITE_NOTICE_RECOVER_ROLLBACK"; break;
116146116215
case SQLITE_WARNING: zName = "SQLITE_WARNING"; break;
116216
+ case SQLITE_WARNING_AUTOINDEX: zName = "SQLITE_WARNING_AUTOINDEX"; break;
116147116217
case SQLITE_DONE: zName = "SQLITE_DONE"; break;
116148116218
}
116149116219
}
116150116220
if( zName==0 ){
116151116221
static char zBuf[50];
@@ -116400,11 +116470,11 @@
116400116470
** is being overridden/deleted but there are no active VMs, allow the
116401116471
** operation to continue but invalidate all precompiled statements.
116402116472
*/
116403116473
p = sqlite3FindFunction(db, zFunctionName, nName, nArg, (u8)enc, 0);
116404116474
if( p && p->iPrefEnc==enc && p->nArg==nArg ){
116405
- if( db->activeVdbeCnt ){
116475
+ if( db->nVdbeActive ){
116406116476
sqlite3Error(db, SQLITE_BUSY,
116407116477
"unable to delete/modify user-function due to active statements");
116408116478
assert( !db->mallocFailed );
116409116479
return SQLITE_BUSY;
116410116480
}else{
@@ -116981,11 +117051,11 @@
116981117051
** sequence. If so, and there are active VMs, return busy. If there
116982117052
** are no active VMs, invalidate any pre-compiled statements.
116983117053
*/
116984117054
pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 0);
116985117055
if( pColl && pColl->xCmp ){
116986
- if( db->activeVdbeCnt ){
117056
+ if( db->nVdbeActive ){
116987117057
sqlite3Error(db, SQLITE_BUSY,
116988117058
"unable to delete/modify collation sequence due to active statements");
116989117059
return SQLITE_BUSY;
116990117060
}
116991117061
sqlite3ExpirePreparedStatements(db);
@@ -117456,11 +117526,14 @@
117456117526
memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
117457117527
db->autoCommit = 1;
117458117528
db->nextAutovac = -1;
117459117529
db->szMmap = sqlite3GlobalConfig.szMmap;
117460117530
db->nextPagesize = 0;
117461
- db->flags |= SQLITE_ShortColNames | SQLITE_AutoIndex | SQLITE_EnableTrigger
117531
+ db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117532
+#if !defined(SQLITE_DEAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117533
+ | SQLITE_AutoIndex
117534
+#endif
117462117535
#if SQLITE_DEFAULT_FILE_FORMAT<4
117463117536
| SQLITE_LegacyFileFmt
117464117537
#endif
117465117538
#ifdef SQLITE_ENABLE_LOAD_EXTENSION
117466117539
| SQLITE_LoadExtension
117467117540
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -670,11 +670,11 @@
670 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671 ** [sqlite_version()] and [sqlite_source_id()].
672 */
673 #define SQLITE_VERSION "3.8.0"
674 #define SQLITE_VERSION_NUMBER 3008000
675 #define SQLITE_SOURCE_ID "2013-06-26 22:46:00 93f632152e464a89322a0130adaf9f342411bf7d"
676
677 /*
678 ** CAPI3REF: Run-Time Library Version Numbers
679 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
680 **
@@ -1041,10 +1041,11 @@
1041 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1042 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1043 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1044 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1045 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
 
1046 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1047 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
1048 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
1049 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
1050 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
@@ -1060,10 +1061,11 @@
1060 #define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8))
1061 #define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8))
1062 #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8))
1063 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
1064 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
 
1065
1066 /*
1067 ** CAPI3REF: Flags For File Open Operations
1068 **
1069 ** These bit values are intended for use in the
@@ -10076,13 +10078,14 @@
10076 int newTnum; /* Rootpage of table being initialized */
10077 u8 iDb; /* Which db file is being initialized */
10078 u8 busy; /* TRUE if currently initializing */
10079 u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */
10080 } init;
10081 int activeVdbeCnt; /* Number of VDBEs currently executing */
10082 int writeVdbeCnt; /* Number of active VDBEs that are writing */
10083 int vdbeExecCnt; /* Number of nested calls to VdbeExec() */
 
10084 int nExtension; /* Number of loaded extensions */
10085 void **aExtension; /* Array of shared library handles */
10086 void (*xTrace)(void*,const char*); /* Trace function */
10087 void *pTraceArg; /* Argument to the trace function */
10088 void (*xProfile)(void*,const char*,u64); /* Profiling function */
@@ -10204,10 +10207,11 @@
10204 #define SQLITE_CoverIdxScan 0x0040 /* Covering index scans */
10205 #define SQLITE_OrderByIdxJoin 0x0080 /* ORDER BY of joins via index */
10206 #define SQLITE_SubqCoroutine 0x0100 /* Evaluate subqueries as coroutines */
10207 #define SQLITE_Transitive 0x0200 /* Transitive constraints */
10208 #define SQLITE_OmitNoopJoin 0x0400 /* Omit unused tables in joins */
 
10209 #define SQLITE_AllOpts 0xffff /* All optimizations */
10210
10211 /*
10212 ** Macros for testing whether or not optimizations are enabled or disabled.
10213 */
@@ -13512,11 +13516,12 @@
13512 bft inVtabMethod:2; /* See comments above */
13513 bft changeCntOn:1; /* True to update the change-counter */
13514 bft expired:1; /* True if the VM needs to be recompiled */
13515 bft runOnlyOnce:1; /* Automatically expire on reset */
13516 bft usesStmtJournal:1; /* True if uses a statement journal */
13517 bft readOnly:1; /* True for read-only statements */
 
13518 bft isPrepareV2:1; /* True if prepared with prepare_v2() */
13519 bft doingRerun:1; /* True if rerunning after an auto-reprepare */
13520 int nChange; /* Number of db changes made since last reset */
13521 yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
13522 yDbMask lockMask; /* Subset of btreeMask that requires a lock */
@@ -47891,11 +47896,11 @@
47891 ** the write is disallowed.
47892 */
47893 if( memcmp(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr))!=0 ){
47894 walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);
47895 pWal->writeLock = 0;
47896 rc = SQLITE_BUSY;
47897 }
47898
47899 return rc;
47900 }
47901
@@ -52751,16 +52756,17 @@
52751 ** This function is called from both BtreeCommitPhaseTwo() and BtreeRollback()
52752 ** at the conclusion of a transaction.
52753 */
52754 static void btreeEndTransaction(Btree *p){
52755 BtShared *pBt = p->pBt;
 
52756 assert( sqlite3BtreeHoldsMutex(p) );
52757
52758 #ifndef SQLITE_OMIT_AUTOVACUUM
52759 pBt->bDoTruncate = 0;
52760 #endif
52761 if( p->inTrans>TRANS_NONE && p->db->activeVdbeCnt>1 ){
52762 /* If there are other active statements that belong to this database
52763 ** handle, downgrade to a read-only transaction. The other statements
52764 ** may still be reading from the database. */
52765 downgradeAllSharedCacheTableLocks(p);
52766 p->inTrans = TRANS_READ;
@@ -60277,18 +60283,30 @@
60277 int i;
60278 int nMaxArgs = *pMaxFuncArgs;
60279 Op *pOp;
60280 int *aLabel = p->aLabel;
60281 p->readOnly = 1;
 
60282 for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
60283 u8 opcode = pOp->opcode;
60284
60285 pOp->opflags = sqlite3OpcodeProperty[opcode];
60286 if( opcode==OP_Function || opcode==OP_AggStep ){
60287 if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60288 }else if( (opcode==OP_Transaction && pOp->p2!=0) || opcode==OP_Vacuum ){
 
 
 
 
 
 
 
 
 
 
60289 p->readOnly = 0;
 
60290 #ifndef SQLITE_OMIT_VIRTUALTABLE
60291 }else if( opcode==OP_VUpdate ){
60292 if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
60293 }else if( opcode==OP_VFilter ){
60294 int n;
@@ -60310,12 +60328,12 @@
60310 pOp->p2 = aLabel[-1-pOp->p2];
60311 }
60312 }
60313 sqlite3DbFree(p->db, p->aLabel);
60314 p->aLabel = 0;
60315
60316 *pMaxFuncArgs = nMaxArgs;
 
60317 }
60318
60319 /*
60320 ** Return the address of the next instruction to be inserted.
60321 */
@@ -61837,11 +61855,11 @@
61837
61838 return rc;
61839 }
61840
61841 /*
61842 ** This routine checks that the sqlite3.activeVdbeCnt count variable
61843 ** matches the number of vdbe's in the list sqlite3.pVdbe that are
61844 ** currently active. An assertion fails if the two counts do not match.
61845 ** This is an internal self-check only - it is not an essential processing
61846 ** step.
61847 **
@@ -61850,20 +61868,23 @@
61850 #ifndef NDEBUG
61851 static void checkActiveVdbeCnt(sqlite3 *db){
61852 Vdbe *p;
61853 int cnt = 0;
61854 int nWrite = 0;
 
61855 p = db->pVdbe;
61856 while( p ){
61857 if( p->magic==VDBE_MAGIC_RUN && p->pc>=0 ){
61858 cnt++;
61859 if( p->readOnly==0 ) nWrite++;
 
61860 }
61861 p = p->pNext;
61862 }
61863 assert( cnt==db->activeVdbeCnt );
61864 assert( nWrite==db->writeVdbeCnt );
 
61865 }
61866 #else
61867 #define checkActiveVdbeCnt(x)
61868 #endif
61869
@@ -61995,12 +62016,13 @@
61995 if( p->magic!=VDBE_MAGIC_RUN ){
61996 return SQLITE_OK;
61997 }
61998 checkActiveVdbeCnt(db);
61999
62000 /* No commit or rollback needed if the program never started */
62001 if( p->pc>=0 ){
 
62002 int mrc; /* Primary error code from p->rc */
62003 int eStatementOp = 0;
62004 int isSpecialError; /* Set to true if a 'special' error */
62005
62006 /* Lock all btrees used by the statement */
@@ -62049,11 +62071,11 @@
62049 ** Note: This block also runs if one of the special errors handled
62050 ** above has occurred.
62051 */
62052 if( !sqlite3VtabInSync(db)
62053 && db->autoCommit
62054 && db->writeVdbeCnt==(p->readOnly==0)
62055 ){
62056 if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
62057 rc = sqlite3VdbeCheckFk(p, 1);
62058 if( rc!=SQLITE_OK ){
62059 if( NEVER(p->readOnly) ){
@@ -62130,15 +62152,16 @@
62130 sqlite3VdbeLeave(p);
62131 }
62132
62133 /* We have successfully halted and closed the VM. Record this fact. */
62134 if( p->pc>=0 ){
62135 db->activeVdbeCnt--;
62136 if( !p->readOnly ){
62137 db->writeVdbeCnt--;
62138 }
62139 assert( db->activeVdbeCnt>=db->writeVdbeCnt );
 
62140 }
62141 p->magic = VDBE_MAGIC_HALT;
62142 checkActiveVdbeCnt(db);
62143 if( p->db->mallocFailed ){
62144 p->rc = SQLITE_NOMEM;
@@ -62150,11 +62173,11 @@
62150 */
62151 if( db->autoCommit ){
62152 sqlite3ConnectionUnlocked(db);
62153 }
62154
62155 assert( db->activeVdbeCnt>0 || db->autoCommit==0 || db->nStatement==0 );
62156 return (p->rc==SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK);
62157 }
62158
62159
62160 /*
@@ -63508,35 +63531,36 @@
63508 if( p->pc<0 ){
63509 /* If there are no other statements currently running, then
63510 ** reset the interrupt flag. This prevents a call to sqlite3_interrupt
63511 ** from interrupting a statement that has not yet started.
63512 */
63513 if( db->activeVdbeCnt==0 ){
63514 db->u1.isInterrupted = 0;
63515 }
63516
63517 assert( db->writeVdbeCnt>0 || db->autoCommit==0 || db->nDeferredCons==0 );
63518
63519 #ifndef SQLITE_OMIT_TRACE
63520 if( db->xProfile && !db->init.busy ){
63521 sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
63522 }
63523 #endif
63524
63525 db->activeVdbeCnt++;
63526 if( p->readOnly==0 ) db->writeVdbeCnt++;
 
63527 p->pc = 0;
63528 }
63529 #ifndef SQLITE_OMIT_EXPLAIN
63530 if( p->explain ){
63531 rc = sqlite3VdbeList(p);
63532 }else
63533 #endif /* SQLITE_OMIT_EXPLAIN */
63534 {
63535 db->vdbeExecCnt++;
63536 rc = sqlite3VdbeExec(p);
63537 db->vdbeExecCnt--;
63538 }
63539
63540 #ifndef SQLITE_OMIT_TRACE
63541 /* Invoke the profile callback if there is one
63542 */
@@ -64469,13 +64493,13 @@
64469 return nTotal;
64470 }
64471
64472 /*
64473 ** This function returns a pointer to a nul-terminated string in memory
64474 ** obtained from sqlite3DbMalloc(). If sqlite3.vdbeExecCnt is 1, then the
64475 ** string contains a copy of zRawSql but with host parameters expanded to
64476 ** their current bindings. Or, if sqlite3.vdbeExecCnt is greater than 1,
64477 ** then the returned string holds a copy of zRawSql with "-- " prepended
64478 ** to each line of text.
64479 **
64480 ** If the SQLITE_TRACE_SIZE_LIMIT macro is defined to an integer, then
64481 ** then long strings and blobs are truncated to that many bytes. This
@@ -64509,11 +64533,11 @@
64509
64510 db = p->db;
64511 sqlite3StrAccumInit(&out, zBase, sizeof(zBase),
64512 db->aLimit[SQLITE_LIMIT_LENGTH]);
64513 out.db = db;
64514 if( db->vdbeExecCnt>1 ){
64515 while( *zRawSql ){
64516 const char *zStart = zRawSql;
64517 while( *(zRawSql++)!='\n' && *zRawSql );
64518 sqlite3StrAccumAppend(&out, "-- ", 3);
64519 sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart));
@@ -65815,10 +65839,11 @@
65815 /* This happens if a malloc() inside a call to sqlite3_column_text() or
65816 ** sqlite3_column_text16() failed. */
65817 goto no_mem;
65818 }
65819 assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY );
 
65820 p->rc = SQLITE_OK;
65821 assert( p->explain==0 );
65822 p->pResultSet = 0;
65823 db->busyHandler.nBusy = 0;
65824 CHECK_FOR_INTERRUPT;
@@ -67959,13 +67984,14 @@
67959 */
67960 assert( db->pSavepoint==0 || db->autoCommit==0 );
67961 assert( u.as.p1==SAVEPOINT_BEGIN||u.as.p1==SAVEPOINT_RELEASE||u.as.p1==SAVEPOINT_ROLLBACK );
67962 assert( db->pSavepoint || db->isTransactionSavepoint==0 );
67963 assert( checkSavepointCount(db) );
 
67964
67965 if( u.as.p1==SAVEPOINT_BEGIN ){
67966 if( db->writeVdbeCnt>0 ){
67967 /* A new savepoint cannot be created if there are active write
67968 ** statements (i.e. open read/write incremental blob handles).
67969 */
67970 sqlite3SetString(&p->zErrMsg, db, "cannot open savepoint - "
67971 "SQL statements in progress");
@@ -68018,11 +68044,11 @@
68018 u.as.iSavepoint++;
68019 }
68020 if( !u.as.pSavepoint ){
68021 sqlite3SetString(&p->zErrMsg, db, "no such savepoint: %s", u.as.zName);
68022 rc = SQLITE_ERROR;
68023 }else if( db->writeVdbeCnt>0 && u.as.p1==SAVEPOINT_RELEASE ){
68024 /* It is not possible to release (commit) a savepoint if there are
68025 ** active write statements.
68026 */
68027 sqlite3SetString(&p->zErrMsg, db,
68028 "cannot release savepoint - SQL statements in progress"
@@ -68121,24 +68147,25 @@
68121 u.at.desiredAutoCommit = pOp->p1;
68122 u.at.iRollback = pOp->p2;
68123 u.at.turnOnAC = u.at.desiredAutoCommit && !db->autoCommit;
68124 assert( u.at.desiredAutoCommit==1 || u.at.desiredAutoCommit==0 );
68125 assert( u.at.desiredAutoCommit==1 || u.at.iRollback==0 );
68126 assert( db->activeVdbeCnt>0 ); /* At least this one VM is active */
 
68127
68128 #if 0
68129 if( u.at.turnOnAC && u.at.iRollback && db->activeVdbeCnt>1 ){
68130 /* If this instruction implements a ROLLBACK and other VMs are
68131 ** still running, and a transaction is active, return an error indicating
68132 ** that the other VMs must complete first.
68133 */
68134 sqlite3SetString(&p->zErrMsg, db, "cannot rollback transaction - "
68135 "SQL statements in progress");
68136 rc = SQLITE_BUSY;
68137 }else
68138 #endif
68139 if( u.at.turnOnAC && !u.at.iRollback && db->writeVdbeCnt>0 ){
68140 /* If this instruction implements a COMMIT and other VMs are writing
68141 ** return an error indicating that the other VMs must complete first.
68142 */
68143 sqlite3SetString(&p->zErrMsg, db, "cannot commit transaction - "
68144 "SQL statements in progress");
@@ -68212,10 +68239,12 @@
68212 case OP_Transaction: {
68213 #if 0 /* local variables moved into u.au */
68214 Btree *pBt;
68215 #endif /* local variables moved into u.au */
68216
 
 
68217 assert( pOp->p1>=0 && pOp->p1<db->nDb );
68218 assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
68219 u.au.pBt = db->aDb[pOp->p1].pBt;
68220
68221 if( u.au.pBt ){
@@ -68228,11 +68257,11 @@
68228 if( rc!=SQLITE_OK ){
68229 goto abort_due_to_error;
68230 }
68231
68232 if( pOp->p2 && p->usesStmtJournal
68233 && (db->autoCommit==0 || db->activeVdbeCnt>1)
68234 ){
68235 assert( sqlite3BtreeIsInTrans(u.au.pBt) );
68236 if( p->iStatement==0 ){
68237 assert( db->nStatement>=0 && db->nSavepoint>=0 );
68238 db->nStatement++;
@@ -68270,10 +68299,11 @@
68270 int iMeta;
68271 int iDb;
68272 int iCookie;
68273 #endif /* local variables moved into u.av */
68274
 
68275 u.av.iDb = pOp->p1;
68276 u.av.iCookie = pOp->p3;
68277 assert( pOp->p3<SQLITE_N_BTREE_META );
68278 assert( u.av.iDb>=0 && u.av.iDb<db->nDb );
68279 assert( db->aDb[u.av.iDb].pBt!=0 );
@@ -68299,10 +68329,11 @@
68299 Db *pDb;
68300 #endif /* local variables moved into u.aw */
68301 assert( pOp->p2<SQLITE_N_BTREE_META );
68302 assert( pOp->p1>=0 && pOp->p1<db->nDb );
68303 assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
 
68304 u.aw.pDb = &db->aDb[pOp->p1];
68305 assert( u.aw.pDb->pBt!=0 );
68306 assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) );
68307 pIn3 = &aMem[pOp->p3];
68308 sqlite3VdbeMemIntegerify(pIn3);
@@ -68351,10 +68382,11 @@
68351 #endif /* local variables moved into u.ax */
68352
68353 assert( pOp->p1>=0 && pOp->p1<db->nDb );
68354 assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
68355 assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) );
 
68356 u.ax.pBt = db->aDb[pOp->p1].pBt;
68357 if( u.ax.pBt ){
68358 sqlite3BtreeGetMeta(u.ax.pBt, BTREE_SCHEMA_VERSION, (u32 *)&u.ax.iMeta);
68359 u.ax.iGen = db->aDb[pOp->p1].pSchema->iGeneration;
68360 }else{
@@ -68448,10 +68480,12 @@
68448 Db *pDb;
68449 #endif /* local variables moved into u.ay */
68450
68451 assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR))==pOp->p5 );
68452 assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 );
 
 
68453
68454 if( p->expired ){
68455 rc = SQLITE_ABORT;
68456 break;
68457 }
@@ -70066,19 +70100,22 @@
70066 int iCnt;
70067 Vdbe *pVdbe;
70068 int iDb;
70069 #endif /* local variables moved into u.bw */
70070
 
70071 #ifndef SQLITE_OMIT_VIRTUALTABLE
70072 u.bw.iCnt = 0;
70073 for(u.bw.pVdbe=db->pVdbe; u.bw.pVdbe; u.bw.pVdbe = u.bw.pVdbe->pNext){
70074 if( u.bw.pVdbe->magic==VDBE_MAGIC_RUN && u.bw.pVdbe->inVtabMethod<2 && u.bw.pVdbe->pc>=0 ){
 
 
70075 u.bw.iCnt++;
70076 }
70077 }
70078 #else
70079 u.bw.iCnt = db->activeVdbeCnt;
70080 #endif
70081 pOut->flags = MEM_Null;
70082 if( u.bw.iCnt>1 ){
70083 rc = SQLITE_LOCKED;
70084 p->errorAction = OE_Abort;
@@ -70123,10 +70160,11 @@
70123 #if 0 /* local variables moved into u.bx */
70124 int nChange;
70125 #endif /* local variables moved into u.bx */
70126
70127 u.bx.nChange = 0;
 
70128 assert( (p->btreeMask & (((yDbMask)1)<<pOp->p2))!=0 );
70129 rc = sqlite3BtreeClearTable(
70130 db->aDb[pOp->p2].pBt, pOp->p1, (pOp->p3 ? &u.bx.nChange : 0)
70131 );
70132 if( pOp->p3 ){
@@ -70171,10 +70209,11 @@
70171 #endif /* local variables moved into u.by */
70172
70173 u.by.pgno = 0;
70174 assert( pOp->p1>=0 && pOp->p1<db->nDb );
70175 assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
 
70176 u.by.pDb = &db->aDb[pOp->p1];
70177 assert( u.by.pDb->pBt!=0 );
70178 if( pOp->opcode==OP_CreateTable ){
70179 /* u.by.flags = BTREE_INTKEY; */
70180 u.by.flags = BTREE_INTKEY;
@@ -70323,10 +70362,11 @@
70323 int nErr; /* Number of errors reported */
70324 char *z; /* Text of the error report */
70325 Mem *pnErr; /* Register keeping track of errors remaining */
70326 #endif /* local variables moved into u.ca */
70327
 
70328 u.ca.nRoot = pOp->p2;
70329 assert( u.ca.nRoot>0 );
70330 u.ca.aRoot = sqlite3DbMallocRaw(db, sizeof(int)*(u.ca.nRoot+1) );
70331 if( u.ca.aRoot==0 ) goto no_mem;
70332 assert( pOp->p3>0 && pOp->p3<=p->nMem );
@@ -70844,10 +70884,11 @@
70844 int i; /* Loop counter */
70845 int aRes[3]; /* Results */
70846 Mem *pMem; /* Write results here */
70847 #endif /* local variables moved into u.ci */
70848
 
70849 u.ci.aRes[0] = 0;
70850 u.ci.aRes[1] = u.ci.aRes[2] = -1;
70851 assert( pOp->p2==SQLITE_CHECKPOINT_PASSIVE
70852 || pOp->p2==SQLITE_CHECKPOINT_FULL
70853 || pOp->p2==SQLITE_CHECKPOINT_RESTART
@@ -70895,10 +70936,11 @@
70895 || u.cj.eNew==PAGER_JOURNALMODE_MEMORY
70896 || u.cj.eNew==PAGER_JOURNALMODE_WAL
70897 || u.cj.eNew==PAGER_JOURNALMODE_QUERY
70898 );
70899 assert( pOp->p1>=0 && pOp->p1<db->nDb );
 
70900
70901 u.cj.pBt = db->aDb[pOp->p1].pBt;
70902 u.cj.pPager = sqlite3BtreePager(u.cj.pBt);
70903 u.cj.eOld = sqlite3PagerGetJournalMode(u.cj.pPager);
70904 if( u.cj.eNew==PAGER_JOURNALMODE_QUERY ) u.cj.eNew = u.cj.eOld;
@@ -70918,11 +70960,11 @@
70918 }
70919
70920 if( (u.cj.eNew!=u.cj.eOld)
70921 && (u.cj.eOld==PAGER_JOURNALMODE_WAL || u.cj.eNew==PAGER_JOURNALMODE_WAL)
70922 ){
70923 if( !db->autoCommit || db->activeVdbeCnt>1 ){
70924 rc = SQLITE_ERROR;
70925 sqlite3SetString(&p->zErrMsg, db,
70926 "cannot change %s wal mode from within a transaction",
70927 (u.cj.eNew==PAGER_JOURNALMODE_WAL ? "into" : "out of")
70928 );
@@ -70977,10 +71019,11 @@
70977 ** Vacuum the entire database. This opcode will cause other virtual
70978 ** machines to be created and run. It may not be called from within
70979 ** a transaction.
70980 */
70981 case OP_Vacuum: {
 
70982 rc = sqlite3RunVacuum(&p->zErrMsg, db);
70983 break;
70984 }
70985 #endif
70986
@@ -70996,10 +71039,11 @@
70996 Btree *pBt;
70997 #endif /* local variables moved into u.ck */
70998
70999 assert( pOp->p1>=0 && pOp->p1<db->nDb );
71000 assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
 
71001 u.ck.pBt = db->aDb[pOp->p1].pBt;
71002 rc = sqlite3BtreeIncrVacuum(u.ck.pBt);
71003 if( rc==SQLITE_DONE ){
71004 pc = pOp->p2 - 1;
71005 rc = SQLITE_OK;
@@ -71118,10 +71162,11 @@
71118 sqlite3_vtab_cursor *pVtabCursor;
71119 sqlite3_vtab *pVtab;
71120 sqlite3_module *pModule;
71121 #endif /* local variables moved into u.cm */
71122
 
71123 u.cm.pCur = 0;
71124 u.cm.pVtabCursor = 0;
71125 u.cm.pVtab = pOp->p4.pVtab->pVtab;
71126 u.cm.pModule = (sqlite3_module *)u.cm.pVtab->pModule;
71127 assert(u.cm.pVtab && u.cm.pModule);
@@ -71342,10 +71387,11 @@
71342
71343 u.cq.pVtab = pOp->p4.pVtab->pVtab;
71344 u.cq.pName = &aMem[pOp->p1];
71345 assert( u.cq.pVtab->pModule->xRename );
71346 assert( memIsValid(u.cq.pName) );
 
71347 REGISTER_TRACE(pOp->p1, u.cq.pName);
71348 assert( u.cq.pName->flags & MEM_Str );
71349 testcase( u.cq.pName->enc==SQLITE_UTF8 );
71350 testcase( u.cq.pName->enc==SQLITE_UTF16BE );
71351 testcase( u.cq.pName->enc==SQLITE_UTF16LE );
@@ -71395,10 +71441,11 @@
71395 #endif /* local variables moved into u.cr */
71396
71397 assert( pOp->p2==1 || pOp->p5==OE_Fail || pOp->p5==OE_Rollback
71398 || pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace
71399 );
 
71400 u.cr.pVtab = pOp->p4.pVtab->pVtab;
71401 u.cr.pModule = (sqlite3_module *)u.cr.pVtab->pModule;
71402 u.cr.nArg = pOp->p2;
71403 assert( pOp->p4type==P4_VTAB );
71404 if( ALWAYS(u.cr.pModule->xUpdate) ){
@@ -102957,11 +103004,11 @@
102957
102958 if( !db->autoCommit ){
102959 sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction");
102960 return SQLITE_ERROR;
102961 }
102962 if( db->activeVdbeCnt>1 ){
102963 sqlite3SetString(pzErrMsg, db,"cannot VACUUM - SQL statements in progress");
102964 return SQLITE_ERROR;
102965 }
102966
102967 /* Save the current value of the database flags so that it can be
@@ -104742,11 +104789,11 @@
104742 #define WHERE_INDEXED 0x00000200 /* WhereLoop.u.btree.pIndex is valid */
104743 #define WHERE_VIRTUALTABLE 0x00000400 /* WhereLoop.u.vtab is valid */
104744 #define WHERE_IN_ABLE 0x00000800 /* Able to support an IN operator */
104745 #define WHERE_ONEROW 0x00001000 /* Selects no more than one row */
104746 #define WHERE_MULTI_OR 0x00002000 /* OR using multiple indices */
104747 #define WHERE_TEMP_INDEX 0x00004000 /* Uses an ephemeral index */
104748
104749
104750 /* Convert a WhereCost value (10 times log2(X)) into its integer value X.
104751 ** A rough approximation is used. The value returned is not exact.
104752 */
@@ -106036,10 +106083,11 @@
106036 ** the start of the loop will prevent any results from being returned.
106037 */
106038 if( pExpr->op==TK_NOTNULL
106039 && pExpr->pLeft->op==TK_COLUMN
106040 && pExpr->pLeft->iColumn>=0
 
106041 ){
106042 Expr *pNewExpr;
106043 Expr *pLeft = pExpr->pLeft;
106044 int idxNew;
106045 WhereTerm *pNewTerm;
@@ -106339,10 +106387,11 @@
106339 int mxBitCol; /* Maximum column in pSrc->colUsed */
106340 CollSeq *pColl; /* Collating sequence to on a column */
106341 WhereLoop *pLoop; /* The Loop object */
106342 Bitmask idxCols; /* Bitmap of columns used for indexing */
106343 Bitmask extraCols; /* Bitmap of additional columns */
 
106344
106345 /* Generate code to skip over the creation and initialization of the
106346 ** transient index on 2nd and subsequent iterations of the loop. */
106347 v = pParse->pVdbe;
106348 assert( v!=0 );
@@ -106359,10 +106408,16 @@
106359 if( termCanDriveIndex(pTerm, pSrc, notReady) ){
106360 int iCol = pTerm->u.leftColumn;
106361 Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);
106362 testcase( iCol==BMS );
106363 testcase( iCol==BMS-1 );
 
 
 
 
 
 
106364 if( (idxCols & cMask)==0 ){
106365 if( whereLoopResize(pParse->db, pLoop, nColumn+1) ) return;
106366 pLoop->aLTerm[nColumn++] = pTerm;
106367 idxCols |= cMask;
106368 }
@@ -106369,11 +106424,11 @@
106369 }
106370 }
106371 assert( nColumn>0 );
106372 pLoop->u.btree.nEq = pLoop->nLTerm = nColumn;
106373 pLoop->wsFlags = WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WHERE_INDEXED
106374 | WHERE_TEMP_INDEX;
106375
106376 /* Count the number of additional columns needed to create a
106377 ** covering index. A "covering index" is an index that contains all
106378 ** columns that are needed by the query. With a covering index, the
106379 ** original table never needs to be accessed. Automatic indices must
@@ -106869,11 +106924,11 @@
106869 ){
106870 int rc = SQLITE_OK;
106871
106872 #ifdef SQLITE_ENABLE_STAT3
106873
106874 if( nEq==0 && p->nSample ){
106875 sqlite3_value *pRangeVal;
106876 tRowcnt iLower = 0;
106877 tRowcnt iUpper = p->aiRowEst[0];
106878 tRowcnt a[2];
106879 u8 aff = p->pTable->aCol[p->aiColumn[0]].affinity;
@@ -107415,17 +107470,16 @@
107415 }
107416 if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0
107417 && ALWAYS(pLoop->u.btree.pIndex!=0)
107418 ){
107419 char *zWhere = explainIndexRange(db, pLoop, pItem->pTab);
107420 zMsg = sqlite3MAppendf(db, zMsg, "%s USING %s%sINDEX%s%s%s", zMsg,
107421 ((flags & WHERE_TEMP_INDEX)?"AUTOMATIC ":""),
107422 ((flags & WHERE_IDX_ONLY)?"COVERING ":""),
107423 ((flags & WHERE_TEMP_INDEX)?"":" "),
107424 ((flags & WHERE_TEMP_INDEX)?"": pLoop->u.btree.pIndex->zName),
107425 zWhere
107426 );
107427 sqlite3DbFree(db, zWhere);
107428 }else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){
107429 zMsg = sqlite3MAppendf(db, zMsg, "%s USING INTEGER PRIMARY KEY", zMsg);
107430
107431 if( flags&(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) ){
@@ -108092,11 +108146,11 @@
108092 ** terms, set pCov to the candidate covering index. Otherwise, set
108093 ** pCov to NULL to indicate that no candidate covering index will
108094 ** be available.
108095 */
108096 pSubLoop = pSubWInfo->a[0].pWLoop;
108097 assert( (pSubLoop->wsFlags & WHERE_TEMP_INDEX)==0 );
108098 if( (pSubLoop->wsFlags & WHERE_INDEXED)!=0
108099 && (ii==0 || pSubLoop->u.btree.pIndex==pCov)
108100 ){
108101 assert( pSubWInfo->a[0].iIdxCur==iCovCur );
108102 pCov = pSubLoop->u.btree.pIndex;
@@ -108274,16 +108328,16 @@
108274
108275 /*
108276 ** Clear the WhereLoop.u union. Leave WhereLoop.pLTerm intact.
108277 */
108278 static void whereLoopClearUnion(sqlite3 *db, WhereLoop *p){
108279 if( p->wsFlags & (WHERE_VIRTUALTABLE|WHERE_TEMP_INDEX) ){
108280 if( (p->wsFlags & WHERE_VIRTUALTABLE)!=0 && p->u.vtab.needFree ){
108281 sqlite3_free(p->u.vtab.idxStr);
108282 p->u.vtab.needFree = 0;
108283 p->u.vtab.idxStr = 0;
108284 }else if( (p->wsFlags & WHERE_TEMP_INDEX)!=0 && p->u.btree.pIndex!=0 ){
108285 sqlite3DbFree(db, p->u.btree.pIndex->zColAff);
108286 sqlite3DbFree(db, p->u.btree.pIndex);
108287 p->u.btree.pIndex = 0;
108288 }
108289 }
@@ -108322,11 +108376,11 @@
108322 whereLoopClearUnion(db, pTo);
108323 memcpy(pTo, pFrom, WHERE_LOOP_XFER_SZ);
108324 memcpy(pTo->aLTerm, pFrom->aLTerm, pTo->nLTerm*sizeof(pTo->aLTerm[0]));
108325 if( pFrom->wsFlags & WHERE_VIRTUALTABLE ){
108326 pFrom->u.vtab.needFree = 0;
108327 }else if( (pFrom->wsFlags & WHERE_TEMP_INDEX)!=0 ){
108328 pFrom->u.btree.pIndex = 0;
108329 }
108330 return SQLITE_OK;
108331 }
108332
@@ -108634,11 +108688,12 @@
108634 whereRangeScanEst(pParse, pProbe, pNew->u.btree.nEq,
108635 pBtm, pTop, &rDiv);
108636 pNew->nOut = saved_nOut>rDiv+10 ? saved_nOut - rDiv : 10;
108637 }
108638 #ifdef SQLITE_ENABLE_STAT3
108639 if( pNew->u.btree.nEq==1 && pProbe->nSample ){
 
108640 tRowcnt nOut = 0;
108641 if( (pTerm->eOperator & (WO_EQ|WO_ISNULL))!=0 ){
108642 testcase( pTerm->eOperator & WO_EQ );
108643 testcase( pTerm->eOperator & WO_ISNULL );
108644 rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut);
@@ -108794,17 +108849,20 @@
108794 pNew->u.btree.nEq = 1;
108795 pNew->u.btree.pIndex = 0;
108796 pNew->nLTerm = 1;
108797 pNew->aLTerm[0] = pTerm;
108798 /* TUNING: One-time cost for computing the automatic index is
108799 ** approximately 6*N*log2(N) where N is the number of rows in
108800 ** the table being indexed. */
108801 pNew->rSetup = rLogSize + rSize + 26; assert( 26==whereCost(6) );
108802 /* TUNING: Each index lookup yields 10 rows in the table */
108803 pNew->nOut = 33; assert( 33==whereCost(10) );
 
 
 
108804 pNew->rRun = whereCostAdd(rLogSize,pNew->nOut);
108805 pNew->wsFlags = WHERE_TEMP_INDEX;
108806 pNew->prereq = mExtra | pTerm->prereqRight;
108807 rc = whereLoopInsert(pBuilder, pNew);
108808 }
108809 }
108810 }
@@ -110094,18 +110152,28 @@
110094 && OptimizationEnabled(db, SQLITE_OmitNoopJoin)
110095 ){
110096 Bitmask tabUsed = exprListTableUsage(pMaskSet, pResultSet);
110097 if( pOrderBy ) tabUsed |= exprListTableUsage(pMaskSet, pOrderBy);
110098 while( pWInfo->nLevel>=2 ){
 
110099 pLoop = pWInfo->a[pWInfo->nLevel-1].pWLoop;
110100 if( (pWInfo->pTabList->a[pLoop->iTab].jointype & JT_LEFT)==0 ) break;
110101 if( (wctrlFlags & WHERE_WANT_DISTINCT)==0
110102 && (pLoop->wsFlags & WHERE_ONEROW)==0
110103 ){
110104 break;
110105 }
110106 if( (tabUsed & pLoop->maskSelf)!=0 ) break;
 
 
 
 
 
 
 
 
 
110107 WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId));
110108 pWInfo->nLevel--;
110109 nTabList--;
110110 }
110111 }
@@ -110167,11 +110235,11 @@
110167 }
110168 }else{
110169 sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
110170 }
110171 #ifndef SQLITE_OMIT_AUTOMATIC_INDEX
110172 if( (pLoop->wsFlags & WHERE_TEMP_INDEX)!=0 ){
110173 constructAutomaticIndex(pParse, &pWInfo->sWC, pTabItem, notReady, pLevel);
110174 }else
110175 #endif
110176 if( pLoop->wsFlags & WHERE_INDEXED ){
110177 Index *pIx = pLoop->u.btree.pIndex;
@@ -110290,11 +110358,11 @@
110290 ){
110291 int ws = pLoop->wsFlags;
110292 if( !pWInfo->okOnePass && (ws & WHERE_IDX_ONLY)==0 ){
110293 sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
110294 }
110295 if( (ws & WHERE_INDEXED)!=0 && (ws & (WHERE_IPK|WHERE_TEMP_INDEX))==0 ){
110296 sqlite3VdbeAddOp1(v, OP_Close, pLevel->iIdxCur);
110297 }
110298 }
110299
110300 /* If this scan uses an index, make VDBE code substitutions to read data
@@ -114501,11 +114569,11 @@
114501 sqlite3 *db = pParse->db; /* The database connection */
114502 int mxSqlLen; /* Max length of an SQL string */
114503
114504
114505 mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
114506 if( db->activeVdbeCnt==0 ){
114507 db->u1.isInterrupted = 0;
114508 }
114509 pParse->rc = SQLITE_OK;
114510 pParse->zTail = zSql;
114511 i = 0;
@@ -116069,10 +116137,11 @@
116069 case SQLITE_PERM: zName = "SQLITE_PERM"; break;
116070 case SQLITE_ABORT: zName = "SQLITE_ABORT"; break;
116071 case SQLITE_ABORT_ROLLBACK: zName = "SQLITE_ABORT_ROLLBACK"; break;
116072 case SQLITE_BUSY: zName = "SQLITE_BUSY"; break;
116073 case SQLITE_BUSY_RECOVERY: zName = "SQLITE_BUSY_RECOVERY"; break;
 
116074 case SQLITE_LOCKED: zName = "SQLITE_LOCKED"; break;
116075 case SQLITE_LOCKED_SHAREDCACHE: zName = "SQLITE_LOCKED_SHAREDCACHE";break;
116076 case SQLITE_NOMEM: zName = "SQLITE_NOMEM"; break;
116077 case SQLITE_READONLY: zName = "SQLITE_READONLY"; break;
116078 case SQLITE_READONLY_RECOVERY: zName = "SQLITE_READONLY_RECOVERY"; break;
@@ -116142,10 +116211,11 @@
116142 case SQLITE_NOTICE: zName = "SQLITE_NOTICE"; break;
116143 case SQLITE_NOTICE_RECOVER_WAL: zName = "SQLITE_NOTICE_RECOVER_WAL";break;
116144 case SQLITE_NOTICE_RECOVER_ROLLBACK:
116145 zName = "SQLITE_NOTICE_RECOVER_ROLLBACK"; break;
116146 case SQLITE_WARNING: zName = "SQLITE_WARNING"; break;
 
116147 case SQLITE_DONE: zName = "SQLITE_DONE"; break;
116148 }
116149 }
116150 if( zName==0 ){
116151 static char zBuf[50];
@@ -116400,11 +116470,11 @@
116400 ** is being overridden/deleted but there are no active VMs, allow the
116401 ** operation to continue but invalidate all precompiled statements.
116402 */
116403 p = sqlite3FindFunction(db, zFunctionName, nName, nArg, (u8)enc, 0);
116404 if( p && p->iPrefEnc==enc && p->nArg==nArg ){
116405 if( db->activeVdbeCnt ){
116406 sqlite3Error(db, SQLITE_BUSY,
116407 "unable to delete/modify user-function due to active statements");
116408 assert( !db->mallocFailed );
116409 return SQLITE_BUSY;
116410 }else{
@@ -116981,11 +117051,11 @@
116981 ** sequence. If so, and there are active VMs, return busy. If there
116982 ** are no active VMs, invalidate any pre-compiled statements.
116983 */
116984 pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 0);
116985 if( pColl && pColl->xCmp ){
116986 if( db->activeVdbeCnt ){
116987 sqlite3Error(db, SQLITE_BUSY,
116988 "unable to delete/modify collation sequence due to active statements");
116989 return SQLITE_BUSY;
116990 }
116991 sqlite3ExpirePreparedStatements(db);
@@ -117456,11 +117526,14 @@
117456 memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
117457 db->autoCommit = 1;
117458 db->nextAutovac = -1;
117459 db->szMmap = sqlite3GlobalConfig.szMmap;
117460 db->nextPagesize = 0;
117461 db->flags |= SQLITE_ShortColNames | SQLITE_AutoIndex | SQLITE_EnableTrigger
 
 
 
117462 #if SQLITE_DEFAULT_FILE_FORMAT<4
117463 | SQLITE_LegacyFileFmt
117464 #endif
117465 #ifdef SQLITE_ENABLE_LOAD_EXTENSION
117466 | SQLITE_LoadExtension
117467
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -670,11 +670,11 @@
670 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671 ** [sqlite_version()] and [sqlite_source_id()].
672 */
673 #define SQLITE_VERSION "3.8.0"
674 #define SQLITE_VERSION_NUMBER 3008000
675 #define SQLITE_SOURCE_ID "2013-06-28 23:55:45 338826ef3f8a209b14f8d42370855cab9ac9ed45"
676
677 /*
678 ** CAPI3REF: Run-Time Library Version Numbers
679 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
680 **
@@ -1041,10 +1041,11 @@
1041 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1042 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1043 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1044 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1045 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1046 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1047 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1048 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
1049 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
1050 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
1051 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
@@ -1060,10 +1061,11 @@
1061 #define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8))
1062 #define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8))
1063 #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8))
1064 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
1065 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
1066 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
1067
1068 /*
1069 ** CAPI3REF: Flags For File Open Operations
1070 **
1071 ** These bit values are intended for use in the
@@ -10076,13 +10078,14 @@
10078 int newTnum; /* Rootpage of table being initialized */
10079 u8 iDb; /* Which db file is being initialized */
10080 u8 busy; /* TRUE if currently initializing */
10081 u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */
10082 } init;
10083 int nVdbeActive; /* Number of VDBEs currently running */
10084 int nVdbeRead; /* Number of active VDBEs that read or write */
10085 int nVdbeWrite; /* Number of active VDBEs that read and write */
10086 int nVdbeExec; /* Number of nested calls to VdbeExec() */
10087 int nExtension; /* Number of loaded extensions */
10088 void **aExtension; /* Array of shared library handles */
10089 void (*xTrace)(void*,const char*); /* Trace function */
10090 void *pTraceArg; /* Argument to the trace function */
10091 void (*xProfile)(void*,const char*,u64); /* Profiling function */
@@ -10204,10 +10207,11 @@
10207 #define SQLITE_CoverIdxScan 0x0040 /* Covering index scans */
10208 #define SQLITE_OrderByIdxJoin 0x0080 /* ORDER BY of joins via index */
10209 #define SQLITE_SubqCoroutine 0x0100 /* Evaluate subqueries as coroutines */
10210 #define SQLITE_Transitive 0x0200 /* Transitive constraints */
10211 #define SQLITE_OmitNoopJoin 0x0400 /* Omit unused tables in joins */
10212 #define SQLITE_Stat3 0x0800 /* Use the SQLITE_STAT3 table */
10213 #define SQLITE_AllOpts 0xffff /* All optimizations */
10214
10215 /*
10216 ** Macros for testing whether or not optimizations are enabled or disabled.
10217 */
@@ -13512,11 +13516,12 @@
13516 bft inVtabMethod:2; /* See comments above */
13517 bft changeCntOn:1; /* True to update the change-counter */
13518 bft expired:1; /* True if the VM needs to be recompiled */
13519 bft runOnlyOnce:1; /* Automatically expire on reset */
13520 bft usesStmtJournal:1; /* True if uses a statement journal */
13521 bft readOnly:1; /* True for statements that do not write */
13522 bft bIsReader:1; /* True for statements that read */
13523 bft isPrepareV2:1; /* True if prepared with prepare_v2() */
13524 bft doingRerun:1; /* True if rerunning after an auto-reprepare */
13525 int nChange; /* Number of db changes made since last reset */
13526 yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
13527 yDbMask lockMask; /* Subset of btreeMask that requires a lock */
@@ -47891,11 +47896,11 @@
47896 ** the write is disallowed.
47897 */
47898 if( memcmp(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr))!=0 ){
47899 walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);
47900 pWal->writeLock = 0;
47901 rc = SQLITE_BUSY_SNAPSHOT;
47902 }
47903
47904 return rc;
47905 }
47906
@@ -52751,16 +52756,17 @@
52756 ** This function is called from both BtreeCommitPhaseTwo() and BtreeRollback()
52757 ** at the conclusion of a transaction.
52758 */
52759 static void btreeEndTransaction(Btree *p){
52760 BtShared *pBt = p->pBt;
52761 sqlite3 *db = p->db;
52762 assert( sqlite3BtreeHoldsMutex(p) );
52763
52764 #ifndef SQLITE_OMIT_AUTOVACUUM
52765 pBt->bDoTruncate = 0;
52766 #endif
52767 if( p->inTrans>TRANS_NONE && db->nVdbeRead>1 ){
52768 /* If there are other active statements that belong to this database
52769 ** handle, downgrade to a read-only transaction. The other statements
52770 ** may still be reading from the database. */
52771 downgradeAllSharedCacheTableLocks(p);
52772 p->inTrans = TRANS_READ;
@@ -60277,18 +60283,30 @@
60283 int i;
60284 int nMaxArgs = *pMaxFuncArgs;
60285 Op *pOp;
60286 int *aLabel = p->aLabel;
60287 p->readOnly = 1;
60288 p->bIsReader = 0;
60289 for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
60290 u8 opcode = pOp->opcode;
60291
60292 pOp->opflags = sqlite3OpcodeProperty[opcode];
60293 if( opcode==OP_Function || opcode==OP_AggStep ){
60294 if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;
60295 }else if( opcode==OP_Transaction ){
60296 if( pOp->p2!=0 ) p->readOnly = 0;
60297 p->bIsReader = 1;
60298 }else if( opcode==OP_AutoCommit || opcode==OP_Savepoint ){
60299 p->bIsReader = 1;
60300 }else if( opcode==OP_Vacuum
60301 || opcode==OP_JournalMode
60302 #ifndef SQLITE_OMIT_VIRTUALTABLE
60303 || opcode==OP_Checkpoint
60304 #endif
60305 ){
60306 p->readOnly = 0;
60307 p->bIsReader = 1;
60308 #ifndef SQLITE_OMIT_VIRTUALTABLE
60309 }else if( opcode==OP_VUpdate ){
60310 if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
60311 }else if( opcode==OP_VFilter ){
60312 int n;
@@ -60310,12 +60328,12 @@
60328 pOp->p2 = aLabel[-1-pOp->p2];
60329 }
60330 }
60331 sqlite3DbFree(p->db, p->aLabel);
60332 p->aLabel = 0;
 
60333 *pMaxFuncArgs = nMaxArgs;
60334 assert( p->bIsReader!=0 || p->btreeMask==0 );
60335 }
60336
60337 /*
60338 ** Return the address of the next instruction to be inserted.
60339 */
@@ -61837,11 +61855,11 @@
61855
61856 return rc;
61857 }
61858
61859 /*
61860 ** This routine checks that the sqlite3.nVdbeActive count variable
61861 ** matches the number of vdbe's in the list sqlite3.pVdbe that are
61862 ** currently active. An assertion fails if the two counts do not match.
61863 ** This is an internal self-check only - it is not an essential processing
61864 ** step.
61865 **
@@ -61850,20 +61868,23 @@
61868 #ifndef NDEBUG
61869 static void checkActiveVdbeCnt(sqlite3 *db){
61870 Vdbe *p;
61871 int cnt = 0;
61872 int nWrite = 0;
61873 int nRead = 0;
61874 p = db->pVdbe;
61875 while( p ){
61876 if( p->magic==VDBE_MAGIC_RUN && p->pc>=0 ){
61877 cnt++;
61878 if( p->readOnly==0 ) nWrite++;
61879 if( p->bIsReader ) nRead++;
61880 }
61881 p = p->pNext;
61882 }
61883 assert( cnt==db->nVdbeActive );
61884 assert( nWrite==db->nVdbeWrite );
61885 assert( nRead==db->nVdbeRead );
61886 }
61887 #else
61888 #define checkActiveVdbeCnt(x)
61889 #endif
61890
@@ -61995,12 +62016,13 @@
62016 if( p->magic!=VDBE_MAGIC_RUN ){
62017 return SQLITE_OK;
62018 }
62019 checkActiveVdbeCnt(db);
62020
62021 /* No commit or rollback needed if the program never started or if the
62022 ** SQL statement does not read or write a database file. */
62023 if( p->pc>=0 && p->bIsReader ){
62024 int mrc; /* Primary error code from p->rc */
62025 int eStatementOp = 0;
62026 int isSpecialError; /* Set to true if a 'special' error */
62027
62028 /* Lock all btrees used by the statement */
@@ -62049,11 +62071,11 @@
62071 ** Note: This block also runs if one of the special errors handled
62072 ** above has occurred.
62073 */
62074 if( !sqlite3VtabInSync(db)
62075 && db->autoCommit
62076 && db->nVdbeWrite==(p->readOnly==0)
62077 ){
62078 if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
62079 rc = sqlite3VdbeCheckFk(p, 1);
62080 if( rc!=SQLITE_OK ){
62081 if( NEVER(p->readOnly) ){
@@ -62130,15 +62152,16 @@
62152 sqlite3VdbeLeave(p);
62153 }
62154
62155 /* We have successfully halted and closed the VM. Record this fact. */
62156 if( p->pc>=0 ){
62157 db->nVdbeActive--;
62158 if( !p->readOnly ) db->nVdbeWrite--;
62159 if( p->bIsReader ) db->nVdbeRead--;
62160 assert( db->nVdbeActive>=db->nVdbeRead );
62161 assert( db->nVdbeRead>=db->nVdbeWrite );
62162 assert( db->nVdbeWrite>=0 );
62163 }
62164 p->magic = VDBE_MAGIC_HALT;
62165 checkActiveVdbeCnt(db);
62166 if( p->db->mallocFailed ){
62167 p->rc = SQLITE_NOMEM;
@@ -62150,11 +62173,11 @@
62173 */
62174 if( db->autoCommit ){
62175 sqlite3ConnectionUnlocked(db);
62176 }
62177
62178 assert( db->nVdbeActive>0 || db->autoCommit==0 || db->nStatement==0 );
62179 return (p->rc==SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK);
62180 }
62181
62182
62183 /*
@@ -63508,35 +63531,36 @@
63531 if( p->pc<0 ){
63532 /* If there are no other statements currently running, then
63533 ** reset the interrupt flag. This prevents a call to sqlite3_interrupt
63534 ** from interrupting a statement that has not yet started.
63535 */
63536 if( db->nVdbeActive==0 ){
63537 db->u1.isInterrupted = 0;
63538 }
63539
63540 assert( db->nVdbeWrite>0 || db->autoCommit==0 || db->nDeferredCons==0 );
63541
63542 #ifndef SQLITE_OMIT_TRACE
63543 if( db->xProfile && !db->init.busy ){
63544 sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
63545 }
63546 #endif
63547
63548 db->nVdbeActive++;
63549 if( p->readOnly==0 ) db->nVdbeWrite++;
63550 if( p->bIsReader ) db->nVdbeRead++;
63551 p->pc = 0;
63552 }
63553 #ifndef SQLITE_OMIT_EXPLAIN
63554 if( p->explain ){
63555 rc = sqlite3VdbeList(p);
63556 }else
63557 #endif /* SQLITE_OMIT_EXPLAIN */
63558 {
63559 db->nVdbeExec++;
63560 rc = sqlite3VdbeExec(p);
63561 db->nVdbeExec--;
63562 }
63563
63564 #ifndef SQLITE_OMIT_TRACE
63565 /* Invoke the profile callback if there is one
63566 */
@@ -64469,13 +64493,13 @@
64493 return nTotal;
64494 }
64495
64496 /*
64497 ** This function returns a pointer to a nul-terminated string in memory
64498 ** obtained from sqlite3DbMalloc(). If sqlite3.nVdbeExec is 1, then the
64499 ** string contains a copy of zRawSql but with host parameters expanded to
64500 ** their current bindings. Or, if sqlite3.nVdbeExec is greater than 1,
64501 ** then the returned string holds a copy of zRawSql with "-- " prepended
64502 ** to each line of text.
64503 **
64504 ** If the SQLITE_TRACE_SIZE_LIMIT macro is defined to an integer, then
64505 ** then long strings and blobs are truncated to that many bytes. This
@@ -64509,11 +64533,11 @@
64533
64534 db = p->db;
64535 sqlite3StrAccumInit(&out, zBase, sizeof(zBase),
64536 db->aLimit[SQLITE_LIMIT_LENGTH]);
64537 out.db = db;
64538 if( db->nVdbeExec>1 ){
64539 while( *zRawSql ){
64540 const char *zStart = zRawSql;
64541 while( *(zRawSql++)!='\n' && *zRawSql );
64542 sqlite3StrAccumAppend(&out, "-- ", 3);
64543 sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart));
@@ -65815,10 +65839,11 @@
65839 /* This happens if a malloc() inside a call to sqlite3_column_text() or
65840 ** sqlite3_column_text16() failed. */
65841 goto no_mem;
65842 }
65843 assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY );
65844 assert( p->bIsReader || p->readOnly!=0 );
65845 p->rc = SQLITE_OK;
65846 assert( p->explain==0 );
65847 p->pResultSet = 0;
65848 db->busyHandler.nBusy = 0;
65849 CHECK_FOR_INTERRUPT;
@@ -67959,13 +67984,14 @@
67984 */
67985 assert( db->pSavepoint==0 || db->autoCommit==0 );
67986 assert( u.as.p1==SAVEPOINT_BEGIN||u.as.p1==SAVEPOINT_RELEASE||u.as.p1==SAVEPOINT_ROLLBACK );
67987 assert( db->pSavepoint || db->isTransactionSavepoint==0 );
67988 assert( checkSavepointCount(db) );
67989 assert( p->bIsReader );
67990
67991 if( u.as.p1==SAVEPOINT_BEGIN ){
67992 if( db->nVdbeWrite>0 ){
67993 /* A new savepoint cannot be created if there are active write
67994 ** statements (i.e. open read/write incremental blob handles).
67995 */
67996 sqlite3SetString(&p->zErrMsg, db, "cannot open savepoint - "
67997 "SQL statements in progress");
@@ -68018,11 +68044,11 @@
68044 u.as.iSavepoint++;
68045 }
68046 if( !u.as.pSavepoint ){
68047 sqlite3SetString(&p->zErrMsg, db, "no such savepoint: %s", u.as.zName);
68048 rc = SQLITE_ERROR;
68049 }else if( db->nVdbeWrite>0 && u.as.p1==SAVEPOINT_RELEASE ){
68050 /* It is not possible to release (commit) a savepoint if there are
68051 ** active write statements.
68052 */
68053 sqlite3SetString(&p->zErrMsg, db,
68054 "cannot release savepoint - SQL statements in progress"
@@ -68121,24 +68147,25 @@
68147 u.at.desiredAutoCommit = pOp->p1;
68148 u.at.iRollback = pOp->p2;
68149 u.at.turnOnAC = u.at.desiredAutoCommit && !db->autoCommit;
68150 assert( u.at.desiredAutoCommit==1 || u.at.desiredAutoCommit==0 );
68151 assert( u.at.desiredAutoCommit==1 || u.at.iRollback==0 );
68152 assert( db->nVdbeActive>0 ); /* At least this one VM is active */
68153 assert( p->bIsReader );
68154
68155 #if 0
68156 if( u.at.turnOnAC && u.at.iRollback && db->nVdbeActive>1 ){
68157 /* If this instruction implements a ROLLBACK and other VMs are
68158 ** still running, and a transaction is active, return an error indicating
68159 ** that the other VMs must complete first.
68160 */
68161 sqlite3SetString(&p->zErrMsg, db, "cannot rollback transaction - "
68162 "SQL statements in progress");
68163 rc = SQLITE_BUSY;
68164 }else
68165 #endif
68166 if( u.at.turnOnAC && !u.at.iRollback && db->nVdbeWrite>0 ){
68167 /* If this instruction implements a COMMIT and other VMs are writing
68168 ** return an error indicating that the other VMs must complete first.
68169 */
68170 sqlite3SetString(&p->zErrMsg, db, "cannot commit transaction - "
68171 "SQL statements in progress");
@@ -68212,10 +68239,12 @@
68239 case OP_Transaction: {
68240 #if 0 /* local variables moved into u.au */
68241 Btree *pBt;
68242 #endif /* local variables moved into u.au */
68243
68244 assert( p->bIsReader );
68245 assert( p->readOnly==0 || pOp->p2==0 );
68246 assert( pOp->p1>=0 && pOp->p1<db->nDb );
68247 assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
68248 u.au.pBt = db->aDb[pOp->p1].pBt;
68249
68250 if( u.au.pBt ){
@@ -68228,11 +68257,11 @@
68257 if( rc!=SQLITE_OK ){
68258 goto abort_due_to_error;
68259 }
68260
68261 if( pOp->p2 && p->usesStmtJournal
68262 && (db->autoCommit==0 || db->nVdbeRead>1)
68263 ){
68264 assert( sqlite3BtreeIsInTrans(u.au.pBt) );
68265 if( p->iStatement==0 ){
68266 assert( db->nStatement>=0 && db->nSavepoint>=0 );
68267 db->nStatement++;
@@ -68270,10 +68299,11 @@
68299 int iMeta;
68300 int iDb;
68301 int iCookie;
68302 #endif /* local variables moved into u.av */
68303
68304 assert( p->bIsReader );
68305 u.av.iDb = pOp->p1;
68306 u.av.iCookie = pOp->p3;
68307 assert( pOp->p3<SQLITE_N_BTREE_META );
68308 assert( u.av.iDb>=0 && u.av.iDb<db->nDb );
68309 assert( db->aDb[u.av.iDb].pBt!=0 );
@@ -68299,10 +68329,11 @@
68329 Db *pDb;
68330 #endif /* local variables moved into u.aw */
68331 assert( pOp->p2<SQLITE_N_BTREE_META );
68332 assert( pOp->p1>=0 && pOp->p1<db->nDb );
68333 assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
68334 assert( p->readOnly==0 );
68335 u.aw.pDb = &db->aDb[pOp->p1];
68336 assert( u.aw.pDb->pBt!=0 );
68337 assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) );
68338 pIn3 = &aMem[pOp->p3];
68339 sqlite3VdbeMemIntegerify(pIn3);
@@ -68351,10 +68382,11 @@
68382 #endif /* local variables moved into u.ax */
68383
68384 assert( pOp->p1>=0 && pOp->p1<db->nDb );
68385 assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
68386 assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) );
68387 assert( p->bIsReader );
68388 u.ax.pBt = db->aDb[pOp->p1].pBt;
68389 if( u.ax.pBt ){
68390 sqlite3BtreeGetMeta(u.ax.pBt, BTREE_SCHEMA_VERSION, (u32 *)&u.ax.iMeta);
68391 u.ax.iGen = db->aDb[pOp->p1].pSchema->iGeneration;
68392 }else{
@@ -68448,10 +68480,12 @@
68480 Db *pDb;
68481 #endif /* local variables moved into u.ay */
68482
68483 assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR))==pOp->p5 );
68484 assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 );
68485 assert( p->bIsReader );
68486 assert( pOp->opcode==OP_OpenRead || p->readOnly==0 );
68487
68488 if( p->expired ){
68489 rc = SQLITE_ABORT;
68490 break;
68491 }
@@ -70066,19 +70100,22 @@
70100 int iCnt;
70101 Vdbe *pVdbe;
70102 int iDb;
70103 #endif /* local variables moved into u.bw */
70104
70105 assert( p->readOnly==0 );
70106 #ifndef SQLITE_OMIT_VIRTUALTABLE
70107 u.bw.iCnt = 0;
70108 for(u.bw.pVdbe=db->pVdbe; u.bw.pVdbe; u.bw.pVdbe = u.bw.pVdbe->pNext){
70109 if( u.bw.pVdbe->magic==VDBE_MAGIC_RUN && u.bw.pVdbe->bIsReader
70110 && u.bw.pVdbe->inVtabMethod<2 && u.bw.pVdbe->pc>=0
70111 ){
70112 u.bw.iCnt++;
70113 }
70114 }
70115 #else
70116 u.bw.iCnt = db->nVdbeRead;
70117 #endif
70118 pOut->flags = MEM_Null;
70119 if( u.bw.iCnt>1 ){
70120 rc = SQLITE_LOCKED;
70121 p->errorAction = OE_Abort;
@@ -70123,10 +70160,11 @@
70160 #if 0 /* local variables moved into u.bx */
70161 int nChange;
70162 #endif /* local variables moved into u.bx */
70163
70164 u.bx.nChange = 0;
70165 assert( p->readOnly==0 );
70166 assert( (p->btreeMask & (((yDbMask)1)<<pOp->p2))!=0 );
70167 rc = sqlite3BtreeClearTable(
70168 db->aDb[pOp->p2].pBt, pOp->p1, (pOp->p3 ? &u.bx.nChange : 0)
70169 );
70170 if( pOp->p3 ){
@@ -70171,10 +70209,11 @@
70209 #endif /* local variables moved into u.by */
70210
70211 u.by.pgno = 0;
70212 assert( pOp->p1>=0 && pOp->p1<db->nDb );
70213 assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
70214 assert( p->readOnly==0 );
70215 u.by.pDb = &db->aDb[pOp->p1];
70216 assert( u.by.pDb->pBt!=0 );
70217 if( pOp->opcode==OP_CreateTable ){
70218 /* u.by.flags = BTREE_INTKEY; */
70219 u.by.flags = BTREE_INTKEY;
@@ -70323,10 +70362,11 @@
70362 int nErr; /* Number of errors reported */
70363 char *z; /* Text of the error report */
70364 Mem *pnErr; /* Register keeping track of errors remaining */
70365 #endif /* local variables moved into u.ca */
70366
70367 assert( p->bIsReader );
70368 u.ca.nRoot = pOp->p2;
70369 assert( u.ca.nRoot>0 );
70370 u.ca.aRoot = sqlite3DbMallocRaw(db, sizeof(int)*(u.ca.nRoot+1) );
70371 if( u.ca.aRoot==0 ) goto no_mem;
70372 assert( pOp->p3>0 && pOp->p3<=p->nMem );
@@ -70844,10 +70884,11 @@
70884 int i; /* Loop counter */
70885 int aRes[3]; /* Results */
70886 Mem *pMem; /* Write results here */
70887 #endif /* local variables moved into u.ci */
70888
70889 assert( p->readOnly==0 );
70890 u.ci.aRes[0] = 0;
70891 u.ci.aRes[1] = u.ci.aRes[2] = -1;
70892 assert( pOp->p2==SQLITE_CHECKPOINT_PASSIVE
70893 || pOp->p2==SQLITE_CHECKPOINT_FULL
70894 || pOp->p2==SQLITE_CHECKPOINT_RESTART
@@ -70895,10 +70936,11 @@
70936 || u.cj.eNew==PAGER_JOURNALMODE_MEMORY
70937 || u.cj.eNew==PAGER_JOURNALMODE_WAL
70938 || u.cj.eNew==PAGER_JOURNALMODE_QUERY
70939 );
70940 assert( pOp->p1>=0 && pOp->p1<db->nDb );
70941 assert( p->readOnly==0 );
70942
70943 u.cj.pBt = db->aDb[pOp->p1].pBt;
70944 u.cj.pPager = sqlite3BtreePager(u.cj.pBt);
70945 u.cj.eOld = sqlite3PagerGetJournalMode(u.cj.pPager);
70946 if( u.cj.eNew==PAGER_JOURNALMODE_QUERY ) u.cj.eNew = u.cj.eOld;
@@ -70918,11 +70960,11 @@
70960 }
70961
70962 if( (u.cj.eNew!=u.cj.eOld)
70963 && (u.cj.eOld==PAGER_JOURNALMODE_WAL || u.cj.eNew==PAGER_JOURNALMODE_WAL)
70964 ){
70965 if( !db->autoCommit || db->nVdbeRead>1 ){
70966 rc = SQLITE_ERROR;
70967 sqlite3SetString(&p->zErrMsg, db,
70968 "cannot change %s wal mode from within a transaction",
70969 (u.cj.eNew==PAGER_JOURNALMODE_WAL ? "into" : "out of")
70970 );
@@ -70977,10 +71019,11 @@
71019 ** Vacuum the entire database. This opcode will cause other virtual
71020 ** machines to be created and run. It may not be called from within
71021 ** a transaction.
71022 */
71023 case OP_Vacuum: {
71024 assert( p->readOnly==0 );
71025 rc = sqlite3RunVacuum(&p->zErrMsg, db);
71026 break;
71027 }
71028 #endif
71029
@@ -70996,10 +71039,11 @@
71039 Btree *pBt;
71040 #endif /* local variables moved into u.ck */
71041
71042 assert( pOp->p1>=0 && pOp->p1<db->nDb );
71043 assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
71044 assert( p->readOnly==0 );
71045 u.ck.pBt = db->aDb[pOp->p1].pBt;
71046 rc = sqlite3BtreeIncrVacuum(u.ck.pBt);
71047 if( rc==SQLITE_DONE ){
71048 pc = pOp->p2 - 1;
71049 rc = SQLITE_OK;
@@ -71118,10 +71162,11 @@
71162 sqlite3_vtab_cursor *pVtabCursor;
71163 sqlite3_vtab *pVtab;
71164 sqlite3_module *pModule;
71165 #endif /* local variables moved into u.cm */
71166
71167 assert( p->bIsReader );
71168 u.cm.pCur = 0;
71169 u.cm.pVtabCursor = 0;
71170 u.cm.pVtab = pOp->p4.pVtab->pVtab;
71171 u.cm.pModule = (sqlite3_module *)u.cm.pVtab->pModule;
71172 assert(u.cm.pVtab && u.cm.pModule);
@@ -71342,10 +71387,11 @@
71387
71388 u.cq.pVtab = pOp->p4.pVtab->pVtab;
71389 u.cq.pName = &aMem[pOp->p1];
71390 assert( u.cq.pVtab->pModule->xRename );
71391 assert( memIsValid(u.cq.pName) );
71392 assert( p->readOnly==0 );
71393 REGISTER_TRACE(pOp->p1, u.cq.pName);
71394 assert( u.cq.pName->flags & MEM_Str );
71395 testcase( u.cq.pName->enc==SQLITE_UTF8 );
71396 testcase( u.cq.pName->enc==SQLITE_UTF16BE );
71397 testcase( u.cq.pName->enc==SQLITE_UTF16LE );
@@ -71395,10 +71441,11 @@
71441 #endif /* local variables moved into u.cr */
71442
71443 assert( pOp->p2==1 || pOp->p5==OE_Fail || pOp->p5==OE_Rollback
71444 || pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace
71445 );
71446 assert( p->readOnly==0 );
71447 u.cr.pVtab = pOp->p4.pVtab->pVtab;
71448 u.cr.pModule = (sqlite3_module *)u.cr.pVtab->pModule;
71449 u.cr.nArg = pOp->p2;
71450 assert( pOp->p4type==P4_VTAB );
71451 if( ALWAYS(u.cr.pModule->xUpdate) ){
@@ -102957,11 +103004,11 @@
103004
103005 if( !db->autoCommit ){
103006 sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction");
103007 return SQLITE_ERROR;
103008 }
103009 if( db->nVdbeActive>1 ){
103010 sqlite3SetString(pzErrMsg, db,"cannot VACUUM - SQL statements in progress");
103011 return SQLITE_ERROR;
103012 }
103013
103014 /* Save the current value of the database flags so that it can be
@@ -104742,11 +104789,11 @@
104789 #define WHERE_INDEXED 0x00000200 /* WhereLoop.u.btree.pIndex is valid */
104790 #define WHERE_VIRTUALTABLE 0x00000400 /* WhereLoop.u.vtab is valid */
104791 #define WHERE_IN_ABLE 0x00000800 /* Able to support an IN operator */
104792 #define WHERE_ONEROW 0x00001000 /* Selects no more than one row */
104793 #define WHERE_MULTI_OR 0x00002000 /* OR using multiple indices */
104794 #define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
104795
104796
104797 /* Convert a WhereCost value (10 times log2(X)) into its integer value X.
104798 ** A rough approximation is used. The value returned is not exact.
104799 */
@@ -106036,10 +106083,11 @@
106083 ** the start of the loop will prevent any results from being returned.
106084 */
106085 if( pExpr->op==TK_NOTNULL
106086 && pExpr->pLeft->op==TK_COLUMN
106087 && pExpr->pLeft->iColumn>=0
106088 && OptimizationEnabled(db, SQLITE_Stat3)
106089 ){
106090 Expr *pNewExpr;
106091 Expr *pLeft = pExpr->pLeft;
106092 int idxNew;
106093 WhereTerm *pNewTerm;
@@ -106339,10 +106387,11 @@
106387 int mxBitCol; /* Maximum column in pSrc->colUsed */
106388 CollSeq *pColl; /* Collating sequence to on a column */
106389 WhereLoop *pLoop; /* The Loop object */
106390 Bitmask idxCols; /* Bitmap of columns used for indexing */
106391 Bitmask extraCols; /* Bitmap of additional columns */
106392 u8 sentWarning = 0; /* True if a warnning has been issued */
106393
106394 /* Generate code to skip over the creation and initialization of the
106395 ** transient index on 2nd and subsequent iterations of the loop. */
106396 v = pParse->pVdbe;
106397 assert( v!=0 );
@@ -106359,10 +106408,16 @@
106408 if( termCanDriveIndex(pTerm, pSrc, notReady) ){
106409 int iCol = pTerm->u.leftColumn;
106410 Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);
106411 testcase( iCol==BMS );
106412 testcase( iCol==BMS-1 );
106413 if( !sentWarning ){
106414 sqlite3_log(SQLITE_WARNING_AUTOINDEX,
106415 "automatic index on %s(%s)", pTable->zName,
106416 pTable->aCol[iCol].zName);
106417 sentWarning = 1;
106418 }
106419 if( (idxCols & cMask)==0 ){
106420 if( whereLoopResize(pParse->db, pLoop, nColumn+1) ) return;
106421 pLoop->aLTerm[nColumn++] = pTerm;
106422 idxCols |= cMask;
106423 }
@@ -106369,11 +106424,11 @@
106424 }
106425 }
106426 assert( nColumn>0 );
106427 pLoop->u.btree.nEq = pLoop->nLTerm = nColumn;
106428 pLoop->wsFlags = WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WHERE_INDEXED
106429 | WHERE_AUTO_INDEX;
106430
106431 /* Count the number of additional columns needed to create a
106432 ** covering index. A "covering index" is an index that contains all
106433 ** columns that are needed by the query. With a covering index, the
106434 ** original table never needs to be accessed. Automatic indices must
@@ -106869,11 +106924,11 @@
106924 ){
106925 int rc = SQLITE_OK;
106926
106927 #ifdef SQLITE_ENABLE_STAT3
106928
106929 if( nEq==0 && p->nSample && OptimizationEnabled(pParse->db, SQLITE_Stat3) ){
106930 sqlite3_value *pRangeVal;
106931 tRowcnt iLower = 0;
106932 tRowcnt iUpper = p->aiRowEst[0];
106933 tRowcnt a[2];
106934 u8 aff = p->pTable->aCol[p->aiColumn[0]].affinity;
@@ -107415,17 +107470,16 @@
107470 }
107471 if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0
107472 && ALWAYS(pLoop->u.btree.pIndex!=0)
107473 ){
107474 char *zWhere = explainIndexRange(db, pLoop, pItem->pTab);
107475 zMsg = sqlite3MAppendf(db, zMsg,
107476 ((flags & WHERE_AUTO_INDEX) ?
107477 "%s USING AUTOMATIC %sINDEX%.0s%s" :
107478 "%s USING %sINDEX %s%s"),
107479 zMsg, ((flags & WHERE_IDX_ONLY) ? "COVERING " : ""),
107480 pLoop->u.btree.pIndex->zName, zWhere);
 
107481 sqlite3DbFree(db, zWhere);
107482 }else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){
107483 zMsg = sqlite3MAppendf(db, zMsg, "%s USING INTEGER PRIMARY KEY", zMsg);
107484
107485 if( flags&(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) ){
@@ -108092,11 +108146,11 @@
108146 ** terms, set pCov to the candidate covering index. Otherwise, set
108147 ** pCov to NULL to indicate that no candidate covering index will
108148 ** be available.
108149 */
108150 pSubLoop = pSubWInfo->a[0].pWLoop;
108151 assert( (pSubLoop->wsFlags & WHERE_AUTO_INDEX)==0 );
108152 if( (pSubLoop->wsFlags & WHERE_INDEXED)!=0
108153 && (ii==0 || pSubLoop->u.btree.pIndex==pCov)
108154 ){
108155 assert( pSubWInfo->a[0].iIdxCur==iCovCur );
108156 pCov = pSubLoop->u.btree.pIndex;
@@ -108274,16 +108328,16 @@
108328
108329 /*
108330 ** Clear the WhereLoop.u union. Leave WhereLoop.pLTerm intact.
108331 */
108332 static void whereLoopClearUnion(sqlite3 *db, WhereLoop *p){
108333 if( p->wsFlags & (WHERE_VIRTUALTABLE|WHERE_AUTO_INDEX) ){
108334 if( (p->wsFlags & WHERE_VIRTUALTABLE)!=0 && p->u.vtab.needFree ){
108335 sqlite3_free(p->u.vtab.idxStr);
108336 p->u.vtab.needFree = 0;
108337 p->u.vtab.idxStr = 0;
108338 }else if( (p->wsFlags & WHERE_AUTO_INDEX)!=0 && p->u.btree.pIndex!=0 ){
108339 sqlite3DbFree(db, p->u.btree.pIndex->zColAff);
108340 sqlite3DbFree(db, p->u.btree.pIndex);
108341 p->u.btree.pIndex = 0;
108342 }
108343 }
@@ -108322,11 +108376,11 @@
108376 whereLoopClearUnion(db, pTo);
108377 memcpy(pTo, pFrom, WHERE_LOOP_XFER_SZ);
108378 memcpy(pTo->aLTerm, pFrom->aLTerm, pTo->nLTerm*sizeof(pTo->aLTerm[0]));
108379 if( pFrom->wsFlags & WHERE_VIRTUALTABLE ){
108380 pFrom->u.vtab.needFree = 0;
108381 }else if( (pFrom->wsFlags & WHERE_AUTO_INDEX)!=0 ){
108382 pFrom->u.btree.pIndex = 0;
108383 }
108384 return SQLITE_OK;
108385 }
108386
@@ -108634,11 +108688,12 @@
108688 whereRangeScanEst(pParse, pProbe, pNew->u.btree.nEq,
108689 pBtm, pTop, &rDiv);
108690 pNew->nOut = saved_nOut>rDiv+10 ? saved_nOut - rDiv : 10;
108691 }
108692 #ifdef SQLITE_ENABLE_STAT3
108693 if( pNew->u.btree.nEq==1 && pProbe->nSample
108694 && OptimizationEnabled(db, SQLITE_Stat3) ){
108695 tRowcnt nOut = 0;
108696 if( (pTerm->eOperator & (WO_EQ|WO_ISNULL))!=0 ){
108697 testcase( pTerm->eOperator & WO_EQ );
108698 testcase( pTerm->eOperator & WO_ISNULL );
108699 rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut);
@@ -108794,17 +108849,20 @@
108849 pNew->u.btree.nEq = 1;
108850 pNew->u.btree.pIndex = 0;
108851 pNew->nLTerm = 1;
108852 pNew->aLTerm[0] = pTerm;
108853 /* TUNING: One-time cost for computing the automatic index is
108854 ** approximately 7*N*log2(N) where N is the number of rows in
108855 ** the table being indexed. */
108856 pNew->rSetup = rLogSize + rSize + 28; assert( 28==whereCost(7) );
108857 /* TUNING: Each index lookup yields 20 rows in the table. This
108858 ** is more than the usual guess of 10 rows, since we have no way
108859 ** of knowning how selective the index will ultimately be. It would
108860 ** not be unreasonable to make this value much larger. */
108861 pNew->nOut = 43; assert( 43==whereCost(20) );
108862 pNew->rRun = whereCostAdd(rLogSize,pNew->nOut);
108863 pNew->wsFlags = WHERE_AUTO_INDEX;
108864 pNew->prereq = mExtra | pTerm->prereqRight;
108865 rc = whereLoopInsert(pBuilder, pNew);
108866 }
108867 }
108868 }
@@ -110094,18 +110152,28 @@
110152 && OptimizationEnabled(db, SQLITE_OmitNoopJoin)
110153 ){
110154 Bitmask tabUsed = exprListTableUsage(pMaskSet, pResultSet);
110155 if( pOrderBy ) tabUsed |= exprListTableUsage(pMaskSet, pOrderBy);
110156 while( pWInfo->nLevel>=2 ){
110157 WhereTerm *pTerm, *pEnd;
110158 pLoop = pWInfo->a[pWInfo->nLevel-1].pWLoop;
110159 if( (pWInfo->pTabList->a[pLoop->iTab].jointype & JT_LEFT)==0 ) break;
110160 if( (wctrlFlags & WHERE_WANT_DISTINCT)==0
110161 && (pLoop->wsFlags & WHERE_ONEROW)==0
110162 ){
110163 break;
110164 }
110165 if( (tabUsed & pLoop->maskSelf)!=0 ) break;
110166 pEnd = sWLB.pWC->a + sWLB.pWC->nTerm;
110167 for(pTerm=sWLB.pWC->a; pTerm<pEnd; pTerm++){
110168 if( (pTerm->prereqAll & pLoop->maskSelf)!=0
110169 && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
110170 ){
110171 break;
110172 }
110173 }
110174 if( pTerm<pEnd ) break;
110175 WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId));
110176 pWInfo->nLevel--;
110177 nTabList--;
110178 }
110179 }
@@ -110167,11 +110235,11 @@
110235 }
110236 }else{
110237 sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
110238 }
110239 #ifndef SQLITE_OMIT_AUTOMATIC_INDEX
110240 if( (pLoop->wsFlags & WHERE_AUTO_INDEX)!=0 ){
110241 constructAutomaticIndex(pParse, &pWInfo->sWC, pTabItem, notReady, pLevel);
110242 }else
110243 #endif
110244 if( pLoop->wsFlags & WHERE_INDEXED ){
110245 Index *pIx = pLoop->u.btree.pIndex;
@@ -110290,11 +110358,11 @@
110358 ){
110359 int ws = pLoop->wsFlags;
110360 if( !pWInfo->okOnePass && (ws & WHERE_IDX_ONLY)==0 ){
110361 sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
110362 }
110363 if( (ws & WHERE_INDEXED)!=0 && (ws & (WHERE_IPK|WHERE_AUTO_INDEX))==0 ){
110364 sqlite3VdbeAddOp1(v, OP_Close, pLevel->iIdxCur);
110365 }
110366 }
110367
110368 /* If this scan uses an index, make VDBE code substitutions to read data
@@ -114501,11 +114569,11 @@
114569 sqlite3 *db = pParse->db; /* The database connection */
114570 int mxSqlLen; /* Max length of an SQL string */
114571
114572
114573 mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
114574 if( db->nVdbeActive==0 ){
114575 db->u1.isInterrupted = 0;
114576 }
114577 pParse->rc = SQLITE_OK;
114578 pParse->zTail = zSql;
114579 i = 0;
@@ -116069,10 +116137,11 @@
116137 case SQLITE_PERM: zName = "SQLITE_PERM"; break;
116138 case SQLITE_ABORT: zName = "SQLITE_ABORT"; break;
116139 case SQLITE_ABORT_ROLLBACK: zName = "SQLITE_ABORT_ROLLBACK"; break;
116140 case SQLITE_BUSY: zName = "SQLITE_BUSY"; break;
116141 case SQLITE_BUSY_RECOVERY: zName = "SQLITE_BUSY_RECOVERY"; break;
116142 case SQLITE_BUSY_SNAPSHOT: zName = "SQLITE_BUSY_SNAPSHOT"; break;
116143 case SQLITE_LOCKED: zName = "SQLITE_LOCKED"; break;
116144 case SQLITE_LOCKED_SHAREDCACHE: zName = "SQLITE_LOCKED_SHAREDCACHE";break;
116145 case SQLITE_NOMEM: zName = "SQLITE_NOMEM"; break;
116146 case SQLITE_READONLY: zName = "SQLITE_READONLY"; break;
116147 case SQLITE_READONLY_RECOVERY: zName = "SQLITE_READONLY_RECOVERY"; break;
@@ -116142,10 +116211,11 @@
116211 case SQLITE_NOTICE: zName = "SQLITE_NOTICE"; break;
116212 case SQLITE_NOTICE_RECOVER_WAL: zName = "SQLITE_NOTICE_RECOVER_WAL";break;
116213 case SQLITE_NOTICE_RECOVER_ROLLBACK:
116214 zName = "SQLITE_NOTICE_RECOVER_ROLLBACK"; break;
116215 case SQLITE_WARNING: zName = "SQLITE_WARNING"; break;
116216 case SQLITE_WARNING_AUTOINDEX: zName = "SQLITE_WARNING_AUTOINDEX"; break;
116217 case SQLITE_DONE: zName = "SQLITE_DONE"; break;
116218 }
116219 }
116220 if( zName==0 ){
116221 static char zBuf[50];
@@ -116400,11 +116470,11 @@
116470 ** is being overridden/deleted but there are no active VMs, allow the
116471 ** operation to continue but invalidate all precompiled statements.
116472 */
116473 p = sqlite3FindFunction(db, zFunctionName, nName, nArg, (u8)enc, 0);
116474 if( p && p->iPrefEnc==enc && p->nArg==nArg ){
116475 if( db->nVdbeActive ){
116476 sqlite3Error(db, SQLITE_BUSY,
116477 "unable to delete/modify user-function due to active statements");
116478 assert( !db->mallocFailed );
116479 return SQLITE_BUSY;
116480 }else{
@@ -116981,11 +117051,11 @@
117051 ** sequence. If so, and there are active VMs, return busy. If there
117052 ** are no active VMs, invalidate any pre-compiled statements.
117053 */
117054 pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 0);
117055 if( pColl && pColl->xCmp ){
117056 if( db->nVdbeActive ){
117057 sqlite3Error(db, SQLITE_BUSY,
117058 "unable to delete/modify collation sequence due to active statements");
117059 return SQLITE_BUSY;
117060 }
117061 sqlite3ExpirePreparedStatements(db);
@@ -117456,11 +117526,14 @@
117526 memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
117527 db->autoCommit = 1;
117528 db->nextAutovac = -1;
117529 db->szMmap = sqlite3GlobalConfig.szMmap;
117530 db->nextPagesize = 0;
117531 db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger
117532 #if !defined(SQLITE_DEAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
117533 | SQLITE_AutoIndex
117534 #endif
117535 #if SQLITE_DEFAULT_FILE_FORMAT<4
117536 | SQLITE_LegacyFileFmt
117537 #endif
117538 #ifdef SQLITE_ENABLE_LOAD_EXTENSION
117539 | SQLITE_LoadExtension
117540
+3 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.8.0"
111111
#define SQLITE_VERSION_NUMBER 3008000
112
-#define SQLITE_SOURCE_ID "2013-06-26 22:46:00 93f632152e464a89322a0130adaf9f342411bf7d"
112
+#define SQLITE_SOURCE_ID "2013-06-28 23:55:45 338826ef3f8a209b14f8d42370855cab9ac9ed45"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -478,10 +478,11 @@
478478
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479479
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480480
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481481
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
482482
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
483
+#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
483484
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
484485
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
485486
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
486487
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
487488
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
@@ -497,10 +498,11 @@
497498
#define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8))
498499
#define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8))
499500
#define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8))
500501
#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
501502
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
503
+#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
502504
503505
/*
504506
** CAPI3REF: Flags For File Open Operations
505507
**
506508
** These bit values are intended for use in the
507509
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.0"
111 #define SQLITE_VERSION_NUMBER 3008000
112 #define SQLITE_SOURCE_ID "2013-06-26 22:46:00 93f632152e464a89322a0130adaf9f342411bf7d"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -478,10 +478,11 @@
478 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
482 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
 
483 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
484 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
485 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
486 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
487 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
@@ -497,10 +498,11 @@
497 #define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8))
498 #define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8))
499 #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8))
500 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
501 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
 
502
503 /*
504 ** CAPI3REF: Flags For File Open Operations
505 **
506 ** These bit values are intended for use in the
507
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.0"
111 #define SQLITE_VERSION_NUMBER 3008000
112 #define SQLITE_SOURCE_ID "2013-06-28 23:55:45 338826ef3f8a209b14f8d42370855cab9ac9ed45"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -478,10 +478,11 @@
478 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
482 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
483 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
484 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
485 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
486 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
487 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
488 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
@@ -497,10 +498,11 @@
498 #define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8))
499 #define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8))
500 #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8))
501 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
502 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
503 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
504
505 /*
506 ** CAPI3REF: Flags For File Open Operations
507 **
508 ** These bit values are intended for use in the
509

Keyboard Shortcuts

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