Skip to content

Commit aba288e

Browse files
committed
Support simple CREATE Path
no variables, no labels, completely useless, but important for everything that comes next
1 parent 532800e commit aba288e

8 files changed

Lines changed: 875 additions & 75 deletions

File tree

postgraph--0.1.0.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ AS 'MODULE_PATHNAME';
534534
--
535535
-- graphid - comparison operators (=, <>, <, >, <=, >=)
536536
--
537-
CREATE FUNCTION graphid_eq(postgraph.graphid, postgraph.graphid)
537+
CREATE FUNCTION graphid_eq(graphid, graphid)
538538
RETURNS boolean
539539
LANGUAGE c
540540
IMMUTABLE
@@ -549,9 +549,9 @@ CREATE OPERATOR = (
549549
COMMUTATOR = =,
550550
NEGATOR = <>,
551551
RESTRICT = eqsel,
552-
JOIN = eqjoinsel,
553-
HASHES,
554-
MERGES
552+
JOIN = eqjoinsel--,
553+
--HASHES,
554+
--MERGES
555555
);
556556

557557
CREATE FUNCTION graphid_ne(graphid, graphid)

regress/expected/cypher_create.out

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ USE GRAPH cypher_create;
3333

3434
CREATE ();
3535
WARNING: relcache reference leak: relation "_ag_label_vertex" not closed
36+
WARNING: relcache reference leak: relation "_ag_label_vertex" not closed
3637
--
3738
(0 rows)
3839

@@ -67,8 +68,82 @@ SELECT * FROM postgraph.ag_label;
6768
test | 18833 | 3 | v | cypher_create.test | cypher_create._adj_test | _ag_label_vertex.test
6869
(7 rows)
6970

71+
CREATE (:test);
72+
WARNING: relcache reference leak: relation "test" not closed
73+
WARNING: relcache reference leak: relation "test" not closed
74+
--
75+
(0 rows)
76+
77+
SELECT * FROM postgraph.ag_label;
78+
name | graph | id | kind | relation | vertex_adjlist | label_path
79+
------------------+-------+----+------+--------------------------------+-------------------------------------+-----------------------
80+
_ag_label_vertex | 18780 | 1 | v | 18783 | 18792 | _ag_label_vertex
81+
_ag_label_edge | 18780 | 2 | e | 18796 | | _ag_label_edge
82+
_ag_label_vertex | 18805 | 1 | v | 18808 | 18817 | _ag_label_vertex
83+
_ag_label_edge | 18805 | 2 | e | 18821 | | _ag_label_edge
84+
_ag_label_vertex | 18833 | 1 | v | cypher_create._ag_label_vertex | cypher_create._adj__ag_label_vertex | _ag_label_vertex
85+
_ag_label_edge | 18833 | 2 | e | cypher_create._ag_label_edge | | _ag_label_edge
86+
test | 18833 | 3 | v | cypher_create.test | cypher_create._adj_test | _ag_label_vertex.test
87+
(7 rows)
88+
89+
SELECT * FROM cypher_create.test;
90+
id | properties
91+
-----------------+------------
92+
844424930131969 |
93+
(1 row)
94+
95+
CREATE (:test2);
96+
WARNING: relcache reference leak: relation "test2" not closed
97+
WARNING: relcache reference leak: relation "test2" not closed
98+
--
99+
(0 rows)
100+
101+
SELECT * FROM postgraph.ag_label;
102+
name | graph | id | kind | relation | vertex_adjlist | label_path
103+
------------------+-------+----+------+--------------------------------+-------------------------------------+------------------------
104+
_ag_label_vertex | 18780 | 1 | v | 18783 | 18792 | _ag_label_vertex
105+
_ag_label_edge | 18780 | 2 | e | 18796 | | _ag_label_edge
106+
_ag_label_vertex | 18805 | 1 | v | 18808 | 18817 | _ag_label_vertex
107+
_ag_label_edge | 18805 | 2 | e | 18821 | | _ag_label_edge
108+
_ag_label_vertex | 18833 | 1 | v | cypher_create._ag_label_vertex | cypher_create._adj__ag_label_vertex | _ag_label_vertex
109+
_ag_label_edge | 18833 | 2 | e | cypher_create._ag_label_edge | | _ag_label_edge
110+
test | 18833 | 3 | v | cypher_create.test | cypher_create._adj_test | _ag_label_vertex.test
111+
test2 | 18833 | 4 | v | cypher_create.test2 | cypher_create._adj_test2 | _ag_label_vertex.test2
112+
(8 rows)
113+
114+
SELECT * FROM cypher_create.test2;
115+
id | properties
116+
------------------+------------
117+
1125899906842625 |
118+
(1 row)
119+
120+
MATCH () RETURN 1;
121+
?column?
122+
----------
123+
1
124+
1
125+
1
126+
(3 rows)
127+
70128
CREATE ()-[]->();
71-
ERROR: CREATE doesn't work with paths
129+
WARNING: relcache reference leak: relation "_ag_label_vertex" not closed
130+
WARNING: relcache reference leak: relation "_ag_label_vertex" not closed
131+
WARNING: relcache reference leak: relation "_ag_label_vertex" not closed
132+
WARNING: relcache reference leak: relation "_ag_label_vertex" not closed
133+
WARNING: relcache reference leak: relation "_ag_label_edge" not closed
134+
--
135+
(0 rows)
136+
137+
MATCH () RETURN 1;
138+
?column?
139+
----------
140+
1
141+
1
142+
1
143+
1
144+
1
145+
(5 rows)
146+
72147
CYPHER WITH 1 as a
73148
CREATE ();
74149
ERROR: CREATE doesn't work with previous clauses
@@ -78,12 +153,14 @@ ERROR: CREATE doesn't work with next clauses
78153
-- Clean up
79154
--
80155
DROP GRAPH cypher_create CASCADE;
81-
NOTICE: drop cascades to 5 other objects
156+
NOTICE: drop cascades to 7 other objects
82157
DETAIL: drop cascades to table cypher_create._ag_label_vertex
83158
drop cascades to table cypher_create._adj__ag_label_vertex
84159
drop cascades to table cypher_create._ag_label_edge
85160
drop cascades to table cypher_create.test
86161
drop cascades to table cypher_create._adj_test
162+
drop cascades to table cypher_create.test2
163+
drop cascades to table cypher_create._adj_test2
87164
NOTICE: graph "cypher_create" has been dropped
88165
drop_graph
89166
------------

regress/expected/vertex_am.out

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,35 @@ LOAD 'postgraph';
1919
CREATE TABLE vertex_am_tst (id postgraph.graphid not null, props postgraph.gtype not null) USING vertex_adjlist;
2020
INSERT INTO vertex_am_tst (id, props)
2121
VALUES ('1'::postgraph.graphid, postgraph.gtype_build_map('id', 1));
22-
SELECT * FROM vertex_am_tst;
23-
id | props
24-
----+-----------
25-
1 | {"id": 1}
26-
(1 row)
27-
22+
SELECT * FROM vertex_am_tst WHERE id = '1'::postgraph.graphid;
23+
ERROR: operator does not exist: postgraph.graphid = postgraph.graphid
24+
LINE 1: SELECT * FROM vertex_am_tst WHERE id = '1'::postgraph.graphi...
25+
^
26+
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
27+
/*
2828
DELETE FROM vertex_am_tst;
29+
30+
31+
SELECT * FROM vertex_am_tst WHERE id = '1'::postgraph.graphid;
32+
33+
2934
INSERT INTO vertex_am_tst (id, props)
3035
VALUES ('2'::postgraph.graphid, postgraph.gtype_build_map('id', 1));
36+
37+
38+
SELECT * FROM vertex_am_tst WHERE id = '2'::postgraph.graphid;
39+
40+
3141
SELECT * FROM vertex_am_tst;
32-
id | props
33-
----+-----------
34-
2 | {"id": 1}
35-
(1 row)
3642

3743
UPDATE vertex_am_tst SET id = '2'::postgraph.graphid;
44+
3845
INSERT INTO vertex_am_tst (id, props)
3946
VALUES ('4'::postgraph.graphid, postgraph.gtype_build_map('id', 1));
40-
SELECT * FROM vertex_am_tst;
41-
id | props
42-
----+-----------
43-
2 | {"id": 1}
44-
4 | {"id": 1}
45-
(2 rows)
4647

48+
49+
INSERT INTO vertex_am_tst (id, props)
50+
VALUES ('5'::postgraph.graphid, NULL);
51+
52+
SELECT * FROM vertex_am_tst WHERE id = '5'::postgraph.graphid;
53+
*/

regress/sql/cypher_create.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ MATCH () RETURN 1;
4646

4747
CREATE ()-[]->();
4848

49+
MATCH () RETURN 1;
50+
4951
CYPHER WITH 1 as a
5052
CREATE ();
5153

regress/sql/vertex_am.sql

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,21 @@ INSERT INTO vertex_am_tst (id, props)
2626
VALUES ('1'::postgraph.graphid, postgraph.gtype_build_map('id', 1));
2727

2828

29-
SELECT * FROM vertex_am_tst;
30-
29+
SELECT * FROM vertex_am_tst WHERE id = '1'::postgraph.graphid;
30+
/*
3131
DELETE FROM vertex_am_tst;
3232
33+
34+
SELECT * FROM vertex_am_tst WHERE id = '1'::postgraph.graphid;
35+
36+
3337
INSERT INTO vertex_am_tst (id, props)
3438
VALUES ('2'::postgraph.graphid, postgraph.gtype_build_map('id', 1));
3539
3640
41+
SELECT * FROM vertex_am_tst WHERE id = '2'::postgraph.graphid;
42+
43+
3744
SELECT * FROM vertex_am_tst;
3845
3946
UPDATE vertex_am_tst SET id = '2'::postgraph.graphid;
@@ -45,4 +52,5 @@ VALUES ('4'::postgraph.graphid, postgraph.gtype_build_map('id', 1));
4552
INSERT INTO vertex_am_tst (id, props)
4653
VALUES ('5'::postgraph.graphid, NULL);
4754
48-
SELECT * FROM vertex_am_tst;
55+
SELECT * FROM vertex_am_tst WHERE id = '5'::postgraph.graphid;
56+
*/

0 commit comments

Comments
 (0)