Final touch to wkb binary input function

git-svn-id: http://svn.osgeo.org/postgis/trunk@404 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
Sandro Santilli 2003-12-09 11:58:42 +00:00
parent 18d50c9239
commit f44b43fa97

View file

@ -11,6 +11,9 @@
* *
********************************************************************** **********************************************************************
* $Log$ * $Log$
* Revision 1.32 2003/12/09 11:58:42 strk
* Final touch to wkb binary input function
*
* Revision 1.31 2003/12/09 11:13:41 strk * Revision 1.31 2003/12/09 11:13:41 strk
* WKB_recv: set StringInfo cursor to the end of StringInfo buf as required by postgres backend * WKB_recv: set StringInfo cursor to the end of StringInfo buf as required by postgres backend
* *
@ -3554,22 +3557,25 @@ Datum WKB_out(PG_FUNCTION_ARGS)
* and leave it at the end of StringInfo.buf. If it fails * and leave it at the end of StringInfo.buf. If it fails
* to do so the backend will raise an exception with message: * to do so the backend will raise an exception with message:
* ERROR: incorrect binary data format in bind parameter # * ERROR: incorrect binary data format in bind parameter #
*
*/ */
PG_FUNCTION_INFO_V1(WKB_recv); PG_FUNCTION_INFO_V1(WKB_recv);
Datum WKB_recv(PG_FUNCTION_ARGS) Datum WKB_recv(PG_FUNCTION_ARGS)
{ {
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
WellKnownBinary *result; bytea *result;
elog(NOTICE, "WKB_recv start"); //elog(NOTICE, "WKB_recv start");
result = (WellKnownBinary *)palloc(buf->len); /* Add VARLENA size info to make it a valid varlena object */
memcpy(result, buf->data, buf->len); result = (WellKnownBinary *)palloc(buf->len+VARHDRSZ);
VARATT_SIZEP(result) = buf->len+VARHDRSZ;
memcpy(VARATT_DATA(result), buf->data, buf->len);
/* Set cursor to the end of buffer (so the backend is happy) */ /* Set cursor to the end of buffer (so the backend is happy) */
buf->cursor = buf->len; buf->cursor = buf->len;
elog(NOTICE, "WKB_recv end (returning result)"); //elog(NOTICE, "WKB_recv end (returning result)");
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
#endif #endif