NAME

DBIO::PostgreSQL::Storage - PostgreSQL storage layer for DBIO

VERSION

version 0.900000

DESCRIPTION

DBIO::PostgreSQL::Storage is the DBI storage class for PostgreSQL. It extends DBIO::Storage::DBI with PostgreSQL-specific behaviour:

  • INSERT ... RETURNING for efficient last-insert-id retrieval (PostgreSQL 8.2+).

  • Deferred foreign key checks via SET CONSTRAINTS ALL DEFERRED.

  • Sequence lookup via pg_catalog when RETURNING is not available.

  • BYTEA column binding through DBD::Pg native type constants.

  • Native savepoint support via pg_savepoint, pg_release, and pg_rollback_to.

  • Deployment via DBIO::PostgreSQL::DDL when the schema has the DBIO::PostgreSQL component loaded, falling back to SQL::Translator otherwise.

This class is registered as the driver for the Pg DBD and is selected automatically when DBIO::PostgreSQL is loaded into a schema class. Schema-introspection and migration planning live in DBIO::PostgreSQL::Introspect, DBIO::PostgreSQL::Diff, and DBIO::PostgreSQL::Deploy; this class stays focused on the live DBI storage behaviour.

METHODS

with_deferred_fk_checks

$storage->with_deferred_fk_checks(sub { ... });

Wraps the given coderef in a transaction with SET CONSTRAINTS ALL DEFERRED, restoring immediate constraint checking afterwards. Use this when bulk-loading data that temporarily violates referential integrity.

last_insert_id

my @ids = $storage->last_insert_id($source, @cols);

Returns the last inserted value(s) for the given column(s) by querying the associated sequence via pg_catalog. Only called when INSERT ... RETURNING is unavailable (PostgreSQL older than 8.2). The sequence is determined from the column default expression.

bind_attribute_by_data_type

my $attr = $storage->bind_attribute_by_data_type($data_type);

Returns { pg_type => DBD::Pg::PG_BYTEA() } for binary LOB types so that DBD::Pg handles BYTEA columns correctly. Also checks that a compatible DBD::Pg version is installed for the connected PostgreSQL server version.

deploy

$storage->deploy($schema, $type, $sqltargs, $dir);

Deploys the schema. When the schema has the DBIO::PostgreSQL component loaded (i.e. $schema->can('pg_deploy') is true), delegates to "install" in DBIO::PostgreSQL::Deploy. Otherwise falls back to the parent SQL::Translator-based deployment.

deployment_statements

my $sql = $storage->deployment_statements($schema, ...);

Generates DDL statements for deployment. When the schema has pg_install_ddl, returns native PostgreSQL DDL from DBIO::PostgreSQL::DDL. Otherwise falls back to SQL::Translator, passing the detected server version as postgres_version to the producer.

cake_defaults

Returns PostgreSQL-optimized defaults for DBIO::Cake. Activated via use DBIO::Cake '-Pg'.

  • inflate_jsonb — on (PostgreSQL standard is jsonb, not json)

  • inflate_datetime — on

  • retrieve_defaults — on (PostgreSQL generates UUIDs, serials, NOW(), etc.)

AUTHOR

DBIO & DBIx::Class Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 380:

Unknown directive: =seealso