Make bit/varbit substring() treat any negative length as meaning "all the rest
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 7 Jan 2010 19:53:27 +0000 (19:53 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 7 Jan 2010 19:53:27 +0000 (19:53 +0000)
commit26098d8f8650d3ee667b75de54c6977b7ef021b3
tree3eb75fe5051aada8603fadf5dd8451cf21775b33
parent2de646cd8f31318b1642c0f2cb717b32207d53e0
Make bit/varbit substring() treat any negative length as meaning "all the rest
of the string".  The previous coding treated only -1 that way, and would
produce an invalid result value for other negative values.

We ought to fix it so that 2-parameter bit substring() is a different C
function and the 3-parameter form throws error for negative length, but
that takes a pg_proc change which is impractical in the back branches;
and in any case somebody might be relying on -1 working this way.
So just do this as a back-patchable fix.
src/backend/utils/adt/varbit.c