Add ParameterDescription message to libpq frontend long message types

Started by Ning Sun4 days ago2 messageshackers
Jump to latest
#1Ning Sun
classicning@gmail.com

Hi,

I'm maintaining a Rust library pgwire to implement postgres wire
protocol in rust. While doing a corner case test, I noticed the
inconsistency for ParameterDescription between backend and frontend.

The backend allows up to 65535 parameters in a prepared statement. But
when running Describe on the statement, there is a size limit of 30000
bytes for ParameterDescription on the frontend. This means we can only
describe statements with at most ~7500 parameters. For statements exceed
the limit, it ends up with error about the message size.

This patch simply adds ParameterDescription to VALID_LONG_MESSAGE_TYPE
whitelist to remove the cap.

Attachments:

0001-add-ParameterDescription-to-long-message-types.patchtext/x-patch; charset=UTF-8; name=0001-add-ParameterDescription-to-long-message-types.patchDownload+2-2
#2jie wang
jugierwang@gmail.com
In reply to: Ning Sun (#1)
Re: Add ParameterDescription message to libpq frontend long message types

Ning Sun <classicning@gmail.com> 于2026年4月2日周四 08:52写道:

Hi,

I'm maintaining a Rust library pgwire to implement postgres wire
protocol in rust. While doing a corner case test, I noticed the
inconsistency for ParameterDescription between backend and frontend.

The backend allows up to 65535 parameters in a prepared statement. But
when running Describe on the statement, there is a size limit of 30000
bytes for ParameterDescription on the frontend. This means we can only
describe statements with at most ~7500 parameters. For statements exceed
the limit, it ends up with error about the message size.

This patch simply adds ParameterDescription to VALID_LONG_MESSAGE_TYPE
whitelist to remove the cap.

Hi,

Based on my understanding, this approach is safe for the following reasons:

1. The message format is clearly defined and has been properly handled.
2. Similar message types (such as RowDescription) are already allowed to
exceed this limit.
3. No changes have been introduced at the protocol level.

Thanks!
wang jie