Skip to content

when truncate(...) is NULL, truncate(...) is not NULL evaluates to 1 unexpectedly #53546

@r33s3n6

Description

@r33s3n6

1. Minimal reproduce step (Required)

create table t1 (c1 int);
insert into t1 values (null);
select truncate(1,c1), truncate(1,c1) is not NULL from t1;

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

The column (truncate(...) is not NULL) should be 0 when the expression in the column truncate(...) is NULL:

mysql> select NULL is not NULL;
+------------------+
| NULL is not NULL |
+------------------+
|                0 |
+------------------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

But TiDB output 1.

mysql> select truncate(1,c1), truncate(1,c1) is not NULL from t1;
+----------------+----------------------------+
| truncate(1,c1) | truncate(1,c1) is not NULL |
+----------------+----------------------------+
|           NULL |                          1 |
+----------------+----------------------------+
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

Release Version: v8.2.0-alpha-126-g5d780eb
Edition: Community
Git Commit Hash: 5d780ebf8e9bec3f4f38a26e3f1ec26269dda555
Git Branch: HEAD
UTC Build Time: 2024-05-11 01:07:06
GoVersion: go1.21.4
Race Enabled: false
Check Table Before Drop: false
Store: tikv

topology:

distributed.yaml:

global:
  user: "tidb"
  ssh_port: 22
  deploy_dir: "/tidb-deploy"
  data_dir: "/tidb-data"

pd_servers:
  - host: 10.0.2.31

tidb_servers:
  - host: 10.0.2.21

tikv_servers:
  - host: 10.0.2.11
  - host: 10.0.2.12
  - host: 10.0.2.13

monitoring_servers:
  - host: 10.0.2.8

grafana_servers:
  - host: 10.0.2.8

alertmanager_servers:
  - host: 10.0.2.8

tiflash_servers:
  - host: 10.0.2.32

about us

We are the BASS team from the School of Cyber Science and Technology at Beihang University. Our main focus is on system software security, operating systems, and program analysis research, as well as the development of automated program testing frameworks for detecting software defects. Using our self-developed database vulnerability testing tool, we have identified the above-mentioned vulnerabilities in TiDB that may lead to database logic error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-6.1This bug affects the 6.1.x(LTS) versions.affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.severity/majorsig/executionSIG executiontype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions