Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions regress/expected/cypher_match.out
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,17 @@ SELECT * FROM cypher('cypher_match', $$
$$) AS (a agtype);
a
----------------------------------------------------------------------------------
{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex
{"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex
{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex
(2 rows)

SELECT * FROM cypher('cypher_match', $$
MATCH ()-[]-()-[]-(a:v1) RETURN a
$$) AS (a agtype);
a
----------------------------------------------------------------------------------
{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex
{"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex
{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex
(2 rows)

SELECT * FROM cypher('cypher_match', $$
Expand Down Expand Up @@ -132,21 +132,21 @@ SELECT * FROM cypher('cypher_match', $$
$$) AS (a agtype);
a
---------------------------------------------------------------------------------------------------------------------------
{"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge
{"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge
{"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge
{"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge
{"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge
{"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge
(4 rows)

SELECT * FROM cypher('cypher_match', $$
MATCH (:v1)-[e]-() RETURN e
$$) AS (a agtype);
a
---------------------------------------------------------------------------------------------------------------------------
{"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge
{"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge
{"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge
{"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge
{"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge
{"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge
(4 rows)

SELECT * FROM cypher('cypher_match', $$
Expand All @@ -165,17 +165,17 @@ SELECT * FROM cypher('cypher_match', $$
$$) AS (a agtype);
a
---------------------------------------------------------------------------------------------------------------------------
{"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge
{"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge
{"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge
(2 rows)

SELECT * FROM cypher('cypher_match', $$
MATCH (a)-[]-()-[]-(:v1) RETURN a
$$) AS (a agtype);
a
----------------------------------------------------------------------------------
{"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex
{"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex
{"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex
(2 rows)

-- Right Path Test
Expand Down Expand Up @@ -348,10 +348,10 @@ SELECT * FROM cypher('cypher_match', $$
$$) AS (i agtype);
i
----------------------------------------------------------------------------------
{"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex
{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex
{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex
{"id": 1688849860263939, "label": "v2", "properties": {"id": "end"}}::vertex
{"id": 1688849860263937, "label": "v2", "properties": {"id": "initial"}}::vertex
{"id": 1688849860263938, "label": "v2", "properties": {"id": "middle"}}::vertex
(4 rows)

SELECT * FROM cypher('cypher_match', $$
Expand Down Expand Up @@ -537,18 +537,18 @@ SELECT * FROM cypher('cypher_match', $$
$$) AS (i agtype, b agtype, c agtype);
i | b | c
---+-----------+-----------
| "end" | "middle"
0 | "end" | "middle"
1 | "end" | "middle"
| "middle" | "end"
0 | "middle" | "end"
1 | "middle" | "end"
| "middle" | "initial"
0 | "middle" | "initial"
1 | "middle" | "initial"
| "end" | "middle"
0 | "end" | "middle"
1 | "end" | "middle"
| "initial" | "middle"
0 | "initial" | "middle"
1 | "initial" | "middle"
| "middle" | "initial"
0 | "middle" | "initial"
1 | "middle" | "initial"
(12 rows)

SELECT * FROM cypher('cypher_match', $$
Expand All @@ -558,18 +558,18 @@ SELECT * FROM cypher('cypher_match', $$
$$) AS (i agtype, c agtype);
i | c
---+-----------
| "middle"
0 | "middle"
1 | "middle"
| "end"
0 | "end"
1 | "end"
| "initial"
0 | "initial"
1 | "initial"
| "middle"
0 | "middle"
1 | "middle"
| "middle"
0 | "middle"
1 | "middle"
| "initial"
0 | "initial"
1 | "initial"
(12 rows)

--
Expand Down Expand Up @@ -2407,15 +2407,15 @@ SELECT * FROM cypher('cypher_match', $$ MATCH (a {name:a.name}) MATCH (a {age:a.
SELECT * FROM cypher('cypher_match', $$ MATCH p=(a)-[u {relationship: u.relationship}]->(b) RETURN p $$) as (a agtype);
a
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[{"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex, {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge, {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex]::path
[{"id": 281474976710661, "label": "", "properties": {"age": 4, "name": "T"}}::vertex, {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge, {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex]::path
[{"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex, {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge, {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex]::path
(2 rows)

SELECT * FROM cypher('cypher_match', $$ MATCH p=(a)-[u {relationship: u.relationship, years: u.years}]->(b) RETURN p $$) as (a agtype);
a
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[{"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex, {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge, {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex]::path
[{"id": 281474976710661, "label": "", "properties": {"age": 4, "name": "T"}}::vertex, {"id": 4785074604081153, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710661, "properties": {"years": 3, "relationship": "friends"}}::edge, {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex]::path
[{"id": 281474976710659, "label": "", "properties": {"age": 3, "name": "orphan"}}::vertex, {"id": 4785074604081154, "label": "knows", "end_id": 281474976710666, "start_id": 281474976710659, "properties": {"years": 4, "relationship": "enemies"}}::edge, {"id": 281474976710666, "label": "", "properties": {"age": 6}}::vertex]::path
(2 rows)

SELECT * FROM cypher('cypher_match', $$ MATCH p=(a {name:a.name})-[u {relationship: u.relationship}]->(b {age:b.age}) RETURN p $$) as (a agtype);
Expand Down
24 changes: 12 additions & 12 deletions regress/expected/expr.out
Original file line number Diff line number Diff line change
Expand Up @@ -2644,10 +2644,10 @@ SELECT * FROM cypher('expr', $$ MATCH (v) RETURN v $$) AS (expression agtype);
SELECT * FROM cypher('expr', $$ MATCH ()-[e]-() RETURN e $$) AS (expression agtype);
expression
---------------------------------------------------------------------------------------------------------------------------
{"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge
{"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge
{"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge
{"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge
{"id": 1407374883553282, "label": "e1", "end_id": 1125899906842626, "start_id": 1125899906842625, "properties": {}}::edge
{"id": 1407374883553281, "label": "e1", "end_id": 1125899906842627, "start_id": 1125899906842626, "properties": {}}::edge
(4 rows)

-- id()
Expand All @@ -2656,10 +2656,10 @@ SELECT * FROM cypher('expr', $$
$$) AS (id agtype);
id
------------------
1407374883553281
1407374883553281
1407374883553282
1407374883553281
1407374883553282
1407374883553281
(4 rows)

SELECT * FROM cypher('expr', $$
Expand Down Expand Up @@ -2698,10 +2698,10 @@ SELECT * FROM cypher('expr', $$
$$) AS (start_id agtype);
start_id
------------------
1125899906842626
1125899906842626
1125899906842625
1125899906842626
1125899906842625
1125899906842626
(4 rows)

-- should return null
Expand Down Expand Up @@ -2731,10 +2731,10 @@ SELECT * FROM cypher('expr', $$
$$) AS (end_id agtype);
end_id
------------------
1125899906842627
1125899906842627
1125899906842626
1125899906842627
1125899906842626
1125899906842627
(4 rows)

-- should return null
Expand Down Expand Up @@ -2764,10 +2764,10 @@ SELECT * FROM cypher('expr', $$
$$) AS (id agtype, start_id agtype, startNode agtype);
id | start_id | startnode
------------------+------------------+----------------------------------------------------------------------------------
1407374883553281 | 1125899906842626 | {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex
1407374883553281 | 1125899906842626 | {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex
1407374883553282 | 1125899906842625 | {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex
1407374883553281 | 1125899906842626 | {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex
1407374883553282 | 1125899906842625 | {"id": 1125899906842625, "label": "v1", "properties": {"id": "initial"}}::vertex
1407374883553281 | 1125899906842626 | {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex
(4 rows)

-- should return null
Expand Down Expand Up @@ -2797,10 +2797,10 @@ SELECT * FROM cypher('expr', $$
$$) AS (id agtype, end_id agtype, endNode agtype);
id | end_id | endnode
------------------+------------------+---------------------------------------------------------------------------------
1407374883553281 | 1125899906842627 | {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex
1407374883553281 | 1125899906842627 | {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex
1407374883553282 | 1125899906842626 | {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex
1407374883553281 | 1125899906842627 | {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex
1407374883553282 | 1125899906842626 | {"id": 1125899906842626, "label": "v1", "properties": {"id": "middle"}}::vertex
1407374883553281 | 1125899906842627 | {"id": 1125899906842627, "label": "v1", "properties": {"id": "end"}}::vertex
(4 rows)

-- should return null
Expand Down
1 change: 1 addition & 0 deletions src/backend/catalog/ag_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "access/genam.h"
#include "catalog/indexing.h"
#include "executor/executor.h"
#include "nodes/makefuncs.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
Expand Down
2 changes: 2 additions & 0 deletions src/backend/executor/cypher_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include "postgres.h"

#include "executor/executor.h"

#include "catalog/ag_label.h"
#include "executor/cypher_executor.h"
#include "executor/cypher_utils.h"
Expand Down
3 changes: 2 additions & 1 deletion src/backend/executor/cypher_delete.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "postgres.h"

#include "executor/executor.h"
#include "storage/bufmgr.h"
#include "common/hashfn.h"

Expand Down Expand Up @@ -257,7 +258,7 @@ static agtype_value *extract_entity(CustomScanState *node,
tupleDescriptor = scanTupleSlot->tts_tupleDescriptor;

/* type checking, make sure the entity is an agtype vertex or edge */
if (tupleDescriptor->attrs[entity_position -1].atttypid != AGTYPEOID)
if (TupleDescAttr(tupleDescriptor, entity_position -1)->atttypid != AGTYPEOID)
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("DELETE clause can only delete agtype")));

Expand Down
2 changes: 2 additions & 0 deletions src/backend/executor/cypher_merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include "postgres.h"

#include "executor/executor.h"

#include "catalog/ag_label.h"
#include "executor/cypher_executor.h"
#include "executor/cypher_utils.h"
Expand Down
29 changes: 23 additions & 6 deletions src/backend/executor/cypher_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "postgres.h"

#include "executor/executor.h"
#include "storage/bufmgr.h"

#include "executor/cypher_executor.h"
Expand Down Expand Up @@ -102,6 +103,7 @@ static HeapTuple update_entity_tuple(ResultRelInfo *resultRelInfo,
TM_Result result;
CommandId cid = GetCurrentCommandId(true);
ResultRelInfo **saved_resultRels = estate->es_result_relations;
bool close_indices = false;

estate->es_result_relations = &resultRelInfo;

Expand All @@ -113,7 +115,16 @@ static HeapTuple update_entity_tuple(ResultRelInfo *resultRelInfo,

if (lock_result == TM_Ok)
{
ExecOpenIndices(resultRelInfo, false);
/*
* Open indices if not already open. The resultRelInfo may already
* have indices opened by the caller (e.g., create_entity_result_rel_info),
* so only open if needed and track that we did so for cleanup.
*/
if (resultRelInfo->ri_IndexRelationDescs == NULL)
{
ExecOpenIndices(resultRelInfo, false);
close_indices = true;
}
ExecStoreVirtualTuple(elemTupleSlot);
tuple = ExecFetchSlotHeapTuple(elemTupleSlot, true, NULL);
tuple->t_self = old_tuple->t_self;
Expand Down Expand Up @@ -141,7 +152,10 @@ static HeapTuple update_entity_tuple(ResultRelInfo *resultRelInfo,
errmsg("tuple to be updated was already modified")));
}

ExecCloseIndices(resultRelInfo);
if (close_indices)
{
ExecCloseIndices(resultRelInfo);
}
estate->es_result_relations = saved_resultRels;

return tuple;
Expand All @@ -160,7 +174,10 @@ static HeapTuple update_entity_tuple(ResultRelInfo *resultRelInfo,
(update_indexes == TU_Summarizing));
}

ExecCloseIndices(resultRelInfo);
if (close_indices)
{
ExecCloseIndices(resultRelInfo);
}
}
else if (lock_result == TM_SelfModified)
{
Expand Down Expand Up @@ -310,7 +327,7 @@ static void update_all_paths(CustomScanState *node, graphid id,
agtype_value *original_entity_value;

/* skip nulls */
if (scanTupleSlot->tts_tupleDescriptor->attrs[i].atttypid != AGTYPEOID)
if (TupleDescAttr(scanTupleSlot->tts_tupleDescriptor, i)->atttypid != AGTYPEOID)
{
continue;
}
Expand Down Expand Up @@ -414,7 +431,7 @@ static void process_update_list(CustomScanState *node)
continue;
}

if (scanTupleSlot->tts_tupleDescriptor->attrs[update_item->entity_position -1].atttypid != AGTYPEOID)
if (TupleDescAttr(scanTupleSlot->tts_tupleDescriptor, update_item->entity_position -1)->atttypid != AGTYPEOID)
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
Expand Down Expand Up @@ -588,7 +605,7 @@ static void process_update_list(CustomScanState *node)
}

estate->es_snapshot->curcid = cid;
/* close relation */
/* close relation */
ExecCloseIndices(resultRelInfo);
table_close(resultRelInfo->ri_RelationDesc, RowExclusiveLock);

Expand Down
1 change: 1 addition & 0 deletions src/backend/executor/cypher_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "postgres.h"

#include "executor/executor.h"
#include "nodes/makefuncs.h"
#include "parser/parse_relation.h"

Expand Down
4 changes: 2 additions & 2 deletions src/backend/parser/cypher_clause.c
Original file line number Diff line number Diff line change
Expand Up @@ -2585,9 +2585,9 @@ static void get_res_cols(ParseState *pstate, ParseNamespaceItem *l_pnsi,
List *colnames = NIL;
List *colvars = NIL;

expandRTE(l_pnsi->p_rte, l_pnsi->p_rtindex, 0, -1, false,
expandRTE(l_pnsi->p_rte, l_pnsi->p_rtindex, 0, VAR_RETURNING_DEFAULT, -1, false,
&l_colnames, &l_colvars);
expandRTE(r_pnsi->p_rte, r_pnsi->p_rtindex, 0, -1, false,
expandRTE(r_pnsi->p_rte, r_pnsi->p_rtindex, 0, VAR_RETURNING_DEFAULT, -1, false,
&r_colnames, &r_colvars);

/* add in all colnames and colvars from the l_rte. */
Expand Down
8 changes: 3 additions & 5 deletions src/backend/utils/adt/agtype_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,9 @@ static void parse_object(agtype_lex_context *lex, agtype_sem_action *sem);
static void parse_array_element(agtype_lex_context *lex,
agtype_sem_action *sem);
static void parse_array(agtype_lex_context *lex, agtype_sem_action *sem);
static void report_parse_error(agtype_parse_context ctx,
agtype_lex_context *lex)
pg_attribute_noreturn();
static void report_invalid_token(agtype_lex_context *lex)
pg_attribute_noreturn();
static pg_noreturn void report_parse_error(agtype_parse_context ctx,
agtype_lex_context *lex);
static pg_noreturn void report_invalid_token(agtype_lex_context *lex);
static int report_agtype_context(agtype_lex_context *lex);
static char *extract_mb_char(char *s);

Expand Down
Loading