Skip to content

A logic bug caused by the combined use of MATCH and OPTIONAL MATCH. #3242

@sjhhh321

Description

@sjhhh321

Redis version: redis-7.2.4
RedisGraph version: redisgraph-2.12.10
Operating system: Ubuntu 20.04

Q1:MATCH (n0 :L2)<-[r0 :T6]-(n1 :L3)-[r1 :T1]->(n2 :L4), (n3)<-[r2 :T2]-(n1 :L3), (n0)-[r3 :T0]->(n4 :L1), (n0 :L2)-[r4 :T4]->(n0)<-[r5 :T3]-(n5 :L3), (n6 :L0)-[r6 :T4]->(n1), (n3 :L4)-[r7 :T0]->(n7)<-[r8 :T4]-(n8 :L1), (n6 :L0)<-[r9 :T6]-(n9 :L1)<-[r10 :T0]-(n10), (n11 :L3)-[r11 :T3]->(n9)-[r12 :T3]->(n12 :L0) MATCH (n1)-[]->(n0)-[]->(n4 :L1) OPTIONAL MATCH (n13 :L1)<-[r13 :T5]-(n14 :L4)-[r14 :T0]->(n15 :L1), (n16 :L3)<-[r15 :T0]-(n15)<-[r16 :T2]-(n17 :L1), (n18 :L3)-[r17 :T5]->(n19 :L2)<-[r18 :T6]-(n16), (n20 :L2)-[r19 :T3]->(n19)-[r20 :T2]->(n21 :L4), (n18)<-[r21 :T5]-(n22), (n23 :L3)-[r22 :T3]->(n15), (n24 :L2)-[r23 :T0]->(n16) RETURN count(*)
return --2

Q2:MATCH (n7)<-[r7 :T0]-(n3 :L4)<-[r2 :T2]-(n1 :L3), (n4 :L1)<-[r3 :T0]-(n0 :L2)<-[r4 :T4]-(n0 :L2), (n0 :L2), (n7)<-[r8 :T4]-(n8 :L1), (n9 :L1)<-[r10 :T0]-(n10), (n12 :L0)<-[r12 :T3]-(n9 :L1), (n5 :L3)-[r5 :T3]->(n0 :L2)<-[r0 :T6]-(n1 :L3), (n6 :L0)-[r6 :T4]->(n1 :L3)-[r1 :T1]->(n2 :L4), (n9 :L1)-[r9 :T6]->(n6 :L0), (n11 :L3), (n11 :L3), (n9 :L1)<-[r11 :T3]-(n11 :L3) MATCH (n1)-[]->(n0)-[]->(n4 :L1) OPTIONAL MATCH (n22), (n14 :L4)-[r13 :T5]->(n13 :L1), (n15 :L1)<-[r22 :T3]-(n23 :L3), (n18 :L3), (n14 :L4)-[r14 :T0]->(n15 :L1)-[r15 :T0]->(n16 :L3), (n19 :L2)<-[r19 :T3]-(n20 :L2), (n24 :L2), (n16 :L3)<-[r23 :T0]-(n24 :L2), (n16 :L3)-[r18 :T6]->(n19 :L2), (n15 :L1), (n15 :L1)<-[r16 :T2]-(n17 :L1), (n22)-[r21 :T5]->(n18 :L3)-[r17 :T5]->(n19 :L2)-[r20 :T2]->(n21 :L4) RETURN count(*) --0
Q1 and Q2 is equivalent query, so the result should be same. But now the results of these two queries are inconsistent.

database:

database.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions