Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b9poU-0000RS-Vs for pgsql-general@arkaria.postgresql.org; Mon, 06 Jun 2016 08:23:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1b9poU-0005EL-H0 for pgsql-general@arkaria.postgresql.org; Mon, 06 Jun 2016 08:23:10 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1b9poT-0005Do-EY for pgsql-general@postgresql.org; Mon, 06 Jun 2016 08:23:09 +0000 Received: from fr1.2ndquadrant.fr ([94.23.17.124]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1b9poQ-0008Us-FX for pgsql-general@postgresql.org; Mon, 06 Jun 2016 08:23:08 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by fr1.2ndquadrant.fr (Postfix) with ESMTP id 111FB60564; Mon, 6 Jun 2016 10:23:04 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at fr1.2ndquadrant.fr Received: from fr1.2ndquadrant.fr ([127.0.0.1]) by localhost (fr1.2ndquadrant.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OTom0rRkZFFX; Mon, 6 Jun 2016 10:23:02 +0200 (CEST) Received: from [192.168.0.3] (ath91-3-88-167-161-184.fbx.proxad.net [88.167.161.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: charles) by fr1.2ndquadrant.fr (Postfix) with ESMTPSA id 91BC1601EF; Mon, 6 Jun 2016 10:23:02 +0200 (CEST) Subject: Re: Replication To: Masahiko Sawada References: <5752DE6A.7010706@2ndquadrant.fr> Cc: Bertrand Paquet , pgsql-general@postgresql.org From: Vik Fearing Message-ID: <575532DA.2010801@2ndquadrant.fr> Date: Mon, 6 Jun 2016 10:22:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org On 06/06/16 09:54, Masahiko Sawada wrote: > On Sat, Jun 4, 2016 at 10:58 PM, Vik Fearing wrote: >> On 02/06/16 15:32, Bertrand Paquet wrote: >>> Hi, >>> >>> On an hot standby streaming server, is there any way to know, in SQL, to >>> know the ip of current master ? >> >> No. >> >>> The solution I have is to read the recovery.conf file to find >>> primary_conninfo, >> >> That is currently the only solution. There are plans to allow SQL >> access to the parameters in recovery.conf (or to merge them into >> postgresql.conf) but that's not currently possible. > > It might not be a right way but how about using pg_read_file()? > postgres(1)=# select regexp_replace(pg_read_file('recovery.conf'), > '.*primary_conninfo = (.*)', '\1'); > regexp_replace > --------------------------------------------------- > 'host=localhost port=5550 application_name=node1'+ > > (1 row) > > You can get the master server information via SQL from standby server. This is a good idea, but suffers the same problem that Bertrand has with looking at the file a different way: if the file was changed but the standby server has not been restarted, it's (potentially) not going to be the correct information. -- Vik Fearing +33 6 46 75 15 36 http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general