CLI enhancements: Add the ".filectrl" command. Make the ".testctrl" command
visible to ".help". FossilOrigin-Name: 7b3a99fce8b4a757f2b2ef2f0b02d68566f2528d9ae1e30628522717f872466c
This commit is contained in:
parent
48646e497b
commit
d985f7260b
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sa\stest\scase\sfor\sthe\sunix\sSQLITE_FCNTL_CHUNK_SIZE\sfile-control.
|
||||
D 2019-06-05T13:14:19.264
|
||||
C CLI\senhancements:\s\sAdd\sthe\s".filectrl"\scommand.\s\sMake\sthe\s".testctrl"\scommand\nvisible\sto\s".help".
|
||||
D 2019-06-05T14:29:53.728
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -523,7 +523,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
|
||||
F src/resolve.c bae0a7562db77b02d87101b587819d5a5dcd8625e477d2d8a228a20bba4fead6
|
||||
F src/rowset.c d977b011993aaea002cab3e0bb2ce50cf346000dff94e944d547b989f4b1fe93
|
||||
F src/select.c 9187f2c65744e975b191ccee49946732ee922f8bf40da998b322aca1633405ea
|
||||
F src/shell.c.in 6a58aac018b61c6fc3184f431d3955b4738154b57a73e29a10b38a7cdec008ac
|
||||
F src/shell.c.in 9648bc2035a4dc2a380c863535893dc1d9f8a62bab57b6f2943e530aa62d04a8
|
||||
F src/sqlite.h.in d19c873a17c2effd4417f687fad942b6cc0ab0c64535f669cc2f22a5b05db23b
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h 9ecc93b8493bd20c0c07d52e2ac0ed8bab9b549c7f7955b59869597b650dd8b5
|
||||
@ -1830,7 +1830,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 4979f138e8c8bef7dd6b5921fb9ca9fea86bbf7ec1419934bb2d1a0d74e77183
|
||||
R 522b3167ef6a36c1a53d7505a94718e4
|
||||
U dan
|
||||
Z 3782252d7bfa19845f7bea0ebc102852
|
||||
P 3a477fd0c944440be03d23c667053b346c769c6a4f6ba1ef094b7581a08d7bd4
|
||||
R 177641f432f1c6b30cb4289f1dc2ad01
|
||||
U drh
|
||||
Z d627a69eae92e533d7c2a62b56c5ad5b
|
||||
|
@ -1 +1 @@
|
||||
3a477fd0c944440be03d23c667053b346c769c6a4f6ba1ef094b7581a08d7bd4
|
||||
7b3a99fce8b4a757f2b2ef2f0b02d68566f2528d9ae1e30628522717f872466c
|
123
src/shell.c.in
123
src/shell.c.in
@ -3510,6 +3510,8 @@ static const char *(azHelp[]) = {
|
||||
/* Because explain mode comes on automatically now, the ".explain" mode
|
||||
** is removed from the help screen. It is still supported for legacy, however */
|
||||
/*".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic",*/
|
||||
".filectrl CMD ... Run various sqlite3_file_control() operations",
|
||||
" Run \".filectrl\" with no arguments for details",
|
||||
".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
|
||||
".headers on|off Turn display of headers on or off",
|
||||
".help ?-all? ?PATTERN? Show help text for PATTERN",
|
||||
@ -3627,6 +3629,8 @@ static const char *(azHelp[]) = {
|
||||
#endif
|
||||
".tables ?TABLE? List names of tables matching LIKE pattern TABLE",
|
||||
".testcase NAME Begin redirecting output to 'testcase-out.txt'",
|
||||
".testctrl CMD ... Run various sqlite3_test_control() operations",
|
||||
" Run \".testctrl\" with no arguments for details",
|
||||
".timeout MS Try opening locked tables for MS milliseconds",
|
||||
".timer on|off Turn SQL timer on or off",
|
||||
#ifndef SQLITE_OMIT_TRACE
|
||||
@ -7277,6 +7281,125 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
}else
|
||||
#endif
|
||||
|
||||
if( c=='f' && strncmp(azArg[0], "filectrl", n)==0 ){
|
||||
static const struct {
|
||||
const char *zCtrlName; /* Name of a test-control option */
|
||||
int ctrlCode; /* Integer code for that option */
|
||||
const char *zUsage; /* Usage notes */
|
||||
} aCtrl[] = {
|
||||
{ "size_limit", SQLITE_FCNTL_SIZE_LIMIT, "[LIMIT]" },
|
||||
{ "chunk_size", SQLITE_FCNTL_CHUNK_SIZE, "SIZE" },
|
||||
/* { "win32_av_retry", SQLITE_FCNTL_WIN32_AV_RETRY, "COUNT DELAY" },*/
|
||||
{ "persist_wal", SQLITE_FCNTL_PERSIST_WAL, "[BOOLEAN]" },
|
||||
{ "psow", SQLITE_FCNTL_POWERSAFE_OVERWRITE, "[BOOLEAN]" },
|
||||
/* { "pragma", SQLITE_FCNTL_PRAGMA, "NAME ARG" },*/
|
||||
{ "tempfilename", SQLITE_FCNTL_TEMPFILENAME, "" },
|
||||
{ "has_moved", SQLITE_FCNTL_HAS_MOVED, "" },
|
||||
{ "lock_timeout", SQLITE_FCNTL_LOCK_TIMEOUT, "MILLISEC" },
|
||||
};
|
||||
int filectrl = -1;
|
||||
int iCtrl = -1;
|
||||
sqlite3_int64 iRes; /* Integer result to display if rc2==1 */
|
||||
int isOk = 0; /* 0: usage 1: %lld 2: no-result */
|
||||
int n2, i;
|
||||
const char *zCmd = 0;
|
||||
|
||||
open_db(p, 0);
|
||||
zCmd = nArg>=2 ? azArg[1] : "help";
|
||||
|
||||
/* The argument can optionally begin with "-" or "--" */
|
||||
if( zCmd[0]=='-' && zCmd[1] ){
|
||||
zCmd++;
|
||||
if( zCmd[0]=='-' && zCmd[1] ) zCmd++;
|
||||
}
|
||||
|
||||
/* --help lists all file-controls */
|
||||
if( strcmp(zCmd,"help")==0 ){
|
||||
utf8_printf(p->out, "Available file-controls:\n");
|
||||
for(i=0; i<ArraySize(aCtrl); i++){
|
||||
utf8_printf(p->out, " .filectrl %s %s\n",
|
||||
aCtrl[i].zCtrlName, aCtrl[i].zUsage);
|
||||
}
|
||||
rc = 1;
|
||||
goto meta_command_exit;
|
||||
}
|
||||
|
||||
/* convert filectrl text option to value. allow any unique prefix
|
||||
** of the option name, or a numerical value. */
|
||||
n2 = strlen30(zCmd);
|
||||
for(i=0; i<ArraySize(aCtrl); i++){
|
||||
if( strncmp(zCmd, aCtrl[i].zCtrlName, n2)==0 ){
|
||||
if( filectrl<0 ){
|
||||
filectrl = aCtrl[i].ctrlCode;
|
||||
iCtrl = i;
|
||||
}else{
|
||||
utf8_printf(stderr, "Error: ambiguous file-control: \"%s\"\n"
|
||||
"Use \".filectrl --help\" for help\n", zCmd);
|
||||
rc = 1;
|
||||
goto meta_command_exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( filectrl<0 ){
|
||||
utf8_printf(stderr,"Error: unknown file-control: %s\n"
|
||||
"Use \".filectrl --help\" for help\n", zCmd);
|
||||
}else{
|
||||
switch(filectrl){
|
||||
case SQLITE_FCNTL_SIZE_LIMIT: {
|
||||
if( nArg!=2 && nArg!=3 ) break;
|
||||
iRes = nArg==3 ? integerValue(azArg[2]) : -1;
|
||||
sqlite3_file_control(p->db, 0, SQLITE_FCNTL_SIZE_LIMIT, &iRes);
|
||||
isOk = 1;
|
||||
break;
|
||||
}
|
||||
case SQLITE_FCNTL_LOCK_TIMEOUT:
|
||||
case SQLITE_FCNTL_CHUNK_SIZE: {
|
||||
int x;
|
||||
if( nArg!=3 ) break;
|
||||
x = (int)integerValue(azArg[2]);
|
||||
sqlite3_file_control(p->db, 0, filectrl, &x);
|
||||
isOk = 2;
|
||||
break;
|
||||
}
|
||||
case SQLITE_FCNTL_PERSIST_WAL:
|
||||
case SQLITE_FCNTL_POWERSAFE_OVERWRITE: {
|
||||
int x;
|
||||
if( nArg!=2 && nArg!=3 ) break;
|
||||
x = nArg==3 ? booleanValue(azArg[2]) : -1;
|
||||
sqlite3_file_control(p->db, 0, filectrl, &x);
|
||||
iRes = x;
|
||||
isOk = 1;
|
||||
break;
|
||||
}
|
||||
case SQLITE_FCNTL_HAS_MOVED: {
|
||||
int x;
|
||||
if( nArg!=2 ) break;
|
||||
sqlite3_file_control(p->db, 0, filectrl, &x);
|
||||
iRes = x;
|
||||
isOk = 1;
|
||||
break;
|
||||
}
|
||||
case SQLITE_FCNTL_TEMPFILENAME: {
|
||||
char *z = 0;
|
||||
if( nArg!=2 ) break;
|
||||
sqlite3_file_control(p->db, 0, filectrl, &z);
|
||||
if( z ){
|
||||
utf8_printf(p->out, "%s\n", z);
|
||||
sqlite3_free(z);
|
||||
}
|
||||
isOk = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( isOk==0 && iCtrl>=0 ){
|
||||
utf8_printf(p->out, "Usage: .filectrl %s %s\n", zCmd,aCtrl[iCtrl].zUsage);
|
||||
rc = 1;
|
||||
}else if( isOk==1 ){
|
||||
raw_printf(p->out, "%lld\n", iRes);
|
||||
}
|
||||
}else
|
||||
|
||||
if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){
|
||||
ShellState data;
|
||||
char *zErrMsg = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user