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

For the ".import" command of the command-line shell, start a transaction

if there is not one active already.

FossilOrigin-Name: 5dcc2d91bd343cd0fac79d3c8f079a5ce534cdf7
This commit is contained in:
drh
2013-08-06 14:36:36 +00:00
parent 9f099fd45a
commit 2d463113f0
3 changed files with 11 additions and 8 deletions

View File

@@ -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 ){