I have now pushed this to 9.5, 9.6 and master. It could be backpatched
to 9.4 with ease (just a small change in heap_form_tuple); anything
further back would require much more effort.
I used a 32-bit limit using sizeof(int32). I tested and all the
mentioned cases seem to work sanely; if you can spare some more time to
test what was committed, I'd appreciate it.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services