taosdata / taosdata/TDengine

There is a logical error in the combination of the BETWEEN expression and the OR expression.

Open
#28,902 2 comments 0 reactions 1 assignee View on GitHub

@yu285 is already working on this.

Since Nov 29, 2024.

bug
Dominant language
C
Stars
25.1k
Forks
5k
Avg merge
4d 59m
Merged PRs (30d)
7

Description

Bug Description

There is a logical error in the combination of the BETWEEN expression and the OR expression. The abstract expression sequence is: (time BETWEEN CONSTANT AND CONSTANT) OR (TRUE)

To Reproduce

Assume that we execute the following statement under a database named testdb.

DROP TABLE IF EXISTS t1;
CREATE TABLE t1(time TIMESTAMP, c1 BIGINT);
INSERT INTO t1(time, c1) VALUES (1641024000000, 1);

# query 1
SELECT c1 FROM t1 WHERE (time BETWEEN 1641024000000 AND 1641024000001);

# query 2
SELECT c1 FROM t1 WHERE (time BETWEEN 1641024000000 AND 1641024000001) OR (1 < 2);
Expected Behavior

Query 1 returned result set: 1

Query 2 returned result set: 1

Actual behaviour

Query 1 returned result set: 1

Query 2 returned result set: empty set

Environment
  • OS:Ubuntu Server 22.04 LTS 64bit
  • TDengine Version:3.3.4.3
Additional Context

Hello, TDengine team. In Query 1, the BETWEEN expression is used to constrain the values of the time field, yielding correct results. In Query 2, when it is combined with an OR expression and the right-hand expression evaluates to TRUE, a logical error occurs, resulting in an incorrect query outcome.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.