@op-engineering/op-sqlite 6.0.2-beta1 → 6.0.2-beta4
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/android/CMakeLists.txt +26 -15
- package/android/build.gradle +10 -1
- package/android/cpp-adapter.cpp +4 -0
- package/android/jniLibs/arm64-v8a/libsql_experimental.a +0 -0
- package/android/jniLibs/armeabi-v7a/libsql_experimental.a +0 -0
- package/android/jniLibs/x86/libsql_experimental.a +0 -0
- package/android/jniLibs/x86_64/libsql_experimental.a +0 -0
- package/cpp/DBHostObject.cpp +234 -87
- package/cpp/DBHostObject.h +19 -10
- package/cpp/PreparedStatementHostObject.cpp +28 -14
- package/cpp/PreparedStatementHostObject.h +18 -14
- package/cpp/bindings.cpp +49 -32
- package/cpp/bindings.h +4 -3
- package/cpp/bridge.cpp +45 -0
- package/cpp/bridge.h +3 -0
- package/cpp/libsql/bridge.cpp +660 -0
- package/cpp/libsql/bridge.h +76 -0
- package/cpp/libsql/libsql.h +133 -0
- package/cpp/sqlite3.h +0 -1
- package/cpp/types.h +5 -0
- package/cpp/utils.cpp +45 -3
- package/cpp/utils.h +2 -3
- package/ios/libsql.xcframework/Info.plist +48 -0
- package/ios/libsql.xcframework/ios-arm64/Headers/libsql.h +133 -0
- package/ios/libsql.xcframework/ios-arm64/libsql_experimental.a +0 -0
- package/ios/libsql.xcframework/ios-arm64_x86_64-simulator/Headers/libsql.h +133 -0
- package/ios/libsql.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.a +0 -0
- package/lib/commonjs/index.js +167 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +164 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +14 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/op-sqlite.podspec +20 -3
- package/package.json +1 -1
- package/src/index.ts +209 -3
- package/cpp/sqlbatchexecutor.cpp +0 -93
- package/cpp/sqlbatchexecutor.h +0 -30
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "DumbHostObject.h"
|
|
4
|
+
#include "SmartHostObject.h"
|
|
5
|
+
#include "libsql.h"
|
|
6
|
+
#include "types.h"
|
|
7
|
+
#include "utils.h"
|
|
8
|
+
#include <vector>
|
|
9
|
+
|
|
10
|
+
#define LIBSQL_INT 1
|
|
11
|
+
#define LIBSQL_FLOAT 2
|
|
12
|
+
#define LIBSQL_TEXT 3
|
|
13
|
+
#define LIBSQL_BLOB 4
|
|
14
|
+
#define LIBSQL_NULL 5
|
|
15
|
+
|
|
16
|
+
namespace opsqlite {
|
|
17
|
+
|
|
18
|
+
namespace jsi = facebook::jsi;
|
|
19
|
+
|
|
20
|
+
/// Convenience types to avoid super long types
|
|
21
|
+
typedef std::function<void(std::string dbName, std::string table_name,
|
|
22
|
+
std::string operation, int row_id)>
|
|
23
|
+
UpdateCallback;
|
|
24
|
+
typedef std::function<void(std::string dbName)> CommitCallback;
|
|
25
|
+
typedef std::function<void(std::string dbName)> RollbackCallback;
|
|
26
|
+
|
|
27
|
+
std::string opsqlite_get_db_path(std::string const &name,
|
|
28
|
+
std::string const &location);
|
|
29
|
+
|
|
30
|
+
BridgeResult opsqlite_libsql_open(std::string const &name,
|
|
31
|
+
std::string const &path);
|
|
32
|
+
|
|
33
|
+
BridgeResult opsqlite_libsql_open_remote(std::string const &url,
|
|
34
|
+
std::string const &auth_token);
|
|
35
|
+
|
|
36
|
+
BridgeResult opsqlite_libsql_close(std::string const &name);
|
|
37
|
+
|
|
38
|
+
BridgeResult opsqlite_libsql_remove(std::string const &name,
|
|
39
|
+
std::string const &path);
|
|
40
|
+
|
|
41
|
+
BridgeResult opsqlite_libsql_attach(std::string const &mainDBName,
|
|
42
|
+
std::string const &docPath,
|
|
43
|
+
std::string const &databaseToAttach,
|
|
44
|
+
std::string const &alias);
|
|
45
|
+
|
|
46
|
+
BridgeResult opsqlite_libsql_detach(std::string const &mainDBName,
|
|
47
|
+
std::string const &alias);
|
|
48
|
+
|
|
49
|
+
BridgeResult opsqlite_libsql_execute(
|
|
50
|
+
std::string const &name, std::string const &query,
|
|
51
|
+
const std::vector<JSVariant> *params, std::vector<DumbHostObject> *results,
|
|
52
|
+
std::shared_ptr<std::vector<SmartHostObject>> metadatas);
|
|
53
|
+
|
|
54
|
+
BridgeResult
|
|
55
|
+
opsqlite_libsql_execute_raw(std::string const &dbName, std::string const &query,
|
|
56
|
+
const std::vector<JSVariant> *params,
|
|
57
|
+
std::vector<std::vector<JSVariant>> *results);
|
|
58
|
+
|
|
59
|
+
BatchResult
|
|
60
|
+
opsqlite_libsql_execute_batch(std::string const &name,
|
|
61
|
+
std::vector<BatchArguments> *commands);
|
|
62
|
+
|
|
63
|
+
void opsqlite_libsql_close_all();
|
|
64
|
+
|
|
65
|
+
libsql_stmt_t opsqlite_libsql_prepare_statement(std::string const &name,
|
|
66
|
+
std::string const &query);
|
|
67
|
+
|
|
68
|
+
void opsqlite_libsql_bind_statement(libsql_stmt_t stmt,
|
|
69
|
+
const std::vector<JSVariant> *params);
|
|
70
|
+
|
|
71
|
+
BridgeResult opsqlite_libsql_execute_prepared_statement(
|
|
72
|
+
std::string const &name, libsql_stmt_t stmt,
|
|
73
|
+
std::vector<DumbHostObject> *results,
|
|
74
|
+
std::shared_ptr<std::vector<SmartHostObject>> metadatas);
|
|
75
|
+
|
|
76
|
+
} // namespace opsqlite
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#ifndef LIBSQL_EXPERIMENTAL_H
|
|
2
|
+
#define LIBSQL_EXPERIMENTAL_H
|
|
3
|
+
|
|
4
|
+
#include <stdint.h>
|
|
5
|
+
|
|
6
|
+
#define LIBSQL_INT 1
|
|
7
|
+
|
|
8
|
+
#define LIBSQL_FLOAT 2
|
|
9
|
+
|
|
10
|
+
#define LIBSQL_TEXT 3
|
|
11
|
+
|
|
12
|
+
#define LIBSQL_BLOB 4
|
|
13
|
+
|
|
14
|
+
#define LIBSQL_NULL 5
|
|
15
|
+
|
|
16
|
+
typedef struct libsql_connection libsql_connection;
|
|
17
|
+
|
|
18
|
+
typedef struct libsql_database libsql_database;
|
|
19
|
+
|
|
20
|
+
typedef struct libsql_row libsql_row;
|
|
21
|
+
|
|
22
|
+
typedef struct libsql_rows libsql_rows;
|
|
23
|
+
|
|
24
|
+
typedef struct libsql_rows_future libsql_rows_future;
|
|
25
|
+
|
|
26
|
+
typedef struct libsql_stmt libsql_stmt;
|
|
27
|
+
|
|
28
|
+
typedef const libsql_database *libsql_database_t;
|
|
29
|
+
|
|
30
|
+
typedef const libsql_connection *libsql_connection_t;
|
|
31
|
+
|
|
32
|
+
typedef const libsql_stmt *libsql_stmt_t;
|
|
33
|
+
|
|
34
|
+
typedef const libsql_rows *libsql_rows_t;
|
|
35
|
+
|
|
36
|
+
typedef const libsql_rows_future *libsql_rows_future_t;
|
|
37
|
+
|
|
38
|
+
typedef const libsql_row *libsql_row_t;
|
|
39
|
+
|
|
40
|
+
typedef struct {
|
|
41
|
+
const char *ptr;
|
|
42
|
+
int len;
|
|
43
|
+
} blob;
|
|
44
|
+
|
|
45
|
+
#ifdef __cplusplus
|
|
46
|
+
extern "C" {
|
|
47
|
+
#endif // __cplusplus
|
|
48
|
+
|
|
49
|
+
int libsql_sync(libsql_database_t db, const char **out_err_msg);
|
|
50
|
+
|
|
51
|
+
int libsql_open_sync(const char *db_path,
|
|
52
|
+
const char *primary_url,
|
|
53
|
+
const char *auth_token,
|
|
54
|
+
char read_your_writes,
|
|
55
|
+
const char *encryption_key,
|
|
56
|
+
libsql_database_t *out_db,
|
|
57
|
+
const char **out_err_msg);
|
|
58
|
+
|
|
59
|
+
int libsql_open_ext(const char *url, libsql_database_t *out_db, const char **out_err_msg);
|
|
60
|
+
|
|
61
|
+
int libsql_open_file(const char *url, libsql_database_t *out_db, const char **out_err_msg);
|
|
62
|
+
|
|
63
|
+
int libsql_open_remote(const char *url, const char *auth_token, libsql_database_t *out_db, const char **out_err_msg);
|
|
64
|
+
|
|
65
|
+
void libsql_close(libsql_database_t db);
|
|
66
|
+
|
|
67
|
+
int libsql_connect(libsql_database_t db, libsql_connection_t *out_conn, const char **out_err_msg);
|
|
68
|
+
|
|
69
|
+
int libsql_reset(libsql_connection_t conn, const char **out_err_msg);
|
|
70
|
+
|
|
71
|
+
void libsql_disconnect(libsql_connection_t conn);
|
|
72
|
+
|
|
73
|
+
int libsql_prepare(libsql_connection_t conn, const char *sql, libsql_stmt_t *out_stmt, const char **out_err_msg);
|
|
74
|
+
|
|
75
|
+
int libsql_bind_int(libsql_stmt_t stmt, int idx, long long value, const char **out_err_msg);
|
|
76
|
+
|
|
77
|
+
int libsql_bind_float(libsql_stmt_t stmt, int idx, double value, const char **out_err_msg);
|
|
78
|
+
|
|
79
|
+
int libsql_bind_null(libsql_stmt_t stmt, int idx, const char **out_err_msg);
|
|
80
|
+
|
|
81
|
+
int libsql_bind_string(libsql_stmt_t stmt, int idx, const char *value, const char **out_err_msg);
|
|
82
|
+
|
|
83
|
+
int libsql_bind_blob(libsql_stmt_t stmt, int idx, const unsigned char *value, int value_len, const char **out_err_msg);
|
|
84
|
+
|
|
85
|
+
int libsql_query_stmt(libsql_stmt_t stmt, libsql_rows_t *out_rows, const char **out_err_msg);
|
|
86
|
+
|
|
87
|
+
int libsql_execute_stmt(libsql_stmt_t stmt, const char **out_err_msg);
|
|
88
|
+
|
|
89
|
+
int libsql_reset_stmt(libsql_stmt_t stmt, const char **out_err_msg);
|
|
90
|
+
|
|
91
|
+
void libsql_free_stmt(libsql_stmt_t stmt);
|
|
92
|
+
|
|
93
|
+
int libsql_query(libsql_connection_t conn, const char *sql, libsql_rows_t *out_rows, const char **out_err_msg);
|
|
94
|
+
|
|
95
|
+
int libsql_execute(libsql_connection_t conn, const char *sql, const char **out_err_msg);
|
|
96
|
+
|
|
97
|
+
void libsql_free_rows(libsql_rows_t res);
|
|
98
|
+
|
|
99
|
+
void libsql_free_rows_future(libsql_rows_future_t res);
|
|
100
|
+
|
|
101
|
+
void libsql_wait_result(libsql_rows_future_t res);
|
|
102
|
+
|
|
103
|
+
int libsql_column_count(libsql_rows_t res);
|
|
104
|
+
|
|
105
|
+
int libsql_column_name(libsql_rows_t res, int col, const char **out_name, const char **out_err_msg);
|
|
106
|
+
|
|
107
|
+
int libsql_column_type(libsql_rows_t res, libsql_row_t row, int col, int *out_type, const char **out_err_msg);
|
|
108
|
+
|
|
109
|
+
uint64_t libsql_changes(libsql_connection_t conn);
|
|
110
|
+
|
|
111
|
+
int64_t libsql_last_insert_rowid(libsql_connection_t conn);
|
|
112
|
+
|
|
113
|
+
int libsql_next_row(libsql_rows_t res, libsql_row_t *out_row, const char **out_err_msg);
|
|
114
|
+
|
|
115
|
+
void libsql_free_row(libsql_row_t res);
|
|
116
|
+
|
|
117
|
+
int libsql_get_string(libsql_row_t res, int col, const char **out_value, const char **out_err_msg);
|
|
118
|
+
|
|
119
|
+
void libsql_free_string(const char *ptr);
|
|
120
|
+
|
|
121
|
+
int libsql_get_int(libsql_row_t res, int col, long long *out_value, const char **out_err_msg);
|
|
122
|
+
|
|
123
|
+
int libsql_get_float(libsql_row_t res, int col, double *out_value, const char **out_err_msg);
|
|
124
|
+
|
|
125
|
+
int libsql_get_blob(libsql_row_t res, int col, blob *out_blob, const char **out_err_msg);
|
|
126
|
+
|
|
127
|
+
void libsql_free_blob(blob b);
|
|
128
|
+
|
|
129
|
+
#ifdef __cplusplus
|
|
130
|
+
} // extern "C"
|
|
131
|
+
#endif // __cplusplus
|
|
132
|
+
|
|
133
|
+
#endif /* LIBSQL_EXPERIMENTAL_H */
|
package/cpp/sqlite3.h
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
*************************************************************************
|
|
12
12
|
** This header file defines the interface that the SQLite library
|
|
13
13
|
** presents to client programs. If a C-function, structure, datatype,
|
|
14
|
-
** or constant definition does not appear in this file, then it is
|
|
15
14
|
** not a published API of SQLite, is subject to change without
|
|
16
15
|
** notice, and should not be referenced by programs that use SQLite.
|
|
17
16
|
**
|
package/cpp/types.h
CHANGED
|
@@ -29,4 +29,9 @@ struct ArrayBuffer {
|
|
|
29
29
|
using JSVariant = std::variant<nullptr_t, bool, int, double, long, long long,
|
|
30
30
|
std::string, ArrayBuffer>;
|
|
31
31
|
|
|
32
|
+
struct BatchArguments {
|
|
33
|
+
std::string sql;
|
|
34
|
+
std::shared_ptr<std::vector<JSVariant>> params;
|
|
35
|
+
};
|
|
36
|
+
|
|
32
37
|
#endif /* types_h */
|
package/cpp/utils.cpp
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#include "utils.h"
|
|
2
2
|
#include "SmartHostObject.h"
|
|
3
|
+
#ifndef OP_SQLITE_USE_LIBSQL
|
|
3
4
|
#include "bridge.h"
|
|
5
|
+
#endif
|
|
4
6
|
#include <fstream>
|
|
5
7
|
#include <iostream>
|
|
6
8
|
#include <sstream>
|
|
@@ -12,7 +14,6 @@ namespace opsqlite {
|
|
|
12
14
|
namespace jsi = facebook::jsi;
|
|
13
15
|
|
|
14
16
|
jsi::Value toJSI(jsi::Runtime &rt, JSVariant value) {
|
|
15
|
-
|
|
16
17
|
if (std::holds_alternative<bool>(value)) {
|
|
17
18
|
return std::get<bool>(value);
|
|
18
19
|
} else if (std::holds_alternative<int>(value)) {
|
|
@@ -22,7 +23,8 @@ jsi::Value toJSI(jsi::Runtime &rt, JSVariant value) {
|
|
|
22
23
|
} else if (std::holds_alternative<double>(value)) {
|
|
23
24
|
return jsi::Value(std::get<double>(value));
|
|
24
25
|
} else if (std::holds_alternative<std::string>(value)) {
|
|
25
|
-
|
|
26
|
+
auto str = std::get<std::string>(value);
|
|
27
|
+
return jsi::String::createFromUtf8(rt, str);
|
|
26
28
|
} else if (std::holds_alternative<ArrayBuffer>(value)) {
|
|
27
29
|
auto jsBuffer = std::get<ArrayBuffer>(value);
|
|
28
30
|
jsi::Function array_buffer_ctor =
|
|
@@ -80,7 +82,6 @@ JSVariant toVariant(jsi::Runtime &rt, const jsi::Value &value) {
|
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
std::vector<std::string> to_string_vec(jsi::Runtime &rt, jsi::Value const &xs) {
|
|
83
|
-
|
|
84
85
|
jsi::Array values = xs.asObject(rt).asArray(rt);
|
|
85
86
|
std::vector<std::string> res;
|
|
86
87
|
for (int ii = 0; ii < values.length(rt); ii++) {
|
|
@@ -218,6 +219,46 @@ create_raw_result(jsi::Runtime &rt, BridgeResult status,
|
|
|
218
219
|
return res;
|
|
219
220
|
}
|
|
220
221
|
|
|
222
|
+
void to_batch_arguments(jsi::Runtime &rt, jsi::Array const &batchParams,
|
|
223
|
+
std::vector<BatchArguments> *commands) {
|
|
224
|
+
for (int i = 0; i < batchParams.length(rt); i++) {
|
|
225
|
+
const jsi::Array &command =
|
|
226
|
+
batchParams.getValueAtIndex(rt, i).asObject(rt).asArray(rt);
|
|
227
|
+
if (command.length(rt) == 0) {
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const std::string query =
|
|
232
|
+
command.getValueAtIndex(rt, 0).asString(rt).utf8(rt);
|
|
233
|
+
const jsi::Value &commandParams = command.length(rt) > 1
|
|
234
|
+
? command.getValueAtIndex(rt, 1)
|
|
235
|
+
: jsi::Value::undefined();
|
|
236
|
+
if (!commandParams.isUndefined() &&
|
|
237
|
+
commandParams.asObject(rt).isArray(rt) &&
|
|
238
|
+
commandParams.asObject(rt).asArray(rt).length(rt) > 0 &&
|
|
239
|
+
commandParams.asObject(rt)
|
|
240
|
+
.asArray(rt)
|
|
241
|
+
.getValueAtIndex(rt, 0)
|
|
242
|
+
.isObject()) {
|
|
243
|
+
// This arguments is an array of arrays, like a batch update of a single
|
|
244
|
+
// sql command.
|
|
245
|
+
const jsi::Array &batchUpdateParams =
|
|
246
|
+
commandParams.asObject(rt).asArray(rt);
|
|
247
|
+
for (int x = 0; x < batchUpdateParams.length(rt); x++) {
|
|
248
|
+
const jsi::Value &p = batchUpdateParams.getValueAtIndex(rt, x);
|
|
249
|
+
auto params =
|
|
250
|
+
std::make_shared<std::vector<JSVariant>>(to_variant_vec(rt, p));
|
|
251
|
+
commands->push_back({query, params});
|
|
252
|
+
}
|
|
253
|
+
} else {
|
|
254
|
+
auto params = std::make_shared<std::vector<JSVariant>>(
|
|
255
|
+
to_variant_vec(rt, commandParams));
|
|
256
|
+
commands->push_back({query, params});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
#ifndef OP_SQLITE_USE_LIBSQL
|
|
221
262
|
BatchResult importSQLFile(std::string dbName, std::string fileLocation) {
|
|
222
263
|
std::string line;
|
|
223
264
|
std::ifstream sqFile(fileLocation);
|
|
@@ -256,6 +297,7 @@ BatchResult importSQLFile(std::string dbName, std::string fileLocation) {
|
|
|
256
297
|
return {SQLiteError, "[op-sqlite][loadSQLFile] Could not open file", 0, 0};
|
|
257
298
|
}
|
|
258
299
|
}
|
|
300
|
+
#endif
|
|
259
301
|
|
|
260
302
|
bool folder_exists(const std::string &foldername) {
|
|
261
303
|
struct stat buffer;
|
package/cpp/utils.h
CHANGED
|
@@ -16,19 +16,18 @@ namespace opsqlite {
|
|
|
16
16
|
namespace jsi = facebook::jsi;
|
|
17
17
|
|
|
18
18
|
jsi::Value toJSI(jsi::Runtime &rt, JSVariant value);
|
|
19
|
-
|
|
20
19
|
JSVariant toVariant(jsi::Runtime &rt, jsi::Value const &value);
|
|
21
20
|
std::vector<std::string> to_string_vec(jsi::Runtime &rt, jsi::Value const &xs);
|
|
22
21
|
std::vector<JSVariant> to_variant_vec(jsi::Runtime &rt, jsi::Value const &xs);
|
|
23
22
|
std::vector<int> to_int_vec(jsi::Runtime &rt, jsi::Value const &xs);
|
|
24
|
-
|
|
25
23
|
jsi::Value createResult(jsi::Runtime &rt, BridgeResult status,
|
|
26
24
|
std::vector<DumbHostObject> *results,
|
|
27
25
|
std::shared_ptr<std::vector<SmartHostObject>> metadata);
|
|
28
|
-
|
|
29
26
|
jsi::Value
|
|
30
27
|
create_raw_result(jsi::Runtime &rt, BridgeResult status,
|
|
31
28
|
const std::vector<std::vector<JSVariant>> *results);
|
|
29
|
+
void to_batch_arguments(jsi::Runtime &rt, jsi::Array const &batchParams,
|
|
30
|
+
std::vector<BatchArguments> *commands);
|
|
32
31
|
|
|
33
32
|
BatchResult importSQLFile(std::string dbName, std::string fileLocation);
|
|
34
33
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>AvailableLibraries</key>
|
|
6
|
+
<array>
|
|
7
|
+
<dict>
|
|
8
|
+
<key>BinaryPath</key>
|
|
9
|
+
<string>libsql_experimental.a</string>
|
|
10
|
+
<key>HeadersPath</key>
|
|
11
|
+
<string>Headers</string>
|
|
12
|
+
<key>LibraryIdentifier</key>
|
|
13
|
+
<string>ios-arm64</string>
|
|
14
|
+
<key>LibraryPath</key>
|
|
15
|
+
<string>libsql_experimental.a</string>
|
|
16
|
+
<key>SupportedArchitectures</key>
|
|
17
|
+
<array>
|
|
18
|
+
<string>arm64</string>
|
|
19
|
+
</array>
|
|
20
|
+
<key>SupportedPlatform</key>
|
|
21
|
+
<string>ios</string>
|
|
22
|
+
</dict>
|
|
23
|
+
<dict>
|
|
24
|
+
<key>BinaryPath</key>
|
|
25
|
+
<string>libsql_experimental.a</string>
|
|
26
|
+
<key>HeadersPath</key>
|
|
27
|
+
<string>Headers</string>
|
|
28
|
+
<key>LibraryIdentifier</key>
|
|
29
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
30
|
+
<key>LibraryPath</key>
|
|
31
|
+
<string>libsql_experimental.a</string>
|
|
32
|
+
<key>SupportedArchitectures</key>
|
|
33
|
+
<array>
|
|
34
|
+
<string>arm64</string>
|
|
35
|
+
<string>x86_64</string>
|
|
36
|
+
</array>
|
|
37
|
+
<key>SupportedPlatform</key>
|
|
38
|
+
<string>ios</string>
|
|
39
|
+
<key>SupportedPlatformVariant</key>
|
|
40
|
+
<string>simulator</string>
|
|
41
|
+
</dict>
|
|
42
|
+
</array>
|
|
43
|
+
<key>CFBundlePackageType</key>
|
|
44
|
+
<string>XFWK</string>
|
|
45
|
+
<key>XCFrameworkFormatVersion</key>
|
|
46
|
+
<string>1.0</string>
|
|
47
|
+
</dict>
|
|
48
|
+
</plist>
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#ifndef LIBSQL_EXPERIMENTAL_H
|
|
2
|
+
#define LIBSQL_EXPERIMENTAL_H
|
|
3
|
+
|
|
4
|
+
#include <stdint.h>
|
|
5
|
+
|
|
6
|
+
#define LIBSQL_INT 1
|
|
7
|
+
|
|
8
|
+
#define LIBSQL_FLOAT 2
|
|
9
|
+
|
|
10
|
+
#define LIBSQL_TEXT 3
|
|
11
|
+
|
|
12
|
+
#define LIBSQL_BLOB 4
|
|
13
|
+
|
|
14
|
+
#define LIBSQL_NULL 5
|
|
15
|
+
|
|
16
|
+
typedef struct libsql_connection libsql_connection;
|
|
17
|
+
|
|
18
|
+
typedef struct libsql_database libsql_database;
|
|
19
|
+
|
|
20
|
+
typedef struct libsql_row libsql_row;
|
|
21
|
+
|
|
22
|
+
typedef struct libsql_rows libsql_rows;
|
|
23
|
+
|
|
24
|
+
typedef struct libsql_rows_future libsql_rows_future;
|
|
25
|
+
|
|
26
|
+
typedef struct libsql_stmt libsql_stmt;
|
|
27
|
+
|
|
28
|
+
typedef const libsql_database *libsql_database_t;
|
|
29
|
+
|
|
30
|
+
typedef const libsql_connection *libsql_connection_t;
|
|
31
|
+
|
|
32
|
+
typedef const libsql_stmt *libsql_stmt_t;
|
|
33
|
+
|
|
34
|
+
typedef const libsql_rows *libsql_rows_t;
|
|
35
|
+
|
|
36
|
+
typedef const libsql_rows_future *libsql_rows_future_t;
|
|
37
|
+
|
|
38
|
+
typedef const libsql_row *libsql_row_t;
|
|
39
|
+
|
|
40
|
+
typedef struct {
|
|
41
|
+
const char *ptr;
|
|
42
|
+
int len;
|
|
43
|
+
} blob;
|
|
44
|
+
|
|
45
|
+
#ifdef __cplusplus
|
|
46
|
+
extern "C" {
|
|
47
|
+
#endif // __cplusplus
|
|
48
|
+
|
|
49
|
+
int libsql_sync(libsql_database_t db, const char **out_err_msg);
|
|
50
|
+
|
|
51
|
+
int libsql_open_sync(const char *db_path,
|
|
52
|
+
const char *primary_url,
|
|
53
|
+
const char *auth_token,
|
|
54
|
+
char read_your_writes,
|
|
55
|
+
const char *encryption_key,
|
|
56
|
+
libsql_database_t *out_db,
|
|
57
|
+
const char **out_err_msg);
|
|
58
|
+
|
|
59
|
+
int libsql_open_ext(const char *url, libsql_database_t *out_db, const char **out_err_msg);
|
|
60
|
+
|
|
61
|
+
int libsql_open_file(const char *url, libsql_database_t *out_db, const char **out_err_msg);
|
|
62
|
+
|
|
63
|
+
int libsql_open_remote(const char *url, const char *auth_token, libsql_database_t *out_db, const char **out_err_msg);
|
|
64
|
+
|
|
65
|
+
void libsql_close(libsql_database_t db);
|
|
66
|
+
|
|
67
|
+
int libsql_connect(libsql_database_t db, libsql_connection_t *out_conn, const char **out_err_msg);
|
|
68
|
+
|
|
69
|
+
int libsql_reset(libsql_connection_t conn, const char **out_err_msg);
|
|
70
|
+
|
|
71
|
+
void libsql_disconnect(libsql_connection_t conn);
|
|
72
|
+
|
|
73
|
+
int libsql_prepare(libsql_connection_t conn, const char *sql, libsql_stmt_t *out_stmt, const char **out_err_msg);
|
|
74
|
+
|
|
75
|
+
int libsql_bind_int(libsql_stmt_t stmt, int idx, long long value, const char **out_err_msg);
|
|
76
|
+
|
|
77
|
+
int libsql_bind_float(libsql_stmt_t stmt, int idx, double value, const char **out_err_msg);
|
|
78
|
+
|
|
79
|
+
int libsql_bind_null(libsql_stmt_t stmt, int idx, const char **out_err_msg);
|
|
80
|
+
|
|
81
|
+
int libsql_bind_string(libsql_stmt_t stmt, int idx, const char *value, const char **out_err_msg);
|
|
82
|
+
|
|
83
|
+
int libsql_bind_blob(libsql_stmt_t stmt, int idx, const unsigned char *value, int value_len, const char **out_err_msg);
|
|
84
|
+
|
|
85
|
+
int libsql_query_stmt(libsql_stmt_t stmt, libsql_rows_t *out_rows, const char **out_err_msg);
|
|
86
|
+
|
|
87
|
+
int libsql_execute_stmt(libsql_stmt_t stmt, const char **out_err_msg);
|
|
88
|
+
|
|
89
|
+
int libsql_reset_stmt(libsql_stmt_t stmt, const char **out_err_msg);
|
|
90
|
+
|
|
91
|
+
void libsql_free_stmt(libsql_stmt_t stmt);
|
|
92
|
+
|
|
93
|
+
int libsql_query(libsql_connection_t conn, const char *sql, libsql_rows_t *out_rows, const char **out_err_msg);
|
|
94
|
+
|
|
95
|
+
int libsql_execute(libsql_connection_t conn, const char *sql, const char **out_err_msg);
|
|
96
|
+
|
|
97
|
+
void libsql_free_rows(libsql_rows_t res);
|
|
98
|
+
|
|
99
|
+
void libsql_free_rows_future(libsql_rows_future_t res);
|
|
100
|
+
|
|
101
|
+
void libsql_wait_result(libsql_rows_future_t res);
|
|
102
|
+
|
|
103
|
+
int libsql_column_count(libsql_rows_t res);
|
|
104
|
+
|
|
105
|
+
int libsql_column_name(libsql_rows_t res, int col, const char **out_name, const char **out_err_msg);
|
|
106
|
+
|
|
107
|
+
int libsql_column_type(libsql_rows_t res, libsql_row_t row, int col, int *out_type, const char **out_err_msg);
|
|
108
|
+
|
|
109
|
+
uint64_t libsql_changes(libsql_connection_t conn);
|
|
110
|
+
|
|
111
|
+
int64_t libsql_last_insert_rowid(libsql_connection_t conn);
|
|
112
|
+
|
|
113
|
+
int libsql_next_row(libsql_rows_t res, libsql_row_t *out_row, const char **out_err_msg);
|
|
114
|
+
|
|
115
|
+
void libsql_free_row(libsql_row_t res);
|
|
116
|
+
|
|
117
|
+
int libsql_get_string(libsql_row_t res, int col, const char **out_value, const char **out_err_msg);
|
|
118
|
+
|
|
119
|
+
void libsql_free_string(const char *ptr);
|
|
120
|
+
|
|
121
|
+
int libsql_get_int(libsql_row_t res, int col, long long *out_value, const char **out_err_msg);
|
|
122
|
+
|
|
123
|
+
int libsql_get_float(libsql_row_t res, int col, double *out_value, const char **out_err_msg);
|
|
124
|
+
|
|
125
|
+
int libsql_get_blob(libsql_row_t res, int col, blob *out_blob, const char **out_err_msg);
|
|
126
|
+
|
|
127
|
+
void libsql_free_blob(blob b);
|
|
128
|
+
|
|
129
|
+
#ifdef __cplusplus
|
|
130
|
+
} // extern "C"
|
|
131
|
+
#endif // __cplusplus
|
|
132
|
+
|
|
133
|
+
#endif /* LIBSQL_EXPERIMENTAL_H */
|
|
Binary file
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#ifndef LIBSQL_EXPERIMENTAL_H
|
|
2
|
+
#define LIBSQL_EXPERIMENTAL_H
|
|
3
|
+
|
|
4
|
+
#include <stdint.h>
|
|
5
|
+
|
|
6
|
+
#define LIBSQL_INT 1
|
|
7
|
+
|
|
8
|
+
#define LIBSQL_FLOAT 2
|
|
9
|
+
|
|
10
|
+
#define LIBSQL_TEXT 3
|
|
11
|
+
|
|
12
|
+
#define LIBSQL_BLOB 4
|
|
13
|
+
|
|
14
|
+
#define LIBSQL_NULL 5
|
|
15
|
+
|
|
16
|
+
typedef struct libsql_connection libsql_connection;
|
|
17
|
+
|
|
18
|
+
typedef struct libsql_database libsql_database;
|
|
19
|
+
|
|
20
|
+
typedef struct libsql_row libsql_row;
|
|
21
|
+
|
|
22
|
+
typedef struct libsql_rows libsql_rows;
|
|
23
|
+
|
|
24
|
+
typedef struct libsql_rows_future libsql_rows_future;
|
|
25
|
+
|
|
26
|
+
typedef struct libsql_stmt libsql_stmt;
|
|
27
|
+
|
|
28
|
+
typedef const libsql_database *libsql_database_t;
|
|
29
|
+
|
|
30
|
+
typedef const libsql_connection *libsql_connection_t;
|
|
31
|
+
|
|
32
|
+
typedef const libsql_stmt *libsql_stmt_t;
|
|
33
|
+
|
|
34
|
+
typedef const libsql_rows *libsql_rows_t;
|
|
35
|
+
|
|
36
|
+
typedef const libsql_rows_future *libsql_rows_future_t;
|
|
37
|
+
|
|
38
|
+
typedef const libsql_row *libsql_row_t;
|
|
39
|
+
|
|
40
|
+
typedef struct {
|
|
41
|
+
const char *ptr;
|
|
42
|
+
int len;
|
|
43
|
+
} blob;
|
|
44
|
+
|
|
45
|
+
#ifdef __cplusplus
|
|
46
|
+
extern "C" {
|
|
47
|
+
#endif // __cplusplus
|
|
48
|
+
|
|
49
|
+
int libsql_sync(libsql_database_t db, const char **out_err_msg);
|
|
50
|
+
|
|
51
|
+
int libsql_open_sync(const char *db_path,
|
|
52
|
+
const char *primary_url,
|
|
53
|
+
const char *auth_token,
|
|
54
|
+
char read_your_writes,
|
|
55
|
+
const char *encryption_key,
|
|
56
|
+
libsql_database_t *out_db,
|
|
57
|
+
const char **out_err_msg);
|
|
58
|
+
|
|
59
|
+
int libsql_open_ext(const char *url, libsql_database_t *out_db, const char **out_err_msg);
|
|
60
|
+
|
|
61
|
+
int libsql_open_file(const char *url, libsql_database_t *out_db, const char **out_err_msg);
|
|
62
|
+
|
|
63
|
+
int libsql_open_remote(const char *url, const char *auth_token, libsql_database_t *out_db, const char **out_err_msg);
|
|
64
|
+
|
|
65
|
+
void libsql_close(libsql_database_t db);
|
|
66
|
+
|
|
67
|
+
int libsql_connect(libsql_database_t db, libsql_connection_t *out_conn, const char **out_err_msg);
|
|
68
|
+
|
|
69
|
+
int libsql_reset(libsql_connection_t conn, const char **out_err_msg);
|
|
70
|
+
|
|
71
|
+
void libsql_disconnect(libsql_connection_t conn);
|
|
72
|
+
|
|
73
|
+
int libsql_prepare(libsql_connection_t conn, const char *sql, libsql_stmt_t *out_stmt, const char **out_err_msg);
|
|
74
|
+
|
|
75
|
+
int libsql_bind_int(libsql_stmt_t stmt, int idx, long long value, const char **out_err_msg);
|
|
76
|
+
|
|
77
|
+
int libsql_bind_float(libsql_stmt_t stmt, int idx, double value, const char **out_err_msg);
|
|
78
|
+
|
|
79
|
+
int libsql_bind_null(libsql_stmt_t stmt, int idx, const char **out_err_msg);
|
|
80
|
+
|
|
81
|
+
int libsql_bind_string(libsql_stmt_t stmt, int idx, const char *value, const char **out_err_msg);
|
|
82
|
+
|
|
83
|
+
int libsql_bind_blob(libsql_stmt_t stmt, int idx, const unsigned char *value, int value_len, const char **out_err_msg);
|
|
84
|
+
|
|
85
|
+
int libsql_query_stmt(libsql_stmt_t stmt, libsql_rows_t *out_rows, const char **out_err_msg);
|
|
86
|
+
|
|
87
|
+
int libsql_execute_stmt(libsql_stmt_t stmt, const char **out_err_msg);
|
|
88
|
+
|
|
89
|
+
int libsql_reset_stmt(libsql_stmt_t stmt, const char **out_err_msg);
|
|
90
|
+
|
|
91
|
+
void libsql_free_stmt(libsql_stmt_t stmt);
|
|
92
|
+
|
|
93
|
+
int libsql_query(libsql_connection_t conn, const char *sql, libsql_rows_t *out_rows, const char **out_err_msg);
|
|
94
|
+
|
|
95
|
+
int libsql_execute(libsql_connection_t conn, const char *sql, const char **out_err_msg);
|
|
96
|
+
|
|
97
|
+
void libsql_free_rows(libsql_rows_t res);
|
|
98
|
+
|
|
99
|
+
void libsql_free_rows_future(libsql_rows_future_t res);
|
|
100
|
+
|
|
101
|
+
void libsql_wait_result(libsql_rows_future_t res);
|
|
102
|
+
|
|
103
|
+
int libsql_column_count(libsql_rows_t res);
|
|
104
|
+
|
|
105
|
+
int libsql_column_name(libsql_rows_t res, int col, const char **out_name, const char **out_err_msg);
|
|
106
|
+
|
|
107
|
+
int libsql_column_type(libsql_rows_t res, libsql_row_t row, int col, int *out_type, const char **out_err_msg);
|
|
108
|
+
|
|
109
|
+
uint64_t libsql_changes(libsql_connection_t conn);
|
|
110
|
+
|
|
111
|
+
int64_t libsql_last_insert_rowid(libsql_connection_t conn);
|
|
112
|
+
|
|
113
|
+
int libsql_next_row(libsql_rows_t res, libsql_row_t *out_row, const char **out_err_msg);
|
|
114
|
+
|
|
115
|
+
void libsql_free_row(libsql_row_t res);
|
|
116
|
+
|
|
117
|
+
int libsql_get_string(libsql_row_t res, int col, const char **out_value, const char **out_err_msg);
|
|
118
|
+
|
|
119
|
+
void libsql_free_string(const char *ptr);
|
|
120
|
+
|
|
121
|
+
int libsql_get_int(libsql_row_t res, int col, long long *out_value, const char **out_err_msg);
|
|
122
|
+
|
|
123
|
+
int libsql_get_float(libsql_row_t res, int col, double *out_value, const char **out_err_msg);
|
|
124
|
+
|
|
125
|
+
int libsql_get_blob(libsql_row_t res, int col, blob *out_blob, const char **out_err_msg);
|
|
126
|
+
|
|
127
|
+
void libsql_free_blob(blob b);
|
|
128
|
+
|
|
129
|
+
#ifdef __cplusplus
|
|
130
|
+
} // extern "C"
|
|
131
|
+
#endif // __cplusplus
|
|
132
|
+
|
|
133
|
+
#endif /* LIBSQL_EXPERIMENTAL_H */
|