forked from WiseLibs/better-sqlite3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joshua Wise
committed
Sep 12, 2016
1 parent
68a5c28
commit 75b6f48
Showing
51 changed files
with
310 additions
and
826 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
---------- Version 1 ---------- | ||
write tests | ||
should a new HandleScope be inside the .each() loop? | ||
|
||
re-write benchmarks for sync | ||
|
||
re-write readme for sync | ||
|
||
re-write tests for sync | ||
|
||
write tests | ||
compare tests to node-sqlite3 | ||
|
||
---------- Version 2 ---------- | ||
use special objects to deal with 64bit integers | ||
|
||
---------- Backlog ---------- | ||
Make sure that Promise.promisify(fn, {deoptimize: true}) does not reduce performance too much for situations with ~6 arguments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,37 @@ | ||
// .checkpoint([boolean force], Function callback) -> this | ||
|
||
NAN_METHOD(Database::Checkpoint) { | ||
bool force; | ||
v8::Local<v8::Function> func; | ||
if (info.Length() >= 2) { | ||
TRUTHINESS_OF_ARGUMENT(0, a); | ||
REQUIRE_ARGUMENT_FUNCTION(1, b); | ||
force = a; | ||
func = b; | ||
} else { | ||
force = false; | ||
REQUIRE_ARGUMENT_FUNCTION(0, a); | ||
func = a; | ||
} | ||
|
||
TRUTHINESS_OF_ARGUMENT(0, force); | ||
Database* db = Nan::ObjectWrap::Unwrap<Database>(info.This()); | ||
if (db->in_each) { | ||
return Nan::ThrowTypeError("This database connection is busy executing a query."); | ||
} | ||
if (db->state != DB_READY) { | ||
return Nan::ThrowError("The database connection is not open."); | ||
} | ||
|
||
if (db->workers++ == 0) {db->Ref();} | ||
db->checkpoints += 1; | ||
Nan::AsyncQueueWorker(new CheckpointWorker(db, force, new Nan::Callback(func))); | ||
int total_frames; | ||
int checkpointed_frames; | ||
int status = sqlite3_wal_checkpoint_v2( | ||
db->db_handle, | ||
"main", | ||
force ? SQLITE_CHECKPOINT_RESTART : SQLITE_CHECKPOINT_PASSIVE, | ||
&total_frames, | ||
&checkpointed_frames | ||
); | ||
|
||
info.GetReturnValue().Set(info.This()); | ||
if (status != SQLITE_OK) { | ||
CONCAT2(message, "SQLite: ", sqlite3_errmsg(db->db_handle)); | ||
return Nan::ThrowError(message); | ||
} | ||
|
||
if (checkpointed_frames < 0 || total_frames < 0) { | ||
info.GetReturnValue().Set(Nan::New<v8::Number>(0)); | ||
} else if (total_frames == 0) { | ||
info.GetReturnValue().Set(Nan::New<v8::Number>(1)); | ||
} else { | ||
info.GetReturnValue().Set(Nan::New<v8::Number>( | ||
(double)checkpointed_frames / (double)total_frames | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.