From: vlsi (@vlsi) <noreply+vlsi@github.com>
To: pgjdbc/pgjdbc <noreply+pgjdbc-pgjdbc@github.com>
Subject: Re: [pgjdbc/pgjdbc] PR #4332: fix: limit FINEST Bind, Parse and SimpleQuery log messages to maxLogMessageLength to avoid OOM
Date: Wed, 14 Oct 2026 06:22:27 +0000
Message-ID: <gh-pgjdbc-pgjdbc-4332-rc4267444384@github.com> (raw)
In-Reply-To: <gh-pgjdbc-pgjdbc-4332@github.com>
References: <gh-pgjdbc-pgjdbc-4332@github.com>
(on pgjdbc/src/main/java/org/postgresql/core/v3/BindLog.java)
This estimate shows values that fit as cut. `quoteAndCast` adds no cast for `VARCHAR` or `TEXT`, but `castExtra` counts `::VARCHAR`, and the factor 2 assumes every character is a quote. A 60-character `VARCHAR` followed by an `int4` makes a 144-character trace, yet at every limit from 144 to 169 the trace shows `$1=<('vvv…v...>`, with all 60 characters, `...` in place of the closing `')`, and, at 144, no `)`. Please compute the exact literal length instead: count the quotes, and the backslashes when `standard_conforming_strings` is off, in one pass, and add the cast `quoteAndCast` actually writes.