-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
Support backing up to an instance of sqlite3.Database #1649
base: master
Are you sure you want to change the base?
Conversation
The destination database must be locked, as per https://www.sqlite.org/c3ref/backup_finish.html ("Concurrent usage of database handles").
Help neededThe call to the backup API is causing a segfault, currently. I suppose this line is causing the issue: https://github.com/SmartArray/node-sqlite3/blob/401937943af31cd6e7844deb124e315df4c58400/src/backup.cc#L161 I could not figure out why the destructor of the Backup instance causes this bad memory access (a double free)? I would love some assistance in this issue! Unfortunately I have no experience using the N-API. Here is the backtrace I gathered with LLDB:
|
Fixed all memory issues, tests and added typescript declarations. |
if (info[1].IsObject()) { | ||
// A database instance was passed instead of a filename | ||
otherDb = Napi::ObjectWrap<Database>::Unwrap(info[1].As<Napi::Object>()); | ||
otherDb->Ref(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if the Ref() call is needed here. I have applied this from @paulfitz.
I assume it is needed because it prevents the otherDb instance to be freed while a backup is in progress, which should usually not happen unless the user closes the db during a backup process.
Please someone double check.
This PR introduces the ability to use an instance of sqlite3.Database to perform backups using the Online Backup API.
This PR is a work in progress until
yarn test
runs through successfully.