influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

Binary bitwise operations treat null values as FALSE during execution

Open LingweiKuang opened this issue 1 year ago • 0 comments

Dear InfluxDB Team, I have a bug that I need to report to you.

Steps to reproduce

In the latest version of InfluxDB, if we have an organization named "organization", we can use the Influx client to execute the following commands to create a bucket and write the specified data into that bucket.

influx bucket delete --name db0
influx bucket create --name db0 --org organization

influx write \
-b db0 \
-o organization \
-p ns \
  't0,t0_tag0=initTag t0_f0=0i 1641024000000000000
  t0,t0_tag0="rv" t0_f0=1236421386i 1641024000000000000
  t0,t1_tag0="4Ka" t0_f0=562086714i 1641024000000000000'

Next, we use the Influx v1 shell command to enter the Influx shell backend and execute four types of query statements:

# query 1 success
SELECT t0_f0, t0_tag0, t1_tag0 FROM db0.autogen.t0

# query 2 success
SELECT t0_f0, t0_tag0, t1_tag0 FROM db0.autogen.t0 WHERE (t1_tag0 != "abc")
SELECT t0_f0, t0_tag0, t1_tag0 FROM db0.autogen.t0 WHERE TRUE and (t1_tag0 != "4Ka")

# query 3
SELECT t0_f0, t0_tag0, t1_tag0 FROM db0.autogen.t0 WHERE TRUE ^ (t1_tag0 != "4Ka")
SELECT t0_f0, t1_f0, t0_tag0, t1_tag0 FROM db0.autogen.t0, db0.autogen.t1 WHERE TRUE ^ FALSE

# query 4
SELECT t0_f0, t0_tag0, t1_tag0 FROM db0.autogen.t0 WHERE FALSE ^ (t1_tag0 != "4Ka")
SELECT t0_f0, t1_f0, t0_tag0, t1_tag0 FROM db0.autogen.t0, db0.autogen.t1 WHERE TRUE ^ TRUE

Expected behaviour

Query 1 retrieves 3 rows of data, while Query 2 can only retrieve 1 row where t1_tag0 is not empty. The results of Query 3 should be consistent with Query 2. Query 4 should return "No Results."

Actual behaviour

Query 1 retrieves 3 rows of data, while Query 2 can only retrieve 1 row where t1_tag0 is not empty. Query 4 return "No Results." However, Query 3 returns all the data, as the binary bitwise operation treats null values as FALSE during execution. Could this be considered a logical issue?

Environment info

Influx CLI dev (git: none) build_date: 2023-04-28T14:24:14Z

InfluxDB OSS v2.7.10 (git: f302d97)

Linux 5.15.0-94-generic x86_64

LingweiKuang avatar Oct 11 '24 01:10 LingweiKuang