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
118 changes: 112 additions & 6 deletions age--1.5.0--y.y.y.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ CREATE OPERATOR @>> (
RIGHTARG = agtype,
FUNCTION = ag_catalog.agtype_contains_top_level,
COMMUTATOR = '<<@',
RESTRICT = contsel,
JOIN = contjoinsel
RESTRICT = matchingsel,
JOIN = matchingjoinsel
);

CREATE FUNCTION ag_catalog.agtype_contained_by_top_level(agtype, agtype)
Expand All @@ -58,17 +58,114 @@ CREATE OPERATOR <<@ (
RIGHTARG = agtype,
FUNCTION = ag_catalog.agtype_contained_by_top_level,
COMMUTATOR = '@>>',
RESTRICT = contsel,
JOIN = contjoinsel
RESTRICT = matchingsel,
JOIN = matchingjoinsel
);

/*
* We have to drop and recreate the operators, because
* commutator is not modifiable using ALTER OPERATOR.
*/
ALTER EXTENSION age
DROP OPERATOR ? (agtype, agtype);
ALTER EXTENSION age
DROP OPERATOR ? (agtype, text);
ALTER EXTENSION age
DROP OPERATOR ?| (agtype, agtype);
ALTER EXTENSION age
DROP OPERATOR ?| (agtype, text[]);
ALTER EXTENSION age
DROP OPERATOR ?& (agtype, agtype[]);
ALTER EXTENSION age
DROP OPERATOR ?& (agtype, text);

DROP OPERATOR ? (agtype, agtype), ? (agtype, text),
?| (agtype, agtype), ?| (agtype, text[]),
?& (agtype, agtype[]), ?& (agtype, text);

CREATE OPERATOR ? (
LEFTARG = agtype,
RIGHTARG = agtype,
FUNCTION = ag_catalog.agtype_exists_agtype,
RESTRICT = matchingsel,
JOIN = matchingjoinsel
);

CREATE OPERATOR ? (
LEFTARG = agtype,
RIGHTARG = text,
FUNCTION = ag_catalog.agtype_exists,
RESTRICT = matchingsel,
JOIN = matchingjoinsel
);

CREATE OPERATOR ?| (
LEFTARG = agtype,
RIGHTARG = agtype,
FUNCTION = ag_catalog.agtype_exists_any_agtype,
RESTRICT = matchingsel,
JOIN = matchingjoinsel
);

CREATE OPERATOR ?| (
LEFTARG = agtype,
RIGHTARG = text[],
FUNCTION = ag_catalog.agtype_exists_any,
RESTRICT = matchingsel,
JOIN = matchingjoinsel
);

CREATE OPERATOR ?& (
LEFTARG = agtype,
RIGHTARG = agtype,
FUNCTION = ag_catalog.agtype_exists_all_agtype,
RESTRICT = matchingsel,
JOIN = matchingjoinsel
);

CREATE OPERATOR ?& (
LEFTARG = agtype,
RIGHTARG = text[],
FUNCTION = ag_catalog.agtype_exists_all,
RESTRICT = matchingsel,
JOIN = matchingjoinsel
);

ALTER EXTENSION age
ADD OPERATOR ? (agtype, agtype);
ALTER EXTENSION age
ADD OPERATOR ? (agtype, text);
ALTER EXTENSION age
ADD OPERATOR ?| (agtype, agtype);
ALTER EXTENSION age
ADD OPERATOR ?| (agtype, text[]);
ALTER EXTENSION age
ADD OPERATOR ?& (agtype, agtype[]);
ALTER EXTENSION age
ADD OPERATOR ?& (agtype, text);

ALTER OPERATOR @> (agtype, agtype)
SET (RESTRICT = matchingsel, JOIN = matchingjoinsel);

ALTER OPERATOR @> (agtype, agtype)
SET (RESTRICT = matchingsel, JOIN = matchingjoinsel);

ALTER OPERATOR <@ (agtype, agtype)
SET (RESTRICT = matchingsel, JOIN = matchingjoinsel);

ALTER OPERATOR <@ (agtype, agtype)
SET (RESTRICT = matchingsel, JOIN = matchingjoinsel);

/*
* Since there is no option to add or drop operator from class,
* we have to drop and recreate the whole operator class.
* Reference: https://www.postgresql.org/docs/current/sql-alteropclass.html
*/

DROP OPERATOR CLASS ag_catalog.gin_agtype_ops;
ALTER EXTENSION age
DROP OPERATOR CLASS ag_catalog.gin_agtype_ops USING gin;

DROP OPERATOR CLASS ag_catalog.gin_agtype_ops USING gin;

CREATE OPERATOR CLASS ag_catalog.gin_agtype_ops
DEFAULT FOR TYPE agtype USING gin AS
Expand All @@ -89,6 +186,9 @@ DEFAULT FOR TYPE agtype USING gin AS
internal, internal, internal),
STORAGE text;

ALTER EXTENSION age
ADD OPERATOR CLASS ag_catalog.gin_agtype_ops USING gin;

-- this function went from variadic "any" to just "any" type
CREATE OR REPLACE FUNCTION ag_catalog.age_tostring("any")
RETURNS agtype
Expand Down Expand Up @@ -148,4 +248,10 @@ PARALLEL SAFE
AS 'MODULE_PATHNAME';

CREATE CAST (agtype[] AS agtype)
WITH FUNCTION ag_catalog.agtype_array_to_agtype(agtype[]);
WITH FUNCTION ag_catalog.agtype_array_to_agtype(agtype[]);

CREATE OPERATOR =~ (
LEFTARG = agtype,
RIGHTARG = agtype,
FUNCTION = ag_catalog.age_eq_tilde
);
1 change: 1 addition & 0 deletions drivers/jdbc/lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies {

testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

testImplementation("org.testcontainers:testcontainers:1.18.0")
testImplementation("org.postgresql:postgresql:42.6.0")
Expand Down
6 changes: 3 additions & 3 deletions regress/expected/cypher_match.out
Original file line number Diff line number Diff line change
Expand Up @@ -2407,22 +2407,22 @@ 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": 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
[{"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
(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": 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
[{"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
(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);
a
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[{"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
[{"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
(2 rows)

SELECT * FROM cypher('cypher_match', $$ CREATE () WITH * MATCH (x{n0:x.n1}) RETURN 0 $$) as (a agtype);
Expand Down
6 changes: 3 additions & 3 deletions regress/expected/cypher_vle.out
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,8 @@ SELECT prepend_node('list01', 'b');
SELECT * FROM show_list_use_vle('list01');
node
-----------------------------------------------------------------------------------
{"id": 1407374883553281, "label": "node", "properties": {"content": "a"}}::vertex
{"id": 1407374883553282, "label": "node", "properties": {"content": "b"}}::vertex
{"id": 1407374883553281, "label": "node", "properties": {"content": "a"}}::vertex
(2 rows)

-- prepend a node 'c'
Expand All @@ -741,9 +741,9 @@ SELECT prepend_node('list01', 'c');
SELECT * FROM show_list_use_vle('list01');
node
-----------------------------------------------------------------------------------
{"id": 1407374883553281, "label": "node", "properties": {"content": "a"}}::vertex
{"id": 1407374883553282, "label": "node", "properties": {"content": "b"}}::vertex
{"id": 1407374883553283, "label": "node", "properties": {"content": "c"}}::vertex
{"id": 1407374883553282, "label": "node", "properties": {"content": "b"}}::vertex
{"id": 1407374883553281, "label": "node", "properties": {"content": "a"}}::vertex
(3 rows)

DROP FUNCTION show_list_use_vle;
Expand Down
Loading