influxdata / influxdata/influxdb

Binary bitwise operations treat null values as FALSE during execution

Open
#25,458 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

Dear InfluxDB Team, I have a logic 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
SELECT t0_f0, t0_tag0, t1_tag0 FROM db0.autogen.t0 WHERE TRUE ^ (t1_tag0 != "4Ka")

# query 2
SELECT t0_f0, t1_f0, t0_tag0, t1_tag0 FROM db0.autogen.t0, db0.autogen.t1 WHERE TRUE ^ FALSE
```

#### Expected behaviour

Expected result set for Query 1: **empty set**

Expected result set for Query 2: **all data**

#### Actual behaviour

Query 1 returned result set: **all data**

Query 2 returned result set: **all data**

The InfluxDB OSS 2 documentation states that any arithmetic operation involving null values results in a null value. Therefore, Query 1 should return an empty set, while Query 2 should retrieve all data. However, in Query 1, **null** values are treated as **FALSE** during bitwise operations, causing Query 1 to erroneously retrieve all data.

#### Environment info

Influx CLI dev (git: a79a2a1b825867421d320428538f76a4c90aa34c) build_date: 2024-04-16T14:34:32Z

InfluxDB OSS v2.7.11 (git: [fbf5d4a](https://github.com/influxdata/influxdb/commit/fbf5d4ab5e65d3a3661aa52e1d05259d19a6a81b))

Linux 5.15.0-94-generic x86_64

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior using the Influx v1 shell and the two SELECT queries in the issue, confirming the empty-set and all-data expectations. Then trace bitwise expression evaluation for null values and add regression coverage showing that null is not treated as FALSE; done means both queries return the documented results.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.