aboutsummaryrefslogtreecommitdiff
path: root/src/shell.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2013-08-06 14:36:36 +0000
committerdrh <drh@noemail.net>2013-08-06 14:36:36 +0000
commit2d463113f0e374b89bb3b74c1fb65678c1ccc7b5 (patch)
treee9b6f60b8825371b5f5eb1325467136608df9411 /src/shell.c
parent9f099fd45a8191e4694f11ac6d760b7c21455890 (diff)
downloadsqlite-2d463113f0e374b89bb3b74c1fb65678c1ccc7b5.tar.gz
sqlite-2d463113f0e374b89bb3b74c1fb65678c1ccc7b5.zip
For the ".import" command of the command-line shell, start a transaction
if there is not one active already. FossilOrigin-Name: 5dcc2d91bd343cd0fac79d3c8f079a5ce534cdf7
Diffstat (limited to 'src/shell.c')
-rw-r--r--src/shell.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/shell.c b/src/shell.c
index 65bf5511d..4a59c667a 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -1990,6 +1990,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
int nCol; /* Number of columns in the table */
int nByte; /* Number of bytes in an SQL string */
int i, j; /* Loop counters */
+ int needCommit; /* True to COMMIT or ROLLBACK at end */
int nSep; /* Number of bytes in p->separator[] */
char *zSql; /* An SQL statement */
CSVReader sCsv; /* Reader context */
@@ -2091,6 +2092,8 @@ static int do_meta_command(char *zLine, struct callback_data *p){
xCloser(sCsv.in);
return 1;
}
+ needCommit = sqlite3_get_autocommit(db);
+ if( needCommit ) sqlite3_exec(db, "BEGIN", 0, 0, 0);
do{
int startLine = sCsv.nLine;
for(i=0; i<nCol; i++){
@@ -2127,7 +2130,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
xCloser(sCsv.in);
sqlite3_free(sCsv.z);
sqlite3_finalize(pStmt);
- sqlite3_exec(p->db, "COMMIT", 0, 0, 0);
+ if( needCommit ) sqlite3_exec(db, "COMMIT", 0, 0, 0);
}else
if( c=='i' && strncmp(azArg[0], "indices", n)==0 && nArg<3 ){