1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-03 16:53:36 +03:00

Enhance the shell export to support emitting column names in 'insert' mode when headers are enabled.

FossilOrigin-Name: 6e504cd00b148b5acca73f039a20b8acc85dc2f0
This commit is contained in:
mistachkin
2015-04-07 21:16:40 +00:00
parent 48cc29a9ac
commit 151c75ad89
4 changed files with 62 additions and 10 deletions

View File

@@ -989,7 +989,16 @@ static int shell_callback(
case MODE_Insert: {
p->cnt++;
if( azArg==0 ) break;
fprintf(p->out,"INSERT INTO %s VALUES(",p->zDestTable);
fprintf(p->out,"INSERT INTO %s",p->zDestTable);
if( p->showHeader ){
fprintf(p->out,"(");
for(i=0; i<nArg; i++){
char *zSep = i>0 ? ",": "";
fprintf(p->out, "%s%s", zSep, azCol[i]);
}
fprintf(p->out,")");
}
fprintf(p->out," VALUES(");
for(i=0; i<nArg; i++){
char *zSep = i>0 ? ",": "";
if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){