@@ -55,22 +55,29 @@ func (q *Query) parseHeader(line string) {
5555 } else if strings .Contains (part , "rows_sent:" ) {
5656 q .RowsSent , err = strconv .Atoi (parts [idx + 1 ])
5757 if err != nil {
58- logrus .Errorf ("error converting %s to int: %s" , parts [idx + 1 ], err )
58+ logrus .Errorf ("row_sent: error converting %s to int: %s" , parts [idx + 1 ], err )
5959 }
6060 } else if strings .Contains (part , "rows_examined:" ) {
6161 q .RowsExamined , err = strconv .Atoi (parts [idx + 1 ])
6262 if err != nil {
63- logrus .Errorf ("error converting %s to int: %s" , parts [idx + 1 ], err )
63+ logrus .Errorf ("rows_examined: error converting %s to int: %s" , parts [idx + 1 ], err )
6464 }
6565 } else if strings .Contains (part , "rows_affected:" ) {
6666 q .RowsAffected , err = strconv .Atoi (parts [idx + 1 ])
6767 if err != nil {
68- logrus .Errorf ("error converting %s to int: %s" , parts [idx + 1 ], err )
68+ logrus .Errorf ("rows_affected: error converting %s to int: %s" , parts [idx + 1 ], err )
6969 }
7070 } else if strings .Contains (part , "id:" ) {
71- q .ID , err = strconv .Atoi (parts [idx + 1 ]) // TODO(ezekiel): find an other way to get the ID, as the number of spaces can vary
71+ // Some IDs can have multiple space, so we try to bruteforce the
72+ // number of spaces
73+ item := ""
74+ for item == "" {
75+ idx ++
76+ item = parts [idx ]
77+ }
78+ q .ID , err = strconv .Atoi (parts [idx ])
7279 if err != nil {
73- logrus .Errorf ("error converting %s to int: %s" , parts [idx + 1 ], err )
80+ logrus .Errorf ("id: error converting %s to int: %s" , parts [idx + 1 ], err )
7481 }
7582 } else if strings .Contains (part , "user@host:" ) {
7683 items := re .FindAllString (line , - 1 )
@@ -83,17 +90,17 @@ func (q *Query) parseHeader(line string) {
8390 } else if strings .Contains (part , "last_errno:" ) {
8491 q .LastErrNo , err = strconv .Atoi (parts [idx + 1 ])
8592 if err != nil {
86- logrus .Errorf ("error converting %s to int: %s" , parts [idx + 1 ], err )
93+ logrus .Errorf ("last_errno: error converting %s to int: %s" , parts [idx + 1 ], err )
8794 }
8895 } else if strings .Contains (part , "killed:" ) {
8996 q .Killed , err = strconv .Atoi (parts [idx + 1 ])
9097 if err != nil {
91- logrus .Errorf ("error converting %s to int: %s" , parts [idx + 1 ], err )
98+ logrus .Errorf ("killed: error converting %s to int: %s" , parts [idx + 1 ], err )
9299 }
93100 } else if strings .Contains (part , "bytes_sent:" ) {
94101 q .BytesSent , err = strconv .Atoi (parts [idx + 1 ])
95102 if err != nil {
96- logrus .Errorf ("error converting %s to int: %s" , parts [idx + 1 ], err )
103+ logrus .Errorf ("bytes_sent: error converting %s to int: %s" , parts [idx + 1 ], err )
97104 }
98105 }
99106 }
0 commit comments