Skip to content

Commit f5ae76c

Browse files
committed
expose cloudsync_uuid function
1 parent 9b6e35d commit f5ae76c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/cloudsync.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2981,6 +2981,17 @@ void cloudsync_commit_alter (sqlite3_context *context, int argc, sqlite3_value *
29812981
}
29822982
}
29832983

2984+
// MARK: -
2985+
2986+
void cloudsync_uuid (sqlite3_context *context, int argc, sqlite3_value **argv) {
2987+
DEBUG_FUNCTION("cloudsync_uuid");
2988+
2989+
char value[UUID_STR_MAXLEN];
2990+
char *uuid = cloudsync_uuid_v7_string(value, true);
2991+
sqlite3_result_text(context, uuid, -1, SQLITE_TRANSIENT);
2992+
}
2993+
2994+
29842995
// MARK: - Main Entrypoint -
29852996

29862997
APIEXPORT int sqlite3_cloudsync_init (sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi) {
@@ -3091,6 +3102,9 @@ APIEXPORT int sqlite3_cloudsync_init (sqlite3 *db, char **pzErrMsg, const sqlite
30913102
rc = dbutils_register_function(db, "cloudsync_commit_alter", cloudsync_commit_alter, 1, pzErrMsg, ctx, NULL);
30923103
if (rc != SQLITE_OK) return rc;
30933104

3105+
rc = dbutils_register_function(db, "cloudsync_uuid", cloudsync_uuid, 0, pzErrMsg, ctx, NULL);
3106+
if (rc != SQLITE_OK) return rc;
3107+
30943108
// NETWORK LAYER
30953109
#ifndef CLOUDSYNC_OMIT_NETWORK
30963110
rc = cloudsync_network_register(db, pzErrMsg, ctx);

test/unittest.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,11 @@ bool do_test_functions (sqlite3 *db, bool print_results) {
829829
rc = sqlite3_exec(db, "SELECT cloudsync_cleanup('*');", NULL, NULL, NULL);
830830
if (rc != SQLITE_OK) goto abort_test_functions;
831831

832+
char *uuid = dbutils_text_select(db, "SELECT cloudsync_uuid();");
833+
if (uuid == NULL) goto abort_test_functions;
834+
if (print_results) printf("New uuid: %s\n", uuid);
835+
cloudsync_memory_free(uuid);
836+
832837
return true;
833838

834839
abort_test_functions:

0 commit comments

Comments
 (0)