influxdata / influxdata/influxdb

why regexp_like(room, \\\\Kitchen)=true is not same with room ~ '\\\\Kitchen'?

Open
#27,087 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

v3
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

Steps to reproduce:
List the minimal actions needed to reproduce the behaviour.

  1. influxdb3 write --database mydb --precision ns
    "test_pattern3,room=\\Kitchen temp=21.4,hum=35.9,co=0i 172800000000000
    test_pattern3,room=\\\\Kitchen temp=23.6,hum=36.2,co=0i 259200000000000
    test_pattern3,room=\\\\\\Kitchen temp=22.2,hum=35.9,co=0i 691200000000000
    test_pattern3,room=Kitchen temp=21.6,hum=35.9,co=0i 86400000000000
    test_pattern3,room=/Kitchen temp=21.8,hum=36.6,co=0i 345600000000000
    test_pattern3,room=//Kitchen temp=22.7,hum=36.1,co=0i 432000000000000
    "

  2. influxdb3 query --database mydb "select * from test_pattern3 where room ~ '\\\\Kitchen'"
    +----+------+------------+------+---------------------+
    | co | hum | room | temp | time |
    +----+------+------------+------+---------------------+
    | 0 | 35.9 | \Kitchen | 21.4 | 1970-01-03T00:00:00 |
    | 0 | 35.9 | \\Kitchen | 22.2 | 1970-01-09T00:00:00 |
    | 0 | 36.2 | \Kitchen | 23.6 | 1970-01-04T00:00:00 |
    +----+------+------------+------+---------------------+

  3. influxdb3 query --database mydb "select * from test_pattern3 where room ~ '\\Kitchen'"
    +----+------+------------+------+---------------------+
    | co | hum | room | temp | time |
    +----+------+------------+------+---------------------+
    | 0 | 35.9 | Kitchen | 21.6 | 1970-01-02T00:00:00 |
    | 0 | 35.9 | \Kitchen | 21.4 | 1970-01-03T00:00:00 |
    | 0 | 36.2 | \Kitchen | 23.6 | 1970-01-04T00:00:00 |
    | 0 | 36.6 | /Kitchen | 21.8 | 1970-01-05T00:00:00 |
    | 0 | 36.1 | //Kitchen | 22.7 | 1970-01-06T00:00:00 |
    | 0 | 35.9 | \\Kitchen | 22.2 | 1970-01-09T00:00:00 |
    +----+------+------------+------+---------------------+

  4. influxdb3 query --database mydb "select * from test_pattern3 where regexp_like(room, '\\Kitchen') = true"
    +----+------+------------+------+---------------------+
    | co | hum | room | temp | time |
    +----+------+------------+------+---------------------+
    | 0 | 35.9 | \Kitchen | 21.4 | 1970-01-03T00:00:00 |
    | 0 | 36.2 | \Kitchen | 23.6 | 1970-01-04T00:00:00 |
    | 0 | 35.9 | \\Kitchen | 22.2 | 1970-01-09T00:00:00 |
    +----+------+------------+------+---------------------+

Expected behaviour:
regexp_like(room, '\\Kitchen') = true is same with room ~ '\\Kitchen'

Actual behaviour:
regexp_like(room, '\\Kitchen') = true is not same with room ~ '\\Kitchen', but same with room ~ '\\\\Kitchen'

looks like '\\Kitchen' in regexp_like escaped 2 times, and '\\Kitchen' in ~ escaped 3 times

Environment info:

Linux 4.19.90-24.4.v2101.ky10.x86_64 x86_64
influxdb3-core-3.5.0_linux_amd64

Config:
none

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.

Research direction

Start by reproducing the two SQL queries in the issue against the supplied room values, comparing regexp_like with the ~ operator. Trace the regex escaping used by these query entry points and add coverage for the shown backslash cases; done means both expressions return the same rows.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.