NAME

DBIO::PostgreSQL::Introspect::Functions - Introspect PostgreSQL functions

VERSION

version 0.900007

DESCRIPTION

Fetches function and procedure metadata from pg_catalog.pg_proc. The full function definition is retrieved via pg_get_functiondef. System functions (in pg_* and information_schema schemas) are excluded, and so are the member functions of an installed extension (a pg_depend row of deptype e): CREATE EXTENSION / DROP EXTENSION own them, so they are not the schema's to create or drop one by one.

Left out as well are the functions PostgreSQL made as part of another object (a pg_depend row of deptype i, "internal_part_filter" in DBIO::PostgreSQL::Introspect): the constructor functions of a range type and of its multirange type. CREATE TYPE ... AS RANGE makes them and DROP TYPE takes them; the type is in the model (DBIO::PostgreSQL::Introspect::Types), and they are part of it.

METHODS

fetch

my $functions = DBIO::PostgreSQL::Introspect::Functions->fetch($dbh, $filter);

Returns a hashref keyed by schema.function_name(identity_args). Each entry has: schema_name, function_name, identity_args, definition (full source from pg_get_functiondef), language, volatility (i/s/v), is_strict, security_definer, return_type, kind (pg_proc.prokind: f function, p procedure, a aggregate, w window function) and input_types, the types of the arguments the server files the routine by (pg_proc.proargtypes, comma separated, written like identity_args): one function or procedure per schema, name and input_types, so a function and a procedure with the same ones can not stand side by side whatever the names and modes of their arguments ("diff" in DBIO::PostgreSQL::Diff::Function).

An aggregate and a window function have no definition (undef): pg_get_functiondef raises an error for them. They carry a fingerprint instead, the text of the catalog rows that define them (pg_aggregate; for a window function the language, source and library), so that two models can be told apart. The diff does not write one from it ("diff" in DBIO::PostgreSQL::Diff::Function).

identity_args, return_type and the head of definition are written by the server for the session that asks, without the schema of a type that session's search_path finds -- and identity_args is part of the key. In a model read with "qualified_names" in DBIO::PostgreSQL::Introspect (the default) every type outside pg_catalog comes with its schema, in the key too (app.label(s app.status)); read without it the same function is filed under two keys by two sessions with another search_path.

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.