NAME
DBIO::PostgreSQL::Introspect::Sequences - Introspect PostgreSQL sequences
VERSION
version 0.900007
DESCRIPTION
Fetches sequence metadata from pg_catalog.pg_sequence, including ownership information (the table and column the sequence is attached to via pg_depend), start value, increment, min/max bounds, cache size, cycle flag, and data type. The sequences an installed extension owns (a pg_depend row of deptype e) are left out: CREATE EXTENSION / DROP EXTENSION own them.
A sequence belongs to a column when pg_depend ties it to one: deptype a for a serial column and for ALTER SEQUENCE ... OWNED BY, deptype i for an identity column. Both are reported as owned, and is_identity tells the second from the first. Such a sequence goes where its table goes -- it is dropped with the column -- so the one behind a column of an extension's member table is left out along with that table, although no member row of its own says so.
The two are not the same kind of thing. A sequence a column owns is an object of its own: CREATE SEQUENCE makes it, a default calls it by name, ALTER SEQUENCE ... OWNED BY ties it to the column, and it can be given to another column or to none. The sequence of an identity column is a part of that column: GENERATED ... AS IDENTITY makes it and DROP IDENTITY takes it, and PostgreSQL has no other statement for either. DBIO::PostgreSQL::Diff::Sequence creates the first kind and leaves the second to the column.
METHODS
fetch
my $sequences = DBIO::PostgreSQL::Introspect::Sequences->fetch($dbh, $filter);
Returns a hashref keyed by schema.sequence_name. Each entry has: schema_name, sequence_name, owned_by_table, owned_by_table_name, owned_by_column, is_identity, start_value, increment, min_value, max_value, cache_size, is_cycle, data_type.
The table a sequence belongs to is there twice. owned_by_table_name is its name as the catalog has it; its schema is the sequence's, PostgreSQL ties a sequence to no table of another schema. owned_by_table is that table as the session reads it (regclass): quoted where the name needs it, and with its schema only where the session's search_path does not find the table. It is for a reader, and is neither a key of the model nor a name to quote. All three owned_by_* are undef for a sequence no column owns.
is_identity is true for the sequence of an identity column and false for every other.
data_type is what the sequence counts in (smallint, integer, bigint), start_value where it started, not where it stands.
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.