Fix statement finalization in scripts (#24)

This commit is contained in:
Alexey Romanov
2014-10-10 11:35:48 +04:00
parent d125bcba07
commit 45a1b22b41

View File

@@ -852,21 +852,21 @@ static void sql_exec_async(void *_async_command) {
end = async_command->end; end = async_command->end;
while ((rest < end) && !(async_command->error_code)) { while ((rest < end) && !(async_command->error_code)) {
if (statement) {
sqlite3_finalize(statement);
}
result = sqlite3_prepare_v2(drv->db, rest, end - rest, &statement, &rest); result = sqlite3_prepare_v2(drv->db, rest, end - rest, &statement, &rest);
if (result != SQLITE_OK) { if (result != SQLITE_OK) {
// sqlite doc says statement will be NULL here, so no need to finalize it
num_statements++; num_statements++;
return_error(drv, result, sqlite3_errmsg(drv->db), &dataset, return_error(drv, result, sqlite3_errmsg(drv->db), &dataset,
&term_count, &term_allocated, &async_command->error_code); &term_count, &term_allocated, &async_command->error_code);
break; break;
} else if (statement == NULL) { } else if (statement == NULL) {
// the script has completed
break; break;
} else { } else {
num_statements++; num_statements++;
result = sql_exec_one_statement(statement, async_command, &term_count, result = sql_exec_one_statement(statement, async_command, &term_count,
&term_allocated, &dataset); &term_allocated, &dataset);
sqlite3_finalize(statement);
if (result) { if (result) {
break; break;
} }