Skip to content
Merged
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Some of the big supported features:
- SQLCipher is supported as a compilation target
- FTS5 plugin
- Rtree plugin
- cr-sqlite plugin
- sqlite-vec plugin
- Reactive queries
- Custom tokenizers
Expand Down
6 changes: 0 additions & 6 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ else()
target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlite3.c ../cpp/bridge.cpp)
endif()

if (USE_CRSQLITE)
add_definitions(
-DOP_SQLITE_USE_CRSQLITE=1
)
endif()

if (USE_SQLITE_VEC)
add_definitions(
-DOP_SQLITE_USE_SQLITE_VEC=1
Expand Down
18 changes: 0 additions & 18 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def reactNativeArchitectures() {
def useSQLCipher = false
def useLibsql = false
def useTurso = false
def useCRSQLite = false
def performanceMode = false
def sqliteFlags = ""
def enableFTS5 = false
Expand Down Expand Up @@ -74,7 +73,6 @@ def opsqliteConfig = packageJson["op-sqlite"]
if(opsqliteConfig) {
println "[OP-SQLITE] Detected op-sqlite config from package.json at: " + packageJsonFile.absolutePath
useSQLCipher = !!opsqliteConfig["sqlcipher"]
useCRSQLite = !!opsqliteConfig["crsqlite"]
useSqliteVec = !!opsqliteConfig["sqliteVec"]
performanceMode = opsqliteConfig["performanceMode"]
sqliteFlags = opsqliteConfig["sqliteFlags"] ? opsqliteConfig["sqliteFlags"] : ""
Expand All @@ -89,10 +87,6 @@ if(useLibsql && useTurso) {
throw new GradleException("[OP-SQLITE] Error: libsql and turso backends are mutually exclusive.")
}

if(useLibsql && useCRSQLite) {
throw new GradleException("[OP-SQLITE] Error: You cannot use crsqlite with libsql.")
}

if(useSQLCipher) {
println "[OP-SQLITE] using sqlcipher."
} else if(useTurso) {
Expand All @@ -101,10 +95,6 @@ if(useSQLCipher) {
println "[OP-SQLITE] using libsql. Report any issues to Turso"
}

if(useCRSQLite) {
println "[OP-SQLITE] using CR-SQLite"
}

if(performanceMode) {
println "[OP-SQLITE] Performance mode enabled"
}
Expand Down Expand Up @@ -175,10 +165,6 @@ android {
cFlags += "-DOP_SQLITE_USE_TURSO=1"
cppFlags += "-DOP_SQLITE_USE_TURSO=1"
}
if(useCRSQLite) {
cFlags += "-DOP_SQLITE_USE_CRSQLITE=1"
cppFlags += "-DOP_SQLITE_USE_CRSQLITE=1"
}
if(useSqliteVec) {
cFlags += "-DOP_SQLITE_USE_SQLITE_VEC=1"
cppFlags += "-DOP_SQLITE_USE_SQLITE_VEC=1"
Expand Down Expand Up @@ -206,7 +192,6 @@ android {
"-DDEFAULT_SQLITE_FLAGS='${defaultSqliteFlags.join(' ')}'",
"-DSQLITE_FLAGS='$sqliteFlags'",
"-DUSE_SQLCIPHER=${useSQLCipher ? 1 : 0}",
"-DUSE_CRSQLITE=${useCRSQLite ? 1 : 0}",
"-DUSE_LIBSQL=${useLibsql ? 1 : 0}",
"-DUSE_TURSO=${useTurso ? 1 : 0}",
"-DUSE_SQLITE_VEC=${useSqliteVec ? 1 : 0}",
Expand Down Expand Up @@ -277,9 +262,6 @@ android {
if (useTurso) {
srcDirs += 'src/main/tursoLibs'
}
if (useCRSQLite) {
srcDirs += 'src/main/libcrsqlite'
}
if (useSqliteVec) {
srcDirs += 'src/main/libsqlitevec'
}
Expand Down
3 changes: 1 addition & 2 deletions android/cpp-adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ struct OPSQLiteBridge : jni::JavaClass<OPSQLiteBridge> {
std::string dbPathStr = dbPath->toStdString();

auto generation_alive = opsqlite::install(
*jsiRuntime, jsCallInvoker, dbPathStr.c_str(), "libcrsqlite",
"libsqlite_vec");
*jsiRuntime, jsCallInvoker, dbPathStr.c_str(), "libsqlite_vec");

auto *handle = new std::shared_ptr<std::atomic<bool>>(generation_alive);
return reinterpret_cast<jlong>(handle);
Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed android/src/main/libcrsqlite/x86/libcrsqlite.so
Binary file not shown.
Binary file removed android/src/main/libcrsqlite/x86_64/libcrsqlite.so
Binary file not shown.
5 changes: 1 addition & 4 deletions cpp/OPSqlite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace jsi = facebook::jsi;
namespace react = facebook::react;

std::string _base_path;
std::string _crsqlite_path;
std::string _sqlite_vec_path;
std::shared_ptr<react::CallInvoker> invoker;
std::shared_ptr<std::atomic<bool>> generation_alive;
Expand All @@ -42,11 +41,9 @@ void invalidate(const std::shared_ptr<std::atomic<bool>> &generation_alive) {

std::shared_ptr<std::atomic<bool>>
install(jsi::Runtime &rt, const std::shared_ptr<react::CallInvoker> &_invoker,
const char *base_path, const char *crsqlite_path,
const char *sqlite_vec_path) {
const char *base_path, const char *sqlite_vec_path) {

_base_path = std::string(base_path);
_crsqlite_path = std::string(crsqlite_path);
_sqlite_vec_path = std::string(sqlite_vec_path);
opsqlite::invoker = _invoker;

Expand Down
3 changes: 1 addition & 2 deletions cpp/OPSqlite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ namespace react = facebook::react;
// look it up -- see the comment on opsqlite::generation_alive in types.hpp.
std::shared_ptr<std::atomic<bool>>
install(jsi::Runtime &rt, const std::shared_ptr<react::CallInvoker> &invoker,
const char *base_path, const char *crsqlite_path,
const char *sqlite_vec_path);
const char *base_path, const char *sqlite_vec_path);
void invalidate(const std::shared_ptr<std::atomic<bool>> &generation_alive);
void expoUpdatesWorkaround(const char *base_path);

Expand Down
15 changes: 0 additions & 15 deletions cpp/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,6 @@ sqlite3 *opsqlite_open(std::string const &name, std::string const &path,
sqlite3_enable_load_extension(db, 1);
#endif

#ifdef OP_SQLITE_USE_CRSQLITE
const char *crsqliteEntryPoint = "sqlite3_crsqlite_init";

sqlite3_load_extension(db, _crsqlite_path.c_str(), crsqliteEntryPoint,
&errMsg);

if (errMsg != nullptr) {
throw std::runtime_error(errMsg);
}
#endif

#ifdef OP_SQLITE_USE_SQLITE_VEC
const char *vec_entry_point = "sqlite3_vec_init";

Expand Down Expand Up @@ -172,10 +161,6 @@ void create_dirs_if_needed(const std::string &path) {
}

void opsqlite_close(sqlite3 *db) {
#ifdef OP_SQLITE_USE_CRSQLITE
opsqlite_execute(db, "select crsql_finalize();", nullptr);
#endif

sqlite3_close_v2(db);
}

Expand Down
5 changes: 2 additions & 3 deletions cpp/bridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ typedef std::function<void(std::string dbName, std::string tableName,
typedef std::function<void(std::string dbName)> CommitCallback;
typedef std::function<void(std::string dbName)> RollbackCallback;

// Paths to the optional loadable extensions, set once in install() and
// Path to the optional loadable extension, set once in install() and
// shared by every subsequent open() call instead of being threaded through
// as parameters.
extern std::string _crsqlite_path;
// as a parameter.
extern std::string _sqlite_vec_path;

std::string opsqlite_get_db_path(std::string const &db_name,
Expand Down
12 changes: 6 additions & 6 deletions docs/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,13 +492,13 @@ Loading runtime extensions is supported. You need compile your extension to the
/main
/jniLibs
/arm64-v8a
libcrsqlite.so
libmyextension.so
/armeabi-v7a
libcrsqlite.so
libmyextension.so
/x86
libcrsqlite.so
libmyextension.so
/x86_64
libcrsqlite.so
libmyextension.so
```

### iOS
Expand All @@ -514,9 +514,9 @@ Loading runtime extensions is supported. You need compile your extension to the
import {open, getDylibPath} from '@op-sqlite/op-engineering';

const db = open(...);
let path = "libcrsqlite" // in Android it will be the name of the .so
let path = "libmyextension" // in Android it will be the name of the .so
if (Platform.os == "ios") {
path = getDylibPath("io.vlcn.crsqlite", "crsqlite"); // You need to get the bundle name from the .framework/plist.info inside of the .xcframework you created and then the canonical name inside the same plist
path = getDylibPath("com.example.myextension", "myextension"); // You need to get the bundle name from the .framework/plist.info inside of the .xcframework you created and then the canonical name inside the same plist
}
// Extensions usually have a default entry point to be loaded, if the documentation says nothing, you should assume no entry point change
db.loadExtension(path);
Expand Down
4 changes: 4 additions & 0 deletions docs/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ sidebar_position: 11

# API Changes

## 18.0.0

- **Breaking:** Removed `crsqlite` support entirely. The `crsqlite` key in the `op-sqlite` `package.json` config no longer has any effect, and the bundled `cr-sqlite` extension binaries have been removed from the package (iOS `crsqlite.xcframework`, Android `libcrsqlite` `.so`s). If you need CR-SQLite, load it yourself as a runtime extension via `loadExtension` — see [Loading Extensions](./api.md#loading-extensions).

## 17.2.0

- Added `failOnCreate` option to `open()`. When set to `true`, the database file must already exist; if it doesn't, `open()` throws instead of creating it. Implemented natively across all backends (plain SQLite3, SQLCipher, libsql and Turso). See the [Open Existing Only (failOnCreate)](./api.md#open-existing-only-failoncreate) section for usage.
Expand Down
2 changes: 0 additions & 2 deletions docs/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ SQLite is very customizable on compilation level. op-sqlite also allows you add
// All the keys are optional, see the usage below
"op-sqlite": {
"sqlcipher": false
// "crsqlite": false,
// "performanceMode": true,
// "iosSqlite": false,
// "sqliteFlags": "-DSQLITE_DQS=0 -DSQLITE_MY_FLAG=1",
Expand All @@ -77,7 +76,6 @@ SQLite is very customizable on compilation level. op-sqlite also allows you add
All keys are optional, only turn on the features you want:

- `sqlcipher` allows to change the base sqlite implementation to [sqlcipher](https://www.zetetic.net/sqlcipher/), which encrypts all the database data with minimal overhead. You will still need to keep your encryption key secure. Read more about security in React Native [here](https://ospfranco.com/react-native-security-guide/).
- `crsqlite` is an extension that allows replication to a server backed sqlite database copy. [Repo here](https://github.com/vlcn-io/cr-sqlite).
- `performanceMode` turns on certain compilation flags that make sqlite speedier at the cost of disabling some features. You should almost always turn this on, but test your app thoroughly.
- `iosSqlite` uses the embedded iOS version from sqlite, which saves disk space but may use an older version and cannot load extensions as Apple disables it due to security concerns. On Android SQLite is always compiled from source as each vendor messes with sqlite or uses outdated versions.
- `sqliteFlags` allows you to pass your own compilation flags to further disable/enable features and extensions. It follows the C flag format: `-D[YOUR_FLAG]=[YOUR_VALUE]`. If you are running large queries on large databases sometimes on Android devices you might get a IO exception. You can disable temporary files by using adding the `"-DSQLITE_TEMP_STORE=2"` flag. Flags listed here are applied AFTER the library defaults (including those added by `performanceMode`), so they override any default with the same name on both iOS and Android. For example, setting `"sqliteFlags": "-DSQLITE_DQS=3"` re-enables double-quoted string literals even when `performanceMode` is on.
Expand Down
1 change: 0 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"iosSqlite": false,
"fts5": true,
"rtree": true,
"crsqlite": false,
"sqliteVec": false,
"performanceMode": true,
"tokenizers": [
Expand Down
13 changes: 1 addition & 12 deletions ios/OPSQLite.mm
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,6 @@ - (NSDictionary *)getConstants {
documentPath = [paths objectAtIndex:0];
}

#ifdef OP_SQLITE_USE_CRSQLITE
NSString *crsqlite_bundle_path =
[[[NSBundle mainBundle] privateFrameworksPath]
stringByAppendingPathComponent:@"crsqlite.framework"];
NSBundle *crsqlite_bundle = [NSBundle bundleWithPath:crsqlite_bundle_path];
NSString *crsqlite_path = [crsqlite_bundle pathForResource:@"crsqlite"
ofType:@""];
#else
NSString *crsqlite_path = @"";
#endif

#ifdef OP_SQLITE_USE_SQLITE_VEC
NSString *sqlitevec_bundle_path =
[[[NSBundle mainBundle] privateFrameworksPath]
Expand All @@ -107,7 +96,7 @@ - (NSDictionary *)getConstants {

_generationAlive =
opsqlite::install(runtime, callInvoker, [documentPath UTF8String],
[crsqlite_path UTF8String], [sqlite_vec_path UTF8String]);
[sqlite_vec_path UTF8String]);
return @true;
}

Expand Down
46 changes: 0 additions & 46 deletions ios/crsqlite.xcframework/Info.plist

This file was deleted.

24 changes: 0 additions & 24 deletions ios/crsqlite.xcframework/ios-arm64/crsqlite.framework/Info.plist

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Loading
Loading