ChuckBell / MySQL_Connector_Arduino

Database connector library for using MySQL with your Arduino projects.
332 stars 133 forks source link

MySQL_Packet::wait_for_client() - wrong packet size #1

Closed ceotto closed 2 years ago

ceotto commented 8 years ago

The MySQL_Packet.h is using a #define MYSQL_MIN_BYTES 8 which is wrong and MySQL_Packet::wait_for_client() allways exits per tiime-out.

It seems to function a little better changing the following define to 5 bytes: #define MYSQL_MIN_BYTES 5

In fact from the docs (https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html) we can observe that the ok packet is 1+2+2 bytes (at least):

Table 14.1 Payload of OK Packet
Type            Name            Description
int<1>          header          [00] or [fe] the OK packet header
int<lenenc>     affected_rows   affected rows
int<lenenc>     last_insert_id  last insert-id
ChuckBell commented 8 years ago

You may want to check that. 8 is the correct value. Remember, the lengths are encoded.

On Jun 22, 2016, at 4:26 PM, Franco Ceotto notifications@github.com wrote:

The MySQL_Packet.h is using a

define MYSQL_MIN_BYTES 8

which is wrong and MySQL_Packet::wait_for_client() allways exits per tiime-out.

It seems to function a little better changing the following define to 5 bytes:

define MYSQL_MIN_BYTES 5

In fact from the docs (https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html) we can observe that the ok packet is 1+2+2 bytes (at least):

Table 14.1 Payload of OK Packet Type Name Description int<1> header [00] or [fe] the OK packet header int affected_rows affected rows int last_insert_id last insert-id

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/1, or mute the thread https://github.com/notifications/unsubscribe/AH0j4Cuzc3yyFHQLkS-C_F6FQ4TRpB51ks5qOZpvgaJpZM4I8L0x.

ChuckBell commented 8 years ago

Observe:

Example OK Packet Hexadecimal ASCII


field_count 00 . affected_rows 01 . insert_id 00 . server_status 02 00 .. warning_count 00 00 ..

On Jun 22, 2016, at 5:07 PM, Charles Bell drcharlesbell@gmail.com wrote:

You may want to check that. 8 is the correct value. Remember, the lengths are encoded.

On Jun 22, 2016, at 4:26 PM, Franco Ceotto <notifications@github.com mailto:notifications@github.com> wrote:

The MySQL_Packet.h is using a

define MYSQL_MIN_BYTES 8

which is wrong and MySQL_Packet::wait_for_client() allways exits per tiime-out.

It seems to function a little better changing the following define to 5 bytes:

define MYSQL_MIN_BYTES 5

In fact from the docs (https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html) we can observe that the ok packet is 1+2+2 bytes (at least):

Table 14.1 Payload of OK Packet Type Name Description int<1> header [00] or [fe] the OK packet header int affected_rows affected rows int last_insert_id last insert-id

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/1, or mute the thread https://github.com/notifications/unsubscribe/AH0j4Cuzc3yyFHQLkS-C_F6FQ4TRpB51ks5qOZpvgaJpZM4I8L0x.

ceotto commented 8 years ago

good evening dr Bell. I'm using a raspbian server 5.5: "Connected to server version 5.5.44-0+deb8u1". And I'm quite sure that the answer is 5 byte long, as per this code: void MySQL_Packet::read_packet() {   byte local[4];

  if (buffer != NULL)     free(buffer);

  int avail_bytes = wait_for_client();   while (avail_bytes < 4) {     avail_bytes = wait_for_client();   }

After you can wait for the rest ...

  avail_bytes = wait_for_client();   while (avail_bytes < packet_len) {     avail_bytes = wait_for_client();   }

best regards Franco Ceotto OCP DBA, Performance Engineer franco_ceotto@yahoo.it

Il Mercoledì 22 Giugno 2016 23:12, Dr. Charles Bell <notifications@github.com> ha scritto:

Observe:

Example OK Packet Hexadecimal ASCII


field_count 00 . affected_rows 01 . insert_id 00 . server_status 02 00 .. warning_count 00 00 ..

On Jun 22, 2016, at 5:07 PM, Charles Bell drcharlesbell@gmail.com wrote:

You may want to check that. 8 is the correct value. Remember, the lengths are encoded.

On Jun 22, 2016, at 4:26 PM, Franco Ceotto <notifications@github.com mailto:notifications@github.com> wrote:

The MySQL_Packet.h is using a

define MYSQL_MIN_BYTES 8

which is wrong and MySQL_Packet::wait_for_client() allways exits per tiime-out.

It seems to function a little better changing the following define to 5 bytes:

define MYSQL_MIN_BYTES 5

In fact from the docs (https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html) we can observe that the ok packet is 1+2+2 bytes (at least):

Table 14.1 Payload of OK Packet Type Name Description int<1> header [00] or [fe] the OK packet header int affected_rows affected rows int last_insert_id last insert-id

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/1, or mute the thread https://github.com/notifications/unsubscribe/AH0j4Cuzc3yyFHQLkS-C_F6FQ4TRpB51ks5qOZpvgaJpZM4I8L0x.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

ChuckBell commented 8 years ago

You may want to capture the packets and analyze them because I am consistently seeing 8+ bytes in Ok packets.

On Jun 22, 2016, at 6:07 PM, Franco Ceotto notifications@github.com wrote:

good evening dr Bell. I'm using a raspbian server 5.5: "Connected to server version 5.5.44-0+deb8u1". And I'm quite sure that the answer is 5 byte long, as per this code: void MySQL_Packet::read_packet() { byte local[4];

if (buffer != NULL) free(buffer);

int avail_bytes = wait_for_client(); while (avail_bytes < 4) { avail_bytes = wait_for_client(); }

After you can wait for the rest ...

avail_bytes = wait_for_client(); while (avail_bytes < packet_len) { avail_bytes = wait_for_client(); }

best regards Franco Ceotto OCP DBA, Performance Engineer franco_ceotto@yahoo.it

Il Mercoledì 22 Giugno 2016 23:12, Dr. Charles Bell notifications@github.com ha scritto:

Observe:

Example OK Packet Hexadecimal ASCII


field_count 00 . affected_rows 01 . insert_id 00 . server_status 02 00 .. warning_count 00 00 ..

On Jun 22, 2016, at 5:07 PM, Charles Bell drcharlesbell@gmail.com wrote:

You may want to check that. 8 is the correct value. Remember, the lengths are encoded.

On Jun 22, 2016, at 4:26 PM, Franco Ceotto <notifications@github.com mailto:notifications@github.com> wrote:

The MySQL_Packet.h is using a

define MYSQL_MIN_BYTES 8

which is wrong and MySQL_Packet::wait_for_client() allways exits per tiime-out.

It seems to function a little better changing the following define to 5 bytes:

define MYSQL_MIN_BYTES 5

In fact from the docs (https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html) we can observe that the ok packet is 1+2+2 bytes (at least):

Table 14.1 Payload of OK Packet Type Name Description int<1> header [00] or [fe] the OK packet header int affected_rows affected rows int last_insert_id last insert-id

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/1, or mute the thread https://github.com/notifications/unsubscribe/AH0j4Cuzc3yyFHQLkS-C_F6FQ4TRpB51ks5qOZpvgaJpZM4I8L0x.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/1#issuecomment-227892285, or mute the thread https://github.com/notifications/unsubscribe/AH0j4MIDSrAEXZm1Jhn3Idl5R3m8A7fjks5qObIqgaJpZM4I8L0x.

ceotto commented 8 years ago

Hi. YOU are waiting for 5 bytes ... in read-packet, but in the sub wait-for-client a compile-time const of 8 is cabled in the code. Best regards.Frank

Inviato da Yahoo Mail su Android

Il gio, 23 giu, 2016 alle 21:07, Dr. Charles Bellnotifications@github.com ha scritto: You may want to capture the packets and analyze them because I am consistently seeing 8+ bytes in Ok packets.

On Jun 22, 2016, at 6:07 PM, Franco Ceotto notifications@github.com wrote:

good evening dr Bell. I'm using a raspbian server 5.5: "Connected to server version 5.5.44-0+deb8u1". And I'm quite sure that the answer is 5 byte long, as per this code: void MySQL_Packet::read_packet() { byte local[4];

if (buffer != NULL) free(buffer);

int avail_bytes = wait_for_client(); while (avail_bytes < 4) { avail_bytes = wait_for_client(); }

After you can wait for the rest ...

avail_bytes = wait_for_client(); while (avail_bytes < packet_len) { avail_bytes = wait_for_client(); }

best regards Franco Ceotto OCP DBA, Performance Engineer franco_ceotto@yahoo.it

Il Mercoledì 22 Giugno 2016 23:12, Dr. Charles Bell notifications@github.com ha scritto:

Observe:

Example OK Packet Hexadecimal ASCII


field_count 00 . affected_rows 01 . insert_id 00 . server_status 02 00 .. warning_count 00 00 ..

On Jun 22, 2016, at 5:07 PM, Charles Bell drcharlesbell@gmail.com wrote:

You may want to check that. 8 is the correct value. Remember, the lengths are encoded.

On Jun 22, 2016, at 4:26 PM, Franco Ceotto <notifications@github.com mailto:notifications@github.com> wrote:

The MySQL_Packet.h is using a

define MYSQL_MIN_BYTES 8

which is wrong and MySQL_Packet::wait_for_client() allways exits per tiime-out.

It seems to function a little better changing the following define to 5 bytes:

define MYSQL_MIN_BYTES 5

In fact from the docs (https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html) we can observe that the ok packet is 1+2+2 bytes (at least):

Table 14.1 Payload of OK Packet Type Name Description int<1> header [00] or [fe] the OK packet header int affected_rows affected rows int last_insert_id last insert-id

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/1, or mute the thread https://github.com/notifications/unsubscribe/AH0j4Cuzc3yyFHQLkS-C_F6FQ4TRpB51ks5qOZpvgaJpZM4I8L0x.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/1#issuecomment-227892285, or mute the thread https://github.com/notifications/unsubscribe/AH0j4MIDSrAEXZm1Jhn3Idl5R3m8A7fjks5qObIqgaJpZM4I8L0x.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

ChuckBell commented 8 years ago

Ok, let me know how you get it worked out. :)

On Jun 23, 2016, at 4:00 PM, Franco Ceotto notifications@github.com wrote:

Hi. YOU are waiting for 5 bytes ... in read-packet, but in the sub wait-for-client a compile-time const of 8 is cabled in the code. Best regards.Frank

Inviato da Yahoo Mail su Android

Il gio, 23 giu, 2016 alle 21:07, Dr. Charles Bellnotifications@github.com ha scritto: You may want to capture the packets and analyze them because I am consistently seeing 8+ bytes in Ok packets.

On Jun 22, 2016, at 6:07 PM, Franco Ceotto notifications@github.com wrote:

good evening dr Bell. I'm using a raspbian server 5.5: "Connected to server version 5.5.44-0+deb8u1". And I'm quite sure that the answer is 5 byte long, as per this code: void MySQL_Packet::read_packet() { byte local[4];

if (buffer != NULL) free(buffer);

int avail_bytes = wait_for_client(); while (avail_bytes < 4) { avail_bytes = wait_for_client(); }

After you can wait for the rest ...

avail_bytes = wait_for_client(); while (avail_bytes < packet_len) { avail_bytes = wait_for_client(); }

best regards Franco Ceotto OCP DBA, Performance Engineer franco_ceotto@yahoo.it

Il Mercoledì 22 Giugno 2016 23:12, Dr. Charles Bell notifications@github.com ha scritto:

Observe:

Example OK Packet Hexadecimal ASCII


field_count 00 . affected_rows 01 . insert_id 00 . server_status 02 00 .. warning_count 00 00 ..

On Jun 22, 2016, at 5:07 PM, Charles Bell drcharlesbell@gmail.com wrote:

You may want to check that. 8 is the correct value. Remember, the lengths are encoded.

On Jun 22, 2016, at 4:26 PM, Franco Ceotto <notifications@github.com mailto:notifications@github.com> wrote:

The MySQL_Packet.h is using a

define MYSQL_MIN_BYTES 8

which is wrong and MySQL_Packet::wait_for_client() allways exits per tiime-out.

It seems to function a little better changing the following define to 5 bytes:

define MYSQL_MIN_BYTES 5

In fact from the docs (https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html) we can observe that the ok packet is 1+2+2 bytes (at least):

Table 14.1 Payload of OK Packet Type Name Description int<1> header [00] or [fe] the OK packet header int affected_rows affected rows int last_insert_id last insert-id

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/1, or mute the thread https://github.com/notifications/unsubscribe/AH0j4Cuzc3yyFHQLkS-C_F6FQ4TRpB51ks5qOZpvgaJpZM4I8L0x.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/1#issuecomment-227892285, or mute the thread https://github.com/notifications/unsubscribe/AH0j4MIDSrAEXZm1Jhn3Idl5R3m8A7fjks5qObIqgaJpZM4I8L0x.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/1#issuecomment-228166193, or mute the thread https://github.com/notifications/unsubscribe/AH0j4DqAJtUz9uDD8gKBkpWtQCJDBCSsks5qOuXggaJpZM4I8L0x.