Fix assorted integer-overflow hazards in varbit.c.
Fix assorted integer-overflow hazards in varbit.c.

bitshiftright() and bitshiftleft() would recursively call each other
infinitely if the user passed INT_MIN for the shift amount, due to integer
overflow in negating the shift amount.  To fix, clamp to -VARBITMAXLEN.
That doesn't change the results since any shift distance larger than the
input bit string's length produces an all-zeroes result.

Also fix some places that seemed inadequately paranoid about input typmods
exceeding VARBITMAXLEN.  While a typmod accepted by anybit_typmodin() will
certainly be much less than that, at least some of these spots are
reachable with user-chosen integer values.

Andreas Seltenreich and Tom Lane

Discussion: <4a44c085c120c0bc781fe13580463358972565bb@credativ.de>

lisakowen/gpdb,adam8157/gpdb,greenplum-db/gpdb,lisakowen/gpdb,adam8157/gpdb,greenplum-db/gpdb,adam8157/gpdb,50wu/gpdb,xinzweb/gpdb,adam8157/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,xinzweb/gpdb,50wu/gpdb,50wu/gpdb,lisakowen/gpdb,lisakowen/gpdb,adam8157/gpdb,greenplum-db/gpdb,lisakowen/gpdb,adam8157/gpdb,xinzweb/gpdb,xinzweb/gpdb,xinzweb/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,lisakowen/gpdb,50wu/gpdb,xinzweb/gpdb,50wu/gpdb,50wu/gpdb,lisakowen/gpdb,adam8157/gpdb,xinzweb/gpdb,xinzweb/gpdb,50wu/gpdb,greenplum-db/gpdb,adam8157/gpdb,lisakowen/gpdb,50wu/gpdb