MXS-2106: Add null value support to cdc_connector

The cdc_connector had no explicit null value detection which is required
now that the null value handling is fixed.
This commit is contained in:
Markus Mäkelä
2018-11-01 08:14:13 +02:00
parent 562c7be8fe
commit 451e75eb6a
3 changed files with 39 additions and 4 deletions

View File

@ -23,6 +23,7 @@
#include <vector>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <jansson.h>
@ -199,6 +200,31 @@ public:
return m_values.at(it - m_keys->begin());
}
/**
* Check if a field has a NULL value
*
* @param i The field index
*
* @return True if the field has a NULL value
*/
bool is_null(size_t i) const
{
return m_nulls.count(i);
}
/**
* Check if a field has a NULL value
*
* @param str The field name
*
* @return True if the field has a NULL value
*/
bool is_null(const std::string& str) const
{
ValueVector::const_iterator it = std::find(m_keys->begin(), m_keys->end(), str);
return m_nulls.count(it - m_keys->begin());
}
/**
* Get the GTID of this row
*
@ -243,15 +269,18 @@ private:
SValueVector m_keys;
SValueVector m_types;
ValueVector m_values;
std::set<size_t> m_nulls;
// Only a Connection should construct an InternalRow
friend class Connection;
Row(SValueVector& keys,
SValueVector& types,
ValueVector& values):
ValueVector& values,
std::set<size_t>& nulls):
m_keys(keys),
m_types(types)
m_types(types),
m_nulls(nulls)
{
m_values.swap(values);
}