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

It is not possible to create two commands in parallel if they are assigned to one connection #867

Closed
BoBiene opened this issue Aug 6, 2020 · 5 comments
Assignees
Labels

Comments

@BoBiene
Copy link

BoBiene commented Aug 6, 2020

 MySqlConnection connection = new MySqlConnection(/* ... */);
connection.Open(); ;

var cmd1 = connection.CreateCommand();
cmd1.CommandText = "SELECT 1";
using (var reader = cmd1.ExecuteReader())
{
    var cmd2 = connection.CreateCommand();
    cmd2.CommandText = "SELECT 1";  //should not fail

    //cmd2.Execute[..]() <- should fail
}
@bgrainger
Copy link
Member

The test here is too strict; it really should only be checking whether there is an active reader for this MySqlCommand, not any command.

if (m_connection?.HasActiveReader ?? false)
throw new InvalidOperationException("Cannot set MySqlCommand.CommandText when there is an open DataReader for this command; it must be closed first.");

@bgrainger bgrainger added the bug label Aug 6, 2020
@bgrainger
Copy link
Member

I suspect this should be fixed by checking ServerSession.m_activeCommandId.

@bgrainger bgrainger self-assigned this Aug 7, 2020
@bgrainger
Copy link
Member

The fix is available as a pre-release, 1.0.1-beta.0.20, from GitHub Packages: https://github.com/mysql-net/MySqlConnector/packages/39735

@BoBiene
Copy link
Author

BoBiene commented Aug 7, 2020

Thank you @bgrainger 👍

@bgrainger
Copy link
Member

Fixed in 1.0.1.

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

Successfully merging a pull request may close this issue.

2 participants