From a40340a098b465d679a9513922b43bf75d48ca82 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr." Date: Sun, 1 Oct 2023 10:56:57 -0500 Subject: [PATCH 1/3] consistency for database ID parameter --- cozo-lib-c/cozo_c.h | 6 +++--- cozo-lib-c/src/lib.rs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cozo-lib-c/cozo_c.h b/cozo-lib-c/cozo_c.h index 7121f6f4..218bad76 100644 --- a/cozo-lib-c/cozo_c.h +++ b/cozo-lib-c/cozo_c.h @@ -25,7 +25,7 @@ extern "C" { * * `engine`: which storage engine to use, can be "mem", "sqlite" or "rocksdb". * `path`: should contain the UTF-8 encoded path name as a null-terminated C-string. - * `db_id`: will contain the id of the database opened. + * `db_id`: will contain the ID of the database opened. * `options`: options for the DB constructor: engine dependent. * * When the function is successful, null pointer is returned, @@ -37,12 +37,12 @@ char *cozo_open_db(const char *engine, const char *path, const char *options, in /** * Close a database. * - * `id`: the ID representing the database to close. + * `db_id`: the ID representing the database to close. * * Returns `true` if the database is closed, * `false` if it has already been closed, or does not exist. */ -bool cozo_close_db(int32_t id); +bool cozo_close_db(int32_t db_id); /** * Run query against a database. diff --git a/cozo-lib-c/src/lib.rs b/cozo-lib-c/src/lib.rs index fd696a26..922b2055 100644 --- a/cozo-lib-c/src/lib.rs +++ b/cozo-lib-c/src/lib.rs @@ -34,7 +34,7 @@ lazy_static! { /// /// `engine`: which storage engine to use, can be "mem", "sqlite" or "rocksdb". /// `path`: should contain the UTF-8 encoded path name as a null-terminated C-string. -/// `db_id`: will contain the id of the database opened. +/// `db_id`: will contain the ID of the database opened. /// `options`: options for the DB constructor: engine dependent. /// /// When the function is successful, null pointer is returned, @@ -76,15 +76,15 @@ pub unsafe extern "C" fn cozo_open_db( /// Close a database. /// -/// `id`: the ID representing the database to close. +/// `db_id`: the ID representing the database to close. /// /// Returns `true` if the database is closed, /// `false` if it has already been closed, or does not exist. #[no_mangle] -pub unsafe extern "C" fn cozo_close_db(id: i32) -> bool { +pub unsafe extern "C" fn cozo_close_db(db_id: i32) -> bool { let db = { let mut dbs = HANDLES.dbs.lock().unwrap(); - dbs.remove(&id) + dbs.remove(&db_id) }; db.is_some() } From 02afa95240e00a6309c5065ea29d2de4cd7d3373 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr." Date: Sun, 1 Oct 2023 11:09:19 -0500 Subject: [PATCH 2/3] update doc comments for cozo_run_query --- cozo-lib-c/cozo_c.h | 15 +++++++-------- cozo-lib-c/src/lib.rs | 15 +++++++-------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/cozo-lib-c/cozo_c.h b/cozo-lib-c/cozo_c.h index 218bad76..ced6056f 100644 --- a/cozo-lib-c/cozo_c.h +++ b/cozo-lib-c/cozo_c.h @@ -47,14 +47,13 @@ bool cozo_close_db(int32_t db_id); /** * Run query against a database. * - * `db_id`: the ID representing the database to run the query. - * `script_raw`: a UTF-8 encoded C-string for the CozoScript to execute. - * `params_raw`: a UTF-8 encoded C-string for the params of the query, - * in JSON format. You must always pass in a valid JSON map, - * even if you do not use params in your query - * (pass "{}" in this case). - * `errored`: will point to `false` if the query is successful, - * `true` if an error occurred. + * `db_id`: the ID representing the database to run the query. + * `script_raw`: a UTF-8 encoded C-string for the CozoScript to execute. + * `params_raw`: a UTF-8 encoded C-string for the params of the query, + * in JSON format. You must always pass in a valid JSON map, + * even if you do not use params in your query + * (pass "{}" in this case). + * `immutable_query`: whether the query is read-only. * * Returns a UTF-8-encoded C-string that **must** be freed with `cozo_free_str`. * The string contains the JSON return value of the query. diff --git a/cozo-lib-c/src/lib.rs b/cozo-lib-c/src/lib.rs index 922b2055..e34bb351 100644 --- a/cozo-lib-c/src/lib.rs +++ b/cozo-lib-c/src/lib.rs @@ -91,14 +91,13 @@ pub unsafe extern "C" fn cozo_close_db(db_id: i32) -> bool { /// Run query against a database. /// -/// `db_id`: the ID representing the database to run the query. -/// `script_raw`: a UTF-8 encoded C-string for the CozoScript to execute. -/// `params_raw`: a UTF-8 encoded C-string for the params of the query, -/// in JSON format. You must always pass in a valid JSON map, -/// even if you do not use params in your query -/// (pass "{}" in this case). -/// `errored`: will point to `false` if the query is successful, -/// `true` if an error occurred. +/// `db_id`: the ID representing the database to run the query. +/// `script_raw`: a UTF-8 encoded C-string for the CozoScript to execute. +/// `params_raw`: a UTF-8 encoded C-string for the params of the query, +/// in JSON format. You must always pass in a valid JSON map, +/// even if you do not use params in your query +/// (pass "{}" in this case). +/// `immutable_query`: whether the query is read-only. /// /// Returns a UTF-8-encoded C-string that **must** be freed with `cozo_free_str`. /// The string contains the JSON return value of the query. From ae9771cdcf17f5804a1b37decf0a0c5b77967b2d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 17:02:09 +0000 Subject: [PATCH 3/3] @michaelsbradleyjr has signed the CLA in cozodb/cozo#190 --- signatures/version1/cla.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/signatures/version1/cla.json b/signatures/version1/cla.json index c1aa8832..2f6495fa 100644 --- a/signatures/version1/cla.json +++ b/signatures/version1/cla.json @@ -55,6 +55,14 @@ "created_at": "2023-07-28T20:55:41Z", "repoId": 551374215, "pullRequestNo": 164 + }, + { + "name": "michaelsbradleyjr", + "id": 194260, + "comment_id": 1742139428, + "created_at": "2023-10-01T17:01:55Z", + "repoId": 551374215, + "pullRequestNo": 190 } ] } \ No newline at end of file