9#ifndef HEADER_SQLITEPP_DATABASE_IFACE_INCLUDED
10#define HEADER_SQLITEPP_DATABASE_IFACE_INCLUDED
13#include "exception_iface.hpp"
14#include "mutex_iface.hpp"
15#include "blob_iface.hpp"
16#include "snapshot_iface.hpp"
17#include "memory_iface.hpp"
18#include "string_param.hpp"
27 #pragma GCC diagnostic push
28 #pragma GCC diagnostic ignored "-Wcast-function-type"
30 #if defined(__APPLE__) && defined(__clang__)
31 #pragma GCC diagnostic ignored "-Wunguarded-availability-new"
32 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
40 SQLITEPP_EXPORTED
class context;
41 SQLITEPP_EXPORTED
class row;
42 SQLITEPP_EXPORTED
class value;
46 struct database_detector
48 SQLITEPP_CALL_DETECTOR(enable_load_extension,
int, sqlite3_enable_load_extension, (T *)
nullptr,
int{});
49 SQLITEPP_CALL_DETECTOR(load_extension,
int, sqlite3_load_extension, (T *)
nullptr,
50 (
const char *)
nullptr,
51 (
const char *)
nullptr,
54 SQLITEPP_METHOD_DETECTOR(
void, step, (context *)
nullptr,
int{}, (value **)
nullptr);
55 SQLITEPP_METHOD_DETECTOR(
void, last, (context *)
nullptr);
56 SQLITEPP_METHOD_DETECTOR(
void, inverse, (context *)
nullptr,
int{}, (value **)
nullptr);
57 SQLITEPP_METHOD_DETECTOR(
void, current, (context *)
nullptr);
64 static constexpr bool is_aggregate_function = has_noexcept_step<T> && has_noexcept_last<T>;
67 static constexpr bool is_aggregate_window_function = is_aggregate_function<T> && has_noexcept_inverse<T> && has_noexcept_current<T>;
69 template<
class R,
class T,
class... ArgTypes>
73 template<
class R,
class T,
class... ArgTypes>
81 is_function<std::remove_pointer_t<T>> ||
82 is_aggregate_function<std::remove_pointer_t<T>>
111 template<
int Code,
class ...Args>
114 static void apply(
database & db, Args && ...args)
121 template<
int Code>
struct config_mapping;
123 template<
int Code,
class ...Args>
124 struct vtab_config_option
126 static void apply(
database & db, Args && ...args)
133 template<
int Code>
struct vtab_config_mapping;
161 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 50, 0)
175 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 44, 0)
197 delete static_cast<T *>(d);
225 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 36, 1)
234 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 51, 1)
267 #if __cpp_char8_t >= 201811
321 #if __cpp_char8_t >= 201811
348 void)
busy_handler(
int (* handler)(type_identity_t<T> data_ptr,
int count_invoked)
noexcept, T data_ptr)
366 SQLITEPP_ENABLE_IF((database_detector::is_pointer_to_callback<bool, T, int>),
383 void)
collation_needed(T data_ptr,
void (* handler)(type_identity_t<T> data_ptr,
database *,
int encoding,
const char * name)
noexcept)
403 SQLITEPP_ENABLE_IF((database_detector::is_pointer_to_callback<void, T, database *, int, const char *>),
419 void)
commit_hook(
int (* handler)(type_identity_t<T> data_ptr)
noexcept, T data_ptr)
noexcept
436 SQLITEPP_ENABLE_IF((database_detector::is_pointer_to_callback<bool, T>),
453 void)
rollback_hook(
void (* handler)(type_identity_t<T> data_ptr)
noexcept, T data_ptr)
noexcept
470 SQLITEPP_ENABLE_IF((database_detector::is_pointer_to_callback<void, T>),
506 SQLITEPP_ENABLE_IF((database_detector::is_pointer_to_callback<void, T, int, const char *, const char *, int64_t>),
511 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 16, 0) && defined(SQLITE_ENABLE_PREUPDATE_HOOK)
558 SQLITEPP_ENABLE_IF((database_detector::is_pointer_to_callback<void, T, database *, int, const char *, const char *, int64_t, int64_t>),
593 SQLITEPP_ENABLE_IF((database_detector::is_pointer_to_throwing_callback<void, T, database *, const char *, int>),
600 #if defined(SQLITE_ENABLE_PREUPDATE_HOOK)
601 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 16, 0)
664 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 36, 0)
740 int (*compare)(type_identity_t<T> collator,
int lhs_len,
const void * lhs_bytes,
int rhs_len,
const void * rhs_bytes)
noexcept,
741 void (*destructor)(type_identity_t<T> collator)
noexcept);
765 void (*destructor)(type_identity_t<T> obj)
noexcept =
nullptr);
800 void (*last)(
context*)
noexcept,
801 void (*destructor)(type_identity_t<T> data_ptr)
noexcept);
832 SQLITEPP_ENABLE_IF(database_detector::is_pointer_to_function<T>,
834 T impl_ptr,
void (*destructor)(type_identity_t<T> obj)
noexcept =
nullptr);
838#if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 25, 0)
866 void (*last)(
context*)
noexcept,
867 void (*current)(
context*)
noexcept,
869 void (*destructor)(type_identity_t<T> data_ptr)
noexcept);
898 SQLITEPP_ENABLE_IF(database_detector::is_pointer_to_window_function<T>,
900 T impl_ptr,
void (*destructor)(type_identity_t<T> obj)
noexcept =
nullptr);
906#if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 10, 0)
934 template<
int Code,
class ...Args>
939 config_mapping<Code>::type::apply(*
this,
std::forward<
decltype(args)>(args)...)
976 template<
typename T,
typename D =
void(*)(T *) noexcept>
979 T * data, D destructor =
nullptr)
1008 template<
int Code,
class ...Args>
1013 vtab_config_mapping<Code>::type::apply(*
this,
std::forward<
decltype(args)>(args)...)
1033#if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 30, 0)
1063 SQLITEPP_ENABLE_IF(N > 0,
1066 if (keep[N-1] !=
nullptr)
throw exception(SQLITE_MISUSE);
1080 template<
class ...Args>
1118 return ret ? ret :
"";
1137 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 41, 0)
1157#if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 18, 0)
1194 { check_error(call_sqlite3_enable_load_extension(this->
c_ptr(), val)); }
1204 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 8, 7)
1291 void)
progress_handler(
int step_count,
int(*handler)(type_identity_t<T> data_ptr)
noexcept, T data_ptr)
const noexcept
1346 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 51, 0)
1347 [[deprecated(
"use status64")]]
1356 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 51, 1)
1404 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 36, 1)
1411#if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 34, 0)
1435#if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 39, 0)
1489 {
deserialize(schema_name, (
std::byte *)buf, size, buf_size, flags | SQLITE_DESERIALIZE_READONLY); }
1505 unsigned flags = 0);
1516#if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 10, 0) && (THINSQLITEPP_ENABLE_EXPERIMENTAL || THINSQLITEPP_ENABLE_EXPIREMENTAL)
1560 #if SQLITE_VERSION_NUMBER >= SQLITEPP_SQLITE_VERSION(3, 39, 0)
1579 void check_error(
int res)
const
1586 static int call_sqlite3_enable_load_extension(T * db,
int onoff)
1588 if constexpr (database_detector::has_enable_load_extension<T>)
1595 static int call_sqlite3_load_extension(T * db,
const char * file,
const char * proc,
char ** err)
1597 if constexpr (database_detector::has_load_extension<T>)
1609 SQLITEPP_SUPPRESS_SILLY_VARARG_WARNING_BEGIN
1611 #if SQLITEPP_USE_VARARG_POUND_POUND_TRICK
1613 #define SQLITEPP_DEFINE_DB_OPTION(code, ...) \
1614 template<> struct database::config_mapping<code> { using type = database::config_option<code, ##__VA_ARGS__>; };
1618 #define SQLITEPP_DEFINE_VTAB_OPTION_0(code) \
1619 template<> struct database::vtab_config_mapping<code> { using type = database::vtab_config_option<code>; };
1620 #define SQLITEPP_DEFINE_VTAB_OPTION_N(code, ...) \
1621 template<> struct database::vtab_config_mapping<code> { using type = database::vtab_config_option<code, ##__VA_ARGS__>; };
1625 #define SQLITEPP_DEFINE_DB_OPTION(code, ...) \
1626 template<> struct database::config_mapping<code> { using type = database::config_option<code __VA_OPT__(,) __VA_ARGS__>; };
1628 #define SQLITEPP_DEFINE_VTAB_OPTION_N(code, ...) \
1629 template<> struct database::vtab_config_mapping<code> { using type = database::vtab_config_option<code __VA_OPT__(,) __VA_ARGS__>; };
1631 #define SQLITEPP_DEFINE_VTAB_OPTION_0(code) SQLITEPP_DEFINE_VTAB_OPTION_N(code)
1637#ifdef SQLITE_DBCONFIG_MAINDBNAME
1638 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_MAINDBNAME,
const char *);
1640 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_LOOKASIDE,
void *,
int,
int);
1641 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_ENABLE_FKEY,
int,
int *);
1642 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_ENABLE_TRIGGER,
int,
int *);
1643#ifdef SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER
1644 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER,
int,
int *);
1646#ifdef SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION
1647 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION,
int,
int *);
1649#ifdef SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE
1650 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE,
int,
int *);
1652#ifdef SQLITE_DBCONFIG_ENABLE_QPSG
1653 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_ENABLE_QPSG,
int,
int *);
1655#ifdef SQLITE_DBCONFIG_TRIGGER_EQP
1656 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_TRIGGER_EQP,
int,
int *);
1658#ifdef SQLITE_DBCONFIG_RESET_DATABASE
1659 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_RESET_DATABASE,
int,
int *);
1661#ifdef SQLITE_DBCONFIG_DEFENSIVE
1662 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_DEFENSIVE,
int,
int *);
1664#ifdef SQLITE_DBCONFIG_WRITABLE_SCHEMA
1665 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_WRITABLE_SCHEMA,
int,
int *);
1667#ifdef SQLITE_DBCONFIG_LEGACY_ALTER_TABLE
1668 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_LEGACY_ALTER_TABLE,
int,
int *);
1670#ifdef SQLITE_DBCONFIG_ENABLE_VIEW
1671 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_ENABLE_VIEW,
int,
int *);
1673#ifdef SQLITE_DBCONFIG_LEGACY_FILE_FORMAT
1674 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_LEGACY_FILE_FORMAT,
int,
int *);
1676#ifdef SQLITE_DBCONFIG_TRUSTED_SCHEMA
1677 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_TRUSTED_SCHEMA,
int,
int *);
1679#ifdef SQLITE_DBCONFIG_STMT_SCANSTATUS
1680 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_STMT_SCANSTATUS,
int,
int *);
1682#ifdef SQLITE_DBCONFIG_REVERSE_SCANORDER
1683 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_REVERSE_SCANORDER,
int,
int *);
1685#ifdef SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE
1686 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE,
int,
int *);
1688#ifdef SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE
1689 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE,
int,
int *);
1691#ifdef SQLITE_DBCONFIG_ENABLE_COMMENTS
1692 SQLITEPP_DEFINE_DB_OPTION( SQLITE_DBCONFIG_ENABLE_COMMENTS,
int,
int *);
1698 SQLITEPP_DEFINE_VTAB_OPTION_N(SQLITE_VTAB_CONSTRAINT_SUPPORT,
int);
1699#ifdef SQLITE_VTAB_INNOCUOUS
1700 SQLITEPP_DEFINE_VTAB_OPTION_0(SQLITE_VTAB_INNOCUOUS );
1702#ifdef SQLITE_VTAB_DIRECTONLY
1703 SQLITEPP_DEFINE_VTAB_OPTION_0(SQLITE_VTAB_DIRECTONLY );
1705#ifdef SQLITE_VTAB_USES_ALL_SCHEMAS
1706 SQLITEPP_DEFINE_VTAB_OPTION_0(SQLITE_VTAB_USES_ALL_SCHEMAS );
1711 #undef SQLITEPP_DEFINE_DB_OPTION
1712 #undef SQLITEPP_DEFINE_VTAB_OPTION_0
1713 #undef SQLITEPP_DEFINE_VTAB_OPTION_N
1715 SQLITEPP_SUPPRESS_SILLY_VARARG_WARNING_END
1721 #pragma GCC diagnostic pop
sqlite3_cancel_auto_extension
const T * c_str() const noexcept
Returns the stored pointer.
Definition string_param.hpp:51
SQL Function Context Object.
Definition context_iface.hpp:38
Database Connection.
Definition database_iface.hpp:109
void release_memory() const
Free memory used by the database connection.
Definition database_iface.hpp:1334
bool auto_increment
Whether column is auto-increment.
Definition database_iface.hpp:1383
void interrupt() noexcept
Interrupt a long-running query.
Definition database_iface.hpp:1134
void drop_modules_except(const char *const *keep)
Remove virtual table modules from database connection.
Definition database_iface.hpp:1051
const char * collation_sequence
Collation sequence name.
Definition database_iface.hpp:1380
int vtab_on_conflict() const noexcept
Determine the virtual table conflict policy.
Definition database_iface.hpp:1029
value * preupdate_new(int column_idx)
Returns value of a column of the table row after it is updated.
void busy_timeout(int ms)
Set a busy timeout.
Definition database_iface.hpp:155
void enable_load_extension(bool val)
Enable or disable extension loading.
Definition database_iface.hpp:1193
std::unique_ptr< blob > open_blob(const string_param &dbname, const string_param &table, const string_param &column, int64_t rowid, bool writable)
Open a blob.
void commit_hook(int(*handler)(type_identity_t< T > data_ptr) noexcept, T data_ptr) noexcept
Register a callback to be called on commit.
Definition database_iface.hpp:419
void drop_modules_except(const char *const (&keep)[N])
Remove virtual table modules from database connection.
Definition database_iface.hpp:1064
class mutex * mutex() const noexcept
Retrieve the mutex for the database connection.
Definition database_iface.hpp:1246
void cacheflush()
Flush caches to disk mid-transaction.
Definition database_iface.hpp:914
void create_function(const char *name, int arg_count, int flags, T data_ptr, void(*func)(context *, int, value **) noexcept, void(*step)(context *, int, value **) noexcept, void(*last)(context *) noexcept, void(*destructor)(type_identity_t< T > data_ptr) noexcept)
Create or redefine SQL function.
T exec(std::u8string_view sql, T callback)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition database_iface.hpp:324
void update_hook(T handler_ptr) noexcept
Register a callback to be called whenever a row is updated, inserted or deleted in a rowid table.
int txn_state(const string_param &schema) const noexcept
Returns the transaction state of a database.
Definition database_iface.hpp:1420
T exec(std::string_view sql, T callback)
Run multiple statements of SQL with a callback.
void drop_modules()
Remove all virtual table modules from database connection.
Definition database_iface.hpp:1041
void deserialize(const string_param &schema_name, std::byte *buf, size_t size, size_t buf_size, unsigned flags=0)
Deserialize a database.
Definition database_iface.hpp:1467
void create_function(const char *name, int arg_count, int flags, T impl_ptr, void(*destructor)(type_identity_t< T > obj) noexcept=nullptr)
Create or redefine SQL function.
void create_collation(const string_param &name, int encoding, T collator_ptr, void(*destructor)(type_identity_t< T > obj) noexcept=nullptr)
Define a new collating sequence.
void drop_modules_except(Args &&...args)
Remove virtual table modules from database connection.
Definition database_iface.hpp:1082
void autocheckpoint(int num_frames)
Configure an auto-checkpoint.
Definition database_iface.hpp:708
void file_control(const string_param &db_name, int op, void *data)
Low-level control of database file.
Definition database_iface.hpp:1107
void open_snapshot(const string_param &schema, const snapshot &snap)
Start a read transaction on an historical snapshot.
Definition database_iface.hpp:1539
void wal_hook(int(*handler)(type_identity_t< T > data_ptr, database *db, const char *db_name, int num_pages) noexcept, T data_ptr) noexcept
Register a callback to be called each time data is committed to a database in wal mode.
Definition database_iface.hpp:574
void declare_vtab(const string_param &sdl)
Declare the schema of a virtual table.
Definition database_iface.hpp:990
column_metadata table_column_metadata(const string_param &db_name, const string_param &table_name, const string_param &column_name) const
Extract metadata about a column of a table.
void create_collation(const string_param &name, int encoding, T collator_ptr, int(*compare)(type_identity_t< T > collator, int lhs_len, const void *lhs_bytes, int rhs_len, const void *rhs_bytes) noexcept, void(*destructor)(type_identity_t< T > collator) noexcept)
Define a new collating sequence.
void busy_handler(T handler_ptr)
Register a callback to handle SQLITE_BUSY errors.
void commit_hook(T handler_ptr) noexcept
Register a callback to be called on commit.
auto config(Args &&...args) -> void
Configure database connection.
Definition database_iface.hpp:935
bool is_interrupted() noexcept
Returns whether or not an interrupt is currently in effect.
Definition database_iface.hpp:1145
void setlk_timeout(int ms, int flags=0)
Set a setlk timeout.
Definition database_iface.hpp:168
std::unique_ptr< snapshot > get_snapshot(const string_param &schema)
Record a database snapshot.
void auto_extension(void(*entry_point)(database *, const char **, const struct sqlite3_api_routines *))
Automatically load statically linked extension.
Definition database_iface.hpp:1213
~database() noexcept
Equivalent to sqlite3_close_v2.
Definition database_iface.hpp:144
std::pair< int, int > checkpoint(const string_param &db_name, int mode=SQLITE_CHECKPOINT_PASSIVE)
Checkpoint a database.
void create_window_function(const char *name, int arg_count, int flags, T impl_ptr, void(*destructor)(type_identity_t< T > obj) noexcept=nullptr)
Create or redefine SQL aggregate window function.
int preupdate_blobwrite() const noexcept
Returns the index of the column being written via sqlite3_blob_write.
Definition database_iface.hpp:675
void cancel_auto_extension(void(*entry_point)(database *, const char **, const struct sqlite3_api_routines *))
Cancel automatic extension Loading.
Definition database_iface.hpp:1223
static std::unique_ptr< database > open(const string_param &db_filename, int flags, const char *vfs=nullptr)
Open a new database connection.
void preupdate_hook(T handler_ptr) noexcept
Register a callback to be called prior to each INSERT, UPDATE, and DELETE operation on a database tab...
void extended_result_codes(bool onoff)
Enable or disable extended result codes.
Definition database_iface.hpp:1098
void set_clientdata(const string_param &name, std::unique_ptr< T > &&data)
Set arbitrary client data to this database connection.
Definition database_iface.hpp:194
const char * filename(const string_param &db_name) const noexcept
Return the filename for the database connection.
Definition database_iface.hpp:1115
void set_errmsg(int errcode, const string_param &message)
Set error code and message.
Definition database_iface.hpp:240
int preupdate_count() const noexcept
Returns the number of columns in the row that is being inserted, updated, or deleted.
Definition database_iface.hpp:641
int limit(int id, int new_val) noexcept
Set or retrieve run-time limits.
Definition database_iface.hpp:1179
class statement * next_statement(const class statement *prev) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition database_iface.hpp:1260
void update_hook(void(*handler)(type_identity_t< T > data_ptr, int op, const char *db_name, const char *table, sqlite3_int64 rowid) noexcept, T data_ptr) noexcept
Register a callback to be called whenever a row is updated, inserted or deleted in a rowid table.
Definition database_iface.hpp:487
void create_window_function(const char *name, int arg_count, int flags, T data_ptr, void(*step)(context *, int, value **) noexcept, void(*last)(context *) noexcept, void(*current)(context *) noexcept, void(*inverse)(context *, int, value **) noexcept, void(*destructor)(type_identity_t< T > data_ptr) noexcept)
Create or redefine SQL aggregate window function.
void collation_needed(T data_ptr, void(*handler)(type_identity_t< T > data_ptr, database *, int encoding, const char *name) noexcept)
Register a callback to be called when undefined collation sequence is required.
Definition database_iface.hpp:383
void deserialize(const string_param &schema_name, const std::byte *buf, size_t size, size_t buf_size, unsigned flags=0)
Deserialize a database.
Definition database_iface.hpp:1484
void load_extension(const string_param &file, const string_param &proc=nullptr)
Load an extension.
int64_t last_insert_rowid() const noexcept
Returns last insert rowid.
Definition database_iface.hpp:1154
void set_clientdata(const string_param &name, void *ptr, void(*destroy)(void *)=nullptr)
Set arbitrary client data to this database connection.
Definition database_iface.hpp:182
void progress_handler(int step_count, T handler_ptr) const noexcept
Register a callback to be called on query progress.
int preupdate_depth() const noexcept
Returns the "depth" of an update from the top level SQL.
Definition database_iface.hpp:659
void deserialize(const string_param &schema_name, allocated_bytes buf, size_t size, size_t buf_size, unsigned flags=0)
Deserialize a database.
void preupdate_hook(void(*handler)(type_identity_t< T > data_ptr, database *db, int op, const char *db_name, const char *table, sqlite3_int64 rowid_old, sqlite3_int64 rowid_new) noexcept, T data_ptr) noexcept
Register a callback to be called prior to each INSERT, UPDATE, and DELETE operation on a database tab...
Definition database_iface.hpp:527
std::optional< bool > readonly(const string_param &db_name) const noexcept
Determine if a database is read-only.
const class statement * next_statement(const class statement *prev) const noexcept
Find the next prepared statement.
Definition database_iface.hpp:1256
bool not_null
Whether NOT NULL constraint exists.
Definition database_iface.hpp:1381
void create_module(const string_param &name, const sqlite3_module *mod)
Register a virtual table implementation.
Definition database_iface.hpp:962
value * preupdate_old(int column_idx)
Returns value of a column of the table row before it is updated.
void rollback_hook(T handler_ptr) noexcept
Register a callback to be called on rollback.
void collation_needed(T handler_ptr)
Register a callback to be called when undefined collation sequence is required.
T exec(std::u8string_view sql)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition database_iface.hpp:270
bool get_autocommit() const noexcept
Return the auto-commit mode.
Definition database_iface.hpp:1126
int64_t total_changes() const noexcept
Returns total number of rows modified.
Definition database_iface.hpp:1402
const char * data_type
Declared data type.
Definition database_iface.hpp:1379
void create_module(const string_param &name, const sqlite3_module *mod, T *data, D destructor=nullptr)
Register a virtual table implementation.
Definition database_iface.hpp:978
void progress_handler(int step_count, int(*handler)(type_identity_t< T > data_ptr) noexcept, T data_ptr) const noexcept
Register a callback to be called on query progress.
Definition database_iface.hpp:1291
void busy_handler(int(*handler)(type_identity_t< T > data_ptr, int count_invoked) noexcept, T data_ptr)
Register a callback to handle SQLITE_BUSY errors.
Definition database_iface.hpp:348
auto vtab_config(Args &&...args) -> void
Configure virtual table.
Definition database_iface.hpp:1009
int64_t changes() const noexcept
Count of the number of rows modified.
Definition database_iface.hpp:223
std::pair< allocated_bytes, size_t > serialize(const string_param &schema_name)
Serialize a database.
void recover_snapshot(const string_param &db)
Recover snapshots from a wal file.
Definition database_iface.hpp:1552
void exec(std::string_view sql)
Run multiple statements of SQL.
void rollback_hook(void(*handler)(type_identity_t< T > data_ptr) noexcept, T data_ptr) noexcept
Register a callback to be called on rollback.
Definition database_iface.hpp:453
span< std::byte > serialize_reference(const string_param &schema_name) noexcept
Serialize a database.
void reset_auto_extension() noexcept
Reset automatic extension loading.
Definition database_iface.hpp:1234
void set_last_insert_rowid(int64_t value) noexcept
Set the last insert rowid value.
Definition database_iface.hpp:1165
bool primary_key
Whether column part of PK.
Definition database_iface.hpp:1382
const char * db_name(int idx) noexcept
Return schema names.
Definition database_iface.hpp:1571
void overload_function(const string_param &name, int arg_count)
Overload a function for a virtual table.
Definition database_iface.hpp:1270
void wal_hook(T handler_ptr) noexcept
Register a callback to be called each time data is committed to a database in wal mode.
T * get_clientdata(const string_param &name) noexcept
Get arbitrary client data of this database connection.
Definition database_iface.hpp:211
Return type for status().
Definition database_iface.hpp:1341
Return type for status64().
Definition database_iface.hpp:1360
Exception used to report any SQLite errors.
Definition exception_iface.hpp:180
T * c_ptr() const noexcept
Access the real underlying SQLite type.
Definition handle.hpp:45
Row result of a statement.
Definition row_iterator.hpp:145
A database snapshot.
Definition snapshot_iface.hpp:43
Prepared Statement Object.
Definition statement_iface.hpp:87
Dynamically Typed Value Object.
Definition value_iface.hpp:36
sqlite3_db_release_memory
sqlite3_enable_load_extension
sqlite3_extended_result_codes
std::span< T > span
Alias or reimplementation of std::span.
Definition span.hpp:36
basic_string_param< char > string_param
Convenience typedef.
Definition string_param.hpp:58
std::unique_ptr< std::byte, sqlite_deleter< std::byte > > allocated_bytes
A byte buffer allocated by SQLite.
Definition memory_iface.hpp:58
@ reset
Reset the statement (does not affect the bindings).
Definition statement_iface.hpp:782
T is_nothrow_invocable_r_v
sqlite3_last_insert_rowid
ThinSQLite++ namespace.
Definition backup_iface.hpp:17
sqlite3_overload_function
sqlite3_reset_auto_extension
sqlite3_set_last_insert_rowid
sqlite3_wal_autocheckpoint