Fossil SCM

Cherry-pick [http://www.sqlite.org/src/info/f61db04be4d7fb21b7f721647c37c45e283ffbea|f61db04be4]: In the command-line shell, added options --lookaside, --pagecache, and --scratch used to configure auxiliary memories (except from the change from SQLITE_CONFIG_SINGLETHREAD -> SQLITE_CONFIG_MULTITHREAD, because fossil doesn't use multiple threads)

jan.nijtmans 2014-08-31 08:42 UTC trunk
Commit 75dcdd0bdb6b235f1b73b4032f408e4f4f99ab62
1 file changed +66 -21
+66 -21
--- src/shell.c
+++ src/shell.c
@@ -460,10 +460,11 @@
460460
FILE *traceOut; /* Output for sqlite3_trace() */
461461
int nErr; /* Number of errors seen */
462462
int mode; /* An output mode setting */
463463
int writableSchema; /* True if PRAGMA writable_schema=ON */
464464
int showHeader; /* True to show column names in List or Column mode */
465
+ unsigned shellFlgs; /* Various flags */
465466
char *zDestTable; /* Name of destination table when MODE_Insert */
466467
char separator[20]; /* Separator character for MODE_List */
467468
char newline[20]; /* Record separator in MODE_Csv */
468469
int colWidth[100]; /* Requested width of each column when in column mode*/
469470
int actualWidth[100]; /* Actual width of each column */
@@ -479,10 +480,17 @@
479480
int *aiIndent; /* Array of indents used in MODE_Explain */
480481
int nIndent; /* Size of array aiIndent[] */
481482
int iIndent; /* Index of current op in aiIndent[] */
482483
};
483484
485
+/*
486
+** These are the allowed shellFlgs values
487
+*/
488
+#define SHFLG_Scratch 0x00001 /* The --scratch option is used */
489
+#define SHFLG_Pagecache 0x00002 /* The --pagecache option is used */
490
+#define SHFLG_Lookaside 0x00004 /* Lookaside memory is used */
491
+
484492
/*
485493
** These are the allowed modes.
486494
*/
487495
#define MODE_Line 0 /* One column per line. Blank line between records */
488496
#define MODE_Column 1 /* One record per line in neat columns */
@@ -1095,25 +1103,23 @@
10951103
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset);
10961104
fprintf(pArg->out, "Memory Used: %d (max %d) bytes\n", iCur, iHiwtr);
10971105
iHiwtr = iCur = -1;
10981106
sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset);
10991107
fprintf(pArg->out, "Number of Outstanding Allocations: %d (max %d)\n", iCur, iHiwtr);
1100
-/*
1101
-** Not currently used by the CLI.
1102
-** iHiwtr = iCur = -1;
1103
-** sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset);
1104
-** fprintf(pArg->out, "Number of Pcache Pages Used: %d (max %d) pages\n", iCur, iHiwtr);
1105
-*/
1108
+ if( pArg->shellFlgs & SHFLG_Pagecache ){
1109
+ iHiwtr = iCur = -1;
1110
+ sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset);
1111
+ fprintf(pArg->out, "Number of Pcache Pages Used: %d (max %d) pages\n", iCur, iHiwtr);
1112
+ }
11061113
iHiwtr = iCur = -1;
11071114
sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset);
11081115
fprintf(pArg->out, "Number of Pcache Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr);
1109
-/*
1110
-** Not currently used by the CLI.
1111
-** iHiwtr = iCur = -1;
1112
-** sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset);
1113
-** fprintf(pArg->out, "Number of Scratch Allocations Used: %d (max %d)\n", iCur, iHiwtr);
1114
-*/
1116
+ if( pArg->shellFlgs & SHFLG_Scratch ){
1117
+ iHiwtr = iCur = -1;
1118
+ sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset);
1119
+ fprintf(pArg->out, "Number of Scratch Allocations Used: %d (max %d)\n", iCur, iHiwtr);
1120
+ }
11151121
iHiwtr = iCur = -1;
11161122
sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset);
11171123
fprintf(pArg->out, "Number of Scratch Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr);
11181124
iHiwtr = iCur = -1;
11191125
sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset);
@@ -1130,19 +1136,21 @@
11301136
fprintf(pArg->out, "Deepest Parser Stack: %d (max %d)\n", iCur, iHiwtr);
11311137
#endif
11321138
}
11331139
11341140
if( pArg && pArg->out && db ){
1135
- iHiwtr = iCur = -1;
1136
- sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset);
1137
- fprintf(pArg->out, "Lookaside Slots Used: %d (max %d)\n", iCur, iHiwtr);
1138
- sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset);
1139
- fprintf(pArg->out, "Successful lookaside attempts: %d\n", iHiwtr);
1140
- sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset);
1141
- fprintf(pArg->out, "Lookaside failures due to size: %d\n", iHiwtr);
1142
- sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset);
1143
- fprintf(pArg->out, "Lookaside failures due to OOM: %d\n", iHiwtr);
1141
+ if( pArg->shellFlgs & SHFLG_Lookaside ){
1142
+ iHiwtr = iCur = -1;
1143
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset);
1144
+ fprintf(pArg->out, "Lookaside Slots Used: %d (max %d)\n", iCur, iHiwtr);
1145
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset);
1146
+ fprintf(pArg->out, "Successful lookaside attempts: %d\n", iHiwtr);
1147
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset);
1148
+ fprintf(pArg->out, "Lookaside failures due to size: %d\n", iHiwtr);
1149
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset);
1150
+ fprintf(pArg->out, "Lookaside failures due to OOM: %d\n", iHiwtr);
1151
+ }
11441152
iHiwtr = iCur = -1;
11451153
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset);
11461154
fprintf(pArg->out, "Pager Heap Usage: %d bytes\n", iCur); iHiwtr = iCur = -1;
11471155
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);
11481156
fprintf(pArg->out, "Page cache hits: %d\n", iCur);
@@ -3777,16 +3785,19 @@
37773785
" -help show this message\n"
37783786
" -html set output mode to HTML\n"
37793787
" -interactive force interactive I/O\n"
37803788
" -line set output mode to 'line'\n"
37813789
" -list set output mode to 'list'\n"
3790
+ " -lookaside SIZE N use N entries of SZ bytes for lookaside memory\n"
37823791
" -mmap N default mmap size set to N\n"
37833792
#ifdef SQLITE_ENABLE_MULTIPLEX
37843793
" -multiplex enable the multiplexor VFS\n"
37853794
#endif
37863795
" -newline SEP set newline character(s) for CSV\n"
37873796
" -nullvalue TEXT set text string for NULL values. Default ''\n"
3797
+ " -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n"
3798
+ " -scratch SIZE N use N slots of SZ bytes each for scratch memory\n"
37883799
" -separator SEP set output field separator. Default: '|'\n"
37893800
" -stats print memory stats before each finalize\n"
37903801
" -version show SQLite version\n"
37913802
" -vfs NAME use NAME as the default VFS\n"
37923803
#ifdef SQLITE_ENABLE_VFSTRACE
@@ -3813,10 +3824,11 @@
38133824
memset(data, 0, sizeof(*data));
38143825
data->mode = MODE_List;
38153826
memcpy(data->separator,"|", 2);
38163827
memcpy(data->newline,"\r\n", 3);
38173828
data->showHeader = 0;
3829
+ data->shellFlgs = SHFLG_Lookaside;
38183830
sqlite3_config(SQLITE_CONFIG_URI, 1);
38193831
sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);
38203832
sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
38213833
sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> ");
38223834
sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
@@ -3926,10 +3938,37 @@
39263938
zSize = cmdline_option_value(argc, argv, ++i);
39273939
szHeap = integerValue(zSize);
39283940
if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000;
39293941
sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);
39303942
#endif
3943
+ }else if( strcmp(z,"-scratch")==0 ){
3944
+ int n, sz;
3945
+ sz = integerValue(cmdline_option_value(argc,argv,++i));
3946
+ if( sz>400000 ) sz = 400000;
3947
+ if( sz<2500 ) sz = 2500;
3948
+ n = integerValue(cmdline_option_value(argc,argv,++i));
3949
+ if( n>10 ) n = 10;
3950
+ if( n<1 ) n = 1;
3951
+ sqlite3_config(SQLITE_CONFIG_SCRATCH, malloc(n*sz+1), sz, n);
3952
+ data.shellFlgs |= SHFLG_Scratch;
3953
+ }else if( strcmp(z,"-pagecache")==0 ){
3954
+ int n, sz;
3955
+ sz = integerValue(cmdline_option_value(argc,argv,++i));
3956
+ if( sz>70000 ) sz = 70000;
3957
+ if( sz<800 ) sz = 800;
3958
+ n = integerValue(cmdline_option_value(argc,argv,++i));
3959
+ if( n<10 ) n = 10;
3960
+ sqlite3_config(SQLITE_CONFIG_PAGECACHE, malloc(n*sz+1), sz, n);
3961
+ data.shellFlgs |= SHFLG_Pagecache;
3962
+ }else if( strcmp(z,"-lookaside")==0 ){
3963
+ int n, sz;
3964
+ sz = integerValue(cmdline_option_value(argc,argv,++i));
3965
+ if( sz<0 ) sz = 0;
3966
+ n = integerValue(cmdline_option_value(argc,argv,++i));
3967
+ if( n<0 ) n = 0;
3968
+ sqlite3_config(SQLITE_CONFIG_LOOKASIDE, sz, n);
3969
+ if( sz*n==0 ) data.shellFlgs &= ~SHFLG_Lookaside;
39313970
#ifdef SQLITE_ENABLE_VFSTRACE
39323971
}else if( strcmp(z,"-vfstrace")==0 ){
39333972
extern int vfstrace_register(
39343973
const char *zTraceName,
39353974
const char *zOldVfsName,
@@ -4041,10 +4080,16 @@
40414080
stdin_is_interactive = 1;
40424081
}else if( strcmp(z,"-batch")==0 ){
40434082
stdin_is_interactive = 0;
40444083
}else if( strcmp(z,"-heap")==0 ){
40454084
i++;
4085
+ }else if( strcmp(z,"-scratch")==0 ){
4086
+ i+=2;
4087
+ }else if( strcmp(z,"-pagecache")==0 ){
4088
+ i+=2;
4089
+ }else if( strcmp(z,"-lookaside")==0 ){
4090
+ i+=2;
40464091
}else if( strcmp(z,"-mmap")==0 ){
40474092
i++;
40484093
}else if( strcmp(z,"-vfs")==0 ){
40494094
i++;
40504095
#ifdef SQLITE_ENABLE_VFSTRACE
40514096
--- src/shell.c
+++ src/shell.c
@@ -460,10 +460,11 @@
460 FILE *traceOut; /* Output for sqlite3_trace() */
461 int nErr; /* Number of errors seen */
462 int mode; /* An output mode setting */
463 int writableSchema; /* True if PRAGMA writable_schema=ON */
464 int showHeader; /* True to show column names in List or Column mode */
 
465 char *zDestTable; /* Name of destination table when MODE_Insert */
466 char separator[20]; /* Separator character for MODE_List */
467 char newline[20]; /* Record separator in MODE_Csv */
468 int colWidth[100]; /* Requested width of each column when in column mode*/
469 int actualWidth[100]; /* Actual width of each column */
@@ -479,10 +480,17 @@
479 int *aiIndent; /* Array of indents used in MODE_Explain */
480 int nIndent; /* Size of array aiIndent[] */
481 int iIndent; /* Index of current op in aiIndent[] */
482 };
483
 
 
 
 
 
 
 
484 /*
485 ** These are the allowed modes.
486 */
487 #define MODE_Line 0 /* One column per line. Blank line between records */
488 #define MODE_Column 1 /* One record per line in neat columns */
@@ -1095,25 +1103,23 @@
1095 sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset);
1096 fprintf(pArg->out, "Memory Used: %d (max %d) bytes\n", iCur, iHiwtr);
1097 iHiwtr = iCur = -1;
1098 sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset);
1099 fprintf(pArg->out, "Number of Outstanding Allocations: %d (max %d)\n", iCur, iHiwtr);
1100 /*
1101 ** Not currently used by the CLI.
1102 ** iHiwtr = iCur = -1;
1103 ** sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset);
1104 ** fprintf(pArg->out, "Number of Pcache Pages Used: %d (max %d) pages\n", iCur, iHiwtr);
1105 */
1106 iHiwtr = iCur = -1;
1107 sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset);
1108 fprintf(pArg->out, "Number of Pcache Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr);
1109 /*
1110 ** Not currently used by the CLI.
1111 ** iHiwtr = iCur = -1;
1112 ** sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset);
1113 ** fprintf(pArg->out, "Number of Scratch Allocations Used: %d (max %d)\n", iCur, iHiwtr);
1114 */
1115 iHiwtr = iCur = -1;
1116 sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset);
1117 fprintf(pArg->out, "Number of Scratch Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr);
1118 iHiwtr = iCur = -1;
1119 sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset);
@@ -1130,19 +1136,21 @@
1130 fprintf(pArg->out, "Deepest Parser Stack: %d (max %d)\n", iCur, iHiwtr);
1131 #endif
1132 }
1133
1134 if( pArg && pArg->out && db ){
1135 iHiwtr = iCur = -1;
1136 sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset);
1137 fprintf(pArg->out, "Lookaside Slots Used: %d (max %d)\n", iCur, iHiwtr);
1138 sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset);
1139 fprintf(pArg->out, "Successful lookaside attempts: %d\n", iHiwtr);
1140 sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset);
1141 fprintf(pArg->out, "Lookaside failures due to size: %d\n", iHiwtr);
1142 sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset);
1143 fprintf(pArg->out, "Lookaside failures due to OOM: %d\n", iHiwtr);
 
 
1144 iHiwtr = iCur = -1;
1145 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset);
1146 fprintf(pArg->out, "Pager Heap Usage: %d bytes\n", iCur); iHiwtr = iCur = -1;
1147 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);
1148 fprintf(pArg->out, "Page cache hits: %d\n", iCur);
@@ -3777,16 +3785,19 @@
3777 " -help show this message\n"
3778 " -html set output mode to HTML\n"
3779 " -interactive force interactive I/O\n"
3780 " -line set output mode to 'line'\n"
3781 " -list set output mode to 'list'\n"
 
3782 " -mmap N default mmap size set to N\n"
3783 #ifdef SQLITE_ENABLE_MULTIPLEX
3784 " -multiplex enable the multiplexor VFS\n"
3785 #endif
3786 " -newline SEP set newline character(s) for CSV\n"
3787 " -nullvalue TEXT set text string for NULL values. Default ''\n"
 
 
3788 " -separator SEP set output field separator. Default: '|'\n"
3789 " -stats print memory stats before each finalize\n"
3790 " -version show SQLite version\n"
3791 " -vfs NAME use NAME as the default VFS\n"
3792 #ifdef SQLITE_ENABLE_VFSTRACE
@@ -3813,10 +3824,11 @@
3813 memset(data, 0, sizeof(*data));
3814 data->mode = MODE_List;
3815 memcpy(data->separator,"|", 2);
3816 memcpy(data->newline,"\r\n", 3);
3817 data->showHeader = 0;
 
3818 sqlite3_config(SQLITE_CONFIG_URI, 1);
3819 sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);
3820 sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
3821 sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> ");
3822 sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
@@ -3926,10 +3938,37 @@
3926 zSize = cmdline_option_value(argc, argv, ++i);
3927 szHeap = integerValue(zSize);
3928 if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000;
3929 sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);
3930 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3931 #ifdef SQLITE_ENABLE_VFSTRACE
3932 }else if( strcmp(z,"-vfstrace")==0 ){
3933 extern int vfstrace_register(
3934 const char *zTraceName,
3935 const char *zOldVfsName,
@@ -4041,10 +4080,16 @@
4041 stdin_is_interactive = 1;
4042 }else if( strcmp(z,"-batch")==0 ){
4043 stdin_is_interactive = 0;
4044 }else if( strcmp(z,"-heap")==0 ){
4045 i++;
 
 
 
 
 
 
4046 }else if( strcmp(z,"-mmap")==0 ){
4047 i++;
4048 }else if( strcmp(z,"-vfs")==0 ){
4049 i++;
4050 #ifdef SQLITE_ENABLE_VFSTRACE
4051
--- src/shell.c
+++ src/shell.c
@@ -460,10 +460,11 @@
460 FILE *traceOut; /* Output for sqlite3_trace() */
461 int nErr; /* Number of errors seen */
462 int mode; /* An output mode setting */
463 int writableSchema; /* True if PRAGMA writable_schema=ON */
464 int showHeader; /* True to show column names in List or Column mode */
465 unsigned shellFlgs; /* Various flags */
466 char *zDestTable; /* Name of destination table when MODE_Insert */
467 char separator[20]; /* Separator character for MODE_List */
468 char newline[20]; /* Record separator in MODE_Csv */
469 int colWidth[100]; /* Requested width of each column when in column mode*/
470 int actualWidth[100]; /* Actual width of each column */
@@ -479,10 +480,17 @@
480 int *aiIndent; /* Array of indents used in MODE_Explain */
481 int nIndent; /* Size of array aiIndent[] */
482 int iIndent; /* Index of current op in aiIndent[] */
483 };
484
485 /*
486 ** These are the allowed shellFlgs values
487 */
488 #define SHFLG_Scratch 0x00001 /* The --scratch option is used */
489 #define SHFLG_Pagecache 0x00002 /* The --pagecache option is used */
490 #define SHFLG_Lookaside 0x00004 /* Lookaside memory is used */
491
492 /*
493 ** These are the allowed modes.
494 */
495 #define MODE_Line 0 /* One column per line. Blank line between records */
496 #define MODE_Column 1 /* One record per line in neat columns */
@@ -1095,25 +1103,23 @@
1103 sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset);
1104 fprintf(pArg->out, "Memory Used: %d (max %d) bytes\n", iCur, iHiwtr);
1105 iHiwtr = iCur = -1;
1106 sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset);
1107 fprintf(pArg->out, "Number of Outstanding Allocations: %d (max %d)\n", iCur, iHiwtr);
1108 if( pArg->shellFlgs & SHFLG_Pagecache ){
1109 iHiwtr = iCur = -1;
1110 sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset);
1111 fprintf(pArg->out, "Number of Pcache Pages Used: %d (max %d) pages\n", iCur, iHiwtr);
1112 }
 
1113 iHiwtr = iCur = -1;
1114 sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset);
1115 fprintf(pArg->out, "Number of Pcache Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr);
1116 if( pArg->shellFlgs & SHFLG_Scratch ){
1117 iHiwtr = iCur = -1;
1118 sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset);
1119 fprintf(pArg->out, "Number of Scratch Allocations Used: %d (max %d)\n", iCur, iHiwtr);
1120 }
 
1121 iHiwtr = iCur = -1;
1122 sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset);
1123 fprintf(pArg->out, "Number of Scratch Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr);
1124 iHiwtr = iCur = -1;
1125 sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset);
@@ -1130,19 +1136,21 @@
1136 fprintf(pArg->out, "Deepest Parser Stack: %d (max %d)\n", iCur, iHiwtr);
1137 #endif
1138 }
1139
1140 if( pArg && pArg->out && db ){
1141 if( pArg->shellFlgs & SHFLG_Lookaside ){
1142 iHiwtr = iCur = -1;
1143 sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset);
1144 fprintf(pArg->out, "Lookaside Slots Used: %d (max %d)\n", iCur, iHiwtr);
1145 sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset);
1146 fprintf(pArg->out, "Successful lookaside attempts: %d\n", iHiwtr);
1147 sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset);
1148 fprintf(pArg->out, "Lookaside failures due to size: %d\n", iHiwtr);
1149 sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset);
1150 fprintf(pArg->out, "Lookaside failures due to OOM: %d\n", iHiwtr);
1151 }
1152 iHiwtr = iCur = -1;
1153 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset);
1154 fprintf(pArg->out, "Pager Heap Usage: %d bytes\n", iCur); iHiwtr = iCur = -1;
1155 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);
1156 fprintf(pArg->out, "Page cache hits: %d\n", iCur);
@@ -3777,16 +3785,19 @@
3785 " -help show this message\n"
3786 " -html set output mode to HTML\n"
3787 " -interactive force interactive I/O\n"
3788 " -line set output mode to 'line'\n"
3789 " -list set output mode to 'list'\n"
3790 " -lookaside SIZE N use N entries of SZ bytes for lookaside memory\n"
3791 " -mmap N default mmap size set to N\n"
3792 #ifdef SQLITE_ENABLE_MULTIPLEX
3793 " -multiplex enable the multiplexor VFS\n"
3794 #endif
3795 " -newline SEP set newline character(s) for CSV\n"
3796 " -nullvalue TEXT set text string for NULL values. Default ''\n"
3797 " -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n"
3798 " -scratch SIZE N use N slots of SZ bytes each for scratch memory\n"
3799 " -separator SEP set output field separator. Default: '|'\n"
3800 " -stats print memory stats before each finalize\n"
3801 " -version show SQLite version\n"
3802 " -vfs NAME use NAME as the default VFS\n"
3803 #ifdef SQLITE_ENABLE_VFSTRACE
@@ -3813,10 +3824,11 @@
3824 memset(data, 0, sizeof(*data));
3825 data->mode = MODE_List;
3826 memcpy(data->separator,"|", 2);
3827 memcpy(data->newline,"\r\n", 3);
3828 data->showHeader = 0;
3829 data->shellFlgs = SHFLG_Lookaside;
3830 sqlite3_config(SQLITE_CONFIG_URI, 1);
3831 sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);
3832 sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
3833 sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> ");
3834 sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
@@ -3926,10 +3938,37 @@
3938 zSize = cmdline_option_value(argc, argv, ++i);
3939 szHeap = integerValue(zSize);
3940 if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000;
3941 sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);
3942 #endif
3943 }else if( strcmp(z,"-scratch")==0 ){
3944 int n, sz;
3945 sz = integerValue(cmdline_option_value(argc,argv,++i));
3946 if( sz>400000 ) sz = 400000;
3947 if( sz<2500 ) sz = 2500;
3948 n = integerValue(cmdline_option_value(argc,argv,++i));
3949 if( n>10 ) n = 10;
3950 if( n<1 ) n = 1;
3951 sqlite3_config(SQLITE_CONFIG_SCRATCH, malloc(n*sz+1), sz, n);
3952 data.shellFlgs |= SHFLG_Scratch;
3953 }else if( strcmp(z,"-pagecache")==0 ){
3954 int n, sz;
3955 sz = integerValue(cmdline_option_value(argc,argv,++i));
3956 if( sz>70000 ) sz = 70000;
3957 if( sz<800 ) sz = 800;
3958 n = integerValue(cmdline_option_value(argc,argv,++i));
3959 if( n<10 ) n = 10;
3960 sqlite3_config(SQLITE_CONFIG_PAGECACHE, malloc(n*sz+1), sz, n);
3961 data.shellFlgs |= SHFLG_Pagecache;
3962 }else if( strcmp(z,"-lookaside")==0 ){
3963 int n, sz;
3964 sz = integerValue(cmdline_option_value(argc,argv,++i));
3965 if( sz<0 ) sz = 0;
3966 n = integerValue(cmdline_option_value(argc,argv,++i));
3967 if( n<0 ) n = 0;
3968 sqlite3_config(SQLITE_CONFIG_LOOKASIDE, sz, n);
3969 if( sz*n==0 ) data.shellFlgs &= ~SHFLG_Lookaside;
3970 #ifdef SQLITE_ENABLE_VFSTRACE
3971 }else if( strcmp(z,"-vfstrace")==0 ){
3972 extern int vfstrace_register(
3973 const char *zTraceName,
3974 const char *zOldVfsName,
@@ -4041,10 +4080,16 @@
4080 stdin_is_interactive = 1;
4081 }else if( strcmp(z,"-batch")==0 ){
4082 stdin_is_interactive = 0;
4083 }else if( strcmp(z,"-heap")==0 ){
4084 i++;
4085 }else if( strcmp(z,"-scratch")==0 ){
4086 i+=2;
4087 }else if( strcmp(z,"-pagecache")==0 ){
4088 i+=2;
4089 }else if( strcmp(z,"-lookaside")==0 ){
4090 i+=2;
4091 }else if( strcmp(z,"-mmap")==0 ){
4092 i++;
4093 }else if( strcmp(z,"-vfs")==0 ){
4094 i++;
4095 #ifdef SQLITE_ENABLE_VFSTRACE
4096

Keyboard Shortcuts

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