Skip to content

Add DBD::Pg compatibility shim backed by JDBC #1107

Description

@fglock

Summary

Add a PerlOnJava DBD::Pg compatibility shim backed by the existing
DBD::JDBC infrastructure and a PostgreSQL JDBC driver.

Motivation

PerlOnJava already provides DBI through JDBC and has a working DBD::JDBC
base driver plus a DBD::SQLite DSN-translation shim. However, CPAN modules
that use the conventional dbi:Pg: DSN or declare DBD::Pg currently cannot
use PostgreSQL through PerlOnJava without a native libpq/XS driver.

MetaCPAN lists 83 distributions depending directly on DBD::Pg, including
recent and actively maintained projects such as:

  • App::Netdisco
  • DBIx::Auto::Migrate
  • Lilith
  • DBIO::PostgreSQL
  • Mojo::Pg
  • Yote::SQLObjectStore
  • DBD::Patroni
  • IO::Async::Pg
  • Tapper::Schema

Reverse-dependency evidence:
https://metacpan.org/module/DBD%3A%3APg/requires

Proposed scope

  • Add src/main/perl/lib/DBD/Pg.pm as a PerlOnJava compatibility driver.
  • Inherit the common handle implementation from DBD::JDBC.
  • Translate common DSNs such as:
    • dbi:Pg:dbname=name
    • dbi:Pg:dbname=name;host=host;port=5432
      into PostgreSQL JDBC URLs.
  • Preserve standard DBI operations: connect, prepare, execute, fetch,
    transactions, metadata, quoting, and error handling.
  • Keep the PostgreSQL JDBC connector optional and use the existing
    Configure.pl/classpath driver configuration path.
  • Add focused DSN and handle tests without requiring a live server, plus an
    optional integration suite against PostgreSQL when a JDBC driver and server
    are available.

PostgreSQL-specific compatibility

The first milestone should target ordinary DBI consumers. Follow-up work may
be needed for:

  • PostgreSQL arrays, jsonb, bytea, and other type mappings.
  • COPY operations.
  • Notifications and asynchronous queries.
  • Server-side prepare behavior.
  • pg_* database and statement-handle methods.
  • PostgreSQL-specific SSL, socket, and connection attributes.

Unsupported PostgreSQL-specific behavior should be reported clearly rather
than silently emulated incorrectly. The shim should not perform broad SQL
rewriting; PostgreSQL SQL semantics should come from the PostgreSQL JDBC
driver.

Acceptance criteria

  • use DBD::Pg succeeds under PerlOnJava without XS loading.
  • Standard DBI->connect('dbi:Pg:...', ...) reaches the PostgreSQL JDBC
    driver.
  • A PostgreSQL-backed smoke test exercises schema introspection, prepared
    statements, transactions, parameter binding, and error propagation.
  • JVM and interpreter backends have equivalent behavior for the shim.
  • At least one representative CPAN consumer can connect using its normal
    DBD::Pg DSN once PostgreSQL and the JDBC driver are supplied.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions