Skip to content

Commit 4066dea

Browse files
committed
fix: use "ROLLBACK TO" and "RELEASE" commands to rollback SAVEPOINTs
1 parent 65a8a37 commit 4066dea

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/cloudsync.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2993,7 +2993,7 @@ void cloudsync_init (sqlite3_context *context, const char *table, const char *al
29932993
}
29942994

29952995
if (rc == SQLITE_OK) dbutils_update_schema_hash(db, &data->schema_hash);
2996-
else sqlite3_exec(db, "ROLLBACK", NULL, NULL, NULL);
2996+
else sqlite3_exec(db, "ROLLBACK TO cloudsync_init; RELEASE cloudsync_init", NULL, NULL, NULL);
29972997
}
29982998

29992999
void cloudsync_init3 (sqlite3_context *context, int argc, sqlite3_value **argv) {
@@ -3042,7 +3042,7 @@ void cloudsync_begin_alter (sqlite3_context *context, int argc, sqlite3_value **
30423042
if (cloudsync_context_init(db, data, context) == NULL) {
30433043
sqlite3_result_error(context, "Unable to init the cloudsync context.", -1);
30443044
sqlite3_result_error_code(context, SQLITE_MISUSE);
3045-
goto cleanup_begin_alter;
3045+
return;
30463046
}
30473047

30483048
// create a savepoint to manage the alter operations as a transaction
@@ -3083,7 +3083,7 @@ void cloudsync_begin_alter (sqlite3_context *context, int argc, sqlite3_value **
30833083
return;
30843084

30853085
rollback_begin_alter:
3086-
sqlite3_exec(db, "ROLLBACK", NULL, NULL, NULL);
3086+
sqlite3_exec(db, "ROLLBACK TO cloudsync_alter; RELEASE cloudsync_alter;", NULL, NULL, NULL);
30873087

30883088
cleanup_begin_alter:
30893089
sqlite3_free_table(result);
@@ -3143,7 +3143,7 @@ void cloudsync_commit_alter (sqlite3_context *context, int argc, sqlite3_value *
31433143
return;
31443144

31453145
rollback_finalize_alter:
3146-
sqlite3_exec(db, "ROLLBACK", NULL, NULL, NULL);
3146+
sqlite3_exec(db, "ROLLBACK TO cloudsync_alter; RELEASE cloudsync_alter;", NULL, NULL, NULL);
31473147
if (table) {
31483148
sqlite3_free_table(table->pk_name);
31493149
table->pk_name = NULL;

0 commit comments

Comments
 (0)