From fae69c1b40debba76d1fa768a50edacb84a4f1c9 Mon Sep 17 00:00:00 2001
From: Michael Davis <michael.davis@cern.ch>
Date: Mon, 20 May 2019 14:58:09 +0200
Subject: [PATCH] [rdbms] Implements VARBINARY (blob) type for MySQL

---
 catalogue/CMakeLists.txt    | 2 +-
 rdbms/wrapper/MysqlRset.cpp | 4 ++--
 rdbms/wrapper/MysqlStmt.cpp | 6 +++++-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/catalogue/CMakeLists.txt b/catalogue/CMakeLists.txt
index 70b532b250..60a931aa7f 100644
--- a/catalogue/CMakeLists.txt
+++ b/catalogue/CMakeLists.txt
@@ -97,7 +97,7 @@ add_custom_command (OUTPUT sqlite_catalogue_schema.sql mysql_catalogue_schema.sq
     ${CMAKE_CURRENT_SOURCE_DIR}/mysql_catalogue_schema_header.sql 
     ${CMAKE_CURRENT_SOURCE_DIR}/common_catalogue_schema.sql 
     ${CMAKE_CURRENT_SOURCE_DIR}/mysql_catalogue_schema_trailer.sql
-    | sed 's/CHECKSUM_BLOB_TYPE/RAWBINARY\(200\)/g'
+    | sed 's/CHECKSUM_BLOB_TYPE/VARBINARY\(200\)/g'
     > mysql_catalogue_schema.sql
   COMMAND cat
     ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_header.sql
diff --git a/rdbms/wrapper/MysqlRset.cpp b/rdbms/wrapper/MysqlRset.cpp
index af938ea06f..ee45544fba 100644
--- a/rdbms/wrapper/MysqlRset.cpp
+++ b/rdbms/wrapper/MysqlRset.cpp
@@ -79,7 +79,6 @@ bool MysqlRset::next() {
   }
 
   return true;
-  // throw exception::Exception(std::string(__FUNCTION__) + " not implemented.");
 }
 
 //------------------------------------------------------------------------------
@@ -97,7 +96,8 @@ bool MysqlRset::columnIsNull(const std::string &colName) const {
 }
 
 std::string MysqlRset::columnBlob(const std::string &colName) const {
-  throw exception::Exception("MysqlRset::columnBlob not implemented.");
+  auto blob = columnOptionalString(colName);
+  return blob ? *blob : std::string();
 }
 
 //------------------------------------------------------------------------------
diff --git a/rdbms/wrapper/MysqlStmt.cpp b/rdbms/wrapper/MysqlStmt.cpp
index a86c9cf9ce..d4d2246369 100644
--- a/rdbms/wrapper/MysqlStmt.cpp
+++ b/rdbms/wrapper/MysqlStmt.cpp
@@ -261,7 +261,11 @@ void MysqlStmt::bindOptionalDouble(const std::string &paramName, const optional<
 }
 
 void MysqlStmt::bindBlob(const std::string &paramName, const std::string &paramValue) {
-  throw exception::Exception("MysqlStmt::bindBlob not implemented.");
+  try {
+    bindOptionalString(paramName, paramValue);
+  } catch(exception::Exception &ex) {
+    throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str());
+  }
 }
 
 //------------------------------------------------------------------------------
-- 
GitLab