@op-engineering/op-sqlite 11.2.14 → 11.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cpp/DBHostObject.cpp +627 -591
- package/cpp/DBHostObject.h +54 -53
- package/cpp/DumbHostObject.cpp +35 -34
- package/cpp/DumbHostObject.h +12 -11
- package/cpp/PreparedStatementHostObject.cpp +102 -96
- package/cpp/PreparedStatementHostObject.h +28 -26
- package/cpp/SmartHostObject.cpp +13 -13
- package/cpp/SmartHostObject.h +6 -5
- package/cpp/ThreadPool.cpp +80 -78
- package/cpp/ThreadPool.h +28 -28
- package/cpp/bindings.cpp +112 -108
- package/cpp/bridge.cpp +637 -615
- package/cpp/bridge.h +4 -4
- package/cpp/libsql/bridge.cpp +566 -564
- package/cpp/libsql/bridge.h +16 -23
- package/cpp/libsql/libsql.h +62 -48
- package/cpp/logs.h +17 -17
- package/cpp/types.h +12 -12
- package/cpp/utils.cpp +254 -248
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -1
package/cpp/libsql/bridge.h
CHANGED
|
@@ -25,43 +25,37 @@ typedef std::function<void(std::string dbName)> CommitCallback;
|
|
|
25
25
|
typedef std::function<void(std::string dbName)> RollbackCallback;
|
|
26
26
|
|
|
27
27
|
struct DB {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
libsql_database_t db;
|
|
29
|
+
libsql_connection_t c;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
std::string opsqlite_get_db_path(std::string const &name,
|
|
33
33
|
std::string const &location);
|
|
34
34
|
|
|
35
|
-
DB opsqlite_libsql_open(std::string const &name,
|
|
36
|
-
|
|
37
|
-
std::string const &crsqlitePath);
|
|
35
|
+
DB opsqlite_libsql_open(std::string const &name, std::string const &path,
|
|
36
|
+
std::string const &crsqlitePath);
|
|
38
37
|
|
|
39
38
|
DB opsqlite_libsql_open_remote(std::string const &url,
|
|
40
|
-
|
|
39
|
+
std::string const &auth_token);
|
|
41
40
|
|
|
42
|
-
DB opsqlite_libsql_open_sync(std::string const &name,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
std::string const &auth_token,
|
|
46
|
-
int sync_interval);
|
|
41
|
+
DB opsqlite_libsql_open_sync(std::string const &name, std::string const &path,
|
|
42
|
+
std::string const &url,
|
|
43
|
+
std::string const &auth_token, int sync_interval);
|
|
47
44
|
|
|
48
45
|
void opsqlite_libsql_close(DB &db);
|
|
49
46
|
|
|
50
47
|
void opsqlite_libsql_remove(DB &db, std::string const &name,
|
|
51
|
-
|
|
48
|
+
std::string const &path);
|
|
52
49
|
|
|
53
|
-
void opsqlite_libsql_attach(DB const &db,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
std::string const &alias);
|
|
50
|
+
void opsqlite_libsql_attach(DB const &db, std::string const &docPath,
|
|
51
|
+
std::string const &databaseToAttach,
|
|
52
|
+
std::string const &alias);
|
|
57
53
|
|
|
58
|
-
void opsqlite_libsql_detach(DB const &db,
|
|
59
|
-
std::string const &alias);
|
|
54
|
+
void opsqlite_libsql_detach(DB const &db, std::string const &alias);
|
|
60
55
|
|
|
61
56
|
void opsqlite_libsql_sync(DB const &db);
|
|
62
57
|
|
|
63
|
-
BridgeResult opsqlite_libsql_execute(DB const &db,
|
|
64
|
-
std::string const &query,
|
|
58
|
+
BridgeResult opsqlite_libsql_execute(DB const &db, std::string const &query,
|
|
65
59
|
const std::vector<JSVariant> *params);
|
|
66
60
|
|
|
67
61
|
BridgeResult opsqlite_libsql_execute_with_host_objects(
|
|
@@ -76,7 +70,7 @@ opsqlite_libsql_execute_raw(DB const &db, std::string const &query,
|
|
|
76
70
|
|
|
77
71
|
BatchResult
|
|
78
72
|
opsqlite_libsql_execute_batch(DB const &db,
|
|
79
|
-
std::vector<BatchArguments> *commands);
|
|
73
|
+
const std::vector<BatchArguments> *commands);
|
|
80
74
|
|
|
81
75
|
libsql_stmt_t opsqlite_libsql_prepare_statement(DB const &db,
|
|
82
76
|
std::string const &query);
|
|
@@ -85,8 +79,7 @@ void opsqlite_libsql_bind_statement(libsql_stmt_t stmt,
|
|
|
85
79
|
const std::vector<JSVariant> *params);
|
|
86
80
|
|
|
87
81
|
BridgeResult opsqlite_libsql_execute_prepared_statement(
|
|
88
|
-
DB const &db, libsql_stmt_t stmt,
|
|
89
|
-
std::vector<DumbHostObject> *results,
|
|
82
|
+
DB const &db, libsql_stmt_t stmt, std::vector<DumbHostObject> *results,
|
|
90
83
|
const std::shared_ptr<std::vector<SmartHostObject>> &metadatas);
|
|
91
84
|
|
|
92
85
|
} // namespace opsqlite
|
package/cpp/libsql/libsql.h
CHANGED
|
@@ -28,18 +28,18 @@ typedef struct libsql_stmt libsql_stmt;
|
|
|
28
28
|
typedef const libsql_database *libsql_database_t;
|
|
29
29
|
|
|
30
30
|
typedef struct {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
int frame_no;
|
|
32
|
+
int frames_synced;
|
|
33
33
|
} replicated;
|
|
34
34
|
|
|
35
35
|
typedef struct {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
const char *db_path;
|
|
37
|
+
const char *primary_url;
|
|
38
|
+
const char *auth_token;
|
|
39
|
+
char read_your_writes;
|
|
40
|
+
const char *encryption_key;
|
|
41
|
+
int sync_interval;
|
|
42
|
+
char with_webpki;
|
|
43
43
|
} libsql_config;
|
|
44
44
|
|
|
45
45
|
typedef const libsql_connection *libsql_connection_t;
|
|
@@ -53,8 +53,8 @@ typedef const libsql_rows_future *libsql_rows_future_t;
|
|
|
53
53
|
typedef const libsql_row *libsql_row_t;
|
|
54
54
|
|
|
55
55
|
typedef struct {
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
const char *ptr;
|
|
57
|
+
int len;
|
|
58
58
|
} blob;
|
|
59
59
|
|
|
60
60
|
#ifdef __cplusplus
|
|
@@ -65,63 +65,68 @@ int libsql_enable_internal_tracing(void);
|
|
|
65
65
|
|
|
66
66
|
int libsql_sync(libsql_database_t db, const char **out_err_msg);
|
|
67
67
|
|
|
68
|
-
int libsql_sync2(libsql_database_t db, replicated *out_replicated,
|
|
68
|
+
int libsql_sync2(libsql_database_t db, replicated *out_replicated,
|
|
69
|
+
const char **out_err_msg);
|
|
69
70
|
|
|
70
|
-
int libsql_open_sync(const char *db_path,
|
|
71
|
-
const char *
|
|
72
|
-
const char *
|
|
73
|
-
char read_your_writes,
|
|
74
|
-
const char *encryption_key,
|
|
75
|
-
libsql_database_t *out_db,
|
|
71
|
+
int libsql_open_sync(const char *db_path, const char *primary_url,
|
|
72
|
+
const char *auth_token, char read_your_writes,
|
|
73
|
+
const char *encryption_key, libsql_database_t *out_db,
|
|
76
74
|
const char **out_err_msg);
|
|
77
75
|
|
|
78
|
-
int libsql_open_sync_with_webpki(const char *db_path,
|
|
79
|
-
const char *
|
|
80
|
-
const char *auth_token,
|
|
81
|
-
char read_your_writes,
|
|
76
|
+
int libsql_open_sync_with_webpki(const char *db_path, const char *primary_url,
|
|
77
|
+
const char *auth_token, char read_your_writes,
|
|
82
78
|
const char *encryption_key,
|
|
83
79
|
libsql_database_t *out_db,
|
|
84
80
|
const char **out_err_msg);
|
|
85
81
|
|
|
86
|
-
int libsql_open_sync_with_config(libsql_config config,
|
|
82
|
+
int libsql_open_sync_with_config(libsql_config config,
|
|
83
|
+
libsql_database_t *out_db,
|
|
84
|
+
const char **out_err_msg);
|
|
87
85
|
|
|
88
|
-
int libsql_open_ext(const char *url, libsql_database_t *out_db,
|
|
86
|
+
int libsql_open_ext(const char *url, libsql_database_t *out_db,
|
|
87
|
+
const char **out_err_msg);
|
|
89
88
|
|
|
90
|
-
int libsql_open_file(const char *url, libsql_database_t *out_db,
|
|
89
|
+
int libsql_open_file(const char *url, libsql_database_t *out_db,
|
|
90
|
+
const char **out_err_msg);
|
|
91
91
|
|
|
92
|
-
int libsql_open_remote(const char *url, const char *auth_token,
|
|
92
|
+
int libsql_open_remote(const char *url, const char *auth_token,
|
|
93
|
+
libsql_database_t *out_db, const char **out_err_msg);
|
|
93
94
|
|
|
94
|
-
int libsql_open_remote_with_webpki(const char *url,
|
|
95
|
-
const char *auth_token,
|
|
95
|
+
int libsql_open_remote_with_webpki(const char *url, const char *auth_token,
|
|
96
96
|
libsql_database_t *out_db,
|
|
97
97
|
const char **out_err_msg);
|
|
98
98
|
|
|
99
99
|
void libsql_close(libsql_database_t db);
|
|
100
100
|
|
|
101
|
-
int libsql_connect(libsql_database_t db, libsql_connection_t *out_conn,
|
|
101
|
+
int libsql_connect(libsql_database_t db, libsql_connection_t *out_conn,
|
|
102
|
+
const char **out_err_msg);
|
|
102
103
|
|
|
103
|
-
int libsql_load_extension(libsql_connection_t conn,
|
|
104
|
-
const char *
|
|
105
|
-
const char *entry_point,
|
|
106
|
-
const char **out_err_msg);
|
|
104
|
+
int libsql_load_extension(libsql_connection_t conn, const char *path,
|
|
105
|
+
const char *entry_point, const char **out_err_msg);
|
|
107
106
|
|
|
108
107
|
int libsql_reset(libsql_connection_t conn, const char **out_err_msg);
|
|
109
108
|
|
|
110
109
|
void libsql_disconnect(libsql_connection_t conn);
|
|
111
110
|
|
|
112
|
-
int libsql_prepare(libsql_connection_t conn, const char *sql,
|
|
111
|
+
int libsql_prepare(libsql_connection_t conn, const char *sql,
|
|
112
|
+
libsql_stmt_t *out_stmt, const char **out_err_msg);
|
|
113
113
|
|
|
114
|
-
int libsql_bind_int(libsql_stmt_t stmt, int idx, long long value,
|
|
114
|
+
int libsql_bind_int(libsql_stmt_t stmt, int idx, long long value,
|
|
115
|
+
const char **out_err_msg);
|
|
115
116
|
|
|
116
|
-
int libsql_bind_float(libsql_stmt_t stmt, int idx, double value,
|
|
117
|
+
int libsql_bind_float(libsql_stmt_t stmt, int idx, double value,
|
|
118
|
+
const char **out_err_msg);
|
|
117
119
|
|
|
118
120
|
int libsql_bind_null(libsql_stmt_t stmt, int idx, const char **out_err_msg);
|
|
119
121
|
|
|
120
|
-
int libsql_bind_string(libsql_stmt_t stmt, int idx, const char *value,
|
|
122
|
+
int libsql_bind_string(libsql_stmt_t stmt, int idx, const char *value,
|
|
123
|
+
const char **out_err_msg);
|
|
121
124
|
|
|
122
|
-
int libsql_bind_blob(libsql_stmt_t stmt, int idx, const unsigned char *value,
|
|
125
|
+
int libsql_bind_blob(libsql_stmt_t stmt, int idx, const unsigned char *value,
|
|
126
|
+
int value_len, const char **out_err_msg);
|
|
123
127
|
|
|
124
|
-
int libsql_query_stmt(libsql_stmt_t stmt, libsql_rows_t *out_rows,
|
|
128
|
+
int libsql_query_stmt(libsql_stmt_t stmt, libsql_rows_t *out_rows,
|
|
129
|
+
const char **out_err_msg);
|
|
125
130
|
|
|
126
131
|
int libsql_execute_stmt(libsql_stmt_t stmt, const char **out_err_msg);
|
|
127
132
|
|
|
@@ -129,9 +134,11 @@ int libsql_reset_stmt(libsql_stmt_t stmt, const char **out_err_msg);
|
|
|
129
134
|
|
|
130
135
|
void libsql_free_stmt(libsql_stmt_t stmt);
|
|
131
136
|
|
|
132
|
-
int libsql_query(libsql_connection_t conn, const char *sql,
|
|
137
|
+
int libsql_query(libsql_connection_t conn, const char *sql,
|
|
138
|
+
libsql_rows_t *out_rows, const char **out_err_msg);
|
|
133
139
|
|
|
134
|
-
int libsql_execute(libsql_connection_t conn, const char *sql,
|
|
140
|
+
int libsql_execute(libsql_connection_t conn, const char *sql,
|
|
141
|
+
const char **out_err_msg);
|
|
135
142
|
|
|
136
143
|
void libsql_free_rows(libsql_rows_t res);
|
|
137
144
|
|
|
@@ -141,27 +148,34 @@ void libsql_wait_result(libsql_rows_future_t res);
|
|
|
141
148
|
|
|
142
149
|
int libsql_column_count(libsql_rows_t res);
|
|
143
150
|
|
|
144
|
-
int libsql_column_name(libsql_rows_t res, int col, const char **out_name,
|
|
151
|
+
int libsql_column_name(libsql_rows_t res, int col, const char **out_name,
|
|
152
|
+
const char **out_err_msg);
|
|
145
153
|
|
|
146
|
-
int libsql_column_type(libsql_rows_t res, libsql_row_t row, int col,
|
|
154
|
+
int libsql_column_type(libsql_rows_t res, libsql_row_t row, int col,
|
|
155
|
+
int *out_type, const char **out_err_msg);
|
|
147
156
|
|
|
148
157
|
uint64_t libsql_changes(libsql_connection_t conn);
|
|
149
158
|
|
|
150
159
|
int64_t libsql_last_insert_rowid(libsql_connection_t conn);
|
|
151
160
|
|
|
152
|
-
int libsql_next_row(libsql_rows_t res, libsql_row_t *out_row,
|
|
161
|
+
int libsql_next_row(libsql_rows_t res, libsql_row_t *out_row,
|
|
162
|
+
const char **out_err_msg);
|
|
153
163
|
|
|
154
164
|
void libsql_free_row(libsql_row_t res);
|
|
155
165
|
|
|
156
|
-
int libsql_get_string(libsql_row_t res, int col, const char **out_value,
|
|
166
|
+
int libsql_get_string(libsql_row_t res, int col, const char **out_value,
|
|
167
|
+
const char **out_err_msg);
|
|
157
168
|
|
|
158
169
|
void libsql_free_string(const char *ptr);
|
|
159
170
|
|
|
160
|
-
int libsql_get_int(libsql_row_t res, int col, long long *out_value,
|
|
171
|
+
int libsql_get_int(libsql_row_t res, int col, long long *out_value,
|
|
172
|
+
const char **out_err_msg);
|
|
161
173
|
|
|
162
|
-
int libsql_get_float(libsql_row_t res, int col, double *out_value,
|
|
174
|
+
int libsql_get_float(libsql_row_t res, int col, double *out_value,
|
|
175
|
+
const char **out_err_msg);
|
|
163
176
|
|
|
164
|
-
int libsql_get_blob(libsql_row_t res, int col, blob *out_blob,
|
|
177
|
+
int libsql_get_blob(libsql_row_t res, int col, blob *out_blob,
|
|
178
|
+
const char **out_err_msg);
|
|
165
179
|
|
|
166
180
|
void libsql_free_blob(blob b);
|
|
167
181
|
|
package/cpp/logs.h
CHANGED
|
@@ -15,26 +15,26 @@
|
|
|
15
15
|
#include <stdio.h>
|
|
16
16
|
#define LOG_TAG "op-sqlite"
|
|
17
17
|
#define LOGV(...) \
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
printf(" "); \
|
|
19
|
+
printf(__VA_ARGS__); \
|
|
20
|
+
printf("\t - <%s> \n", LOG_TAG);
|
|
21
21
|
#define LOGD(...) \
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
printf(" "); \
|
|
23
|
+
printf(__VA_ARGS__); \
|
|
24
|
+
printf("\t - <%s> \n", LOG_TAG);
|
|
25
25
|
#define LOGI(...) \
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
printf(" "); \
|
|
27
|
+
printf(__VA_ARGS__); \
|
|
28
|
+
printf("\t - <%s> \n", LOG_TAG);
|
|
29
29
|
#define LOGW(...) \
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
printf(" * Warning: "); \
|
|
31
|
+
printf(__VA_ARGS__); \
|
|
32
|
+
printf("\t - <%s> \n", LOG_TAG);
|
|
33
33
|
#define LOGE(...) \
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
printf(" *** Error: "); \
|
|
35
|
+
printf(__VA_ARGS__); \
|
|
36
|
+
printf("\t - <%s> \n", LOG_TAG);
|
|
37
37
|
#define LOGSIMPLE(...) \
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
printf(" "); \
|
|
39
|
+
printf(__VA_ARGS__);
|
|
40
40
|
#endif // ANDROID
|
package/cpp/types.h
CHANGED
|
@@ -6,28 +6,28 @@
|
|
|
6
6
|
#include <vector>
|
|
7
7
|
|
|
8
8
|
struct ArrayBuffer {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
std::shared_ptr<uint8_t> data;
|
|
10
|
+
size_t size;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
using JSVariant = std::variant<nullptr_t, bool, int, double, long, long long,
|
|
14
14
|
std::string, ArrayBuffer>;
|
|
15
15
|
|
|
16
16
|
struct BridgeResult {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
std::string message;
|
|
18
|
+
int affectedRows;
|
|
19
|
+
double insertId;
|
|
20
|
+
std::vector<std::vector<JSVariant>> rows;
|
|
21
|
+
std::vector<std::string> column_names;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
struct BatchResult {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
std::string message;
|
|
26
|
+
int affectedRows;
|
|
27
|
+
int commands;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
struct BatchArguments {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
std::string sql;
|
|
32
|
+
std::vector<JSVariant> params;
|
|
33
33
|
};
|