Skip to content

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

@cstarc

Description

@cstarc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions