Added basics to expose backup api

This commit is contained in:
Maas-Maarten Zeeman
2022-01-06 23:55:40 +01:00
parent c764204c23
commit 6bdaf1e894
2 changed files with 339 additions and 67 deletions

View File

@@ -21,27 +21,34 @@
-author("Maas-Maarten Zeeman <mmzeeman@xs4all.nl>").
%% low-level exports
-export([start/0,
open/4,
set_update_hook/4,
exec/4,
changes/3,
insert/4,
last_insert_rowid/3,
get_autocommit/3,
prepare/4,
multi_step/5,
reset/4,
finalize/4,
bind/5,
column_names/4,
column_types/4,
interrupt/1,
close/3
]).
-export([
start/0,
open/4,
set_update_hook/4,
exec/4,
changes/3,
insert/4,
last_insert_rowid/3,
get_autocommit/3,
prepare/4,
multi_step/5,
reset/4,
finalize/4,
bind/5,
column_names/4,
column_types/4,
backup_init/6,
backup_step/5,
backup_remaining/4,
backup_pagecount/4,
backup_finish/4,
interrupt/1,
close/3
]).
-type raw_connection() :: reference().
-type raw_statement() :: reference().
-type raw_backup() :: reference().
-type sql() :: iodata().
-export_type([raw_connection/0, raw_statement/0, sql/0]).
@@ -137,6 +144,31 @@ column_names(_Db, _Stmt, _Ref, _Dest) ->
column_types(_Db, _Stmt, _Ref, _Dest) ->
erlang:nif_error(nif_library_not_loaded).
%% @doc Initialize a backup procedure of a database.
-spec backup_init(raw_connection(), iodata(), raw_connection(), iodata(), reference(), pid()) -> ok | {error, _}.
backup_init(_DestDb, _DestName, _SourceDb, _SourceName, _Ref, _Dest) ->
erlang:nif_error(nif_library_not_loaded).
%% @doc Do a backup step.
-spec backup_step(raw_connection(), raw_backup(), integer(), reference(), pid()) -> ok | {error, _}.
backup_step(_Db, _Backup, _NPages, _Ref, _Dest) ->
erlang:nif_error(nif_library_not_loaded).
%% @doc Get the amount of remaining pages which need to be backed up.
-spec backup_remaining(raw_connection(), raw_backup(), reference(), pid()) -> ok | {error, _}.
backup_remaining(_Db, _Backup, _Ref, _Dest) ->
erlang:nif_error(nif_library_not_loaded).
%% @doc Get the total number of pages which need to be backed up.
-spec backup_pagecount(raw_connection(), raw_backup(), reference(), pid()) -> ok | {error, _}.
backup_pagecount(_Db, _Backup, _Ref, _Dest) ->
erlang:nif_error(nif_library_not_loaded).
%% @doc Finish the backup.
-spec backup_finish(raw_connection(), raw_backup(), reference(), pid()) -> ok | {error, _}.
backup_finish(_Db, _Backup, _Ref, _Dest) ->
erlang:nif_error(nif_library_not_loaded).
%% @doc Interrupt all active queries.
-spec interrupt(raw_connection()) -> ok.
interrupt(_Db) ->