aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2020-05-28 20:37:17 +0000
committerdrh <drh@noemail.net>2020-05-28 20:37:17 +0000
commitc683573fd4530567b11f224fad7b209349d9e84e (patch)
treee62292b19d78285438b5446c0fbd88d5a2aaa390 /src
parent56c65c92cb922039fe3edb4f624a79acdcc7a5c2 (diff)
downloadsqlite-c683573fd4530567b11f224fad7b209349d9e84e.tar.gz
sqlite-c683573fd4530567b11f224fad7b209349d9e84e.zip
Enhance the ".quote" mode in the shell so that it honors .separator.
FossilOrigin-Name: b5e33ed537e7d7dcabc9f6dc91d6838e0d1657f323440e09e2e24ffa2ba6141a
Diffstat (limited to 'src')
-rw-r--r--src/shell.c.in10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/shell.c.in b/src/shell.c.in
index 585829642..9f960a745 100644
--- a/src/shell.c.in
+++ b/src/shell.c.in
@@ -2205,14 +2205,14 @@ static int shell_callback(
if( azArg==0 ) break;
if( p->cnt==0 && p->showHeader ){
for(i=0; i<nArg; i++){
- if( i>0 ) raw_printf(p->out, ",");
+ if( i>0 ) fputs(p->colSeparator, p->out);
output_quoted_string(p->out, azCol[i]);
}
- raw_printf(p->out,"\n");
+ fputs(p->rowSeparator, p->out);
}
p->cnt++;
for(i=0; i<nArg; i++){
- if( i>0 ) raw_printf(p->out, ",");
+ if( i>0 ) fputs(p->colSeparator, p->out);
if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
utf8_printf(p->out,"NULL");
}else if( aiType && aiType[i]==SQLITE_TEXT ){
@@ -2234,7 +2234,7 @@ static int shell_callback(
output_quoted_string(p->out, azArg[i]);
}
}
- raw_printf(p->out,"\n");
+ fputs(p->rowSeparator, p->out);
break;
}
case MODE_Ascii: {
@@ -8218,6 +8218,8 @@ static int do_meta_command(char *zLine, ShellState *p){
set_table_name(p, nArg>=3 ? azArg[2] : "table");
}else if( c2=='q' && strncmp(azArg[1],"quote",n2)==0 ){
p->mode = MODE_Quote;
+ sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Comma);
+ sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
}else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
p->mode = MODE_Ascii;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);