Add ".mode quote" to the command-line shell.
FossilOrigin-Name: c4f5fa78cd8207ce1e46e32e632b8f6ee86047e1
This commit is contained in:
parent
e24452edef
commit
41f5f6ec2c
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Avoid\susing\sthe\s"direct\soverflow\sread"\soptimization\sto\sread\slarge\sblobs\sif\sthe\npager\slayer\shas\sa\swal\sfile\sopen\s-\seven\sif\sthe\sdatabase\sheader\sindicates\sthat\nthe\sdb\sis\snot\sa\swal\sdatabase.
|
||||
D 2016-10-21T10:49:39.630
|
||||
C Add\s".mode\squote"\sto\sthe\scommand-line\sshell.
|
||||
D 2016-10-21T17:39:30.026
|
||||
F Makefile.in 6fd48ffcf7c2deea7499062d1f3747f986c19678
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc 5151cc64c4c05f3455f4f692ad11410a810d937f
|
||||
@ -388,7 +388,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
|
||||
F src/resolve.c 3fac1b2737ea5a724f20b921ac7e259c9be2100b
|
||||
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
|
||||
F src/select.c ea3af83e2d0f245fef81ea4cf04cb730ce67f722
|
||||
F src/shell.c b80396d2fadce4681397707e30078bf416e1dec2
|
||||
F src/shell.c f0e8b54c58a8a13cc046f5af6d72de7e0a118a2b
|
||||
F src/sqlite.h.in 7ef021d74ac7d4004c784a16ad015508f171c4bf
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae
|
||||
@ -1527,7 +1527,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 b7d9727bff2e840af4b090872c991693e78e6076
|
||||
R 775b940b506452362a073212102869ea
|
||||
U dan
|
||||
Z 738379ab10ae31c6f3af66e5c08bf61c
|
||||
P b54c15f11796a75683eec4b502a22ccb87d621c6
|
||||
R cdb213453699e4a8a0bded009eb336d4
|
||||
U drh
|
||||
Z 3ba463b9129586b08f555ed8d54aa9f2
|
||||
|
@ -1 +1 @@
|
||||
b54c15f11796a75683eec4b502a22ccb87d621c6
|
||||
c4f5fa78cd8207ce1e46e32e632b8f6ee86047e1
|
36
src/shell.c
36
src/shell.c
@ -668,11 +668,12 @@ struct ShellState {
|
||||
#define MODE_Semi 3 /* Same as MODE_List but append ";" to each line */
|
||||
#define MODE_Html 4 /* Generate an XHTML table */
|
||||
#define MODE_Insert 5 /* Generate SQL "insert" statements */
|
||||
#define MODE_Tcl 6 /* Generate ANSI-C or TCL quoted elements */
|
||||
#define MODE_Csv 7 /* Quote strings, numbers are plain */
|
||||
#define MODE_Explain 8 /* Like MODE_Column, but do not truncate data */
|
||||
#define MODE_Ascii 9 /* Use ASCII unit and record separators (0x1F/0x1E) */
|
||||
#define MODE_Pretty 10 /* Pretty-print schemas */
|
||||
#define MODE_Quote 6 /* Quote values as for SQL */
|
||||
#define MODE_Tcl 7 /* Generate ANSI-C or TCL quoted elements */
|
||||
#define MODE_Csv 8 /* Quote strings, numbers are plain */
|
||||
#define MODE_Explain 9 /* Like MODE_Column, but do not truncate data */
|
||||
#define MODE_Ascii 10 /* Use ASCII unit and record separators (0x1F/0x1E) */
|
||||
#define MODE_Pretty 11 /* Pretty-print schemas */
|
||||
|
||||
static const char *modeDescr[] = {
|
||||
"line",
|
||||
@ -681,6 +682,7 @@ static const char *modeDescr[] = {
|
||||
"semi",
|
||||
"html",
|
||||
"insert",
|
||||
"quote",
|
||||
"tcl",
|
||||
"csv",
|
||||
"explain",
|
||||
@ -1198,19 +1200,22 @@ static int shell_callback(
|
||||
setTextMode(p->out, 1);
|
||||
break;
|
||||
}
|
||||
case MODE_Quote:
|
||||
case MODE_Insert: {
|
||||
p->cnt++;
|
||||
if( azArg==0 ) break;
|
||||
utf8_printf(p->out,"INSERT INTO %s",p->zDestTable);
|
||||
if( p->showHeader ){
|
||||
raw_printf(p->out,"(");
|
||||
for(i=0; i<nArg; i++){
|
||||
char *zSep = i>0 ? ",": "";
|
||||
utf8_printf(p->out, "%s%s", zSep, azCol[i]);
|
||||
if( p->cMode==MODE_Insert ){
|
||||
utf8_printf(p->out,"INSERT INTO %s",p->zDestTable);
|
||||
if( p->showHeader ){
|
||||
raw_printf(p->out,"(");
|
||||
for(i=0; i<nArg; i++){
|
||||
char *zSep = i>0 ? ",": "";
|
||||
utf8_printf(p->out, "%s%s", zSep, azCol[i]);
|
||||
}
|
||||
raw_printf(p->out,")");
|
||||
}
|
||||
raw_printf(p->out,")");
|
||||
raw_printf(p->out," VALUES(");
|
||||
}
|
||||
raw_printf(p->out," VALUES(");
|
||||
for(i=0; i<nArg; i++){
|
||||
char *zSep = i>0 ? ",": "";
|
||||
if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
|
||||
@ -1233,7 +1238,7 @@ static int shell_callback(
|
||||
output_quoted_string(p->out, azArg[i]);
|
||||
}
|
||||
}
|
||||
raw_printf(p->out,");\n");
|
||||
raw_printf(p->out,p->cMode==MODE_Quote?"\n":");\n");
|
||||
break;
|
||||
}
|
||||
case MODE_Ascii: {
|
||||
@ -2177,6 +2182,7 @@ static char zHelp[] =
|
||||
" insert SQL insert statements for TABLE\n"
|
||||
" line One value per line\n"
|
||||
" list Values delimited by .separator strings\n"
|
||||
" quote Escape answers as for SQL\n"
|
||||
" tabs Tab-separated values\n"
|
||||
" tcl TCL list elements\n"
|
||||
".nullvalue STRING Use STRING in place of NULL values\n"
|
||||
@ -3977,6 +3983,8 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
}else if( c2=='i' && strncmp(azArg[1],"insert",n2)==0 ){
|
||||
p->mode = MODE_Insert;
|
||||
set_table_name(p, nArg>=3 ? azArg[2] : "table");
|
||||
}else if( c2=='q' && strncmp(azArg[1],"quote",n2)==0 ){
|
||||
p->mode = MODE_Quote;
|
||||
}else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
|
||||
p->mode = MODE_Ascii;
|
||||
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);
|
||||
|
Loading…
Reference in New Issue
Block a user