bug: query result not correct
ZhengLin-Li opened this issue · comments
Zhenglin Li commented
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Please confirm if bug report does NOT exists already ?
- I confirm there is no existing issue for this
Describe the problem
SQLancer found that the query below result is not correct on docker v1.0.4, though correct result on docker v1.0.3
Expected behavior
both two select return NULL
How To Reproduce
CREATE TABLE t0(c0 INT);
SELECT * FROM t0 WHERE (t0.c0 IS NULL);
SELECT SUM(count) FROM (SELECT (t0.c0 IS NULL) IS TRUE as count FROM t0) as res; -- Expted NULL but got 1
SELECT SUM(count) FROM (SELECT CAST((t0.c0 IS NULL) AS UNSIGNED) as count FROM t0) as res; -- Expted NULL but got 1
Environment
docker v1.0.4
Are you interested in submitting a PR to solve the problem?
- Yes, I will!
Double commented
In the function AggregationAlgorithm::Aggregate
in aggregation_algorithm.cpp, it doesn't check validity of mit
before PutAggregatedValue
.
void AggregationAlgorithm::Aggregate(bool just_distinct, int64_t &limit, int64_t &offset, ResultSender *sender) {
MEASURE_FET("TempTable::Aggregate(...)");
thd_proc_info(m_conn->Thd(), "aggregation");
......
{
for (int gr_a = gbw.NumOfGroupingAttrs(); gr_a < gbw.NumOfAttrs(); gr_a++) {
TempTable::Attr &cur_a = *(t->GetAttrP(gr_a));
if (cur_a.term.vc && dynamic_cast<Tianmu::vcolumn::ExpressionColumn *>(cur_a.term.vc)) {
bool value_successfully_aggregated = gbw.PutAggregatedValue(gr_a, 0, mit, mit.Factor());
if (!value_successfully_aggregated) {
gbw.DistinctlyOmitted(gr_a, 0);
}
}
}
}
}
......
}