Skip to content

check for closed connection in changes #251

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

Merged
merged 2 commits into from
Jun 4, 2023
Merged
Changes from all commits
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
6 changes: 5 additions & 1 deletion c_src/sqlite3_nif.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ exqlite_changes(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
return make_error_tuple(env, "invalid_connection");
}

if (conn->db == NULL) {
return make_error_tuple(env, "connection_closed");
}

int changes = sqlite3_changes(conn->db);
return make_ok_tuple(env, enif_make_int(env, changes));
}
Expand Down Expand Up @@ -386,7 +390,7 @@ exqlite_prepare(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
if (conn->db == NULL) {
enif_mutex_unlock(conn->mutex);
enif_release_resource(statement);
return make_error_tuple(env, "connection closed");
return make_error_tuple(env, "connection_closed");
}
rc = sqlite3_prepare_v3(conn->db, (char*)bin.data, bin.size, 0, &statement->statement, NULL);
enif_mutex_unlock(conn->mutex);
Expand Down