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)
Commit
75dcdd0bdb6b235f1b73b4032f408e4f4f99ab62
Parent
e4bc6f12ead5d40…
1 file changed
+66
-21
+66
-21
| --- src/shell.c | ||
| +++ src/shell.c | ||
| @@ -460,10 +460,11 @@ | ||
| 460 | 460 | FILE *traceOut; /* Output for sqlite3_trace() */ |
| 461 | 461 | int nErr; /* Number of errors seen */ |
| 462 | 462 | int mode; /* An output mode setting */ |
| 463 | 463 | int writableSchema; /* True if PRAGMA writable_schema=ON */ |
| 464 | 464 | int showHeader; /* True to show column names in List or Column mode */ |
| 465 | + unsigned shellFlgs; /* Various flags */ | |
| 465 | 466 | char *zDestTable; /* Name of destination table when MODE_Insert */ |
| 466 | 467 | char separator[20]; /* Separator character for MODE_List */ |
| 467 | 468 | char newline[20]; /* Record separator in MODE_Csv */ |
| 468 | 469 | int colWidth[100]; /* Requested width of each column when in column mode*/ |
| 469 | 470 | int actualWidth[100]; /* Actual width of each column */ |
| @@ -479,10 +480,17 @@ | ||
| 479 | 480 | int *aiIndent; /* Array of indents used in MODE_Explain */ |
| 480 | 481 | int nIndent; /* Size of array aiIndent[] */ |
| 481 | 482 | int iIndent; /* Index of current op in aiIndent[] */ |
| 482 | 483 | }; |
| 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 | + | |
| 484 | 492 | /* |
| 485 | 493 | ** These are the allowed modes. |
| 486 | 494 | */ |
| 487 | 495 | #define MODE_Line 0 /* One column per line. Blank line between records */ |
| 488 | 496 | #define MODE_Column 1 /* One record per line in neat columns */ |
| @@ -1095,25 +1103,23 @@ | ||
| 1095 | 1103 | sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset); |
| 1096 | 1104 | fprintf(pArg->out, "Memory Used: %d (max %d) bytes\n", iCur, iHiwtr); |
| 1097 | 1105 | iHiwtr = iCur = -1; |
| 1098 | 1106 | sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset); |
| 1099 | 1107 | 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 | + } | |
| 1106 | 1113 | iHiwtr = iCur = -1; |
| 1107 | 1114 | sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset); |
| 1108 | 1115 | 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 | + } | |
| 1115 | 1121 | iHiwtr = iCur = -1; |
| 1116 | 1122 | sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset); |
| 1117 | 1123 | fprintf(pArg->out, "Number of Scratch Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr); |
| 1118 | 1124 | iHiwtr = iCur = -1; |
| 1119 | 1125 | sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset); |
| @@ -1130,19 +1136,21 @@ | ||
| 1130 | 1136 | fprintf(pArg->out, "Deepest Parser Stack: %d (max %d)\n", iCur, iHiwtr); |
| 1131 | 1137 | #endif |
| 1132 | 1138 | } |
| 1133 | 1139 | |
| 1134 | 1140 | 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 | + } | |
| 1144 | 1152 | iHiwtr = iCur = -1; |
| 1145 | 1153 | sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset); |
| 1146 | 1154 | fprintf(pArg->out, "Pager Heap Usage: %d bytes\n", iCur); iHiwtr = iCur = -1; |
| 1147 | 1155 | sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1); |
| 1148 | 1156 | fprintf(pArg->out, "Page cache hits: %d\n", iCur); |
| @@ -3777,16 +3785,19 @@ | ||
| 3777 | 3785 | " -help show this message\n" |
| 3778 | 3786 | " -html set output mode to HTML\n" |
| 3779 | 3787 | " -interactive force interactive I/O\n" |
| 3780 | 3788 | " -line set output mode to 'line'\n" |
| 3781 | 3789 | " -list set output mode to 'list'\n" |
| 3790 | + " -lookaside SIZE N use N entries of SZ bytes for lookaside memory\n" | |
| 3782 | 3791 | " -mmap N default mmap size set to N\n" |
| 3783 | 3792 | #ifdef SQLITE_ENABLE_MULTIPLEX |
| 3784 | 3793 | " -multiplex enable the multiplexor VFS\n" |
| 3785 | 3794 | #endif |
| 3786 | 3795 | " -newline SEP set newline character(s) for CSV\n" |
| 3787 | 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" | |
| 3788 | 3799 | " -separator SEP set output field separator. Default: '|'\n" |
| 3789 | 3800 | " -stats print memory stats before each finalize\n" |
| 3790 | 3801 | " -version show SQLite version\n" |
| 3791 | 3802 | " -vfs NAME use NAME as the default VFS\n" |
| 3792 | 3803 | #ifdef SQLITE_ENABLE_VFSTRACE |
| @@ -3813,10 +3824,11 @@ | ||
| 3813 | 3824 | memset(data, 0, sizeof(*data)); |
| 3814 | 3825 | data->mode = MODE_List; |
| 3815 | 3826 | memcpy(data->separator,"|", 2); |
| 3816 | 3827 | memcpy(data->newline,"\r\n", 3); |
| 3817 | 3828 | data->showHeader = 0; |
| 3829 | + data->shellFlgs = SHFLG_Lookaside; | |
| 3818 | 3830 | sqlite3_config(SQLITE_CONFIG_URI, 1); |
| 3819 | 3831 | sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data); |
| 3820 | 3832 | sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); |
| 3821 | 3833 | sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); |
| 3822 | 3834 | sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); |
| @@ -3926,10 +3938,37 @@ | ||
| 3926 | 3938 | zSize = cmdline_option_value(argc, argv, ++i); |
| 3927 | 3939 | szHeap = integerValue(zSize); |
| 3928 | 3940 | if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000; |
| 3929 | 3941 | sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64); |
| 3930 | 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; | |
| 3931 | 3970 | #ifdef SQLITE_ENABLE_VFSTRACE |
| 3932 | 3971 | }else if( strcmp(z,"-vfstrace")==0 ){ |
| 3933 | 3972 | extern int vfstrace_register( |
| 3934 | 3973 | const char *zTraceName, |
| 3935 | 3974 | const char *zOldVfsName, |
| @@ -4041,10 +4080,16 @@ | ||
| 4041 | 4080 | stdin_is_interactive = 1; |
| 4042 | 4081 | }else if( strcmp(z,"-batch")==0 ){ |
| 4043 | 4082 | stdin_is_interactive = 0; |
| 4044 | 4083 | }else if( strcmp(z,"-heap")==0 ){ |
| 4045 | 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; | |
| 4046 | 4091 | }else if( strcmp(z,"-mmap")==0 ){ |
| 4047 | 4092 | i++; |
| 4048 | 4093 | }else if( strcmp(z,"-vfs")==0 ){ |
| 4049 | 4094 | i++; |
| 4050 | 4095 | #ifdef SQLITE_ENABLE_VFSTRACE |
| 4051 | 4096 |
| --- 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 |