sfackler / rust-postgres

Native PostgreSQL driver for the Rust programming language
Apache License 2.0
3.42k stars 436 forks source link

Schema for empty results? #1086

Closed maxburke closed 8 months ago

maxburke commented 8 months ago

Is it possible to get the schema for queries that return no rows? For example, if Client::query doesn't return any rows it isn't possible to get the schema of the result set via the tokio_postgres API, as far as I can tell?

Looking at the protocol docs (https://www.postgresql.org/docs/current/protocol-flow.html) I think that it might be possible to do so by looking at the RowDescription message, regardless if there are DataRow messages?

sfackler commented 8 months ago

Explicitly call Client::prepare first.

maxburke commented 8 months ago

That definitely works; thanks!