extralite-bundle 3.1.2 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/ext/extralite/database.c +9 -14
- data/ext/extralite/query.c +5 -5
- data/lib/extralite/version.rb +1 -1
- data/test/test_query.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: 476ad3a137ab5292ac1e7a5b6053db39b8136141154e42c06502e0d723875680
|
|
4
|
+
data.tar.gz: d33bae3131575f702577d7e1960a54f64d4d2ac6d3903eb41b3f8fb9f896288f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cbeb90a19c16e0355825de837ef6488614c1576df06ab2ba4dba1e6868568b839ee124d1713f4884156aa58ae3d7c8314e5675d90022fe3a08c6a54ec3448498
|
|
7
|
+
data.tar.gz: 885f3d695eec965ef271c3500eb07a56f9f06890b514f52d27d8f3a6e25c71c43b8034d730048b1a7f9db7e8f25ddebb5f69f1ddd2a9f53fe8adb926d323ad4a
|
data/CHANGELOG.md
CHANGED
data/ext/extralite/database.c
CHANGED
|
@@ -72,24 +72,19 @@ static void Database_compact(void *ptr) {
|
|
|
72
72
|
db->progress_handler.proc = rb_gc_location(db->progress_handler.proc);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
static
|
|
76
|
-
sqlite3_stmt *stmt = (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (stmt_cache == Qnil) return;
|
|
83
|
-
if (rb_hash_size_num(stmt_cache) == 0) return;
|
|
84
|
-
|
|
85
|
-
rb_hash_foreach(stmt_cache, stmt_cache_iter, Qnil);
|
|
86
|
-
RB_GC_GUARD(stmt_cache);
|
|
75
|
+
static inline void finalize_all_stmts(sqlite3 *db) {
|
|
76
|
+
sqlite3_stmt *stmt = sqlite3_next_stmt(db, NULL);
|
|
77
|
+
while (stmt) {
|
|
78
|
+
sqlite3_stmt *next = sqlite3_next_stmt(db, stmt);
|
|
79
|
+
sqlite3_finalize(stmt);
|
|
80
|
+
stmt = next;
|
|
81
|
+
}
|
|
87
82
|
}
|
|
88
83
|
|
|
89
84
|
static void Database_free(void *ptr) {
|
|
90
85
|
Database_t *db = ptr;
|
|
91
86
|
if (db->sqlite3_db) {
|
|
92
|
-
|
|
87
|
+
finalize_all_stmts(db->sqlite3_db);
|
|
93
88
|
sqlite3_close_v2(db->sqlite3_db);
|
|
94
89
|
}
|
|
95
90
|
free(ptr);
|
|
@@ -278,7 +273,7 @@ VALUE Database_close(VALUE self) {
|
|
|
278
273
|
int rc;
|
|
279
274
|
Database_t *db = self_to_database(self);
|
|
280
275
|
|
|
281
|
-
|
|
276
|
+
finalize_all_stmts(db->sqlite3_db);
|
|
282
277
|
rb_hash_clear(db->stmt_cache);
|
|
283
278
|
rc = sqlite3_close_v2(db->sqlite3_db);
|
|
284
279
|
if (rc) {
|
data/ext/extralite/query.c
CHANGED
|
@@ -40,8 +40,7 @@ static void Query_compact(void *ptr) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
static void Query_free(void *ptr) {
|
|
43
|
-
Query_t *query = ptr;
|
|
44
|
-
if (query->stmt) sqlite3_finalize(query->stmt);
|
|
43
|
+
// Query_t *query = ptr;
|
|
45
44
|
free(ptr);
|
|
46
45
|
}
|
|
47
46
|
|
|
@@ -70,7 +69,7 @@ static inline Query_t *self_to_query(VALUE obj) {
|
|
|
70
69
|
// verifies that the query is not closed
|
|
71
70
|
static inline Query_t *self_to_query_verify(VALUE obj) {
|
|
72
71
|
Query_t *query = self_to_query(obj);
|
|
73
|
-
if (query->closed) rb_raise(cError, "Query is closed");
|
|
72
|
+
if (query->closed || !(query->db_struct->sqlite3_db)) rb_raise(cError, "Query is closed");
|
|
74
73
|
return query;
|
|
75
74
|
}
|
|
76
75
|
|
|
@@ -133,8 +132,10 @@ VALUE Query_initialize(VALUE self, VALUE db, VALUE sql, VALUE mode) {
|
|
|
133
132
|
|
|
134
133
|
static inline void prep_query(Query_t *query) {
|
|
135
134
|
stmt_ctx stmt_ctx;
|
|
136
|
-
make_stmt_ctx(&stmt_ctx, query->db_struct, &(query->stmt), query->sql,
|
|
135
|
+
make_stmt_ctx(&stmt_ctx, query->db_struct, &(query->stmt), query->sql, 1, NULL);
|
|
137
136
|
prep_single_stmt(&stmt_ctx);
|
|
137
|
+
if (!(stmt_ctx.flags & STMT_CTX_F_CACHE_HIT))
|
|
138
|
+
rb_hash_aset(query->db_struct->stmt_cache, query->sql, ULONG2NUM((uint64_t)(query->stmt)));
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
static inline void query_reset(Query_t *query) {
|
|
@@ -531,7 +532,6 @@ VALUE Query_clone(VALUE self) {
|
|
|
531
532
|
VALUE Query_close(VALUE self) {
|
|
532
533
|
Query_t *query = self_to_query(self);
|
|
533
534
|
if (query->stmt) {
|
|
534
|
-
sqlite3_finalize(query->stmt);
|
|
535
535
|
query->stmt = NULL;
|
|
536
536
|
}
|
|
537
537
|
query->closed = 1;
|
data/lib/extralite/version.rb
CHANGED
data/test/test_query.rb
CHANGED
|
@@ -933,7 +933,7 @@ class QueryTest < Minitest::Test
|
|
|
933
933
|
def test_query_after_db_close
|
|
934
934
|
assert_equal [{ x: 4, y: 5, z: 6}], @query.bind(4).to_a
|
|
935
935
|
@db.close
|
|
936
|
-
|
|
936
|
+
assert_raises(Extralite::Error) { @query.bind(4).to_a }
|
|
937
937
|
end
|
|
938
938
|
|
|
939
939
|
def test_query_eof
|