Re: Parsing tuple contents

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vignesh Raghunathan <vignesh(dot)pgsql(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Parsing tuple contents
Date: 2015-08-13 01:31:24
Message-ID: 13101.1439429484@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Vignesh Raghunathan <vignesh(dot)pgsql(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-08-13 01:32:33 Re: Test code is worth the space
Previous Message Tom Lane 2015-08-13 01:27:01 Re: Macro nesting hell