[Pgpool-general] sql to know if connection is using pgpool

Gary Fu gfu at sigmaspace.com
Tue Jan 18 21:06:33 UTC 2011


  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.

Thanks,
Gary


More information about the Pgpool-general mailing list