Skip to content

Commit 3b93591

Browse files
committed
Handle failure to find procedure. Fixes #282
If no parameters are found, assume the schema name is incorrect and don't populate the cache. This will require the user to supply the stored procedure's parameters in the correct order (but that will be successful). Additionally, skip parameter lookup if the schema name is unknown (since that will always fail).
1 parent bc145ab commit 3b93591

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/MySqlConnector/Core/CachedProcedure.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ FROM information_schema.parameters
4848
}
4949
}
5050

51-
return new CachedProcedure(schema, component, parameters.AsReadOnly());
51+
return parameters.Count == 0 ? null : new CachedProcedure(schema, component, parameters.AsReadOnly());
5252
}
5353

5454
private CachedProcedure(string schema, string component, ReadOnlyCollection<CachedParameter> parameters)

src/MySqlConnector/MySql.Data.MySqlClient/MySqlConnection.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ internal async Task<CachedProcedure> GetCachedProcedure(IOBehavior ioBehavior, s
307307
cachedProcedures = m_cachedProcedures = new Dictionary<string, CachedProcedure>();
308308

309309
var normalized = NormalizedSchema.MustNormalize(name, Database);
310+
if (string.IsNullOrEmpty(normalized.Schema))
311+
return null;
312+
310313
CachedProcedure cachedProcedure;
311314
lock (cachedProcedures)
312315
cachedProcedures.TryGetValue(normalized.FullyQualified, out cachedProcedure);

0 commit comments

Comments
 (0)