extralite 2.7.1 → 2.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,12 +22,16 @@ ID ID_to_s;
22
22
  ID ID_track;
23
23
 
24
24
  VALUE SYM_at_least_once;
25
+ VALUE SYM_full;
25
26
  VALUE SYM_gvl_release_threshold;
26
27
  VALUE SYM_once;
27
28
  VALUE SYM_none;
28
29
  VALUE SYM_normal;
30
+ VALUE SYM_passive;
29
31
  VALUE SYM_pragma;
30
32
  VALUE SYM_read_only;
33
+ VALUE SYM_restart;
34
+ VALUE SYM_truncate;
31
35
  VALUE SYM_wal;
32
36
 
33
37
  struct progress_handler global_progress_handler = {
@@ -342,18 +346,18 @@ VALUE Database_query(int argc, VALUE *argv, VALUE self) {
342
346
  * splatted:
343
347
  *
344
348
  * transform = ->(a, b, c) { a * 100 + b * 10 + c }
345
- * db.query_argv(transform, 'select a, b, c from foo where c = ?', 42)
349
+ * db.query_splat(transform, 'select a, b, c from foo where c = ?', 42)
346
350
  *
347
- * @overload query_argv(sql, ...)
351
+ * @overload query_splat(sql, ...)
348
352
  * @param sql [String] SQL statement
349
353
  * @return [Array<Array, any>, Integer] rows or total changes
350
- * @overload query_argv(transform, sql, ...)
354
+ * @overload query_splat(transform, sql, ...)
351
355
  * @param transform [Proc] transform proc
352
356
  * @param sql [String] SQL statement
353
357
  * @return [Array<Array, any>, Integer] rows or total changes
354
358
  */
355
- VALUE Database_query_argv(int argc, VALUE *argv, VALUE self) {
356
- return Database_perform_query(argc, argv, self, safe_query_argv, QUERY_ARGV);
359
+ VALUE Database_query_splat(int argc, VALUE *argv, VALUE self) {
360
+ return Database_perform_query(argc, argv, self, safe_query_splat, QUERY_SPLAT);
357
361
  }
358
362
 
359
363
  /* Runs a query returning rows as arrays. If a block is given, it will be called
@@ -364,26 +368,26 @@ VALUE Database_query_argv(int argc, VALUE *argv, VALUE self) {
364
368
  * parameters are given as an array, the query should specify parameters using
365
369
  * `?`:
366
370
  *
367
- * db.query_ary('select * from foo where x = ?', 42)
371
+ * db.query_array('select * from foo where x = ?', 42)
368
372
  *
369
373
  * Named placeholders are specified using `:`. The placeholder values are
370
374
  * specified using a hash, where keys are either strings are symbols. String
371
375
  * keys can include or omit the `:` prefix. The following are equivalent:
372
376
  *
373
- * db.query_ary('select * from foo where x = :bar', bar: 42)
374
- * db.query_ary('select * from foo where x = :bar', 'bar' => 42)
375
- * db.query_ary('select * from foo where x = :bar', ':bar' => 42)
377
+ * db.query_array('select * from foo where x = :bar', bar: 42)
378
+ * db.query_array('select * from foo where x = :bar', 'bar' => 42)
379
+ * db.query_array('select * from foo where x = :bar', ':bar' => 42)
376
380
  *
377
- * @overload query_ary(sql, ...)
381
+ * @overload query_array(sql, ...)
378
382
  * @param sql [String] SQL statement
379
383
  * @return [Array<Array>, Integer] rows or total changes
380
- * @overload query_ary(transform, sql, ...)
384
+ * @overload query_array(transform, sql, ...)
381
385
  * @param transform [Proc] transform proc
382
386
  * @param sql [String] SQL statement
383
387
  * @return [Array<Array>, Integer] rows or total changes
384
388
  */
385
- VALUE Database_query_ary(int argc, VALUE *argv, VALUE self) {
386
- return Database_perform_query(argc, argv, self, safe_query_ary, QUERY_ARY);
389
+ VALUE Database_query_array(int argc, VALUE *argv, VALUE self) {
390
+ return Database_perform_query(argc, argv, self, safe_query_array, QUERY_ARRAY);
387
391
  }
388
392
 
389
393
  /* Runs a query returning a single row as a hash.
@@ -419,23 +423,23 @@ VALUE Database_query_single(int argc, VALUE *argv, VALUE self) {
419
423
  * parameters are given as an array, the query should specify parameters using
420
424
  * `?`:
421
425
  *
422
- * db.query_single_argv('select * from foo where x = ?', 42)
426
+ * db.query_single_splat('select * from foo where x = ?', 42)
423
427
  *
424
428
  * Named placeholders are specified using `:`. The placeholder values are
425
429
  * specified using keyword arguments:
426
430
  *
427
- * db.query_single_argv('select * from foo where x = :bar', bar: 42)
431
+ * db.query_single_splat('select * from foo where x = :bar', bar: 42)
428
432
  *
429
- * @overload query_single_argv(sql, ...) -> row
433
+ * @overload query_single_splat(sql, ...) -> row
430
434
  * @param sql [String] SQL statement
431
435
  * @return [Array, any] row
432
- * @overload query_single_argv(transform, sql, ...) -> row
436
+ * @overload query_single_splat(transform, sql, ...) -> row
433
437
  * @param transform [Proc] transform proc
434
438
  * @param sql [String] SQL statement
435
439
  * @return [Array, any] row
436
440
  */
437
- VALUE Database_query_single_argv(int argc, VALUE *argv, VALUE self) {
438
- return Database_perform_query(argc, argv, self, safe_query_single_row_argv, QUERY_ARGV);
441
+ VALUE Database_query_single_splat(int argc, VALUE *argv, VALUE self) {
442
+ return Database_perform_query(argc, argv, self, safe_query_single_row_splat, QUERY_SPLAT);
439
443
  }
440
444
 
441
445
  /* Runs a query returning a single row as an array.
@@ -445,23 +449,23 @@ VALUE Database_query_single_argv(int argc, VALUE *argv, VALUE self) {
445
449
  * parameters are given as an array, the query should specify parameters using
446
450
  * `?`:
447
451
  *
448
- * db.query_single_ary('select * from foo where x = ?', 42)
452
+ * db.query_single_array('select * from foo where x = ?', 42)
449
453
  *
450
454
  * Named placeholders are specified using `:`. The placeholder values are
451
455
  * specified using keyword arguments:
452
456
  *
453
- * db.query_single_ary('select * from foo where x = :bar', bar: 42)
457
+ * db.query_single_array('select * from foo where x = :bar', bar: 42)
454
458
  *
455
- * @overload query_single_ary(sql, ...) -> row
459
+ * @overload query_single_array(sql, ...) -> row
456
460
  * @param sql [String] SQL statement
457
461
  * @return [Array, any] row
458
- * @overload query_single_ary(transform, sql, ...) -> row
462
+ * @overload query_single_array(transform, sql, ...) -> row
459
463
  * @param transform [Proc] transform proc
460
464
  * @param sql [String] SQL statement
461
465
  * @return [Array, any] row
462
466
  */
463
- VALUE Database_query_single_ary(int argc, VALUE *argv, VALUE self) {
464
- return Database_perform_query(argc, argv, self, safe_query_single_row_ary, QUERY_ARY);
467
+ VALUE Database_query_single_array(int argc, VALUE *argv, VALUE self) {
468
+ return Database_perform_query(argc, argv, self, safe_query_single_row_array, QUERY_ARRAY);
465
469
  }
466
470
 
467
471
  /* call-seq:
@@ -532,6 +536,8 @@ VALUE Database_batch_execute(VALUE self, VALUE sql, VALUE parameters) {
532
536
  /* call-seq:
533
537
  * db.batch_query(sql, params_source) -> rows
534
538
  * db.batch_query(sql, params_source) { |rows| ... } -> changes
539
+ * db.batch_query_hash(sql, params_source) -> rows
540
+ * db.batch_query_hash(sql, params_source) { |rows| ... } -> changes
535
541
  *
536
542
  * Executes the given query for each list of parameters in the given paramter
537
543
  * source. If a block is given, it is called with the resulting rows for each
@@ -564,8 +570,8 @@ VALUE Database_batch_query(VALUE self, VALUE sql, VALUE parameters) {
564
570
  }
565
571
 
566
572
  /* call-seq:
567
- * db.batch_query_ary(sql, params_source) -> rows
568
- * db.batch_query_ary(sql, params_source) { |rows| ... } -> changes
573
+ * db.batch_query_array(sql, params_source) -> rows
574
+ * db.batch_query_array(sql, params_source) { |rows| ... } -> changes
569
575
  *
570
576
  * Executes the given query for each list of parameters in the given paramter
571
577
  * source. If a block is given, it is called with the resulting rows for each
@@ -577,29 +583,29 @@ VALUE Database_batch_query(VALUE self, VALUE sql, VALUE parameters) {
577
583
  * [1, 2],
578
584
  * [3, 4]
579
585
  * ]
580
- * db.batch_query_ary('insert into foo values (?, ?) returning bar, baz', records)
586
+ * db.batch_query_array('insert into foo values (?, ?) returning bar, baz', records)
581
587
  * #=> [[1, 2], [3, 4]]
582
588
  * *
583
589
  * @param sql [String] query SQL
584
590
  * @param parameters [Array<Array, Hash>, Enumerable, Enumerator, Callable] parameters to run query with
585
591
  * @return [Array<Array>, Integer] Total number of changes effected
586
592
  */
587
- VALUE Database_batch_query_ary(VALUE self, VALUE sql, VALUE parameters) {
593
+ VALUE Database_batch_query_array(VALUE self, VALUE sql, VALUE parameters) {
588
594
  Database_t *db = self_to_open_database(self);
589
595
  sqlite3_stmt *stmt;
590
596
 
591
597
  prepare_single_stmt(DB_GVL_MODE(db), db->sqlite3_db, &stmt, sql);
592
598
  query_ctx ctx = QUERY_CTX(
593
599
  self, sql, db, stmt, parameters,
594
- Qnil, QUERY_ARY, ROW_MULTI, ALL_ROWS
600
+ Qnil, QUERY_ARRAY, ROW_MULTI, ALL_ROWS
595
601
  );
596
602
 
597
- return rb_ensure(SAFE(safe_batch_query_ary), (VALUE)&ctx, SAFE(cleanup_stmt), (VALUE)&ctx);
603
+ return rb_ensure(SAFE(safe_batch_query_array), (VALUE)&ctx, SAFE(cleanup_stmt), (VALUE)&ctx);
598
604
  }
599
605
 
600
606
  /* call-seq:
601
- * db.batch_query_argv(sql, params_source) -> rows
602
- * db.batch_query_argv(sql, params_source) { |rows| ... } -> changes
607
+ * db.batch_query_splat(sql, params_source) -> rows
608
+ * db.batch_query_splat(sql, params_source) { |rows| ... } -> changes
603
609
  *
604
610
  * Executes the given query for each list of parameters in the given paramter
605
611
  * source. If a block is given, it is called with the resulting rows for each
@@ -611,24 +617,24 @@ VALUE Database_batch_query_ary(VALUE self, VALUE sql, VALUE parameters) {
611
617
  * [1, 2],
612
618
  * [3, 4]
613
619
  * ]
614
- * db.batch_query_argv('insert into foo values (?, ?) returning baz', records)
620
+ * db.batch_query_splat('insert into foo values (?, ?) returning baz', records)
615
621
  * #=> [2, 4]
616
622
  * *
617
623
  * @param sql [String] query SQL
618
624
  * @param parameters [Array<Array, Hash>, Enumerable, Enumerator, Callable] parameters to run query with
619
625
  * @return [Array<any>, Integer] Total number of changes effected
620
626
  */
621
- VALUE Database_batch_query_argv(VALUE self, VALUE sql, VALUE parameters) {
627
+ VALUE Database_batch_query_splat(VALUE self, VALUE sql, VALUE parameters) {
622
628
  Database_t *db = self_to_open_database(self);
623
629
  sqlite3_stmt *stmt;
624
630
 
625
631
  prepare_single_stmt(DB_GVL_MODE(db), db->sqlite3_db, &stmt, sql);
626
632
  query_ctx ctx = QUERY_CTX(
627
633
  self, sql, db, stmt, parameters,
628
- Qnil, QUERY_ARGV, ROW_MULTI, ALL_ROWS
634
+ Qnil, QUERY_SPLAT, ROW_MULTI, ALL_ROWS
629
635
  );
630
636
 
631
- return rb_ensure(SAFE(safe_batch_query_argv), (VALUE)&ctx, SAFE(cleanup_stmt), (VALUE)&ctx);
637
+ return rb_ensure(SAFE(safe_batch_query_splat), (VALUE)&ctx, SAFE(cleanup_stmt), (VALUE)&ctx);
632
638
  }
633
639
 
634
640
  /* Returns the column names for the given query, without running it.
@@ -738,9 +744,9 @@ VALUE Database_prepare_hash(int argc, VALUE *argv, VALUE self) {
738
744
  }
739
745
 
740
746
  /* call-seq:
741
- * db.prepare_argv(sql) -> Extralite::Query
742
- * db.prepare_argv(sql, *params) -> Extralite::Query
743
- * db.prepare_argv(sql, *params) { ... } -> Extralite::Query
747
+ * db.prepare_splat(sql) -> Extralite::Query
748
+ * db.prepare_splat(sql, *params) -> Extralite::Query
749
+ * db.prepare_splat(sql, *params) { ... } -> Extralite::Query
744
750
  *
745
751
  * Creates a prepared query with the given SQL query in argv mode. If query
746
752
  * parameters are given, they are bound to the query. If a block is given, it is
@@ -750,16 +756,16 @@ VALUE Database_prepare_hash(int argc, VALUE *argv, VALUE self) {
750
756
  * @param *params [Array<any>] parameters to bind
751
757
  * @return [Extralite::Query] prepared query
752
758
  */
753
- VALUE Database_prepare_argv(int argc, VALUE *argv, VALUE self) {
754
- return Database_prepare(argc, argv, self, SYM_argv);
759
+ VALUE Database_prepare_splat(int argc, VALUE *argv, VALUE self) {
760
+ return Database_prepare(argc, argv, self, SYM_splat);
755
761
  }
756
762
 
757
763
  /* call-seq:
758
- * db.prepare_ary(sql) -> Extralite::Query
759
- * db.prepare_ary(sql, *params) -> Extralite::Query
760
- * db.prepare_ary(sql, *params) { ... } -> Extralite::Query
764
+ * db.prepare_array(sql) -> Extralite::Query
765
+ * db.prepare_array(sql, *params) -> Extralite::Query
766
+ * db.prepare_array(sql, *params) { ... } -> Extralite::Query
761
767
  *
762
- * Creates a prepared query with the given SQL query in ary mode. If query
768
+ * Creates a prepared query with the given SQL query in array mode. If query
763
769
  * parameters are given, they are bound to the query. If a block is given, it is
764
770
  * used as a transform proc.
765
771
  *
@@ -767,8 +773,8 @@ VALUE Database_prepare_argv(int argc, VALUE *argv, VALUE self) {
767
773
  * @param *params [Array<any>] parameters to bind
768
774
  * @return [Extralite::Query] prepared query
769
775
  */
770
- VALUE Database_prepare_ary(int argc, VALUE *argv, VALUE self) {
771
- return Database_prepare(argc, argv, self, SYM_ary);
776
+ VALUE Database_prepare_array(int argc, VALUE *argv, VALUE self) {
777
+ return Database_prepare(argc, argv, self, SYM_array);
772
778
  }
773
779
 
774
780
  /* Interrupts a long running query. This method is to be called from a different
@@ -853,11 +859,7 @@ VALUE backup_cleanup(VALUE ptr) {
853
859
  return Qnil;
854
860
  }
855
861
 
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
862
+ /* Creates a backup of the database to the given destination, which can be
861
863
  * either a filename or a database instance. In order to monitor the backup
862
864
  * progress you can pass a block that will be called periodically by the backup
863
865
  * method with two arguments: the remaining page count, and the total page
@@ -871,6 +873,8 @@ VALUE backup_cleanup(VALUE ptr) {
871
873
  * @param dest [String, Extralite::Database] backup destination
872
874
  * @param src_db_name [String] source database name (default: "main")
873
875
  * @param dst_db_name [String] Destination database name (default: "main")
876
+ * @yieldparam remaining [Integer] remaining page count
877
+ * @yieldparam total [Integer] total page count
874
878
  * @return [Extralite::Database] source database
875
879
  */
876
880
  VALUE Database_backup(int argc, VALUE *argv, VALUE self) {
@@ -920,6 +924,13 @@ VALUE Database_backup(int argc, VALUE *argv, VALUE self) {
920
924
  /* Returns runtime status values for the given op as an array containing the
921
925
  * current value and the high water mark value. To reset the high water mark,
922
926
  * pass true as reset.
927
+ *
928
+ * You can use the various `Extralite::SQLITE_STATUS_xxx` constants with this
929
+ * method:
930
+ *
931
+ * Extralite.runtime_status(Extralite::SQLITE_STATUS_MEMORY_USED)
932
+ *
933
+ * For more information see the SQLite docs: https://sqlite.org/c3ref/c_status_malloc_count.html
923
934
  *
924
935
  * @overload runtime_status(op)
925
936
  * @param op [Integer] op
@@ -1404,6 +1415,53 @@ VALUE Database_gvl_release_threshold_set(VALUE self, VALUE value) {
1404
1415
  return INT2NUM(db->gvl_release_threshold);
1405
1416
  }
1406
1417
 
1418
+ int checkpoint_mode_symbol_to_int(VALUE mode) {
1419
+ if (mode == SYM_passive) return SQLITE_CHECKPOINT_PASSIVE;
1420
+ if (mode == SYM_full) return SQLITE_CHECKPOINT_FULL;
1421
+ if (mode == SYM_restart) return SQLITE_CHECKPOINT_RESTART;
1422
+ if (mode == SYM_truncate) return SQLITE_CHECKPOINT_TRUNCATE;
1423
+
1424
+ rb_raise(eArgumentError, "Invalid WAL checkpoint mode specified");
1425
+ }
1426
+
1427
+ /* Runs a WAL checkpoint operation with the given mode. If a database name is
1428
+ * given, the checkpoint operation is ran on the corresponding attached
1429
+ * database, otherwise it is run on the main database. Returns an array
1430
+ * containing the total number of frames in the WAL file, and the number of
1431
+ * frames checkpointed. For more information see:
1432
+ * https://sqlite.org/c3ref/wal_checkpoint_v2.html
1433
+ *
1434
+ * @overload wal_checkpoint(mode)
1435
+ * @param mode [Symbol] checkpoint mode (`:passive`, `:full`, `:restart`, `:truncate`)
1436
+ * @return [Array<int>] total and checkpointed frame count
1437
+ * @overload wal_checkpoint(mode, db_name)
1438
+ * @param mode [Symbol] checkpoint mode (`:passive`, `:full`, `:restart`, `:truncate`)
1439
+ * @param db_name [String] attached database name
1440
+ * @return [Array<int>] total and checkpointed frame count
1441
+ */
1442
+ VALUE Database_wal_checkpoint(int argc, VALUE *argv, VALUE self) {
1443
+ Database_t *db = self_to_open_database(self);
1444
+ VALUE mode = Qnil;
1445
+ VALUE db_name = Qnil;
1446
+ int total_frames;
1447
+ int checkpointed_frames;
1448
+
1449
+ rb_scan_args(argc, argv, "11", &mode, &db_name);
1450
+
1451
+ int mode_int = checkpoint_mode_symbol_to_int(mode);
1452
+ int rc = sqlite3_wal_checkpoint_v2(
1453
+ db->sqlite3_db,
1454
+ NIL_P(db_name) ? NULL : StringValueCStr(db_name),
1455
+ mode_int,
1456
+ &total_frames,
1457
+ &checkpointed_frames
1458
+ );
1459
+ if (rc != SQLITE_OK)
1460
+ rb_raise(cError, "Failed to perform WAL checkpoint: %s", sqlite3_errstr(rc));
1461
+
1462
+ return rb_ary_new3(2, INT2NUM(total_frames), INT2NUM(checkpointed_frames));
1463
+ }
1464
+
1407
1465
  void Init_ExtraliteDatabase(void) {
1408
1466
  VALUE mExtralite = rb_define_module("Extralite");
1409
1467
  rb_define_singleton_method(mExtralite, "runtime_status", Extralite_runtime_status, -1);
@@ -1416,8 +1474,8 @@ void Init_ExtraliteDatabase(void) {
1416
1474
  rb_define_method(cDatabase, "backup", Database_backup, -1);
1417
1475
  rb_define_method(cDatabase, "batch_execute", Database_batch_execute, 2);
1418
1476
  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);
1477
+ rb_define_method(cDatabase, "batch_query_array", Database_batch_query_array, 2);
1478
+ rb_define_method(cDatabase, "batch_query_splat", Database_batch_query_splat, 2);
1421
1479
  rb_define_method(cDatabase, "batch_query_hash", Database_batch_query, 2);
1422
1480
  rb_define_method(cDatabase, "busy_timeout=", Database_busy_timeout_set, 1);
1423
1481
  rb_define_method(cDatabase, "changes", Database_changes, 0);
@@ -1447,21 +1505,22 @@ void Init_ExtraliteDatabase(void) {
1447
1505
 
1448
1506
  rb_define_method(cDatabase, "on_progress", Database_on_progress, -1);
1449
1507
  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);
1508
+ rb_define_method(cDatabase, "prepare_splat", Database_prepare_splat, -1);
1509
+ rb_define_method(cDatabase, "prepare_array", Database_prepare_array, -1);
1452
1510
  rb_define_method(cDatabase, "prepare_hash", Database_prepare_hash, -1);
1453
1511
  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);
1512
+ rb_define_method(cDatabase, "query_splat", Database_query_splat, -1);
1513
+ rb_define_method(cDatabase, "query_array", Database_query_array, -1);
1456
1514
  rb_define_method(cDatabase, "query_hash", Database_query, -1);
1457
1515
  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);
1516
+ rb_define_method(cDatabase, "query_single_array", Database_query_single_array, -1);
1517
+ rb_define_method(cDatabase, "query_single_splat", Database_query_single_splat, -1);
1460
1518
  rb_define_method(cDatabase, "query_single_hash", Database_query_single, -1);
1461
1519
  rb_define_method(cDatabase, "read_only?", Database_read_only_p, 0);
1462
1520
  rb_define_method(cDatabase, "status", Database_status, -1);
1463
1521
  rb_define_method(cDatabase, "total_changes", Database_total_changes, 0);
1464
1522
  rb_define_method(cDatabase, "trace", Database_trace, 0);
1523
+ rb_define_method(cDatabase, "wal_checkpoint", Database_wal_checkpoint, -1);
1465
1524
 
1466
1525
  #ifdef EXTRALITE_ENABLE_CHANGESET
1467
1526
  rb_define_method(cDatabase, "track_changes", Database_track_changes, -1);
@@ -1488,21 +1547,29 @@ void Init_ExtraliteDatabase(void) {
1488
1547
  ID_track = rb_intern("track");
1489
1548
 
1490
1549
  SYM_at_least_once = ID2SYM(rb_intern("at_least_once"));
1550
+ SYM_full = ID2SYM(rb_intern("full"));
1491
1551
  SYM_gvl_release_threshold = ID2SYM(rb_intern("gvl_release_threshold"));
1492
1552
  SYM_once = ID2SYM(rb_intern("once"));
1493
1553
  SYM_none = ID2SYM(rb_intern("none"));
1494
1554
  SYM_normal = ID2SYM(rb_intern("normal"));
1555
+ SYM_passive = ID2SYM(rb_intern("passive"));
1495
1556
  SYM_pragma = ID2SYM(rb_intern("pragma"));
1496
1557
  SYM_read_only = ID2SYM(rb_intern("read_only"));
1558
+ SYM_restart = ID2SYM(rb_intern("restart"));
1559
+ SYM_truncate = ID2SYM(rb_intern("truncate"));
1497
1560
  SYM_wal = ID2SYM(rb_intern("wal"));
1498
1561
 
1499
1562
  rb_gc_register_mark_object(SYM_at_least_once);
1563
+ rb_gc_register_mark_object(SYM_full);
1500
1564
  rb_gc_register_mark_object(SYM_gvl_release_threshold);
1501
1565
  rb_gc_register_mark_object(SYM_once);
1502
1566
  rb_gc_register_mark_object(SYM_none);
1503
1567
  rb_gc_register_mark_object(SYM_normal);
1568
+ rb_gc_register_mark_object(SYM_passive);
1504
1569
  rb_gc_register_mark_object(SYM_pragma);
1505
1570
  rb_gc_register_mark_object(SYM_read_only);
1571
+ rb_gc_register_mark_object(SYM_restart);
1572
+ rb_gc_register_mark_object(SYM_truncate);
1506
1573
  rb_gc_register_mark_object(SYM_wal);
1507
1574
 
1508
1575
  rb_gc_register_mark_object(global_progress_handler.proc);
@@ -42,8 +42,8 @@ extern ID ID_strip;
42
42
  extern ID ID_to_s;
43
43
  extern ID ID_track;
44
44
 
45
- extern VALUE SYM_argv;
46
- extern VALUE SYM_ary;
45
+ extern VALUE SYM_splat;
46
+ extern VALUE SYM_array;
47
47
  extern VALUE SYM_hash;
48
48
 
49
49
  enum progress_handler_mode {
@@ -71,8 +71,8 @@ typedef struct {
71
71
 
72
72
  enum query_mode {
73
73
  QUERY_HASH,
74
- QUERY_ARGV,
75
- QUERY_ARY
74
+ QUERY_SPLAT,
75
+ QUERY_ARRAY
76
76
  };
77
77
 
78
78
  typedef struct {
@@ -87,13 +87,6 @@ typedef struct {
87
87
  enum query_mode query_mode;
88
88
  } Query_t;
89
89
 
90
- enum iterator_mode {
91
- ITERATOR_HASH,
92
- ITERATOR_ARGV,
93
- ITERATOR_ARY,
94
- ITERATOR_SINGLE_COLUMN
95
- };
96
-
97
90
  typedef struct {
98
91
  VALUE query;
99
92
  } Iterator_t;
@@ -165,16 +158,16 @@ typedef VALUE (*safe_query_impl)(query_ctx *);
165
158
 
166
159
  VALUE safe_batch_execute(query_ctx *ctx);
167
160
  VALUE safe_batch_query(query_ctx *ctx);
168
- VALUE safe_batch_query_argv(query_ctx *ctx);
169
- VALUE safe_batch_query_ary(query_ctx *ctx);
170
- VALUE safe_query_argv(query_ctx *ctx);
171
- VALUE safe_query_ary(query_ctx *ctx);
161
+ VALUE safe_batch_query_splat(query_ctx *ctx);
162
+ VALUE safe_batch_query_array(query_ctx *ctx);
163
+ VALUE safe_query_splat(query_ctx *ctx);
164
+ VALUE safe_query_array(query_ctx *ctx);
172
165
  VALUE safe_query_changes(query_ctx *ctx);
173
166
  VALUE safe_query_columns(query_ctx *ctx);
174
167
  VALUE safe_query_hash(query_ctx *ctx);
175
168
  VALUE safe_query_single_row_hash(query_ctx *ctx);
176
- VALUE safe_query_single_row_argv(query_ctx *ctx);
177
- VALUE safe_query_single_row_ary(query_ctx *ctx);
169
+ VALUE safe_query_single_row_splat(query_ctx *ctx);
170
+ VALUE safe_query_single_row_array(query_ctx *ctx);
178
171
 
179
172
  VALUE Query_each(VALUE self);
180
173
  VALUE Query_next(int argc, VALUE *argv, VALUE self);
@@ -15,8 +15,8 @@ ID ID_inspect;
15
15
  ID ID_slice;
16
16
 
17
17
  VALUE SYM_hash;
18
- VALUE SYM_argv;
19
- VALUE SYM_ary;
18
+ VALUE SYM_splat;
19
+ VALUE SYM_array;
20
20
 
21
21
  #define DB_GVL_MODE(query) Database_prepare_gvl_mode(query->db_struct)
22
22
 
@@ -68,8 +68,8 @@ static inline Query_t *self_to_query(VALUE obj) {
68
68
 
69
69
  static inline enum query_mode symbol_to_query_mode(VALUE sym) {
70
70
  if (sym == SYM_hash) return QUERY_HASH;
71
- if (sym == SYM_argv) return QUERY_ARGV;
72
- if (sym == SYM_ary) return QUERY_ARY;
71
+ if (sym == SYM_splat) return QUERY_SPLAT;
72
+ if (sym == SYM_array) return QUERY_ARRAY;
73
73
 
74
74
  rb_raise(cError, "Invalid query mode");
75
75
  }
@@ -78,10 +78,10 @@ static inline VALUE query_mode_to_symbol(enum query_mode query_mode) {
78
78
  switch (query_mode) {
79
79
  case QUERY_HASH:
80
80
  return SYM_hash;
81
- case QUERY_ARGV:
82
- return SYM_argv;
83
- case QUERY_ARY:
84
- return SYM_ary;
81
+ case QUERY_SPLAT:
82
+ return SYM_splat;
83
+ case QUERY_ARRAY:
84
+ return SYM_array;
85
85
  default:
86
86
  rb_raise(cError, "Invalid mode");
87
87
  }
@@ -232,10 +232,10 @@ inline safe_query_impl query_impl(enum query_mode query_mode) {
232
232
  switch (query_mode) {
233
233
  case QUERY_HASH:
234
234
  return safe_query_hash;
235
- case QUERY_ARGV:
236
- return safe_query_argv;
237
- case QUERY_ARY:
238
- return safe_query_ary;
235
+ case QUERY_SPLAT:
236
+ return safe_query_splat;
237
+ case QUERY_ARRAY:
238
+ return safe_query_array;
239
239
  default:
240
240
  rb_raise(cError, "Invalid query mode (query_impl)");
241
241
  }
@@ -596,7 +596,7 @@ VALUE Query_mode_get(VALUE self) {
596
596
  /* call-seq:
597
597
  * query.mode = mode
598
598
  *
599
- * Sets the query mode. This can be one of `:hash`, `:argv`, `:ary`.
599
+ * Sets the query mode. This can be one of `:hash`, `:splat`, `:array`.
600
600
  *
601
601
  * @param mode [Symbol] query mode
602
602
  * @return [Symbol] query mode
@@ -642,10 +642,10 @@ void Init_ExtraliteQuery(void) {
642
642
  ID_slice = rb_intern("slice");
643
643
 
644
644
  SYM_hash = ID2SYM(rb_intern("hash"));
645
- SYM_argv = ID2SYM(rb_intern("argv"));
646
- SYM_ary = ID2SYM(rb_intern("ary"));
645
+ SYM_splat = ID2SYM(rb_intern("splat"));
646
+ SYM_array = ID2SYM(rb_intern("array"));
647
647
 
648
648
  rb_gc_register_mark_object(SYM_hash);
649
- rb_gc_register_mark_object(SYM_argv);
650
- rb_gc_register_mark_object(SYM_ary);
649
+ rb_gc_register_mark_object(SYM_splat);
650
+ rb_gc_register_mark_object(SYM_array);
651
651
  }
data/gemspec.rb CHANGED
@@ -18,7 +18,7 @@ def common_spec(s)
18
18
  s.required_ruby_version = '>= 3.0'
19
19
 
20
20
  s.add_development_dependency 'rake-compiler', '1.2.7'
21
- s.add_development_dependency 'minitest', '5.21.2'
21
+ s.add_development_dependency 'minitest', '5.22.2'
22
22
  s.add_development_dependency 'simplecov', '0.17.1'
23
23
  s.add_development_dependency 'yard', '0.9.34'
24
24
  s.add_development_dependency 'sequel', '5.77.0'
@@ -1,4 +1,4 @@
1
1
  module Extralite
2
2
  # Extralite version
3
- VERSION = '2.7.1'
3
+ VERSION = '2.8'
4
4
  end