Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't obtain results from stored procedure with version 2.3.0+ and Mysql 5.1.73 #1445

Closed
hclander opened this issue Jan 29, 2024 · 2 comments

Comments

@hclander
Copy link

hclander commented Jan 29, 2024

Software versions
MySqlConnector version: 2.3.0+ with Mysql 5.1.73

.NET version: 7

Describe the bug
From version 2.3.0+ we can't get results from stored procedures from Mysql 5.1.73 database servers.
With version 2.2.7 all works fine and with version 2.3.0+ and Mysql 8.0.33 also works fine.

Exception

Unhandled exception. MySqlConnector.MySqlException (0x80004005): **_PROCEDURE DbGis.FindGis can't return a result set in the given context_**
   at MySqlConnector.Core.ServerSession.ReceiveReplyAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ServerSession.cs:line 950
   at MySqlConnector.Core.ResultSet.ReadResultSetHeaderAsync(IOBehavior ioBehavior) in /_/src/MySqlConnector/Core/ResultSet.cs:line 37
   at MySqlConnector.MySqlDataReader.ActivateResultSet(CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlDataReader.cs:line 130
   at MySqlConnector.MySqlDataReader.InitAsync(CommandListPosition commandListPosition, ICommandPayloadCreator payloadCreator, IDictionary`2 cachedProcedures, IMySqlCommand command, CommandBehavior behavior, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlDataReader.cs:line 483
   at MySqlConnector.Core.CommandExecutor.ExecuteReaderAsync(CommandListPosition commandListPosition, ICommandPayloadCreator payloadCreator, CommandBehavior behavior, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/CommandExecutor.cs:line 56
   at MySqlConnector.MySqlCommand.ExecuteReaderAsync(CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlCommand.cs:line 357
   at MySqlConnector.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior) in /_/src/MySqlConnector/MySqlCommand.cs:line 290
   at Dapper.SqlMapper.ExecuteReaderWithFlagsFallback(IDbCommand cmd, Boolean wasClosed, CommandBehavior behavior) in /_/Dapper/SqlMapper.cs:line 1156
   at Dapper.SqlMapper.QueryImpl[T](IDbConnection cnn, CommandDefinition command, Type effectiveType)+MoveNext() in /_/Dapper/SqlMapper.cs:line 1184
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType) in /_/Dapper/SqlMapper.cs:line 815
   at Program.<<Main>$>g__BuscaLugarOpt|0_26(MySqlConnection cnx, Double lat, Double lon, Int32 range) in ~/RiderProjects/test_db_gis/test_db_gis/Program.cs:line 1731
   at Program.<<Main>$>g__TestBenchmark|0_2(MySqlConnection cnx, BuscarLugar buscar, Int32 limit, Int32 progress, Int32 rounds) in ~/RiderProjects/test_db_gis/test_db_gis/Program.cs:line 331
   at Program.<>c__DisplayClass0_0.<<Main>$>g__BenchMarks|0() in ~/RiderProjects/test_db_gis/test_db_gis/Program.cs:line 192
   at Program.<Main>$(String[] args) in ~/RiderProjects/test_db_gis/test_db_gis/Program.cs:line 119

Code sample

  var sql = "call FindGis(38.741283,-6.391783,25)";

    var rx = cnx5.Query<(int Id, double lat, double lon, string Zone1, string Zone2)>(sql);

    foreach (var r in rx)
    {
        Console.WriteLine(r);
    }

Expected behavior
We expected to obtain a few rows with POIs stored in the database within a 25 m. range from a latitude and latitude parameters

Additional context
No special context

@bgrainger
Copy link
Member

This was probably a bug introduced here: b35721f#diff-c8c9f7280ba6967bad39399065f6bd8ba907536c1b8bab63f52597b8eef6f798

Specifically, that could cause these two flags to be turned off:

			ProtocolCapabilities.MultiStatements |
			ProtocolCapabilities.MultiResults |

According to https://stackoverflow.com/a/5447952/23633 and https://bugs.php.net/bug.php?id=42548, the last flag is necessary to avoid this error.

bgrainger referenced this issue Jan 29, 2024
Since MariaDB 10.6 (with https://jira.mariadb.org/browse/MDEV-19237), binary result-set skips sending metadata when they haven't changed. This avoids network data and parsing client-side.

Signed-off-by: rusher <diego.dupin@gmail.com>
@bgrainger
Copy link
Member

Fixed in 2.3.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants