feat(DBI): driver-architecture + pure-Perl DBD support#544
Closed
fglock wants to merge 1 commit intofix/dbi-verifier-fallbackfrom
Closed
feat(DBI): driver-architecture + pure-Perl DBD support#544fglock wants to merge 1 commit intofix/dbi-verifier-fallbackfrom
fglock wants to merge 1 commit intofix/dbi-verifier-fallbackfrom
Conversation
Previously `use DBI; DBI->install_driver("NullP")` died with
"Undefined subroutine &DBI::install_driver". The bundled DBI.pm
talked to the Java DBI backend only, bypassing the DBI driver
architecture (DBD::<name>::driver factories, DBI::_new_drh/dbh/sth,
DBD::_::common / dr / db / st base classes). That path covers JDBC
drivers (SQLite, H2, ...) but not the pure-Perl DBDs bundled with
upstream DBI — DBD::NullP, DBD::ExampleP, DBD::Sponge, DBD::Mem,
DBD::File, DBD::DBM — which the DBI self-tests rely on extensively.
This change adds the minimum driver-architecture pieces needed by
those DBDs, in a new file src/main/perl/lib/DBI/_Handles.pm:
* DBI->install_driver / installed_drivers / data_sources /
available_drivers / setup_driver;
* DBI::_new_drh / _new_dbh / _new_sth (handle factories,
returning plain blessed hashrefs — no tie magic);
* DBI::_get_imp_data (stub);
* DBD::_::common / dr / db / st base classes with FETCH, STORE,
err, errstr, state, set_err, trace, trace_msg,
parse_trace_flag(s), func, dump_handle, visit_child_handles,
default connect / connect_cached, quote, quote_identifier,
data_sources, disconnect, commit, rollback, ping, finish,
fetchrow_array, fetchrow_hashref, rows, bind_col(s),
bind_param(_array), execute_array, _set_fbav;
* Stub DBI::dr / DBI::db / DBI::st packages so `isa('DBI::dr')`
succeeds; DBD::_::<suffix> inherits from DBI::<suffix>.
DBI.pm's connect wrapper now detects a pure-Perl DBD (has `driver()`
but no `_dsn_to_jdbc`) and routes through
`install_driver($name)->connect(...)` instead of the JDBC backend.
Lives in a separate .pm for the same per-method bytecode-size
reason as DBI/_Utils.pm from PR #540.
Effect on `jcpan -t DBI` (stacked on PR #542):
before: 200 files, 946 subtests, 676 passing, 270 failing
after: 200 files, 1600 subtests, 1240 passing, 360 failing
=> +564 subtests now pass (+654 newly executed). 10 fewer test
files fail overall; the remaining failures are real DBI-level
issues (DBI::PurePerl, DBD::File/DBM/Gofer, a handful of
handle-tracking edge cases) tracked as Phase 3 in the plan.
See dev/modules/dbi_test_parity.md.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
5 tasks
Owner
Author
|
Superseded by unified PR (see new PR). All four commits rebased into a single branch targeting master. |
7 tasks
fglock
added a commit
that referenced
this pull request
Apr 23, 2026
Phase 3 first batch of the DBI test-parity plan: add the methods
the DBI self-tests and the bundled pure-Perl DBDs
(DBD::File / DBD::DBM / DBD::Sponge / DBD::Mem / DBI::DBD::SqlEngine)
call on DBI and on handles.
Top-level DBI methods / helpers:
* DBI->internal (fake DBD::Switch::dr drh, isa('DBI::dr'))
* DBI->parse_dsn
* DBI->driver_prefix (accepts both 'File' and 'DBD::File')
* DBI->dbixs_revision
* DBI->install_method / DBI->_install_method
* DBI::hash (ported from DBI::PurePerl)
* DBI::_concat_hash_sorted
* DBI::dbi_profile / dbi_profile_merge / dbi_profile_merge_nodes
* DBI->data_sources now accepts "dbi:DRIVER:" form.
Trace fix in DBI.pm:
* DBI->trace / DBI->trace_msg now work as class methods
(previously crashed on strict refs when the invocant was "DBI").
DBD::_::db base class:
* do, prepare_cached
* selectrow_array / _arrayref / _hashref
* selectall_arrayref / _hashref
* selectcol_arrayref
* type_info stub
DBD::_::st base class:
* fetchall_arrayref (plain / slice / hash)
* fetchall_hashref
* _get_fbav
* FETCH override computing NAME_lc / NAME_uc / NAME_hash /
NAME_lc_hash / NAME_uc_hash from NAME when called via
$sth->FETCH(...). Direct $sth->{NAME_lc} access still requires
tied-hash semantics, which we do not provide.
DBD::_::common base class:
* FETCH_many, debug, dbixs_revision, install_method, dump_handle.
Effect on `jcpan -t DBI` (stacked on #544):
before: 200 files, 1600 subtests, 1240 passing, 360 failing
after: 200 files, 5610 subtests, 3978 passing, 1632 failing
=> +2738 subtests now pass (+4010 more executed). 4 fewer test
files fail overall. The remaining 166 files are dominated by
(a) DBD::File / DBD::DBM-specific methods not yet wired and
(b) tied-hash-dependent attribute access.
Cumulative across the four stacked PRs (#540, #542, #544, this one):
master: 562 subtests, 308 passing
now: 5610 subtests, 3978 passing (~13× more passes)
See dev/modules/dbi_test_parity.md.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
Summary
Previously
use DBI; DBI->install_driver("NullP")died withUndefined subroutine &DBI::install_driver. The bundledDBI.pmtalked to the Java DBI backend only, bypassing the DBI driver architecture (DBD::<name>::driverfactories,DBI::_new_drh/_new_dbh/_new_sth,DBD::_::common/dr/db/stbase classes). That path covers JDBC drivers (SQLite, H2, ...) but not the pure-Perl DBDs bundled with upstream DBI —DBD::NullP,DBD::ExampleP,DBD::Sponge,DBD::Mem,DBD::File,DBD::DBM— which the DBI self-tests rely on extensively.This PR adds the minimum driver-architecture pieces needed by those DBDs, in a new file
src/main/perl/lib/DBI/_Handles.pm:DBI->install_driver/installed_drivers/data_sources/available_drivers/setup_driver;DBI::_new_drh/_new_dbh/_new_sth(handle factories, returning plain blessed hashrefs — no tie magic);DBI::_get_imp_data(stub);DBD::_::common/dr/db/stbase classes withFETCH,STORE,err,errstr,state,set_err,trace,trace_msg,parse_trace_flag(s),func,dump_handle,visit_child_handles, defaultconnect/connect_cached,quote,quote_identifier,data_sources,disconnect,commit,rollback,ping,finish,fetchrow_array,fetchrow_hashref,rows,bind_col(s),bind_param(_array),execute_array,_set_fbav;DBI::dr/DBI::db/DBI::stpackages soisa('DBI::dr')succeeds;DBD::_::<suffix>inherits fromDBI::<suffix>.DBI.pm'sconnectwrapper now detects a pure-Perl DBD (hasdriver()but no_dsn_to_jdbc) and routes throughinstall_driver($name)->connect(...)instead of the JDBC backend.Lives in a separate
.pmfor the same per-method bytecode-size reason asDBI/_Utils.pmfrom #540.Effect on
jcpan -t DBI(stacked on #542)+564 subtests now pass, +654 more are reached. 10 fewer test files fail overall. The remaining failures are real DBI-level issues (
DBI::PurePerl,DBD::File/DBM/Gofer, a handful of handle-tracking edge cases) tracked as Phase 3 indev/modules/dbi_test_parity.md.Depends on
Test plan
make(full unit tests) passes../jperl -e 'use DBI; my $drh = DBI->install_driver("NullP"); my $dbh = DBI->connect("dbi:NullP:", "", ""); my $sth = $dbh->prepare("SELECT 1"); $sth->execute'now works../jperl ~/.cpan/build/DBI-1.647-5/t/02dbidrv.truns 37+ subtests (previously: died on line 155 withCan't locate object method install_driver).jcpan -t DBIbaseline matches the table above.Generated with Devin