Compare commits
11 Commits
better-sql
...
no-openssl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1f73c0738 | ||
|
|
4f66ee7b85 | ||
|
|
92ed9e3635 | ||
|
|
9de3488f68 | ||
|
|
917a6f5cf8 | ||
|
|
32828e03be | ||
|
|
2fa02d2484 | ||
|
|
a78376d86b | ||
|
|
86b685e046 | ||
|
|
a78e94135c | ||
|
|
5acdaf9d03 |
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1 +1,2 @@
|
|||||||
*.lzz linguist-language=C++
|
*.lzz linguist-language=C++
|
||||||
|
deps/sqlite3.tar.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
|||||||
@ -13,6 +13,14 @@
|
|||||||
'xcode_settings': {
|
'xcode_settings': {
|
||||||
'OTHER_CPLUSPLUSFLAGS': ['-std=c++14', '-stdlib=libc++'],
|
'OTHER_CPLUSPLUSFLAGS': ['-std=c++14', '-stdlib=libc++'],
|
||||||
},
|
},
|
||||||
|
'conditions': [
|
||||||
|
['OS=="linux"', {
|
||||||
|
'ldflags': [
|
||||||
|
'-Wl,-Bsymbolic',
|
||||||
|
'-Wl,--exclude-libs,ALL',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'target_name': 'test_extension',
|
'target_name': 'test_extension',
|
||||||
|
|||||||
5
deps/common.gypi
vendored
5
deps/common.gypi
vendored
@ -12,11 +12,6 @@
|
|||||||
'ExceptionHandling': 1,
|
'ExceptionHandling': 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'conditions': [
|
|
||||||
['OS == "win"', {
|
|
||||||
'defines': ['WIN32'],
|
|
||||||
}],
|
|
||||||
],
|
|
||||||
'configurations': {
|
'configurations': {
|
||||||
'Debug': {
|
'Debug': {
|
||||||
'defines!': [
|
'defines!': [
|
||||||
|
|||||||
11
deps/defines.gypi
vendored
11
deps/defines.gypi
vendored
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'defines': [
|
'defines': [
|
||||||
'SQLITE_DQS=0',
|
|
||||||
'SQLITE_LIKE_DOESNT_MATCH_BLOBS',
|
'SQLITE_LIKE_DOESNT_MATCH_BLOBS',
|
||||||
'SQLITE_THREADSAFE=2',
|
'SQLITE_THREADSAFE=2',
|
||||||
'SQLITE_USE_URI=0',
|
'SQLITE_USE_URI=0',
|
||||||
@ -19,14 +18,14 @@
|
|||||||
'SQLITE_ENABLE_COLUMN_METADATA',
|
'SQLITE_ENABLE_COLUMN_METADATA',
|
||||||
'SQLITE_ENABLE_UPDATE_DELETE_LIMIT',
|
'SQLITE_ENABLE_UPDATE_DELETE_LIMIT',
|
||||||
'SQLITE_ENABLE_STAT4',
|
'SQLITE_ENABLE_STAT4',
|
||||||
'SQLITE_ENABLE_FTS3_PARENTHESIS',
|
|
||||||
'SQLITE_ENABLE_FTS3',
|
|
||||||
'SQLITE_ENABLE_FTS4',
|
|
||||||
'SQLITE_ENABLE_FTS5',
|
'SQLITE_ENABLE_FTS5',
|
||||||
'SQLITE_ENABLE_JSON1',
|
'SQLITE_ENABLE_JSON1',
|
||||||
'SQLITE_ENABLE_RTREE',
|
'SQLITE_ENABLE_RTREE',
|
||||||
'SQLITE_ENABLE_GEOPOLY',
|
|
||||||
'SQLITE_INTROSPECTION_PRAGMAS',
|
'SQLITE_INTROSPECTION_PRAGMAS',
|
||||||
'SQLITE_SOUNDEX',
|
|
||||||
|
# SQLCipher-specific options
|
||||||
|
'SQLITE_HAS_CODEC',
|
||||||
|
'SQLITE_TEMP_STORE=2',
|
||||||
|
'SQLITE_SECURE_DELETE',
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
56
deps/sqlite3.gyp
vendored
56
deps/sqlite3.gyp
vendored
@ -12,54 +12,42 @@
|
|||||||
'target_name': 'locate_sqlite3',
|
'target_name': 'locate_sqlite3',
|
||||||
'type': 'none',
|
'type': 'none',
|
||||||
'hard_dependency': 1,
|
'hard_dependency': 1,
|
||||||
'conditions': [
|
'actions': [{
|
||||||
['sqlite3 == ""', {
|
'action_name': 'extract_sqlite3',
|
||||||
'actions': [{
|
'inputs': ['sqlite3.tar.gz'],
|
||||||
'action_name': 'extract_sqlite3',
|
'outputs': [
|
||||||
'inputs': ['sqlite3.tar.gz'],
|
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c',
|
||||||
'outputs': [
|
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.h',
|
||||||
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c',
|
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3ext.h',
|
||||||
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.h',
|
],
|
||||||
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3ext.h',
|
'action': ['node', 'extract.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3'],
|
||||||
],
|
}],
|
||||||
'action': ['node', 'extract.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3'],
|
|
||||||
}],
|
|
||||||
}, {
|
|
||||||
'actions': [{
|
|
||||||
'action_name': 'symlink_sqlite3',
|
|
||||||
'inputs': [],
|
|
||||||
'outputs': [
|
|
||||||
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c',
|
|
||||||
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.h',
|
|
||||||
],
|
|
||||||
'action': ['node', 'symlink.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3', '<(sqlite3)'],
|
|
||||||
}],
|
|
||||||
}],
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'target_name': 'sqlite3',
|
'target_name': 'sqlite3',
|
||||||
'type': 'static_library',
|
'type': 'static_library',
|
||||||
|
'include_dirs': [
|
||||||
|
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/',
|
||||||
|
],
|
||||||
|
'direct_dependent_settings': {
|
||||||
|
'include_dirs': [
|
||||||
|
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/',
|
||||||
|
],
|
||||||
|
},
|
||||||
'dependencies': ['locate_sqlite3'],
|
'dependencies': ['locate_sqlite3'],
|
||||||
'sources': ['<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c'],
|
'sources': ['<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c'],
|
||||||
'include_dirs': ['<(SHARED_INTERMEDIATE_DIR)/sqlite3/'],
|
|
||||||
'direct_dependent_settings': {
|
|
||||||
'include_dirs': ['<(SHARED_INTERMEDIATE_DIR)/sqlite3/'],
|
|
||||||
},
|
|
||||||
'cflags': ['-std=c99', '-w'],
|
'cflags': ['-std=c99', '-w'],
|
||||||
'xcode_settings': {
|
'xcode_settings': {
|
||||||
'OTHER_CFLAGS': ['-std=c99'],
|
'OTHER_CFLAGS': ['-std=c99'],
|
||||||
'WARNING_CFLAGS': ['-w'],
|
'WARNING_CFLAGS': ['-w'],
|
||||||
},
|
},
|
||||||
|
'includes': ['defines.gypi'],
|
||||||
'conditions': [
|
'conditions': [
|
||||||
['sqlite3 == ""', {
|
['OS == "win"', {
|
||||||
'includes': ['defines.gypi'],
|
|
||||||
}, {
|
|
||||||
'defines': [
|
'defines': [
|
||||||
# This is currently required by better-sqlite3.
|
'WIN32'
|
||||||
'SQLITE_ENABLE_COLUMN_METADATA',
|
|
||||||
],
|
],
|
||||||
}]
|
}],
|
||||||
],
|
],
|
||||||
'configurations': {
|
'configurations': {
|
||||||
'Debug': {
|
'Debug': {
|
||||||
|
|||||||
BIN
deps/sqlite3.tar.gz
vendored
BIN
deps/sqlite3.tar.gz
vendored
Binary file not shown.
@ -6,6 +6,7 @@ const util = require('./util');
|
|||||||
const {
|
const {
|
||||||
Database: CPPDatabase,
|
Database: CPPDatabase,
|
||||||
setErrorConstructor,
|
setErrorConstructor,
|
||||||
|
setCorruptionLogger,
|
||||||
} = require('bindings')('better_sqlite3.node');
|
} = require('bindings')('better_sqlite3.node');
|
||||||
|
|
||||||
function Database(filenameGiven, options) {
|
function Database(filenameGiven, options) {
|
||||||
@ -61,6 +62,7 @@ Database.prototype.close = wrappers.close;
|
|||||||
Database.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
|
Database.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
|
||||||
Database.prototype.unsafeMode = wrappers.unsafeMode;
|
Database.prototype.unsafeMode = wrappers.unsafeMode;
|
||||||
Database.prototype[util.inspect] = require('./methods/inspect');
|
Database.prototype[util.inspect] = require('./methods/inspect');
|
||||||
|
Database.setCorruptionLogger = setCorruptionLogger;
|
||||||
|
|
||||||
module.exports = Database;
|
module.exports = Database;
|
||||||
setErrorConstructor(require('./sqlite-error'));
|
setErrorConstructor(require('./sqlite-error'));
|
||||||
|
|||||||
@ -11,7 +11,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bindings": "^1.5.0",
|
"bindings": "^1.5.0",
|
||||||
"prebuild-install": "^6.0.1",
|
|
||||||
"tar": "^6.1.0"
|
"tar": "^6.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -20,12 +19,11 @@
|
|||||||
"fs-extra": "^9.1.0",
|
"fs-extra": "^9.1.0",
|
||||||
"mocha": "^8.3.2",
|
"mocha": "^8.3.2",
|
||||||
"nodemark": "^0.3.0",
|
"nodemark": "^0.3.0",
|
||||||
"prebuild": "^10.0.1",
|
|
||||||
"sqlite": "^4.0.19",
|
"sqlite": "^4.0.19",
|
||||||
"sqlite3": "^5.0.2"
|
"sqlite3": "^5.0.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"install": "prebuild-install || npm run build-release",
|
"install": "npm run build-release",
|
||||||
"build-release": "node-gyp rebuild --release",
|
"build-release": "node-gyp rebuild --release",
|
||||||
"build-debug": "node-gyp rebuild --debug",
|
"build-debug": "node-gyp rebuild --debug",
|
||||||
"rebuild-release": "npm run lzz && npm run build-release",
|
"rebuild-release": "npm run lzz && npm run build-release",
|
||||||
|
|||||||
@ -18,6 +18,7 @@ NODE_MODULE_INIT(/* exports, context */) {
|
|||||||
exports->Set(context, InternalizedFromLatin1(isolate, "StatementIterator"), StatementIterator::Init(isolate, data)).FromJust();
|
exports->Set(context, InternalizedFromLatin1(isolate, "StatementIterator"), StatementIterator::Init(isolate, data)).FromJust();
|
||||||
exports->Set(context, InternalizedFromLatin1(isolate, "Backup"), Backup::Init(isolate, data)).FromJust();
|
exports->Set(context, InternalizedFromLatin1(isolate, "Backup"), Backup::Init(isolate, data)).FromJust();
|
||||||
exports->Set(context, InternalizedFromLatin1(isolate, "setErrorConstructor"), v8::FunctionTemplate::New(isolate, Addon::JS_setErrorConstructor, data)->GetFunction(context).ToLocalChecked()).FromJust();
|
exports->Set(context, InternalizedFromLatin1(isolate, "setErrorConstructor"), v8::FunctionTemplate::New(isolate, Addon::JS_setErrorConstructor, data)->GetFunction(context).ToLocalChecked()).FromJust();
|
||||||
|
exports->Set(context, InternalizedFromLatin1(isolate, "setCorruptionLogger"), v8::FunctionTemplate::New(isolate, Addon::JS_setCorruptionLogger, data)->GetFunction(context).ToLocalChecked()).FromJust();
|
||||||
|
|
||||||
// Store addon instance data.
|
// Store addon instance data.
|
||||||
addon->Statement.Reset(isolate, v8::Local<v8::Function>::Cast(exports->Get(context, InternalizedFromLatin1(isolate, "Statement")).ToLocalChecked()));
|
addon->Statement.Reset(isolate, v8::Local<v8::Function>::Cast(exports->Get(context, InternalizedFromLatin1(isolate, "Statement")).ToLocalChecked()));
|
||||||
@ -1669,6 +1670,48 @@ void Addon::JS_setErrorConstructor (v8::FunctionCallbackInfo <v8 :: Value> const
|
|||||||
if ( info . Length ( ) <= ( 0 ) || ! info [ 0 ] -> IsFunction ( ) ) return ThrowTypeError ( "Expected " "first" " argument to be " "a function" ) ; v8 :: Local < v8 :: Function > SqliteError = v8 :: Local < v8 :: Function > :: Cast ( info [ 0 ] ) ;
|
if ( info . Length ( ) <= ( 0 ) || ! info [ 0 ] -> IsFunction ( ) ) return ThrowTypeError ( "Expected " "first" " argument to be " "a function" ) ; v8 :: Local < v8 :: Function > SqliteError = v8 :: Local < v8 :: Function > :: Cast ( info [ 0 ] ) ;
|
||||||
static_cast < Addon * > ( v8 :: Local < v8 :: External > :: Cast ( info . Data ( ) ) -> Value ( ) ) ->SqliteError.Reset( info . GetIsolate ( ) , SqliteError);
|
static_cast < Addon * > ( v8 :: Local < v8 :: External > :: Cast ( info . Data ( ) ) -> Value ( ) ) ->SqliteError.Reset( info . GetIsolate ( ) , SqliteError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class LogWrapper {
|
||||||
|
public:
|
||||||
|
LogWrapper(
|
||||||
|
v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Function> fn
|
||||||
|
): isolate_(isolate) {
|
||||||
|
fn_.Reset(isolate, fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Call(const char* msg) {
|
||||||
|
v8::HandleScope scope(isolate_);
|
||||||
|
v8::Local<v8::Function> fn =
|
||||||
|
v8::Local<v8::Function>::New(isolate_, fn_);
|
||||||
|
v8::Local<v8::Value> arg = StringFromUtf8(isolate_, msg, -1);
|
||||||
|
fn->Call(isolate_->GetCurrentContext(), v8::Undefined(isolate_), 1, &arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Fn(void *pArg, int iErrCode, const char *zMsg) {
|
||||||
|
LogWrapper* wrapper = reinterpret_cast<LogWrapper*>(pArg);
|
||||||
|
if (iErrCode == SQLITE_CORRUPT || iErrCode == SQLITE_NOTADB) {
|
||||||
|
wrapper->Call(zMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
v8::Isolate* isolate_;
|
||||||
|
v8::Persistent<v8::Function> fn_;
|
||||||
|
};
|
||||||
|
|
||||||
|
void Addon::JS_setCorruptionLogger (v8::FunctionCallbackInfo <v8 :: Value> const & info) {
|
||||||
|
if (info.Length() <= 0)
|
||||||
|
return ThrowTypeError("Expected one argument");
|
||||||
|
|
||||||
|
v8::Local<v8::Function> fn = v8::Local<v8::Function>::Cast(info[0]);
|
||||||
|
int status = sqlite3_config(
|
||||||
|
SQLITE_CONFIG_LOG,
|
||||||
|
LogWrapper::Fn,
|
||||||
|
new LogWrapper(v8::Isolate::GetCurrent(), fn));
|
||||||
|
assert(status == SQLITE_OK);
|
||||||
|
}
|
||||||
|
|
||||||
#line 48 "./src/better_sqlite3.lzz"
|
#line 48 "./src/better_sqlite3.lzz"
|
||||||
void Addon::Cleanup (void * ptr)
|
void Addon::Cleanup (void * ptr)
|
||||||
#line 48 "./src/better_sqlite3.lzz"
|
#line 48 "./src/better_sqlite3.lzz"
|
||||||
|
|||||||
@ -665,6 +665,7 @@ struct Addon
|
|||||||
std::set <Database*, Database::CompareDatabase> dbs;
|
std::set <Database*, Database::CompareDatabase> dbs;
|
||||||
#line 43 "./src/better_sqlite3.lzz"
|
#line 43 "./src/better_sqlite3.lzz"
|
||||||
static void JS_setErrorConstructor (v8::FunctionCallbackInfo <v8 :: Value> const & info);
|
static void JS_setErrorConstructor (v8::FunctionCallbackInfo <v8 :: Value> const & info);
|
||||||
|
static void JS_setCorruptionLogger (v8::FunctionCallbackInfo <v8 :: Value> const & info);
|
||||||
#line 48 "./src/better_sqlite3.lzz"
|
#line 48 "./src/better_sqlite3.lzz"
|
||||||
static void Cleanup (void * ptr);
|
static void Cleanup (void * ptr);
|
||||||
#line 55 "./src/better_sqlite3.lzz"
|
#line 55 "./src/better_sqlite3.lzz"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user