postgresql-jdbc.git / summary / log / commit / refs

commit    bbd8fdcd7831d9de0fd5be617d44e1eb7691354b
Author:   Sehrope Sarkuni <sehrope@jackdb.com>
Date:     Wed Aug 19 10:33:40 2026 +0000

    docs: record the CopyData limit as a deliberate decision
    
    CopyData keeps the MaxAllocSize limit, so if the stream goes out of sync
    inside a COPY or a replication stream the driver can still allocate up
    to a gigabyte once. The protocol gives this message no smaller limit.
    The backend builds one per COPY row or per logical replication message,
    either of which can legitimately approach that size, so any lower limit
    would be arbitrary.
    
    The alternative was to limit it with maxResultBuffer. That was rejected
    because the property is documented for result sets, and extending it
    would silently change what an existing setting does.


pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java b/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java index af911869..ccde8814 100644 --- a/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java +++ b/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java @@ -1550,6 +1550,10 @@ public class QueryExecutorImpl extends QueryExecutorBase { LOGGER.log(Level.FINEST, " <=BE CopyData"); + // CopyData keeps the MaxAllocSize limit. The protocol gives it no smaller one, and + // a COPY row or a logical replication message can be that large, so if the stream + // goes out of sync inside a COPY the driver can still make one large allocation. + // maxResultBuffer is documented for result sets, so it is not used here. len = pgStream.receiveMessageLength("CopyData", 4, PGStream.MAX_MESSAGE_LENGTH) - 4; byte[] buf = pgStream.receive(len); [parent: 4a9decdbab96]