On Mon, 01 Jul 2002 11:10:20 -0400, Tom Lane <tgl@sss.pgh.pa.us>
wrote:
>Yes, but I still think the Assert is useless. The only thing it can
>catch is failure to set t_hoff before touching the OID, but in practice
>if t_hoff has not been set then it will be uninitialized garbage; the
>odds that the Assert will actually fire are only about 1 in 10.
Sad, but true. Thanks for pointing that out.
AssertMacro((tup)->t_hoff >= offsetof(HeapTupleHeaderData, t_bits))
should be
AssertMacro((tup)->t_hoff == ExpectedLen(tup))
where
#define ExpectedLen(tup) MAXALIGN( \
offsetof(HeapTupleHeaderData, t_bits) + \
(((tup)->t_infomask | HEAP_HASNULL) \
? BITMAPLEN((tup)->t_natts) : 0) \
)
Sure, this is even more expensive, but it catches 255 out of 256
errors.
On Mon, 01 Jul 2002 10:40:34 -0400, Tom Lane <tgl@sss.pgh.pa.us> wrote
on -hackers:
>Also, you could be a little more conservative about
>adding Asserts --- those are not free, at least not from a development
>point of view, so I object to adding multiple redundant Asserts in
>hotspot routines.
Messing around with tuple headers is delicate stuff IMHO, and I don't
want to be remembered as the man who broke the best open source
database. So I cowardly put in those Asserts ... If you are concerned
about performance in development versions, is there any chance you
could be convinced of a configurable paranoia level? Then I could
write
Assert3(...)
which would expand to
if (PARANOIA_LEVEL >= 3) Assert(...)
Servus
Manfred