mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-06 15:49:35 +03:00
Command-line shell enhancements: Added the ".print" command. Enhanced
the ".width" command so that negative widths will right-justify. FossilOrigin-Name: a1d8269da3868e41a6603c1a683e324fe21fb317
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Consolidate\smore\sof\sthe\sDISTINCT\sprocessing\slogic\sinto\sa\ssingle\sspot\sin\sthe\ncode.\s\sReduce\sthe\snumber\sof\sOP_Column\soperations\sneeded\sto\sperform\sa\nWHERE_DISTINCT_ORDERED.
|
C Command-line\sshell\senhancements:\s\sAdded\sthe\s".print"\scommand.\s\sEnhanced\nthe\s".width"\scommand\sso\sthat\snegative\swidths\swill\sright-justify.
|
||||||
D 2012-09-21T00:04:28.345
|
D 2012-09-21T13:40:02.707
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb
|
F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -175,7 +175,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
|
|||||||
F src/resolve.c 9e28280ec98035f31900fdd1db01f86f68ca6c32
|
F src/resolve.c 9e28280ec98035f31900fdd1db01f86f68ca6c32
|
||||||
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
|
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
|
||||||
F src/select.c c2a83ada835d3554a4d724c5358d4475aa7e1e77
|
F src/select.c c2a83ada835d3554a4d724c5358d4475aa7e1e77
|
||||||
F src/shell.c 87953c5d9c73d9494db97d1607e2e2280418f261
|
F src/shell.c f41fbf4c21003a37d69b863d3c3c562a3db180a6
|
||||||
F src/sqlite.h.in c76c38f9635590ff5844684a7976843878327137
|
F src/sqlite.h.in c76c38f9635590ff5844684a7976843878327137
|
||||||
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
|
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
|
||||||
F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477
|
F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477
|
||||||
@@ -702,7 +702,7 @@ F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e
|
|||||||
F test/shared8.test b27befbefbe7f4517f1d6b7ff8f64a41ec74165d
|
F test/shared8.test b27befbefbe7f4517f1d6b7ff8f64a41ec74165d
|
||||||
F test/shared_err.test 91e26ec4f3fbe07951967955585137e2f18993de
|
F test/shared_err.test 91e26ec4f3fbe07951967955585137e2f18993de
|
||||||
F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf
|
F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf
|
||||||
F test/shell1.test 9895ee3013742a02e5afd8d77793729967ffd195
|
F test/shell1.test 272384163432c0efd2c6817396beb0d119565d53
|
||||||
F test/shell2.test 037d6ad16e873354195d30bb2dc4b5321788154a
|
F test/shell2.test 037d6ad16e873354195d30bb2dc4b5321788154a
|
||||||
F test/shell3.test 9196c42772d575685e722c92b4b39053c6ebba59
|
F test/shell3.test 9196c42772d575685e722c92b4b39053c6ebba59
|
||||||
F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9
|
F test/shell4.test aa4eef8118b412d1a01477a53426ece169ea86a9
|
||||||
@@ -1016,7 +1016,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||||
F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9
|
F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9
|
||||||
P cf40b7b5ebdacc3215d769aadacce8c9e7e9dfbb
|
P 79e922f7ae29bbe06d639d648fbd72523cf9a28e
|
||||||
R d02ff4711c6f63d54e76f1ced6a5b15a
|
R e0319168dcbdc9e6aaca1f64320b5398
|
||||||
U drh
|
U drh
|
||||||
Z 9a19995b7c09e7ae5080d30ca61a0cd3
|
Z e9c67fc218434dfa019e9bea621d5ceb
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
79e922f7ae29bbe06d639d648fbd72523cf9a28e
|
a1d8269da3868e41a6603c1a683e324fe21fb317
|
||||||
30
src/shell.c
30
src/shell.c
@@ -696,7 +696,7 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
|
|||||||
}else{
|
}else{
|
||||||
w = 0;
|
w = 0;
|
||||||
}
|
}
|
||||||
if( w<=0 ){
|
if( w==0 ){
|
||||||
w = strlen30(azCol[i] ? azCol[i] : "");
|
w = strlen30(azCol[i] ? azCol[i] : "");
|
||||||
if( w<10 ) w = 10;
|
if( w<10 ) w = 10;
|
||||||
n = strlen30(azArg && azArg[i] ? azArg[i] : p->nullvalue);
|
n = strlen30(azArg && azArg[i] ? azArg[i] : p->nullvalue);
|
||||||
@@ -706,7 +706,11 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
|
|||||||
p->actualWidth[i] = w;
|
p->actualWidth[i] = w;
|
||||||
}
|
}
|
||||||
if( p->showHeader ){
|
if( p->showHeader ){
|
||||||
fprintf(p->out,"%-*.*s%s",w,w,azCol[i], i==nArg-1 ? "\n": " ");
|
if( w<0 ){
|
||||||
|
fprintf(p->out,"%*.*s%s",-w,-w,azCol[i], i==nArg-1 ? "\n": " ");
|
||||||
|
}else{
|
||||||
|
fprintf(p->out,"%-*.*s%s",w,w,azCol[i], i==nArg-1 ? "\n": " ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( p->showHeader ){
|
if( p->showHeader ){
|
||||||
@@ -714,6 +718,7 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
|
|||||||
int w;
|
int w;
|
||||||
if( i<ArraySize(p->actualWidth) ){
|
if( i<ArraySize(p->actualWidth) ){
|
||||||
w = p->actualWidth[i];
|
w = p->actualWidth[i];
|
||||||
|
if( w<0 ) w = -w;
|
||||||
}else{
|
}else{
|
||||||
w = 10;
|
w = 10;
|
||||||
}
|
}
|
||||||
@@ -735,8 +740,13 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
|
|||||||
strlen30(azArg[i])>w ){
|
strlen30(azArg[i])>w ){
|
||||||
w = strlen30(azArg[i]);
|
w = strlen30(azArg[i]);
|
||||||
}
|
}
|
||||||
fprintf(p->out,"%-*.*s%s",w,w,
|
if( w<0 ){
|
||||||
azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": " ");
|
fprintf(p->out,"%*.*s%s",-w,-w,
|
||||||
|
azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": " ");
|
||||||
|
}else{
|
||||||
|
fprintf(p->out,"%-*.*s%s",w,w,
|
||||||
|
azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": " ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1416,9 +1426,10 @@ static char zHelp[] =
|
|||||||
" list Values delimited by .separator string\n"
|
" list Values delimited by .separator string\n"
|
||||||
" tabs Tab-separated values\n"
|
" tabs Tab-separated values\n"
|
||||||
" tcl TCL list elements\n"
|
" tcl TCL list elements\n"
|
||||||
".nullvalue STRING Print STRING in place of NULL values\n"
|
".nullvalue STRING Use STRING in place of NULL values\n"
|
||||||
".output FILENAME Send output to FILENAME\n"
|
".output FILENAME Send output to FILENAME\n"
|
||||||
".output stdout Send output to the screen\n"
|
".output stdout Send output to the screen\n"
|
||||||
|
".print STRING... Print literal STRING\n"
|
||||||
".prompt MAIN CONTINUE Replace the standard prompts\n"
|
".prompt MAIN CONTINUE Replace the standard prompts\n"
|
||||||
".quit Exit this program\n"
|
".quit Exit this program\n"
|
||||||
".read FILENAME Execute SQL in FILENAME\n"
|
".read FILENAME Execute SQL in FILENAME\n"
|
||||||
@@ -2070,6 +2081,15 @@ static int do_meta_command(char *zLine, struct callback_data *p){
|
|||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
|
|
||||||
|
if( c=='p' && n>=3 && strncmp(azArg[0], "print", n)==0 ){
|
||||||
|
int i;
|
||||||
|
for(i=1; i<nArg; i++){
|
||||||
|
if( i>1 ) fprintf(p->out, " ");
|
||||||
|
fprintf(p->out, "%s", azArg[i]);
|
||||||
|
}
|
||||||
|
fprintf(p->out, "\n");
|
||||||
|
}else
|
||||||
|
|
||||||
if( c=='p' && strncmp(azArg[0], "prompt", n)==0 && (nArg==2 || nArg==3)){
|
if( c=='p' && strncmp(azArg[0], "prompt", n)==0 && (nArg==2 || nArg==3)){
|
||||||
if( nArg >= 2) {
|
if( nArg >= 2) {
|
||||||
strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);
|
strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);
|
||||||
|
|||||||
@@ -680,6 +680,15 @@ do_test shell1-3.26.4 {
|
|||||||
catchcmd "test.db" ".width 1 1"
|
catchcmd "test.db" ".width 1 1"
|
||||||
# this should be treated the same as a '1' width for col 1 and 2
|
# this should be treated the same as a '1' width for col 1 and 2
|
||||||
} {0 {}}
|
} {0 {}}
|
||||||
|
do_test shell1-3.26.5 {
|
||||||
|
catchcmd "test.db" ".mode column\n.width 10 -10\nSELECT 'abcdefg', 123456;"
|
||||||
|
# this should be treated the same as a '1' width for col 1 and 2
|
||||||
|
} {0 {abcdefg 123456}}
|
||||||
|
do_test shell1-3.26.6 {
|
||||||
|
catchcmd "test.db" ".mode column\n.width -10 10\nSELECT 'abcdefg', 123456;"
|
||||||
|
# this should be treated the same as a '1' width for col 1 and 2
|
||||||
|
} {0 { abcdefg 123456 }}
|
||||||
|
|
||||||
|
|
||||||
# .timer ON|OFF Turn the CPU timer measurement on or off
|
# .timer ON|OFF Turn the CPU timer measurement on or off
|
||||||
do_test shell1-3.27.1 {
|
do_test shell1-3.27.1 {
|
||||||
@@ -701,6 +710,10 @@ do_test shell1-3-28.1 {
|
|||||||
".log stdout\nSELECT coalesce(sqlite_log(123,'hello'),'456');"
|
".log stdout\nSELECT coalesce(sqlite_log(123,'hello'),'456');"
|
||||||
} "0 {(123) hello\n456}"
|
} "0 {(123) hello\n456}"
|
||||||
|
|
||||||
|
do_test shell1-3-29.1 {
|
||||||
|
catchcmd "test.db" ".print this is a test"
|
||||||
|
} {0 {this is a test}}
|
||||||
|
|
||||||
# Test the output of the ".dump" command
|
# Test the output of the ".dump" command
|
||||||
#
|
#
|
||||||
do_test shell1-4.1 {
|
do_test shell1-4.1 {
|
||||||
|
|||||||
Reference in New Issue
Block a user