Re: Using HeapTuple.t_len to verify size of tuple

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: Using HeapTuple.t_len to verify size of tuple
Date: 2015-08-25 21:56:02
Message-ID: 21367.1440539762@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:
> Can the t_len field in HeapTuple structure be used to verify the length of
> the tuple?

> That is, if I calculate the length from the contents of the tuple using
> data from pg_attribute for fixed length fields and the data from the header
> for varlena fields, should it always match the value stored in t_len?

If t_len were *less* than that, it would be a bug. But I think it's
fairly common for t_len to be rounded up to the next maxalign boundary.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-08-25 22:09:17 Re: 9.4 broken on alpha
Previous Message Alvaro Herrera 2015-08-25 21:54:41 Re: 9.4 broken on alpha