forked from apache/age
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix MERGE visibility in chained commands, SET specifically.
Background: The MERGE command searches for a pattern to return. If that pattern isn't found, it will create it and return the newly created pattern. In both cases, MERGE will return one or more tuples. When MERGE is chained with other commands, the tuples generated (either found or created) by MERGE are passed up to the parent commands. Those parent commands can then make modifications to those tuples, if necessary. Issue: The issue here was that the newly created tuples were not visible, meaning the currentCommandId used to create them was not strictly less than the currentCommandId used to update them further in the chain. The error with the processed tuples would show up on the surface (the return value) as being correct. However, after inspection, it would be shown that the tuple wasn't actually modified by any of the chained commands. Note, this was only the case for newly created tuples. merge (n:node {name: 'Jason'}) SET n.name = 'Lisa' RETURN n; n ---------------------------------------------------------------------------------- {"id": 844424930131970, "label": "node", "properties": {"name": "Lisa"}}::vertex (1 row) match (n) return n; n ---------------------------------------------------------------------------------- {"id": 844424930131970, "label": "node", "properties": {"name": "Jason"}}::vertex (1 row) To fix this, the currentCommandId needed to be incremented after creating a tuple in MERGE. This would allow the chained commands that follow, to see it. However, the currentCommandId used by the MERGE still needed to remain the same. This made it necessary to create a field in the custom scan node to hold the original currentCommandId for the MERGE instances' updates. What this does is to always keep the newly created MERGE tuples updated with a currentCommandId that is always 1 less than the currrent currentCommandId. Doing this corrected the issue. merge (n:node {name: 'Jason'}) SET n.name = 'Lisa' RETURN n; n ---------------------------------------------------------------------------------- {"id": 844424930131971, "label": "node", "properties": {"name": "Lisa"}}::vertex (1 row) match (n) return n; ---------------------------------------------------------------------------------- {"id": 844424930131971, "label": "node", "properties": {"name": "Lisa"}}::vertex (1 row) Added regression tests.
- Loading branch information
1 parent
6fbdfa8
commit 99e7c62
Showing
5 changed files
with
142 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters