Handle empty extended queries - #453
Conversation
| let describe_response = if portal.statement.statement.is_none() { | ||
| DescribePortalResponse::no_data() | ||
| } else { | ||
| self.do_describe_portal(client, &portal).await? |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
A bool would still need a value for S when parsing is skipped, which means parsing the empty query again or requiring S: Default. I kept the Option and handled None directly in the examples. Does that work for you?
There was a problem hiding this comment.
yes but without the bool, even if we can return EmptyQuery in our default handler implementation, the user will still need to deal with the Option and have duplicated EmptyQuery logic.
There was a problem hiding this comment.
A possible new idea is to update our PortalStore API to store empty query specifically. A breaking change at PortalStore is fine because it's rarely directly used in user code.
Fixes #304.
Empty
Parsemessages now keep an empty statement instead of invoking the query parser.DescribeandExecutereturn the protocol responses expected by PostgreSQL clients, including when handlers override the describe methods.Tests:
cargo test -p pgwirecargo test --test empty_extended_querycargo check -p pgwire --examplescargo check --manifest-path tests-integration/test-server/Cargo.tomlcargo clippy -p pgwire --lib -- -D warnings