Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 6FC58632B81 for ; Fri, 30 Apr 2010 11:43:59 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 02474-10 for ; Fri, 30 Apr 2010 14:43:51 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from web23604.mail.ird.yahoo.com (web23604.mail.ird.yahoo.com [87.248.115.47]) by mail.postgresql.org (Postfix) with SMTP id 40D1F6328E0 for ; Fri, 30 Apr 2010 11:43:52 -0300 (ADT) Received: (qmail 67208 invoked by uid 60001); 30 Apr 2010 14:43:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1272638630; bh=h6Y1H5jSjVC6FQNzWWdcRccr2+CmBxSc1BVFWXTo5sI=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=Gg8oN2Mb01a0PzUbztgAEVhskJ9od0tUBuPjb0JzD9crYQNxw5tn995TaE+IlSnMMmRfWdU1OcHlHwRJ4spfv4vGuDjC9LmxFMHnYUNNt919gvFILWLh9QzU6Un/1jcrf/oJKP2avJz93ymk3BbLdqVQ3j18+zlGd8rz77rYGvE= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=2uauTNqxyEJGGC29MkG/nmPM1xmYdIzAueBZYL45YsvmL1hxo4Hk2J3KSiZK0JYKSYXNW/SG9+vpc6Udb/F6t0JzqLRTLCmD2GLouDDbbStI8KNxBSYi1UKXTYo+XkGGKDOosAg04CyKUP2cWfGRsCz5tg2DTY23B6TPaaSUUHY=; Message-ID: <292551.66852.qm@web23604.mail.ird.yahoo.com> X-YMail-OSG: Rv8FS5YVM1nBz.xaut8g4PRssfKarwFbv7uID0S5tfh8Dsb Kprpohg1yFQeB99jzG4wE8CHHYuZoHWFQslfyQYQwBpdyuGopWocXswtCgbE eWK9MCv0jXGw293dCSaSu.yHH7BR_vr2IngRktOzjKIDQlD75gYbA2zqCD1t 8plbOqR_7jIptqknagOOSto8ZSAV0LIDAytKaP8eVujvL8XclDtxcvoWhMom ItfssT7oN.y1bG_h93.UtgAjJVo5JYFo1vjqCmAx95fO7iRzUA90x32hWRgc LUyngh4Z5Flrmfq1z Received: from [83.100.146.195] by web23604.mail.ird.yahoo.com via HTTP; Fri, 30 Apr 2010 14:43:49 GMT X-Mailer: YahooMailClassic/10.1.11 YahooMailWebService/0.8.103.269680 Date: Fri, 30 Apr 2010 14:43:49 +0000 (GMT) From: Glyn Astill Subject: Re: Querying the hostname of the server To: pgsql-admin@postgresql.org, "Ross J. Reedstrom" In-Reply-To: <20100430141404.GB28614@rice.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201004/366 X-Sequence-Number: 34460 --- On Fri, 30/4/10, Ross J. Reedstrom wrote:=0A=0A> > = Hi,=0A> > =0A> > I have a number of PostgreSQL servers which I often=0A> ac= cess through ssh=0A> > tunnel with Pgadmin3. I would like to double check= =0A> which one I have landed=0A> > on (if the tunnel is really configured t= he way I=0A> want). Is there a way to=0A> > query the hostname from the cat= alogs?=0A> =0A> Hmm, that's a bit tricky, since I assume you're using a=0A>= local db=0A> connection inside the tunnel, so inet_server_addr()=0A> proba= bly returns=0A> null. If you're talking unix/linux machines, then=0A> /etc/= hostname _should_=0A> have the current hostname in it, so:=0A> =0A> create = temp table foo (t text);=0A> copy foo from '/etc/hostname';=0A> select * fr= om foo;=0A> drop table foo;=0A> =0A> Should work.=0A> =0A=0AOr you could do= something like:=0A=0ACREATE OR REPLACE FUNCTION hostname()=0ARETURNS text = AS=0A$BODY$=0A=09$host =3D `hostname`;=0A return $host;=0A$BODY$=0AL= ANGUAGE 'plperlu';=0A=0A=0A=0A=0A