Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(c/driver/sqlite): Wrap bulk ingests in a single begin/commit txn #910

Merged
merged 4 commits into from
Jul 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions c/driver/sqlite/sqlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,10 @@ AdbcStatusCode SqliteStatementExecuteIngest(struct SqliteStatement* stmt,
AdbcStatusCode status = SqliteStatementInitIngest(stmt, &insert, error);

int64_t row_count = 0;
int is_autocommit = sqlite3_get_autocommit(stmt->conn);
if (status == ADBC_STATUS_OK) {
if (is_autocommit) sqlite3_exec(stmt->conn, "BEGIN TRANSACTION", 0, 0, 0);

while (1) {
char finished = 0;
status =
Expand All @@ -1120,6 +1123,8 @@ AdbcStatusCode SqliteStatementExecuteIngest(struct SqliteStatement* stmt,
}
row_count++;
}

if (is_autocommit) sqlite3_exec(stmt->conn, "COMMIT", 0, 0, 0);
}

if (rows_affected) *rows_affected = row_count;
Expand Down