NAME

DBIO::Firebird::Introspect - Introspect a Firebird database via rdb$ system tables

VERSION

version 0.900004

DESCRIPTION

DBIO::Firebird::Introspect reads the live state of a Firebird database via the rdb$* system tables and returns a unified model hashref. It is the source side of the test-deploy-and-compare strategy used by DBIO::Firebird::Deploy.

my $intro = DBIO::Firebird::Introspect->new(dbh => $dbh);
my $model = $intro->model;
# $model->{tables}, $model->{columns}, $model->{indexes},
# $model->{unique_constraints}, $model->{foreign_keys}

The model is built lazily on first access and has five top-level sections: tables, columns, indexes, unique_constraints, and foreign_keys (views are surfaced within the tables section, not as a separate top-level key). On top of it, this class implements the normalized generation contract from DBIO::Introspect::Base so it can act as a DBIO::Generate source.

THE INTROSPECTED MODEL

The model hashref returned by model is the shared substrate of this distribution: produced here by the Introspect::* helpers, consumed by DBIO::Firebird::Diff (table/column/index comparison) and by the "NORMALIZED CONTRACT" methods below (the DBIO::Generate source). It has exactly five top-level sections — tables, columns, indexes, unique_constraints, and foreign_keys — each a hashref keyed by table name (Firebird has no schemas, so keys are bare, un-qualified relation names).

tables

{ $table_name => { table_name => $name, kind => 'table' | 'view',
                   view_source => $text, primary_key_name => $name } }

view_source exists for a view only: rdb$relations.rdb$view_source, the query after AS as the server stores it (no trailing semicolon). The diff compares it with whitespace normalised ("VIEWS" in DBIO::Firebird::Diff).

primary_key_name exists for a table with a primary key: the name of its constraint in rdb$relation_constraints, the server's INTEG_<n> unless the table was created with a named key. Dropping the key needs it (DBIO::Firebird::Diff::Constraint).

columns

{ $table_name => [ \%column, ... ] }   # in rdb$field_position order

Each column hashref:

  • column_name — the column name.

  • data_type — the bare SQL type (e.g. 'integer', 'decimal', 'varchar'). Size/precision is not folded in here; it lives in size. The names are the ones the server reports: smallint, integer, bigint, numeric, decimal, float, double precision, char, varchar, binary, varbinary (CHAR/VARCHAR in character set OCTETS), date, time, timestamp, boolean, blob (binary) and blob sub_type text, and for Firebird 4+ int128, decfloat, time with time zone, timestamp with time zone. See "sql_type_from_rdb" in DBIO::Firebird::Type.

  • size — undef, a scalar length (char/varchar/binary/ varbinary, or the digit count of decfloat), or an [ precision, scale ] pair (decimal/numeric). Rendered to SQL via "render_size" in DBIO::Firebird::Type.

  • not_null — 1 if the column is NOT NULL, else 0 (from rdb$null_flag).

  • default_value — the column default expression, or undef.

  • is_auto_increment — 1 for an identity column (GENERATED ... AS IDENTITY, rdb$identity_type not NULL), else 0. Both kinds, ALWAYS and BY DEFAULT, read as 1; this driver writes only BY DEFAULT.

  • is_pk / pk_position — primary-key membership and 0-based position (rdb$field_position).

indexes

{ $table_name => { $index_name => { index_name, is_unique, columns => [...] } } }

Indexes backed by PRIMARY KEY / UNIQUE constraints are excluded — they belong to the table definition, not an explicit CREATE INDEX.

unique_constraints

{ $table_name => [ [ $constraint_name, \@column_names ], ... ] }

UNIQUE constraints (distinct from the CREATE UNIQUE INDEX objects in indexes), sorted by constraint name. Source of the table_uniq_info contract method.

foreign_keys

{ $table_name => [ \%fk, ... ] }

Each FK hashref: constraint_name, from_table, from_columns, to_table, to_columns, and the referential actions on_update, on_delete, match (from rdb$ref_constraints).

NORMALIZED CONTRACT

The DBIO::Generate generation contract (table_keys, table_columns, table_columns_info, table_pk_info, table_uniq_info, table_fk_info, table_is_view) is inherited unchanged from DBIO::Introspect::Base: the model built by _build_model follows the canonical single-schema shape (see "CANONICAL MODEL" in DBIO::Introspect::Base) that those default implementations read, so no Firebird-specific override is needed. In particular unique_constraints is the authoritative source for table_uniq_info, and FK remote_schema is always undef (Firebird has no schemas).

SEE ALSO

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.