Repository navigation
Conversation
cjac
force-pushed
the
feature/dbi-non-blocking-core
branch
from
December 2, 2026 19:59
3a29e36 to
5baccdd
Compare
cjac
force-pushed
the
feature/dbi-non-blocking-core
branch
from
December 2, 2026 21:40
5baccdd to
c5eccd6
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.
Add DBI Non-Blocking Async Core Support (
perl5-dbi/dbi#185)Overview
This pull request bridges
DBD::Pg's existinglibpqasynchronous execution plumbing (PG_ASYNC,pg_ready,pg_result,pg_socket) to the new DBI core non-blocking asynchronous interface proposed inperl5-dbi/dbi#185(documented inDBI::DBDunder ASYNCHRONOUS EXECUTION SUPPORT).All new code is gated on
#ifdef DBIcf_Async, soDBD::Pgremains 100% source- and binary-compatible with older DBI releases.Summary of Changes
Internal Driver Readiness Hooks (
Pg.xs)_async_read_ready()and_async_write_ready()on bothDBD::Pg::dbandDBD::Pg::stunder#ifdef DBIcf_Async(wrapped by DBI core into$on_ready_cbforDBI::EventLoopbackends)._async_read_ready()pollspg_db_ready(); if still busy (0), returns0without clearing flags; once complete (> 0), clearsAsyncWantRead/AsyncWantWriteviaDBIh_ASYNC_CLEAR_WANT, emitson_removeviaDBIh_ASYNC_NOTIFY_WATCHER, and finalizes the result viapg_db_result()(returningundefstrictly on error)._async_write_ready()drivesPQflush()and clearsAsyncWantWriteonce the write buffer drains.Non-Blocking
execute()& Mid-Flight Teardown (dbdimp.c,dbdimp.h)dbd_st_execute(), whenDBIc_ASYNC(imp_sth)is active, enablesPG_ASYNCso allPQsendQuery/PQsendQueryParams/PQsendQueryPreparedpaths run non-blocking.AsyncWantRead(andAsyncWantWriteifPQflush()returns1), leaves$h->erruntouched (zero$h->erroverloading; callers inspectDBI::is_wouldblock($sth)), and notifies DBI's activeDBI::EventLoopwatcher (on_add) viaDBIh_ASYNC_NOTIFY_WATCHERwithPQsocket(conn).dbd_db_disconnect()anddbd_st_finish()emiton_removeand clearAsyncWantRead/AsyncWantWritebefore closing sockets or discarding pending results.Integration Test Suite (
t/09async_dbi.t)$dbh->{Async} = 1capability acceptance and inheritance onto prepared statement handles.$sth->execute()returns'0E0', setsAsyncWantRead(DBI::is_wouldblock($sth)true,$sth->erruntouched), and fireson_addwith$dbh->{pg_socket}and$on_ready_cb.AsyncWantRead, emitson_remove, and$sth->fetch_async_row()returns the expected result row.!defined &DBI::is_wouldblock).Testing
Tested against a live
postgres:17-alpinecontainer usingperl5-dbi/dbi#185(feature/non-blocking-core):t/08async.t: 127/127 passed (zero regressions on existingPG_ASYNCbehavior)t/09async_dbi.t: 14/14 passed