Re: convert binary string to datum

From: Ron Peterson <ron(dot)peterson(at)yellowbank(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: convert binary string to datum
Date: 2007-10-13 03:32:14
Message-ID: 20071013033214.GB5729@yellowbank.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2007-10-12_22:22:32-0400 Ron Peterson <ron(dot)peterson(at)yellowbank(dot)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/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message brien colwell 2007-10-13 05:17:02 contrib / fuzzystr documentation
Previous Message Tom Lane 2007-10-13 02:49:57 Re: can I define own variables?