The following bug has been logged online:
Bug reference: 5237
Logged by: Roman Kononov
Email address: kononov@ftml.net
PostgreSQL version: 8.4.1
Operating system: GNU/Linux x86_64
Description: strange int->bit and bit->int conversions
Details:
test=# select (11::int4<<23 | 11::int4)::bit(32);
00000101100000000000000000001011
test=# select (11::int4<<23 | 11::int4)::bit(33);
000001011100000000000000000001011
test=# select (11::int4<<23 | 11::int4)::bit(39);
000001010000101100000000000000000001011
test=# select (11::int4<<23 | 11::int4)::bit(40);
0000000000000101100000000000000000001011
The ::bit(33) and ::bit(39) conversions seem wrong.
test-std=# select 1::int4::bit(32)::int4;
1
test-std=# select 1::int4::bit(33)::int4;
ERROR: integer out of range
Why is it out of range?