diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-05-09 21:19:50 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-05-09 21:19:50 +0000 |
commit | b1ee615a7f9b645d72ee560b74e4621ed5936cf8 (patch) | |
tree | 9ef1ab11c2ef687a6870138110c5618fc6bd4ce0 /src/backend/utils/adt/geo_ops.c | |
parent | 38d9919d1ac22ca39b18acc4b8df457995101517 (diff) | |
download | postgresql-b1ee615a7f9b645d72ee560b74e4621ed5936cf8.tar.gz postgresql-b1ee615a7f9b645d72ee560b74e4621ed5936cf8.zip |
COPY BINARY uses the new binary I/O routines. Update a few more datatypes
so that COPY BINARY regression test passes.
Diffstat (limited to 'src/backend/utils/adt/geo_ops.c')
-rw-r--r-- | src/backend/utils/adt/geo_ops.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index d8d1f7c3afe..956bd1753f6 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.75 2003/03/11 21:01:33 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.76 2003/05/09 21:19:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -19,11 +19,11 @@ #include <float.h> #include <ctype.h> +#include "libpq/pqformat.h" #include "utils/builtins.h" #include "utils/geo_decls.h" #ifndef M_PI -/* from my RH5.2 gcc math.h file - thomas 2000-04-03 */ #define M_PI 3.14159265358979323846 #endif @@ -1589,6 +1589,36 @@ point_out(PG_FUNCTION_ARGS) PG_RETURN_CSTRING(path_encode(-1, 1, pt)); } +/* + * point_recv - converts external binary format to point + */ +Datum +point_recv(PG_FUNCTION_ARGS) +{ + StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); + Point *point; + + point = (Point *) palloc(sizeof(Point)); + point->x = pq_getmsgfloat8(buf); + point->y = pq_getmsgfloat8(buf); + PG_RETURN_POINT_P(point); +} + +/* + * point_send - converts point to binary format + */ +Datum +point_send(PG_FUNCTION_ARGS) +{ + Point *pt = PG_GETARG_POINT_P(0); + StringInfoData buf; + + pq_begintypsend(&buf); + pq_sendfloat8(&buf, pt->x); + pq_sendfloat8(&buf, pt->y); + PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); +} + static Point * point_construct(double x, double y) |