fix(DBI): export SQL_* constants, add tables(), round-trip BLOB bytes#614
Merged
fix(DBI): export SQL_* constants, add tables(), round-trip BLOB bytes#614
Conversation
Fixes three issues surfaced by `jcpan -t CGI::Session::Auth`, whose
dependency chain pulls in CGI-Session-4.48 with three failing SQLite
tests (g4_sqlite.t, g4_sqlite_freezethaw.t, g4_sqlite_storable.t).
1. `use DBI qw(SQL_BLOB)` did not actually export anything — the
constants were declared via `use constant` but DBI.pm had no
Exporter setup, so the bareword tripped `strict subs` in
CGI::Session::Driver::sqlite. Add Exporter, @SQL_TYPES,
@EXPORT_OK, and a :sql_types tag.
2. `$dbh->tables()` was missing. Real DBI provides it on top of
table_info; CGI::Session's t/g4_sqlite.t uses it to detect
existing tables. Implement DBI::db::tables in Perl, quoting
names so callers stripping `['"]` keep working.
3. `table_info(..., "TABLE,VIEW")` returned no rows because JDBC's
getTables() takes a String[] of types, not a comma-joined
string. Split on commas, and treat undef/empty catalog/schema/
table as null.
4. `bind_param($p, $bytes, SQL_BLOB)` round-tripped through UTF-8,
corrupting Storable::freeze output stored in SQLite TEXT
columns (`thaw failed: Illegal base64 character …`). The
bound_attrs map was stored but never consulted in execute().
Now: SQL_BLOB / SQL_BINARY / SQL_VARBINARY / SQL_LONGVARBINARY
(also `{TYPE => …}` hashref) → setBytes(ISO_8859_1). On the
read side, when getObject() returns a byte[] (BLOB column),
decode as ISO-8859-1 and tag BYTE_STRING so each Perl byte
stays a byte.
Result:
- CGI-Session-4.48: 45/48 → 48/48 PASS
- CGI-Session-Auth-1.07: t/base.t + t/dbi.t = 18/18 PASS
- `make` (full unit suite) still passes
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
Fixes three PerlOnJava DBI gaps surfaced by
jcpan -t CGI::Session::Auth. The dependency chain pulls in CGI-Session-4.48 with three failing SQLite tests, which then blocked CGI-Session-Auth from getting an installed CGI::Session to test against.use DBI qw(SQL_BLOB)did not export anything — constants were declared viause constantbutDBI.pmhad no Exporter setup, so the bareword trippedstrict subsinCGI::Session::Driver::sqlite. AddedExporter,@SQL_TYPES,@EXPORT_OK, and:sql_typestag.$dbh->tables()was missing. ImplementedDBI::db::tablesin Perl on top oftable_info, quoting names so callers stripping['"]keep working (e.g.t/g4_sqlite.t).table_info(..., "TABLE,VIEW")returned no rows because JDBC'sgetTables()takes aString[]. Now split on commas; treat undef/empty catalog/schema/table asnull.bind_param($p, $bytes, SQL_BLOB)round-tripped through UTF-8, corruptingStorable::freezeoutput stored in SQLite TEXT columns (thaw failed: Illegal base64 character …). Thebound_attrsmap was stored but never consulted inexecute(). Now SQL_BLOB / SQL_BINARY / SQL_VARBINARY / SQL_LONGVARBINARY (also{TYPE => …}hashref) callsetBytes(ISO_8859_1), and on read, whengetObject()returnsbyte[], decode as ISO-8859-1 and tagBYTE_STRINGso each Perl byte stays a byte.Test plan
t/g4_sqlite.t,t/g4_sqlite_freezethaw.t,t/g4_sqlite_storable.t)t/base.t+t/dbi.t= 18/18 PASSmake(full unit suite) passesmake test-bundled-modules: same 2 pre-existing failures asmaster(Net-SSLeay/33_x509_create_cert.t,Text-CSV/55_combi.t); no new regressionsGenerated with Devin