Index: doc/src/sgml/func.sgml =================================================================== RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/func.sgml,v retrieving revision 1.202 diff -u -r1.202 func.sgml --- doc/src/sgml/func.sgml 14 May 2004 21:42:27 -0000 1.202 +++ doc/src/sgml/func.sgml 17 May 2004 21:33:15 -0000 @@ -6593,6 +6593,12 @@ + inet_client_addr + inet + address of the remote connection + + + session_user name session user name @@ -6646,6 +6652,14 @@ they must be called without trailing parentheses. + + + inet_client_addr returns the IPv4 or IPv6 + (if configured) address of the host connecting to the database. + If the connection is local and not a network connection, + inet_client_addr returns + NULL. + current_schema returns the name of the schema that is Index: src/backend/utils/adt/geo_ops.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/utils/adt/geo_ops.c,v retrieving revision 1.84 diff -u -r1.84 geo_ops.c --- src/backend/utils/adt/geo_ops.c 12 May 2004 22:38:44 -0000 1.84 +++ src/backend/utils/adt/geo_ops.c 17 May 2004 21:33:16 -0000 @@ -1313,6 +1313,27 @@ *---------------------------------------------------------*/ Datum +path_area(PG_FUNCTION_ARGS) +{ + PATH *path = PG_GETARG_PATH_P(0); + double area = 0.0; + int i,j; + + if (!path->closed) + PG_RETURN_NULL(); + + for (i = 0; i < path->npts; i++) { + j = (i + 1) % path->npts; + area += path->p[i].x * path->p[j].y; + area -= path->p[i].y * path->p[j].x; + } + + area *= 0.5; + PG_RETURN_FLOAT8(area < 0.0 ? -area : area); +} + + +Datum path_in(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); Index: src/backend/utils/adt/network.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/utils/adt/network.c,v retrieving revision 1.49 diff -u -r1.49 network.c --- src/backend/utils/adt/network.c 1 Dec 2003 18:50:19 -0000 1.49 +++ src/backend/utils/adt/network.c 17 May 2004 21:33:16 -0000 @@ -14,7 +14,9 @@ #include #include "catalog/pg_type.h" +#include "libpq/libpq-be.h" #include "libpq/pqformat.h" +#include "miscadmin.h" #include "utils/builtins.h" #include "utils/inet.h" @@ -128,6 +130,26 @@ char *src = PG_GETARG_CSTRING(0); PG_RETURN_INET_P(network_in(src, 1)); +} + +/* INET that the client is connecting from */ +Datum +inet_client_addr(PG_FUNCTION_ARGS) +{ + if (MyProcPort == NULL) + PG_RETURN_NULL(); + + switch (MyProcPort->raddr.addr.ss_family) { + case AF_INET: +#ifdef HAVE_IPV6 + case AF_INET6: +#endif + break; + default: + PG_RETURN_NULL(); + } + + PG_RETURN_INET_P(network_in(MyProcPort->remote_host, 0)); } /* Index: src/include/catalog/pg_proc.h =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/include/catalog/pg_proc.h,v retrieving revision 1.329 diff -u -r1.329 pg_proc.h --- src/include/catalog/pg_proc.h 14 May 2004 21:42:28 -0000 1.329 +++ src/include/catalog/pg_proc.h 17 May 2004 21:33:17 -0000 @@ -1259,6 +1259,8 @@ DESCR("box height"); DATA(insert OID = 978 ( box_distance PGNSP PGUID 12 f f t f i 2 701 "603 603" _null_ box_distance - _null_ )); DESCR("distance between boxes"); +DATA(insert OID = 979 ( area PGNSP PGUID 12 f f t f i 1 701 "602" _null_ path_area - _null_ )); +DESCR("area of a closed path"); DATA(insert OID = 980 ( box_intersect PGNSP PGUID 12 f f t f i 2 603 "603 603" _null_ box_intersect - _null_ )); DESCR("box intersection (another box)"); DATA(insert OID = 981 ( diagonal PGNSP PGUID 12 f f t f i 1 601 "603" _null_ box_diagonal - _null_ )); @@ -2343,6 +2345,8 @@ DESCR("I/O"); DATA(insert OID = 911 ( inet_out PGNSP PGUID 12 f f t f i 1 2275 "869" _null_ inet_out - _null_ )); DESCR("I/O"); +DATA(insert OID = 912 ( inet_client_addr PGNSP PGUID 12 f f f f s 0 869 "" _null_ inet_client_addr - _null_ )); +DESCR("Returns the INET address of the client connected to the backend"); /* for cidr type support */ DATA(insert OID = 1267 ( cidr_in PGNSP PGUID 12 f f t f i 1 650 "2275" _null_ cidr_in - _null_ )); Index: src/include/utils/builtins.h =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/include/utils/builtins.h,v retrieving revision 1.238 diff -u -r1.238 builtins.h --- src/include/utils/builtins.h 14 May 2004 21:42:30 -0000 1.238 +++ src/include/utils/builtins.h 17 May 2004 21:33:17 -0000 @@ -645,6 +645,7 @@ void *dst, size_t size); /* network.c */ +extern Datum inet_client_addr(PG_FUNCTION_ARGS); extern Datum inet_in(PG_FUNCTION_ARGS); extern Datum inet_out(PG_FUNCTION_ARGS); extern Datum inet_recv(PG_FUNCTION_ARGS); Index: src/include/utils/geo_decls.h =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/include/utils/geo_decls.h,v retrieving revision 1.43 diff -u -r1.43 geo_decls.h --- src/include/utils/geo_decls.h 29 Nov 2003 22:41:15 -0000 1.43 +++ src/include/utils/geo_decls.h 17 May 2004 21:33:17 -0000 @@ -305,6 +305,7 @@ extern Datum box_div(PG_FUNCTION_ARGS); /* public path routines */ +extern Datum path_area(PG_FUNCTION_ARGS); extern Datum path_in(PG_FUNCTION_ARGS); extern Datum path_out(PG_FUNCTION_ARGS); extern Datum path_recv(PG_FUNCTION_ARGS);