Skip to content

Commit

Permalink
Merge missed decimal divide fix
Browse files Browse the repository at this point in the history
Signed-off-by: yibin <[email protected]>
  • Loading branch information
yibin87 committed Mar 15, 2023
1 parent 0f547df commit 994584c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dbms/src/Functions/divide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct TiDBDivideFloatingImpl<A, B, false>
res_null = 1;
return static_cast<Result>(0);
}
return static_cast<Result>(a) / b;
return apply<Result>(a, b);
}
};

Expand All @@ -115,7 +115,7 @@ struct TiDBDivideFloatingImpl<A, B, true>
res_null = 1;
return static_cast<Result>(0);
}
return static_cast<Result>(a) / static_cast<Result>(b);
return apply<Result>(a, b);
}
};

Expand Down
9 changes: 8 additions & 1 deletion tests/tidb-ci/fullstack-test-dt/issue_1425.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@ mysql> drop table if exists test.t;

mysql> create table test.t (id int, value decimal(7,4), c1 int, c2 int);

mysql> insert into test.t values(1,1.9286,54,28);
mysql> insert into test.t values (1,1.9285,54,28), (1,1.9286,54,28);

mysql> alter table test.t set tiflash replica 1;

func> wait_table test t

# note: ref to https://github.com/pingcap/tiflash/issues/1682,
# The precision of tiflash results is different from that of tidb, which is a compatibility issue
mysql> use test; set session tidb_isolation_read_engines='tiflash'; select * from t where value = 54/28;

mysql> use test; set session tidb_isolation_read_engines='tiflash'; select * from t where value = c1/c2;
+------+--------+------+------+
| id | value | c1 | c2 |
+------+--------+------+------+
| 1 | 1.9286 | 54 | 28 |
+------+--------+------+------+

mysql> drop table if exists test.t;

0 comments on commit 994584c

Please sign in to comment.