From 6d3ab14365172b54394966e62957006e7138fd6e Mon Sep 17 00:00:00 2001 From: Tobias Stumpf Date: Tue, 23 Sep 2014 18:53:26 +0200 Subject: [PATCH] DatabaseProtobufAdapter: fix translation of unsigned fields Independent of the protocol specification all integer fields in the result table are signed. For instance, if I store a kernel IP (e.g. 0xf1....) the value in the database is 0x7fffffff because of the wrong type. Therefore, the data fields of the result table should have the same types as specified in the protocol. Change-Id: I9154251e4ad67ba70fe86155ebda378c4a9982c2 --- src/core/util/DatabaseProtobufAdapter.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/util/DatabaseProtobufAdapter.hpp b/src/core/util/DatabaseProtobufAdapter.hpp index 6c8e5cf9..ca9bffd2 100644 --- a/src/core/util/DatabaseProtobufAdapter.hpp +++ b/src/core/util/DatabaseProtobufAdapter.hpp @@ -80,7 +80,7 @@ class DatabaseProtobufAdapter { TypeBridge_uint32(const google::protobuf::FieldDescriptor *desc) : TypeBridge(desc){}; - virtual std::string sql_type() { return "INT"; }; + virtual std::string sql_type() { return "INT UNSIGNED"; }; virtual int element_size() { return 4; }; virtual void copy_to(const google::protobuf::Message *msg, int i, void *); virtual void bind(MYSQL_BIND *bind, const google::protobuf::Message *msg); @@ -101,7 +101,7 @@ class DatabaseProtobufAdapter { TypeBridge_uint64(const google::protobuf::FieldDescriptor *desc) : TypeBridge(desc){}; - virtual std::string sql_type() { return "BIGINT"; }; + virtual std::string sql_type() { return "BIGINT UNSIGNED"; }; virtual int element_size() { return 8; }; virtual void copy_to(const google::protobuf::Message *msg, int i, void *); virtual void bind(MYSQL_BIND *bind, const google::protobuf::Message *msg);