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

From Kedar Potdar
Subject Re: Writing values to relation using bytearray ...
Date
Msg-id bd8134a40903060341p1642a20ek2b262ae757933910@mail.gmail.com
Whole thread Raw
In response to Re: Writing values to relation using bytearray ...  (Greg Stark <stark@enterprisedb.com>)
Responses Re: Writing values to relation using bytearray ...  (Greg Stark <stark@enterprisedb.com>)
Re: Writing values to relation using bytearray ...  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Thanks Greg, for showing interest.<br /><br />The problem here is I need to store values of different types into
bytearraycolumn of relation. <br /><br /><div class="gmail_quote">On Fri, Mar 6, 2009 at 4:33 PM, Greg Stark <span
dir="ltr"><<ahref="mailto:stark@enterprisedb.com">stark@enterprisedb.com</a>></span> wrote:<br /><blockquote
class="gmail_quote"style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:
1ex;"><divclass="im">On Fri, Mar 6, 2009 at 10:03 AM, Kedar Potdar <<a
href="mailto:kedar.potdar@gmail.com">kedar.potdar@gmail.com</a>>wrote:<br /> ><br /> > The aforementioned code
worksfine for types like int, data, text and I can<br /> > read values from the relation correctly. The problem
arisesfor type<br /> > "float8" which is not "by value" type and it has fixed length (8) where I<br /> > can't
readthe values written to relation correctly.<br /> ><br /> > Am i missing something here?<br /><br /></div>Well
asyou've correctly diagnosed, not all byvalue data types are<br /> variable-length.<br /><br /> This code all seems
unnecessary.The whole point of heap_form_datum<br /> and heap_deform_datum/heap_getattr is that you don't have to
worry<br/> about all this. there are also functions like datumCopy() but you<br /> probably don't even need them here,
youcan just put the datums you<br /> have handy into the values[] array and pass that to heap_form_tuple --<br /> it'll
copythem into the resulting tuple so once you've formed the<br /> tuple you don't have to worry about the lifetime of
theoriginal<br /> datums. heap_deform_tuple() and heap_getattr can return pointers into<br /> the original tuple so you
dohave to be careful to copy them if you<br /> need them to survive the original tuple -- but you might not be<br />
anyways.<br/><br /><br /> --<br /><font color="#888888">greg<br /></font></blockquote></div><br /> 

pgsql-hackers by date:

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