-
Notifications
You must be signed in to change notification settings - Fork 95
[sqlite3_native_assets] How to enable loading extensions #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm worried that something is linking another version of SQLite which might interfere with the native build. Is this on standalone Dart or on a Flutter app with plugin dependencies? You could try adding this to your @ffi.DefaultAsset('package:sqlite3_native_assets/sqlite3_native_assets.dart')
library;
import 'dart:io';
import 'dart:ffi' as ffi;
import 'package:ffi/ffi.dart' as ffi;
import 'package:sqlite3/sqlite3.dart';
import 'package:sqlite3_native_assets/sqlite3_native_assets.dart';
@ffi.Native<ffi.Pointer<ffi.Utf8> Function(ffi.Int)>()
external ffi.Pointer<ffi.Utf8> sqlite3_compileoption_get(int i);
void main() {
final sqlite3 = sqlite3Native;
print('Using sqlite3 ${sqlite3.version}');
ffi.Pointer<ffi.Utf8> option;
for (var i = 0; (option = sqlite3_compileoption_get(i)).address != 0; i++) {
print('Compile-option: ${option.toDartString()}');
} |
Running the code above does yield Also it has the flag in the list:
Even running with |
Is there a way to force a rebuild of the native assets? I tried with |
That version sounds like it's using the SQLite library from the system (which can happen easily as a fallback when not using a custom
In my experience the cache is quite solid and gets invalidated for changes to build scripts. You can always remove the
What surprises me here is that it works without that flag at all, are you on Dart stable? For me, trying to run a Dart program that depends on a package with native assets fails immediately when I'm not enabling the experiment. So I think the tool may not have picked up the build hook? |
This is weird, because the version for my system is even different than that:
This is my Dart and Flutter version:
That has to be what is happening. But what is so weird is that the session extension is supported (which requires extra flags), I just cannot load extensions. Although what ever version is detected might have it enabled. |
The
Extra flags that Apple has, to my own surprise, enabled. Running SELECT sqlite_compileoption_get(value) FROM generate_series(0, 500) where sqlite_compileoption_get(value) is not null; will print both |
Wow! I also is installed SQLite via homebrew since the one with macOS does not load extensions. But I have to usually override it when loading in Dart. And I override it in zsh. Native assets must be picking up the MacOS version instead... How should I proceed on debugging? This is my first time with native assets, and I can reach out to the internal dart team if needed. |
Also on the SQLite session extension I am proposing it is enabled by default for sqlite3.dart It already is enabled for default WASM official SQLite build and Node.js official SQLite support! I have a PR I am working on if you are interested with all the bindings wired up. FFI is done and working on WASM |
I think that may be the best approach, I've not encountered the issue of build hooks not being recognized before.
That would be awesome 🚀 I'm also happy to help with WASM or anything else, I know the internal setup to get everything running is quite complex. |
Here is the Session PR. Would love some help on the WASM side, the FFI side is working great for me! |
Awesome, I'll take a look this weekend 🚀 |
Uh oh!
There was an error while loading. Please reload this page.
I cannot figure out how to add custom extension loading when using the
sqlite3_native_assets
package and customizing the flags.For example I added flags to support the SQLite Session extension:
No matter what flags I add, it still passes the SQLITE_OMIT_LOAD_EXTENSION flag is being included but cannot find it in the source code.
Curious where I should look next to try to debug?
The text was updated successfully, but these errors were encountered: