Fix database renaming with no default database

If no default database was given, it was possible that the code would end
up in an endless loop.
This commit is contained in:
Markus Mäkelä 2019-12-12 13:42:24 +02:00
parent 2f3afa943c
commit 90f7c69f9d
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
2 changed files with 2 additions and 2 deletions

View File

@ -263,7 +263,7 @@ std::string pcre2_substitute(pcre2_code* re,
(PCRE2_SPTR) replace.c_str(), replace.length(),
(PCRE2_UCHAR*) &rval[0], &size_tmp)) == PCRE2_ERROR_NOMEMORY)
{
rval.resize(rval.size() * 2);
rval.resize(rval.size() * 2 + 1);
size_tmp = rval.size();
}

View File

@ -855,7 +855,7 @@ void BinlogFilterSession::checkStatement(GWBUF** buffer, const REP_HEADER& hdr)
auto new_db = mxs::pcre2_substitute(config.rewrite_src, db, config.rewrite_dest, &err);
auto new_sql = mxs::pcre2_substitute(config.rewrite_src, sql, config.rewrite_dest, &err);
if (new_db.empty() || new_sql.empty())
if ((new_db.empty() && !db.empty()) || (new_sql.empty() && !sql.empty()))
{
MXS_ERROR("PCRE2 error on pattern '%s' with replacement '%s': %s",
config.rewrite_src_pattern.c_str(),