From b860bc97d523a93a3f43e8eee17e1855a96161c1 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 4 Aug 2004 15:16:55 +0000 Subject: [PATCH] In the command-line shell: importments to the "help" message and better error checking in the new .import command. (CVS 1877) FossilOrigin-Name: ed489f776aed2de2f16e5c4b93ec6bc872118fb2 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 42 ++++++++++++++++++++++++++++-------------- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 7fc04d8500..2b26e1a455 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Separate\sP4\stiming\sasm\scode\sout\sof\sthe\sSQLITE_DEBUG\smacro\sso\sthat\sSQLITE_DEBUG\ncan\sbe\sused\son\snon-x86\smachines\sand\swith\scompilers\sother\sthan\sGCC.\nTicket\s#838.\s(CVS\s1876) -D 2004-08-04T14:44:34 +C In\sthe\scommand-line\sshell:\simportments\sto\sthe\s"help"\smessage\sand\sbetter\nerror\schecking\sin\sthe\snew\s.import\scommand.\s(CVS\s1877) +D 2004-08-04T15:16:55 F Makefile.in 4a5e570a9e2d35b09c31b3cf01b78cea764ade4b F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -58,7 +58,7 @@ F src/pragma.c c8be18093f0492f9983406647808781ca0073d8b F src/printf.c 17b28a1eedfe8129b05de981719306c18c3f1327 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 F src/select.c cbed45f4af76ad7fdfc0a0df6878b2b3827ae1d4 -F src/shell.c 7371f0a4b1c1aaed336176dfcc6e6742c138b263 +F src/shell.c 4b40fac1a07512d6b8dbdf8abe0b4660d777c9ce F src/sqlite.h.in c340a12b4d0521efb474dd000fba3bdfb18d76da F src/sqliteInt.h 7a8dec83364d940372507ca4d4ff0c96bce05300 F src/table.c 4521c278892f60e4d630788c0ea5cf4db1e75c49 @@ -240,7 +240,7 @@ F www/tclsqlite.tcl 06a86cba4d7fc88e2bcd633b57702d3d16abebb5 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P 4e7953c13fd2cb32e5c97737c4b2f99b1b1edc9b -R 32ad53e3950d031bf8dd62a53bdface5 +P add266ccc3146fa56572d109e84c8a79dc3df2ca +R 674b4df64dead6e35bf0c60489ccd67c U drh -Z 06402d986b3876ed10b4e307c21b4abe +Z 8d01172e36dc4738ad87459856f6ce34 diff --git a/manifest.uuid b/manifest.uuid index 9a62ae3ef4..2b443ccdad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -add266ccc3146fa56572d109e84c8a79dc3df2ca \ No newline at end of file +ed489f776aed2de2f16e5c4b93ec6bc872118fb2 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 03a8081a79..cfaa813a6f 100644 --- a/src/shell.c +++ b/src/shell.c @@ -12,7 +12,7 @@ ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** -** $Id: shell.c,v 1.108 2004/08/01 00:10:45 drh Exp $ +** $Id: shell.c,v 1.109 2004/08/04 15:16:55 drh Exp $ */ #include #include @@ -643,18 +643,24 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){ */ static char zHelp[] = ".databases List names and files of attached databases\n" - ".dump ?TABLE? ... Dump the database in a text format\n" + ".dump ?TABLE? ... Dump the database in an SQL text format\n" ".echo ON|OFF Turn command echo on or off\n" ".exit Exit this program\n" ".explain ON|OFF Turn output mode suitable for EXPLAIN on or off.\n" ".header(s) ON|OFF Turn display of headers on or off\n" ".help Show this message\n" - ".import FILE TABLE Import data from FILE\n" + ".import FILE TABLE Import data from FILE into TABLE\n" ".indices TABLE Show names of all indices on TABLE\n" - ".mode MODE Set mode to one of: cvs column html insert line\n" - " list tabs tcl\n" - ".mode insert TABLE Generate SQL insert statements for TABLE\n" - ".nullvalue STRING Print STRING instead of nothing for NULL data\n" + ".mode MODE ?TABLE? Set output mode where MODE is on of:\n" + " cvs Comma-separated values\n" + " column Left-aligned columns. (See .width)\n" + " html HTML code\n" + " insert SQL insert statements for TABLE\n" + " line One value per line\n" + " list Values delimited by .separator string\n" + " tabs Tab-separated values\n" + " tcl TCL list elements\n" + ".nullvalue STRING Print STRING in place of NULL values\n" ".output FILENAME Send output to FILENAME\n" ".output stdout Send output to the screen\n" ".prompt MAIN CONTINUE Replace the standard prompts\n" @@ -664,7 +670,7 @@ static char zHelp[] = ".rekey OLD NEW NEW Change the encryption key\n" #endif ".schema ?TABLE? Show the CREATE statements\n" - ".separator STRING Change separator string\n" + ".separator STRING Change separator used by output mode and .import\n" ".show Show the current values for various settings\n" ".tables ?PATTERN? List names of tables matching a LIKE pattern\n" ".timeout MS Try opening locked tables for MS milliseconds\n" @@ -915,7 +921,8 @@ static int do_meta_command(char *zLine, struct callback_data *p){ char *zLine; /* A single line of input from the file */ char **azCol; /* zLine[] broken up into columns */ char *zCommit; /* How to commit changes */ - FILE *in; /* The input file */ + FILE *in; /* The input file */ + int lineno = 0; /* Line number of input file */ nSep = strlen(p->separator); if( nSep==0 ){ @@ -965,17 +972,24 @@ static int do_meta_command(char *zLine, struct callback_data *p){ while( (zLine = local_getline(0, in))!=0 ){ char *z; i = 0; + lineno++; azCol[0] = zLine; for(i=0, z=zLine; *z; z++){ if( *z==p->separator[0] && strncmp(z, p->separator, nSep)==0 ){ *z = 0; i++; - if( i>=nCol ) break; - azCol[i] = &z[nSep]; - z += nSep-1; + if( idb, "COMMIT", 0, 0, 0); + sqlite3_exec(p->db, zCommit, 0, 0, 0); }else if( c=='i' && strncmp(azArg[0], "indices", n)==0 && nArg>1 ){ -- 2.47.3