diff --git a/sqlx-mysql/src/row.rs b/sqlx-mysql/src/row.rs index 7bed7c7726..1b786abf21 100644 --- a/sqlx-mysql/src/row.rs +++ b/sqlx-mysql/src/row.rs @@ -1,6 +1,5 @@ -use std::sync::Arc; - pub(crate) use sqlx_core::row::*; +use std::sync::Arc; use crate::column::ColumnIndex; use crate::error::Error; @@ -42,10 +41,23 @@ impl Row for MySqlRow { impl ColumnIndex for &'_ str { fn index(&self, row: &MySqlRow) -> Result { - row.column_names - .get(*self) - .ok_or_else(|| Error::ColumnNotFound((*self).into())) - .copied() + // Original fast path (works for normal SELECTs) + if let Some(&idx) = row.column_names.get(*self) { + return Ok(idx); + } + + // NEW: Fallback for stored procedures / CALL (your requested change) + // We scan the real columns and add the name→index mapping on the fly + for (i, col) in row.columns.iter().enumerate() { + if &*col.name == *self { + // Optional: you could even mutate the map here if you want to "cache" it, + // but for simplicity we just return the index. + + return Ok(i); + } + } + + Err(Error::ColumnNotFound((*self).into())) } }