rubydb 0.1.4 → 0.1.6
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/PULL_REQUEST_TEMPLATE.md +15 -15
- data/.github/workflows/benchmark.yml +26 -26
- data/.github/workflows/compatibility.yml +63 -63
- data/.github/workflows/fuzz.yml +33 -33
- data/.github/workflows/lint.yml +21 -21
- data/.github/workflows/operations.yml +24 -24
- data/.github/workflows/production-validation.yml +111 -111
- data/.github/workflows/release.yml +77 -77
- data/.github/workflows/security.yml +39 -37
- data/.github/workflows/test.yml +26 -26
- data/.github/workflows/workload.yml +58 -58
- data/.gitignore +16 -5
- data/.rubocop.yml +50 -44
- data/.standard.yml +9 -14
- data/ARCHITECTURE.md +21 -21
- data/CHANGELOG.md +57 -27
- data/CODE_OF_CONDUCT.md +13 -13
- data/CONTRIBUTING.md +29 -29
- data/GOVERNANCE.md +16 -16
- data/Gemfile +18 -17
- data/Gemfile.lock +125 -71
- data/README.md +168 -12
- data/ROADMAP.md +27 -27
- data/Rakefile +76 -71
- data/SECURITY.md +54 -54
- data/SUPPORT.md +14 -14
- data/accelerator/bin/SHA256SUMS +6 -0
- data/accelerator/bin/rubydb-accelerator-darwin-amd64 +0 -0
- data/accelerator/bin/rubydb-accelerator-darwin-arm64 +0 -0
- data/accelerator/bin/rubydb-accelerator-linux-amd64 +0 -0
- data/accelerator/bin/rubydb-accelerator-linux-arm64 +0 -0
- data/accelerator/bin/rubydb-accelerator-windows-amd64.exe +0 -0
- data/accelerator/bin/rubydb-accelerator-windows-arm64.exe +0 -0
- data/accelerator/cmd/rubydb-accelerator/main.go +11 -0
- data/accelerator/go.mod +3 -0
- data/accelerator/internal/execution/aggregate.go +94 -0
- data/accelerator/internal/execution/distinct.go +22 -0
- data/accelerator/internal/execution/filter.go +73 -0
- data/accelerator/internal/execution/join.go +79 -0
- data/accelerator/internal/execution/operators.go +167 -0
- data/accelerator/internal/execution/scan.go +20 -0
- data/accelerator/internal/execution/sort.go +62 -0
- data/accelerator/internal/execution/types.go +136 -0
- data/accelerator/internal/execution/value.go +67 -0
- data/accelerator/internal/memory/arena.go +47 -0
- data/accelerator/internal/memory/reuse.go +22 -0
- data/accelerator/internal/metrics/registry.go +67 -0
- data/accelerator/internal/parallel/bounded_queue.go +56 -0
- data/accelerator/internal/parallel/scheduler.go +47 -0
- data/accelerator/internal/parallel/worker_pool.go +53 -0
- data/accelerator/internal/protocol/cancellation.go +48 -0
- data/accelerator/internal/protocol/columnar.go +263 -0
- data/accelerator/internal/protocol/frame.go +187 -0
- data/accelerator/internal/runtime/worker.go +521 -0
- data/accelerator/internal/storage/page_reader.go +81 -0
- data/accelerator/internal/storage/snapshot_scan.go +539 -0
- data/accelerator/internal/wal/checksum.go +13 -0
- data/accelerator/internal/wal/compression.go +41 -0
- data/accelerator/internal/wal/group_commit.go +24 -0
- data/accelerator/internal/wal/record_encoder.go +40 -0
- data/adapters/activerecord/Gemfile +11 -11
- data/adapters/activerecord/README.md +8 -3
- data/adapters/activerecord/lib/active_record/connection_adapters/rubydb_adapter.rb +881 -879
- data/adapters/activerecord/rubydb-activerecord.gemspec +21 -21
- data/adapters/activerecord/spec/rubydb_adapter_integration_spec.rb +143 -143
- data/adapters/ruby/README.md +18 -18
- data/adapters/sequel/README.md +11 -11
- data/config/monitoring/prometheus-alerts.yml +39 -39
- data/config/production.yml +36 -36
- data/docs/README.md +77 -71
- data/docs/architecture/concurrency.md +14 -14
- data/docs/architecture/current-state.md +125 -125
- data/docs/architecture/execution-engine.md +25 -25
- data/docs/architecture/go-accelerator.md +179 -0
- data/docs/architecture/indexes.md +19 -19
- data/docs/architecture/mvcc.md +19 -19
- data/docs/architecture/overview.md +13 -13
- data/docs/architecture/pages.md +11 -11
- data/docs/architecture/production-roadmap.md +82 -82
- data/docs/architecture/query-planner.md +20 -20
- data/docs/architecture/recovery.md +18 -18
- data/docs/architecture/sql-engine.md +12 -12
- data/docs/architecture/storage-engine.md +14 -14
- data/docs/architecture/transactions.md +10 -10
- data/docs/architecture/wal.md +28 -28
- data/docs/cli-cheatsheet.md +98 -98
- data/docs/cli.md +299 -275
- data/docs/contributing/architecture.md +9 -9
- data/docs/contributing/benchmarking.md +30 -14
- data/docs/contributing/development.md +16 -16
- data/docs/contributing/release-process.md +49 -49
- data/docs/contributing/testing.md +16 -16
- data/docs/debugging.md +229 -229
- data/docs/developer/branching.md +10 -10
- data/docs/developer/database-diff.md +10 -10
- data/docs/developer/local-development.md +49 -17
- data/docs/developer/snapshots.md +9 -9
- data/docs/developer/temporal-data.md +10 -10
- data/docs/developer-guide.md +297 -297
- data/docs/getting-started/first-database.md +16 -16
- data/docs/getting-started/first-query.md +13 -13
- data/docs/getting-started/installation.md +19 -19
- data/docs/getting-started/local-to-production.md +300 -300
- data/docs/getting-started/quickstart.md +17 -17
- data/docs/getting-started/rails.md +16 -16
- data/docs/hardening_backlog.md +93 -93
- data/docs/lessons-learned.md +112 -112
- data/docs/operations/backups.md +33 -33
- data/docs/operations/disaster-recovery.md +31 -31
- data/docs/operations/failover.md +30 -30
- data/docs/operations/monitoring.md +25 -25
- data/docs/operations/production-guide.md +295 -295
- data/docs/operations/production-runbook.md +45 -45
- data/docs/operations/replication.md +33 -33
- data/docs/operations/restore.md +6 -6
- data/docs/operations/runbook.md +34 -34
- data/docs/operations/upgrades.md +14 -14
- data/docs/operations/workload-testing.md +17 -17
- data/docs/production-readiness.md +118 -118
- data/docs/production_validation.md +150 -150
- data/docs/rails/active-record.md +11 -11
- data/docs/rails/compatibility-guide.md +90 -90
- data/docs/rails/database-yml.md +92 -92
- data/docs/rails/installation.md +17 -17
- data/docs/rails/migrations.md +17 -17
- data/docs/rails/production.md +82 -82
- data/docs/rails/troubleshooting.md +18 -18
- data/docs/release.md +25 -25
- data/docs/server/architecture.md +10 -10
- data/docs/server/authentication.md +10 -10
- data/docs/server/configuration.md +16 -16
- data/docs/server/connection-pooling.md +10 -10
- data/docs/server/deployment.md +10 -10
- data/docs/server/protocol.md +12 -12
- data/docs/sql/compatibility-guide.md +82 -82
- data/docs/sql/compatibility.md +39 -39
- data/docs/sql/data-types.md +10 -10
- data/docs/sql/functions.md +9 -9
- data/docs/sql/joins.md +9 -9
- data/docs/sql/operators.md +9 -9
- data/docs/sql/sqlite-compatibility.md +21 -21
- data/docs/sql/syntax.md +10 -10
- data/docs/sql/transactions.md +10 -10
- data/docs/troubleshooting.md +244 -244
- data/lessons/01-foundations.md +73 -0
- data/lessons/02-local-development.md +121 -0
- data/lessons/03-embedded-rubydb.md +99 -0
- data/lessons/04-rails-complex-apps.md +138 -0
- data/lessons/05-rubydb-production-server.md +237 -0
- data/lessons/06-postgresql-massive-apps.md +96 -0
- data/lessons/07-hybrid-microservices.md +179 -0
- data/lessons/08-migrations-backups-recovery.md +86 -0
- data/lessons/09-observability-security-scale.md +87 -0
- data/lessons/10-release-readiness.md +192 -0
- data/lessons/11-community-adapter.md +323 -0
- data/lessons/12-rails-ecommerce-pressure.md +263 -0
- data/lib/rubydb/accelerator/client.rb +451 -0
- data/lib/rubydb/accelerator/error.rb +22 -0
- data/lib/rubydb/accelerator/manager.rb +606 -0
- data/lib/rubydb/accelerator.rb +13 -0
- data/lib/rubydb/backup/archive.rb +332 -334
- data/lib/rubydb/backup/backup.rb +400 -401
- data/lib/rubydb/backup/incremental.rb +349 -353
- data/lib/rubydb/backup/restore.rb +289 -290
- data/lib/rubydb/backup/snapshot.rb +265 -267
- data/lib/rubydb/backup/verification.rb +276 -279
- data/lib/rubydb/branching/branch.rb +181 -181
- data/lib/rubydb/branching/branch_manager.rb +307 -311
- data/lib/rubydb/branching/branch_metadata.rb +140 -140
- data/lib/rubydb/branching/checkout.rb +165 -166
- data/lib/rubydb/branching/copy_on_write.rb +272 -272
- data/lib/rubydb/branching/diff.rb +137 -138
- data/lib/rubydb/branching/merge.rb +282 -285
- data/lib/rubydb/build_info.rb +15 -15
- data/lib/rubydb/catalog/catalog.rb +391 -391
- data/lib/rubydb/catalog/column.rb +112 -112
- data/lib/rubydb/catalog/constraint.rb +180 -180
- data/lib/rubydb/catalog/database.rb +184 -184
- data/lib/rubydb/catalog/index.rb +97 -97
- data/lib/rubydb/catalog/schema.rb +103 -103
- data/lib/rubydb/catalog/sequence.rb +90 -90
- data/lib/rubydb/catalog/system_catalog.rb +698 -698
- data/lib/rubydb/catalog/table.rb +178 -178
- data/lib/rubydb/catalog/trigger.rb +102 -102
- data/lib/rubydb/catalog/view.rb +66 -66
- data/lib/rubydb/cli/application.rb +168 -163
- data/lib/rubydb/cli/commands/accelerator.rb +72 -0
- data/lib/rubydb/cli/commands/backup.rb +80 -81
- data/lib/rubydb/cli/commands/branch.rb +72 -72
- data/lib/rubydb/cli/commands/checkout.rb +54 -54
- data/lib/rubydb/cli/commands/create.rb +58 -58
- data/lib/rubydb/cli/commands/diff.rb +76 -77
- data/lib/rubydb/cli/commands/doctor.rb +77 -74
- data/lib/rubydb/cli/commands/drop.rb +57 -57
- data/lib/rubydb/cli/commands/init.rb +101 -102
- data/lib/rubydb/cli/commands/inspect.rb +95 -95
- data/lib/rubydb/cli/commands/merge.rb +63 -63
- data/lib/rubydb/cli/commands/migrate.rb +62 -62
- data/lib/rubydb/cli/commands/restart.rb +42 -39
- data/lib/rubydb/cli/commands/restore.rb +121 -121
- data/lib/rubydb/cli/commands/shell.rb +365 -365
- data/lib/rubydb/cli/commands/snapshot.rb +79 -79
- data/lib/rubydb/cli/commands/start.rb +88 -82
- data/lib/rubydb/cli/commands/status.rb +96 -92
- data/lib/rubydb/cli/commands/stop.rb +47 -47
- data/lib/rubydb/cli/commands/vacuum.rb +58 -58
- data/lib/rubydb/cli/formatter.rb +221 -221
- data/lib/rubydb/cli/output.rb +168 -168
- data/lib/rubydb/client/client.rb +309 -304
- data/lib/rubydb/client/connection.rb +429 -415
- data/lib/rubydb/client/connection_pool.rb +168 -168
- data/lib/rubydb/client/connection_url.rb +96 -96
- data/lib/rubydb/client/prepared_statement.rb +60 -60
- data/lib/rubydb/client/result.rb +127 -123
- data/lib/rubydb/client/statement.rb +52 -52
- data/lib/rubydb/client/transaction.rb +130 -130
- data/lib/rubydb/concurrency/concurrency.rb +19 -19
- data/lib/rubydb/concurrency/deadlock_detector.rb +148 -150
- data/lib/rubydb/concurrency/latch.rb +101 -101
- data/lib/rubydb/concurrency/lock_graph.rb +163 -165
- data/lib/rubydb/concurrency/mutex.rb +181 -183
- data/lib/rubydb/concurrency/rw_lock.rb +180 -180
- data/lib/rubydb/concurrency/scheduler.rb +248 -250
- data/lib/rubydb/concurrency/worker_pool.rb +145 -143
- data/lib/rubydb/configuration/config.rb +170 -170
- data/lib/rubydb/configuration/defaults.rb +191 -179
- data/lib/rubydb/configuration/environment.rb +152 -152
- data/lib/rubydb/configuration/parser.rb +185 -185
- data/lib/rubydb/configuration/validation.rb +228 -221
- data/lib/rubydb/constants.rb +74 -74
- data/lib/rubydb/constraints/check.rb +181 -181
- data/lib/rubydb/constraints/constraint.rb +101 -101
- data/lib/rubydb/constraints/foreign_key.rb +130 -130
- data/lib/rubydb/constraints/not_null.rb +64 -64
- data/lib/rubydb/constraints/primary_key.rb +99 -99
- data/lib/rubydb/constraints/unique.rb +106 -108
- data/lib/rubydb/constraints/validator.rb +349 -350
- data/lib/rubydb/errors/authentication_error.rb +10 -10
- data/lib/rubydb/errors/authorization_error.rb +23 -23
- data/lib/rubydb/errors/client_error.rb +10 -10
- data/lib/rubydb/errors/configuration_error.rb +10 -10
- data/lib/rubydb/errors/connection_error.rb +10 -10
- data/lib/rubydb/errors/constraint_error.rb +23 -23
- data/lib/rubydb/errors/corruption_error.rb +10 -10
- data/lib/rubydb/errors/database_error.rb +10 -10
- data/lib/rubydb/errors/error.rb +20 -20
- data/lib/rubydb/errors/execution_error.rb +10 -10
- data/lib/rubydb/errors/parser_error.rb +10 -10
- data/lib/rubydb/errors/recovery_error.rb +10 -10
- data/lib/rubydb/errors/replication_error.rb +10 -10
- data/lib/rubydb/errors/server_error.rb +6 -6
- data/lib/rubydb/errors/storage_error.rb +10 -10
- data/lib/rubydb/errors/transaction_error.rb +10 -10
- data/lib/rubydb/execution/accelerator_dispatch.rb +30 -0
- data/lib/rubydb/execution/aggregate_executor.rb +134 -138
- data/lib/rubydb/execution/cost_model.rb +72 -0
- data/lib/rubydb/execution/delete_executor.rb +110 -112
- data/lib/rubydb/execution/distinct_executor.rb +131 -135
- data/lib/rubydb/execution/executor.rb +1544 -1188
- data/lib/rubydb/execution/expression.rb +191 -193
- data/lib/rubydb/execution/index_scan.rb +142 -142
- data/lib/rubydb/execution/insert_executor.rb +215 -217
- data/lib/rubydb/execution/join_executor.rb +243 -249
- data/lib/rubydb/execution/limit_executor.rb +83 -85
- data/lib/rubydb/execution/operator_selection.rb +57 -0
- data/lib/rubydb/execution/optimizer.rb +227 -215
- data/lib/rubydb/execution/physical_plan.rb +47 -0
- data/lib/rubydb/execution/plan.rb +355 -353
- data/lib/rubydb/execution/planner.rb +508 -536
- data/lib/rubydb/execution/predicate.rb +235 -235
- data/lib/rubydb/execution/scan.rb +49 -49
- data/lib/rubydb/execution/sequential_scan.rb +63 -63
- data/lib/rubydb/execution/sort_executor.rb +194 -185
- data/lib/rubydb/execution/update_executor.rb +160 -162
- data/lib/rubydb/functions/aggregate.rb +70 -70
- data/lib/rubydb/functions/date_functions.rb +274 -278
- data/lib/rubydb/functions/function.rb +85 -85
- data/lib/rubydb/functions/json_functions.rb +231 -215
- data/lib/rubydb/functions/numeric_functions.rb +346 -346
- data/lib/rubydb/functions/scalar.rb +52 -52
- data/lib/rubydb/functions/string_functions.rb +383 -383
- data/lib/rubydb/functions/system_functions.rb +258 -246
- data/lib/rubydb/history/as_of.rb +238 -238
- data/lib/rubydb/history/change.rb +105 -105
- data/lib/rubydb/history/history.rb +131 -131
- data/lib/rubydb/history/history_manager.rb +228 -229
- data/lib/rubydb/history/temporal_query.rb +202 -202
- data/lib/rubydb/history/timeline.rb +144 -144
- data/lib/rubydb/indexes/btree.rb +215 -186
- data/lib/rubydb/indexes/btree_cursor.rb +258 -258
- data/lib/rubydb/indexes/btree_node.rb +384 -385
- data/lib/rubydb/indexes/hash_index.rb +150 -150
- data/lib/rubydb/indexes/index.rb +71 -71
- data/lib/rubydb/indexes/index_manager.rb +408 -406
- data/lib/rubydb/indexes/index_scan.rb +466 -470
- data/lib/rubydb/migrations/migration.rb +253 -254
- data/lib/rubydb/migrations/migration_lock.rb +146 -146
- data/lib/rubydb/migrations/migration_manager.rb +187 -176
- data/lib/rubydb/migrations/migration_version.rb +71 -71
- data/lib/rubydb/migrations/schema_diff.rb +211 -211
- data/lib/rubydb/migrations/schema_version.rb +64 -64
- data/lib/rubydb/monitoring/events.rb +155 -160
- data/lib/rubydb/monitoring/health.rb +216 -222
- data/lib/rubydb/monitoring/logger.rb +188 -193
- data/lib/rubydb/monitoring/metrics.rb +363 -359
- data/lib/rubydb/monitoring/performance.rb +176 -176
- data/lib/rubydb/monitoring/statistics.rb +168 -170
- data/lib/rubydb/mvcc/garbage_collector.rb +199 -199
- data/lib/rubydb/mvcc/mvcc.rb +16 -16
- data/lib/rubydb/mvcc/snapshot.rb +146 -147
- data/lib/rubydb/mvcc/vacuum.rb +180 -180
- data/lib/rubydb/mvcc/version.rb +106 -106
- data/lib/rubydb/mvcc/version_store.rb +396 -398
- data/lib/rubydb/mvcc/visibility.rb +107 -109
- data/lib/rubydb/protocol/capabilities.rb +125 -125
- data/lib/rubydb/protocol/decoder.rb +142 -145
- data/lib/rubydb/protocol/encoder.rb +131 -136
- data/lib/rubydb/protocol/handshake.rb +306 -305
- data/lib/rubydb/protocol/message.rb +121 -121
- data/lib/rubydb/protocol/parameter_binder.rb +101 -0
- data/lib/rubydb/protocol/protocol.rb +276 -277
- data/lib/rubydb/protocol/version.rb +54 -54
- data/lib/rubydb/rails/adapter.rb +245 -239
- data/lib/rubydb/rails/connection.rb +312 -314
- data/lib/rubydb/rails/database_statements.rb +122 -122
- data/lib/rubydb/rails/migration.rb +131 -131
- data/lib/rubydb/rails/quoting.rb +109 -109
- data/lib/rubydb/rails/result.rb +117 -117
- data/lib/rubydb/rails/schema_statements.rb +339 -339
- data/lib/rubydb/rails/transaction.rb +105 -105
- data/lib/rubydb/rails/type.rb +126 -126
- data/lib/rubydb/recovery/checkpoint.rb +261 -257
- data/lib/rubydb/recovery/consistency.rb +457 -467
- data/lib/rubydb/recovery/corruption_detector.rb +5 -5
- data/lib/rubydb/recovery/crash_recovery.rb +381 -387
- data/lib/rubydb/recovery/recovery_manager.rb +204 -206
- data/lib/rubydb/recovery/redo.rb +235 -237
- data/lib/rubydb/recovery/undo.rb +204 -206
- data/lib/rubydb/replication/failover.rb +5 -5
- data/lib/rubydb/replication/fencing.rb +63 -63
- data/lib/rubydb/replication/primary.rb +461 -450
- data/lib/rubydb/replication/replica.rb +382 -384
- data/lib/rubydb/replication/replication_log.rb +194 -200
- data/lib/rubydb/replication/replication_manager.rb +307 -308
- data/lib/rubydb/replication/replication_slot.rb +293 -295
- data/lib/rubydb/replication/replication_stream.rb +198 -201
- data/lib/rubydb/rubydb.rb +570 -560
- data/lib/rubydb/security/access_control.rb +252 -254
- data/lib/rubydb/security/audit_log.rb +209 -213
- data/lib/rubydb/security/authentication.rb +302 -302
- data/lib/rubydb/security/authorization.rb +282 -282
- data/lib/rubydb/security/credentials.rb +192 -196
- data/lib/rubydb/security/password.rb +205 -215
- data/lib/rubydb/security/permissions.rb +74 -74
- data/lib/rubydb/security/role.rb +99 -101
- data/lib/rubydb/security/user.rb +86 -86
- data/lib/rubydb/server/connection.rb +383 -366
- data/lib/rubydb/server/connection_pool.rb +193 -193
- data/lib/rubydb/server/lifecycle.rb +227 -228
- data/lib/rubydb/server/listener.rb +139 -136
- data/lib/rubydb/server/request_handler.rb +277 -276
- data/lib/rubydb/server/server.rb +363 -364
- data/lib/rubydb/server/session.rb +416 -369
- data/lib/rubydb/server/worker.rb +206 -210
- data/lib/rubydb/server/worker_pool.rb +168 -168
- data/lib/rubydb/sql/ast/alter_table.rb +169 -169
- data/lib/rubydb/sql/ast/begin_transaction.rb +47 -47
- data/lib/rubydb/sql/ast/commit.rb +37 -37
- data/lib/rubydb/sql/ast/constraint.rb +92 -83
- data/lib/rubydb/sql/ast/create_database.rb +41 -41
- data/lib/rubydb/sql/ast/create_index.rb +61 -61
- data/lib/rubydb/sql/ast/create_schema.rb +52 -52
- data/lib/rubydb/sql/ast/create_table.rb +187 -187
- data/lib/rubydb/sql/ast/delete.rb +54 -54
- data/lib/rubydb/sql/ast/drop_database.rb +41 -41
- data/lib/rubydb/sql/ast/drop_index.rb +41 -41
- data/lib/rubydb/sql/ast/drop_schema.rb +49 -49
- data/lib/rubydb/sql/ast/drop_table.rb +49 -49
- data/lib/rubydb/sql/ast/explain.rb +64 -64
- data/lib/rubydb/sql/ast/expression.rb +617 -604
- data/lib/rubydb/sql/ast/insert.rb +66 -66
- data/lib/rubydb/sql/ast/node.rb +42 -42
- data/lib/rubydb/sql/ast/rollback.rb +63 -63
- data/lib/rubydb/sql/ast/savepoint.rb +59 -59
- data/lib/rubydb/sql/ast/select.rb +88 -88
- data/lib/rubydb/sql/ast/set_operation.rb +22 -20
- data/lib/rubydb/sql/ast/trigger.rb +35 -29
- data/lib/rubydb/sql/ast/update.rb +88 -88
- data/lib/rubydb/sql/ast/vacuum.rb +19 -19
- data/lib/rubydb/sql/ast/view.rb +38 -32
- data/lib/rubydb/sql/ast/with.rb +32 -32
- data/lib/rubydb/sql/grammar.rb +86 -86
- data/lib/rubydb/sql/keywords.rb +156 -156
- data/lib/rubydb/sql/lexer.rb +209 -214
- data/lib/rubydb/sql/operators.rb +100 -100
- data/lib/rubydb/sql/parser.rb +1167 -1170
- data/lib/rubydb/sql/planner/analyzer.rb +283 -302
- data/lib/rubydb/sql/planner/binder.rb +537 -550
- data/lib/rubydb/sql/planner/type_checker.rb +427 -431
- data/lib/rubydb/sql/token.rb +210 -210
- data/lib/rubydb/storage/buffer_frame.rb +44 -44
- data/lib/rubydb/storage/buffer_pool.rb +155 -155
- data/lib/rubydb/storage/database_lock.rb +74 -74
- data/lib/rubydb/storage/deserializer.rb +332 -342
- data/lib/rubydb/storage/engine.rb +2409 -2330
- data/lib/rubydb/storage/file_manager.rb +191 -187
- data/lib/rubydb/storage/free_space_map.rb +79 -81
- data/lib/rubydb/storage/page.rb +92 -94
- data/lib/rubydb/storage/page_allocator.rb +852 -855
- data/lib/rubydb/storage/page_header.rb +63 -67
- data/lib/rubydb/storage/page_manager.rb +127 -131
- data/lib/rubydb/storage/record.rb +58 -58
- data/lib/rubydb/storage/row.rb +78 -78
- data/lib/rubydb/storage/serializer.rb +51 -51
- data/lib/rubydb/storage/snapshot_reader.rb +167 -0
- data/lib/rubydb/storage/storage_layout.rb +151 -151
- data/lib/rubydb/storage/storage_manager.rb +114 -114
- data/lib/rubydb/storage/tuple.rb +458 -461
- data/lib/rubydb/storage/visibility_map.rb +964 -973
- data/lib/rubydb/transactions/commit_manager.rb +219 -220
- data/lib/rubydb/transactions/isolation.rb +98 -98
- data/lib/rubydb/transactions/lock.rb +76 -76
- data/lib/rubydb/transactions/lock_manager.rb +359 -362
- data/lib/rubydb/transactions/savepoint.rb +142 -143
- data/lib/rubydb/transactions/transaction.rb +214 -215
- data/lib/rubydb/transactions/transaction_id.rb +84 -84
- data/lib/rubydb/transactions/transaction_log.rb +256 -257
- data/lib/rubydb/transactions/transaction_manager.rb +434 -435
- data/lib/rubydb/types/bigint.rb +36 -36
- data/lib/rubydb/types/blob.rb +37 -37
- data/lib/rubydb/types/boolean.rb +34 -34
- data/lib/rubydb/types/date.rb +39 -39
- data/lib/rubydb/types/decimal.rb +48 -48
- data/lib/rubydb/types/float.rb +34 -34
- data/lib/rubydb/types/integer.rb +36 -36
- data/lib/rubydb/types/json.rb +41 -41
- data/lib/rubydb/types/null.rb +34 -34
- data/lib/rubydb/types/smallint.rb +36 -36
- data/lib/rubydb/types/text.rb +37 -37
- data/lib/rubydb/types/time.rb +46 -46
- data/lib/rubydb/types/timestamp.rb +39 -39
- data/lib/rubydb/types/type.rb +119 -119
- data/lib/rubydb/types/uuid.rb +47 -47
- data/lib/rubydb/types/varchar.rb +37 -37
- data/lib/rubydb/version.rb +32 -32
- data/lib/rubydb/wal/archive.rb +207 -193
- data/lib/rubydb/wal/checkpoint.rb +181 -183
- data/lib/rubydb/wal/lsn.rb +94 -94
- data/lib/rubydb/wal/reader.rb +259 -260
- data/lib/rubydb/wal/record.rb +105 -105
- data/lib/rubydb/wal/segment.rb +193 -193
- data/lib/rubydb/wal/wal.rb +481 -452
- data/lib/rubydb/wal/writer.rb +236 -236
- data/lib/rubydb.rb +7 -7
- data/packaging/docker/docker-compose.failover.yml +43 -43
- data/packaging/homebrew/rubydb.rb +19 -19
- data/rubydb.gemspec +70 -57
- data/scripts/benchmark +7 -7
- data/scripts/build_accelerator +49 -0
- data/scripts/durability_drill +37 -37
- data/scripts/fuzz +63 -63
- data/scripts/release +77 -42
- data/scripts/release_check +43 -43
- data/scripts/replication_failover_drill +268 -250
- data/scripts/replication_network_failover_drill +287 -255
- data/scripts/restore_drill +45 -45
- data/scripts/security +45 -0
- metadata +102 -1
data/lib/rubydb/rubydb.rb
CHANGED
|
@@ -1,560 +1,570 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# RubyDB - A developer-first relational database for Ruby and Rails
|
|
4
|
-
#
|
|
5
|
-
# This is the main entry point for the RubyDB library.
|
|
6
|
-
# It provides the core database functionality and loads all required components.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
require_relative "
|
|
13
|
-
require_relative "
|
|
14
|
-
require_relative "
|
|
15
|
-
require_relative "
|
|
16
|
-
|
|
17
|
-
require_relative "errors/
|
|
18
|
-
require_relative "errors/
|
|
19
|
-
require_relative "errors/
|
|
20
|
-
require_relative "errors/
|
|
21
|
-
|
|
22
|
-
require_relative "
|
|
23
|
-
require_relative "
|
|
24
|
-
require_relative "
|
|
25
|
-
require_relative "
|
|
26
|
-
|
|
27
|
-
require_relative "storage/
|
|
28
|
-
require_relative "storage/
|
|
29
|
-
require_relative "storage/
|
|
30
|
-
require_relative "storage/
|
|
31
|
-
require_relative "storage/
|
|
32
|
-
require_relative "storage/
|
|
33
|
-
require_relative "storage/
|
|
34
|
-
require_relative "storage/
|
|
35
|
-
require_relative "storage/
|
|
36
|
-
require_relative "storage/
|
|
37
|
-
require_relative "storage/
|
|
38
|
-
require_relative "storage/
|
|
39
|
-
require_relative "storage/
|
|
40
|
-
|
|
41
|
-
require_relative "
|
|
42
|
-
require_relative "
|
|
43
|
-
require_relative "
|
|
44
|
-
require_relative "
|
|
45
|
-
|
|
46
|
-
require_relative "sql/
|
|
47
|
-
require_relative "sql/
|
|
48
|
-
require_relative "sql/
|
|
49
|
-
require_relative "sql/
|
|
50
|
-
require_relative "sql/
|
|
51
|
-
require_relative "sql/ast/
|
|
52
|
-
require_relative "sql/ast/
|
|
53
|
-
require_relative "sql/ast/
|
|
54
|
-
require_relative "sql/ast/
|
|
55
|
-
require_relative "sql/ast/
|
|
56
|
-
require_relative "sql/ast/
|
|
57
|
-
require_relative "sql/ast/
|
|
58
|
-
require_relative "sql/ast/
|
|
59
|
-
require_relative "sql/ast/
|
|
60
|
-
require_relative "sql/ast/
|
|
61
|
-
require_relative "sql/ast/
|
|
62
|
-
require_relative "sql/ast/
|
|
63
|
-
require_relative "sql/ast/
|
|
64
|
-
require_relative "sql/ast/
|
|
65
|
-
require_relative "sql/ast/
|
|
66
|
-
require_relative "sql/ast/
|
|
67
|
-
require_relative "sql/ast/
|
|
68
|
-
require_relative "sql/ast/
|
|
69
|
-
require_relative "sql/ast/
|
|
70
|
-
require_relative "sql/ast/
|
|
71
|
-
require_relative "sql/ast/
|
|
72
|
-
require_relative "sql/
|
|
73
|
-
require_relative "sql/
|
|
74
|
-
require_relative "sql/
|
|
75
|
-
|
|
76
|
-
require_relative "
|
|
77
|
-
require_relative "
|
|
78
|
-
require_relative "
|
|
79
|
-
require_relative "
|
|
80
|
-
|
|
81
|
-
require_relative "execution/
|
|
82
|
-
require_relative "execution/
|
|
83
|
-
require_relative "execution/
|
|
84
|
-
require_relative "execution/
|
|
85
|
-
require_relative "execution/
|
|
86
|
-
require_relative "execution/
|
|
87
|
-
require_relative "execution/
|
|
88
|
-
require_relative "execution/
|
|
89
|
-
require_relative "execution/
|
|
90
|
-
require_relative "execution/
|
|
91
|
-
require_relative "execution/
|
|
92
|
-
require_relative "execution/
|
|
93
|
-
|
|
94
|
-
require_relative "
|
|
95
|
-
require_relative "
|
|
96
|
-
require_relative "
|
|
97
|
-
require_relative "
|
|
98
|
-
require_relative "
|
|
99
|
-
require_relative "
|
|
100
|
-
require_relative "
|
|
101
|
-
require_relative "
|
|
102
|
-
|
|
103
|
-
require_relative "catalog/
|
|
104
|
-
require_relative "catalog/
|
|
105
|
-
|
|
106
|
-
require_relative "
|
|
107
|
-
require_relative "
|
|
108
|
-
require_relative "
|
|
109
|
-
require_relative "
|
|
110
|
-
require_relative "
|
|
111
|
-
require_relative "
|
|
112
|
-
require_relative "
|
|
113
|
-
require_relative "
|
|
114
|
-
|
|
115
|
-
require_relative "transactions/
|
|
116
|
-
|
|
117
|
-
require_relative "
|
|
118
|
-
require_relative "
|
|
119
|
-
require_relative "
|
|
120
|
-
require_relative "
|
|
121
|
-
require_relative "
|
|
122
|
-
require_relative "
|
|
123
|
-
require_relative "
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
require_relative "
|
|
127
|
-
require_relative "
|
|
128
|
-
require_relative "
|
|
129
|
-
require_relative "
|
|
130
|
-
require_relative "
|
|
131
|
-
require_relative "
|
|
132
|
-
require_relative "
|
|
133
|
-
|
|
134
|
-
require_relative "
|
|
135
|
-
require_relative "
|
|
136
|
-
require_relative "
|
|
137
|
-
require_relative "
|
|
138
|
-
require_relative "
|
|
139
|
-
require_relative "
|
|
140
|
-
require_relative "
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
require_relative "
|
|
144
|
-
require_relative "
|
|
145
|
-
require_relative "
|
|
146
|
-
require_relative "
|
|
147
|
-
require_relative "
|
|
148
|
-
|
|
149
|
-
require_relative "
|
|
150
|
-
|
|
151
|
-
require_relative "
|
|
152
|
-
require_relative "
|
|
153
|
-
require_relative "
|
|
154
|
-
require_relative "
|
|
155
|
-
require_relative "
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
require_relative "
|
|
159
|
-
require_relative "
|
|
160
|
-
require_relative "
|
|
161
|
-
require_relative "
|
|
162
|
-
require_relative "
|
|
163
|
-
require_relative "
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
require_relative "
|
|
167
|
-
require_relative "
|
|
168
|
-
require_relative "
|
|
169
|
-
require_relative "
|
|
170
|
-
require_relative "
|
|
171
|
-
require_relative "
|
|
172
|
-
require_relative "
|
|
173
|
-
|
|
174
|
-
require_relative "
|
|
175
|
-
require_relative "
|
|
176
|
-
require_relative "
|
|
177
|
-
require_relative "
|
|
178
|
-
require_relative "
|
|
179
|
-
require_relative "
|
|
180
|
-
require_relative "
|
|
181
|
-
require_relative "
|
|
182
|
-
|
|
183
|
-
require_relative "types/
|
|
184
|
-
require_relative "types/
|
|
185
|
-
require_relative "types/
|
|
186
|
-
require_relative "types/
|
|
187
|
-
require_relative "types/
|
|
188
|
-
require_relative "types/
|
|
189
|
-
require_relative "types/
|
|
190
|
-
|
|
191
|
-
require_relative "
|
|
192
|
-
require_relative "
|
|
193
|
-
require_relative "
|
|
194
|
-
require_relative "
|
|
195
|
-
require_relative "
|
|
196
|
-
require_relative "
|
|
197
|
-
require_relative "
|
|
198
|
-
require_relative "
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
require_relative "
|
|
202
|
-
require_relative "
|
|
203
|
-
require_relative "
|
|
204
|
-
require_relative "
|
|
205
|
-
require_relative "
|
|
206
|
-
require_relative "
|
|
207
|
-
require_relative "
|
|
208
|
-
require_relative "
|
|
209
|
-
|
|
210
|
-
require_relative "
|
|
211
|
-
require_relative "
|
|
212
|
-
require_relative "
|
|
213
|
-
require_relative "
|
|
214
|
-
require_relative "
|
|
215
|
-
require_relative "
|
|
216
|
-
require_relative "
|
|
217
|
-
require_relative "
|
|
218
|
-
|
|
219
|
-
require_relative "
|
|
220
|
-
require_relative "
|
|
221
|
-
require_relative "
|
|
222
|
-
require_relative "
|
|
223
|
-
require_relative "
|
|
224
|
-
require_relative "
|
|
225
|
-
require_relative "
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
require_relative "
|
|
229
|
-
require_relative "
|
|
230
|
-
require_relative "
|
|
231
|
-
require_relative "
|
|
232
|
-
require_relative "
|
|
233
|
-
|
|
234
|
-
require_relative "
|
|
235
|
-
|
|
236
|
-
require_relative "
|
|
237
|
-
require_relative "
|
|
238
|
-
require_relative "
|
|
239
|
-
require_relative "
|
|
240
|
-
require_relative "
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
require_relative "
|
|
244
|
-
require_relative "
|
|
245
|
-
require_relative "
|
|
246
|
-
require_relative "
|
|
247
|
-
require_relative "
|
|
248
|
-
|
|
249
|
-
require_relative "
|
|
250
|
-
|
|
251
|
-
require_relative "
|
|
252
|
-
require_relative "
|
|
253
|
-
require_relative "
|
|
254
|
-
require_relative "
|
|
255
|
-
|
|
256
|
-
require_relative "
|
|
257
|
-
|
|
258
|
-
require_relative "
|
|
259
|
-
require_relative "
|
|
260
|
-
require_relative "
|
|
261
|
-
require_relative "
|
|
262
|
-
require_relative "
|
|
263
|
-
require_relative "
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
require_relative "
|
|
267
|
-
require_relative "
|
|
268
|
-
require_relative "
|
|
269
|
-
require_relative "
|
|
270
|
-
require_relative "
|
|
271
|
-
|
|
272
|
-
require_relative "
|
|
273
|
-
require_relative "
|
|
274
|
-
|
|
275
|
-
require_relative "
|
|
276
|
-
require_relative "
|
|
277
|
-
require_relative "
|
|
278
|
-
|
|
279
|
-
require_relative "
|
|
280
|
-
|
|
281
|
-
require_relative "
|
|
282
|
-
require_relative "
|
|
283
|
-
require_relative "
|
|
284
|
-
require_relative "
|
|
285
|
-
require_relative "
|
|
286
|
-
require_relative "
|
|
287
|
-
|
|
288
|
-
require_relative "cli/
|
|
289
|
-
require_relative "cli/
|
|
290
|
-
require_relative "cli/
|
|
291
|
-
require_relative "cli/commands/
|
|
292
|
-
require_relative "cli/commands/
|
|
293
|
-
require_relative "cli/commands/
|
|
294
|
-
require_relative "cli/commands/
|
|
295
|
-
require_relative "cli/commands/
|
|
296
|
-
require_relative "cli/commands/
|
|
297
|
-
require_relative "cli/commands/
|
|
298
|
-
require_relative "cli/commands/
|
|
299
|
-
require_relative "cli/commands/
|
|
300
|
-
require_relative "cli/commands/
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
@connection
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
results
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
@
|
|
425
|
-
end
|
|
426
|
-
|
|
427
|
-
def
|
|
428
|
-
ensure_connected
|
|
429
|
-
@engine.
|
|
430
|
-
end
|
|
431
|
-
|
|
432
|
-
def
|
|
433
|
-
ensure_connected
|
|
434
|
-
@engine.
|
|
435
|
-
end
|
|
436
|
-
|
|
437
|
-
def
|
|
438
|
-
ensure_connected
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
@engine.
|
|
458
|
-
end
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
Database
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
db
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
{
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# RubyDB - A developer-first relational database for Ruby and Rails
|
|
4
|
+
#
|
|
5
|
+
# This is the main entry point for the RubyDB library.
|
|
6
|
+
# It provides the core database functionality and loads all required components.
|
|
7
|
+
|
|
8
|
+
# Ruby 3.3 does not ship Set as a built-in; keep the entrypoint standalone.
|
|
9
|
+
# rubocop:disable Lint/RedundantRequireStatement
|
|
10
|
+
require "set"
|
|
11
|
+
# rubocop:enable Lint/RedundantRequireStatement
|
|
12
|
+
require_relative "version"
|
|
13
|
+
require_relative "constants"
|
|
14
|
+
require_relative "build_info"
|
|
15
|
+
require_relative "accelerator"
|
|
16
|
+
|
|
17
|
+
require_relative "errors/error"
|
|
18
|
+
require_relative "errors/connection_error"
|
|
19
|
+
require_relative "errors/database_error"
|
|
20
|
+
require_relative "errors/storage_error"
|
|
21
|
+
require_relative "errors/execution_error"
|
|
22
|
+
require_relative "errors/parser_error"
|
|
23
|
+
require_relative "errors/transaction_error"
|
|
24
|
+
require_relative "errors/client_error"
|
|
25
|
+
require_relative "errors/server_error"
|
|
26
|
+
|
|
27
|
+
require_relative "storage/database_lock"
|
|
28
|
+
require_relative "storage/engine"
|
|
29
|
+
require_relative "storage/storage_manager"
|
|
30
|
+
require_relative "storage/file_manager"
|
|
31
|
+
require_relative "storage/page"
|
|
32
|
+
require_relative "storage/page_header"
|
|
33
|
+
require_relative "storage/page_manager"
|
|
34
|
+
require_relative "storage/page_allocator"
|
|
35
|
+
require_relative "storage/buffer_pool"
|
|
36
|
+
require_relative "storage/buffer_frame"
|
|
37
|
+
require_relative "storage/record"
|
|
38
|
+
require_relative "storage/row"
|
|
39
|
+
require_relative "storage/tuple"
|
|
40
|
+
require_relative "storage/serializer"
|
|
41
|
+
require_relative "storage/deserializer"
|
|
42
|
+
require_relative "storage/free_space_map"
|
|
43
|
+
require_relative "storage/visibility_map"
|
|
44
|
+
require_relative "storage/storage_layout"
|
|
45
|
+
|
|
46
|
+
require_relative "sql/lexer"
|
|
47
|
+
require_relative "sql/token"
|
|
48
|
+
require_relative "sql/parser"
|
|
49
|
+
require_relative "sql/keywords"
|
|
50
|
+
require_relative "sql/operators"
|
|
51
|
+
require_relative "sql/ast/node"
|
|
52
|
+
require_relative "sql/ast/expression"
|
|
53
|
+
require_relative "sql/ast/select"
|
|
54
|
+
require_relative "sql/ast/with"
|
|
55
|
+
require_relative "sql/ast/set_operation"
|
|
56
|
+
require_relative "sql/ast/insert"
|
|
57
|
+
require_relative "sql/ast/update"
|
|
58
|
+
require_relative "sql/ast/delete"
|
|
59
|
+
require_relative "sql/ast/create_table"
|
|
60
|
+
require_relative "sql/ast/constraint"
|
|
61
|
+
require_relative "sql/ast/drop_table"
|
|
62
|
+
require_relative "sql/ast/create_index"
|
|
63
|
+
require_relative "sql/ast/drop_index"
|
|
64
|
+
require_relative "sql/ast/alter_table"
|
|
65
|
+
require_relative "sql/ast/create_database"
|
|
66
|
+
require_relative "sql/ast/drop_database"
|
|
67
|
+
require_relative "sql/ast/create_schema"
|
|
68
|
+
require_relative "sql/ast/drop_schema"
|
|
69
|
+
require_relative "sql/ast/view"
|
|
70
|
+
require_relative "sql/ast/trigger"
|
|
71
|
+
require_relative "sql/ast/vacuum"
|
|
72
|
+
require_relative "sql/ast/begin_transaction"
|
|
73
|
+
require_relative "sql/ast/commit"
|
|
74
|
+
require_relative "sql/ast/rollback"
|
|
75
|
+
require_relative "sql/ast/savepoint"
|
|
76
|
+
require_relative "sql/ast/explain"
|
|
77
|
+
require_relative "sql/planner/binder"
|
|
78
|
+
require_relative "sql/planner/analyzer"
|
|
79
|
+
require_relative "sql/planner/type_checker"
|
|
80
|
+
|
|
81
|
+
require_relative "execution/plan"
|
|
82
|
+
require_relative "execution/physical_plan"
|
|
83
|
+
require_relative "execution/cost_model"
|
|
84
|
+
require_relative "execution/operator_selection"
|
|
85
|
+
require_relative "execution/accelerator_dispatch"
|
|
86
|
+
require_relative "execution/executor"
|
|
87
|
+
require_relative "execution/planner"
|
|
88
|
+
require_relative "execution/optimizer"
|
|
89
|
+
require_relative "execution/expression"
|
|
90
|
+
require_relative "execution/predicate"
|
|
91
|
+
require_relative "execution/scan"
|
|
92
|
+
require_relative "execution/sequential_scan"
|
|
93
|
+
require_relative "execution/index_scan"
|
|
94
|
+
require_relative "execution/insert_executor"
|
|
95
|
+
require_relative "execution/update_executor"
|
|
96
|
+
require_relative "execution/delete_executor"
|
|
97
|
+
require_relative "execution/join_executor"
|
|
98
|
+
require_relative "execution/aggregate_executor"
|
|
99
|
+
require_relative "execution/sort_executor"
|
|
100
|
+
require_relative "execution/limit_executor"
|
|
101
|
+
require_relative "execution/distinct_executor"
|
|
102
|
+
|
|
103
|
+
require_relative "catalog/catalog"
|
|
104
|
+
require_relative "catalog/database"
|
|
105
|
+
require_relative "catalog/schema"
|
|
106
|
+
require_relative "catalog/table"
|
|
107
|
+
require_relative "catalog/column"
|
|
108
|
+
require_relative "catalog/index"
|
|
109
|
+
require_relative "catalog/constraint"
|
|
110
|
+
require_relative "catalog/sequence"
|
|
111
|
+
require_relative "catalog/view"
|
|
112
|
+
require_relative "catalog/trigger"
|
|
113
|
+
require_relative "catalog/system_catalog"
|
|
114
|
+
|
|
115
|
+
require_relative "transactions/transaction"
|
|
116
|
+
require_relative "transactions/transaction_manager"
|
|
117
|
+
require_relative "transactions/transaction_id"
|
|
118
|
+
require_relative "transactions/lock_manager"
|
|
119
|
+
require_relative "transactions/lock"
|
|
120
|
+
require_relative "transactions/isolation"
|
|
121
|
+
require_relative "transactions/savepoint"
|
|
122
|
+
require_relative "errors/replication_error"
|
|
123
|
+
require_relative "transactions/commit_manager"
|
|
124
|
+
require_relative "transactions/transaction_log"
|
|
125
|
+
|
|
126
|
+
require_relative "indexes/index"
|
|
127
|
+
require_relative "indexes/btree"
|
|
128
|
+
require_relative "indexes/btree_node"
|
|
129
|
+
require_relative "indexes/btree_cursor"
|
|
130
|
+
require_relative "indexes/hash_index"
|
|
131
|
+
require_relative "indexes/index_scan"
|
|
132
|
+
require_relative "indexes/index_manager"
|
|
133
|
+
|
|
134
|
+
require_relative "wal/wal"
|
|
135
|
+
require_relative "wal/record"
|
|
136
|
+
require_relative "wal/writer"
|
|
137
|
+
require_relative "wal/reader"
|
|
138
|
+
require_relative "wal/segment"
|
|
139
|
+
require_relative "wal/checkpoint"
|
|
140
|
+
require_relative "wal/lsn"
|
|
141
|
+
require_relative "wal/archive"
|
|
142
|
+
|
|
143
|
+
require_relative "recovery/crash_recovery"
|
|
144
|
+
require_relative "recovery/checkpoint"
|
|
145
|
+
require_relative "recovery/redo"
|
|
146
|
+
require_relative "recovery/undo"
|
|
147
|
+
require_relative "recovery/consistency"
|
|
148
|
+
require_relative "recovery/corruption_detector"
|
|
149
|
+
require_relative "recovery/recovery_manager"
|
|
150
|
+
|
|
151
|
+
require_relative "mvcc/version"
|
|
152
|
+
require_relative "mvcc/visibility"
|
|
153
|
+
require_relative "mvcc/snapshot"
|
|
154
|
+
require_relative "mvcc/version_store"
|
|
155
|
+
require_relative "mvcc/vacuum"
|
|
156
|
+
require_relative "mvcc/garbage_collector"
|
|
157
|
+
|
|
158
|
+
require_relative "concurrency/scheduler"
|
|
159
|
+
require_relative "concurrency/latch"
|
|
160
|
+
require_relative "concurrency/mutex"
|
|
161
|
+
require_relative "concurrency/rw_lock"
|
|
162
|
+
require_relative "concurrency/deadlock_detector"
|
|
163
|
+
require_relative "concurrency/lock_graph"
|
|
164
|
+
require_relative "concurrency/worker_pool"
|
|
165
|
+
|
|
166
|
+
require_relative "constraints/constraint"
|
|
167
|
+
require_relative "constraints/primary_key"
|
|
168
|
+
require_relative "constraints/foreign_key"
|
|
169
|
+
require_relative "constraints/unique"
|
|
170
|
+
require_relative "constraints/not_null"
|
|
171
|
+
require_relative "constraints/check"
|
|
172
|
+
require_relative "constraints/validator"
|
|
173
|
+
|
|
174
|
+
require_relative "functions/function"
|
|
175
|
+
require_relative "functions/scalar"
|
|
176
|
+
require_relative "functions/aggregate"
|
|
177
|
+
require_relative "functions/string_functions"
|
|
178
|
+
require_relative "functions/numeric_functions"
|
|
179
|
+
require_relative "functions/date_functions"
|
|
180
|
+
require_relative "functions/json_functions"
|
|
181
|
+
require_relative "functions/system_functions"
|
|
182
|
+
|
|
183
|
+
require_relative "types/type"
|
|
184
|
+
require_relative "types/integer"
|
|
185
|
+
require_relative "types/bigint"
|
|
186
|
+
require_relative "types/smallint"
|
|
187
|
+
require_relative "types/float"
|
|
188
|
+
require_relative "types/decimal"
|
|
189
|
+
require_relative "types/boolean"
|
|
190
|
+
require_relative "types/text"
|
|
191
|
+
require_relative "types/varchar"
|
|
192
|
+
require_relative "types/blob"
|
|
193
|
+
require_relative "types/date"
|
|
194
|
+
require_relative "types/time"
|
|
195
|
+
require_relative "types/timestamp"
|
|
196
|
+
require_relative "types/json"
|
|
197
|
+
require_relative "types/uuid"
|
|
198
|
+
require_relative "types/null"
|
|
199
|
+
|
|
200
|
+
require_relative "security/authentication"
|
|
201
|
+
require_relative "security/authorization"
|
|
202
|
+
require_relative "security/password"
|
|
203
|
+
require_relative "security/credentials"
|
|
204
|
+
require_relative "security/user"
|
|
205
|
+
require_relative "security/role"
|
|
206
|
+
require_relative "security/permissions"
|
|
207
|
+
require_relative "security/access_control"
|
|
208
|
+
require_relative "security/audit_log"
|
|
209
|
+
|
|
210
|
+
require_relative "server/server"
|
|
211
|
+
require_relative "server/listener"
|
|
212
|
+
require_relative "server/connection"
|
|
213
|
+
require_relative "server/session"
|
|
214
|
+
require_relative "server/connection_pool"
|
|
215
|
+
require_relative "server/worker"
|
|
216
|
+
require_relative "server/request_handler"
|
|
217
|
+
require_relative "server/lifecycle"
|
|
218
|
+
|
|
219
|
+
require_relative "client/connection_url"
|
|
220
|
+
require_relative "client/client"
|
|
221
|
+
require_relative "client/connection"
|
|
222
|
+
require_relative "client/result"
|
|
223
|
+
require_relative "client/statement"
|
|
224
|
+
require_relative "client/prepared_statement"
|
|
225
|
+
require_relative "client/transaction"
|
|
226
|
+
require_relative "client/connection_pool"
|
|
227
|
+
|
|
228
|
+
require_relative "replication/primary"
|
|
229
|
+
require_relative "replication/replica"
|
|
230
|
+
require_relative "replication/replication_log"
|
|
231
|
+
require_relative "replication/replication_stream"
|
|
232
|
+
require_relative "replication/replication_manager"
|
|
233
|
+
require_relative "replication/replication_slot"
|
|
234
|
+
require_relative "replication/failover"
|
|
235
|
+
|
|
236
|
+
require_relative "backup/backup"
|
|
237
|
+
require_relative "backup/restore"
|
|
238
|
+
require_relative "backup/snapshot"
|
|
239
|
+
require_relative "backup/archive"
|
|
240
|
+
require_relative "backup/incremental"
|
|
241
|
+
require_relative "backup/verification"
|
|
242
|
+
|
|
243
|
+
require_relative "branching/branch"
|
|
244
|
+
require_relative "branching/branch_manager"
|
|
245
|
+
require_relative "branching/copy_on_write"
|
|
246
|
+
require_relative "branching/checkout"
|
|
247
|
+
require_relative "branching/merge"
|
|
248
|
+
require_relative "branching/diff"
|
|
249
|
+
require_relative "branching/branch_metadata"
|
|
250
|
+
|
|
251
|
+
require_relative "history/history"
|
|
252
|
+
require_relative "history/change"
|
|
253
|
+
require_relative "history/timeline"
|
|
254
|
+
require_relative "history/temporal_query"
|
|
255
|
+
require_relative "history/as_of"
|
|
256
|
+
require_relative "history/history_manager"
|
|
257
|
+
|
|
258
|
+
require_relative "migrations/migration"
|
|
259
|
+
require_relative "migrations/migration_manager"
|
|
260
|
+
require_relative "migrations/migration_version"
|
|
261
|
+
require_relative "migrations/schema_diff"
|
|
262
|
+
require_relative "migrations/schema_version"
|
|
263
|
+
require_relative "migrations/migration_lock"
|
|
264
|
+
|
|
265
|
+
require_relative "rails/adapter"
|
|
266
|
+
require_relative "rails/connection"
|
|
267
|
+
require_relative "rails/database_statements"
|
|
268
|
+
require_relative "rails/schema_statements"
|
|
269
|
+
require_relative "rails/quoting"
|
|
270
|
+
require_relative "rails/type"
|
|
271
|
+
require_relative "rails/migration"
|
|
272
|
+
require_relative "rails/transaction"
|
|
273
|
+
require_relative "rails/result"
|
|
274
|
+
|
|
275
|
+
require_relative "configuration/config"
|
|
276
|
+
require_relative "configuration/environment"
|
|
277
|
+
require_relative "configuration/defaults"
|
|
278
|
+
require_relative "configuration/parser"
|
|
279
|
+
require_relative "configuration/validation"
|
|
280
|
+
|
|
281
|
+
require_relative "monitoring/metrics"
|
|
282
|
+
require_relative "monitoring/statistics"
|
|
283
|
+
require_relative "monitoring/logger"
|
|
284
|
+
require_relative "monitoring/health"
|
|
285
|
+
require_relative "monitoring/performance"
|
|
286
|
+
require_relative "monitoring/events"
|
|
287
|
+
|
|
288
|
+
require_relative "cli/application"
|
|
289
|
+
require_relative "cli/formatter"
|
|
290
|
+
require_relative "cli/output"
|
|
291
|
+
require_relative "cli/commands/init"
|
|
292
|
+
require_relative "cli/commands/create"
|
|
293
|
+
require_relative "cli/commands/drop"
|
|
294
|
+
require_relative "cli/commands/start"
|
|
295
|
+
require_relative "cli/commands/stop"
|
|
296
|
+
require_relative "cli/commands/restart"
|
|
297
|
+
require_relative "cli/commands/status"
|
|
298
|
+
require_relative "cli/commands/shell"
|
|
299
|
+
require_relative "cli/commands/migrate"
|
|
300
|
+
require_relative "cli/commands/backup"
|
|
301
|
+
require_relative "cli/commands/restore"
|
|
302
|
+
require_relative "cli/commands/snapshot"
|
|
303
|
+
require_relative "cli/commands/branch"
|
|
304
|
+
require_relative "cli/commands/checkout"
|
|
305
|
+
require_relative "cli/commands/merge"
|
|
306
|
+
require_relative "cli/commands/diff"
|
|
307
|
+
require_relative "cli/commands/inspect"
|
|
308
|
+
require_relative "cli/commands/vacuum"
|
|
309
|
+
require_relative "cli/commands/doctor"
|
|
310
|
+
require_relative "cli/commands/accelerator"
|
|
311
|
+
|
|
312
|
+
module RubyDB
|
|
313
|
+
# Main database class
|
|
314
|
+
class Database
|
|
315
|
+
attr_reader :path, :config, :engine, :connection
|
|
316
|
+
|
|
317
|
+
def initialize(path, config = {})
|
|
318
|
+
@path = path
|
|
319
|
+
@config = config
|
|
320
|
+
@engine = nil
|
|
321
|
+
@connection = nil
|
|
322
|
+
@is_open = false
|
|
323
|
+
@lock = Mutex.new
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
def connect
|
|
327
|
+
@lock.synchronize do
|
|
328
|
+
return self if @is_open
|
|
329
|
+
|
|
330
|
+
# Initialize storage engine
|
|
331
|
+
@engine = Storage::Engine.new(@path, @config)
|
|
332
|
+
|
|
333
|
+
# Initialize client connection
|
|
334
|
+
@connection = Client::Client.new(
|
|
335
|
+
database: @path,
|
|
336
|
+
host: @config[:host] || "localhost",
|
|
337
|
+
port: @config[:port] || 7432,
|
|
338
|
+
username: @config[:username] || "rubydb",
|
|
339
|
+
password: @config[:password] || "",
|
|
340
|
+
timeout: @config[:timeout] || 30,
|
|
341
|
+
pool_size: @config[:pool_size] || 1,
|
|
342
|
+
auto_connect: @config.fetch(:auto_connect, true)
|
|
343
|
+
)
|
|
344
|
+
@connection.connect if @config[:auto_connect] != false
|
|
345
|
+
|
|
346
|
+
@is_open = true
|
|
347
|
+
self
|
|
348
|
+
end
|
|
349
|
+
rescue => e
|
|
350
|
+
raise ConnectionError, "Failed to connect to database: #{e.message}"
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
def execute(sql)
|
|
354
|
+
ensure_connected
|
|
355
|
+
|
|
356
|
+
# Parse SQL
|
|
357
|
+
lexer = SQL::Lexer.new(sql)
|
|
358
|
+
tokens = lexer.tokenize
|
|
359
|
+
parser = SQL::Parser.new(tokens)
|
|
360
|
+
statements = parser.parse
|
|
361
|
+
|
|
362
|
+
results = []
|
|
363
|
+
statements.each do |stmt|
|
|
364
|
+
# Plan and execute
|
|
365
|
+
planner = Execution::Planner.new(@engine)
|
|
366
|
+
plan = planner.plan(stmt)
|
|
367
|
+
executor = Execution::Executor.new(@engine)
|
|
368
|
+
result = executor.execute(plan)
|
|
369
|
+
results << result
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
(results.size == 1) ? results.first : results
|
|
373
|
+
rescue => e
|
|
374
|
+
raise ExecutionError, "Failed to execute SQL: #{e.message}"
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
def query(sql)
|
|
378
|
+
result = execute(sql)
|
|
379
|
+
if result.is_a?(Hash) && result[:rows]
|
|
380
|
+
result[:rows]
|
|
381
|
+
elsif result.is_a?(Array)
|
|
382
|
+
result.map { |r| (r.is_a?(Hash) && r[:rows]) ? r[:rows] : r }.flatten
|
|
383
|
+
else
|
|
384
|
+
[]
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
def close
|
|
389
|
+
@lock.synchronize do
|
|
390
|
+
return true unless @is_open
|
|
391
|
+
|
|
392
|
+
@connection&.disconnect
|
|
393
|
+
@engine&.close
|
|
394
|
+
|
|
395
|
+
@is_open = false
|
|
396
|
+
@engine = nil
|
|
397
|
+
@connection = nil
|
|
398
|
+
true
|
|
399
|
+
end
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
def transaction(&block)
|
|
403
|
+
ensure_connected
|
|
404
|
+
|
|
405
|
+
begin
|
|
406
|
+
# Begin transaction
|
|
407
|
+
tx_id = @engine.begin_transaction
|
|
408
|
+
|
|
409
|
+
# Execute block
|
|
410
|
+
result = block.call if block_given?
|
|
411
|
+
|
|
412
|
+
# Commit transaction
|
|
413
|
+
@engine.commit_transaction(tx_id)
|
|
414
|
+
|
|
415
|
+
result
|
|
416
|
+
rescue => e
|
|
417
|
+
# Rollback on error
|
|
418
|
+
@engine.rollback_transaction(tx_id) if tx_id
|
|
419
|
+
raise TransactionError, "Transaction failed: #{e.message}"
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
def open?
|
|
424
|
+
@is_open
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
def stats
|
|
428
|
+
ensure_connected
|
|
429
|
+
@engine.stats
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
def tables
|
|
433
|
+
ensure_connected
|
|
434
|
+
@engine.list_tables
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
def create_table(name, &)
|
|
438
|
+
ensure_connected
|
|
439
|
+
@engine.create_table(name, &)
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
def drop_table(name)
|
|
443
|
+
ensure_connected
|
|
444
|
+
@engine.drop_table(name)
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
def insert(table, data)
|
|
448
|
+
ensure_connected
|
|
449
|
+
columns = data.keys
|
|
450
|
+
values = data.values
|
|
451
|
+
@engine.insert_row(table, columns, values)
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
def select(table, conditions = {})
|
|
455
|
+
ensure_connected
|
|
456
|
+
columns = @engine.table_columns(table)
|
|
457
|
+
@engine.select_rows(table, columns, conditions)
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
def update(table, id, data)
|
|
461
|
+
ensure_connected
|
|
462
|
+
@engine.update_row(table, id, data)
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
def delete(table, id)
|
|
466
|
+
ensure_connected
|
|
467
|
+
@engine.delete_row(table, id)
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
private
|
|
471
|
+
|
|
472
|
+
def ensure_connected
|
|
473
|
+
connect unless @is_open
|
|
474
|
+
raise DatabaseError, "Database is not open" unless @is_open
|
|
475
|
+
end
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
# Connect to a database
|
|
479
|
+
def self.connect(url)
|
|
480
|
+
# Parse URL: rubydb://local/./path/to/database.rdb
|
|
481
|
+
# rubydb://user:pass@host:7432/database
|
|
482
|
+
if url.start_with?("rubydb://local/")
|
|
483
|
+
path = url.sub("rubydb://local/", "")
|
|
484
|
+
Database.new(path).connect
|
|
485
|
+
elsif url.start_with?("rubydb://")
|
|
486
|
+
# Server mode
|
|
487
|
+
uri = URI.parse(url)
|
|
488
|
+
config = {
|
|
489
|
+
host: uri.host,
|
|
490
|
+
port: uri.port || 7432,
|
|
491
|
+
username: uri.user,
|
|
492
|
+
password: uri.password,
|
|
493
|
+
database: uri.path.sub("/", "")
|
|
494
|
+
}
|
|
495
|
+
db = Database.new(config[:database], config)
|
|
496
|
+
db.connect
|
|
497
|
+
db
|
|
498
|
+
else
|
|
499
|
+
# Treat as local path
|
|
500
|
+
Database.new(url).connect
|
|
501
|
+
end
|
|
502
|
+
rescue => e
|
|
503
|
+
raise ConnectionError, "Failed to connect: #{e.message}"
|
|
504
|
+
end
|
|
505
|
+
|
|
506
|
+
# Open a database file
|
|
507
|
+
def self.open(path, config = {})
|
|
508
|
+
db = Database.new(path, config)
|
|
509
|
+
db.connect
|
|
510
|
+
db
|
|
511
|
+
end
|
|
512
|
+
|
|
513
|
+
# Create a new database
|
|
514
|
+
def self.create(path, config = {})
|
|
515
|
+
# Ensure directory exists
|
|
516
|
+
dir = File.dirname(path)
|
|
517
|
+
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
|
|
518
|
+
|
|
519
|
+
# Create and initialize database
|
|
520
|
+
db = Database.new(path, config)
|
|
521
|
+
db.connect
|
|
522
|
+
|
|
523
|
+
# Create default schema
|
|
524
|
+
db.execute("CREATE TABLE IF NOT EXISTS schema_migrations (version TEXT PRIMARY KEY, applied_at TIMESTAMP)")
|
|
525
|
+
db.execute("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT UNIQUE, email TEXT UNIQUE, created_at TIMESTAMP, updated_at TIMESTAMP)")
|
|
526
|
+
|
|
527
|
+
db
|
|
528
|
+
rescue => e
|
|
529
|
+
raise DatabaseError, "Failed to create database: #{e.message}"
|
|
530
|
+
end
|
|
531
|
+
|
|
532
|
+
# Version information
|
|
533
|
+
def self.version
|
|
534
|
+
VERSION
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
# Database information
|
|
538
|
+
def self.info
|
|
539
|
+
{
|
|
540
|
+
name: "RubyDB",
|
|
541
|
+
version: VERSION,
|
|
542
|
+
description: "A developer-first relational database for Ruby and Rails",
|
|
543
|
+
homepage: "https://github.com/rubydb/rubydb",
|
|
544
|
+
license: "MIT"
|
|
545
|
+
}
|
|
546
|
+
end
|
|
547
|
+
|
|
548
|
+
# Load a configuration file
|
|
549
|
+
def self.load_config(path)
|
|
550
|
+
Configuration::Config.load(path)
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
# Run migrations
|
|
554
|
+
def self.migrate(database, options = {})
|
|
555
|
+
manager = Migrations::MigrationManager.new(database, options)
|
|
556
|
+
manager.migrate
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
# Create a backup
|
|
560
|
+
def self.backup(database, options = {})
|
|
561
|
+
backup = Backup::Backup.new(database, options)
|
|
562
|
+
backup.create_backup
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
# Restore from backup
|
|
566
|
+
def self.restore(backup_path, options = {})
|
|
567
|
+
restore = Backup::Restore.new(nil, options)
|
|
568
|
+
restore.restore(backup_path)
|
|
569
|
+
end
|
|
570
|
+
end
|