KSQL_CLOSE(3) Library Functions Manual KSQL_CLOSE(3)

ksql_close
close a ksql database connection

library “ksql”

#include <sys/types.h>
#include <stdint.h>
#include <ksql.h>
enum ksqlc
ksql_close(struct ksql *sql);

The ksql_close function closes a database connection opened with ksql_open(3). If the connection was not opened, is already closed, or sql is NULL, this function is a no-op.
This function will begin by calling sqlite3_finalize(3) on all active statements (it is an error to have any open connections), then it will roll back any open transactions (also triggering an error) if found, then it will close out the database itself with sqlite3_close(3). In the event of statements still being open, all statements are finalised and the database closed prior to calling the error handler. If KSQL_FAIL_ON_EXIT was specified on sql, the exit(2) will only be invoked after all resources have been closed and freed.

This returns KSQL_STMT if there were open statements, KSQL_TRANS if there was an open transaction (if there were both open statements and a transaction, this is returned), KSQL_DB if there were database-level errors (this overrides whether there were open transactions and/or a transaction), or KSQL_OK on success.

sqlite3_close(3), sqlite3_exec(3), sqlite3_finalize(3)
April 3, 2018 OpenBSD 6.4