It seems that ifnull triggered a bug

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: ifnull好像触发bug了

| username: qhd2004

[TiDB Version]
v5.4.1

[Encountered Problem: Phenomenon and Impact]


The ifnull function works in this query.


The ifnull function seems incorrect in this query. Is it triggering a bug?

Attached are two tables dumped using mysqldump.
syk_test.sql (27.1 KB)

| username: 我是咖啡哥 | Original post link

Please also send the SQL, I’ll try it in my environment.

| username: qhd2004 | Original post link

The two SQL queries provided are selecting values from subqueries and using the IFNULL function to handle null values. The first query is selecting from a subquery named a which retrieves measure_status and the value of measure_status lagged by 2 rows within each patient_id partition, ordered by create_time. The second query is similar but selects from a subquery named b, which retrieves measure_status and the value of measure_status lagged by 2 rows within each patient_id partition, ordered by measure_time. Both queries replace null values with ‘-1’ using the IFNULL function.

| username: TiDBer_mKxCaaYu | Original post link

Why wasn’t null captured? Using case when or if(xx is null, ‘-1’, l2), is there a difference between them?
关注了

| username: 我是咖啡哥 | Original post link

5.7.25-TiDB-v6.4.0
This version works for my tests.

| username: qhd2004 | Original post link

I tested it in v5.4.3 and it doesn’t work either.

| username: qhd2004 | Original post link

During testing, it was found that it works in version V6.3.0.

Please have the official team check if it is a bug.

| username: Billmay表妹 | Original post link

It is also possible that this BUG exists in some older versions but has been fixed in the new version.

| username: qhd2004 | Original post link

The profile file was exported using the above command, see the attachment.
cpu.profile (22.7 KB)

| username: buddyyuan | Original post link

I think we can raise an issue. This is an unexpected behavior. :joy:

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.