Merge branch '2.1' into 2.2

This commit is contained in:
Johan Wikman
2018-03-01 17:52:42 +02:00
8 changed files with 189 additions and 21 deletions

View File

@ -1044,6 +1044,11 @@ public:
return rv;
}
const std::string& name() const
{
return m_name;
}
void print(ostream& out) const
{
out << m_name;
@ -1166,6 +1171,19 @@ bool operator == (const QcFunctionInfo& lhs, const QcFunctionInfo& rhs)
return lhs.eq(rhs);
}
void collect_missing_function_names(const std::set<QcFunctionInfo>& one,
const std::set<QcFunctionInfo>& other,
std::set<std::string>* pNames)
{
for (std::set<QcFunctionInfo>::const_iterator i = one.begin(); i != one.end(); ++i)
{
if (other.count(*i) == 0)
{
pNames->insert(i->name());
}
}
}
bool compare_get_function_info(QUERY_CLASSIFIER* pClassifier1, GWBUF* pCopy1,
QUERY_CLASSIFIER* pClassifier2, GWBUF* pCopy2)
{
@ -1199,7 +1217,47 @@ bool compare_get_function_info(QUERY_CLASSIFIER* pClassifier1, GWBUF* pCopy1,
}
else
{
ss << "ERR: " << f1 << " != " << f2;
std::set<std::string> names1;
collect_missing_function_names(f1, f2, &names1);
std::set<std::string> names2;
collect_missing_function_names(f2, f1, &names2);
bool real_error = false;
// We assume that names1 are from the qc_mysqlembedded and names2 from qc_sqlite.
// The embedded parser reports all date_add(), adddate(), date_sub() and subdate()
// functions as date_add_interval(). Further, all "DATE + INTERVAL ..." cases become
// use of date_add_interval() functions.
for (std::set<std::string>::iterator i = names1.begin(); i != names1.end(); ++i)
{
if (*i == "date_add_interval")
{
if ((names2.count("date_add") == 0) &&
(names2.count("adddate") == 0) &&
(names2.count("date_sub") == 0) &&
(names2.count("subdate") == 0) &&
(names2.count("+") == 0) &&
(names2.count("-") == 0))
{
real_error = true;
}
}
else
{
real_error = true;
}
}
if (real_error)
{
ss << "ERR: " << f1 << " != " << f2;
}
else
{
ss << "Ok : " << f1 << " != " << f2;
success = true;
}
}
report(success, ss.str());

View File

@ -89,3 +89,11 @@ call p1();
call p1(@var);
create or replace table t (a int);
# MXS-1688
select id from db2.t1 where DATE_SUB("2017-06-15", INTERVAL 10 DAY) < "2017-06-15";
select id from db2.t1 where SUBDATE("2017-06-15", INTERVAL 10 DAY) < "2017-06-15";
select id from db2.t1 where DATE_ADD("2017-06-15", INTERVAL 10 DAY) < "2017-06-15";
select id from db2.t1 where ADDDATE("2017-06-15", INTERVAL 10 DAY) < "2017-06-15";
SELECT '2008-12-31 23:59:59' + INTERVAL 1 SECOND;
SELECT '2005-01-01' - INTERVAL 1 SECOND;