odbc_api/cursor.rs
1mod block_cursor;
2mod concurrent_block_cursor;
3mod polling_cursor;
4
5use log::warn;
6use odbc_sys::HStmt;
7
8use crate::{
9 Error, ResultSetMetadata,
10 buffers::Indicator,
11 error::ExtendResult,
12 handles::{
13 AsStatementRef, CDataMut, DiagnosticStream, SqlResult, State, Statement, StatementRef,
14 log_diagnostic_record,
15 },
16 parameter::{Binary, CElement, Text, VarCell, VarKind, WideText},
17};
18
19use std::{
20 mem::{MaybeUninit, size_of},
21 ptr,
22 thread::panicking,
23};
24
25pub use self::{
26 block_cursor::{BlockCursor, BlockCursorIterator},
27 concurrent_block_cursor::ConcurrentBlockCursor,
28 polling_cursor::{BlockCursorPolling, CursorPolling},
29};
30
31/// Cursors are used to process and iterate the result sets returned by executing queries.
32///
33/// # Example: Fetching result in batches
34///
35/// ```rust
36/// use odbc_api::{Cursor, buffers::{BufferDesc, ColumnarAnyBuffer}, Error};
37///
38/// /// Fetches all values from the first column of the cursor as i32 in batches of 100 and stores
39/// /// them in a vector.
40/// fn fetch_all_ints(cursor: impl Cursor) -> Result<Vec<i32>, Error> {
41/// let mut all_ints = Vec::new();
42/// // Batch size determines how many values we fetch at once.
43/// let batch_size = 100;
44/// // We expect the first column to hold INTEGERs (or a type convertible to INTEGER). Use
45/// // the metadata on the result set, if you want to investige the types of the columns at
46/// // runtime.
47/// let description = BufferDesc::I32 { nullable: false };
48/// // This is the buffer we bind to the driver, and repeatedly use to fetch each batch
49/// let buffer = ColumnarAnyBuffer::from_descs(batch_size, [description]);
50/// // Bind buffer to cursor
51/// let mut row_set_buffer = cursor.bind_buffer(buffer)?;
52/// // Fetch data batch by batch
53/// while let Some(batch) = row_set_buffer.fetch()? {
54/// all_ints.extend_from_slice(batch.column(0).as_slice().unwrap())
55/// }
56/// Ok(all_ints)
57/// }
58/// ```
59pub trait Cursor: ResultSetMetadata {
60 /// Advances the cursor to the next row in the result set. This is **Slow**. Bind
61 /// [`crate::buffers`] instead, for good performance.
62 ///
63 /// ⚠ While this method is very convenient due to the fact that the application does not have
64 /// to declare and bind specific buffers, it is also in many situations extremely slow. Concrete
65 /// performance depends on the ODBC driver in question, but it is likely it performs a roundtrip
66 /// to the datasource for each individual row. It is also likely an extra conversion is
67 /// performed then requesting individual fields, since the C buffer type is not known to the
68 /// driver in advance. Consider binding a buffer to the cursor first using
69 /// [`Self::bind_buffer`].
70 ///
71 /// That being said, it is a convenient programming model, as the developer does not need to
72 /// prepare and allocate the buffers beforehand. It is also a good way to retrieve really large
73 /// single values out of a data source (like one large text file). See [`CursorRow::get_text`].
74 fn next_row(&mut self) -> Result<Option<CursorRow<'_>>, Error> {
75 let row_available = unsafe {
76 self.as_stmt_ref()
77 .fetch()
78 .into_result_bool(&self.as_stmt_ref())?
79 };
80 let ret = if row_available {
81 Some(unsafe { CursorRow::new(self.as_stmt_ref()) })
82 } else {
83 None
84 };
85 Ok(ret)
86 }
87
88 /// Binds this cursor to a buffer holding a row set.
89 fn bind_buffer<B>(self, row_set_buffer: B) -> Result<BlockCursor<Self, B>, Error>
90 where
91 Self: Sized,
92 B: RowSetBuffer;
93
94 /// For some datasources it is possible to create more than one result set at once via a call to
95 /// execute. E.g. by calling a stored procedure or executing multiple SQL statements at once.
96 /// This method consumes the current cursor and creates a new one representing the next result
97 /// set should it exist.
98 fn more_results(self) -> Result<Option<Self>, Error>
99 where
100 Self: Sized;
101}
102
103/// An individual row of an result set. See [`crate::Cursor::next_row`].
104pub struct CursorRow<'s> {
105 statement: StatementRef<'s>,
106}
107
108impl<'s> CursorRow<'s> {
109 /// # Safety
110 ///
111 /// `statement` must be in a cursor state.
112 unsafe fn new(statement: StatementRef<'s>) -> Self {
113 CursorRow { statement }
114 }
115}
116
117impl CursorRow<'_> {
118 /// Fills a suitable target buffer with a field from the current row of the result set. This
119 /// method drains the data from the field. It can be called repeatedly to if not all the data
120 /// fit in the output buffer at once. It should not called repeatedly to fetch the same value
121 /// twice. Column index starts at `1`.
122 ///
123 /// You can use [`crate::Nullable`] to fetch nullable values.
124 ///
125 /// # Example
126 ///
127 /// ```
128 /// # use odbc_api::{Cursor, Error, Nullable};
129 /// # fn fetch_values_example(cursor: &mut impl Cursor) -> Result<(), Error> {
130 /// // Declare nullable value to fetch value into. ODBC values layout is different from Rusts
131 /// // option. We can not use `Option<i32>` directly.
132 /// let mut field = Nullable::<i32>::null();
133 /// // Move cursor to next row
134 /// let mut row = cursor.next_row()?.unwrap();
135 /// // Fetch first column into field
136 /// row.get_data(1, &mut field)?;
137 /// // Convert nullable value to Option for convinience
138 /// let field = field.into_opt();
139 /// if let Some(value) = field {
140 /// println!("Value: {}", value);
141 /// } else {
142 /// println!("Value is NULL");
143 /// }
144 /// # Ok(())
145 /// # }
146 /// ```
147 pub fn get_data(
148 &mut self,
149 col_or_param_num: u16,
150 target: &mut (impl CElement + CDataMut),
151 ) -> Result<(), Error> {
152 self.statement
153 .get_data(col_or_param_num, target)
154 .into_result(&self.statement)
155 .provide_context_for_diagnostic(|record, function| {
156 if record.state == State::INDICATOR_VARIABLE_REQUIRED_BUT_NOT_SUPPLIED {
157 Error::UnableToRepresentNull(record)
158 } else {
159 Error::Diagnostics { record, function }
160 }
161 })
162 }
163
164 /// Retrieves arbitrary large character data from the row and stores it in the buffer. Column
165 /// index starts at `1`. The used encoding is accordig to the ODBC standard determined by your
166 /// system local. Ultimatly the choice is up to the implementation of your ODBC driver, which
167 /// often defaults to always UTF-8.
168 ///
169 /// # Example
170 ///
171 /// Retrieve an arbitrary large text file from a database field.
172 ///
173 /// ```
174 /// use odbc_api::{Connection, Error, IntoParameter, Cursor};
175 ///
176 /// fn get_large_text(name: &str, conn: &mut Connection<'_>) -> Result<Option<String>, Error> {
177 /// let query = "SELECT content FROM LargeFiles WHERE name=?";
178 /// let parameters = &name.into_parameter();
179 /// let timeout_sec = None;
180 /// let mut cursor = conn
181 /// .execute(query, parameters, timeout_sec)?
182 /// .expect("Assume select statement creates cursor");
183 /// if let Some(mut row) = cursor.next_row()? {
184 /// let mut buf = Vec::new();
185 /// row.get_text(1, &mut buf)?;
186 /// let ret = String::from_utf8(buf).unwrap();
187 /// Ok(Some(ret))
188 /// } else {
189 /// Ok(None)
190 /// }
191 /// }
192 /// ```
193 ///
194 /// # Return
195 ///
196 /// `true` indicates that the value has not been `NULL` and the value has been placed in `buf`.
197 /// `false` indicates that the value is `NULL`. The buffer is cleared in that case.
198 pub fn get_text(&mut self, col_or_param_num: u16, buf: &mut Vec<u8>) -> Result<bool, Error> {
199 self.get_variadic::<Text>(col_or_param_num, buf)
200 }
201
202 /// Retrieves arbitrary large character data from the row and stores it in the buffer. Column
203 /// index starts at `1`. The used encoding is UTF-16.
204 ///
205 /// # Return
206 ///
207 /// `true` indicates that the value has not been `NULL` and the value has been placed in `buf`.
208 /// `false` indicates that the value is `NULL`. The buffer is cleared in that case.
209 pub fn get_wide_text(
210 &mut self,
211 col_or_param_num: u16,
212 buf: &mut Vec<u16>,
213 ) -> Result<bool, Error> {
214 self.get_variadic::<WideText>(col_or_param_num, buf)
215 }
216
217 /// Retrieves arbitrary large binary data from the row and stores it in the buffer. Column index
218 /// starts at `1`.
219 ///
220 /// # Return
221 ///
222 /// `true` indicates that the value has not been `NULL` and the value has been placed in `buf`.
223 /// `false` indicates that the value is `NULL`. The buffer is cleared in that case.
224 pub fn get_binary(&mut self, col_or_param_num: u16, buf: &mut Vec<u8>) -> Result<bool, Error> {
225 self.get_variadic::<Binary>(col_or_param_num, buf)
226 }
227
228 fn get_variadic<K: VarKind>(
229 &mut self,
230 col_or_param_num: u16,
231 buf: &mut Vec<K::Element>,
232 ) -> Result<bool, Error> {
233 if buf.capacity() == 0 {
234 // User did just provide an empty buffer. So it is fair to assume not much domain
235 // knowledge has been used to decide its size. We just default to 256 to increase the
236 // chance that we get it done with one alloctaion. The buffer size being 0 we need at
237 // least 1 anyway. If the capacity is not `0` we'll leave the buffer size untouched as
238 // we do not want to prevent users from providing better guessen based on domain
239 // knowledge.
240 // This also implicitly makes sure that we can at least hold one terminating zero.
241 buf.reserve(256);
242 }
243 // Utilize all of the allocated buffer.
244 buf.resize(buf.capacity(), K::ZERO);
245
246 // Did we learn how much capacity we need in the last iteration? We use this only to panic
247 // on erroneous implementations of get_data and avoid endless looping until we run out of
248 // memory.
249 let mut remaining_length_known = false;
250 // We repeatedly fetch data and add it to the buffer. The buffer length is therefore the
251 // accumulated value size. The target always points to the last window in buf which is going
252 // to contain the **next** part of the data, whereas buf contains the entire accumulated
253 // value so far.
254 let mut target =
255 VarCell::<&mut [K::Element], K>::from_buffer(buf.as_mut_slice(), Indicator::NoTotal);
256 self.get_data(col_or_param_num, &mut target)?;
257 while !target.is_complete() {
258 // Amount of payload bytes (excluding terminating zeros) fetched with the last call to
259 // get_data.
260 let fetched = target
261 .len_in_bytes()
262 .expect("ODBC driver must always report how many bytes were fetched.");
263 match target.indicator() {
264 // If Null the value would be complete
265 Indicator::Null => unreachable!(),
266 // We do not know how large the value is. Let's fetch the data with repeated calls
267 // to get_data.
268 Indicator::NoTotal => {
269 let old_len = buf.len();
270 // Use an exponential strategy for increasing buffer size.
271 buf.resize(old_len * 2, K::ZERO);
272 let buf_extend = &mut buf[(old_len - K::TERMINATING_ZEROES)..];
273 target = VarCell::<&mut [K::Element], K>::from_buffer(
274 buf_extend,
275 Indicator::NoTotal,
276 );
277 }
278 // We did not get all of the value in one go, but the data source has been friendly
279 // enough to tell us how much is missing.
280 Indicator::Length(len) => {
281 if remaining_length_known {
282 panic!(
283 "SQLGetData has been unable to fetch all data, even though the \
284 capacity of the target buffer has been adapted to hold the entire \
285 payload based on the indicator of the last part. You may consider \
286 filing a bug with the ODBC driver you are using."
287 )
288 }
289 remaining_length_known = true;
290 // Amount of bytes missing from the value using get_data, excluding terminating
291 // zero.
292 let still_missing_in_bytes = len - fetched;
293 let still_missing = still_missing_in_bytes / size_of::<K::Element>();
294 let old_len = buf.len();
295 buf.resize(old_len + still_missing, K::ZERO);
296 let buf_extend = &mut buf[(old_len - K::TERMINATING_ZEROES)..];
297 target = VarCell::<&mut [K::Element], K>::from_buffer(
298 buf_extend,
299 Indicator::NoTotal,
300 );
301 }
302 }
303 // Fetch binary data into buffer.
304 self.get_data(col_or_param_num, &mut target)?;
305 }
306 // We did get the complete value, including the terminating zero. Let's resize the buffer to
307 // match the retrieved value exactly (excluding terminating zero).
308 if let Some(len_in_bytes) = target.indicator().length() {
309 // Since the indicator refers to value length without terminating zero, and capacity is
310 // including the terminating zero this also implicitly drops the terminating zero at the
311 // end of the buffer.
312 let shrink_by_bytes = target.capacity_in_bytes() - len_in_bytes;
313 let shrink_by_chars = shrink_by_bytes / size_of::<K::Element>();
314 buf.resize(buf.len() - shrink_by_chars, K::ZERO);
315 Ok(true)
316 } else {
317 // value is NULL
318 buf.clear();
319 Ok(false)
320 }
321 }
322}
323
324/// Cursors are used to process and iterate the result sets returned by executing queries. Created
325/// by either a prepared query or direct execution. Usually utilized through the [`crate::Cursor`]
326/// trait.
327#[derive(Debug)]
328pub struct CursorImpl<Stmt: Statement> {
329 /// A statement handle in cursor mode.
330 statement: Stmt,
331}
332
333impl<S> Drop for CursorImpl<S>
334where
335 S: Statement,
336{
337 fn drop(&mut self) {
338 if let Err(e) = self
339 .statement
340 .end_cursor_scope()
341 .into_result(&self.statement)
342 {
343 // Avoid panicking, if we already have a panic. We don't want to mask the original
344 // error.
345 if !panicking() {
346 panic!("Unexpected error closing cursor: {e:?}")
347 }
348 }
349 }
350}
351
352impl<S> AsStatementRef for CursorImpl<S>
353where
354 S: Statement,
355{
356 fn as_stmt_ref(&mut self) -> StatementRef<'_> {
357 self.statement.as_stmt_ref()
358 }
359}
360
361impl<S> ResultSetMetadata for CursorImpl<S> where S: Statement {}
362
363impl<S> Cursor for CursorImpl<S>
364where
365 S: Statement,
366{
367 fn bind_buffer<B>(mut self, mut row_set_buffer: B) -> Result<BlockCursor<Self, B>, Error>
368 where
369 B: RowSetBuffer,
370 {
371 let stmt = self.statement.as_stmt_ref();
372 unsafe {
373 bind_row_set_buffer_to_statement(stmt, &mut row_set_buffer)?;
374 }
375 Ok(BlockCursor::new(row_set_buffer, self))
376 }
377
378 fn more_results(self) -> Result<Option<Self>, Error>
379 where
380 Self: Sized,
381 {
382 // Consume self without calling drop to avoid calling close_cursor.
383 let mut statement = self.into_stmt();
384
385 let has_another_result =
386 unsafe { statement.more_results() }.into_result_bool(&statement)?;
387 let next = if has_another_result {
388 Some(CursorImpl { statement })
389 } else {
390 None
391 };
392 Ok(next)
393 }
394}
395
396impl<S> CursorImpl<S>
397where
398 S: Statement,
399{
400 /// Users of this library are encouraged not to call this constructor directly but rather invoke
401 /// [`crate::Connection::execute`] or [`crate::Prepared::execute`] to get a cursor and utilize
402 /// it using the [`crate::Cursor`] trait. This method is public so users with an understanding
403 /// of the raw ODBC C-API have a way to create a cursor, after they left the safety rails of the
404 /// Rust type System, in order to implement a use case not covered yet, by the safe abstractions
405 /// within this crate.
406 ///
407 /// # Safety
408 ///
409 /// `statement` must be in Cursor state, for the invariants of this type to hold.
410 pub unsafe fn new(statement: S) -> Self {
411 Self { statement }
412 }
413
414 /// Deconstructs the `CursorImpl` without calling drop. This is a way to get to the underlying
415 /// statement, while preventing a call to close cursor.
416 pub fn into_stmt(self) -> S {
417 // We want to move `statement` out of self, which would make self partially uninitialized.
418 let dont_drop_me = MaybeUninit::new(self);
419 let self_ptr = dont_drop_me.as_ptr();
420
421 // Safety: We know `dont_drop_me` is valid at this point so reading the ptr is okay
422 unsafe { ptr::read(&(*self_ptr).statement) }
423 }
424
425 pub(crate) fn as_sys(&mut self) -> HStmt {
426 self.as_stmt_ref().as_sys()
427 }
428}
429
430/// A Row set buffer binds row, or column wise buffers to a cursor in order to fill them with row
431/// sets with each call to fetch.
432///
433/// # Safety
434///
435/// Implementers of this trait must ensure that every pointer bound in `bind_to_cursor` stays valid
436/// even if an instance is moved in memory. Bound members should therefore be likely references
437/// themselves. To bind stack allocated buffers it is recommended to implement this trait on the
438/// reference type instead.
439pub unsafe trait RowSetBuffer {
440 /// Declares the bind type of the Row set buffer. `0` Means a columnar binding is used. Any non
441 /// zero number is interpreted as the size of a single row in a row wise binding style.
442 fn bind_type(&self) -> usize;
443
444 /// The batch size for bulk cursors, if retrieving many rows at once.
445 fn row_array_size(&self) -> usize;
446
447 /// Mutable reference to the number of fetched rows.
448 ///
449 /// # Safety
450 ///
451 /// Implementations of this method must take care that the returned referenced stays valid, even
452 /// if `self` should be moved.
453 fn mut_num_fetch_rows(&mut self) -> &mut usize;
454
455 /// Binds the buffer either column or row wise to the cursor.
456 ///
457 /// # Safety
458 ///
459 /// It's the implementation's responsibility to ensure that all bound buffers are valid until
460 /// unbound or the statement handle is deleted.
461 unsafe fn bind_colmuns_to_cursor(&mut self, cursor: StatementRef<'_>) -> Result<(), Error>;
462
463 /// Find an indicator larger than the maximum element size of the buffer.
464 fn find_truncation(&self) -> Option<TruncationInfo>;
465}
466
467/// Returned by [`RowSetBuffer::find_truncation`]. Contains information about the truncation found.
468#[derive(Clone, Copy, PartialEq, Eq, Debug)]
469pub struct TruncationInfo {
470 /// Length of the untruncated value if known
471 pub indicator: Option<usize>,
472 /// Zero based buffer index of the column in which the truncation occurred.
473 pub buffer_index: usize,
474}
475
476unsafe impl<T: RowSetBuffer> RowSetBuffer for &mut T {
477 fn bind_type(&self) -> usize {
478 (**self).bind_type()
479 }
480
481 fn row_array_size(&self) -> usize {
482 (**self).row_array_size()
483 }
484
485 fn mut_num_fetch_rows(&mut self) -> &mut usize {
486 (*self).mut_num_fetch_rows()
487 }
488
489 unsafe fn bind_colmuns_to_cursor(&mut self, cursor: StatementRef<'_>) -> Result<(), Error> {
490 unsafe { (*self).bind_colmuns_to_cursor(cursor) }
491 }
492
493 fn find_truncation(&self) -> Option<TruncationInfo> {
494 (**self).find_truncation()
495 }
496}
497
498/// Binds a row set buffer to a statment. Implementation is shared between synchronous and
499/// asynchronous cursors.
500unsafe fn bind_row_set_buffer_to_statement(
501 mut stmt: StatementRef<'_>,
502 row_set_buffer: &mut impl RowSetBuffer,
503) -> Result<(), Error> {
504 unsafe {
505 stmt.set_row_bind_type(row_set_buffer.bind_type())
506 .into_result(&stmt)?;
507 let size = row_set_buffer.row_array_size();
508 let sql_result = stmt.set_row_array_size(size);
509
510 // Search for "option value changed". A QODBC driver reported "option value changed", yet
511 // set the value to `723477590136`. We want to panic if something like this happens.
512 //
513 // See: <https://github.com/pacman82/odbc-api/discussions/742#discussioncomment-13887516>
514 let mut diagnostic_stream = DiagnosticStream::new(&stmt);
515 // We just rememeber that we have seen "option value changed", before asking for the array
516 // size, in order to not mess with other diagnostic records.
517 let mut option_value_changed = false;
518 while let Some(record) = diagnostic_stream.next() {
519 log_diagnostic_record(record);
520 if record.state == State::OPTION_VALUE_CHANGED {
521 option_value_changed = true;
522 }
523 }
524 if option_value_changed {
525 // Now rejecting a too large buffer size is save, but not if the value is something
526 // even larger after. Zero is also suspicious.
527 let actual_size = stmt.row_array_size().into_result(&stmt)?;
528 #[cfg(not(feature = "structured_logging"))]
529 warn!(
530 "Row array size set by the driver to: {actual_size}. Desired size had been: {size}"
531 );
532 #[cfg(feature = "structured_logging")]
533 warn!(
534 target: "odbc_api",
535 requested = size,
536 actual = actual_size;
537 "Row array size overridden by driver"
538 );
539 if actual_size > size || actual_size == 0 {
540 panic!(
541 "Your ODBC buffer changed the array size for bulk fetchin in an unsound way. \
542 To prevent undefined behavior the application must panic. You can try \
543 different batch sizes for bulk fetching, or report a bug with your ODBC driver \
544 provider. This behavior has been observed with QODBC drivers. If you are using \
545 one try fetching row by row rather than the faster bulk fetch."
546 )
547 }
548 }
549
550 sql_result
551 // We already logged diagnostic records then we were looking for Option value changed
552 .into_result_without_logging(&stmt)
553 // SAP anywhere has been seen to return with an "invalid attribute" error instead of
554 // a success with "option value changed" info. Let us map invalid attributes during
555 // setting row set array size to something more precise.
556 .provide_context_for_diagnostic(|record, function| {
557 if record.state == State::INVALID_ATTRIBUTE_VALUE {
558 Error::InvalidRowArraySize { record, size }
559 } else {
560 Error::Diagnostics { record, function }
561 }
562 })?;
563 stmt.set_num_rows_fetched(row_set_buffer.mut_num_fetch_rows())
564 .into_result(&stmt)?;
565 row_set_buffer.bind_colmuns_to_cursor(stmt)?;
566 Ok(())
567 }
568}
569
570/// Error handling for bulk fetching is shared between synchronous and asynchronous usecase.
571fn error_handling_for_fetch(
572 result: SqlResult<()>,
573 mut stmt: StatementRef,
574 buffer: &impl RowSetBuffer,
575 error_for_truncation: bool,
576) -> Result<bool, Error> {
577 // Only check for truncation if a) the user indicated that he wants to error instead of just
578 // ignoring it and if there is at least one diagnostic record. ODBC standard requires a
579 // diagnostic record to be there in case of truncation. Sadly we can not rely on this particular
580 // record to be there, as the driver could generate a large amount of diagnostic records,
581 // while we are limited in the amount we can check. The second check serves as an optimization
582 // for the happy path.
583 if error_for_truncation
584 && result == SqlResult::SuccessWithInfo(())
585 && let Some(TruncationInfo {
586 indicator,
587 buffer_index,
588 }) = buffer.find_truncation()
589 {
590 return Err(Error::TooLargeValueForBuffer {
591 indicator,
592 buffer_index,
593 });
594 }
595
596 let has_row = result
597 .on_success(|| true)
598 .on_no_data(|| false)
599 .into_result(&stmt.as_stmt_ref())
600 // Oracle's ODBC driver does not support 64Bit integers. Furthermore, it does not
601 // tell it to the user when binding parameters, but rather now then we fetch
602 // results. The error code returned is `HY004` rather than `HY003` which should
603 // be used to indicate invalid buffer types.
604 .provide_context_for_diagnostic(|record, function| {
605 if record.state == State::INVALID_SQL_DATA_TYPE {
606 Error::OracleOdbcDriverDoesNotSupport64Bit(record)
607 } else {
608 Error::Diagnostics { record, function }
609 }
610 })?;
611 Ok(has_row)
612}
613
614/// Unbinds buffer and num_rows_fetched from the cursor. This implementation is shared between
615/// unbind and the drop handler, and the synchronous and asynchronous variant.
616fn unbind_buffer_from_cursor(cursor: &mut impl AsStatementRef) -> Result<(), Error> {
617 // Now that we have cursor out of block cursor, we need to unbind the buffer.
618 let mut stmt = cursor.as_stmt_ref();
619 stmt.unbind_cols().into_result(&stmt)?;
620 stmt.unset_num_rows_fetched().into_result(&stmt)?;
621 Ok(())
622}