Re: Writing values to relation using bytearray ...

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: Writing values to relation using bytearray ...
Дата
Msg-id 4136ffa0903060303p632274adlad88a588057dc0e1@mail.gmail.com
обсуждение исходный текст
Ответ на Writing values to relation using bytearray ...  (Kedar Potdar <kedar.potdar@gmail.com>)
Ответы Re: Writing values to relation using bytearray ...
Список 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 по дате отправления:

Предыдущее
От: Gregory Stark
Дата:
Сообщение: Re: Validating problem in the isn contrib module
Следующее
От: Andreas 'ads' Scherbaum
Дата:
Сообщение: Re: Validating problem in the isn contrib module