extralite-bundle 2.7 → 2.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +5 -5
- data/ext/extralite/database.c +72 -59
- data/ext/extralite/iterator.c +0 -1
- data/ext/extralite/query.c +29 -28
- data/lib/extralite/version.rb +1 -1
- data/lib/extralite.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d930ae5bbc020859a6166e1737f1fd4bf2ebf286852db88f049c2d231a2d1e1
|
4
|
+
data.tar.gz: f1f7c4940418fd0a8c714d3fb7d2e772a2d62165c8ee191a9d0f1d07ee10fef2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd572e5bee474de4c48af4b38d78d1680fdc0f32faa0ca42486d2f509951711d775ff34c4fff5fba85709339fd6f910abafa73e02dede9db05337ad2d9f46fc8
|
7
|
+
data.tar.gz: bc7873b6b58aa93b747125a97d8b2602dd4aa92cd82f5d368264c07abccaf4fdfd6ffebb7d01f846d9cb69dd2b1219aa6390355eb8a97ac5195fd19669863851
|
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -891,7 +891,7 @@ above, calling `#interrupt` causes the query to raise a
|
|
891
891
|
`Extralite::InterruptError` exception:
|
892
892
|
|
893
893
|
```ruby
|
894
|
-
db.on_progress { db.interrupt }
|
894
|
+
db.on_progress(period: 1) { db.interrupt }
|
895
895
|
db.query('select 1')
|
896
896
|
#=> Extralite::InterruptError!
|
897
897
|
```
|
@@ -900,7 +900,7 @@ You can also interrupt queries in progress by raising an exception. The query
|
|
900
900
|
will be stopped, and the exception will propagate to the call site:
|
901
901
|
|
902
902
|
```ruby
|
903
|
-
db.on_progress do
|
903
|
+
db.on_progress(period: 1) do
|
904
904
|
raise 'BOOM!'
|
905
905
|
end
|
906
906
|
|
@@ -1003,7 +1003,7 @@ handler. This will work for switching between fibers using either Polyphony or
|
|
1003
1003
|
any fiber scheduler gem, such as Async et al:
|
1004
1004
|
|
1005
1005
|
```ruby
|
1006
|
-
db.on_progress
|
1006
|
+
db.on_progress { sleep(0) }
|
1007
1007
|
```
|
1008
1008
|
|
1009
1009
|
For Polyphony-based apps, you can also call `snooze` to allow other fibers to
|
@@ -1011,7 +1011,7 @@ run while a query is progressing. If your Polyphony app is multi-threaded,
|
|
1011
1011
|
you'll also need to call `Thread.pass` in order to allow other threads to run:
|
1012
1012
|
|
1013
1013
|
```ruby
|
1014
|
-
db.on_progress
|
1014
|
+
db.on_progress do
|
1015
1015
|
snooze
|
1016
1016
|
Thread.pass
|
1017
1017
|
end
|
@@ -1022,7 +1022,7 @@ use the regular `#move_on_after` and `#cancel_after` methods to implement
|
|
1022
1022
|
timeouts for queries:
|
1023
1023
|
|
1024
1024
|
```ruby
|
1025
|
-
db.on_progress
|
1025
|
+
db.on_progress { snooze }
|
1026
1026
|
|
1027
1027
|
cancel_after(3) do
|
1028
1028
|
db.query(long_running_query)
|
data/ext/extralite/database.c
CHANGED
@@ -721,15 +721,16 @@ static inline VALUE Database_prepare(int argc, VALUE *argv, VALUE self, VALUE mo
|
|
721
721
|
}
|
722
722
|
|
723
723
|
/* call-seq:
|
724
|
-
* db.prepare(sql) ->
|
725
|
-
* db.prepare(sql,
|
726
|
-
* db.prepare(sql,
|
724
|
+
* db.prepare(sql) -> query
|
725
|
+
* db.prepare(sql, *params) -> query
|
726
|
+
* db.prepare(sql, *params) { ... } -> query
|
727
727
|
*
|
728
728
|
* Creates a prepared query with the given SQL query in hash mode. If query
|
729
729
|
* parameters are given, they are bound to the query. If a block is given, it is
|
730
730
|
* used as a transform proc.
|
731
731
|
*
|
732
732
|
* @param sql [String] SQL statement
|
733
|
+
* @param *params [Array<any>] parameters to bind
|
733
734
|
* @return [Extralite::Query] prepared query
|
734
735
|
*/
|
735
736
|
VALUE Database_prepare_hash(int argc, VALUE *argv, VALUE self) {
|
@@ -738,14 +739,15 @@ VALUE Database_prepare_hash(int argc, VALUE *argv, VALUE self) {
|
|
738
739
|
|
739
740
|
/* call-seq:
|
740
741
|
* db.prepare_argv(sql) -> Extralite::Query
|
741
|
-
* db.prepare_argv(sql,
|
742
|
-
* db.prepare_argv(sql,
|
742
|
+
* db.prepare_argv(sql, *params) -> Extralite::Query
|
743
|
+
* db.prepare_argv(sql, *params) { ... } -> Extralite::Query
|
743
744
|
*
|
744
745
|
* Creates a prepared query with the given SQL query in argv mode. If query
|
745
746
|
* parameters are given, they are bound to the query. If a block is given, it is
|
746
747
|
* used as a transform proc.
|
747
748
|
*
|
748
749
|
* @param sql [String] SQL statement
|
750
|
+
* @param *params [Array<any>] parameters to bind
|
749
751
|
* @return [Extralite::Query] prepared query
|
750
752
|
*/
|
751
753
|
VALUE Database_prepare_argv(int argc, VALUE *argv, VALUE self) {
|
@@ -754,14 +756,15 @@ VALUE Database_prepare_argv(int argc, VALUE *argv, VALUE self) {
|
|
754
756
|
|
755
757
|
/* call-seq:
|
756
758
|
* db.prepare_ary(sql) -> Extralite::Query
|
757
|
-
* db.prepare_ary(sql,
|
758
|
-
* db.prepare_ary(sql,
|
759
|
+
* db.prepare_ary(sql, *params) -> Extralite::Query
|
760
|
+
* db.prepare_ary(sql, *params) { ... } -> Extralite::Query
|
759
761
|
*
|
760
762
|
* Creates a prepared query with the given SQL query in ary mode. If query
|
761
763
|
* parameters are given, they are bound to the query. If a block is given, it is
|
762
764
|
* used as a transform proc.
|
763
765
|
*
|
764
766
|
* @param sql [String] SQL statement
|
767
|
+
* @param *params [Array<any>] parameters to bind
|
765
768
|
* @return [Extralite::Query] prepared query
|
766
769
|
*/
|
767
770
|
VALUE Database_prepare_ary(int argc, VALUE *argv, VALUE self) {
|
@@ -850,7 +853,11 @@ VALUE backup_cleanup(VALUE ptr) {
|
|
850
853
|
return Qnil;
|
851
854
|
}
|
852
855
|
|
853
|
-
/*
|
856
|
+
/* call-seq:
|
857
|
+
* db.backup(dest, src_db_name = 'main', dst_db_name = 'main') { |remaining, total| ... } -> db
|
858
|
+
*
|
859
|
+
*
|
860
|
+
* Creates a backup of the database to the given destination, which can be
|
854
861
|
* either a filename or a database instance. In order to monitor the backup
|
855
862
|
* progress you can pass a block that will be called periodically by the backup
|
856
863
|
* method with two arguments: the remaining page count, and the total page
|
@@ -862,6 +869,8 @@ VALUE backup_cleanup(VALUE ptr) {
|
|
862
869
|
* end
|
863
870
|
*
|
864
871
|
* @param dest [String, Extralite::Database] backup destination
|
872
|
+
* @param src_db_name [String] source database name (default: "main")
|
873
|
+
* @param dst_db_name [String] Destination database name (default: "main")
|
865
874
|
* @return [Extralite::Database] source database
|
866
875
|
*/
|
867
876
|
VALUE Database_backup(int argc, VALUE *argv, VALUE self) {
|
@@ -1030,7 +1039,10 @@ VALUE Database_trace(VALUE self) {
|
|
1030
1039
|
}
|
1031
1040
|
|
1032
1041
|
#ifdef EXTRALITE_ENABLE_CHANGESET
|
1033
|
-
/*
|
1042
|
+
/* call-seq:
|
1043
|
+
* db.track_changes(*tables) { ... } -> changeset
|
1044
|
+
*
|
1045
|
+
* Tracks changes to the database and returns a changeset. The changeset can
|
1034
1046
|
* then be used to store the changes to a file, apply them to another database,
|
1035
1047
|
* or undo the changes. The given table names specify which tables should be
|
1036
1048
|
* tracked for changes. Passing a value of nil causes all tables to be tracked.
|
@@ -1041,7 +1053,7 @@ VALUE Database_trace(VALUE self) {
|
|
1041
1053
|
*
|
1042
1054
|
* File.open('my.changes', 'w+') { |f| f << changeset.to_blob }
|
1043
1055
|
*
|
1044
|
-
* @param
|
1056
|
+
* @param *tables [Array<String, Symbol>] table(s) to track
|
1045
1057
|
* @return [Extralite::Changeset] changeset
|
1046
1058
|
*/
|
1047
1059
|
VALUE Database_track_changes(int argc, VALUE *argv, VALUE self) {
|
@@ -1185,7 +1197,7 @@ struct progress_handler parse_progress_handler_opts(VALUE opts) {
|
|
1185
1197
|
* @option opts [Integer] :period period value (`1000` by default)
|
1186
1198
|
* @option opts [Integer] :tick tick value (`10` by default)
|
1187
1199
|
* @option opts [Symbol] :mode progress handler mode (`:normal` by default)
|
1188
|
-
* @
|
1200
|
+
* @return [Extralite::Database] database
|
1189
1201
|
*/
|
1190
1202
|
VALUE Database_on_progress(int argc, VALUE *argv, VALUE self) {
|
1191
1203
|
Database_t *db = self_to_open_database(self);
|
@@ -1220,7 +1232,10 @@ VALUE Database_on_progress(int argc, VALUE *argv, VALUE self) {
|
|
1220
1232
|
return self;
|
1221
1233
|
}
|
1222
1234
|
|
1223
|
-
/*
|
1235
|
+
/* call-seq:
|
1236
|
+
* Extralite.on_progress(**opts) { ... }
|
1237
|
+
*
|
1238
|
+
* Installs or removes a global progress handler that will be executed
|
1224
1239
|
* periodically while a query is running. This method can be used to support
|
1225
1240
|
* switching between fibers and threads or implementing timeouts for running
|
1226
1241
|
* queries.
|
@@ -1275,7 +1290,7 @@ VALUE Database_on_progress(int argc, VALUE *argv, VALUE self) {
|
|
1275
1290
|
* @option opts [Integer] :period period value (`1000` by default)
|
1276
1291
|
* @option opts [Integer] :tick tick value (`10` by default)
|
1277
1292
|
* @option opts [Symbol] :mode progress handler mode (`:normal` by default)
|
1278
|
-
* @
|
1293
|
+
* @return [Extralite::Database] database
|
1279
1294
|
*/
|
1280
1295
|
VALUE Extralite_on_progress(int argc, VALUE *argv, VALUE self) {
|
1281
1296
|
VALUE opts;
|
@@ -1361,7 +1376,7 @@ VALUE Database_gvl_release_threshold_get(VALUE self) {
|
|
1361
1376
|
* A value of nil sets the threshold to the default value, which is
|
1362
1377
|
* currently 1000.
|
1363
1378
|
*
|
1364
|
-
* @param [Integer, nil] GVL release threshold
|
1379
|
+
* @param threshold [Integer, nil] GVL release threshold
|
1365
1380
|
* @return [Integer] GVL release threshold
|
1366
1381
|
*/
|
1367
1382
|
VALUE Database_gvl_release_threshold_set(VALUE self, VALUE value) {
|
@@ -1398,63 +1413,61 @@ void Init_ExtraliteDatabase(void) {
|
|
1398
1413
|
cDatabase = rb_define_class_under(mExtralite, "Database", rb_cObject);
|
1399
1414
|
rb_define_alloc_func(cDatabase, Database_allocate);
|
1400
1415
|
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
DEF("errcode", Database_errcode, 0);
|
1415
|
-
DEF("errmsg", Database_errmsg, 0);
|
1416
|
+
rb_define_method(cDatabase, "backup", Database_backup, -1);
|
1417
|
+
rb_define_method(cDatabase, "batch_execute", Database_batch_execute, 2);
|
1418
|
+
rb_define_method(cDatabase, "batch_query", Database_batch_query, 2);
|
1419
|
+
rb_define_method(cDatabase, "batch_query_ary", Database_batch_query_ary, 2);
|
1420
|
+
rb_define_method(cDatabase, "batch_query_argv", Database_batch_query_argv, 2);
|
1421
|
+
rb_define_method(cDatabase, "batch_query_hash", Database_batch_query, 2);
|
1422
|
+
rb_define_method(cDatabase, "busy_timeout=", Database_busy_timeout_set, 1);
|
1423
|
+
rb_define_method(cDatabase, "changes", Database_changes, 0);
|
1424
|
+
rb_define_method(cDatabase, "close", Database_close, 0);
|
1425
|
+
rb_define_method(cDatabase, "closed?", Database_closed_p, 0);
|
1426
|
+
rb_define_method(cDatabase, "columns", Database_columns, 1);
|
1427
|
+
rb_define_method(cDatabase, "errcode", Database_errcode, 0);
|
1428
|
+
rb_define_method(cDatabase, "errmsg", Database_errmsg, 0);
|
1416
1429
|
|
1417
1430
|
#ifdef HAVE_SQLITE3_ERROR_OFFSET
|
1418
|
-
|
1431
|
+
rb_define_method(cDatabase, "error_offset", Database_error_offset, 0);
|
1419
1432
|
#endif
|
1420
1433
|
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1434
|
+
rb_define_method(cDatabase, "execute", Database_execute, -1);
|
1435
|
+
rb_define_method(cDatabase, "filename", Database_filename, -1);
|
1436
|
+
rb_define_method(cDatabase, "gvl_release_threshold", Database_gvl_release_threshold_get, 0);
|
1437
|
+
rb_define_method(cDatabase, "gvl_release_threshold=", Database_gvl_release_threshold_set, 1);
|
1438
|
+
rb_define_method(cDatabase, "initialize", Database_initialize, -1);
|
1439
|
+
rb_define_method(cDatabase, "inspect", Database_inspect, 0);
|
1440
|
+
rb_define_method(cDatabase, "interrupt", Database_interrupt, 0);
|
1441
|
+
rb_define_method(cDatabase, "last_insert_rowid", Database_last_insert_rowid, 0);
|
1442
|
+
rb_define_method(cDatabase, "limit", Database_limit, -1);
|
1430
1443
|
|
1431
1444
|
#ifdef HAVE_SQLITE3_LOAD_EXTENSION
|
1432
|
-
|
1445
|
+
rb_define_method(cDatabase, "load_extension", Database_load_extension, 1);
|
1433
1446
|
#endif
|
1434
1447
|
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1448
|
+
rb_define_method(cDatabase, "on_progress", Database_on_progress, -1);
|
1449
|
+
rb_define_method(cDatabase, "prepare", Database_prepare_hash, -1);
|
1450
|
+
rb_define_method(cDatabase, "prepare_argv", Database_prepare_argv, -1);
|
1451
|
+
rb_define_method(cDatabase, "prepare_ary", Database_prepare_ary, -1);
|
1452
|
+
rb_define_method(cDatabase, "prepare_hash", Database_prepare_hash, -1);
|
1453
|
+
rb_define_method(cDatabase, "query", Database_query, -1);
|
1454
|
+
rb_define_method(cDatabase, "query_argv", Database_query_argv, -1);
|
1455
|
+
rb_define_method(cDatabase, "query_ary", Database_query_ary, -1);
|
1456
|
+
rb_define_method(cDatabase, "query_hash", Database_query, -1);
|
1457
|
+
rb_define_method(cDatabase, "query_single", Database_query_single, -1);
|
1458
|
+
rb_define_method(cDatabase, "query_single_ary", Database_query_single_ary, -1);
|
1459
|
+
rb_define_method(cDatabase, "query_single_argv", Database_query_single_argv, -1);
|
1460
|
+
rb_define_method(cDatabase, "query_single_hash", Database_query_single, -1);
|
1461
|
+
rb_define_method(cDatabase, "read_only?", Database_read_only_p, 0);
|
1462
|
+
rb_define_method(cDatabase, "status", Database_status, -1);
|
1463
|
+
rb_define_method(cDatabase, "total_changes", Database_total_changes, 0);
|
1464
|
+
rb_define_method(cDatabase, "trace", Database_trace, 0);
|
1452
1465
|
|
1453
1466
|
#ifdef EXTRALITE_ENABLE_CHANGESET
|
1454
|
-
|
1467
|
+
rb_define_method(cDatabase, "track_changes", Database_track_changes, -1);
|
1455
1468
|
#endif
|
1456
1469
|
|
1457
|
-
|
1470
|
+
rb_define_method(cDatabase, "transaction_active?", Database_transaction_active_p, 0);
|
1458
1471
|
|
1459
1472
|
cBlob = rb_define_class_under(mExtralite, "Blob", rb_cString);
|
1460
1473
|
cError = rb_define_class_under(mExtralite, "Error", rb_eStandardError);
|
data/ext/extralite/iterator.c
CHANGED
data/ext/extralite/query.c
CHANGED
@@ -593,9 +593,12 @@ VALUE Query_mode_get(VALUE self) {
|
|
593
593
|
return query_mode_to_symbol(query->query_mode);
|
594
594
|
}
|
595
595
|
|
596
|
-
/*
|
596
|
+
/* call-seq:
|
597
|
+
* query.mode = mode
|
598
|
+
*
|
599
|
+
* Sets the query mode. This can be one of `:hash`, `:argv`, `:ary`.
|
597
600
|
*
|
598
|
-
* @param [Symbol] query mode
|
601
|
+
* @param mode [Symbol] query mode
|
599
602
|
* @return [Symbol] query mode
|
600
603
|
*/
|
601
604
|
VALUE Query_mode_set(VALUE self, VALUE mode) {
|
@@ -610,32 +613,30 @@ void Init_ExtraliteQuery(void) {
|
|
610
613
|
cQuery = rb_define_class_under(mExtralite, "Query", rb_cObject);
|
611
614
|
rb_define_alloc_func(cQuery, Query_allocate);
|
612
615
|
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
DEF("to_a", Query_to_a, 0);
|
638
|
-
DEF("transform", Query_transform, 0);
|
616
|
+
rb_define_method(cQuery, "bind", Query_bind, -1);
|
617
|
+
rb_define_method(cQuery, "close", Query_close, 0);
|
618
|
+
rb_define_method(cQuery, "closed?", Query_closed_p, 0);
|
619
|
+
rb_define_method(cQuery, "columns", Query_columns, 0);
|
620
|
+
rb_define_method(cQuery, "clone", Query_clone, 0);
|
621
|
+
rb_define_method(cQuery, "database", Query_database, 0);
|
622
|
+
rb_define_method(cQuery, "db", Query_database, 0);
|
623
|
+
rb_define_method(cQuery, "dup", Query_clone, 0);
|
624
|
+
rb_define_method(cQuery, "each", Query_each, 0);
|
625
|
+
rb_define_method(cQuery, "eof?", Query_eof_p, 0);
|
626
|
+
rb_define_method(cQuery, "execute", Query_execute, -1);
|
627
|
+
rb_define_method(cQuery, "<<", Query_execute_chevrons, 1);
|
628
|
+
rb_define_method(cQuery, "batch_execute", Query_batch_execute, 1);
|
629
|
+
rb_define_method(cQuery, "batch_query", Query_batch_query, 1);
|
630
|
+
rb_define_method(cQuery, "initialize", Query_initialize, 3);
|
631
|
+
rb_define_method(cQuery, "inspect", Query_inspect, 0);
|
632
|
+
rb_define_method(cQuery, "mode", Query_mode_get, 0);
|
633
|
+
rb_define_method(cQuery, "mode=", Query_mode_set, 1);
|
634
|
+
rb_define_method(cQuery, "next", Query_next, -1);
|
635
|
+
rb_define_method(cQuery, "reset", Query_reset, 0);
|
636
|
+
rb_define_method(cQuery, "sql", Query_sql, 0);
|
637
|
+
rb_define_method(cQuery, "status", Query_status, -1);
|
638
|
+
rb_define_method(cQuery, "to_a", Query_to_a, 0);
|
639
|
+
rb_define_method(cQuery, "transform", Query_transform, 0);
|
639
640
|
|
640
641
|
ID_inspect = rb_intern("inspect");
|
641
642
|
ID_slice = rb_intern("slice");
|
data/lib/extralite/version.rb
CHANGED
data/lib/extralite.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extralite-bundle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|