MySQL Forums
Forum List  »  Connector/Arduino

Re: Issue with NULL data in column
Posted by: Chuck Bell
Date: October 25, 2016 12:00PM

Ok, I found an issue in the read_string() method. The following fixes the issue.

char *MySQL_Cursor::read_string(int *offset) {
char *str;
int len_bytes = conn->get_lcb_len(conn->buffer[*offset]);
int len = conn->read_int(*offset, len_bytes);
if (len == 251) {
// This is a null field.
str = (char *)malloc(5);
strncpy(str, "NULL", 4);
str[4] = 0x00;
*offset += len_bytes;
} else {
str = (char *)malloc(len+1);
strncpy(str, (char *)&conn->buffer[*offset+len_bytes], len);
str[len] = 0x00;
*offset += len_bytes+len;
}
return str;
}

Replace the existing method with this code and you should be able to read NULL columns as "NULL".

Options: ReplyQuote


Subject
Views
Written By
Posted
1936
October 24, 2016 06:59AM
1009
October 25, 2016 11:01AM
969
October 25, 2016 12:19PM
Re: Issue with NULL data in column
1103
October 25, 2016 12:00PM
988
October 25, 2016 12:18PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.