pgjdbc/pgjdbc — pull request #220 by alexismeneses (2014-11-23 20:38:20+00:00)
Title: Support for setBinaryStream with unknown length

Proposed fix for #213

By protocol design, it's actually impossible to send a BYTEA to the backend without knowing its size beforehand.

So in this fix, when an inputStream without length is used as a prepared statement parameter using ```setBinaryStream()```, the given stream is consumed immediately and buffered either in memory or on disk.
This way, the size is known and the data is read from the buffer instead.

The toggle between memory and disk is set at 50kb (see ```MAX_MEMORY_CACHE_BYTES```), any opinion about that is welcome.

Also, the on-disk buffer is done using regular Java tempfile, deleted when the end of stream is reached. I wonder if it can be an issue in some situations/environments?