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

Transaction: warnings within a transaction (iE Insert ignore) send command with NULL transaction : ERROR #918

Closed
ofendt opened this issue Dec 20, 2020 · 1 comment
Assignees
Labels

Comments

@ofendt
Copy link

ofendt commented Dec 20, 2020

Within a transaction a INSERT IGNORE get a warning.
Then you get an ERROR:
The transaction associated with this command is not the connection's active transaction; see https://fl.vu/mysql-trans
This is because the SHOW WARNINGS was send without the correct command.transaction set.
My soloution:

internal void FinishQuerying(bool hasWarnings)
	{
		m_session!.FinishQuerying();
		m_activeReader = null;

		if (hasWarnings && InfoMessage is not null)
		{
			var errors = new List<MySqlError>();
			using (var command = new MySqlCommand("SHOW WARNINGS;", this))
			{
			  //**************************************************************//
			  //**************************************************************//
				//** FENDT Transaction has to be set *//
				command.Transaction = CurrentTransaction;
				//** FENDT Transaction has to be set *//
			  //**************************************************************//
			  //**************************************************************//
				using (var reader = command.ExecuteReader())
				{
					while (reader.Read())
						errors.Add(new(reader.GetString(0), reader.GetInt32(1), reader.GetString(2)));
				}
			}
			InfoMessage(this, new MySqlInfoMessageEventArgs(errors));
		}
	}
@bgrainger bgrainger self-assigned this Dec 21, 2020
@bgrainger bgrainger added the bug label Dec 21, 2020
@bgrainger
Copy link
Member

Fixed in 1.3.0.

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

No branches or pull requests

2 participants