[Pgpool-general] sql to know if connection is using pgpool
Guillaume Lelarge
guillaume at lelarge.info
Tue Jan 18 21:20:12 UTC 2011
Le 18/01/2011 22:06, Gary Fu a écrit :
> On 01/18/11 15:35, Guillaume Lelarge wrote:
>> Le 18/01/2011 16:16, Gary Fu a écrit :
>>> On 01/17/11 19:45, Tatsuo Ishii wrote:
>>>>> Is there a simple query (not the 'show' command) to tell if my current
>>>>> db connection is using pgpool ?
>>>> No. Why is show pool_status not good?
>>> It causes error when the connection is not using pgpool.
>>>
>> You can try to compare inet_server_addr() and inet_server_port() with
>> the address and port your connected to.
>>
>> Here is an example (PostgreSQL 9.0.2 on 127.0.0.1:5432, pgPool 3.0.1 on
>> 127.0.0.1:9999).
>>
>> guillaume at laptop:/opt/pgpool-head$ psql -h 127.0.0.1 -p 9999 b1
>> psql (9.0.2)
>> Type "help" for help.
>>
>> b1=# select inet_server_addr() as ip, inet_server_port() as port,
>> inet_server_addr()<> '127.0.0.1' or inet_server_port()<> 9999 as
>> through_pgpool;
>> ip | port | through_pgpool
>> -----------+------+----------------
>> 127.0.0.1 | 5432 | t
>> (1 row)
>>
>> b1=# \q
>> guillaume at laptop:/opt/pgpool-head$ psql -h 127.0.0.1 -p 5432 b1
>> psql (9.0.2)
>> Type "help" for help.
>>
>> b1=# select inet_server_addr() as ip, inet_server_port() as port,
>> inet_server_addr()<> '127.0.0.1' or inet_server_port()<> 5432 as
>> through_pgpool;
>> ip | port | through_pgpool
>> -----------+------+----------------
>> 127.0.0.1 | 5432 | f
>> (1 row)
>>
>>
>> The "through_pgpool" column tells me if I'm connected using pgPool or
>> not. Actually, it won't handle every case (for example it won't if you
>> connect through an SSH tunnel).
>>
>>
> It works when the pgpool running on the same db server on the same local
> host and with different port. It is not generic for pgpool running on
> remote server without knowing the ip and port.
>
If you take my queries without modifying them, yes, you're right. But
you're supposed to change the IP address and the port in the query.
select inet_server_addr() <> 'your_connection_ip_number'
or inet_server_port() <> you_connection_port_number;
--
Guillaume
http://www.postgresql.fr
http://dalibo.com
More information about the Pgpool-general
mailing list