1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Add the "--newlines" option to the ".dump" command in the shell to disable

the newline escaping mechanism.

FossilOrigin-Name: bde431b1e332feaeb516dc46d180e2b2f42820c471feed7eda89452ada898dc9
This commit is contained in:
drh
2017-07-10 18:04:41 +00:00
parent 90e39ec349
commit dbc26722cd
4 changed files with 25 additions and 15 deletions

View File

@ -1,5 +1,5 @@
C When\smultiple\sconstraints\sneed\sto\sbe\sevaluated\sfor\sa\srow,\sdo\sany\sconstraints\nthat\sinvolve\scorrelated\ssubqueries\slast.\s\sHence,\sthe\spriority\sis\sindex-covered\nconstraints\sfirst,\scorrelated\ssubquery\sconstraints\slast,\sand\sall\sothers\sin\nthe\smiddle.\s\sThis\sis\sa\nfollow-on\sand\simprovement\sto\sthe\spush-down\soptimization\sof\scheck-in\s[d7bb79ed]. C Add\sthe\s"--newlines"\soption\sto\sthe\s".dump"\scommand\sin\sthe\sshell\sto\sdisable\nthe\snewline\sescaping\smechanism.
D 2017-07-10T17:00:31.898 D 2017-07-10T18:04:41.835
F Makefile.in 081e48dfe7f995d57ce1a88ddf4d2917b4349158648a6cd45b42beae30de3a12 F Makefile.in 081e48dfe7f995d57ce1a88ddf4d2917b4349158648a6cd45b42beae30de3a12
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 20850e3e8d4d4791e0531955852d768eb06f24138214870d543abb1a47346fba F Makefile.msc 20850e3e8d4d4791e0531955852d768eb06f24138214870d543abb1a47346fba
@ -449,7 +449,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
F src/resolve.c 6aa1fb1212e601f65b983ee1215d69a591986c8f97a3805c425c625a53839539 F src/resolve.c 6aa1fb1212e601f65b983ee1215d69a591986c8f97a3805c425c625a53839539
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
F src/select.c 6aa7e8ee53dcb9d0b77b05670bb44a1076d6747bc9b2c1f12a365b553ab6c828 F src/select.c 6aa7e8ee53dcb9d0b77b05670bb44a1076d6747bc9b2c1f12a365b553ab6c828
F src/shell.c a7067f647aef4b81569bbfd025f4fd120a4e7576a647d2aad05028eb50e50e48 F src/shell.c c042ed1f74e80097f7a322bb05457d65c20e1df43459f065f76ad886da7331e0
F src/sqlite.h.in 03a422ba13da1dfef7f1aaa1ba344acf18dc867112620b1fdb2a1426cabba634 F src/sqlite.h.in 03a422ba13da1dfef7f1aaa1ba344acf18dc867112620b1fdb2a1426cabba634
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28
@ -1170,7 +1170,7 @@ F test/sharedA.test 0cdf1a76dfa00e6beee66af5b534b1e8df2720f5
F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e
F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939 F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939
F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304
F test/shell1.test 76ae80ab24af6cdb994cff6df5f21f8cdbb0dc0f7229e937e8f1beb653611e26 F test/shell1.test f78ea0e2637ae9f497cb41206f6346f983052ffc7a359e664aaf6847fc704ea7
F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b
F test/shell3.test 9b95ba643eaa228376f06a898fb410ee9b6e57c1 F test/shell3.test 9b95ba643eaa228376f06a898fb410ee9b6e57c1
F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d
@ -1628,8 +1628,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P dc857a96b00f13ffdf77bc222bc5acbbe14a36ca51e5368b568b3177d1be737a 0ca7474f05e9f27f53f8c71f5a3ff99963ffef9be9c147869e096246d552d6f1 P c4cb90487f34937605732c3959891075e2aabfb0bd05e55c44565d65867093ea
R 6bf4c162edf7ff6903aaf314bb0ae2fb R 6d35197f305c27266246f32d8a4834d8
T +closed 0ca7474f05e9f27f53f8c71f5a3ff99963ffef9be9c147869e096246d552d6f1
U drh U drh
Z acda2b95cccbca8a55a4e5255bd0a430 Z a3a7e11cbaa224fa5a8714694bd756ab

View File

@ -1 +1 @@
c4cb90487f34937605732c3959891075e2aabfb0bd05e55c44565d65867093ea bde431b1e332feaeb516dc46d180e2b2f42820c471feed7eda89452ada898dc9

View File

@ -1523,8 +1523,9 @@ struct ShellState {
#define SHFLG_Lookaside 0x00000004 /* Lookaside memory is used */ #define SHFLG_Lookaside 0x00000004 /* Lookaside memory is used */
#define SHFLG_Backslash 0x00000008 /* The --backslash option is used */ #define SHFLG_Backslash 0x00000008 /* The --backslash option is used */
#define SHFLG_PreserveRowid 0x00000010 /* .dump preserves rowid values */ #define SHFLG_PreserveRowid 0x00000010 /* .dump preserves rowid values */
#define SHFLG_CountChanges 0x00000020 /* .changes setting */ #define SHFLG_Newlines 0x00000020 /* .dump --newline flag */
#define SHFLG_Echo 0x00000040 /* .echo or --echo setting */ #define SHFLG_CountChanges 0x00000040 /* .changes setting */
#define SHFLG_Echo 0x00000080 /* .echo or --echo setting */
/* /*
** Macros for testing and setting shellFlgs ** Macros for testing and setting shellFlgs
@ -2195,7 +2196,11 @@ static int shell_callback(
if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){ if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
utf8_printf(p->out,"NULL"); utf8_printf(p->out,"NULL");
}else if( aiType && aiType[i]==SQLITE_TEXT ){ }else if( aiType && aiType[i]==SQLITE_TEXT ){
output_quoted_escaped_string(p->out, azArg[i]); if( ShellHasFlag(p, SHFLG_Newlines) ){
output_quoted_string(p->out, azArg[i]);
}else{
output_quoted_escaped_string(p->out, azArg[i]);
}
}else if( aiType && aiType[i]==SQLITE_INTEGER ){ }else if( aiType && aiType[i]==SQLITE_INTEGER ){
utf8_printf(p->out,"%s", azArg[i]); utf8_printf(p->out,"%s", azArg[i]);
}else if( aiType && aiType[i]==SQLITE_FLOAT ){ }else if( aiType && aiType[i]==SQLITE_FLOAT ){
@ -2209,6 +2214,8 @@ static int shell_callback(
output_hex_blob(p->out, pBlob, nBlob); output_hex_blob(p->out, pBlob, nBlob);
}else if( isNumber(azArg[i], 0) ){ }else if( isNumber(azArg[i], 0) ){
utf8_printf(p->out,"%s", azArg[i]); utf8_printf(p->out,"%s", azArg[i]);
}else if( ShellHasFlag(p, SHFLG_Newlines) ){
output_quoted_string(p->out, azArg[i]);
}else{ }else{
output_quoted_escaped_string(p->out, azArg[i]); output_quoted_escaped_string(p->out, azArg[i]);
} }
@ -4930,7 +4937,7 @@ static int do_meta_command(char *zLine, ShellState *p){
const char *zLike = 0; const char *zLike = 0;
int i; int i;
int savedShowHeader = p->showHeader; int savedShowHeader = p->showHeader;
ShellClearFlag(p, SHFLG_PreserveRowid); ShellClearFlag(p, SHFLG_PreserveRowid|SHFLG_Newlines);
for(i=1; i<nArg; i++){ for(i=1; i<nArg; i++){
if( azArg[i][0]=='-' ){ if( azArg[i][0]=='-' ){
const char *z = azArg[i]+1; const char *z = azArg[i]+1;
@ -4945,13 +4952,17 @@ static int do_meta_command(char *zLine, ShellState *p){
ShellSetFlag(p, SHFLG_PreserveRowid); ShellSetFlag(p, SHFLG_PreserveRowid);
#endif #endif
}else }else
if( strcmp(z,"newlines")==0 ){
ShellSetFlag(p, SHFLG_Newlines);
}else
{ {
raw_printf(stderr, "Unknown option \"%s\" on \".dump\"\n", azArg[i]); raw_printf(stderr, "Unknown option \"%s\" on \".dump\"\n", azArg[i]);
rc = 1; rc = 1;
goto meta_command_exit; goto meta_command_exit;
} }
}else if( zLike ){ }else if( zLike ){
raw_printf(stderr, "Usage: .dump ?--preserve-rowids? ?LIKE-PATTERN?\n"); raw_printf(stderr, "Usage: .dump ?--preserve-rowids? "
"?--newlines? ?LIKE-PATTERN?\n");
rc = 1; rc = 1;
goto meta_command_exit; goto meta_command_exit;
}else{ }else{

View File

@ -300,7 +300,7 @@ do_test shell1-3.4.2 {
do_test shell1-3.4.3 { do_test shell1-3.4.3 {
# too many arguments # too many arguments
catchcmd "test.db" ".dump FOO BAD" catchcmd "test.db" ".dump FOO BAD"
} {1 {Usage: .dump ?--preserve-rowids? ?LIKE-PATTERN?}} } {1 {Usage: .dump ?--preserve-rowids? ?--newlines? ?LIKE-PATTERN?}}
# .echo ON|OFF Turn command echo on or off # .echo ON|OFF Turn command echo on or off
do_test shell1-3.5.1 { do_test shell1-3.5.1 {