pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedIs there anyway to retrieve server name and/or ip from query
3+ messages / 3 participants
[nested] [flat]
* Is there anyway to retrieve server name and/or ip from query
@ 2005-07-29 13:48 Chris Hoover <revoohc@gmail.com>
2005-07-29 14:00 ` Re: Is there anyway to retrieve server name and/or ip from query Bruce Momjian <pgman@candle.pha.pa.us>
2005-07-29 14:15 ` Re: Is there anyway to retrieve server name and/or ip from query Michael Fuhr <mike@fuhr.org>
0 siblings, 2 replies; 3+ messages in thread
From: Chris Hoover @ 2005-07-29 13:48 UTC (permalink / raw)
To: pgsql-admin
Subject pretty much says it all. Is there a way in a sql query to
have it return the server name and/or the server ip address of the
PostgreSQL server?
thanks,
Chris
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Is there anyway to retrieve server name and/or ip from query
2005-07-29 13:48 Is there anyway to retrieve server name and/or ip from query Chris Hoover <revoohc@gmail.com>
@ 2005-07-29 14:00 ` Bruce Momjian <pgman@candle.pha.pa.us>
1 sibling, 0 replies; 3+ messages in thread
From: Bruce Momjian @ 2005-07-29 14:00 UTC (permalink / raw)
To: Chris Hoover <revoohc@gmail.com>; +Cc: pgsql-admin
Chris Hoover wrote:
> Subject pretty much says it all. Is there a way in a sql query to
> have it return the server name and/or the server ip address of the
> PostgreSQL server?
8.0 has such informix via functions:
test=> \df *server*
List of functions
Schema | Name | Result data type | Argument data types
------------+------------------+------------------+---------------------
pg_catalog | inet_server_addr | inet |
pg_catalog | inet_server_port | integer |
(2 rows)
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Is there anyway to retrieve server name and/or ip from query
2005-07-29 13:48 Is there anyway to retrieve server name and/or ip from query Chris Hoover <revoohc@gmail.com>
@ 2005-07-29 14:15 ` Michael Fuhr <mike@fuhr.org>
1 sibling, 0 replies; 3+ messages in thread
From: Michael Fuhr @ 2005-07-29 14:15 UTC (permalink / raw)
To: Chris Hoover <revoohc@gmail.com>; +Cc: pgsql-admin
On Fri, Jul 29, 2005 at 09:48:28AM -0400, Chris Hoover wrote:
> Subject pretty much says it all. Is there a way in a sql query to
> have it return the server name and/or the server ip address of the
> PostgreSQL server?
Depends on the version of PostgreSQL. In 8.0 you can use
inet_server_addr():
http://www.postgresql.org/docs/8.0/static/functions-info.html
Note that inet_server_addr() returns the IP address that you connected
to, so it won't return all IP addresses of a multihomed host. Also,
it will return NULL if you're connected via a local (Unix-domain) socket.
If you're using an earlier version of PostgreSQL, or if you want
more information that the standard functions provide, then you could
write a function in a language like PL/Perl, PL/Tcl, PL/Python, etc.
Example:
CREATE FUNCTION hostname() RETURNS text AS '
use Sys::Hostname;
return hostname;
' LANGUAGE plperlu;
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-07-29 14:15 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-07-29 13:48 Is there anyway to retrieve server name and/or ip from query Chris Hoover <revoohc@gmail.com>
2005-07-29 14:00 ` Bruce Momjian <pgman@candle.pha.pa.us>
2005-07-29 14:15 ` Michael Fuhr <mike@fuhr.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox