Skip to content
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

Trying to use maths function (from SQLite v3.35) does not work #990

Closed
fr-ser opened this issue Dec 17, 2021 · 4 comments · Fixed by #1059
Closed

Trying to use maths function (from SQLite v3.35) does not work #990

fr-ser opened this issue Dec 17, 2021 · 4 comments · Fixed by #1059

Comments

@fr-ser
Copy link

fr-ser commented Dec 17, 2021

Since this PR the underlying version of SQLite should be >=3.35 (and it is). The PR even mentions the new maths function added.
However, when I try to use math functions (like SELECT power(2,2)) I get this error no such function: power.

Is there something more I need to do than use the latest version of the go-sqlite3 library?

@rittneje
Copy link
Collaborator

As per the SQLite docs, in order to leverage the built-in math functions, you must compile with -DSQLITE_ENABLE_MATH_FUNCTIONS https://www.sqlite.org/lang_mathfunc.html

However, currently there is no way to include that option with this library. Please add a build tag for it, as was done for -DSQLITE_DEFAULT_FOREIGN_KEYS. https://github.com/mattn/go-sqlite3/blob/master/sqlite3_opt_foreign_keys.go

You'll also want to add an entry to the table in the README. https://github.com/mattn/go-sqlite3#feature--extension-list

@fardeadok
Copy link

I didn't understand: is it possible to use pow and sqrt or not? If not, when will it be fixed? I spent a couple of days trying to figure out why sqllite works differently in different applications!

@rittneje
Copy link
Collaborator

is it possible to use pow and sqrt or not?

It is not currently possible to use the built-in math functions, because to do so requires the -DSQLITE_ENABLE_MATH_FUNCTIONS flag to be passed to the C library at compile-time.

If not, when will it be fixed?

You need to raise a PR with the aforementioned changes.

@nkt-dk
Copy link
Contributor

nkt-dk commented Apr 29, 2022

Hi, I came across this issue when trying to use SQRT function in an application. I added the changes @rittneje mentioned and create a PR, I hope it is correctly implemented. At least on my local test system I can successfully use the scalar math functions afterwards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants