extralite-bundle 2.8.2 → 2.10
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/.github/workflows/test.yml +4 -4
- data/CHANGELOG.md +11 -1
- data/README.md +1 -1
- data/ext/extralite/common.c +61 -19
- data/ext/sqlite3/sqlite3.c +8563 -4784
- data/ext/sqlite3/sqlite3.h +343 -53
- data/gemspec.rb +5 -5
- data/lib/extralite/version.rb +1 -1
- data/test/test_database.rb +48 -1
- metadata +13 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 331d047adebf78c99a777dc3fb5861cce9c112bf020c1bfe75c8e188611ba0e1
|
4
|
+
data.tar.gz: c5c02f82568127e8edc4e4b5124f84a361cc53e5d8aafe859456f855b7dca4a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e38f367a6c1baf1d32c52f9ecb540ab292e93989aad9b47cf3b8b3f728190cadde70d90f962a224365b0e689a2677a9e869aafd82852cbf02414b2eb61630df
|
7
|
+
data.tar.gz: ea986d0dbebcc0f668e55b88ce75e2dd2be30d7e93f05c8735b98a77e3fb72bd55041995e3a0a7fd7ee2e67673e980c73c45cb36b21a85db925590cd164e5869
|
data/.github/workflows/test.yml
CHANGED
@@ -11,9 +11,8 @@ jobs:
|
|
11
11
|
strategy:
|
12
12
|
fail-fast: false
|
13
13
|
matrix:
|
14
|
-
|
15
|
-
|
16
|
-
ruby: ['3.0', '3.1', '3.2', '3.3', 'head']
|
14
|
+
os: [ubuntu-latest, macos-latest]
|
15
|
+
ruby: ['3.2', '3.3', '3.4', 'head']
|
17
16
|
|
18
17
|
name: ${{matrix.os}}, ${{matrix.ruby}}
|
19
18
|
|
@@ -25,7 +24,8 @@ jobs:
|
|
25
24
|
- uses: ruby/setup-ruby@v1
|
26
25
|
with:
|
27
26
|
ruby-version: ${{matrix.ruby}}
|
28
|
-
bundler-cache: true
|
27
|
+
bundler-cache: true
|
28
|
+
apt-get: libsqlite3-dev
|
29
29
|
- name: Compile C-extension
|
30
30
|
run: bundle exec rake compile
|
31
31
|
- name: Run tests
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
|
+
## 2.10 2025-02-17
|
2
|
+
|
3
|
+
- Update bundled SQLite to version 3.49.0.
|
4
|
+
|
5
|
+
## 2.9 2025-01-18
|
6
|
+
|
7
|
+
- Update dependencies, test matrix.
|
8
|
+
- Update bundled SQLite to version 3.48.0.
|
9
|
+
- Optimize getting column names when returning rows as hashes.
|
10
|
+
|
1
11
|
## 2.8.2 2024-06-02
|
2
12
|
|
3
|
-
- Update bundled SQLite to version 3.46.0
|
13
|
+
- Update bundled SQLite to version 3.46.0. [#74](https://github.com/digital-fabric/extralite/pull/74)
|
4
14
|
|
5
15
|
## 2.8.1 2024-04-15
|
6
16
|
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ databases.
|
|
32
32
|
Extralite comes in two flavors: the `extralite` gem which uses the
|
33
33
|
system-installed sqlite3 library, and the `extralite-bundle` gem which bundles
|
34
34
|
the latest version of SQLite
|
35
|
-
([3.
|
35
|
+
([3.49.0](https://sqlite.org/releaselog/3_49_0.html)), offering access to the
|
36
36
|
latest features and enhancements.
|
37
37
|
|
38
38
|
## Features
|
data/ext/extralite/common.c
CHANGED
@@ -135,7 +135,44 @@ inline void bind_all_parameters_from_object(sqlite3_stmt *stmt, VALUE obj) {
|
|
135
135
|
bind_parameter_value(stmt, 1, obj);
|
136
136
|
}
|
137
137
|
|
138
|
-
|
138
|
+
#define MAX_EMBEDDED_COLUMN_NAMES 12
|
139
|
+
|
140
|
+
struct column_names {
|
141
|
+
int count;
|
142
|
+
union {
|
143
|
+
VALUE array;
|
144
|
+
VALUE names[MAX_EMBEDDED_COLUMN_NAMES];
|
145
|
+
};
|
146
|
+
};
|
147
|
+
|
148
|
+
static inline void column_names_setup(struct column_names *names, int count) {
|
149
|
+
names->count = count;
|
150
|
+
names->array = (count > MAX_EMBEDDED_COLUMN_NAMES) ? rb_ary_new2(count) : Qnil;
|
151
|
+
}
|
152
|
+
|
153
|
+
static inline void column_names_set(struct column_names *names, int idx, VALUE value) {
|
154
|
+
if (names->count <= MAX_EMBEDDED_COLUMN_NAMES)
|
155
|
+
names->names[idx] = value;
|
156
|
+
else
|
157
|
+
rb_ary_push(names->array, value);
|
158
|
+
}
|
159
|
+
|
160
|
+
static inline VALUE column_names_get(struct column_names *names, int idx) {
|
161
|
+
return (names->count <= MAX_EMBEDDED_COLUMN_NAMES) ?
|
162
|
+
names->names[idx] : RARRAY_AREF(names->array, idx);
|
163
|
+
}
|
164
|
+
|
165
|
+
static inline struct column_names get_column_names(sqlite3_stmt *stmt, int column_count) {
|
166
|
+
struct column_names names;
|
167
|
+
column_names_setup(&names, column_count);
|
168
|
+
for (int i = 0; i < column_count; i++) {
|
169
|
+
VALUE name = ID2SYM(rb_intern(sqlite3_column_name(stmt, i)));
|
170
|
+
column_names_set(&names, i, name);
|
171
|
+
}
|
172
|
+
return names;
|
173
|
+
}
|
174
|
+
|
175
|
+
static inline VALUE get_column_names_array(sqlite3_stmt *stmt, int column_count) {
|
139
176
|
VALUE arr = rb_ary_new2(column_count);
|
140
177
|
for (int i = 0; i < column_count; i++) {
|
141
178
|
VALUE name = ID2SYM(rb_intern(sqlite3_column_name(stmt, i)));
|
@@ -144,11 +181,19 @@ static inline VALUE get_column_names(sqlite3_stmt *stmt, int column_count) {
|
|
144
181
|
return arr;
|
145
182
|
}
|
146
183
|
|
147
|
-
static inline VALUE row_to_hash(sqlite3_stmt *stmt, int column_count,
|
184
|
+
static inline VALUE row_to_hash(sqlite3_stmt *stmt, int column_count, struct column_names *names) {
|
148
185
|
VALUE row = rb_hash_new();
|
149
|
-
|
150
|
-
|
151
|
-
|
186
|
+
if (names->count <= MAX_EMBEDDED_COLUMN_NAMES) {
|
187
|
+
for (int i = 0; i < column_count; i++) {
|
188
|
+
VALUE value = get_column_value(stmt, i, sqlite3_column_type(stmt, i));
|
189
|
+
rb_hash_aset(row, names->names[i], value);
|
190
|
+
}
|
191
|
+
}
|
192
|
+
else {
|
193
|
+
for (int i = 0; i < column_count; i++) {
|
194
|
+
VALUE value = get_column_value(stmt, i, sqlite3_column_type(stmt, i));
|
195
|
+
rb_hash_aset(row, RARRAY_AREF(names->array, i), value);
|
196
|
+
}
|
152
197
|
}
|
153
198
|
return row;
|
154
199
|
}
|
@@ -327,12 +372,12 @@ VALUE safe_query_hash(query_ctx *ctx) {
|
|
327
372
|
VALUE array = ROW_MULTI_P(ctx->row_mode) ? rb_ary_new() : Qnil;
|
328
373
|
VALUE row = Qnil;
|
329
374
|
int column_count = sqlite3_column_count(ctx->stmt);
|
330
|
-
|
375
|
+
struct column_names names = get_column_names(ctx->stmt, column_count);
|
331
376
|
int row_count = 0;
|
332
377
|
int do_transform = !NIL_P(ctx->transform_proc);
|
333
378
|
|
334
379
|
while (stmt_iterate(ctx)) {
|
335
|
-
row = row_to_hash(ctx->stmt, column_count,
|
380
|
+
row = row_to_hash(ctx->stmt, column_count, &names);
|
336
381
|
if (do_transform)
|
337
382
|
row = rb_funcall(ctx->transform_proc, ID_call, 1, row);
|
338
383
|
row_count++;
|
@@ -350,7 +395,7 @@ VALUE safe_query_hash(query_ctx *ctx) {
|
|
350
395
|
return ROW_MULTI_P(ctx->row_mode) ? array : ctx->self;
|
351
396
|
}
|
352
397
|
|
353
|
-
RB_GC_GUARD(
|
398
|
+
RB_GC_GUARD(names.array);
|
354
399
|
RB_GC_GUARD(row);
|
355
400
|
RB_GC_GUARD(array);
|
356
401
|
return ROW_MULTI_P(ctx->row_mode) ? array : Qnil;
|
@@ -445,21 +490,18 @@ VALUE safe_query_array(query_ctx *ctx) {
|
|
445
490
|
}
|
446
491
|
|
447
492
|
VALUE safe_query_single_row_hash(query_ctx *ctx) {
|
448
|
-
int column_count;
|
493
|
+
int column_count = sqlite3_column_count(ctx->stmt);
|
449
494
|
VALUE row = Qnil;
|
450
|
-
|
451
|
-
|
452
|
-
column_count = sqlite3_column_count(ctx->stmt);
|
453
|
-
column_names = get_column_names(ctx->stmt, column_count);
|
495
|
+
struct column_names names = get_column_names(ctx->stmt, column_count);
|
454
496
|
|
455
497
|
if (stmt_iterate(ctx)) {
|
456
|
-
row = row_to_hash(ctx->stmt, column_count,
|
498
|
+
row = row_to_hash(ctx->stmt, column_count, &names);
|
457
499
|
if (!NIL_P(ctx->transform_proc))
|
458
500
|
row = rb_funcall(ctx->transform_proc, ID_call, 1, row);
|
459
501
|
}
|
460
502
|
|
461
503
|
RB_GC_GUARD(row);
|
462
|
-
RB_GC_GUARD(
|
504
|
+
RB_GC_GUARD(names.array);
|
463
505
|
return row;
|
464
506
|
}
|
465
507
|
|
@@ -506,17 +548,17 @@ static inline VALUE batch_iterate_hash(query_ctx *ctx) {
|
|
506
548
|
VALUE rows = rb_ary_new();
|
507
549
|
VALUE row = Qnil;
|
508
550
|
int column_count = sqlite3_column_count(ctx->stmt);
|
509
|
-
|
551
|
+
struct column_names names = get_column_names(ctx->stmt, column_count);
|
510
552
|
const int do_transform = !NIL_P(ctx->transform_proc);
|
511
553
|
|
512
554
|
while (stmt_iterate(ctx)) {
|
513
|
-
row = row_to_hash(ctx->stmt, column_count,
|
555
|
+
row = row_to_hash(ctx->stmt, column_count, &names);
|
514
556
|
if (do_transform)
|
515
557
|
row = rb_funcall(ctx->transform_proc, ID_call, 1, row);
|
516
558
|
rb_ary_push(rows, row);
|
517
559
|
}
|
518
560
|
|
519
|
-
RB_GC_GUARD(
|
561
|
+
RB_GC_GUARD(names.array);
|
520
562
|
RB_GC_GUARD(row);
|
521
563
|
RB_GC_GUARD(rows);
|
522
564
|
return rows;
|
@@ -733,7 +775,7 @@ VALUE safe_batch_query_splat(query_ctx *ctx) {
|
|
733
775
|
}
|
734
776
|
|
735
777
|
VALUE safe_query_columns(query_ctx *ctx) {
|
736
|
-
return
|
778
|
+
return get_column_names_array(ctx->stmt, sqlite3_column_count(ctx->stmt));
|
737
779
|
}
|
738
780
|
|
739
781
|
VALUE safe_query_changes(query_ctx *ctx) {
|