Repository navigation
refactor: Fetch rows into a pluggable row sink - #644
Conversation
MariaResultPrep::fetch_into() owns the fetch loop: the bound check, stepping through the parameter sets, row counting and interrupt checks. A MariaRowSink receives the column metadata in begin() and each row in append(), through a MariaRowView over the bound result buffers. The data frame builder becomes the first sink, MariaDataFrameSink, and fetch() returns its data frame unchanged. Modeled on r-dbi/RPostgres#638. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7atAZVq1J42WzXJpS
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7atAZVq1J42WzXJpS
Note that MariaDataFrameSink is the known exception to the no-longjmp rule. Describe where the `fields` metadata of begin() comes from. Comment out the unused parameter names of the default begin(). Tighten the lifetime of the pointer returned by value_bytes(). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7atAZVq1J42WzXJpS
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7atAZVq1J42WzXJpS
|
"MySQL server" job on 8831d5c (job 141429450511): 25 failed. 23 are Generated by Claude Code |
Resolve the conflict in src/MariaResultPrep.cpp: keep the fetch_into() structure and MariaFieldInfo capture, and pass the UNSIGNED_FLAG from #639 at every variable_type_from_field_type() call site. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7atAZVq1J42WzXJpS
|
Generated by Claude Code |
|
"MySQL server" job on a39d148 (job 141437196479): 9127 passed, 3 failed. All 3 are Generated by Claude Code |
|
Matrix result on a39d148 (run 46290940563): 23 of 26 jobs green, plus one re-run.
Clean review: nothing above Low; the Lows are fixed. Marking ready. Generated by Claude Code |
refactor: Fill the chunk store through the row sink interface of #644. MariaChunkSink appends each row of MariaResultPrep::fetch_into() to a MariaChunk, and get_data() returns the data frame of ALTREP columns as before. The fetch loop, MariaRow and MariaRowView are main's, so layer 1's own loop and MariaRow::append_to() are gone. MariaDataFrameSink has no user left and is removed. The chunk stores fixed-width values as the MariaRowView accessors return them, so BIT(1) and INT UNSIGNED (#639) follow main. The date and time conversions use the arithmetic of MariaDataFrameSink, so that the values are bit for bit the same. The chunk keeps the MariaFieldInfo of begin() instead of its own copy of the fields. The setup of the output when result metadata appears only after execution (9578270, 3b01c61) is kept on top of main's update_metadata(), and the contract in MariaRowSink.h describes it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7atAZVq1J42WzXJpS
This separates the fetch loop from what consumes the rows, modeled on RPostgres#638, as decided in #587 (comment) ("Refactor, independently of #641"). Behavior is unchanged.
Interface
src/MariaRowSink.hdefines the abstractMariaRowSink:begin(names, types, fields)runs once per fetch, after execute, also for a result without rows or columns.fieldsholds aMariaFieldInfoper column (MySQL type, flags, length, decimals, charset). The arguments refer to the live cache, so a sink copies what it needs.append(MariaRowView& row)is called once per fetched row. The view is valid only during the call.remaining()returns -1 for unbounded; 0 stops the loop. The loop checks it before each fetch.append()throws versus whenstep()or the interrupt check throws.MariaRowView(src/MariaRow.h) is the read-only face of the bound row:ncols(),type(j),is_null(j),value_int(),value_int64(),value_double(),value_bool(),value_mysql_time(),value_length()andvalue_bytes().value_bytes()wraps the existingfetch_buffer()/mysql_stmt_fetch_column()logic, so sinks never call libmysql themselves. A comment marks where fix: Correct values and parameter types for placeholder columns with MySQL servers #641's fixed buffer with refetch fits: onlyfetch_buffer(),value_bytes()andsetup()change.MariaResultPrep::fetch_into(MariaRowSink&)owns the loop: bound and complete checks,step()through parameter sets, row counting, interrupt checks, and the logic from fix: Results of a closed connection fail cleanly instead of crashing #624, fix: Raise warnings only after the C++ code is done with the result #632 and fix: A query on a disconnected connection fails with a clear error #640, unchanged.fetch()is now a data frame sink, thenfetch_into(), thenget_data().MariaDataFrameSink(src/MariaDataFrameSink.{h,cpp}) is the first sink. The R conversions moved there fromMariaRow.cpp.Why
dbFetch()with storage-aware column types #587) becomes a second sink, instead of a rewrite of the loop.Verification
test-queries.R: 250 bound rows fetched withn = 0,n = 3, then the rest, across parameter sets.saveRDS()output ofmainand this branch is identical for 9 column types (with NULLs and zero dates),n = -1, 0, 1, 2, 5, chunked fetches across parameter sets, rebinding, and a statement fetch.n = Inf, median of 7 runs in each of 3 interleaved processes:main0.294 / 0.302 / 0.300 s, this branch 0.278 / 0.267 / 0.301 s.Notes
append()throws is lost rather than redelivered, because it has already been fetched from the server. The header says so.dbFetch(n = 0)returns columns without S3 classes onmainalready, so Date and other columns come back unclassed. That is kept here and filed separately asdbFetch(n = 0)returns DATE, DATETIME and BIGINT columns without their classes #645.https://claude.ai/code/session_01Hr1rd7atAZVq1J42WzXJpS
Generated by Claude Code