rafsun42 opened a new issue, #1446:
URL: https://github.com/apache/age/issues/1446

   **Describe the bug**
   In a chained MERGE query with two MERGE clauses, the first MERGE does not 
see the updates of the second one.
   
   **What data setup do we need to do?**
   ```pgsql
   SELECT create_graph('breakmerge');
   SELECT * FROM cypher('breakmerge', $$
       CREATE (:A), (:C)
   $$) as (a agtype);
   ```
   
   **What is the command that caused the error?**
   ```pgsql
   SELECT * FROM cypher('breakmerge', $$
       MATCH (x)
       MERGE (x)-[:r]->(:t)
       MERGE (:C)-[:r]->(:t)
   $$) as (a agtype);
   ```
   Outputs:
   ```
                                   a                                 
   ------------------------------------------------------------------
    {"id": 844424930131969, "label": "A", "properties": {}}::vertex
    {"id": 1125899906842625, "label": "C", "properties": {}}::vertex
    {"id": 1125899906842626, "label": "C", "properties": {}}::vertex
    {"id": 1125899906842627, "label": "C", "properties": {}}::vertex
   (4 rows)
   ```
   
   **Expected behavior**
   There should be only one instance of `:A` and `:C` (verified in Neo4j).
   ```
                                   a                                 
   ------------------------------------------------------------------
    {"id": 844424930131969, "label": "A", "properties": {}}::vertex
    {"id": 1125899906842625, "label": "C", "properties": {}}::vertex
   ```
   
   **Environment (please complete the following information):**
   Master branch; PG 15.4
   
   **Additional context**
   Maybe related to how command IDs are used in MERGE's executor.
   
   My assumption: when the MATCH node sends `:A` to the first MERGE node it 
creates `(:A)-[:r]->(:t)` and the second MERGE node creates `(:C)-[:r]->(:t)`. 
In the next iteration, MATCH sends `:C` to the first MERGE, but it does not see 
that the second MERGE has already created `(:C)-[:r]->(:t)` in the previous 
iteration.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@age.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to