App::I...greSQL(3pm)
πΈ App::Info::RDBMS::PostgreSQL π
User Contributed Perl Documentation Β· App::Info::RDBMS::PostgreSQL(3pm)
okay bestie, sit down, hydrate, because we're about to learn everything about the PostgreSQL info-gathering module and it's honestly kinda iconic β¨
β¨ NAME β¨
App::Info::RDBMS::PostgreSQL β all the tea about PostgreSQL ππ
Basically: it's the little module that goes and finds out what's up with PostgreSQL on your machine. no cap.
π SYNOPSIS π
here's the vibe, copy-paste energy:
use App::Info::RDBMS::PostgreSQL;
my $pg = App::Info::RDBMS::PostgreSQL->new;
if ($pg->installed) {
print "App name: ", $pg->name, "\n";
print "Version: ", $pg->version, "\n";
print "Bin dir: ", $pg->bin_dir, "\n";
} else {
print "PostgreSQL is not installed. :-(\n";
}
like, you make the object, you ask if it's installed, and if it is you get the name, the version and the bin_dir. if it's not installed you get the sad face. it's giving detective but make it perl π΅οΈβοΈβ¨
π DESCRIPTION π
App::Info::RDBMS::PostgreSQL supplies information about the PostgreSQL database server installed on the local system. that's the whole job. it's a lil informant and it's very good at it π«Ά
it implements all of the methods defined by App::Info::RDBMS. all of them. the full set. no skips, no shortcuts, periodt π
now here's the important bit, bestie, so listen up:
- Methods that trigger events will trigger them only the first time they're called. (See
App::Infofor documentation on handling events.) - Wanna start over? say, someone finally installed PostgreSQL and you need the new deets? Construct a new
App::Info::RDBMS::PostgreSQLobject to aggregate new meta data. fresh object, fresh facts, that's the move π
π¦ the event thing (iykyk) π¦
some of the methods trigger the same events. this is due to cross-calling of shared subroutines β they're all borrowing each other's homework, respectfully π
but! any one event should be triggered no more than once. example time:
the info event "Executing `pg_config --version`" is documented for the methodsname(),version(),major_version(),minor_version(), andpatch_version()β but rest assured, it will only be triggered once, by whichever of those four methods is called first. π
so yeah, don't panic if you see the same event name listed in five places. it's one event. one. it's not gonna spam you. slay β¨
(more coming bestie, don't go anywhere) πΈ
π INTERFACE π
β¨ Constructor β¨
new
my $pg = App::Info::RDBMS::PostgreSQL->new(@params);
okay bestie, this hands you back an App::Info::RDBMS::PostgreSQL object π«Ά and if you wanna know everything about the arguments you can pass it, App::Info has the full rundown.
so the way new() works: it goes snooping around your file system looking for an executable with one of the names in the list that search_exe_names() gives you β usually pg_config β inside all the directories that search_bin_dirs() returns π. Found it? iconic. Then pg_config gets called by the object methods below to scoop up whatever data each one needs. If pg_config is nowhere to be found, then we just assume PostgreSQL isn't installed and every one of the object methods will hand you back undef π.
new() also takes a bunch of optional params on top of the ones App::Info already documents. These let you swap in alternate names for the PostgreSQL executables (anything other than pg_config, which you set with the search_exe_names parameter, iykyk). Here they are:
search_postgres_namessearch_createdb_namessearch_createlang_namessearch_createuser_namessearch_dropd_namessearch_droplang_namessearch_dropuser_namessearch_initdb_namessearch_pg_dump_namessearch_pg_dumpall_namessearch_pg_restore_namessearch_postmaster_namessearch_psql_namessearch_vacuumdb_names
Events:
infoβ Looking for pg_configconfirmβ Path to pg_config?unknownβ Path to pg_config?
π Class Method π
key_name
my $key_name = App::Info::RDBMS::PostgreSQL->key_name;
gives you the one-of-a-kind key name that describes this class, and the string it returns is literally PostgreSQL. periodt β¨
π Object Methods π
installed
print "PostgreSQL is ", ($pg->installed ? '' : 'not '), "installed.\n";
true if PostgreSQL is installed, false if it's not β no in-between. App::Info::RDBMS::PostgreSQL decides this purely based on whether the pg_config application was there on the file system back when new() built the object π. And if PostgreSQL doesn't look installed? every other object method returns empty values, rip π.
name
my $name = $pg->name;
returns the name of the application. App::Info::RDBMS::PostgreSQL parses it straight out of the system call `pg_config --version` πΈ.
Events:
infoβ Executing`pg_config --version`error- Failed to find PostgreSQL version with
`pg_config --version` - Unable to parse name from string
- Unable to parse version from string
- Failed to parse PostgreSQL version parts from string
- Failed to find PostgreSQL version with
unknownβ Enter a valid PostgreSQL name
version
my $version = $pg->version;
returns the PostgreSQL version number, parsed from the system call `pg_config --version` π.
Events:
infoβ Executing`pg_config --version`error- Failed to find PostgreSQL version with
`pg_config --version` - Unable to parse name from string
- Unable to parse version from string
- Failed to parse PostgreSQL version parts from string
- Failed to find PostgreSQL version with
unknownβ Enter a valid PostgreSQL version number
major version
my $major_version = $pg->major_version;
returns the PostgreSQL major version number, parsed from the system call `pg_config --version`. for example, if version() gives you 7.1.2, this method gives you 7 π₯.
Events:
infoβ Executing`pg_config --version`error- Failed to find PostgreSQL version with
`pg_config --version` - Unable to parse name from string
- Unable to parse version from string
- Failed to parse PostgreSQL version parts from string
- Failed to find PostgreSQL version with
unknownβ Enter a valid PostgreSQL major version number
minor version
my $minor_version = $pg->minor_version;
returns the PostgreSQL minor version number, parsed from the system call `pg_config --version`. say version() gives you 7.1.2 β then this one gives you 2 π
.
Events:
infoβ Executing`pg_config --version`error- Failed to find PostgreSQL version with
`pg_config --version` - Unable to parse name from string
- Unable to parse version from string
- Failed to parse PostgreSQL version parts from string
- Failed to find PostgreSQL version with
unknownβ Enter a valid PostgreSQL minor version number
patch version
my $patch_version = $pg->patch_version;
returns the PostgreSQL patch version number, parsed from the system call `pg_config --version`. and if version() is 7.1.2, this one gives you 1 π¦.
Events:
infoβ Executing`pg_config --version`error- Failed to find PostgreSQL version with
`pg_config --version` - Unable to parse name from string
- Unable to parse version from string
- Failed to parse PostgreSQL version parts from string
- Failed to find PostgreSQL version with
unknownβ Enter a valid PostgreSQL minor version number
executable
my $exe = $pg->executable;
returns the full path to the PostgreSQL server executable, which goes by the name postgres π. heads up though β this method does not use the executable names that search_exe_names() returns; those names are only used to hunt down pg_config (over in new()).
when you call it, executable() looks for an executable named postgres in the directory that bin_dir() gives you π.
and btw, executable() is literally just an alias for postgres() π«Ά.
Events:
infoβ Looking for postgres executableconfirmβ Path to postgres executable?unknownβ Path to postgres executable?
bin_dir
my $bin_dir = $pg->bin_dir;
returns the PostgreSQL binary directory path, scooped up from the system call `pg_config --bindir` β¨.
Events:
infoβ Executing`pg_config --bindir`errorβ Cannot find bin directoryunknownβ Enter a valid PostgreSQL bin directory
inc_dir
my $inc_dir = $pg->inc_dir;
returns the PostgreSQL include directory path, grabbed from the system call `pg_config --includedir` πΈ.
Events:
infoβ Executing`pg_config --includedir`errorβ Cannot find include directoryunknownβ Enter a valid PostgreSQL include directory
lib_dir
my $lib_dir = $pg->lib_dir;
returns the PostgreSQL library directory path, straight from the system call `pg_config --libdir` π.
Events:
infoβ Executing`pg_config --libdir`errorβ Cannot find library directoryunknownβ Enter a valid PostgreSQL library directory
so_lib_dir
my $so_lib_dir = $pg->so_lib_dir;
returns the PostgreSQL shared object library directory path, pulled from the system call `pg_config --pkglibdir` π§.
Events:
infoβ Executing`pg_config --pkglibdir`errorβ Cannot find shared object library directoryunknownβ Enter a valid PostgreSQL shared object library directory
configure options
my $configure = $pg->configure;
returns the options that the PostgreSQL server was configured with, gathered from the system call `pg_config --configure` π.
Events:
infoβ Executing`pg_config --configure`errorβ Cannot find configure informationunknownβ Enter PostgreSQL configuration options
home_url
my $home_url = $pg->home_url;
returns the PostgreSQL home page URL π.
download_url
my $download_url = $pg->download_url;
returns the PostgreSQL download URL β.
search_exe_names
my @search_exe_names = $app->search_exe_names;
returns a list of possible names for the pg_config executable. by default you just get pg_config (or pg_config.exe on Win32) π.
quick reminder bestie: this method is not used to search for the PostgreSQL server executable β only pg_config π
.
search_bin_dirs
my @search_bin_dirs = $app->search_bin_dirs;
returns a list of possible directories to search for an executable in. the new() constructor uses it to find an executable it can run to collect application info, and whatever directory it finds also gets returned by the bin_dir method π₯.
by default the list is made up of the path defined by File::Spec->path, plus these directories:
$ENV{POSTGRES_HOME}/bin(if$ENV{POSTGRES_HOME}exists)$ENV{POSTGRES_LIB}/../bin(if$ENV{POSTGRES_LIB}exists)/usr/local/pgsql/bin/usr/local/postgres/bin/opt/pgsql/bin/usr/local/bin/usr/local/sbin/usr/bin/usr/sbin/binC:\Program Files\PostgreSQL\bin
π¦ Other Executable Methods π¦
these methods work exactly like executable() does β the only difference is they hand back different executables π«. PostgreSQL ships with a whole bunch of them, and these methods give you a path to a subset of that set. each one, when called, checks for an executable in the directory that bin_dir() returns. and the name of that executable has to be one of the names that the matching search_*_names method returns π.
the executable methods available are:
postgrescreatedbcreatelangcreateuserdropdbdroplangdropuserinitdbpg_dumppg_dumpallpg_restorepostmasterpsqlvacuumdb
and the corresponding search names methods are:
search_postgres_namessearch_createdb_namessearch_createlang_namessearch_createuser_namessearch_dropd_namessearch_droplang_namessearch_dropuser_namessearch_initdb_namessearch_pg_dump_namessearch_pg_dumpall_namessearch_pg_restore_namessearch_postmaster_namessearch_psql_namessearch_vacuumdb_names
Events:
infoβ Looking for executableconfirmβ Path to executable?unknownβ Path to executable?
πΈ SUPPORT πΈ
this module lives in an open GitHub repository <http://github.com/theory/app-info/>. feel free to fork it and contribute, bestie, the door is open π«Ά!
pls file bug reports through GitHub Issues <http://github.com/theory/app-info/issues/> or by sending mail to bug-App-Info@rt.cpan.org <mailto:bug-App-Info@rt.cpan.org> π.
π AUTHOR π
David E. Wheeler <david@justatheory.com>, based on code by Sam Tregar <sam@tregar.com>.
β SEE ALSO β
App::Info documents the event handling interface.
App::Info::RDBMS is the App::Info::RDBMS::PostgreSQL parent class.
DBD::Pg is the DBI driver for connecting to PostgreSQL databases.
<http://www.postgresql.org/> is the PostgreSQL home page.
π COPYRIGHT AND LICENSE π
okay bestie, legal era, but make it cute β¨
- Copyright Β© 2002-2011, David E. Wheeler. Some Rights Reserved. π«Ά
This module is free software, no cap β you can redistribute it and/or modify it under the same terms as Perl itself. That's it, that's the whole vibe. Go forth and remix, just keep the receipts. π
not me writing a whole manpage and then ending it on a copyright line π iconic behavior honestly
and that's a wrap on the whole thing, bestie!! π you made it to the very last line, and the very last line is doing its little footer thing: this is perl v5.36.0, dated 2022-12-06, and the page is App::I...PostgreSQL(3pm). π
go forth and App::Info your heart out. mwah. πβ¨π
π¦ where this page comes from
- debian bookworm: libapp-info-perl 0.57-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libapp-info-perl 0.57-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libapp-info-perl 0.57-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libapp-info-perl 0.57-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libapp-info-perl 0.57-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms