Re: [HACKERS] questionable code in heap_formtuple()]

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: maillist(at)candle(dot)pha(dot)pa(dot)us (Bruce Momjian)
Cc: t-ishii(at)sra(dot)co(dot)jp, hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] questionable code in heap_formtuple()]
Date: 1998-09-04 18:07:18
Message-ID: 199809041807.OAA14198@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > > around line 812 in access/common/heaptuple.c:
> > >
> > > len = sizeof *tuple - sizeof tuple->t_bits;
> > >
> > > This seems questionable for me.
>
>
> > > I think more acculate way to calculate the offset is:
> > >
> > > len = (char *)&tuple->t_bits[0] - (char *)tuple;
>
> OK, now I am more confused. Doesn't this work:
>
> len = sizeof(HeapTupleData) - offsetof(HeapTupleData.t_bits);
>
> while your solution is finding the size of the area before t_bits?

OK, I finally get it. I was thinking HeapTupleData had the tuple data
in the structure, while obviously it does not.

Sometimes there is no HeapTuple to get the size of at the point you need
it, so I have applied a patch to do

len = offsetof(HeapTupleData.t_bits);

which should fix the obvious problem Tatsuo Ishii found. Does that fix
anything, index people?

--
Bruce Momjian | 830 Blythe Avenue
maillist(at)candle(dot)pha(dot)pa(dot)us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1998-09-04 18:15:55 Re: CIDR/IP types. Was: [GENERAL] big numbers
Previous Message Paul A Vixie 1998-09-04 17:58:01 Re: [HACKERS] Re: hackers-digest V1 #954