sqlite icon indicating copy to clipboard operation
sqlite copied to clipboard

sqlite3 extenstion support

Open sunshine69 opened this issue 4 years ago • 5 comments

Hi,

It seems out of the box the extenstion is not supported. I did try to use json1 and got error like function json_extract does not exists.

How can I build the library with json1 ext support for example?

Thanks

sunshine69 avatar Sep 14 '21 07:09 sunshine69

To be explicit, the normal build seems to have the extenstion compiled but not for the static musl target

cargo build --release --target x86_64-unknown-linux-musl

this command build my test repo and produce a non supported json extention.

while the default on ubuntu 20.04 works fine.

so the question really is how to build statically built with json1 ext support for that target x86_64-unknown-linux-musl

sunshine69 avatar Sep 14 '21 07:09 sunshine69

For what is it worth the other (more popular one https://github.com/rusqlite/rusqlite) does not have the problem with the musl target. However I like this more as it has some easier way for me to dynamically find the col names and types.

I would think there is a compile option somewhere which enables the build generically?

sunshine69 avatar Sep 14 '21 07:09 sunshine69

Thank you for the issue! If you know how to compile the original source so it has the support you need, it is a matter of updating this logic:

https://github.com/stainless-steel/sqlite3-src/blob/master/build.rs

Currently, it is simple, but we can add features.

IvanUkhov avatar Sep 14 '21 08:09 IvanUkhov

No I am quite new to rust so still finding way around. All I do is using cargo run and cargo build command like above. I would like to be able to build statically linked.

Look at the other repo they have something like this in Cargo.toml file

[dependencies.rusqlite]
version = "0.25.3"
features = ["bundled"]

Can we design the similar way to add a features option and enforce it to compile for all target? I don't know how though, if I know I would create a PR :)

sunshine69 avatar Sep 14 '21 09:09 sunshine69

Please take a look at what the documentation says about extension support:

https://sqlite.org/howtocompile.html

Maybe the problem is in what other libraries are available when compiling and the corresponding directives. Most likely, -DSQLITE_ENABLE_JSON1 has to be added with an appropriate -l in build.rs.

IvanUkhov avatar Sep 14 '21 11:09 IvanUkhov

https://github.com/stainless-steel/sqlite/pull/75 add support do developer enable/disable and load extensions.

jonatansalemes avatar Oct 04 '23 19:10 jonatansalemes

I think we are talking about two different types of extensions here. There are those that are built in, such as JSON, and there are those that are not. PR #75 is about the latter and unlikely to help with this issue if I understand correctly.

The JSON functions and operators are built into SQLite by default, as of SQLite version 3.38.0 (2022-02-22). They can be omitted by adding the -DSQLITE_OMIT_JSON compile-time option. Prior to version 3.38.0, the JSON functions were an extension that would only be included in builds if the -DSQLITE_ENABLE_JSON1 compile-time option was included. In other words, the JSON functions went from being opt-in with SQLite version 3.37.2 and earlier to opt-out with SQLite version 3.38.0 and later.

IvanUkhov avatar Oct 06 '23 08:10 IvanUkhov

Closing as per the above quote.

IvanUkhov avatar Nov 08 '23 09:11 IvanUkhov