MXS-2854: Repeat read on schema event

The read needs to be repeated if MaxScale sends a schema event.
This commit is contained in:
Markus Mäkelä
2020-01-28 16:09:31 +02:00
parent ea2665214f
commit a3fd5a0218

View File

@ -170,7 +170,7 @@ void Closer<int>::close(int fd)
namespace CDC namespace CDC
{ {
const char* const TIMEOUT = "Request timed out"; const char* const TIMEOUT = "Request timed out";
/** /**
* Public functions * Public functions
@ -449,21 +449,36 @@ SRow Connection::read()
SRow rval; SRow rval;
std::string row; std::string row;
if (read_row(row)) while (true)
{ {
json_error_t err; if (read_row(row))
json_t* js = json_loads(row.c_str(), JSON_ALLOW_NUL, &err); {
json_error_t err;
json_t* js = json_loads(row.c_str(), JSON_ALLOW_NUL, &err);
if (js) if (js)
{ {
rval = process_row(js); if (is_schema(js))
json_decref(js); {
} m_schema = row;
else process_schema(js);
{ json_decref(js);
m_error = "Failed to parse JSON: "; continue;
m_error += err.text; }
else
{
rval = process_row(js);
json_decref(js);
}
}
else
{
m_error = "Failed to parse JSON: ";
m_error += err.text;
}
} }
break;
} }
return rval; return rval;