From b1ee615a7f9b645d72ee560b74e4621ed5936cf8 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 9 May 2003 21:19:50 +0000 Subject: COPY BINARY uses the new binary I/O routines. Update a few more datatypes so that COPY BINARY regression test passes. --- src/backend/utils/adt/geo_ops.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/backend/utils/adt/geo_ops.c') 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 #include +#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) -- cgit v1.2.3