Skip to content

fix(DBI): export SQL_* constants, add tables(), round-trip BLOB bytes#614

Merged
fglock merged 1 commit intomasterfrom
feature/dbi-blob-export-tables
Apr 29, 2026
Merged

fix(DBI): export SQL_* constants, add tables(), round-trip BLOB bytes#614
fglock merged 1 commit intomasterfrom
feature/dbi-blob-export-tables

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 29, 2026

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 via use constant but DBI.pm had no Exporter setup, so the bareword tripped strict subs in CGI::Session::Driver::sqlite. Added Exporter, @SQL_TYPES, @EXPORT_OK, and :sql_types tag.
  • $dbh->tables() was missing. Implemented DBI::db::tables in Perl on top of table_info, quoting names so callers stripping ['"] keep working (e.g. t/g4_sqlite.t).
  • table_info(..., "TABLE,VIEW") returned no rows because JDBC's getTables() takes a String[]. Now split on commas; treat undef/empty catalog/schema/table as null.
  • 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) call setBytes(ISO_8859_1), and on read, when getObject() returns byte[], decode as ISO-8859-1 and tag BYTE_STRING so each Perl byte stays a byte.

Test plan

  • CGI-Session-4.48: 45/48 → 48/48 PASS (incl. t/g4_sqlite.t, t/g4_sqlite_freezethaw.t, t/g4_sqlite_storable.t)
  • CGI-Session-Auth-1.07: t/base.t + t/dbi.t = 18/18 PASS
  • make (full unit suite) passes
  • make test-bundled-modules: same 2 pre-existing failures as master (Net-SSLeay/33_x509_create_cert.t, Text-CSV/55_combi.t); no new regressions

Generated with Devin

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>
@fglock fglock merged commit 36ce115 into master Apr 29, 2026
2 checks passed
@fglock fglock deleted the feature/dbi-blob-export-tables branch April 29, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant