microo8 / plgo

easily create postgresql extensions in golang; moved to gitlab.com/microo8/plgo
292 stars 23 forks source link

Returning []byte results in server (postgres) crashes and generates incorrect SQL #30

Closed onshorechet closed 4 years ago

onshorechet commented 5 years ago

Writing a go function that returns []byte will generate a sql header like:

CREATE OR REPLACE FUNCTION CompressGzip(data text,level bigint)
RETURNS [] AS
'$libdir/vl', 'CompressGzip'
LANGUAGE c VOLATILE STRICT;

From this go function:

func CompressGzip(data string, level int) []byte {
        return cGzip([]byte(data), level);
}

Amending that sql header and installing the function will result in a server crash on use of the function.

microo8 commented 5 years ago

I take a look at it.