NAME
App::Info::RDBMS::PostgreSQL - Information about PostgreSQL
SYNOPSIS
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";
}
DESCRIPTION
App::Info::RDBMS::PostgreSQL supplies information about the PostgreSQL database server installed on the local system. It implements all of the methods defined by App::Info::RDBMS.
When it loads, App::Info::RDBMS::PostgreSQL searches the file system for the pg_config application. If found, pg_config will be called to gather the data necessary for each of the methods below. If pg_config cannot be found, then PostgreSQL is assumed not to be installed, and each of the methods will return undef
.
App::Info::RDBMS::PostgreSQL searches for pg_config along your path, as defined by File::Spec-
path>. Failing that, it searches the following directories:
- /usr/local/pgsql/bin
- /usr/local/postgres/bin
- /opt/pgsql/bin
- /usr/local/bin
- /usr/local/sbin
- /usr/bin
- /usr/sbin
- /bin
CONSTRUCTOR
new
my $pg = App::Info::RDBMS::PostgreSQL->new;
Returns an App::Info::RDBMS::PostgreSQL object. Since App::Info::RDBMS::PostgreSQL is implemented as a singleton class, the same object will be returned every time. This ensures that only the minimum number of system calls are made to gather the data necessary for the object methods.
OBJECT METHODS
installed
print "PostgreSQL is ", ($pg->installed ? '' : 'not '), "installed.\n";
Returns true if PostgreSQL is installed, and false if it is not. App::Info::RDBMS::PostgreSQL determines whether PostgreSQL is installed based on the presence or absence of the pg_config application on the file system.
name
my $name = $pg->name;
Returns the name of the application. App::Info::RDBMS::PostgreSQL parses the name from the system call `pg_config --version`
. Returns undef
if PostgreSQL is not installed. Emits a warning if PostgreSQL is installed but the version number could not be parsed.
version
my $version = $pg->version;
Returns the PostgreSQL version number. App::Info::RDBMS::PostgreSQL parses the version number from the system call `pg_config --version`
. Returns undef
if PostgreSQL is not installed. Emits a warning if PostgreSQL is installed but the version number could not be parsed.
major version
my $major_version = $pg->major_version;
Returns the PostgreSQL major version number. App::Info::RDBMS::PostgreSQL parses the major version number from the system call `pg_config --version`
. For example, version()
returns "7.1.2", then this method returns "7". Returns undef
if PostgreSQL is not installed. Emits a warning if PostgreSQL is installed but the version number could not be parsed.
minor version
my $minor_version = $pg->minor_version;
Returns the PostgreSQL minor version number. App::Info::RDBMS::PostgreSQL parses the minor version number from the system call `pg_config --version`
. For example, if version()
returns "7.1.2", then this method returns "2". Returns undef
if PostgreSQL is not installed. Emits a warning if PostgreSQL is installed but the version number could not be parsed.
patch version
my $patch_version = $pg->patch_version;
Returns the PostgreSQL patch version number. App::Info::RDBMS::PostgreSQL parses the patch version number from the system call `pg_config --version`
. For example, if version()
returns "7.1.2", then this method returns "1". Returns undef
if PostgreSQL is not installed. Emits a warning if PostgreSQL is installed but the version number could not be parsed.
bin_dir
my $bin_dir = $pg->bin_dir;
Returns the PostgreSQL binary directory path. App::Info::RDBMS::PostgreSQL gathers the path from the system call `pg_config --bindir`
. Returns undef
if PostgreSQL is not installed.
inc_dir
my $inc_dir = $pg->inc_dir;
Returns the PostgreSQL include directory path. App::Info::RDBMS::PostgreSQL gathers the path from the system call `pg_config --includedir`
. Returns undef
if PostgreSQL is not installed.
lib_dir
my $lib_dir = $pg->lib_dir;
Returns the PostgreSQL library directory path. App::Info::RDBMS::PostgreSQL gathers the path from the system call `pg_config --libdir`
. Returns undef
if PostgreSQL is not installed.
so_lib_dir
my $so_lib_dir = $pg->so_lib_dir;
Returns the PostgreSQL shared object library directory path. App::Info::RDBMS::PostgreSQL gathers the path from the system call `pg_config --pkglibdir`
. Returns undef
if PostgreSQL is not installed.
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.
BUGS
Feel free to drop me a line if you discover any bugs. Patches welcome.
AUTHOR
David Wheeler <david@wheeler.net> based on code by Sam Tregar <sam@tregar.com>.
SEE ALSO
App::Info, App::Info::RDBMS, DBD::Pg
COPYRIGHT AND LICENSE
Copyright (c) 2002, David Wheeler. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.