From 7ce9ab60d519ff70b3f32bb1c9aa2089e1584aea Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 18 Mar 2026 21:36:40 -0400 Subject: [PATCH 1/4] Add fallback column name lookup for MySQL stored procedures in row.rs --- sqlx-mysql/src/row.rs | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/sqlx-mysql/src/row.rs b/sqlx-mysql/src/row.rs index 7bed7c7726..017d060a42 100644 --- a/sqlx-mysql/src/row.rs +++ b/sqlx-mysql/src/row.rs @@ -1,5 +1,4 @@ use std::sync::Arc; - pub(crate) use sqlx_core::row::*; use crate::column::ColumnIndex; @@ -40,12 +39,29 @@ 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); + } else { + + // 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())) + } } } @@ -54,3 +70,5 @@ impl std::fmt::Debug for MySqlRow { debug_row(self, f) } } + + From dfa93f99966a1363972228861acceb51563be440 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 18 Mar 2026 22:08:58 -0400 Subject: [PATCH 2/4] Remove needless return in ColumnIndex impl (fix clippy warning) --- sqlx-mysql/src/row.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlx-mysql/src/row.rs b/sqlx-mysql/src/row.rs index 017d060a42..63cd201788 100644 --- a/sqlx-mysql/src/row.rs +++ b/sqlx-mysql/src/row.rs @@ -47,7 +47,7 @@ impl ColumnIndex for &'_ str { // Original fast path (works for normal SELECTs) if let Some(&idx) = row.column_names.get(*self) { - return Ok(idx); + Ok(idx); } else { // NEW: Fallback for stored procedures / CALL (your requested change) From 24992f7248ee5569329492e8c6abef03fda552b9 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 18 Mar 2026 22:13:19 -0400 Subject: [PATCH 3/4] Remove needless return in ColumnIndex impl (fix clippy warning) take 2 --- sqlx-mysql/src/row.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sqlx-mysql/src/row.rs b/sqlx-mysql/src/row.rs index 63cd201788..b9541700c3 100644 --- a/sqlx-mysql/src/row.rs +++ b/sqlx-mysql/src/row.rs @@ -47,8 +47,8 @@ impl ColumnIndex for &'_ str { // Original fast path (works for normal SELECTs) if let Some(&idx) = row.column_names.get(*self) { - Ok(idx); - } else { + 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 @@ -61,7 +61,7 @@ impl ColumnIndex for &'_ str { } } Err(Error::ColumnNotFound((*self).into())) - } + } } From 340188a1c730b5f19bd5af94456e6d5290455c40 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 18 Mar 2026 22:20:52 -0400 Subject: [PATCH 4/4] correct formating --- sqlx-mysql/src/row.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/sqlx-mysql/src/row.rs b/sqlx-mysql/src/row.rs index b9541700c3..1b786abf21 100644 --- a/sqlx-mysql/src/row.rs +++ b/sqlx-mysql/src/row.rs @@ -1,5 +1,5 @@ -use std::sync::Arc; pub(crate) use sqlx_core::row::*; +use std::sync::Arc; use crate::column::ColumnIndex; use crate::error::Error; @@ -39,29 +39,25 @@ impl Row for MySqlRow { } } - - impl ColumnIndex for &'_ str { - fn index(&self, row: &MySqlRow) -> Result { - // Original fast path (works for normal SELECTs) - if let Some(&idx) = row.column_names.get(*self) { + 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 { + 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())) - } } @@ -70,5 +66,3 @@ impl std::fmt::Debug for MySqlRow { debug_row(self, f) } } - -