Error opening/creating database on disk and in memory #26

Open
DveMac opened this Issue Mar 14, 2011 · 3 comments

Projects

None yet

3 participants

DveMac commented Mar 14, 2011

using latest source from github. uilds without errors. But .open method causes..

node: ../src/database.h:38: virtual Database::~Database(): Assertion `db_ == __null' failed.

Code sample that reproduces the error:

var sqlite = require('sqlite');

var db = new sqlite.Database();

db.open('/tmp/test.db', function(error) {
    if (error) {
        console.log(error);
    }
    else {
        console.log("Ready!");    
    }
});

setInterval(function() {
    console.log('++');
}, 10000);

For me the crash happens after 3-5 seconds. Resulting output:
$ node example-sqlite.js
Ready!
node: ../src/database.h:38: virtual Database::~Database(): Assertion `db_ == __null' failed.
Aborted

This is with version 1.0.4 installed locally with npm. node version 0.4.8 (from the tgz file on nodejs.org)

isofarro commented Jun 2, 2011

I've been tinkering with this for a while. Started with a fresh slate and checked out the latest version of this project from github.

The example code in the README file works (removing the extra right-rounded bracket on the Tonight. You. line, and creating the database and table structure within the sqlite3 cli).

Taking the example code, if you remove everything inside the open callback function, except for the if (error) check at the start, then the above error occurs again. So smallest example code to reproduce the error:

var sys    = require('sys'),
    sqlite = require('./node-sqlite/sqlite');

var db = new sqlite.Database();

// open the database for reading if file exists
// create new database file if not

db.open("aquateen.db", function (error) {
  if (error) {
      console.log("Tonight. You.");
      throw error;
  }
});

setInterval(function(){ console.log('X'); }, 10000);

The module just seems to dislike just opening the sqlite file, and doing nothing with it. If we add in a very simple SQL select query, the code stops aborting:

var sys    = require('sys'),
    sqlite = require('./node-sqlite/sqlite');

var db = new sqlite.Database();

// open the database for reading if file exists
// create new database file if not

db.open("aquateen.db", function (error) {
  if (error) {
      console.log("Tonight. You.");
      throw error;
  }
    db.query(
        "SELECT * FROM aqua_teens;",
        function (error, row) {
            if (error) { console.log(error) }
            else if(row) {
                console.log(row.name);
            }
        }
    );
});

 setInterval(function(){ console.log('X'); }, 10000);
chestone commented Aug 4, 2011

I am experiencing exactly the same issue. Just wanted to add on to this as it is very annoying to have to hack around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment