Parsing tuple contents

Started by Vignesh Raghunathanover 10 years ago3 messages
#1Vignesh Raghunathan
vignesh.pgsql@gmail.com

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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Vignesh Raghunathan (#1)
Re: Parsing tuple contents

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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Vignesh Raghunathan
vignesh.pgsql@gmail.com
In reply to: Tom Lane (#2)
Re: Parsing tuple contents

Thank you very much for the response.

On Wed, Aug 12, 2015 at 6:31 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

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