Skip to content

Handle empty extended queries - #453

Open
Guflly wants to merge 2 commits into
sunng87:masterfrom
Guflly:fix/empty-extended-query
Open

Handle empty extended queries#453
Guflly wants to merge 2 commits into
sunng87:masterfrom
Guflly:fix/empty-extended-query

Conversation

@Guflly

@Guflly Guflly commented Aug 2, 2026

Copy link
Copy Markdown

Fixes #304.

Empty Parse messages now keep an empty statement instead of invoking the query parser. Describe and Execute return the protocol responses expected by PostgreSQL clients, including when handlers override the describe methods.

Tests:

  • cargo test -p pgwire
  • cargo test --test empty_extended_query
  • cargo check -p pgwire --examples
  • cargo check --manifest-path tests-integration/test-server/Cargo.toml
  • cargo clippy -p pgwire --lib -- -D warnings

Comment thread examples/cursor.rs
pgwire::api::portal::PortalExecutionState::Initial
) {
let inner_query = &portal.statement.statement;
let inner_query = portal.statement.statement.as_ref().unwrap();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we avoid using a hard unwrap in the examples? try to provide demo for how to handle empty statement

Comment thread src/api/query.rs
let describe_response = if portal.statement.statement.is_none() {
DescribePortalResponse::no_data()
} else {
self.do_describe_portal(client, &portal).await?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this api implementation, we will still need to check portal.statement.statement.is_none() or use a hard unwrap just like the examples. I wonder if we can avoid the Option<> in statement, and use a bool field in our Statement struct to indicate if a statement is empty.

WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty query in extended query

2 participants