[postgis-users] jdbc, bytea for the write side

David Blasby dblasby at gmail.com
Sun Jul 4 20:22:31 PDT 2004


ByteA is binary compatible with the postgis type, so you should just
be able to create a "binary compatible" 'NULL' cast for it.

I think something like "CREATE CAST (BYTEA AS
WKB)   WITHOUT FUNCTION AS IMPLICIT ;" should do the trick.

This is only available in recent postgresql versions.

You can do it in older versions easily, too.

Unfortunately, I'm no longer working at Refractions and I havent got a
system setup at home yet; I'm unable to test.

I believe you can (as funny as it sounds), use the "WKBtoBYTEA"
function since its a do-nothing function.

CREATE FUNCTION wkb(bytea)
       RETURNS geometry
       AS '@MODULE_FILENAME@','WKBtoBYTEA'
       LANGUAGE 'C' WITH (iscachable,isstrict);

So instead of using "bytea2wkb()" you can use "wkb(<bytea>)".

If this works, have strk commit the change.

Have you checked to see whats actually being sent between geotools and
Postgis?  If I remember the SQL standard, bytea is sent as strings
like '0001001001000111001' - you could be sending 8* as much data as
you're expecting.  (This is assuming a text, NOT binary, cursor).

dave



More information about the postgis-users mailing list