[PHP] Rewrite URLs in live databases with resumable record cursors - #578
Open
adamziel wants to merge 1 commit into
Open
[PHP] Rewrite URLs in live databases with resumable record cursors#578adamziel wants to merge 1 commit into
adamziel wants to merge 1 commit into
Conversation
Contributor
Pull pipeline performance —
|
| Stage | Wall time | Resume attempts | Status | Details |
|---|---|---|---|---|
playground-sqlite-db-pull |
9.79 s | 1 | ✓ | condition=db-pull in PHP.wasm runtime=php.wasm 8.3 wp_mysql_parser=enabled mode=lexer native_lexer=verified native_token_stream=WP_MySQL_Native_Token_Stream native_token_count=18 native_parser=selected |
playground-sqlite-db-apply |
3.88 s | 1 | ✓ | condition=db-apply to SQLite in PHP.wasm runtime=php.wasm 8.3 wp_mysql_parser=enabled mode=parser native_lexer=verified native_token_stream=WP_MySQL_Native_Token_Stream native_token_count=18 native_parser=verified native_ast=WP_MySQL_Native_Parser_Node sqlite_driver_parser=verified |
| Total | 13.67 s |
Numbers carry runner noise; treat single-run deltas as directional, not authoritative.
📈 Trunk performance history — commit-by-commit timeline.
adamziel
force-pushed
the
codex/rewrite-live-database-urls
branch
from
August 14, 2026 12:03
6ccfe30 to
270331d
Compare
adamziel
changed the base branch from
trunk
to
codex/extract-database-row-reader
August 14, 2026 12:04
adamziel
added a commit
that referenced
this pull request
Aug 14, 2026
Extracts `DatabaseRowsReader` from `MySQLDumpProducer` so database records can be consumed without generating SQL first. `MySQLDumpProducer` now owns a reader and remains responsible for SQL formatting, oversized values, and the dump lifecycle. The reader owns table discovery, metadata, bounded primary-key queries, exclusions, and cursor state. This does not change dump output. The child PR #578 uses the reader to process structured live database records directly. ## Example ```php $reader = new DatabaseRowsReader($pdo, [ "batch_size" => 250, ]); $reader->initialize_tables_to_process(); while ($reader->move_to_next_table()) { while ($reader->next_record()) { $table = $reader->get_current_table(); $record = $reader->get_current_record(); process_record($table, $record); $reader->clear_current_record(); } } ``` ## Testing The existing dump producer tests cover batch boundaries, composite keys, exclusions, data types, and cursor resume. PHP 7.2 compatibility, PHPStan, and CI pass.
adamziel
force-pushed
the
codex/rewrite-live-database-urls
branch
from
August 14, 2026 12:16
270331d to
e00a860
Compare
adamziel
changed the base branch from
codex/extract-database-row-reader
to
trunk
August 14, 2026 12:16
adamziel
force-pushed
the
codex/rewrite-live-database-urls
branch
from
August 14, 2026 12:25
e00a860 to
15bc621
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
db-rewrite-urlsto rewrite URL-bearing values in a live MySQL or SQLite database without exporting or parsing SQL.DatabaseUrlRewriteProcessorowns theDatabaseRowsReaderintroduced in #606, receives structured records directly, and performs one bounded record step at a time. Changed records use primary-key-scoped preparedUPDATEstatements with positional bindings. No table lock or lifecycle-long transaction is taken.The positional Reprint API URL is optional, and this command does not use
--fs-root. Omitted database options fall back to the target recorded bydb-applywhen available.Examples
Resume semantics
Progress is saved after each record decision. SIGINT or SIGTERM stops after the active step and exits with status 2; rerun the command to resume. Completed records are not scanned again. An update interrupted before its cursor is saved may be read again, but the already-rewritten value produces no second update.
A non-empty table without a primary key stops the command. Resume also rejects a changed target or URL mapping, and a concurrent change to the selected row stops rather than overwriting it.
Testing
The importer and MariaDB suites cover structured records, bound updates, identifiers, saved targets, primary keys, batch boundaries, and cursor resume. An E2E test sends SIGTERM mid-table, resumes in a new process, and confirms each content row is processed and updated once.