Thread: Parsing tuple contents

Parsing tuple contents

From
Vignesh Raghunathan
Date:
Hello,

I am working on a project which requires going through each field inside a tuple without using postgresql. I have managed to iterate through each tuple inside a table by recycling postgres's code. However, for the part of parsing through each field in the tuple, I am not able to think of anything other than using a bunch of if/else or switch case statements to handle each postgresql datatype. I looked through postgresql's code base but I am unable to identify the part of code that might do this. Could anyone please let me know where to look?

Thanks,
Vignesh     

Re: Parsing tuple contents

From
Tom Lane
Date:
Vignesh Raghunathan <vignesh.pgsql@gmail.com> writes:
> I am working on a project which requires going through each field inside a
> tuple without using postgresql. I have managed to iterate through each
> tuple inside a table by recycling postgres's code. However, for the part of
> parsing through each field in the tuple, I am not able to think of anything
> other than using a bunch of if/else or switch case statements to handle
> each postgresql datatype. I looked through postgresql's code base but I am
> unable to identify the part of code that might do this. Could anyone please
> let me know where to look?

Well, as far as identifying the field boundaries is concerned, there are
not that many cases: you basically only need to worry about typlen and
typalign.  heap_deform_tuple() would be a good model.

Of course, if you want to print the values in some human-readable form,
there is not going to be a good substitute for per-datatype code :-(
        regards, tom lane



Re: Parsing tuple contents

From
Vignesh Raghunathan
Date:
<div dir="ltr">Thank you very much for the response. </div><div class="gmail_extra"><br /><div class="gmail_quote">On
Wed,Aug 12, 2015 at 6:31 PM, Tom Lane <span dir="ltr"><<a href="mailto:tgl@sss.pgh.pa.us"
target="_blank">tgl@sss.pgh.pa.us</a>></span>wrote:<br /><blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px#ccc solid;padding-left:1ex"><span class="">Vignesh Raghunathan <<a
href="mailto:vignesh.pgsql@gmail.com">vignesh.pgsql@gmail.com</a>>writes:<br /> > I am working on a project which
requiresgoing through each field inside a<br /> > tuple without using postgresql. I have managed to iterate through
each<br/> > tuple inside a table by recycling postgres's code. However, for the part of<br /> > parsing through
eachfield in the tuple, I am not able to think of anything<br /> > other than using a bunch of if/else or switch
casestatements to handle<br /> > each postgresql datatype. I looked through postgresql's code base but I am<br />
>unable to identify the part of code that might do this. Could anyone please<br /> > let me know where to
look?<br/><br /></span>Well, as far as identifying the field boundaries is concerned, there are<br /> not that many
cases:you basically only need to worry about typlen and<br /> typalign.  heap_deform_tuple() would be a good model.<br
/><br/> Of course, if you want to print the values in some human-readable form,<br /> there is not going to be a good
substitutefor per-datatype code :-(<br /><br />                         regards, tom lane<br /></blockquote></div><br
/></div>