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

close() doesn't work. #13

Open
a2800276 opened this issue Dec 7, 2010 · 3 comments
Open

close() doesn't work. #13

a2800276 opened this issue Dec 7, 2010 · 3 comments

Comments

@a2800276
Copy link

a2800276 commented Dec 7, 2010

the callback passed to close almost inevitably gets passed an error object. unfortunately, the sqlite result code is not attached, so it's hard to guess at why.

I've hacked some printfs into the close routines and it seems that the returned error is always 5-> SQLITE_BUSY which is mentioned in the man page for close: "If sqlite3_close() is called on a database connection that still has outstanding prepared statements or BLOB handles, then it returns SQLITE_BUSY."

I'm afraid my c++ isn't too hot, but it seems that sqlite3_finalize is never called on the prepared statement handle in the case of Prepare (PrepareAndStep does call finalize)

Steps to reproduce:
If the tests are changed to log an error in the close callback, none of the tests are able to close without error. ( not sure how to attach a patch here, and I'm not sure if it makes sense to...)

@willwhite
Copy link

Hi there,
I'm running into this as well. If you have a patch with a fix or a test case, you could fork and issue a pull request or add it to https://gist.github.com/. It would be much appreciated.

Will

@willwhite
Copy link

I've put together a very simple test case.

Steps to reproduce:

git clone git@github.com:willwhite/node-sqlite.git

cd node-sqlite

git checkout closedbfix

node-waf configure build

git submodule update --init

./run-tests

I added a simple check to the tests in my "closedbfix" branch.

It should complain: "Error: Error closing database"

Not only is close() returning an error object, but running lsof reveals that files are being left open. The tests are all using memory databases, but it's easy to switch the path so it uses a real file. Then you can test using the lsof approach.

@kkaefer
Copy link

kkaefer commented Feb 11, 2011

For .close() to work, make sure that you call .finalize() on all statements. If there are any statements that are not finalized, .close() fill fail.

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

No branches or pull requests

3 participants