pingcap / pingcap/tidb

Problems when mod , division function and extremum function are used together

Open
#40,996 2 comments 0 reactions 1 assignee Claimed by @YangKeao View on GitHub
severity/moderate sig/sql-infra type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!
We found that problems also occur when we use the mod function, the division function and two extremal functions together

### 1. Minimal reproduce step (Required)

select least('0'/-4,0/-4); -- -0
select greatest('0'/-4,0/-4); -- -0
select least(mod('-12',-4),mod(-12,-4)); -- -0
select Greatest(mod('-12',-4),mod(-12,-4)); -- -0

### 2. What did you expect to see? (Required)

We tested the following two use cases
select mod('-12',-4) = mod(-12,-4); -- 1
select '0'/-4 = 0/4; -- 1

These two use cases prove that the two calculation results are equal. We hope that the extreme value function can give the same result because the operation process of these two extreme value functions should also be the ultimate result of the comparison operator.
Although the result of the internal mod function or division function is incorrect, we think that the extreme value function should eliminate the influence of the negative number representation and give the correct answer

### 3. What did you see instead (Required)

### 4. What is your TiDB version? (Required)

5.7.25-TiDB-v6.1.2

MySQL has verified this as a bug. please see https://bugs.mysql.com/bug.php?id=109842. so I consider it is also a bug for tidb.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.