NAME

DBIO::Informix::Introspect - Introspect an Informix database via its system catalog

VERSION

version 0.900007

DESCRIPTION

DBIO::Informix::Introspect reads the live state of an Informix database via its system catalog (systables, syscolumns, sysindexes, sysconstraints, sysreferences, sysdefaults, sysviews) and returns a unified model hashref. It is the source side of the test-deploy-and-compare strategy used by DBIO::Informix::Deploy.

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

Model shape mirrors DBIO::SQLite::Introspect:

{
    tables       => { $name => { ... } },
    columns      => { $table => [ { ... }, ... ] },
    indexes      => { $table => { $name => { ... } } },
    foreign_keys => { $table => [ { ... }, ... ] },
    unique_constraints => { $table => [ { constraint_name => 'u', columns => [ ... ] }, ... ] },
}

A view is a table of kind view and carries its definition (the CREATE VIEW text the server keeps).

ATTRIBUTES

dbh

A connected DBI handle for Informix. Required.

The readers (Tables, Columns, Indexes, ForeignKeys) are measured against Informix 15.0.1; t/60-introspect-live.t runs them on a server.

schema

The name of the database whose catalog is read (the "database":informix qualifier of the sys* tables). Defaults to the database the handle is connected to.

METHODS

table_columns_info

my \%info = %{ $intro->table_columns_info($key) };

Hashref of column metadata keyed by column name. Unlike the DBIO::Introspect::Base default, the default_value and size keys are omitted entirely when their value is undef -- DBIO::Generate probes for key presence with exists(), and a literal undef would trigger spurious matches.

table_uniq_info

my \@constraints = @{ $intro->table_uniq_info($key) };

List of [ $constraint_name, \@col_names ] pairs. The unique index backing the primary key is excluded by matching the PK's column signature -- the canonical origin => 'pk' marker is not available on Informix introspected indexes.

table_fk_info

my \@fks = @{ $intro->table_fk_info($key) };

Each FK is a hashref as described in DBIO::Introspect::Base. Informix's raw upd_rule / del_rule are mapped to the canonical on_update / on_delete attrs, and the raw constraint name is preserved as constraint_name for downstream callers.

NORMALIZED CONTRACT

DBIO::Introspect::Base ships default implementations of table_keys, table_columns, table_pk_info and table_is_view that read the canonical model shape. Informix's model is canonical (bare table names, declaration-ordered columns, kind on tables, is_pk/pk_position on columns) so all four are inherited unchanged.

Three methods are overridden because Informix's model or Generate's expectations diverge from the canonical defaults:

  • "table_columns_info" -- the canonical default always emits default_value, even when undef. DBIO::Generate styles test key presence with exists(), so a literal undef would emit a spurious key. We omit default_value and size keys when their value is undef.

  • "table_uniq_info" -- the canonical default excludes an index from unique constraints when origin => 'pk' or uc($name) eq 'PRIMARY'. The Informix introspector does not record origin, so the PRIMARY name check alone is insufficient; the PK signature must be matched by column list.

  • "table_fk_info" -- Informix's foreign-key rows carry upd_rule / del_rule; the canonical default expects on_update / on_delete. We map between them and attach constraint_name for downstream callers that need the raw IBM name.

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.