Re: BUG #5237: strange int->bit and bit->int conversions - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5237: strange int->bit and bit->int conversions
Date
Msg-id 11277.1260646119@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #5237: strange int->bit and bit->int conversions  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-bugs
Robert Haas <robertmhaas@gmail.com> writes:
>> I'm not sure this fixes it, although I haven't tested.  When we take
>> the /* store first fractional byte */ branch, destbitsleft is between
>> 1 and 7 bits greater than srcbitsleft.  We then subtract 8 from
>> destbitsleft, and the comment on the next line now asserts that the
>> two are equal.  That doesn't seem right.

The comment's a bit bogus.  What it should say, probably, is that the
*correct* value of srcbitsleft is now equal to destbitsleft so we aren't
bothering to track it anymore.  If we were being fully anal we'd have
reduced srcbitsleft by some number less than 8 inside the if-branch.

>> Also, I thought about the sign extension problem, but aren't we
>> chopping those bits off anyway on the next line?

Nope, we'd have already stored the wrong bits into the output byte.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Robert Haas
Date:
Subject: Re: BUG #5237: strange int->bit and bit->int conversions
Next
From: Tom Lane
Date:
Subject: Re: BUG #5238: frequent signal 11 segfaults