On 13.02.2019 17:54, Dmitry Dolgov wrote:
On Wed, Feb 13, 2019 at 3:52 PM Dmitry Dolgov <9erthali...@gmail.com> wrote:

On Wed, Feb 13, 2019 at 3:46 PM Konstantin Knizhnik
<k.knizh...@postgrespro.ru> wrote:

Moreover, please notice that your implementation is still passing functions
tx/rx functions to stream constructor and so zpq_read is still able to read
data itself. So I do not understand which problem you have solved by
replacing zpq_read with pair of zpq_read_drain+zpq_read.
Nope, I've removed the call of these functions from zlib_read/write, just
forgot to remove the initialization part.
Oh, I see the source of confusion. Due to lack of time I've implemented my
changes only for zlib part, sorry that I didn't mention that before.
And I have looked at zstd part;)
Ok, but still I think that it is better to pass tx/rx function to stream.
There are two important advantages:
1. It eliminates code duplication.
2. It allows to use (in future) this streaming compression not only for libpq for for other streaming data.
And I do not see any disadvantages.

Concerning "layering violation" may be it is better to introduce some other functions something like inflate_read, deflate_write and call them instead of *secure_read. But from my point of view it will not improve readability and modularity of code.

--
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company


Reply via email to