[postgis-devel] Binary Output Functions

Paul Ramsey pramsey at refractions.net
Fri May 27 10:37:22 PDT 2005


Nevermind, with a little poking into the system catalogues, I found the
answer:

The "binary send format" is controlled by the "typsend" attribute in the
"pg_type" catalogue. So for example, for int4, the "typsend" is defined
as "int4send" and the C code is:

Datum
int4send(PG_FUNCTION_ARGS)
{
         int32           arg1 = PG_GETARG_INT32(0);
         StringInfoData buf;

         pq_begintypsend(&buf);
         pq_sendint(&buf, arg1, sizeof(int32));
         PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}

So the return is a BYTEA. I am not sure what the right return type is
for geometry in this case to get interoperability with ESRI, whether it
is the OpenGIS WKB format or something else. Probably WKB. The user
could probably test this by simply updating the "geometry" entry in
pg_type and setting the typsend function to be "asbinary". This returns
(in postgis 1.0) a bytea in the OGC WKB format, which is (probably) what
ESRI is expecting.

Paul


> Shachar,
> You wrote (in response to a question about PgOleDB and PostGIS):
> 
> 
> "OleDb, and accordingly, PgOleDb, is a binary interface driver. As such,
> it gets all data types in binary form from the database. In order for a
> datatype to be supported, two conditions must be satisfied:
> 1. The data type must have a binary output function defined in PG itself.
> 2. PgOleDb must know how to handle this type, to translate it to the
> binary interface OLE DB is expected to return said type."
> 
> Could you elabourate on item 1. above? What is the function signature 
> that PgOleDB expects for the binary output function? It is a typecast to 
> bytea? Something else? In a binary cursor, if you ask for a column, you 
> should just get back the backend struct, which would then drop the 
> system into your problem 2. above. And for that the guy you were talking 
> to will actually need to start hacking in PgOleDb.  ESRI has some 
> directions on doing spatial OLEDB, but the documentation is very very 
> thin...
> 
> http://arcgisdeveloperonline.esri.com/ArcGISDeveloper/ArcGISDevHelp/TechnicalDocuments/Geodatabase/Arc8_provider.htm









More information about the postgis-devel mailing list