Skip to content
Closed
Show file tree
Hide file tree
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
20 changes: 20 additions & 0 deletions packages/treecrdt-sqlite-ext/src/extension/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod node_store;
mod op_index;
mod op_storage;
mod oprefs;
mod order_key;
mod ops;
mod payload_store;
mod schema;
Expand All @@ -23,6 +24,7 @@ use append::{treecrdt_append_op, treecrdt_append_ops};
use doc_id::{treecrdt_doc_id, treecrdt_set_doc_id};
use materialize::{append_ops_impl, ensure_materialized, treecrdt_ensure_materialized};
use oprefs::{treecrdt_oprefs_all, treecrdt_oprefs_children};
use order_key::treecrdt_allocate_order_key;
use ops::{treecrdt_ops_by_oprefs, treecrdt_ops_since};
use schema::*;
use sqlite_api::*;
Expand Down Expand Up @@ -279,6 +281,21 @@ pub extern "C" fn sqlite3_treecrdt_init(
)
};

let rc_allocate_order_key = {
let name = CString::new("treecrdt_allocate_order_key").expect("static name");
sqlite_create_function_v2(
db,
name.as_ptr(),
5,
SQLITE_UTF8 as c_int,
null_mut(),
Some(treecrdt_allocate_order_key),
None,
None,
None,
)
};

if rc != SQLITE_OK as c_int
|| rc_append != SQLITE_OK as c_int
|| rc_set_doc_id != SQLITE_OK as c_int
Expand All @@ -289,6 +306,7 @@ pub extern "C" fn sqlite3_treecrdt_init(
|| rc_subtree_known_state != SQLITE_OK as c_int
|| rc_ops_by_oprefs != SQLITE_OK as c_int
|| rc_since != SQLITE_OK as c_int
|| rc_allocate_order_key != SQLITE_OK as c_int
{
unsafe {
if !pz_err_msg.is_null() {
Expand All @@ -315,6 +333,8 @@ pub extern "C" fn sqlite3_treecrdt_init(
rc_subtree_known_state
} else if rc_ops_by_oprefs != SQLITE_OK as c_int {
rc_ops_by_oprefs
} else if rc_allocate_order_key != SQLITE_OK as c_int {
rc_allocate_order_key
} else {
rc_since
};
Expand Down
Loading