fix(DBI): wire Exporter + :sql_types/:sql_cursor_types/:utils tags#540
Closed
fix(DBI): wire Exporter + :sql_types/:sql_cursor_types/:utils tags#540
Conversation
The bundled DBI.pm declared SQL_* constants but never set up
@EXPORT_OK / %EXPORT_TAGS, so `use DBI qw(:sql_types ...)` (which
essentially every DBI test uses) pulled nothing into the caller's
namespace and failed at compile time with "Bareword SQL_GUID not
allowed while strict subs in use".
This change:
- makes DBI inherit from Exporter and registers the four standard
export tags (sql_types, sql_cursor_types, utils, profile);
- adds the constants that were missing (SQL_INTERVAL_*,
SQL_ARRAY_LOCATOR, SQL_MULTISET_LOCATOR, SQL_CURSOR_*,
DBIstcf_STRICT/DISCARD_STRING);
- ports the small utility functions from DBI / DBI::PurePerl
(neat, neat_list, looks_like_number, data_string_diff,
data_string_desc, data_diff, dump_results, sql_type_cast,
dbi_time) into a sibling DBI::_Utils module, required by
DBI.pm. The utils live in a separate .pm so PerlOnJava
compiles them to their own JVM class; combining everything
into a single DBI.pm tripped a per-method bytecode limit
in our backend.
Effect on `jcpan -t DBI`:
before: 200 files, 562 subtests, 308 passing, 254 failing
after: 200 files, 638 subtests, 368 passing, 270 failing
The remaining failures are unrelated issues (missing
DBI::install_driver / DBI::_new_drh, DBD::File / DBD::DBM /
gofer / DBI::PurePerl not implemented, plus a separate bytecode
verifier bug on very large flat test scripts).
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This was referenced Apr 22, 2026
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
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>
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
The bundled
DBI.pmdefinedSQL_GUID,SQL_WLONGVARCHAR, etc. as constants but never set up@EXPORT_OK/%EXPORT_TAGS, souse DBI qw(:sql_types ...)— which essentially every DBI test starts with — pulled nothing into the caller's namespace and failed with "Bareword SQL_GUID not allowed while strict subs in use" at line 54 oft/01basics.t. That single missing piece caused ~180/200 DBI test files to abort on compile.This PR:
DBIinherit fromExporterand registers the four standard export tags::sql_types,:sql_cursor_types,:utils,:profile.SQL_INTERVAL_*,SQL_ARRAY_LOCATOR,SQL_MULTISET_LOCATOR,SQL_CURSOR_*,DBIstcf_STRICT,DBIstcf_DISCARD_STRING.DBI/DBI::PurePerl—neat,neat_list,looks_like_number,data_string_diff,data_string_desc,data_diff,dump_results,sql_type_cast,dbi_time— into a siblingDBI::_Utilsmodule, whichDBI.pmrequires. The utils live in a separate.pmbecause combining them intoDBI.pmtripped a per-method bytecode limit in PerlOnJava's backend; splitting into a separate file makes the compiler emit a separate JVM class.Effect on
jcpan -t DBIRoughly 60 more subtests now pass and 76 more subtests actually execute (instead of aborting before they could print a plan).
Remaining work (out of scope for this PR)
DBI->install_driver/DBI::_new_drhare not implemented — blockst/02dbidrv.tpast line 155.DBD::File/DBD::DBM/DBI::PurePerl/DBD::Goferpaths not implemented.t/01basics.t(200+ top-levelcmp_okcalls compile into a single method that exceeds JVM local-variable limits). Needs to be handled compiler-side.Test plan
make(unit tests) passes../jperl -e 'use DBI qw(:sql_types :sql_cursor_types :utils); print SQL_GUID, SQL_CURSOR_FORWARD_ONLY, neat("hi")'returns the expected values.jcpan -t DBIstill fails overall (many unrelated upstream issues), but subtest pass count goes up by ~60 and 76 more subtests now run far enough to print their plan.Generated with Devin