Fix bug in the cdc_connector

The cdc_connector did not check if the data request was successful.
This commit is contained in:
Markus Mäkelä 2017-09-29 10:59:45 +03:00
parent b446f442b6
commit 27ccf0877c
2 changed files with 20 additions and 1 deletions

View File

@ -213,6 +213,20 @@ bool Connection::requestData(const std::string& table, const std::string& gtid)
m_error = "Failed to write request: ";
m_error += strerror_r(errno, err, sizeof (err));
}
else
{
// Read the first row to know if data request was successful
Row row = read();
if (row)
{
m_first_row = row;
}
else
{
rval = false;
}
}
return rval;
}
@ -288,7 +302,11 @@ Row Connection::read()
Row rval;
std::string row;
if (readRow(row))
if (m_first_row)
{
rval.swap(m_first_row);
}
else if (readRow(row))
{
json_error_t err;
json_t* js = json_loads(row.c_str(), JSON_ALLOW_NUL, &err);

View File

@ -52,6 +52,7 @@ private:
std::string m_schema;
ValueList m_keys;
ValueList m_types;
Row m_first_row;
bool doAuth();
bool doRegistration();