From: | Greg Stark <stark(at)enterprisedb(dot)com> |
---|---|
To: | Kedar Potdar <kedar(dot)potdar(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Writing values to relation using bytearray ... |
Date: | 2009-03-06 11:03:43 |
Message-ID: | 4136ffa0903060303p632274adlad88a588057dc0e1@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Mar 6, 2009 at 10:03 AM, Kedar Potdar <kedar(dot)potdar(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas 'ads' Scherbaum | 2009-03-06 11:07:18 | Re: Validating problem in the isn contrib module |
Previous Message | Gregory Stark | 2009-03-06 10:50:41 | Re: Validating problem in the isn contrib module |