Re: convert binary string to datum - Mailing list pgsql-general

From Ron Peterson
Subject Re: convert binary string to datum
Date
Msg-id 20071013033214.GB5729@yellowbank.com
Whole thread Raw
In response to convert binary string to datum  (Ron Peterson <ron.peterson@yellowbank.com>)
Responses Re: convert binary string to datum  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-general
2007-10-12_22:22:32-0400 Ron Peterson <ron.peterson@yellowbank.com>:
> How does one convert an octet string (e.g. something like a varlena
> structure) to a Datum?  I want to create datums for use w/
> heap_form_tuple in a function returning a tuple containing bytea
> representations of very large integers.

Is this a legitimate/blessed way to go about it?

aval = (bytea *)palloc( len + VARHDRSZ );
VARATT_SIZEP(aval) = len + VARHDRSZ;
memcpy( VARDATA(aval), myrawdata, len );

values[0] = PointerGetDatum(aval);

...etc

tuple = heap_formtuple( tupdesc, values, &isNull );

--
Ron Peterson
https://www.yellowbank.com/

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: can I define own variables?
Next
From: "brien colwell"
Date:
Subject: contrib / fuzzystr documentation