Re: Writing values to relation using bytearray ... - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Writing values to relation using bytearray ...
Date
Msg-id 4136ffa0903060303p632274adlad88a588057dc0e1@mail.gmail.com
Whole thread Raw
In response to Writing values to relation using bytearray ...  (Kedar Potdar <kedar.potdar@gmail.com>)
Responses Re: Writing values to relation using bytearray ...
List pgsql-hackers
On Fri, Mar 6, 2009 at 10:03 AM, Kedar Potdar <kedar.potdar@gmail.com> wrote:
>
> The aforementioned code works fine for types like int, data, text and I can
> read values from the relation correctly. The problem arises for type
> "float8" which is not "by value" type and it has fixed length (8) where I
> can't read the values written to relation correctly.
>
> Am i missing something here?

Well as you've correctly diagnosed, not all byvalue data types are
variable-length.

This code all seems unnecessary. The whole point of heap_form_datum
and heap_deform_datum/heap_getattr is that you don't have to worry
about all this. there are also functions like datumCopy() but you
probably don't even need them here, you can just put the datums you
have handy into the values[] array and pass that to heap_form_tuple --
it'll copy them into the resulting tuple so once you've formed the
tuple you don't have to worry about the lifetime of the original
datums. heap_deform_tuple() and heap_getattr can return pointers into
the original tuple so you do have to be careful to copy them if you
need them to survive the original tuple -- but you might not be
anyways.


-- 
greg


pgsql-hackers by date:

Previous
From: Gregory Stark
Date:
Subject: Re: Validating problem in the isn contrib module
Next
From: Andreas 'ads' Scherbaum
Date:
Subject: Re: Validating problem in the isn contrib module