1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Merge the sqlite3_db_cacheflush() enhancements and other changes from trunk.

FossilOrigin-Name: f2cde4cfc58cc372f59ae274bf0c2f7cf6e7ddf9
This commit is contained in:
drh
2015-10-30 17:17:12 +00:00
76 changed files with 2585 additions and 498 deletions

View File

@@ -45,3 +45,15 @@ foreach x $extras {
incr max
puts [format "#define TK_%-29s %4d" $x $max]
}
# Some additional #defines related to token codes.
#
puts "\n/* The token codes above must all fit in 8 bits */"
puts [format "#define %-20s %-6s" TKFLG_MASK 0xff]
puts "\n/* Flags that can be added to a token code when it is not"
puts "** being stored in a u8: */"
foreach {fg val comment} {
TKFLG_DONTFOLD 0x100 {/* Omit constant folding optimizations */}
} {
puts [format "#define %-20s %-6s %s" $fg $val $comment]
}

View File

@@ -95,6 +95,10 @@ REM example:
REM
REM SET NMAKE_ARGS=FOR_WINRT=1
REM
REM Using the above command before running this tool will cause the compiled
REM binaries to target the WinRT environment, which provides a subset of the
REM Win32 API.
REM
SETLOCAL
REM SET __ECHO=ECHO

View File

@@ -67,6 +67,7 @@
#include <stdarg.h>
#include <ctype.h>
#include "sqlite3.h"
#define ISDIGIT(X) isdigit((unsigned char)(X))
/*
** All global variables are gathered into the "g" singleton.
@@ -383,7 +384,7 @@ static int integerValue(const char *zArg){
zArg++;
}
}else{
while( isdigit(zArg[0]) ){
while( ISDIGIT(zArg[0]) ){
v = v*10 + zArg[0] - '0';
zArg++;
}

View File

@@ -13,6 +13,14 @@
#include <stdlib.h>
#include <assert.h>
#define ISSPACE(X) isspace((unsigned char)(X))
#define ISDIGIT(X) isdigit((unsigned char)(X))
#define ISALNUM(X) isalnum((unsigned char)(X))
#define ISALPHA(X) isalpha((unsigned char)(X))
#define ISUPPER(X) isupper((unsigned char)(X))
#define ISLOWER(X) islower((unsigned char)(X))
#ifndef __WIN32__
# if defined(_WIN32) || defined(WIN32)
# define __WIN32__
@@ -93,9 +101,9 @@ static int lemon_vsprintf(char *str, const char *zFormat, va_list ap){
int iWidth = 0;
lemon_addtext(str, &nUsed, &zFormat[j], i-j, 0);
c = zFormat[++i];
if( isdigit(c) || (c=='-' && isdigit(zFormat[i+1])) ){
if( ISDIGIT(c) || (c=='-' && ISDIGIT(zFormat[i+1])) ){
if( c=='-' ) i++;
while( isdigit(zFormat[i]) ) iWidth = iWidth*10 + zFormat[i++] - '0';
while( ISDIGIT(zFormat[i]) ) iWidth = iWidth*10 + zFormat[i++] - '0';
if( c=='-' ) iWidth = -iWidth;
c = zFormat[i];
}
@@ -1578,7 +1586,7 @@ int main(int argc, char **argv)
while( lem.symbols[i-1]->type==MULTITERMINAL ){ i--; }
assert( strcmp(lem.symbols[i-1]->name,"{default}")==0 );
lem.nsymbol = i - 1;
for(i=1; isupper(lem.symbols[i]->name[0]); i++);
for(i=1; ISUPPER(lem.symbols[i]->name[0]); i++);
lem.nterminal = i;
/* Generate a reprint of the grammar, if requested on the command line */
@@ -2121,7 +2129,7 @@ static void parseonetoken(struct pstate *psp)
case WAITING_FOR_DECL_OR_RULE:
if( x[0]=='%' ){
psp->state = WAITING_FOR_DECL_KEYWORD;
}else if( islower(x[0]) ){
}else if( ISLOWER(x[0]) ){
psp->lhs = Symbol_new(x);
psp->nrhs = 0;
psp->lhsalias = 0;
@@ -2151,7 +2159,7 @@ to follow the previous rule.");
}
break;
case PRECEDENCE_MARK_1:
if( !isupper(x[0]) ){
if( !ISUPPER(x[0]) ){
ErrorMsg(psp->filename,psp->tokenlineno,
"The precedence symbol must be a terminal.");
psp->errorcnt++;
@@ -2191,7 +2199,7 @@ to follow the previous rule.");
}
break;
case LHS_ALIAS_1:
if( isalpha(x[0]) ){
if( ISALPHA(x[0]) ){
psp->lhsalias = x;
psp->state = LHS_ALIAS_2;
}else{
@@ -2260,7 +2268,7 @@ to follow the previous rule.");
psp->prevrule = rp;
}
psp->state = WAITING_FOR_DECL_OR_RULE;
}else if( isalpha(x[0]) ){
}else if( ISALPHA(x[0]) ){
if( psp->nrhs>=MAXRHS ){
ErrorMsg(psp->filename,psp->tokenlineno,
"Too many symbols on RHS of rule beginning at \"%s\".",
@@ -2289,7 +2297,7 @@ to follow the previous rule.");
msp->subsym = (struct symbol **) realloc(msp->subsym,
sizeof(struct symbol*)*msp->nsubsym);
msp->subsym[msp->nsubsym-1] = Symbol_new(&x[1]);
if( islower(x[1]) || islower(msp->subsym[0]->name[0]) ){
if( ISLOWER(x[1]) || ISLOWER(msp->subsym[0]->name[0]) ){
ErrorMsg(psp->filename,psp->tokenlineno,
"Cannot form a compound containing a non-terminal");
psp->errorcnt++;
@@ -2304,7 +2312,7 @@ to follow the previous rule.");
}
break;
case RHS_ALIAS_1:
if( isalpha(x[0]) ){
if( ISALPHA(x[0]) ){
psp->alias[psp->nrhs-1] = x;
psp->state = RHS_ALIAS_2;
}else{
@@ -2326,7 +2334,7 @@ to follow the previous rule.");
}
break;
case WAITING_FOR_DECL_KEYWORD:
if( isalpha(x[0]) ){
if( ISALPHA(x[0]) ){
psp->declkeyword = x;
psp->declargslot = 0;
psp->decllinenoslot = 0;
@@ -2406,7 +2414,7 @@ to follow the previous rule.");
}
break;
case WAITING_FOR_DESTRUCTOR_SYMBOL:
if( !isalpha(x[0]) ){
if( !ISALPHA(x[0]) ){
ErrorMsg(psp->filename,psp->tokenlineno,
"Symbol name missing after %%destructor keyword");
psp->errorcnt++;
@@ -2420,7 +2428,7 @@ to follow the previous rule.");
}
break;
case WAITING_FOR_DATATYPE_SYMBOL:
if( !isalpha(x[0]) ){
if( !ISALPHA(x[0]) ){
ErrorMsg(psp->filename,psp->tokenlineno,
"Symbol name missing after %%type keyword");
psp->errorcnt++;
@@ -2445,7 +2453,7 @@ to follow the previous rule.");
case WAITING_FOR_PRECEDENCE_SYMBOL:
if( x[0]=='.' ){
psp->state = WAITING_FOR_DECL_OR_RULE;
}else if( isupper(x[0]) ){
}else if( ISUPPER(x[0]) ){
struct symbol *sp;
sp = Symbol_new(x);
if( sp->prec>=0 ){
@@ -2463,7 +2471,7 @@ to follow the previous rule.");
}
break;
case WAITING_FOR_DECL_ARG:
if( x[0]=='{' || x[0]=='\"' || isalnum(x[0]) ){
if( x[0]=='{' || x[0]=='\"' || ISALNUM(x[0]) ){
const char *zOld, *zNew;
char *zBuf, *z;
int nOld, n, nLine = 0, nNew, nBack;
@@ -2524,7 +2532,7 @@ to follow the previous rule.");
case WAITING_FOR_FALLBACK_ID:
if( x[0]=='.' ){
psp->state = WAITING_FOR_DECL_OR_RULE;
}else if( !isupper(x[0]) ){
}else if( !ISUPPER(x[0]) ){
ErrorMsg(psp->filename, psp->tokenlineno,
"%%fallback argument \"%s\" should be a token", x);
psp->errorcnt++;
@@ -2545,7 +2553,7 @@ to follow the previous rule.");
case WAITING_FOR_WILDCARD_ID:
if( x[0]=='.' ){
psp->state = WAITING_FOR_DECL_OR_RULE;
}else if( !isupper(x[0]) ){
}else if( !ISUPPER(x[0]) ){
ErrorMsg(psp->filename, psp->tokenlineno,
"%%wildcard argument \"%s\" should be a token", x);
psp->errorcnt++;
@@ -2561,7 +2569,7 @@ to follow the previous rule.");
}
break;
case WAITING_FOR_CLASS_ID:
if( !islower(x[0]) ){
if( !ISLOWER(x[0]) ){
ErrorMsg(psp->filename, psp->tokenlineno,
"%%token_class must be followed by an identifier: ", x);
psp->errorcnt++;
@@ -2580,12 +2588,12 @@ to follow the previous rule.");
case WAITING_FOR_CLASS_TOKEN:
if( x[0]=='.' ){
psp->state = WAITING_FOR_DECL_OR_RULE;
}else if( isupper(x[0]) || ((x[0]=='|' || x[0]=='/') && isupper(x[1])) ){
}else if( ISUPPER(x[0]) || ((x[0]=='|' || x[0]=='/') && ISUPPER(x[1])) ){
struct symbol *msp = psp->tkclass;
msp->nsubsym++;
msp->subsym = (struct symbol **) realloc(msp->subsym,
sizeof(struct symbol*)*msp->nsubsym);
if( !isupper(x[0]) ) x++;
if( !ISUPPER(x[0]) ) x++;
msp->subsym[msp->nsubsym-1] = Symbol_new(x);
}else{
ErrorMsg(psp->filename, psp->tokenlineno,
@@ -2618,7 +2626,7 @@ static void preprocess_input(char *z){
for(i=0; z[i]; i++){
if( z[i]=='\n' ) lineno++;
if( z[i]!='%' || (i>0 && z[i-1]!='\n') ) continue;
if( strncmp(&z[i],"%endif",6)==0 && isspace(z[i+6]) ){
if( strncmp(&z[i],"%endif",6)==0 && ISSPACE(z[i+6]) ){
if( exclude ){
exclude--;
if( exclude==0 ){
@@ -2626,13 +2634,13 @@ static void preprocess_input(char *z){
}
}
for(j=i; z[j] && z[j]!='\n'; j++) z[j] = ' ';
}else if( (strncmp(&z[i],"%ifdef",6)==0 && isspace(z[i+6]))
|| (strncmp(&z[i],"%ifndef",7)==0 && isspace(z[i+7])) ){
}else if( (strncmp(&z[i],"%ifdef",6)==0 && ISSPACE(z[i+6]))
|| (strncmp(&z[i],"%ifndef",7)==0 && ISSPACE(z[i+7])) ){
if( exclude ){
exclude++;
}else{
for(j=i+7; isspace(z[j]); j++){}
for(n=0; z[j+n] && !isspace(z[j+n]); n++){}
for(j=i+7; ISSPACE(z[j]); j++){}
for(n=0; z[j+n] && !ISSPACE(z[j+n]); n++){}
exclude = 1;
for(k=0; k<nDefine; k++){
if( strncmp(azDefine[k],&z[j],n)==0 && lemonStrlen(azDefine[k])==n ){
@@ -2712,7 +2720,7 @@ void Parse(struct lemon *gp)
lineno = 1;
for(cp=filebuf; (c= *cp)!=0; ){
if( c=='\n' ) lineno++; /* Keep track of the line number */
if( isspace(c) ){ cp++; continue; } /* Skip all white space */
if( ISSPACE(c) ){ cp++; continue; } /* Skip all white space */
if( c=='/' && cp[1]=='/' ){ /* Skip C++ style comments */
cp+=2;
while( (c= *cp)!=0 && c!='\n' ) cp++;
@@ -2782,15 +2790,15 @@ void Parse(struct lemon *gp)
}else{
nextcp = cp+1;
}
}else if( isalnum(c) ){ /* Identifiers */
while( (c= *cp)!=0 && (isalnum(c) || c=='_') ) cp++;
}else if( ISALNUM(c) ){ /* Identifiers */
while( (c= *cp)!=0 && (ISALNUM(c) || c=='_') ) cp++;
nextcp = cp;
}else if( c==':' && cp[1]==':' && cp[2]=='=' ){ /* The operator "::=" */
cp += 3;
nextcp = cp;
}else if( (c=='/' || c=='|') && isalpha(cp[1]) ){
}else if( (c=='/' || c=='|') && ISALPHA(cp[1]) ){
cp += 2;
while( (c = *cp)!=0 && (isalnum(c) || c=='_') ) cp++;
while( (c = *cp)!=0 && (ISALNUM(c) || c=='_') ) cp++;
nextcp = cp;
}else{ /* All other (one character) operators */
cp++;
@@ -3241,7 +3249,7 @@ PRIVATE void tplt_xfer(char *name, FILE *in, FILE *out, int *lineno)
if( name ){
for(i=0; line[i]; i++){
if( line[i]=='P' && strncmp(&line[i],"Parse",5)==0
&& (i==0 || !isalpha(line[i-1]))
&& (i==0 || !ISALPHA(line[i-1]))
){
if( i>iStart ) fprintf(out,"%.*s",i-iStart,&line[iStart]);
fprintf(out,"%s",name);
@@ -3478,9 +3486,9 @@ PRIVATE void translate_code(struct lemon *lemp, struct rule *rp){
/* This const cast is wrong but harmless, if we're careful. */
for(cp=(char *)rp->code; *cp; cp++){
if( isalpha(*cp) && (cp==rp->code || (!isalnum(cp[-1]) && cp[-1]!='_')) ){
if( ISALPHA(*cp) && (cp==rp->code || (!ISALNUM(cp[-1]) && cp[-1]!='_')) ){
char saved;
for(xp= &cp[1]; isalnum(*xp) || *xp=='_'; xp++);
for(xp= &cp[1]; ISALNUM(*xp) || *xp=='_'; xp++);
saved = *xp;
*xp = 0;
if( rp->lhsalias && strcmp(cp,rp->lhsalias)==0 ){
@@ -3645,9 +3653,9 @@ void print_stack_union(
cp = sp->datatype;
if( cp==0 ) cp = lemp->vartype;
j = 0;
while( isspace(*cp) ) cp++;
while( ISSPACE(*cp) ) cp++;
while( *cp ) stddt[j++] = *cp++;
while( j>0 && isspace(stddt[j-1]) ) j--;
while( j>0 && ISSPACE(stddt[j-1]) ) j--;
stddt[j] = 0;
if( lemp->tokentype && strcmp(stddt, lemp->tokentype)==0 ){
sp->dtnum = 0;
@@ -3857,8 +3865,8 @@ void ReportTable(
name = lemp->name ? lemp->name : "Parse";
if( lemp->arg && lemp->arg[0] ){
i = lemonStrlen(lemp->arg);
while( i>=1 && isspace(lemp->arg[i-1]) ) i--;
while( i>=1 && (isalnum(lemp->arg[i-1]) || lemp->arg[i-1]=='_') ) i--;
while( i>=1 && ISSPACE(lemp->arg[i-1]) ) i--;
while( i>=1 && (ISALNUM(lemp->arg[i-1]) || lemp->arg[i-1]=='_') ) i--;
fprintf(out,"#define %sARG_SDECL %s;\n",name,lemp->arg); lineno++;
fprintf(out,"#define %sARG_PDECL ,%s\n",name,lemp->arg); lineno++;
fprintf(out,"#define %sARG_FETCH %s = yypParser->%s\n",
@@ -4666,7 +4674,7 @@ struct symbol *Symbol_new(const char *x)
sp = (struct symbol *)calloc(1, sizeof(struct symbol) );
MemoryCheck(sp);
sp->name = Strsafe(x);
sp->type = isupper(*x) ? TERMINAL : NONTERMINAL;
sp->type = ISUPPER(*x) ? TERMINAL : NONTERMINAL;
sp->rule = 0;
sp->fallback = 0;
sp->prec = -1;

View File

@@ -56,7 +56,7 @@ mv $TMPSPACE/tmp $TMPSPACE/configure.ac
cd $TMPSPACE
aclocal
autoconf
automake
automake --add-missing
mkdir -p tea/generic
echo "#ifdef USE_SYSTEM_SQLITE" > tea/generic/tclsqlite3.c

View File

@@ -3,6 +3,8 @@
*/
#include <stdio.h>
#include <ctype.h>
#define ISDIGIT(X) isdigit((unsigned char)(X))
#define ISPRINT(X) isprint((unsigned char)(X))
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -217,7 +219,7 @@ static unsigned char *print_byte_range(
if( i+j>nByte ){
fprintf(stdout, " ");
}else{
fprintf(stdout,"%c", isprint(aData[i+j]) ? aData[i+j] : '.');
fprintf(stdout,"%c", ISPRINT(aData[i+j]) ? aData[i+j] : '.');
}
}
fprintf(stdout,"\n");
@@ -600,7 +602,7 @@ static void decodeCell(
}else{
zConst[0] = '\'';
for(ii=1, jj=0; jj<szCol[i] && ii<24; jj++, ii++){
zConst[ii] = isprint(pData[jj]) ? pData[jj] : '.';
zConst[ii] = ISPRINT(pData[jj]) ? pData[jj] : '.';
}
zConst[ii] = 0;
}
@@ -653,11 +655,11 @@ static void decode_btree_page(
case 'c': showCellContent = 1; break;
case 'm': showMap = 1; break;
case 'd': {
if( !isdigit(zArgs[1]) ){
if( !ISDIGIT(zArgs[1]) ){
cellToDecode = -1;
}else{
cellToDecode = 0;
while( isdigit(zArgs[1]) ){
while( ISDIGIT(zArgs[1]) ){
zArgs++;
cellToDecode = cellToDecode*10 + zArgs[0] - '0';
}
@@ -1123,7 +1125,7 @@ int main(int argc, char **argv){
usage(zPrg);
continue;
}
if( !isdigit(azArg[i][0]) ){
if( !ISDIGIT(azArg[i][0]) ){
fprintf(stderr, "%s: unknown option: [%s]\n", zPrg, azArg[i]);
continue;
}

View File

@@ -9,6 +9,8 @@
#include <ctype.h>
#include "sqlite3.h"
#define ISPRINT(X) isprint((unsigned char)(X))
typedef sqlite3_int64 i64; /* 64-bit signed integer type */
@@ -131,7 +133,7 @@ int main(int argc, char **argv){
printf("%s\"", zSep);
for(j=0; j<sz; j++){
char c = (char)aSample[y+j];
if( isprint(c) ){
if( ISPRINT(c) ){
if( c=='"' || c=='\\' ) putchar('\\');
putchar(c);
}else if( c=='\n' ){

View File

@@ -7,6 +7,9 @@
#include <sys/stat.h>
#include <fcntl.h>
#define ISDIGIT(X) isdigit((unsigned char)(X))
#define ISPRINT(X) isprint((unsigned char)(X))
#if !defined(_MSC_VER)
#include <unistd.h>
#else
@@ -159,7 +162,7 @@ static void print_byte_range(
if( i+j>nByte ){
fprintf(stdout, " ");
}else{
fprintf(stdout,"%c", isprint(aData[i+j]) ? aData[i+j] : '.');
fprintf(stdout,"%c", ISPRINT(aData[i+j]) ? aData[i+j] : '.');
}
}
fprintf(stdout,"\n");
@@ -550,7 +553,7 @@ int main(int argc, char **argv){
print_wal_header(0);
continue;
}
if( !isdigit(argv[i][0]) ){
if( !ISDIGIT(argv[i][0]) ){
fprintf(stderr, "%s: unknown option: [%s]\n", argv[0], argv[i]);
continue;
}

View File

@@ -29,6 +29,8 @@
#include <unistd.h>
#include "sqlite3.h"
#define ISSPACE(X) isspace((unsigned char)(X))
/*
** hwtime.h contains inline assembler code for implementing
** high-performance timing routines.
@@ -140,7 +142,7 @@ int main(int argc, char **argv){
zSql[j+1] = c;
if( isComplete ){
zSql[j] = 0;
while( i<j && isspace(zSql[i]) ){ i++; }
while( i<j && ISSPACE(zSql[i]) ){ i++; }
if( i<j ){
nStmt++;
nByte += j-i;

View File

@@ -29,6 +29,8 @@
#include <stdarg.h>
#include "sqlite3.h"
#define ISSPACE(X) isspace((unsigned char)(X))
#include "test_osinst.c"
/*
@@ -197,7 +199,7 @@ int main(int argc, char **argv){
zSql[j+1] = c;
if( isComplete ){
zSql[j] = 0;
while( i<j && isspace(zSql[i]) ){ i++; }
while( i<j && ISSPACE(zSql[i]) ){ i++; }
if( i<j ){
prepareAndRun(pInstVfs, db, &zSql[i]);
}