[Interest] Use SQLite math functions (-DSQLITE_ENABLE_MATH_FUNCTIONS) like sin and cos?

Benjamin B (BBenj) balga.benjamin at gmail.com
Thu Oct 27 12:46:19 CEST 2022


Hello,

Not sure if it was mentioned, but you can also copy the QSQLite plugin, change its name and build it with SQLite and all the options you need. Then use it as a Qt SQL plug-in and load it instead of the default one. It’s documented somewhere (creating a custom sql plugin).

I did that in the past to add custom functions in sqlite, among other things. 

Beware of licensing conflicts, maybe? My use of it never extended beyond my own so I didn’t bother at the time. If it’s OSS/GPL I guess it’s fine.

Benjamin 

> Le 26 oct. 2022 à 16:01, Till Oliver Knoll <till.oliver.knoll at gmail.com> a écrit :
> 
> 
> Am 25.10.22 um 18:40 schrieb Christian Ehrlicher:
>>> Am 24.10.2022 um 19:58 schrieb Till Oliver Knoll:
>>>> Dear all,
>>>> 
>>>> What is the least complicated way to enable the math functions that come with SQLite, when it is compiled with the -DSQLITE_ENABLE_MATH_FUNCTIONS switch?
>>>> 
>>>> My empirical experiments with the binary Qt 5.15.2 (open source) release (but also some tests with the lastest Qt 6.4 binary release, for either Windows or macOS) suggest that the SQLite plugin that ships with Qt does not enable those "built in mathematical functions", as described here:
>>>> 
>>>>   https://www.sqlite.org/lang_mathfunc.html
>>>> 
>>>> So do I:
>>>> 
>>>> Recompile the Qt SQLite plugin, with the desired -DSQLITE_ENABLE_MATH_FUNCTIONS flag?
>>>> Disadvantages (?):
>>>> Need to download Qt source code
>>>> Probably complicates the build process... (I have "build actions" on github.com that currently "only" need to install the binary Qt distribution)
>>>> Feels a bit "overkill"
>>> 
>>> From my pov this is the correct way to add new functionality to a Qt plugin. Even for github you can install your binary Qt distribution and then replace the plugin with your own.
>>> 
>> Yes, but that would imply that I had a recompiled Qt SQLite plugin in the first place, and that I would then also "check-in" somehow into my source repository / include into the "github action build step". Something I'd like to avoid, if possible.
>> 
>> Also, I am also trying to avoid to recompile Qt on my desktop(s): it is a simple "one man open source app", and I try to keep the development process (done in my spare time) as simple as possible, for the time being. Or in other words: it's been more than a decade ago since I compiled Qt from source (what was that, perhaps Qt 4.x?), but that was in a "professional environment" ;) I don't even have all the required SKDs installed, expecially not on Windows (the target platform - because the given "flight simulator" runs there, too - however I mostly develop on macOS ;))
>> 
>> In short: I am looking for a solution that - if possible - avoids having to (re-)compile Qt from source. For no other reason other than "I am lazy" ;)
>> 
>> Are there any disadvantages when the math functions are enabled? Esp. regarding to speed?
>> 
> I can't tell for sure, since I do have little experience with SQLite apart from using it, but I would not expect any speed issues when enabling those "math functions".
> 
> Certainly https://www.sqlite.org/lang_mathfunc.html does not mention anything like this. But yes, the code size would grow by some. So if the goal of the Qt binary distribution was "minimal size" (which I don't believe is a particular goal - developers that /really/ care about size recompile Qt anyway with their own custom options, I would expect) then one could argue that all external libraries would also be compiled with a "minimal feature set". But again, I hope that the "omission" of the -DSQLITE_ENABLE_MATH_FUNCTIONS wasn't a concious choice.
> 
> But perhaps someone else with more experience with SQLite could shed some light on this or has some experience why enabling this "math option" by default could be a bad choice?
> 
> 
> 
>> Feel free to open a bug report so we can discuss if this flag can be added by default.
>> 
> I just created a suggestion report here, if anyone wants to contribute information about those "math functions":
> 
> https://bugreports.qt.io/browse/QTBUG-108016
> 
> 
> 
> Thanks for your reply!
> 
>   Oliver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20221027/9006e28a/attachment.htm>


More information about the Interest mailing list