The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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. Methods that trigger events will trigger them only the first time they're called (See App::Info for documentation on handling events). To start over (after, say, someone has installed PostgreSQL) construct a new App::Info::RDBMS::PostgreSQL object to aggregate new metadata.

Some of the methods trigger the same events. This is due to cross-calling of shared subroutines. However, any one event should be triggered no more than once. For example, although the info event "Executing `pg_config --version`" is documented for the methods name(), version(), major_version(), minor_version(), and patch_version(), rest assured that it will only be triggered once, by whichever of those four methods is called first.

INTERFACE

Constructor

new

  my $pg = App::Info::RDBMS::PostgreSQL->new(@params);

Returns an App::Info::RDBMS::PostgreSQL object. See App::Info for a complete description of argument parameters.

When it called, new() searches the file system for the pg_config application. If found, pg_config will be called by the object methods below to gather the data necessary for each. If pg_config cannot be found, then PostgreSQL is assumed not to be installed, and each of the object 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:

$ENV{POSTGRES_HOME}/bin
$ENV{POSTGRES_LIB}/../bin
/usr/local/pgsql/bin
/usr/local/postgres/bin
/opt/pgsql/bin
/usr/local/bin
/usr/local/sbin
/usr/bin
/usr/sbin
/bin

Events:

info

Looking for pg_config

confirm

Path to pg_config?

unknown

Path to pg_config?

Class Method

key_name

  my $key_name = App::Info::RDBMS::PostgreSQL->key_name;

Returns the unique key name that describes this class. The value returned is the string "PostgreSQL".

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 as found when new() constructed the object. If PostgreSQL does not appear to be installed, then all of the other object methods will return empty values.

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`.

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

unknown

Enter a valid PostgreSQL name

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`.

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

unknown

Enter a valid PostgreSQL version number

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".

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

unknown

Enter a valid PostgreSQL major version number

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".

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

unknown

Enter a valid PostgreSQL minor version number

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".

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

unknown

Enter a valid PostgreSQL minor version number

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`.

Events:

info

Executing `pg_config --bindir`

error

Cannot find bin directory

unknown

Enter a valid PostgreSQL bin directory

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`.

Events:

info

Executing `pg_config --includedir`

error

Cannot find include directory

unknown

Enter a valid PostgreSQL include directory

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`.

Events:

info

Executing `pg_config --libdir`

error

Cannot find library directory

unknown

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. App::Info::RDBMS::PostgreSQL gathers the path from the system call `pg_config --pkglibdir`.

Events:

info

Executing `pg_config --pkglibdir`

error

Cannot find shared object library directory

unknown

Enter a valid PostgreSQL shared object library directory

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

Report all bugs via the CPAN Request Tracker at http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Info.

AUTHOR

David Wheeler <david@wheeler.net> 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

Copyright (c) 2002-2004, 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.