ITADN

Add optional resultset and parameter type to QueryParser trait

#355Opensunng87 创建于 2025-11-26
enhancement
S
sunng87commented
## rationale In postgres, once a query is parsed into plan, it will be able to extract all parameter types, as well as resultset schema, including name and type for each column. To respond `Describe` command in extended query, postgres will use these information to return parameter types and results. There is also chances client will specify types for some of the parameters, the server should accept client given types. Developer has to implement this logic correctly otherwise some client drivers may throw error. ## solution I'm going to add two new functions to `QueryParser` trait, for developers whose query engine is capable to compute those type information from a parsed `Statement`, they can provide implementation for these two functions: - `fn get_parameter_types(&self, _stmt: Self::Statement) -> Vec<Type>` - `fn get_result_schema(&self, _stmt: Self::Statement) -> Vec<FieldInfo>` With all this information, we will be able to provide auto implementation of `do_describe_statement` and `do_describe_portal`, and make sure they compatible with postgres driver assumption. Some query engines doesn't have this capability, or didn't expose enough information for this, developers will need to implement `do_describe_statement` and `do_describe_portal` by their own.
0 条评论