MCPcopy
hub / github.com/jackc/pgx / newChunkReader

Function newChunkReader

pgproto3/chunkreader.go:25–41  ·  view source on GitHub ↗

newChunkReader creates and returns a new chunkReader for r with default configuration. If minBufSize is <= 0 it uses a default value.

(r io.Reader, minBufSize int)

Source from the content-addressed store, hash-verified

23// newChunkReader creates and returns a new chunkReader for r with default configuration. If minBufSize is <= 0 it uses
24// a default value.
25func newChunkReader(r io.Reader, minBufSize int) *chunkReader {
26 if minBufSize <= 0 {
27 // By historical reasons Postgres currently has 8KB send buffer inside,
28 // so here we want to have at least the same size buffer.
29 // @see https://github.com/postgres/postgres/blob/249d64999615802752940e017ee5166e726bc7cd/src/backend/libpq/pqcomm.c#L134
30 // @see https://www.postgresql.org/message-id/0cdc5485-cb3c-5e16-4a46-e3b2f7a41322%40ya.ru
31 //
32 // In addition, testing has found no benefit of any larger buffer.
33 minBufSize = 8192
34 }
35
36 return &chunkReader{
37 r: r,
38 minBufSize: minBufSize,
39 buf: iobufpool.Get(minBufSize),
40 }
41}
42
43// Next returns buf filled with the next n bytes. buf is only valid until next call of Next. If an error occurs, buf
44// will be nil.

Callers 4

TestChunkReaderNextFuzzFunction · 0.85
NewFrontendFunction · 0.85
NewBackendFunction · 0.85

Calls 1

GetFunction · 0.92