pdpotter opened a new issue #161:
URL: https://github.com/apache/incubator-age/issues/161
**Describe the bug**
After updating data using the SET clause, data from the updated vertex is no
longer in the index.
**How are you accessing AGE (Command line, driver, etc.)?**
- psql
**What data setup do we need to do?**
```pgsql
...
CREATE OR REPLACE FUNCTION get_id(properties agtype)
RETURNS agtype
AS
$BODY$
select agtype_access_operator($1, '"id"');
$BODY$
LANGUAGE sql
IMMUTABLE;
CREATE FUNCTION
SELECT * FROM cypher('test_graph', $$CREATE (p:person {id: 1, name: 'Jane'})
return p$$) as (p agtype);
p
---------------------------------------------------------------------------------------------
{"id": 844424930131971, "label": "person", "properties": {"id": 1, "name":
"Jane"}}::vertex
(1 row)
CREATE UNIQUE INDEX person_id_idx ON test_graph.person(get_id(properties));
CREATE INDEX
SELECT * FROM cypher('test_graph', $$Match (p:person {id: 1}) set p.name =
"Janine" return p$$) as (p agtype);
p
---------------------------------------------------------------------------------------------
{"id": 844424930131971, "label": "person", "properties": {"id": 1, "name":
"Janine"}}::vertex
(1 row)
...
```
**What is the necessary configuration info needed?**
/
**What is the command that caused the error?**
```pgsql
SELECT * FROM cypher('test_graph', $$CREATE (p:person {id: 1, name: 'Jane'})
return p$$) as (p agtype); p
---------------------------------------------------------------------------------------------
{"id": 844424930131973, "label": "person", "properties": {"id": 1, "name":
"Jane"}}::vertex
(1 row)
```
**Expected behavior**
I would expect an error message `ERROR: duplicate key value violates unique
constraint "person_id_idx"
DETAIL: Key (get_id(properties))=(1) already exists.`. Instead, the new
vertex is added, leading to two vertices with id 1:
```pgsql
SELECT * FROM cypher('test_graph', $$Match (p:person {id: 1}) return p$$)
as (p agtype);
p
-----------------------------------------------------------------------------------------------
{"id": 844424930131971, "label": "person", "properties": {"id": 1, "name":
"Janine"}}::vertex
{"id": 844424930131973, "label": "person", "properties": {"id": 1, "name":
"Jane"}}::vertex
(2 rows)
```
This should be impossible because of the unique index that has been created.
**Environment (please complete the following information):**
- Version: bf9d8367bf4f9ba03d8b79aee5e2065c7a9edbc8
**Additional context**
I encountered this bug while debugging an issue with a corrupt index on the
ids of vertices, which was caused by a query with an invalid syntax (see
https://github.com/apache/incubator-age/issues/160).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]