MySQL Forums :: Connector/Arduino :: Issue with NULL data in column


Advanced Search

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
Issue with NULL data in column 361 Tony Olivieri 10/24/2016 06:59AM
Re: Issue with NULL data in column 172 Chuck Bell 10/25/2016 11:01AM
Re: Issue with NULL data in column 248 Chuck Bell 10/25/2016 12:19PM
Re: Issue with NULL data in column 199 Chuck Bell 10/25/2016 12:00PM
Re: Issue with NULL data in column 155 Chuck Bell 10/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.