NAME

DBIO::PostgreSQL::Introspect::Parse - Pure parsers for raw PostgreSQL metadata strings

VERSION

version 0.900007

DESCRIPTION

Leaf module with pure-data parsers that turn raw pg_catalog strings (typically produced by pg_get_indexdef and reloptions) into the canonical Perl structures consumed by DBIO::Generate. None of these subs talk to the database or hold state; they are class methods that take scalars / arrayrefs and return arrayrefs / hashrefs.

DBIO::PostgreSQL::Introspect::Indexes no longer reads the INCLUDE columns and the operator classes of an index through /include_columns and /column_opclasses: it reads them from the catalog (pg_index.indnkeyatts, indclass, indoption), which keeps a sort order and an operator class in a quoted schema that these two lose. They remain as parsers of a definition string for whoever has only the text.

The parsers are:

  • "include_columns" -- extracts the INCLUDE (col1, col2, ...) clause from an index definition

  • "storage_params" -- decodes a reloptions array / string of key=value pairs into a hashref

  • "column_opclasses" -- extracts the per-column operator classes from the key-column list of an index definition

include_columns

my $cols = DBIO::PostgreSQL::Introspect::Parse->include_columns($def);

Returns an ArrayRef of column names listed in the INCLUDE (col, col) clause of the index definition $def. Returns [] when the clause is missing or the definition is undef. Column names are stripped of surrounding whitespace and double quotes.

storage_params

my $params = DBIO::PostgreSQL::Introspect::Parse->storage_params($reloptions);

Decodes reloptions (pg_class.reloptions) into a hashref. Accepts either a string of the form {key=value, key=value} or an ArrayRef of key=value strings. Returns {} for empty / undef input.

column_opclasses

my $ops = DBIO::PostgreSQL::Introspect::Parse->column_opclasses($def);

Returns a HashRef of column name to operator class name for every plain column in the key-column list of the index definition $def that carries a non-default operator class. pg_get_indexdef only prints the operator class when it is not the access method's default for the column type, so an empty hashref means "every column uses its default opclass" -- which is also what is returned for an undef / unparseable definition.

CREATE INDEX i ON t USING hnsw (embedding vector_cosine_ops)
  -> { embedding => 'vector_cosine_ops' }

Sort options (ASC, DESC, NULLS FIRST/LAST) and a COLLATE clause are recognised and skipped, so (name COLLATE "C" text_pattern_ops DESC) yields { name => 'text_pattern_ops' }. Operator class parameters (PostgreSQL 13+, e.g. tsvector_ops(siglen=32)) are kept with the name. Expression entries are ignored: their operator class cannot be attached to a column name, and it stays in the definition string that DBIO::PostgreSQL::Diff::Index compares.

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.