Re: Writing values to relation using bytearray ...

From: Kedar Potdar <kedar(dot)potdar(at)gmail(dot)com>
To: Greg Stark <stark(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Writing values to relation using bytearray ...
Date: 2009-03-06 11:41:50
Message-ID: bd8134a40903060341p1642a20ek2b262ae757933910@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks Greg, for showing interest.

The problem here is I need to store values of different types into bytearray
column of relation.

On Fri, Mar 6, 2009 at 4:33 PM, Greg Stark <stark(at)enterprisedb(dot)com> wrote:

> 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
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bernd Helmle 2009-03-06 11:44:31 Re: Validating problem in the isn contrib module
Previous Message Andreas 'ads' Scherbaum 2009-03-06 11:07:18 Re: Validating problem in the isn contrib module