From fe53cfe9a06a72391d19dfef71fdbf998be9e091 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 21 Apr 2016 14:18:00 -0700 Subject: [PATCH] Revert "Add support for sqlite3_interrupt" --- src/database.cc | 20 ------------ src/database.h | 4 --- test/interrupt.test.js | 69 ------------------------------------------ 3 files changed, 93 deletions(-) delete mode 100644 test/interrupt.test.js diff --git a/src/database.cc b/src/database.cc index e7891cbd2..5f1e197d3 100644 --- a/src/database.cc +++ b/src/database.cc @@ -23,7 +23,6 @@ NAN_MODULE_INIT(Database::Init) { Nan::SetPrototypeMethod(t, "serialize", Serialize); Nan::SetPrototypeMethod(t, "parallelize", Parallelize); Nan::SetPrototypeMethod(t, "configure", Configure); - Nan::SetPrototypeMethod(t, "interrupt", Interrupt); NODE_SET_GETTER(t, "open", OpenGetter); @@ -225,8 +224,6 @@ void Database::Work_BeginClose(Baton* baton) { assert(baton->db->pending == 0); baton->db->RemoveCallbacks(); - baton->db->closing = true; - int status = uv_queue_work(uv_default_loop(), &baton->request, Work_Close, (uv_after_work_cb)Work_AfterClose); assert(status == 0); @@ -252,8 +249,6 @@ void Database::Work_AfterClose(uv_work_t* req) { Baton* baton = static_cast(req->data); Database* db = baton->db; - db->closing = false; - Local argv[1]; if (baton->status != SQLITE_OK) { EXCEPTION(Nan::New(baton->message.c_str()).ToLocalChecked(), baton->status, exception); @@ -356,21 +351,6 @@ NAN_METHOD(Database::Configure) { info.GetReturnValue().Set(info.This()); } -NAN_METHOD(Database::Interrupt) { - Database* db = Nan::ObjectWrap::Unwrap(info.This()); - - if (!db->open) { - return Nan::ThrowError("Database is not open"); - } - - if (db->closing) { - return Nan::ThrowError("Database is closing"); - } - - sqlite3_interrupt(db->_handle); - info.GetReturnValue().Set(info.This()); -} - void Database::SetBusyTimeout(Baton* baton) { assert(baton->db->open); assert(baton->db->_handle); diff --git a/src/database.h b/src/database.h index 28f7fbfff..8aeabfd5c 100644 --- a/src/database.h +++ b/src/database.h @@ -104,7 +104,6 @@ class Database : public Nan::ObjectWrap { _handle(NULL), open(false), locked(false), - closing(false), pending(0), serialize(false), debug_trace(NULL), @@ -152,8 +151,6 @@ class Database : public Nan::ObjectWrap { static NAN_METHOD(Configure); - static NAN_METHOD(Interrupt); - static void SetBusyTimeout(Baton* baton); static void RegisterTraceCallback(Baton* baton); @@ -174,7 +171,6 @@ class Database : public Nan::ObjectWrap { sqlite3* _handle; bool open; - bool closing; bool locked; unsigned int pending; diff --git a/test/interrupt.test.js b/test/interrupt.test.js deleted file mode 100644 index 143a0f032..000000000 --- a/test/interrupt.test.js +++ /dev/null @@ -1,69 +0,0 @@ -var sqlite3 = require('..'); -var assert = require('assert'); - -describe('interrupt', function() { - it('should interrupt queries', function(done) { - var query = - 'with t (n) as (values (1),(2),(3),(4),(5),(6),(7),(8)) ' + - 'select last.n ' + - 'from t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t as last'; - - var interrupted = false; - var saved = null; - - var db = new sqlite3.Database(':memory:', function() { - db.each(query, function(err) { - if (!interrupted) { - interrupted = true; - db.interrupt(); - } else if (err) { - saved = err; - } - }); - - db.close(function() { - if (saved) { - assert.equal(saved.message, 'SQLITE_INTERRUPT: interrupted'); - assert.equal(saved.errno, sqlite3.INTERRUPT); - assert.equal(saved.code, 'SQLITE_INTERRUPT'); - done(); - } else { - done(new Error('Completed query without error, but expected error')); - } - }); - }); - }); - - it('should throw if interrupt is called before open', function(done) { - var db = new sqlite3.Database(':memory:'); - - assert.throws(function() { - db.interrupt(); - }, (/Database is not open/)); - - db.close(); - done(); - }); - - it('should throw if interrupt is called after close', function(done) { - var db = new sqlite3.Database(':memory:'); - - db.close(function() { - assert.throws(function() { - db.interrupt(); - }, (/Database is not open/)); - - done(); - }); - }); - - it('should throw if interrupt is called during close', function(done) { - var db = new sqlite3.Database(':memory:', function() { - db.close(); - assert.throws(function() { - db.interrupt(); - }, (/Database is closing/)); - done(); - }); - }); -});