@@ -12,8 +12,10 @@ mod odbc_bridge;
1212use crate :: odbc:: { OdbcStatement , OdbcStatementMetadata } ;
1313use futures_core:: future:: BoxFuture ;
1414use futures_util:: future;
15- use odbc_api:: ConnectionTransitions ;
16- use odbc_api:: { handles:: StatementConnection , Prepared , ResultSetMetadata , SharedConnection } ;
15+ use odbc_api:: {
16+ handles:: StatementConnection , ConnectionTransitions , Prepared , ResultSetMetadata ,
17+ SharedConnection ,
18+ } ;
1719use odbc_bridge:: { establish_connection, execute_sql} ;
1820use std:: borrow:: Cow ;
1921use std:: sync:: { Arc , Mutex } ;
@@ -37,6 +39,7 @@ fn collect_columns(
3739 Ok ( count) => count,
3840 Err ( error) if allow_deferred_result_columns && parameter_count > 0 => {
3941 log:: debug!( "ODBC prepare deferred result columns until execution: {error}" ) ;
42+ validate_parameter_metadata ( prepared, parameter_count) ?;
4043 return Ok ( CollectedColumns {
4144 columns : Vec :: new ( ) ,
4245 deferred : true ,
@@ -55,6 +58,18 @@ fn collect_columns(
5558 } )
5659}
5760
61+ fn validate_parameter_metadata (
62+ prepared : & mut PreparedStatement ,
63+ parameter_count : usize ,
64+ ) -> Result < ( ) , Error > {
65+ for index in 1 ..=parameter_count {
66+ let parameter_number = u16:: try_from ( index)
67+ . map_err ( |_| Error :: Protocol ( format ! ( "ODBC parameter index {index} exceeds u16" ) ) ) ?;
68+ prepared. describe_param ( parameter_number) ?;
69+ }
70+ Ok ( ( ) )
71+ }
72+
5873fn collect_statement_metadata (
5974 prepared : & mut PreparedStatement ,
6075 allow_deferred_result_columns : bool ,
0 commit comments