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

Merge the latest trunk enhancements into begin-concurrent-pnu.

FossilOrigin-Name: e70878b363db8ed0ed8aa345342a4174d54a8d95330b1bffc2843f0b07332526
This commit is contained in:
drh
2019-05-14 21:51:57 +00:00
91 changed files with 6421 additions and 709 deletions

View File

@@ -483,22 +483,22 @@ void Configtable_clear(int(*)(struct config *));
/* Allocate a new parser action */
static struct action *Action_new(void){
static struct action *freelist = 0;
static struct action *actionfreelist = 0;
struct action *newaction;
if( freelist==0 ){
if( actionfreelist==0 ){
int i;
int amt = 100;
freelist = (struct action *)calloc(amt, sizeof(struct action));
if( freelist==0 ){
actionfreelist = (struct action *)calloc(amt, sizeof(struct action));
if( actionfreelist==0 ){
fprintf(stderr,"Unable to allocate memory for a new parser action.");
exit(1);
}
for(i=0; i<amt-1; i++) freelist[i].next = &freelist[i+1];
freelist[amt-1].next = 0;
for(i=0; i<amt-1; i++) actionfreelist[i].next = &actionfreelist[i+1];
actionfreelist[amt-1].next = 0;
}
newaction = freelist;
freelist = freelist->next;
newaction = actionfreelist;
actionfreelist = actionfreelist->next;
return newaction;
}
@@ -1907,7 +1907,7 @@ static char *msort(
return ep;
}
/************************ From the file "option.c" **************************/
static char **argv;
static char **g_argv;
static struct s_options *op;
static FILE *errstream;
@@ -1920,14 +1920,14 @@ static FILE *errstream;
static void errline(int n, int k, FILE *err)
{
int spcnt, i;
if( argv[0] ) fprintf(err,"%s",argv[0]);
spcnt = lemonStrlen(argv[0]) + 1;
for(i=1; i<n && argv[i]; i++){
fprintf(err," %s",argv[i]);
spcnt += lemonStrlen(argv[i])+1;
if( g_argv[0] ) fprintf(err,"%s",g_argv[0]);
spcnt = lemonStrlen(g_argv[0]) + 1;
for(i=1; i<n && g_argv[i]; i++){
fprintf(err," %s",g_argv[i]);
spcnt += lemonStrlen(g_argv[i])+1;
}
spcnt += k;
for(; argv[i]; i++) fprintf(err," %s",argv[i]);
for(; g_argv[i]; i++) fprintf(err," %s",g_argv[i]);
if( spcnt<20 ){
fprintf(err,"\n%*s^-- here\n",spcnt,"");
}else{
@@ -1943,13 +1943,13 @@ static int argindex(int n)
{
int i;
int dashdash = 0;
if( argv!=0 && *argv!=0 ){
for(i=1; argv[i]; i++){
if( dashdash || !ISOPT(argv[i]) ){
if( g_argv!=0 && *g_argv!=0 ){
for(i=1; g_argv[i]; i++){
if( dashdash || !ISOPT(g_argv[i]) ){
if( n==0 ) return i;
n--;
}
if( strcmp(argv[i],"--")==0 ) dashdash = 1;
if( strcmp(g_argv[i],"--")==0 ) dashdash = 1;
}
}
return -1;
@@ -1966,9 +1966,9 @@ static int handleflags(int i, FILE *err)
int errcnt = 0;
int j;
for(j=0; op[j].label; j++){
if( strncmp(&argv[i][1],op[j].label,lemonStrlen(op[j].label))==0 ) break;
if( strncmp(&g_argv[i][1],op[j].label,lemonStrlen(op[j].label))==0 ) break;
}
v = argv[i][0]=='-' ? 1 : 0;
v = g_argv[i][0]=='-' ? 1 : 0;
if( op[j].label==0 ){
if( err ){
fprintf(err,"%sundefined option.\n",emsg);
@@ -1982,7 +1982,7 @@ static int handleflags(int i, FILE *err)
}else if( op[j].type==OPT_FFLAG ){
(*(void(*)(int))(op[j].arg))(v);
}else if( op[j].type==OPT_FSTR ){
(*(void(*)(char *))(op[j].arg))(&argv[i][2]);
(*(void(*)(char *))(op[j].arg))(&g_argv[i][2]);
}else{
if( err ){
fprintf(err,"%smissing argument on switch.\n",emsg);
@@ -2004,11 +2004,11 @@ static int handleswitch(int i, FILE *err)
char *cp;
int j;
int errcnt = 0;
cp = strchr(argv[i],'=');
cp = strchr(g_argv[i],'=');
assert( cp!=0 );
*cp = 0;
for(j=0; op[j].label; j++){
if( strcmp(argv[i],op[j].label)==0 ) break;
if( strcmp(g_argv[i],op[j].label)==0 ) break;
}
*cp = '=';
if( op[j].label==0 ){
@@ -2035,7 +2035,7 @@ static int handleswitch(int i, FILE *err)
if( err ){
fprintf(err,
"%sillegal character in floating-point argument.\n",emsg);
errline(i,(int)((char*)end-(char*)argv[i]),err);
errline(i,(int)((char*)end-(char*)g_argv[i]),err);
}
errcnt++;
}
@@ -2046,7 +2046,7 @@ static int handleswitch(int i, FILE *err)
if( *end ){
if( err ){
fprintf(err,"%sillegal character in integer argument.\n",emsg);
errline(i,(int)((char*)end-(char*)argv[i]),err);
errline(i,(int)((char*)end-(char*)g_argv[i]),err);
}
errcnt++;
}
@@ -2086,15 +2086,15 @@ static int handleswitch(int i, FILE *err)
int OptInit(char **a, struct s_options *o, FILE *err)
{
int errcnt = 0;
argv = a;
g_argv = a;
op = o;
errstream = err;
if( argv && *argv && op ){
if( g_argv && *g_argv && op ){
int i;
for(i=1; argv[i]; i++){
if( argv[i][0]=='+' || argv[i][0]=='-' ){
for(i=1; g_argv[i]; i++){
if( g_argv[i][0]=='+' || g_argv[i][0]=='-' ){
errcnt += handleflags(i,err);
}else if( strchr(argv[i],'=') ){
}else if( strchr(g_argv[i],'=') ){
errcnt += handleswitch(i,err);
}
}
@@ -2111,10 +2111,10 @@ int OptNArgs(void){
int cnt = 0;
int dashdash = 0;
int i;
if( argv!=0 && argv[0]!=0 ){
for(i=1; argv[i]; i++){
if( dashdash || !ISOPT(argv[i]) ) cnt++;
if( strcmp(argv[i],"--")==0 ) dashdash = 1;
if( g_argv!=0 && g_argv[0]!=0 ){
for(i=1; g_argv[i]; i++){
if( dashdash || !ISOPT(g_argv[i]) ) cnt++;
if( strcmp(g_argv[i],"--")==0 ) dashdash = 1;
}
}
return cnt;
@@ -2124,7 +2124,7 @@ char *OptArg(int n)
{
int i;
i = argindex(n);
return i>=0 ? argv[i] : 0;
return i>=0 ? g_argv[i] : 0;
}
void OptErr(int n)
@@ -2728,7 +2728,7 @@ to follow the previous rule.");
case WAITING_FOR_CLASS_ID:
if( !ISLOWER(x[0]) ){
ErrorMsg(psp->filename, psp->tokenlineno,
"%%token_class must be followed by an identifier: ", x);
"%%token_class must be followed by an identifier: %s", x);
psp->errorcnt++;
psp->state = RESYNC_AFTER_DECL_ERROR;
}else if( Symbol_find(x) ){
@@ -3848,7 +3848,7 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){
ErrorMsg(lemp->filename,rp->ruleline,
"%s(%s) has the same label as the LHS but is not the left-most "
"symbol on the RHS.",
rp->rhs[i]->name, rp->rhsalias);
rp->rhs[i]->name, rp->rhsalias[i]);
lemp->errorcnt++;
}
for(j=0; j<i; j++){

View File

@@ -307,6 +307,7 @@ set pragma_def {
NAME: case_sensitive_like
FLAG: NoColumns
IF: !defined(SQLITE_OMIT_CASE_SENSITIVE_LIKE_PRAGMA)
NAME: integrity_check
FLAG: NeedSchema Result0 Result1

View File

@@ -40,16 +40,21 @@ proc omit_redundant_typedefs {line} {
}
return $line
}
set iLine 0
while {1} {
set lx [omit_redundant_typedefs [gets $in]]
if {[eof $in]} break;
incr iLine
if {[regexp {^INCLUDE } $lx]} {
set cfile [lindex $lx 1]
puts $out "/************************* Begin $cfile ******************/"
# puts $out "#line 1 \"$cfile\""
set in2 [open $topdir/src/$cfile rb]
while {![eof $in2]} {
set lx [omit_redundant_typedefs [gets $in2]]
if {[regexp {^#include "sqlite} $lx]} continue
if {[regexp {^#include "sqlite} $lx]} {
set lx "/* $lx */"
}
if {[regexp {^# *include "test_windirent.h"} $lx]} {
set lx "/* $lx */"
}
@@ -58,6 +63,7 @@ while {1} {
}
close $in2
puts $out "/************************* End $cfile ********************/"
# puts $out "#line [expr $iLine+1] \"shell.c.in\""
continue
}
puts $out $lx

View File

@@ -835,9 +835,20 @@ static void page_usage_cell(
}
}
/*
** True if the memory is all zeros
*/
static int allZero(unsigned char *a, int n){
while( n && (a++)[0]==0 ){ n--; }
return n==0;
}
/*
** Describe the usages of a b-tree page
** Describe the usages of a b-tree page.
**
** If parent==0, then this is the root of a btree. If parent<0 then
** this is an orphan page.
*/
static void page_usage_btree(
int pgno, /* Page to describe */
@@ -850,22 +861,44 @@ static void page_usage_btree(
int nCell;
int i;
int hdr = pgno==1 ? 100 : 0;
char zEntry[30];
if( pgno<=0 || pgno>g.mxPage ) return;
a = fileRead((pgno-1)*g.pagesize, g.pagesize);
switch( a[hdr] ){
case 0: {
if( allZero(a, g.pagesize) ){
zType = "zeroed page";
}else if( parent<0 ){
return;
}else{
zType = "corrupt node";
}
break;
}
case 2: zType = "interior node of index"; break;
case 5: zType = "interior node of table"; break;
case 10: zType = "leaf of index"; break;
case 13: zType = "leaf of table"; break;
}
if( parent ){
page_usage_msg(pgno, "%s [%s], child %d of page %d",
zType, zName, idx, parent);
}else{
page_usage_msg(pgno, "root %s [%s]", zType, zName);
default: {
if( parent<0 ) return;
zType = "corrupt node";
}
}
nCell = a[hdr+3]*256 + a[hdr+4];
if( nCell==1 ){
sqlite3_snprintf(sizeof(zEntry),zEntry,"1 row");
}else{
sqlite3_snprintf(sizeof(zEntry),zEntry,"%d rows", nCell);
}
if( parent>0 ){
page_usage_msg(pgno, "%s [%s], child %d of page %d, %s",
zType, zName, idx, parent, zEntry);
}else if( parent==0 ){
page_usage_msg(pgno, "root %s [%s], %s", zType, zName, zEntry);
}else{
page_usage_msg(pgno, "orphaned %s, %s", zType, zEntry);
}
if( a[hdr]==2 || a[hdr]==5 ){
int cellstart = hdr+12;
unsigned int child;
@@ -988,6 +1021,7 @@ static void page_usage_report(const char *zPrg, const char *zDbName){
/* Print the report and free memory used */
for(i=1; i<=g.mxPage; i++){
if( zPageUse[i]==0 ) page_usage_btree(i, -1, 0, 0);
printf("%5d: %s\n", i, zPageUse[i] ? zPageUse[i] : "???");
sqlite3_free(zPageUse[i]);
}