-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Broken SQL.open( data ) / SQL.exportData() #9
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
Is it possible that this is still not fixed? I am having the same problem. |
This issue was opened a while ago, before I arrive in the project. If you want to look at this yourself, I think the first thing to try is to close the database before exporting its contents. The method to change is here: https://github.com/kripken/sql.js/blob/master/coffee/api.coffee#L374 |
Thank you for a quick response, I will look at the code right away. Will post if I have any progress. |
https://github.com/kripken/sql.js/blob/master/coffee/api.coffee#L374 is a one-line method:
I am not familiar with coffeescript but it seems to me that the file by the name of @filename that is supposed to be created inside constructor does not get updated when I perform INSERT/UPDATE/DELETE commands agains db. |
I'm sorry, but I can't reproduce this issue, nor #55. I added a test to the Can you please provide a js file that triggers the error? |
I updated JSFiddle so that my problem is now apparent: |
Ok, I'll look at it after my holidays. Thank you for the report, and for the test case. |
Are there any news on this issue? |
I've added the sqlite db from your example to the tests. The tests break now, you can see it here: https://travis-ci.org/kripken/sql.js The fix I first thought of (closing the db before exporting its contents) doesn't work. So, I really don't know where the problem is. I'm going to debug this, but it will require much more work than I first imagined. I will investigate during one of the next weekend. If anyone wants to help, he's welcome, and I'll work with them |
OK, thanks for the update. I doubt that I can make a contribution but I will look into the code and try to make some sense out of it all. |
The code really isn't very complex. It's just bindings to the original sqlite library, the documentation of which can be found here: http://www.sqlite.org/c3ref/funclist.html For this particular bug, I think the best is to compile the whole thing in debug mode with emscripten (with |
When testing test_issue55.js, this constructor gets called 2 times. I compared the contents of the 'data' argument to this constructor both times it is called, they are identical. Then I inspected the db.export() function and it is a one-liner so I believe nothing can go wrong there. Pursuing 2), I checked db.run() function. Number 1) seems more likely to be the actual problem. But I have not yet made any progress in this direction. |
The mechanism through which it is possible to save and load a SQL instance seems to be broken.
The problem happens when opening a SQL instance passing the data returned by exportData() to the open(data) method.
To me it seems that although when created empty the database makes his buffer grow without problem, when the database is opened with a given uint8array, as the database grows the buffer is not reallocated and an overflow is generated, leading then to a corruption in the database disk image (SQLite exception: 11, database disk image is malformed)
Here is the test case proving the bug. The principle is simple, i first create an empty database, fill it with some records, then export its data, close it, reopen it with the exported data, and then going again with insertions.
Here is the Javascript code for this bug test-case, it is inpired by your demo page :
The text was updated successfully, but these errors were encountered: