Open BmdOnline opened 3 years ago
Please specify what version of MySQL you used to test this change.
Hi, I used this version :
mysql Ver 15.1 Distrib 10.5.9-MariaDB, for Linux (x86_64) using readline 5.1
But it's not related to MySQL version. It's a typo in your code, You forget to apply offset in buffer.
To be more specific, I'm trying to catch MySQL errors.
For example, try this query when the table arduino
doesn't exists:
char INSERT_SQL[] = "INSERT INTO test_arduino.hello_arduino (message) VALUES ('Hello, Arduino!')";
You will get this error :
Error: 57 = Table 'test_arduino.hello_arduino' doesn't exist.
According to MySQL reference, it should be:
Error: 1146 = Table 'test_arduino.hello_arduino' doesn't exist.
Buffer, in this case, is :
39:00:00:01:FF:7A:04:23:....
Error code is at and 5th position.
57
is decimal conversion of buffer starting at position 0 : 39:00
1146
is decimal conversion of buffer starting at position 5 : 7A:04
In parse_error_packet
from MySQL_Packet.cpp
, you're right when writing:
Bytes Name
----- ----
1 field_count, always = 0xff
2 errno
1 (sqlstate marker), always '#'
5 sqlstate (5 characters)
n message
And when you're doing :
Serial.print(read_int(5, 2));
Everything seems good, but read_int
always return first bytes, not Nth ones (5th in this case).
I haven't checked other usages of read_int
.
References About error codes, from MySQL and MariaDB : https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html https://mariadb.com/docs/reference/cs10.5/error-codes/ https://mariadb.com/kb/en/mariadb-error-codes/ https://docs.oracle.com/cd/E19078-01/mysql/mysql-refman-5.0/error-handling.html
About decoding error packet, from MySQL and MariaDB : https://dev.mysql.com/doc/dev/mysql-server/8.0.11/page_protocol_basic_err_packet.html https://mariadb.com/kb/en/err_packet/
Yes, I am well aware of the error packet and I will review your suggestions to ensure it is compatible with Oracle MySQL. I do (can) not make changes to support anything else, hence my guarded questions. I will reply back later this week. Thanks!
The offset is missing in the calculation. For example, the MySQL error code returned is false.