-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
please add support for sqlite archives #75
Comments
Actually, support for SQLite Archive Files is part of the SQLite shell. Activating this feature is possible by defining the symbol Admittedly, the shell binaries of the official SQLite distribution have this feature enabled, while the binaries coming with SQLite3 Multiple Ciphers releases currently haven't. I will consider to build binaries with SQLite Archive support. However, I'm a bit reluctant to add the sqlar extension to the core library, as this extension only adds the |
Thanks for the quick reply! I'd like to clarify that my request title was poorly phrased, and I have no need of the shell interface whatsoever - I'm not using the shell for any part of my dev process. I am only interested in the sqlar functions. With that in mind...
The shell understands the specifically formatted sqlar table but the functions are added to the DLL itself. Accordingly, the sqlar_x() interfaces should be available to use for any transaction which desires it, on any table with any data. I believe that any "mandatory/expected" (for lack of a better term) sqlar support ends at ensuring the functions work as intended, and does not extend to any advanced parsing of the sqlar table. However, I do understand your reticence on adding what could be percieved as adding a half-baked feature and appreciate your consideration all the same. :) For what it's worth, my use case is very near to the one described on the sqlar overview page: I'm making an api cache system and it'd be a huge boon to store the response text compressed inside the database, as opposed to the current uncompressed method. |
Ok, I understand. In principle, the sqlar extension could be built as a loadable extension, and the application could then load it at runtime. However, personally I usually try to avoid runtime-loadable extensions, because they impose a security risk. So, it is certainly preferrable to have the option to link extensions into the core library, as is done for quite a few other extensions already. The question is how the dependency on ZLIB should be handled. Personally, I would prefer a solution that doesn't depend on any external library. One way to accomplish that would be to add the single-file ZLIB replacement miniz to the project.
That's right. The
Well, since the extension is included in the official SQLite shell the feature can't be called half-baked, I'd say. In principle, I have no problem to include the sqlar extension, at least as an optional extension not enabled by default.
Being able to compress/decompress data within the database is certainly a useful feature. I will make some tests with miniz in the near future. If that works without major problems, the feature could be added in one of the next releases. |
In the meantime I made a few tests. The ZLIB replacement miniz works without any problems for the extensions compress, sqlar, and zipfile. I will update the project, so that the components compress, sqlar, and zipfile can be enabled by specifying a precompiler symbol. Additionally, it will be possible to decide whether the original ZLIB library or miniz should be used. The source code for the latter will be added to the repository. |
Cool! Thank you very much for entertaining this request. ^_^ |
I expect to commit the necessary changes within the next couple of days. Stay tuned. |
The SQLite extensions COMPRESS, SQLAR, and ZIPFILE can be optionally enabled. All these extensions depend on the ZLIB library. The MINIZ library is included as a replacement for the ZLIB library, eliminating the external dependency, if desired.
Commit 5068c89 is a first implementation of your request. To enable the SQLite extensions COMPRESS, SQLAR, and/or ZIPFILE you have to specify the respective precompiler symbol:
All these extensions depend on the ZLIB library. There are 2 options:
Please give it a try and report any issues. |
Oh, I'll fix that then. You used a different phrase ("precompiler symbol") so I was unsure what you were refering to. Thanks for clarifying! :)
I'll make that adjustment ^_^ Now for the actual SQL portion:
The first thing I did was just replace the DLL in my project where I'm writing the aforementioned cache db. The way the library I'm using functions is it will return a 0 if there's a failure. Therefore, I have simple error popups while I'm in the nuts and bolts phase to know which part is specifically failing. This is in AHK btw. I know you probably aren't fluent in AHK but you'll hopefully be able to understand the main points. 🤞
On a lark just now, I replaced my SQLiteStudio's ( https://sqlitestudio.pl ) dll with the sqlar one, and it immediately worked with There is a curiosity though: the using So I think we are looking at two distinct problems:
Sorry for the info dump. ^^; |
It's not a bug to define the symbols in the source code, but usually it is more convenient to set them in the project settings.
Sorry, I meant to write "preprocessor", and unfortunately I don't have a DWIM-computer (DWIM = Do What I Mean). 😁
Sorry, a different change is required - please see my previous post.
Usually, SQLite's error codes and messages help to identify SQL errors.
You are right that I don't know much about AHK, but it's certainly not rocket science.
At first glance I have no clue why the insert fails. And without knowing the SQLite error code and message it is hard to tell what is going on. You could try to issue the command in a SQLite shell or in a tool like SQLiteStudio, and see what messages you get.
At least that is good news.
Strange. Admittedly, up to now I tested only with the archive command of the SQLite shell and that worked as expected.
I will use your test data for further experiments.
Not that I know of. Since the extensions are statically linked with the SQLite library itself, the functions implemented by the extensions are automatically registered for each new database connection.
This is really weird. I will make some more experiments to check whether I can somehow reproduce this behaviour. |
I know you were probably typing when I posted my last, but most things (save |
Yes, indeed. 😄
If I understand it correctly, |
The wrapper class has a few properties directly accessible after each method call. |
I've never actually used the shell. I'll give it a shot myself and report what happens. |
SQLite's error codes are often quite generic, but most of the times the error message strings contain useful hints, what went wrong.
Proper error handling can be a pain ... |
Thanks for providing the test script. I will use it to track down what exactly is going on. This may take some time...
It is indeed very unlikely that the problem has anything to do with the encryption feature. Nevertheless, I'm curious why there is a problem with this function and what's causing it.
Maybe, but we have to prove it, if possible. |
Well, in the meantime I checked what's going on. Actually, we didn't find a bug in SQLite. I think the problem arises from the somewhat misleading description of the SQLite Archive Feature:
One can get the impression that the argument X of Your application must take care of passing the data as a blob. That is, you will have to write the call to sqlar_compress(CAST('very long textstring' AS BLOB)) The comment in the implementation file
|
Yeah, that overview documentation is jank! So much time wasted due to a poor description. -.-
We're finally past the compression stage, lol. ...Which brings me to the next issue: This failure occurs even when the BC insert is the only row, achievable by commenting/deleting the NC+SC inserts |
Good news. I will soon prepare a release and then will close this issue. |
Thank you for all of your hard work on this obscure function! I really appreciate it. ^_^ |
Quick status report: the sqlar features are working flawlessly! 26k+ individual row inserts comprising data pulled from api endpoints and every one was as fast (or maybe even faster!) than just dumping to disk, with individual record reads being virtually instantaneous. The compressed database comes out to around 40% of uncompressed size - a noticeable reduction! Thanks again for taking the time to enable this - was a huge help. PS: I figured you might find my database schema interesting, given that I'm your first use case. ;) Everything is tracked by the fingerprint, which is a concatonated hash of the remote url and any outgoing headers the user sets. Getting useful data is as simple as SELECTing from vRecords based on any of the criteria you'd normally look for. I'm not using the strict sqlar spec in my project because it didn't make sense to split up the two blobs I'm maintaining per row (plus there was a massive performance hit when I experimented with doing so.)
|
I'm glad to hear that the feature now works to your expectations.
Thanks for describing your use case. This will most likely help other, too, to use this feature. Today I made a new release, Version 1.4.4, that includes the source code of the extensions COMPRESS, SQLAR, and ZIPFILE (as well as the source code of the TCL interface asked for by another developer). With this release I think this issue can be closed. |
Hey there, I'm requesting the addition of the sqlar_compress() and sqlar_uncompress() interfaces. They are already part of the SQLite standard and looks to be just one include file.
sqlar overview: https://www.sqlite.org/sqlar.html
inclusion code: https://sqlite.org/src/file/ext/misc/sqlar.c
Thanks in advance!
The text was updated successfully, but these errors were encountered: