Skip to content

Commit c3ddcef

Browse files
committed
Support CREATE EXTENSION IF NOT EXISTS
1 parent 9de3079 commit c3ddcef

File tree

7 files changed

+29
-32
lines changed

7 files changed

+29
-32
lines changed

README.md

+2-28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PostGraph
22

3-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/854cafdbd0394189bec10e8fdd17df7f)](https://app.codacy.com/gh/PostGraphDB/postgraph?utm_source=github.com&utm_medium=referral&utm_content=PostGraphDB/postgraph&utm_campaign=Badge_Grade) <a href="https://github.com/PostGraphDB/PostGraph/blob/master/LICENSE"><img src="https://img.shields.io/github/license/PostGraphDB/PostGraph"/></a> <a href="https://github.com/PostGraphDB/PostGraph/issues"><img src="https://img.shields.io/github/issues/PostGraphDB/PostGraph"/></a> <a href="https://github.com/PostGraphDB/PostGraph/network/members"><img src="https://img.shields.io/github/forks/PostGraphDB/PostGraph"/></a> <a href="https://github.com/PostGraphDB/PostGraph/stargazers"><img src="https://img.shields.io/github/stars/PostGraphDB/PostGraph"/></a> <a href="https://discord.gg/KDTTx2vz2m"><img src="https://img.shields.io/discord/1036610864071053413.svg?label=discord&style=flat&color=5a66f6"></a>
3+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/854cafdbd0394189bec10e8fdd17df7f)](https://app.codacy.com/gh/PostGraphDB/postgraph?utm_source=github.com&utm_medium=referral&utm_content=PostGraphDB/postgraph&utm_campaign=Badge_Grade) <a href="https://github.com/PostGraphDB/PostGraph/blob/master/LICENSE"><img src="https://img.shields.io/github/license/PostGraphDB/PostGraph"/></a> <a href="https://github.com/PostGraphDB/PostGraph/issues"><img src="https://img.shields.io/github/issues/PostGraphDB/PostGraph"/></a> <a href="https://github.com/PostGraphDB/PostGraph/network/members"><img src="https://img.shields.io/github/forks/PostGraphDB/PostGraph"/></a> <a href="https://github.com/PostGraphDB/PostGraph/stargazers"><img src="https://img.shields.io/github/stars/PostGraphDB/PostGraph"/></a>
44
<p align="center">
55
<img src="/logo.png">
66
</p>
@@ -51,14 +51,7 @@ shared_preload_libraries = 'postgraph'
5151
```
5252

5353
POSTGIS Dependencies:
54-
autoconf
55-
automake
56-
libtool
57-
libxml2-devel
58-
geos-devel
59-
proj-devel
60-
protobuf-devel protobuf-c-compiler protobuf-compiler
61-
gdal-devel
54+
autoconf automake libtool libxml2-devel geos-devel proj-devel protobuf-devel protobuf-c-compiler protobuf-compiler gdal-devel
6255

6356
## Quick Start
6457

@@ -87,25 +80,6 @@ Find data with the MATCH command
8780
MATCH (n) RETURN n;
8881
```
8982

90-
## Roadmap
91-
92-
Completed:
93-
- Support for the OpenCypher Query Language
94-
- Vector Embeddings, powered by [pgVector](https://github.com/pgvector/pgvector)
95-
- Support for Time data
96-
97-
In Progress:
98-
- Support For IVFFLAT Indices, Approximate K-Nearest Neighbors
99-
- Support for Geographic Information Systems, powered by [PostGIS](http://postgis.net/)
100-
101-
Planned
102-
- Support For HNSW Indices, Faster Approximate K-Nearest Neighbors
103-
- Support For Full Text Search, For combing with Vector Embeddings for Natural Language Processing
104-
- Support of Time-Series Graph Data, powered by [TimeScaleDB](https://github.com/timescale/timescaledb)
105-
- [Machine Learning Techniques](https://github.com/postgresml/postgresml)
106-
- Label Partitioning - For advanced storage and performance techniques
107-
- Geospatial Trajectory Data, powered by [MobilityDB](https://github.com/MobilityDB/MobilityDB)
108-
10983
## Thank You to All the Supporters!
11084
![Stargazers repo roster for @Postgraphdb/postgraph](http://bytecrank.com/nastyox/reporoster/php/stargazersSVG.php?user=Postgraphdb&repo=postgraph)
11185
![Forkers repo roster for @Postgraphdb/postgraph](http://bytecrank.com/nastyox/reporoster/php/forkersSVG.php?user=Postgraphdb&repo=postgraph)

regress/expected/cypher_order.out.diff

Whitespace-only changes.

regress/expected/new_cypher.out

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ LOAD 'postgraph';
1919
CREATE EXTENSION postgraph;
2020
ERROR: extension "postgraph" already exists
2121
CREATE EXTENSION hstore;
22+
CREATE EXTENSION IF NOT EXISTS hstore;
23+
NOTICE: extension "hstore" already exists, skipping
2224
-- Basic Graph creation
2325
CREATE GRAPH new_cypher;
2426
NOTICE: graph "new_cypher" has been created

regress/sql/new_cypher.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LOAD 'postgraph';
2020

2121
CREATE EXTENSION postgraph;
2222
CREATE EXTENSION hstore;
23-
23+
CREATE EXTENSION IF NOT EXISTS hstore;
2424
-- Basic Graph creation
2525
CREATE GRAPH new_cypher;
2626

src/backend/parser/cypher_gram.y

+19-3
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@
9292
GRAPH GROUP GROUPS GROUPING
9393
FALSE_P FILTER FIRST_P FOLLOWING FROM
9494
HAVING
95-
ILIKE IN INTERSECT INTERVAL IS
95+
IF ILIKE IN INTERSECT INTERVAL IS
9696
LAST_P LIKE LIMIT LOCALTIME LOCALTIMESTAMP
9797
MATCH MERGE
9898
NO NOT NULL_P NULLS_LA
9999
OPTIONAL OTHERS OR ORDER OVER OVERLAPS
100100
PARTITION PRECEDING
101-
RANGE REMOVE RETURN ROLLUP ROW ROWS
101+
RANGE REMOVE REPLACE RETURN ROLLUP ROW ROWS
102102
SET SETS SKIP SOME STARTS
103103
TIME TIES THEN TIMESTAMP TRUE_P
104104
UNBOUNDED UNION UNWIND USE USING
@@ -123,7 +123,7 @@
123123
%type <node> match cypher_varlen_opt cypher_range_opt cypher_range_idx
124124
cypher_range_idx_opt
125125
%type <integer> Iconst
126-
%type <boolean> optional_opt
126+
%type <boolean> optional_opt opt_or_replace
127127

128128
/* CREATE clause */
129129
%type <node> create
@@ -981,8 +981,24 @@ create:
981981

982982
$$ = (Node *) n;
983983
}
984+
| CREATE EXTENSION IF NOT EXISTS IDENTIFIER
985+
{
986+
CreateExtensionStmt *n = makeNode(CreateExtensionStmt);
987+
988+
n->extname = $6;
989+
n->if_not_exists = true;
990+
n->options = NULL;
991+
992+
$$ = (Node *) n;
993+
}
984994
;
985995

996+
997+
opt_or_replace:
998+
OR REPLACE { $$ = true; }
999+
| /*EMPTY*/ { $$ = false; }
1000+
;
1001+
9861002
/*
9871003
* SET and REMOVE clause
9881004
*/

src/include/nodes/cypher_nodes.h

+3
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ typedef struct cypher_drop_graph
225225
bool cascade;
226226
} cypher_drop_graph;
227227

228+
229+
230+
228231
/*
229232
* expression
230233
*/

src/include/parser/cypher_kwlist.h

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ PG_KEYWORD("group", GROUP, RESERVED_KEYWORD)
4141
PG_KEYWORD("grouping", GROUPING, RESERVED_KEYWORD)
4242
PG_KEYWORD("groups", GROUPS, RESERVED_KEYWORD)
4343
PG_KEYWORD("having", HAVING, RESERVED_KEYWORD)
44+
PG_KEYWORD("if", IF, RESERVED_KEYWORD)
4445
PG_KEYWORD("ilike", ILIKE, RESERVED_KEYWORD)
4546
PG_KEYWORD("in", IN, RESERVED_KEYWORD)
4647
PG_KEYWORD("intersect", INTERSECT, RESERVED_KEYWORD)
@@ -67,6 +68,7 @@ PG_KEYWORD("partition", PARTITION, RESERVED_KEYWORD)
6768
PG_KEYWORD("preceding", PRECEDING, RESERVED_KEYWORD)
6869
PG_KEYWORD("range", RANGE, RESERVED_KEYWORD)
6970
PG_KEYWORD("remove", REMOVE, RESERVED_KEYWORD)
71+
PG_KEYWORD("replace", REPLACE, RESERVED_KEYWORD)
7072
PG_KEYWORD("return", RETURN, RESERVED_KEYWORD)
7173
PG_KEYWORD("rollup", ROLLUP, RESERVED_KEYWORD)
7274
PG_KEYWORD("row", ROW, RESERVED_KEYWORD)

0 commit comments

Comments
 (0)