extralite 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/ext/extralite/extralite.c +23 -3
- data/lib/extralite/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cdf5b562230dd1dc2e3dcc4083836c6d61ac4bfd51fdc12d7129ff57dc36148
|
4
|
+
data.tar.gz: 1db604b9d586ed4f3ca45516ad25ed73c4d668407616c5657372074a7d0d13a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bca80a7a86e23651cf7c672a74bbc423b696b080155a1932378af4028d282260b079754d99c0e6e52e1ab7bd2ca9417c67fe285af8bcd7e090c9b4d764f0f6a5
|
7
|
+
data.tar.gz: 74f35b4542eda30a6944403b1ea46d329a64deacf75a023bdae1ff718f7b0cce01278ffbc1e67f2a7a865d8fca44788454329d2aaedad69b402692c059ca8e90
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/ext/extralite/extralite.c
CHANGED
@@ -44,10 +44,14 @@ VALUE Database_initialize(VALUE self, VALUE path) {
|
|
44
44
|
|
45
45
|
rc = sqlite3_open(StringValueCStr(path), &db->sqlite3_db);
|
46
46
|
if (rc) {
|
47
|
-
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db->sqlite3_db));
|
48
47
|
sqlite3_close(db->sqlite3_db);
|
49
|
-
|
50
|
-
|
48
|
+
rb_raise(cError, "%s", sqlite3_errmsg(db->sqlite3_db));
|
49
|
+
}
|
50
|
+
|
51
|
+
rc = sqlite3_enable_load_extension(db->sqlite3_db, 1);
|
52
|
+
if (rc) {
|
53
|
+
sqlite3_close(db->sqlite3_db);
|
54
|
+
rb_raise(cError, "%s", sqlite3_errmsg(db->sqlite3_db));
|
51
55
|
}
|
52
56
|
|
53
57
|
return Qnil;
|
@@ -371,6 +375,21 @@ VALUE Database_transaction_active_p(VALUE self) {
|
|
371
375
|
return sqlite3_get_autocommit(db->sqlite3_db) ? Qfalse : Qtrue;
|
372
376
|
}
|
373
377
|
|
378
|
+
VALUE Database_load_extension(VALUE self, VALUE path) {
|
379
|
+
Database_t *db;
|
380
|
+
GetDatabase(self, db);
|
381
|
+
char *err_msg;
|
382
|
+
|
383
|
+
int rc = sqlite3_load_extension(db->sqlite3_db, RSTRING_PTR(path), 0, &err_msg);
|
384
|
+
if (rc != SQLITE_OK) {
|
385
|
+
VALUE error = rb_exc_new2(cError, err_msg);
|
386
|
+
sqlite3_free(err_msg);
|
387
|
+
rb_exc_raise(error);
|
388
|
+
}
|
389
|
+
|
390
|
+
return self;
|
391
|
+
}
|
392
|
+
|
374
393
|
void Init_Extralite() {
|
375
394
|
VALUE mExtralite = rb_define_module("Extralite");
|
376
395
|
VALUE cDatabase = rb_define_class_under(mExtralite, "Database", rb_cObject);
|
@@ -388,6 +407,7 @@ void Init_Extralite() {
|
|
388
407
|
rb_define_method(cDatabase, "changes", Database_changes, 0);
|
389
408
|
rb_define_method(cDatabase, "filename", Database_filename, -1);
|
390
409
|
rb_define_method(cDatabase, "transaction_active?", Database_transaction_active_p, 0);
|
410
|
+
rb_define_method(cDatabase, "load_extension", Database_load_extension, 1);
|
391
411
|
|
392
412
|
cError = rb_define_class_under(mExtralite, "Error", rb_eRuntimeError);
|
393
413
|
}
|
data/lib/extralite/version.rb
CHANGED