New function: inet_client_addr()...
От | Sean Chittenden |
---|---|
Тема | New function: inet_client_addr()... |
Дата | |
Msg-id | FF7B75B8-A5F6-11D8-8163-000A95C705DC@chittenden.org обсуждение исходный текст |
Список | pgsql-patches |
In stock PostgreSQL, you can get the database name, the username, but not the address that the client is connecting from (a very, very useful piece of data). Function: inet_client_addr() Args: none Return type: INET (null on AF_UNIX or some catastrophic failure) IPv6 safe: yes The attached patch includes documentation and the relevant code. If there aren't any problems, I think this patch is ready to be committed. If someone wants a way to return the path of AF_UNIX connections, I firmly believe that it should live in a similar, but different function, otherwise PL code (or whatever) will have to tease out whether it's a local or remote connection. Not that I think demand is there for it, but if need be, there should be two more functions written: unix_client_addr() and just client_addr(). unix_client_addr() returns TEXT and the path to the socket and client_addr() returns a TEXT wrapped version of whatever is in MyProcPort->remote_host. -sc % psql -h 192.168.102.100 template1 template1=# SELECT inet_client_addr(); inet_client_addr ------------------ 192.168.102.100 (1 row) template1=# \q % echo $PGHOST tcsh: PGHOST: Undefined variable. % psql template1 template1=# SELECT inet_client_addr(); inet_client_addr ------------------ (1 row) template1=# SELECT inet_client_addr() IS NULL; ?column? ---------- t (1 row) template1=# \q % psql -h 127.0.0.1 template1 template1=# SELECT inet_client_addr() IS NULL; ?column? ---------- f (1 row) template1=# SELECT inet_client_addr(); inet_client_addr ------------------ 127.0.0.1 (1 row) template1=# \q % psql -h localhost template1 template1=# SELECT inet_client_addr(); inet_client_addr ------------------ ::1 (1 row) -- Sean Chittenden
Вложения
В списке pgsql-patches по дате отправления: