From c86b38cab6003e7855f0552d18dc55aefabb5706 Mon Sep 17 00:00:00 2001 From: Pierre Fersing Date: Thu, 4 Jan 2018 11:07:38 +0100 Subject: [PATCH] [563] Fix mysql_log example --- examples/mysql_log/mysql_log.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/mysql_log/mysql_log.c b/examples/mysql_log/mysql_log.c index 565d7e9d..9e7e8d71 100644 --- a/examples/mysql_log/mysql_log.c +++ b/examples/mysql_log/mysql_log.c @@ -43,8 +43,13 @@ void message_callback(struct mosquitto *mosq, void *obj, const struct mosquitto_ bind[0].buffer_type = MYSQL_TYPE_STRING; bind[0].buffer = message->topic; + bind[0].buffer_length = strlen(message->topic); + // Note: payload is normally a binary blob and could contains + // NULL byte. This sample does not handle it and assume payload is a + // string. bind[1].buffer_type = MYSQL_TYPE_STRING; bind[1].buffer = message->payload; + bind[1].buffer_length = message->payloadlen; mysql_stmt_bind_param(stmt, bind); mysql_stmt_execute(stmt);