Description:
Execute a query: select left(rand(),3), count(*) from information_schema.tables group by 1
can got error message: Duplicate entry '0.5' for key '<group_key>'
but execute batch query: select left(rand(),3), count(*) from information_schema.tables group by 1; select left(rand(),3), count(*) from information_schema.tables group by 1
Execute method suspended and session in MySQL is sleep
How to repeat:
Imports MySql.Data.MySqlClient
Module Module1
Sub Main()
Dim connstr = New MySqlConnectionStringBuilder With {
.Server = "localhost", .Port = "3306", .Database = "mysql",
.UserID = "dba_jack", .Password = "jack.1234",
.AllowBatch = True}.ConnectionString
Using conn As New MySqlConnection(connstr)
conn.Open()
Console.WriteLine(" *** Test 2 =================================")
Dim sql = "select left(rand(),3), count(*) from information_schema.tables group by 1"
Console.WriteLine(sql)
Query(conn, sql) ' Sucess got error
Console.WriteLine(" *** Test 2 =================================")
sql &= ";" & sql
Console.WriteLine(sql)
Query(conn, sql) ' Suspended on ExecuteScalar, ExecuteNonQuery and ExecuteReader
conn.Close()
End Using
End Sub
Sub Query(conn As MySqlConnection, sql As String)
Try
Using cmd As New MySqlCommand(sql, conn)
' Console.WriteLine(cmd.ExecuteScalar ())
' Console.WriteLine(cmd.ExecuteNonQuery())
Using reader = cmd.ExecuteReader
If reader.IsClosed = False Then
While reader.Read()
Console.WriteLine(reader(0))
End While
reader.Close()
End If
End Using
End Using
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Sub
End Module