Fix ancient bug of stream write modules.
- Fix bug with pool_write_noerror() when requested length exceeds
remaining write buffer size. This could lead to a buffer overrun
problem, which has not been reported in the field as far as I know
though.
- When write buffer is full, pool_flush_it() is called, which could
write data to socket in the middle of message. I found this by using
following pgproto data. To fix the problem directly write requested
data if the write buffer is going to be full.
'P' "" "SELECT * FROM pgbench_accounts LIMIT 100" 0
'B' "" "" 0 0 0
'E' "" 0
'S'
'Y'
'X'
- Enhance performance of pool_unread(). When retrieving large number
of rows in streaming replication and extended query, pool_unread is
very slow because it needs to memmove large number of bytes in the
read buffer. This happens in read_kind_from_backend() since it uses
pool_unread() to check 'A' packet. To optimize the situation, modify
pool_unread(). If there's enough room in front of cp->po, copies the
data there to avoid memmove.