├── docker
├── hooks
│ ├── push
│ └── build
├── docker-entrypoint-initdb.d
│ └── 00-create-extension-age.sql
├── Dockerfile.dev
└── Dockerfile
├── regress
├── age_regression.conf
├── .gitignore
├── age_load
│ └── data
│ │ ├── conversion_vertices.csv
│ │ └── conversion_edges.csv
├── sql
│ ├── issue_369.sql
│ ├── graphid.sql
│ ├── drop.sql
│ ├── pg_trgm.sql
│ ├── analyze.sql
│ └── agtype_hash_cmp.sql
└── expected
│ └── graphid.out
├── src
├── backend
│ ├── parser
│ │ └── .gitignore
│ ├── catalog
│ │ └── ag_namespace.c
│ ├── age.c
│ └── utils
│ │ ├── ag_guc.c
│ │ └── adt
│ │ └── cypher_funcs.c
└── include
│ ├── parser
│ ├── .gitignore
│ ├── cypher_parser.h
│ ├── cypher_keywords.h
│ ├── cypher_item.h
│ ├── cypher_parse_agg.h
│ ├── cypher_expr.h
│ ├── cypher_clause.h
│ ├── cypher_analyze.h
│ ├── cypher_kwlist.h
│ ├── cypher_gram.h
│ └── cypher_parse_node.h
│ ├── catalog
│ ├── ag_namespace.h
│ ├── ag_catalog.h
│ └── ag_graph.h
│ ├── optimizer
│ ├── cypher_paths.h
│ ├── cypher_pathnode.h
│ └── cypher_createplan.h
│ ├── commands
│ ├── graph_commands.h
│ └── label_commands.h
│ ├── utils
│ ├── age_session_info.h
│ ├── ag_float8_supp.h
│ ├── agtype_ext.h
│ ├── ag_guc.h
│ ├── age_vle.h
│ ├── agtype_raw.h
│ ├── ag_func.h
│ ├── load
│ │ ├── ag_load_edges.h
│ │ ├── ag_load_labels.h
│ │ └── age_load.h
│ ├── ag_cache.h
│ ├── graphid.h
│ ├── age_global_graph.h
│ └── age_graphid_ds.h
│ ├── executor
│ └── cypher_executor.h
│ └── nodes
│ ├── cypher_readfuncs.h
│ └── cypher_copyfuncs.h
├── img
├── AGE.png
├── agce.gif
├── age-01.png
├── age-02.png
├── age-03.png
├── news.jpeg
├── videos.png
├── gettingstarted.svg
├── installation.svg
├── documentation.svg
├── visualization.svg
├── features.svg
├── contributing.svg
├── contents.svg
├── community.svg
├── tick.svg
└── apple.svg
├── drivers
├── golang
│ ├── parser
│ │ ├── generate.go
│ │ ├── generate.sh
│ │ ├── age_visitor.go
│ │ ├── age_base_visitor.go
│ │ ├── age_listener.go
│ │ ├── Age.g4
│ │ └── age_base_listener.go
│ ├── TYPES.md
│ ├── go.mod
│ ├── age
│ │ └── errors.go
│ ├── samples
│ │ └── main.go
│ ├── go.sum
│ └── README.md
├── python
│ ├── requirements.txt
│ ├── antlr
│ │ └── README.md
│ ├── __init__.py
│ ├── age
│ │ ├── gen
│ │ │ └── __init__.py
│ │ ├── networkx
│ │ │ ├── __init__.py
│ │ │ └── networkx_to_age.py
│ │ ├── VERSION.py
│ │ ├── __init__.py
│ │ └── exceptions.py
│ ├── samples
│ │ └── __init__.py
│ ├── setup.py
│ └── pyproject.toml
├── docker-compose.yml
├── jdbc
│ ├── .gitattributes
│ ├── settings.gradle.kts
│ ├── lib
│ │ ├── src
│ │ │ └── main
│ │ │ │ └── java
│ │ │ │ └── org
│ │ │ │ └── apache
│ │ │ │ └── age
│ │ │ │ └── jdbc
│ │ │ │ ├── base
│ │ │ │ ├── type
│ │ │ │ │ ├── AgtypeObject.java
│ │ │ │ │ ├── AgtypeAnnotation.java
│ │ │ │ │ ├── UnrecognizedObject.java
│ │ │ │ │ └── AgtypeListImpl.java
│ │ │ │ ├── InvalidAgtypeException.java
│ │ │ │ └── AgtypeFactory.java
│ │ │ │ ├── AgtypeUnrecognizedList.java
│ │ │ │ └── AgtypeUnrecognizedMap.java
│ │ └── build.gradle.kts
│ ├── .gitignore
│ └── gradle
│ │ └── wrapper
│ │ └── gradle-wrapper.properties
├── nodejs
│ ├── jest.config.js
│ ├── .gitignore
│ ├── .eslintrc.js
│ ├── README.md
│ ├── tsconfig.json
│ ├── package.json
│ └── src
│ │ ├── index.ts
│ │ └── antlr4
│ │ └── Agtype.g4
├── README
└── Agtype.g4
├── .dockerignore
├── .github
├── ISSUE_TEMPLATE
│ ├── question.md
│ ├── feature_request.md
│ └── bug_report.md
├── labeler.yml
└── workflows
│ ├── jdbc-driver.yaml
│ ├── nodejs-driver.yaml
│ ├── go-driver.yml
│ ├── labeler.yml
│ ├── python-driver.yaml
│ └── installcheck.yaml
├── .gitignore
├── sql
├── sql_files
├── agtype_string.sql
├── age_query.sql
├── agtype_operators.sql
├── agtype_gin.sql
└── age_string.sql
├── NOTICE
├── age.control
├── age--1.6.0--y.y.y.sql
├── tools
└── git
│ └── commit-msg
├── META.json
├── .asf.yaml
└── clang-format.5
/docker/hooks/push:
--------------------------------------------------------------------------------
1 | #!/bin/bash
--------------------------------------------------------------------------------
/regress/age_regression.conf:
--------------------------------------------------------------------------------
1 | #age.enable_containment = on
2 |
--------------------------------------------------------------------------------
/src/backend/parser/.gitignore:
--------------------------------------------------------------------------------
1 | ag_scanner.c
2 | cypher_gram.c
3 |
--------------------------------------------------------------------------------
/img/AGE.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/age/master/img/AGE.png
--------------------------------------------------------------------------------
/img/agce.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/age/master/img/agce.gif
--------------------------------------------------------------------------------
/src/include/parser/.gitignore:
--------------------------------------------------------------------------------
1 | cypher_gram_def.h
2 | cypher_kwlist_d.h
3 |
--------------------------------------------------------------------------------
/img/age-01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/age/master/img/age-01.png
--------------------------------------------------------------------------------
/img/age-02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/age/master/img/age-02.png
--------------------------------------------------------------------------------
/img/age-03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/age/master/img/age-03.png
--------------------------------------------------------------------------------
/img/news.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/age/master/img/news.jpeg
--------------------------------------------------------------------------------
/img/videos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/age/master/img/videos.png
--------------------------------------------------------------------------------
/regress/.gitignore:
--------------------------------------------------------------------------------
1 | /instance/
2 | /log/
3 | /results/
4 | regression.*
5 |
--------------------------------------------------------------------------------
/drivers/golang/parser/generate.go:
--------------------------------------------------------------------------------
1 | package parser
2 |
3 | //go:generate ./generate.sh
4 |
--------------------------------------------------------------------------------
/.dockerignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.so
3 | .gitignore
4 | build.sh
5 | .idea
6 | .deps
7 | .DS_Store
8 | *.tokens
9 | *.interp
--------------------------------------------------------------------------------
/drivers/python/requirements.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apache/age/master/drivers/python/requirements.txt
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Question
3 | about: Create a question
4 | title: ''
5 | labels: question
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
--------------------------------------------------------------------------------
/docker/hooks/build:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | docker buildx create --name multiarch --use --platform linux/amd64,linux/arm64/v8
4 | docker buildx build ../ -t $IMAGE_NAME -f Dockerfile --platform linux/amd64,linux/arm64/v8 --push
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.so
3 | build.sh
4 | .idea
5 | .deps
6 | .DS_Store
7 | *.tokens
8 | *.interp
9 | *.dylib
10 | age--*.*.*.sql
11 | !age--*--*sql
12 | __pycache__
13 | **/__pycache__
14 | **/.venv
15 | **/apache_age_python.egg-info
16 |
17 | drivers/python/build
18 |
--------------------------------------------------------------------------------
/drivers/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3.3"
2 | services:
3 | db:
4 | image: apache/age:dev_snapshot_master
5 | environment:
6 | - POSTGRES_USER=postgres
7 | - POSTGRES_PASSWORD=agens
8 | - POSTGRES_DB=postgres
9 | ports:
10 | - 5432:5432
11 |
--------------------------------------------------------------------------------
/sql/sql_files:
--------------------------------------------------------------------------------
1 | age_main
2 | age_agtype
3 | agtype_comparison
4 | agtype_access
5 | agtype_operators
6 | agtype_exists
7 | agtype_gin
8 | agtype_graphid
9 | agtype_coercions
10 | agtype_string
11 | age_query
12 | age_scalar
13 | age_string
14 | age_trig
15 | age_aggregate
16 | agtype_typecast
17 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Apache AGE
2 | Copyright 2023 The Apache Software Foundation.
3 | This product includes software developed at
4 | The Apache Software Foundation (http://www.apache.org/).
5 |
6 |
7 | Portions of Apache AGE were originally developed by Bitnine Co., Ltd. and were
8 | donated to the Apache Software Foundation. Copyright 2019-2020 Bitnine Co., Ltd.
9 |
--------------------------------------------------------------------------------
/.github/labeler.yml:
--------------------------------------------------------------------------------
1 | PG11:
2 | - base-branch: 'PG11'
3 |
4 | PG12:
5 | - base-branch: 'PG12'
6 |
7 | PG13:
8 | - base-branch: 'PG13'
9 |
10 | PG14:
11 | - base-branch: 'PG14'
12 |
13 | PG15:
14 | - base-branch: 'PG15'
15 |
16 | PG16:
17 | - base-branch: 'PG16'
18 |
19 | PG17:
20 | - base-branch: 'PG17'
21 |
22 | master:
23 | - base-branch: 'master'
24 |
--------------------------------------------------------------------------------
/regress/age_load/data/conversion_vertices.csv:
--------------------------------------------------------------------------------
1 | id, string, bool, numeric,
2 | 1, "John Smith", "true", 1
3 | 2, "John", "false", "-2"
4 | 3, John Smith, true, 1.4
5 | 4, """John""", false, -1e10
6 | 5, null, false, 0
7 | 6, nUll, false, "3.14"
8 |
--------------------------------------------------------------------------------
/img/gettingstarted.svg:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/img/installation.svg:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/img/documentation.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/img/visualization.svg:
--------------------------------------------------------------------------------
1 |
9 |
--------------------------------------------------------------------------------
/drivers/golang/parser/generate.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Please be aware that this is used by the CI scripts
4 | #
5 | GRAMMAR_LOC="$(dirname $(pwd))/parser"
6 |
7 | mkdir -p ~/tmp/antlr
8 | cd ~/tmp/antlr
9 | curl -LO "https://www.antlr.org/download/antlr-4.11.1-complete.jar"
10 | echo "ANTLR installation complete."
11 |
12 | echo "Generating Parser & Lexer..."
13 | java -Xmx500M -cp "$HOME/tmp/antlr/antlr-4.11.1-complete.jar:$HOME/tmp/antlr/antlr-4.11.1-complete.jar" org.antlr.v4.Tool -Dlanguage=Go -visitor $GRAMMAR_LOC/Age.g4
14 | exit 0
15 |
16 |
--------------------------------------------------------------------------------
/.github/workflows/jdbc-driver.yaml:
--------------------------------------------------------------------------------
1 | name: JDBC Driver Tests
2 |
3 | on:
4 | push:
5 | branches: [ "master" ]
6 |
7 | pull_request:
8 | branches: [ "master" ]
9 |
10 | jobs:
11 | build:
12 | runs-on: ubuntu-latest
13 | defaults:
14 | run:
15 | working-directory: drivers/jdbc
16 |
17 | steps:
18 | - uses: actions/checkout@v4
19 |
20 | - name: Set up Java
21 | uses: actions/setup-java@v3
22 | with:
23 | distribution: 'zulu'
24 | java-version: '17'
25 |
26 | - name: Build and Test
27 | run: gradle build
28 |
--------------------------------------------------------------------------------
/img/features.svg:
--------------------------------------------------------------------------------
1 |
13 |
--------------------------------------------------------------------------------
/img/contributing.svg:
--------------------------------------------------------------------------------
1 |
13 |
--------------------------------------------------------------------------------
/regress/age_load/data/conversion_edges.csv:
--------------------------------------------------------------------------------
1 | start_id, start_vertex_type, end_id, end_vertex_type, string, bool, numeric,
2 | 1, Person1, 1, Person2, "John Smith", "true", 1
3 | 1, Person1, 1, Person2, "John", "false", "-2"
4 | 1, Person1, 1, Person2, John Smith, true, 1.4
5 | 1, Person1, 1, Person2, """John""", false, -1e10
6 | 1, Person1, 1, Person2, null, false, 0
7 | 1, Person1, 1, Person2, nUll, false, "3.14"
8 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/drivers/python/antlr/README.md:
--------------------------------------------------------------------------------
1 | # ANTLR4 Python3 Agtype parser generation rules for apache-age
2 | Python driver for Apache AGE, graph extension for PostgreSQL.
3 |
4 |
5 | ### Build
6 | #### 1) Generate Agtype parser with ANTLR4
7 | ```
8 | # prerequisites :
9 | # - java over 8
10 | # - download ANTLR4 from https://www.antlr.org/download/antlr-4.11.1-complete.jar
11 | # - java -cp antlr-4.11.1-complete.jar org.antlr.v4.Tool -Dlanguage=Python3 -visitor -o ../age/gen ../../Agtype.g4
12 | ```
13 |
14 |
15 | #### 2) Remove the *.interp & *.tokens files
16 |
17 | #### 3) Proceed to unit testing
18 | ```
19 | python -m unittest -v test_age_py.py
20 | ```
21 | ```
22 | python -m unittest -v test_agtypes.py
23 | `
24 |
--------------------------------------------------------------------------------
/img/contents.svg:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/.github/workflows/nodejs-driver.yaml:
--------------------------------------------------------------------------------
1 | name: Nodejs Driver Tests
2 |
3 | on:
4 | push:
5 | branches: [ "master" ]
6 |
7 | pull_request:
8 | branches: [ "master" ]
9 |
10 | jobs:
11 | build:
12 | runs-on: ubuntu-latest
13 |
14 | defaults:
15 | run:
16 | working-directory: drivers/nodejs/
17 |
18 | steps:
19 | - uses: actions/checkout@v4
20 |
21 | - name: Run apache/age docker image
22 | run: docker compose up -d
23 |
24 | - name: Set up Node
25 | uses: actions/setup-node@v3
26 | with:
27 | node-version: latest
28 |
29 | - name: Install dependencies
30 | run: npm install
31 |
32 | - name: Build
33 | run: npm run build
34 |
35 | - name: Test
36 | run: npm test
37 |
--------------------------------------------------------------------------------
/drivers/python/__init__.py:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | # Unless required by applicable law or agreed to in writing,
10 | # software distributed under the License is distributed on an
11 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 | # KIND, either express or implied. See the License for the
13 | # specific language governing permissions and limitations
14 | # under the License.
15 |
16 |
--------------------------------------------------------------------------------
/drivers/python/age/gen/__init__.py:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | # Unless required by applicable law or agreed to in writing,
10 | # software distributed under the License is distributed on an
11 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 | # KIND, either express or implied. See the License for the
13 | # specific language governing permissions and limitations
14 | # under the License.
15 |
--------------------------------------------------------------------------------
/.github/workflows/go-driver.yml:
--------------------------------------------------------------------------------
1 | name: Go Driver Tests
2 |
3 | on:
4 | push:
5 | branches: [ "master" ]
6 |
7 | pull_request:
8 | branches: [ "master" ]
9 |
10 | jobs:
11 | build:
12 | runs-on: ubuntu-latest
13 | strategy:
14 | matrix:
15 | go-version: [ '1.20', '1.21' ]
16 |
17 | defaults:
18 | run:
19 | working-directory: drivers/golang/age/
20 |
21 | steps:
22 | - uses: actions/checkout@v4
23 |
24 | - name: Run apache/age docker image
25 | run: docker compose up -d
26 |
27 | - name: Set up Go
28 | uses: actions/setup-go@v3
29 | with:
30 | go-version: ${{ matrix.go-version }}
31 |
32 | - name: Generate
33 | run: go generate ./../...
34 |
35 | - name: Build
36 | run: go build -v ./...
37 |
38 | - name: Test
39 | run: go test . -v
40 |
--------------------------------------------------------------------------------
/drivers/python/samples/__init__.py:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | # Unless required by applicable law or agreed to in writing,
10 | # software distributed under the License is distributed on an
11 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 | # KIND, either express or implied. See the License for the
13 | # specific language governing permissions and limitations
14 | # under the License.
15 |
16 |
--------------------------------------------------------------------------------
/drivers/jdbc/.gitattributes:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | *.bat text eol=crlf
19 |
20 |
--------------------------------------------------------------------------------
/docker/docker-entrypoint-initdb.d/00-create-extension-age.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Licensed to the Apache Software Foundation (ASF) under one
3 | -- or more contributor license agreements. See the NOTICE file
4 | -- distributed with this work for additional information
5 | -- regarding copyright ownership. The ASF licenses this file
6 | -- to you under the Apache License, Version 2.0 (the
7 | -- "License"); you may not use this file except in compliance
8 | -- with the License. You may obtain a copy of the License at
9 | --
10 | -- http://www.apache.org/licenses/LICENSE-2.0
11 | --
12 | -- Unless required by applicable law or agreed to in writing, software
13 | -- distributed under the License is distributed on an "AS IS" BASIS,
14 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | -- See the License for the specific language governing permissions and
16 | -- limitations under the License.
17 | --
18 |
19 | CREATE EXTENSION age;
--------------------------------------------------------------------------------
/drivers/jdbc/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | rootProject.name = "age-jdbc"
21 | include("lib")
22 |
--------------------------------------------------------------------------------
/drivers/python/age/networkx/__init__.py:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | # Unless required by applicable law or agreed to in writing,
10 | # software distributed under the License is distributed on an
11 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 | # KIND, either express or implied. See the License for the
13 | # specific language governing permissions and limitations
14 | # under the License.
15 |
16 | from .networkx_to_age import networkx_to_age
17 | from .age_to_networkx import age_to_networkx
18 |
--------------------------------------------------------------------------------
/age.control:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | default_version = '1.6.0'
19 | comment = 'AGE database extension'
20 | module_pathname = '$libdir/age'
21 |
22 | schema = 'ag_catalog'
23 |
--------------------------------------------------------------------------------
/drivers/nodejs/jest.config.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | module.exports = {
21 | preset: 'ts-jest',
22 | testEnvironment: 'node'
23 | }
24 |
--------------------------------------------------------------------------------
/.github/workflows/labeler.yml:
--------------------------------------------------------------------------------
1 | name: "Pull Request Labeler"
2 | on:
3 | - pull_request_target
4 |
5 | jobs:
6 | triage:
7 | permissions:
8 | contents: write
9 | pull-requests: write
10 | issues: write
11 | runs-on: ubuntu-latest
12 | steps:
13 | - name: Checkout
14 | uses: actions/checkout@v3
15 |
16 | - name: Apply branch labels
17 | uses: actions/labeler@v5.0.0
18 |
19 | - name: Apply label based on author
20 | if: |
21 | contains('["jrgemignani", "dehowef", "eyab" "rafsun42", "Zainab-Saad", "MuhammadTahaNaveed"]', github.event.pull_request.user.login)
22 | uses: actions/github-script@v7
23 | with:
24 | script: |
25 | const labelsToAdd = ['override-stale'];
26 | github.rest.issues.addLabels({
27 | issue_number: context.issue.number,
28 | owner: context.repo.owner,
29 | repo: context.repo.repo,
30 | labels: labelsToAdd
31 | });
32 |
--------------------------------------------------------------------------------
/drivers/python/age/VERSION.py:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | # Unless required by applicable law or agreed to in writing,
10 | # software distributed under the License is distributed on an
11 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 | # KIND, either express or implied. See the License for the
13 | # specific language governing permissions and limitations
14 | # under the License.
15 |
16 |
17 |
18 | VER_MAJOR = 1
19 | VER_MINOR = 0
20 | VER_MICRO = 0
21 |
22 | VERSION = '.'.join([str(VER_MAJOR),str(VER_MINOR),str(VER_MICRO)])
23 |
--------------------------------------------------------------------------------
/img/community.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
15 |
--------------------------------------------------------------------------------
/drivers/nodejs/.gitignore:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | /node_modules
19 | /yarn.lock
20 | /package-lock.json
21 | src/antlr4/*.tokens
22 | src/antlr4/*.interp
23 |
24 | # it will be create on "prepare" step.
25 | /dist
26 |
--------------------------------------------------------------------------------
/src/include/parser/cypher_parser.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_CYPHER_PARSER_H
21 | #define AG_CYPHER_PARSER_H
22 |
23 | List *parse_cypher(const char *s);
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/drivers/jdbc/lib/src/main/java/org/apache/age/jdbc/base/type/AgtypeObject.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.age.jdbc.base.type;
21 |
22 | public interface AgtypeObject {
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/drivers/golang/TYPES.md:
--------------------------------------------------------------------------------
1 | # Apache AGE - Go driver Type mapping
2 |
3 | * For more information about Apache AGE result types : https://age.apache.org/docs/Apache_AGE_Guide.pdf
4 |
5 | | Type | AGE Result | Go Type |
6 | |------|------------|---------|
7 | |Vertex|::vertex |Vertex vertex.Id() int64 vertex.Label() string vertex.Prop(string) interface{} |
8 | |Edge |::edge |Edge edge.Id() int64 edge.Label() string edge.StartId() int64 edge.EndId() int64 edge.Prop(string) interface{} |
9 | |Path |::path |Path path.Size() int // quantity of vertices and edges in this path path.Get(index int) Entity // *Vertex or *Edge path.GetAsVertex(index int) *Vertex path.GetAsEdge(index int) *Edge |
10 | |Integer |int |int64 |
11 | |Float |float NaN, -Infinity, Infinity |float64 math.Nan(), math.Inf(-1),math.Inf(1) |
12 | |Numeric |::numeric |*big.Int *big.Float |
13 | |String|string |string |
14 | |Boolean|bool |bool |
15 | |Null|empty result |nil |
16 |
17 |
--------------------------------------------------------------------------------
/drivers/jdbc/.gitignore:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 |
19 | # Ignore Gradle Wapper
20 | gradle/wrapper/gradle-wrapper.jar
21 |
22 | # Ignore Gradle project-specific cache directory
23 | .gradle
24 |
25 | # Ignore Gradle build output directory
26 | build
27 |
--------------------------------------------------------------------------------
/src/include/catalog/ag_namespace.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_AG_NAMESPACE_H
21 | #define AG_AG_NAMESPACE_H
22 |
23 | Oid ag_catalog_namespace_id(void);
24 | Oid pg_catalog_namespace_id(void);
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/src/include/optimizer/cypher_paths.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_CYPHER_PATHS_H
21 | #define AG_CYPHER_PATHS_H
22 |
23 | void set_rel_pathlist_init(void);
24 | void set_rel_pathlist_fini(void);
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/.github/workflows/python-driver.yaml:
--------------------------------------------------------------------------------
1 | name: Python Driver Tests
2 |
3 | on:
4 | push:
5 | branches: [ "master" ]
6 |
7 | pull_request:
8 | branches: [ "master" ]
9 |
10 | jobs:
11 | build:
12 | runs-on: ubuntu-latest
13 |
14 | defaults:
15 | run:
16 | working-directory: drivers/python
17 |
18 | steps:
19 | - uses: actions/checkout@v4
20 |
21 | - name: Run apache/age docker image
22 | run: docker compose up -d
23 |
24 | - name: Set up python
25 | uses: actions/setup-python@v4
26 | with:
27 | python-version: '3.12'
28 |
29 | - name: Install pre-requisites
30 | run: |
31 | sudo apt-get install python3-dev libpq-dev
32 | pip install -r requirements.txt
33 |
34 | - name: Build
35 | run: |
36 | pip install .
37 |
38 | - name: Test
39 | run: |
40 | python test_age_py.py -db "postgres" -u "postgres" -pass "agens"
41 | python test_networkx.py -db "postgres" -u "postgres" -pass "agens"
42 | python -m unittest -v test_agtypes.py
43 |
--------------------------------------------------------------------------------
/drivers/jdbc/lib/src/main/java/org/apache/age/jdbc/base/type/AgtypeAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.age.jdbc.base.type;
21 |
22 | public interface AgtypeAnnotation {
23 |
24 | String getAnnotation();
25 | }
26 |
--------------------------------------------------------------------------------
/drivers/python/setup.py:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | # Unless required by applicable law or agreed to in writing,
10 | # software distributed under the License is distributed on an
11 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 | # KIND, either express or implied. See the License for the
13 | # specific language governing permissions and limitations
14 | # under the License.
15 |
16 | # This setup.py is maintained for backward compatibility.
17 | # All package configuration is in pyproject.toml. For installation,
18 | # use: pip install .
19 |
20 | from setuptools import setup
21 |
22 | setup()
23 |
--------------------------------------------------------------------------------
/img/tick.svg:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/src/include/commands/graph_commands.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_GRAPH_COMMANDS_H
21 | #define AG_GRAPH_COMMANDS_H
22 |
23 | Datum create_graph(PG_FUNCTION_ARGS);
24 | Oid create_graph_internal(const Name graph_name);
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/drivers/jdbc/lib/src/main/java/org/apache/age/jdbc/base/type/UnrecognizedObject.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.age.jdbc.base.type;
21 |
22 | public interface UnrecognizedObject {
23 |
24 | void setAnnotation(String annotation);
25 | }
26 |
--------------------------------------------------------------------------------
/drivers/jdbc/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | distributionBase=GRADLE_USER_HOME
19 | distributionPath=wrapper/dists
20 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
21 | zipStoreBase=GRADLE_USER_HOME
22 | zipStorePath=wrapper/dists
23 |
--------------------------------------------------------------------------------
/drivers/README:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | This folder contains drivers for specific languages
19 |
20 | ### For more information about [Apache AGE](https://age.apache.org/)
21 | * Apache Age : https://age.apache.org/
22 | * GitHub : https://github.com/apache/age
23 | * Document : https://age.apache.org/age-manual/master/index.html
24 |
--------------------------------------------------------------------------------
/src/include/parser/cypher_keywords.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_KEYWORDS_H
21 | #define AG_KEYWORDS_H
22 |
23 | #include "common/kwlookup.h"
24 |
25 | extern const ScanKeywordList CypherKeyword;
26 | extern const uint16 CypherKeywordTokens[];
27 | extern const uint16 CypherKeywordCategories[];
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/drivers/golang/parser/age_visitor.go:
--------------------------------------------------------------------------------
1 | // Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT.
2 |
3 | package parser // Age
4 |
5 | import "github.com/antlr/antlr4/runtime/Go/antlr/v4"
6 |
7 | // A complete Visitor for a parse tree produced by AgeParser.
8 | type AgeVisitor interface {
9 | antlr.ParseTreeVisitor
10 |
11 | // Visit a parse tree produced by AgeParser#ageout.
12 | VisitAgeout(ctx *AgeoutContext) interface{}
13 |
14 | // Visit a parse tree produced by AgeParser#vertex.
15 | VisitVertex(ctx *VertexContext) interface{}
16 |
17 | // Visit a parse tree produced by AgeParser#edge.
18 | VisitEdge(ctx *EdgeContext) interface{}
19 |
20 | // Visit a parse tree produced by AgeParser#path.
21 | VisitPath(ctx *PathContext) interface{}
22 |
23 | // Visit a parse tree produced by AgeParser#value.
24 | VisitValue(ctx *ValueContext) interface{}
25 |
26 | // Visit a parse tree produced by AgeParser#properties.
27 | VisitProperties(ctx *PropertiesContext) interface{}
28 |
29 | // Visit a parse tree produced by AgeParser#pair.
30 | VisitPair(ctx *PairContext) interface{}
31 |
32 | // Visit a parse tree produced by AgeParser#arr.
33 | VisitArr(ctx *ArrContext) interface{}
34 | }
35 |
--------------------------------------------------------------------------------
/src/include/utils/age_session_info.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AGE_SESSION_INFO_H
21 | #define AGE_SESSION_INFO_H
22 |
23 | #include "utils/agtype.h"
24 |
25 | bool is_session_info_prepared(void);
26 | char *get_session_info_graph_name(void);
27 | char *get_session_info_cypher_statement(void);
28 | void reset_session_info(void);
29 |
30 | #endif
31 |
32 |
--------------------------------------------------------------------------------
/drivers/golang/parser/age_base_visitor.go:
--------------------------------------------------------------------------------
1 | // Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT.
2 |
3 | package parser // Age
4 |
5 | import "github.com/antlr/antlr4/runtime/Go/antlr/v4"
6 |
7 | type BaseAgeVisitor struct {
8 | *antlr.BaseParseTreeVisitor
9 | }
10 |
11 | func (v *BaseAgeVisitor) VisitAgeout(ctx *AgeoutContext) interface{} {
12 | return v.VisitChildren(ctx)
13 | }
14 |
15 | func (v *BaseAgeVisitor) VisitVertex(ctx *VertexContext) interface{} {
16 | return v.VisitChildren(ctx)
17 | }
18 |
19 | func (v *BaseAgeVisitor) VisitEdge(ctx *EdgeContext) interface{} {
20 | return v.VisitChildren(ctx)
21 | }
22 |
23 | func (v *BaseAgeVisitor) VisitPath(ctx *PathContext) interface{} {
24 | return v.VisitChildren(ctx)
25 | }
26 |
27 | func (v *BaseAgeVisitor) VisitValue(ctx *ValueContext) interface{} {
28 | return v.VisitChildren(ctx)
29 | }
30 |
31 | func (v *BaseAgeVisitor) VisitProperties(ctx *PropertiesContext) interface{} {
32 | return v.VisitChildren(ctx)
33 | }
34 |
35 | func (v *BaseAgeVisitor) VisitPair(ctx *PairContext) interface{} {
36 | return v.VisitChildren(ctx)
37 | }
38 |
39 | func (v *BaseAgeVisitor) VisitArr(ctx *ArrContext) interface{} {
40 | return v.VisitChildren(ctx)
41 | }
42 |
--------------------------------------------------------------------------------
/src/backend/catalog/ag_namespace.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #include "postgres.h"
21 |
22 | #include "catalog/namespace.h"
23 |
24 | #include "catalog/ag_namespace.h"
25 |
26 | Oid ag_catalog_namespace_id(void)
27 | {
28 | return get_namespace_oid("ag_catalog", false);
29 | }
30 |
31 | Oid pg_catalog_namespace_id(void)
32 | {
33 | return get_namespace_oid("pg_catalog", false);
34 | }
35 |
--------------------------------------------------------------------------------
/src/include/catalog/ag_catalog.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_AG_CATALOG_H
21 | #define AG_AG_CATALOG_H
22 |
23 | #include "postgres.h"
24 |
25 | #include "utils/agtype.h"
26 |
27 | void object_access_hook_init(void);
28 | void object_access_hook_fini(void);
29 |
30 | void process_utility_hook_init(void);
31 | void process_utility_hook_fini(void);
32 |
33 | Oid ag_relation_id(const char *name, const char *kind);
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/drivers/nodejs/.eslintrc.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | module.exports = {
21 | env: {
22 | es2021: true,
23 | node: true
24 | },
25 | extends: [
26 | 'standard',
27 | 'plugin:jest/recommended'
28 | ],
29 | parser: '@typescript-eslint/parser',
30 | parserOptions: {
31 | ecmaVersion: 12,
32 | sourceType: 'module'
33 | },
34 | plugins: [
35 | '@typescript-eslint',
36 | 'jest'
37 | ],
38 | rules: {}
39 | }
40 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **How are you accessing AGE (Command line, driver, etc.)?**
14 | - [e.g. JDBC]
15 |
16 | **What data setup do we need to do?**
17 | ```pgsql
18 | ...
19 | SELECT * from cypher('my_graph_name', $$
20 | CREATE (a:Part {part_num: '123'}),
21 | (b:Part {part_num: '345'}),
22 | (c:Part {part_num: '456'}),
23 | (d:Part {part_num: '789'})
24 | $$) as (a agtype);
25 | ...
26 | ```
27 |
28 | **What is the necessary configuration info needed?**
29 | - [e.g. Installed PostGIS]
30 |
31 | **What is the command that caused the error?**
32 | ```pgsql
33 | SELECT * from cypher('my_graph_name', $$
34 | MATCH (a:Part {part_num: '123'}), (b:Part {part_num: '345'})
35 | CREATE (a)-[u:used_by { quantity: 1 }]->(b)
36 | $$) as (a agtype);
37 | ```
38 | ```
39 | ERROR: something failed to execute
40 | ```
41 |
42 | **Expected behavior**
43 | A clear and concise description of what you expected to happen.
44 |
45 | **Environment (please complete the following information):**
46 | - Version: [e.g. 0.4.0]
47 |
48 | **Additional context**
49 | Add any other context about the problem here.
50 |
--------------------------------------------------------------------------------
/src/include/parser/cypher_item.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_CYPHER_ITEM_H
21 | #define AG_CYPHER_ITEM_H
22 |
23 | TargetEntry *transform_cypher_item(cypher_parsestate *cpstate, Node *node,
24 | Node *expr, ParseExprKind expr_kind,
25 | char *colname, bool resjunk);
26 | List *transform_cypher_item_list(cypher_parsestate *cpstate, List *item_list,
27 | List **groupClause, ParseExprKind expr_kind);
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/drivers/jdbc/lib/src/main/java/org/apache/age/jdbc/base/InvalidAgtypeException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.age.jdbc.base;
21 |
22 | /**
23 | * Runtime exception for when there is an invalid use of Agtype.
24 | */
25 | public class InvalidAgtypeException extends RuntimeException {
26 |
27 | public InvalidAgtypeException(String message) {
28 | super(message);
29 | }
30 |
31 | public InvalidAgtypeException(String message, Throwable cause) {
32 | super(message, cause);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/drivers/nodejs/README.md:
--------------------------------------------------------------------------------
1 | nodejs-pg-age
2 | ===========
3 |
4 |
5 |
6 | Example
7 | -----
8 | Initialize on make connection
9 |
10 | ```typescript
11 | import {types, Client, QueryResultRow} from "pg";
12 | import {setAGETypes} from "../src";
13 |
14 | const config = {
15 | user: 'postgres',
16 | host: '127.0.0.1',
17 | database: 'postgres',
18 | password: 'postgres',
19 | port: 25432,
20 | }
21 |
22 | const client = new Client(config);
23 | await client.connect();
24 | await setAGETypes(client, types);
25 |
26 | await client.query(`SELECT create_graph('age-first-time');`);
27 | ```
28 |
29 | Query
30 |
31 | ```typescript
32 | await client?.query(`
33 | SELECT *
34 | from cypher('age-first-time', $$
35 | CREATE (a:Part {part_num: '123'}),
36 | (b:Part {part_num: '345'}),
37 | (c:Part {part_num: '456'}),
38 | (d:Part {part_num: '789'})
39 | $$) as (a agtype);
40 | `)
41 |
42 | const results: QueryResultRow = await client?.query(`
43 | SELECT *
44 | from cypher('age-first-time', $$
45 | MATCH (a) RETURN a
46 | $$) as (a agtype);
47 | `)!
48 | ```
49 | ### For more information about [Apache AGE](https://age.apache.org/)
50 | * Apache Age : https://age.apache.org/
51 | * GitHub : https://github.com/apache/age
52 | * Document : https://age.apache.org/age-manual/master/index.html
53 |
--------------------------------------------------------------------------------
/drivers/golang/go.mod:
--------------------------------------------------------------------------------
1 | // /*
2 | // * Licensed to the Apache Software Foundation (ASF) under one
3 | // * or more contributor license agreements. See the NOTICE file
4 | // * distributed with this work for additional information
5 | // * regarding copyright ownership. The ASF licenses this file
6 | // * to you under the Apache License, Version 2.0 (the
7 | // * "License"); you may not use this file except in compliance
8 | // * with the License. You may obtain a copy of the License at
9 | // *
10 | // * http://www.apache.org/licenses/LICENSE-2.0
11 | // *
12 | // * Unless required by applicable law or agreed to in writing,
13 | // * software distributed under the License is distributed on an
14 | // * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | // * KIND, either express or implied. See the License for the
16 | // * specific language governing permissions and limitations
17 | // * under the License.
18 | // */
19 |
20 | module github.com/apache/age/drivers/golang
21 |
22 | go 1.19
23 |
24 | require (
25 | github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1
26 | github.com/lib/pq v1.10.9
27 | github.com/stretchr/testify v1.7.0
28 | )
29 |
30 | require (
31 | github.com/davecgh/go-spew v1.1.0 // indirect
32 | github.com/pmezard/go-difflib v1.0.0 // indirect
33 | golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect
34 | gopkg.in/yaml.v3 v3.0.1 // indirect
35 | )
36 |
--------------------------------------------------------------------------------
/regress/sql/issue_369.sql:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | LOAD 'age';
21 | SET search_path TO ag_catalog;
22 |
23 | SELECT create_graph('cypher');
24 |
25 | SELECT * from cypher('cypher', $$ CREATE (a {x:1})-[:foo]->(b {x:2}),(c {x:3}) $$) as (v0 agtype);
26 |
27 | SELECT * from cypher('cypher', $$ MATCH ()-[a:foo]->(), (b {x:2}),(c {x:3}) MERGE (b)-[d:bar]->(c) RETURN d $$) as (v0 agtype);
28 |
29 | SELECT * from cypher('cypher', $$ MATCH (x)-[a:foo]->(), (b {x:2}),(c {x:3}) MERGE (b)-[d:bar]->(c) RETURN d $$) as (v0 agtype);
30 |
31 | SELECT * from cypher('cypher', $$ MATCH ()-[a:foo]->(y), (b {x:2}),(c {x:3}) MERGE (b)-[d:bar]->(c) RETURN d $$) as (v0 agtype);
32 |
--------------------------------------------------------------------------------
/drivers/nodejs/tsconfig.json:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | {
21 | "compilerOptions": {
22 | "target": "es6",
23 | "module": "commonjs",
24 | "declaration": true,
25 | "outDir": "dist/",
26 | "rootDir": "src/",
27 | "strict": true,
28 | "noUnusedLocals": true,
29 | "noUnusedParameters": true,
30 | "noImplicitReturns": true,
31 | "noFallthroughCasesInSwitch": true,
32 | "noUncheckedIndexedAccess": true,
33 | "esModuleInterop": true,
34 | "skipLibCheck": true,
35 | "forceConsistentCasingInFileNames": true
36 | },
37 | "exclude": [
38 | "node_modules",
39 | "**/*.spec.ts",
40 | "test"
41 | ]
42 | }
43 |
--------------------------------------------------------------------------------
/drivers/golang/age/errors.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package age
20 |
21 | import (
22 | "bytes"
23 | "fmt"
24 | )
25 |
26 | type AgeError struct {
27 | cause error
28 | msg string
29 | }
30 |
31 | func (e *AgeError) Error() string {
32 | if e.cause != nil {
33 | return fmt.Sprintf("%s >> Cause:%s", e.msg, e.cause.Error())
34 | }
35 | return e.msg
36 | }
37 |
38 | type AgeParseError struct {
39 | msg string
40 | errors []string
41 | }
42 |
43 | func (e *AgeParseError) Error() string {
44 | var buf bytes.Buffer
45 | buf.WriteString(e.msg)
46 | buf.WriteString(" >> Causes:\n")
47 | for _, err := range e.errors {
48 | buf.WriteString(err)
49 | buf.WriteString("\n")
50 | }
51 | return buf.String()
52 | }
53 |
--------------------------------------------------------------------------------
/drivers/jdbc/lib/src/main/java/org/apache/age/jdbc/AgtypeUnrecognizedList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.age.jdbc;
21 |
22 | import org.apache.age.jdbc.base.type.AgtypeAnnotation;
23 | import org.apache.age.jdbc.base.type.AgtypeListImpl;
24 | import org.apache.age.jdbc.base.type.UnrecognizedObject;
25 |
26 | public class AgtypeUnrecognizedList extends AgtypeListImpl implements UnrecognizedObject,
27 | AgtypeAnnotation {
28 |
29 | private String annotation;
30 |
31 | @Override
32 | public String getAnnotation() {
33 | return this.annotation;
34 | }
35 |
36 | @Override
37 | public void setAnnotation(String annotation) {
38 | this.annotation = annotation;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/drivers/jdbc/lib/src/main/java/org/apache/age/jdbc/AgtypeUnrecognizedMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.age.jdbc;
21 |
22 | import org.apache.age.jdbc.base.type.AgtypeAnnotation;
23 | import org.apache.age.jdbc.base.type.AgtypeMapImpl;
24 | import org.apache.age.jdbc.base.type.UnrecognizedObject;
25 |
26 | public class AgtypeUnrecognizedMap extends AgtypeMapImpl implements UnrecognizedObject,
27 | AgtypeAnnotation {
28 |
29 | private String annotation;
30 |
31 | @Override
32 | public String getAnnotation() {
33 | return this.annotation;
34 | }
35 |
36 | @Override
37 | public void setAnnotation(String annotation) {
38 | this.annotation = annotation;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/backend/age.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #include "catalog/ag_catalog.h"
21 | #include "nodes/ag_nodes.h"
22 | #include "optimizer/cypher_paths.h"
23 | #include "parser/cypher_analyze.h"
24 | #include "utils/ag_guc.h"
25 |
26 | PG_MODULE_MAGIC;
27 |
28 | void _PG_init(void);
29 |
30 | void _PG_init(void)
31 | {
32 | register_ag_nodes();
33 | set_rel_pathlist_init();
34 | object_access_hook_init();
35 | process_utility_hook_init();
36 | post_parse_analyze_init();
37 | define_config_params();
38 | }
39 |
40 | void _PG_fini(void);
41 |
42 | void _PG_fini(void)
43 | {
44 | post_parse_analyze_fini();
45 | process_utility_hook_fini();
46 | object_access_hook_fini();
47 | set_rel_pathlist_fini();
48 | }
49 |
--------------------------------------------------------------------------------
/src/include/parser/cypher_parse_agg.h:
--------------------------------------------------------------------------------
1 | /*
2 | * For PostgreSQL Database Management System:
3 | * (formerly known as Postgres, then as Postgres95)
4 | *
5 | * Portions Copyright (c) 1996-2010, The PostgreSQL Global Development Group
6 | *
7 | * Portions Copyright (c) 1994, The Regents of the University of California
8 | *
9 | * Permission to use, copy, modify, and distribute this software and its documentation for any purpose,
10 | * without fee, and without a written agreement is hereby granted, provided that the above copyright notice
11 | * and this paragraph and the following two paragraphs appear in all copies.
12 | *
13 | * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT,
14 | * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
15 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY
16 | * OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 | *
18 | * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 | *
21 | * THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA
22 | * HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 | */
24 |
25 | #ifndef CYPHER_PARSE_AGG_H
26 | #define CYPHER_PARSE_AGG_H
27 |
28 | #include "parser/parse_node.h"
29 |
30 | extern void parse_check_aggregates(ParseState *pstate, Query *qry);
31 |
32 | #endif /* CYPHER_PARSE_AGG_H */
33 |
--------------------------------------------------------------------------------
/src/include/parser/cypher_expr.h:
--------------------------------------------------------------------------------
1 | /*
2 | * For PostgreSQL Database Management System:
3 | * (formerly known as Postgres, then as Postgres95)
4 | *
5 | * Portions Copyright (c) 1996-2010, The PostgreSQL Global Development Group
6 | *
7 | * Portions Copyright (c) 1994, The Regents of the University of California
8 | *
9 | * Permission to use, copy, modify, and distribute this software and its documentation for any purpose,
10 | * without fee, and without a written agreement is hereby granted, provided that the above copyright notice
11 | * and this paragraph and the following two paragraphs appear in all copies.
12 | *
13 | * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT,
14 | * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
15 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY
16 | * OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 | *
18 | * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 | *
21 | * THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA
22 | * HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 | */
24 |
25 | #ifndef AG_CYPHER_EXPR_H
26 | #define AG_CYPHER_EXPR_H
27 |
28 | #include "parser/cypher_parse_node.h"
29 |
30 | Node *transform_cypher_expr(cypher_parsestate *cpstate, Node *expr,
31 | ParseExprKind expr_kind);
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/drivers/golang/samples/main.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package main
20 |
21 | import (
22 | "fmt"
23 |
24 | _ "github.com/lib/pq"
25 | )
26 |
27 | // var dsn string = "host={host} port={port} dbname={dbname} user={username} password={password} sslmode=disable"
28 | var dsn string = "host=127.0.0.1 port=5432 dbname=postgres user=postgres password=agens sslmode=disable"
29 |
30 | // var graphName string = "{graph_path}"
31 | var graphName string = "testGraph"
32 |
33 | func main() {
34 |
35 | // Do cypher query to AGE with database/sql Tx API transaction control
36 | fmt.Println("# Do cypher query with SQL API")
37 | doWithSqlAPI(dsn, graphName)
38 |
39 | // Do cypher query to AGE with Age API
40 | fmt.Println("# Do cypher query with Age API")
41 | doWithAgeWrapper(dsn, graphName)
42 | }
43 |
--------------------------------------------------------------------------------
/src/include/utils/ag_float8_supp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * For PostgreSQL Database Management System:
3 | * (formerly known as Postgres, then as Postgres95)
4 | *
5 | * Portions Copyright (c) 1996-2010, The PostgreSQL Global Development Group
6 | *
7 | * Portions Copyright (c) 1994, The Regents of the University of California
8 | *
9 | * Permission to use, copy, modify, and distribute this software and its documentation for any purpose,
10 | * without fee, and without a written agreement is hereby granted, provided that the above copyright notice
11 | * and this paragraph and the following two paragraphs appear in all copies.
12 | *
13 | * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT,
14 | * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
15 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY
16 | * OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 | *
18 | * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 | *
21 | * THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA
22 | * HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 | */
24 |
25 | #ifndef AG_FLOAT_H
26 | #define AG_FLOAT_H
27 |
28 | bool is_float8_special_number(float8 number);
29 | float8 float8in_internal_null(char *num, char **endptr_p, const char *type_name,
30 | const char *orig_string, bool *is_valid);
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/src/include/utils/agtype_ext.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_AGTYPE_EXT_H
21 | #define AG_AGTYPE_EXT_H
22 |
23 | #include "postgres.h"
24 |
25 | #include "utils/agtype.h"
26 |
27 | /*
28 | * Function serializes the data into the buffer provided.
29 | * Returns false if the type is not defined. Otherwise, true.
30 | */
31 | bool ag_serialize_extended_type(StringInfo buffer, agtentry *agtentry,
32 | agtype_value *scalar_val);
33 |
34 | /*
35 | * Function deserializes the data from the buffer pointed to by base_addr.
36 | * NOTE: This function writes to the error log and exits for any UNKNOWN
37 | * AGT_HEADER type.
38 | */
39 | void ag_deserialize_extended_type(char *base_addr, uint32 offset,
40 | agtype_value *result);
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/src/include/parser/cypher_clause.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_CYPHER_CLAUSE_H
21 | #define AG_CYPHER_CLAUSE_H
22 |
23 | #include "parser/cypher_parse_node.h"
24 |
25 | typedef struct cypher_clause cypher_clause;
26 |
27 | struct cypher_clause
28 | {
29 | cypher_clause *next; /* next clause */
30 | Node *self;
31 | cypher_clause *prev; /* previous clause */
32 | };
33 |
34 | Query *transform_cypher_clause(cypher_parsestate *cpstate,
35 | cypher_clause *clause);
36 |
37 | Query *cypher_parse_sub_analyze(Node *parseTree,
38 | cypher_parsestate *cpstate,
39 | CommonTableExpr *parentCTE,
40 | bool locked_from_parent,
41 | bool resolve_unknowns);
42 | #endif
43 |
--------------------------------------------------------------------------------
/img/apple.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/docker/Dockerfile.dev:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 |
20 | FROM postgres:17
21 |
22 | RUN apt-get update
23 | RUN apt-get install --assume-yes --no-install-recommends --no-install-suggests \
24 | bison \
25 | build-essential \
26 | flex \
27 | postgresql-server-dev-17 \
28 | locales
29 |
30 | ENV LANG=en_US.UTF-8
31 | ENV LC_COLLATE=en_US.UTF-8
32 | ENV LC_CTYPE=en_US.UTF-8
33 |
34 | RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
35 | && locale-gen \
36 | && update-locale LANG=en_US.UTF-8
37 | COPY . /age
38 |
39 | # Set current working directory to /age/ and build.
40 | WORKDIR /age
41 | RUN make install
42 |
43 | RUN chown -R postgres /age
44 | USER postgres
45 |
46 | RUN make installcheck
47 |
48 | COPY docker/docker-entrypoint-initdb.d/00-create-extension-age.sql /docker-entrypoint-initdb.d/00-create-extension-age.sql
49 |
50 | CMD ["postgres", "-c", "shared_preload_libraries=age"]
51 |
--------------------------------------------------------------------------------
/drivers/python/age/__init__.py:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | # Unless required by applicable law or agreed to in writing,
10 | # software distributed under the License is distributed on an
11 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 | # KIND, either express or implied. See the License for the
13 | # specific language governing permissions and limitations
14 | # under the License.
15 |
16 | import psycopg.conninfo as conninfo
17 | from . import age
18 | from .age import *
19 | from .models import *
20 | from .builder import ResultHandler, DummyResultHandler, parseAgeValue, newResultHandler
21 | from . import VERSION
22 |
23 | def version():
24 | return VERSION.VERSION
25 |
26 |
27 | def connect(dsn=None, graph=None, connection_factory=None, cursor_factory=ClientCursor, load_from_plugins=False,
28 | **kwargs):
29 |
30 | dsn = conninfo.make_conninfo('' if dsn is None else dsn, **kwargs)
31 |
32 | ag = Age()
33 | ag.connect(dsn=dsn, graph=graph, connection_factory=connection_factory, cursor_factory=cursor_factory,
34 | load_from_plugins=load_from_plugins, **kwargs)
35 | return ag
36 |
37 | # Dummy ResultHandler
38 | rawPrinter = DummyResultHandler()
39 |
40 | __name__="age"
41 |
--------------------------------------------------------------------------------
/src/include/optimizer/cypher_pathnode.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_CYPHER_PATHNODE_H
21 | #define AG_CYPHER_PATHNODE_H
22 |
23 | #define CREATE_PATH_NAME "Cypher Create"
24 | #define SET_PATH_NAME "Cypher Set"
25 | #define DELETE_PATH_NAME "Cypher Delete"
26 | #define MERGE_PATH_NAME "Cypher Merge"
27 |
28 | CustomPath *create_cypher_create_path(PlannerInfo *root, RelOptInfo *rel,
29 | List *custom_private);
30 | CustomPath *create_cypher_set_path(PlannerInfo *root, RelOptInfo *rel,
31 | List *custom_private);
32 | CustomPath *create_cypher_delete_path(PlannerInfo *root, RelOptInfo *rel,
33 | List *custom_private);
34 | CustomPath *create_cypher_merge_path(PlannerInfo *root, RelOptInfo *rel,
35 | List *custom_private);
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/src/include/executor/cypher_executor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_CYPHER_EXECUTOR_H
21 | #define AG_CYPHER_EXECUTOR_H
22 |
23 | #include "nodes/extensible.h"
24 |
25 | #define DELETE_SCAN_STATE_NAME "Cypher Delete"
26 | #define SET_SCAN_STATE_NAME "Cypher Set"
27 | #define CREATE_SCAN_STATE_NAME "Cypher Create"
28 | #define MERGE_SCAN_STATE_NAME "Cypher Merge"
29 |
30 | Node *create_cypher_create_plan_state(CustomScan *cscan);
31 | extern const CustomExecMethods cypher_create_exec_methods;
32 |
33 | Node *create_cypher_set_plan_state(CustomScan *cscan);
34 | extern const CustomExecMethods cypher_set_exec_methods;
35 |
36 | Node *create_cypher_delete_plan_state(CustomScan *cscan);
37 | extern const CustomExecMethods cypher_delete_exec_methods;
38 |
39 | Node *create_cypher_merge_plan_state(CustomScan *cscan);
40 | extern const CustomExecMethods cypher_merge_exec_methods;
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/src/include/utils/ag_guc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_GUC_H
21 | #define AG_GUC_H
22 |
23 | /*
24 | * AGE configuration parameters.
25 | *
26 | * Ideally, these parameters should be documented in a .sgml file.
27 | *
28 | * To add a new parameter, add a global variable. Add its definition
29 | * in the `define_config_params` function. Include this header file
30 | * to use the global variable. The parameters can be set just like
31 | * regular Postgres parameters. See guc.h for more details.
32 | */
33 |
34 | /*
35 | * If set true, MATCH's property filter is transformed into the @>
36 | * (containment) operator. Otherwise, the -> operator is used. The former case
37 | * is useful when GIN index is desirable, the latter case is useful for Btree
38 | * expression index.
39 | */
40 | extern bool age_enable_containment;
41 |
42 | void define_config_params(void);
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/drivers/golang/go.sum:
--------------------------------------------------------------------------------
1 | github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1 h1:X8MJ0fnN5FPdcGF5Ij2/OW+HgiJrRg3AfHAx1PJtIzM=
2 | github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM=
3 | github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
4 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5 | github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
6 | github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
7 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
8 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
9 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
10 | github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
11 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
12 | golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo=
13 | golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
14 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
15 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
16 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
17 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
18 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
19 |
--------------------------------------------------------------------------------
/src/include/parser/cypher_analyze.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_CYPHER_ANALYZE_H
21 | #define AG_CYPHER_ANALYZE_H
22 |
23 | #include "parser/cypher_clause.h"
24 | #include "nodes/nodeFuncs.h"
25 |
26 | #define cypher_expr_tree_walker(n, w, c) \
27 | cypher_expr_tree_walker_impl(n, (tree_walker_callback) (w), c)
28 | #define cypher_raw_expr_tree_walker(n, w, c) \
29 | cypher_raw_expr_tree_walker_impl(n, (tree_walker_callback) (w), c)
30 |
31 | void post_parse_analyze_init(void);
32 | void post_parse_analyze_fini(void);
33 |
34 | /* expr tree walker */
35 | bool cypher_expr_tree_walker_impl(Node *node,
36 | bool (*walker)(Node *node, void *context),
37 | void *context);
38 | bool cypher_raw_expr_tree_walker_impl(Node *node,
39 | bool (*walker)(Node *node, void *context),
40 | void *context);
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/src/include/optimizer/cypher_createplan.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_CYPHER_CREATEPLAN_H
21 | #define AG_CYPHER_CREATEPLAN_H
22 |
23 | Plan *plan_cypher_create_path(PlannerInfo *root, RelOptInfo *rel,
24 | CustomPath *best_path, List *tlist,
25 | List *clauses, List *custom_plans);
26 |
27 | Plan *plan_cypher_set_path(PlannerInfo *root, RelOptInfo *rel,
28 | CustomPath *best_path, List *tlist,
29 | List *clauses, List *custom_plans);
30 |
31 | Plan *plan_cypher_delete_path(PlannerInfo *root, RelOptInfo *rel,
32 | CustomPath *best_path, List *tlist,
33 | List *clauses, List *custom_plans);
34 |
35 | Plan *plan_cypher_merge_path(PlannerInfo *root, RelOptInfo *rel,
36 | CustomPath *best_path, List *tlist,
37 | List *clauses, List *custom_plans);
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/src/include/utils/age_vle.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_AGTYPE_VLE_H
21 | #define AG_AGTYPE_VLE_H
22 |
23 | #include "utils/agtype.h"
24 | #include "utils/age_global_graph.h"
25 |
26 | /*
27 | * We declare the VLE_path_container here, and in this way, so that it may be
28 | * used elsewhere. However, we keep the contents private by defining it in
29 | * agtype_vle.c
30 | */
31 | typedef struct VLE_path_container VLE_path_container;
32 |
33 | /*
34 | * Function to take an AGTV_BINARY VLE_path_container and return a path as an
35 | * agtype.
36 | */
37 | agtype *agt_materialize_vle_path(agtype *agt_arg_vpc);
38 | /*
39 | * Function to take a AGTV_BINARY VLE_path_container and return a path as an
40 | * agtype_value.
41 | */
42 | agtype_value *agtv_materialize_vle_path(agtype *agt_arg_vpc);
43 | /*
44 | * Exposed helper function to make an agtype_value AGTV_ARRAY of edges from a
45 | * VLE_path_container.
46 | */
47 | agtype_value *agtv_materialize_vle_edges(agtype *agt_arg_vpc);
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/src/backend/utils/ag_guc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #include "postgres.h"
21 |
22 | #include "utils/guc.h"
23 | #include "utils/ag_guc.h"
24 |
25 | bool age_enable_containment = true;
26 |
27 | /*
28 | * Defines AGE's custom configuration parameters.
29 | *
30 | * The name of the parameter must be `age.*`. This name is used for setting
31 | * value to the parameter. For example, `SET age.enable_containment = on;`.
32 | */
33 | void define_config_params(void)
34 | {
35 | DefineCustomBoolVariable("age.enable_containment",
36 | "Use @> operator to transform MATCH's filter. Otherwise, use -> operator.",
37 | NULL,
38 | &age_enable_containment,
39 | true,
40 | PGC_SUSET,
41 | 0,
42 | NULL,
43 | NULL,
44 | NULL);
45 | EmitWarningsOnPlaceholders("age");
46 | }
47 |
--------------------------------------------------------------------------------
/src/include/utils/agtype_raw.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | /*
21 | * This module provides functions for directly building agtype
22 | * without using agtype_value.
23 | */
24 |
25 | #ifndef AG_AGTYPE_RAW_H
26 | #define AG_AGTYPE_RAW_H
27 |
28 | #include "utils/agtype_ext.h"
29 |
30 | /*
31 | * We declare the agtype_build_state here, and in this way, so that it may be
32 | * used elsewhere. However, we keep the contents private by defining it in
33 | * agtype_raw.c
34 | */
35 | typedef struct agtype_build_state agtype_build_state;
36 |
37 | agtype_build_state *init_agtype_build_state(uint32 size, uint32 header_flag);
38 | agtype *build_agtype(agtype_build_state *bstate);
39 | void pfree_agtype_build_state(agtype_build_state *bstate);
40 |
41 | void write_string(agtype_build_state *bstate, char *str);
42 | void write_graphid(agtype_build_state *bstate, graphid graphid);
43 | void write_container(agtype_build_state *bstate, agtype *agtype);
44 | void write_extended(agtype_build_state *bstate, agtype *val, uint32 header);
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/drivers/python/age/networkx/networkx_to_age.py:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | # Unless required by applicable law or agreed to in writing,
10 | # software distributed under the License is distributed on an
11 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 | # KIND, either express or implied. See the License for the
13 | # specific language governing permissions and limitations
14 | # under the License.
15 |
16 | from age import *
17 | import psycopg
18 | import networkx as nx
19 | from .lib import *
20 |
21 |
22 | def networkx_to_age(connection: psycopg.connect,
23 | G: nx.DiGraph,
24 | graphName: str):
25 | """
26 | @params
27 | -----------
28 | connection - (psycopg.connect) Connection object
29 |
30 | G - (networkx.DiGraph) Networkx directed Graph
31 |
32 | graphName - (str) Name of the graph
33 |
34 | @returns
35 | ------------
36 | None
37 |
38 | """
39 | node_label_list = getNodeLabelListAfterPreprocessing(G)
40 | edge_label_list = getEdgeLabelListAfterPreprocessing(G)
41 |
42 | # Setup connection with Graph
43 | age.setUpAge(connection, graphName)
44 |
45 | create_vlabel(connection, graphName, node_label_list)
46 | create_elabel(connection, graphName, edge_label_list)
47 |
48 | addAllNodesIntoAGE(connection, graphName, G, node_label_list)
49 | addAllEdgesIntoAGE(connection, graphName, G, edge_label_list)
50 |
--------------------------------------------------------------------------------
/src/include/utils/ag_func.h:
--------------------------------------------------------------------------------
1 | /*
2 | * For PostgreSQL Database Management System:
3 | * (formerly known as Postgres, then as Postgres95)
4 | *
5 | * Portions Copyright (c) 1996-2010, The PostgreSQL Global Development Group
6 | *
7 | * Portions Copyright (c) 1994, The Regents of the University of California
8 | *
9 | * Permission to use, copy, modify, and distribute this software and its documentation for any purpose,
10 | * without fee, and without a written agreement is hereby granted, provided that the above copyright notice
11 | * and this paragraph and the following two paragraphs appear in all copies.
12 | *
13 | * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT,
14 | * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
15 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY
16 | * OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 | *
18 | * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 | *
21 | * THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA
22 | * HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 | */
24 |
25 | #ifndef AG_AG_FUNC_H
26 | #define AG_AG_FUNC_H
27 |
28 | #define CREATE_CLAUSE_FUNCTION_NAME "_cypher_create_clause"
29 | #define SET_CLAUSE_FUNCTION_NAME "_cypher_set_clause"
30 | #define DELETE_CLAUSE_FUNCTION_NAME "_cypher_delete_clause"
31 | #define MERGE_CLAUSE_FUNCTION_NAME "_cypher_merge_clause"
32 |
33 | bool is_oid_ag_func(Oid func_oid, const char *func_name);
34 | Oid get_ag_func_oid(const char *func_name, const int nargs, ...);
35 | Oid get_pg_func_oid(const char *func_name, const int nargs, ...);
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/src/backend/utils/adt/cypher_funcs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #include "postgres.h"
21 |
22 | #include "fmgr.h"
23 |
24 | PG_FUNCTION_INFO_V1(cypher);
25 |
26 | Datum cypher(PG_FUNCTION_ARGS)
27 | {
28 | const char *s;
29 |
30 | s = PG_ARGISNULL(0) ? "NULL" : PG_GETARG_CSTRING(0);
31 |
32 | ereport(ERROR, (errmsg_internal("unhandled cypher(cstring) function call"),
33 | errdetail_internal("%s", s)));
34 |
35 | PG_RETURN_NULL();
36 | }
37 |
38 | PG_FUNCTION_INFO_V1(_cypher_create_clause);
39 |
40 | Datum _cypher_create_clause(PG_FUNCTION_ARGS)
41 | {
42 | PG_RETURN_NULL();
43 | }
44 |
45 | PG_FUNCTION_INFO_V1(_cypher_set_clause);
46 |
47 | Datum _cypher_set_clause(PG_FUNCTION_ARGS)
48 | {
49 | PG_RETURN_NULL();
50 | }
51 |
52 | PG_FUNCTION_INFO_V1(_cypher_delete_clause);
53 |
54 | Datum _cypher_delete_clause(PG_FUNCTION_ARGS)
55 | {
56 | PG_RETURN_NULL();
57 | }
58 |
59 | PG_FUNCTION_INFO_V1(_cypher_merge_clause);
60 |
61 | Datum _cypher_merge_clause(PG_FUNCTION_ARGS)
62 | {
63 | PG_RETURN_NULL();
64 | }
65 |
--------------------------------------------------------------------------------
/src/include/catalog/ag_graph.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_AG_GRAPH_H
21 | #define AG_AG_GRAPH_H
22 |
23 | #include "catalog/ag_catalog.h"
24 |
25 | #define Anum_ag_graph_oid 1
26 | #define Anum_ag_graph_name 2
27 | #define Anum_ag_graph_namespace 3
28 |
29 | #define Natts_ag_graph 3
30 |
31 | #define ag_graph_relation_id() ag_relation_id("ag_graph", "table")
32 | #define ag_graph_name_index_id() ag_relation_id("ag_graph_name_index", "index")
33 | #define ag_graph_namespace_index_id() \
34 | ag_relation_id("ag_graph_namespace_index", "index")
35 |
36 | void insert_graph(const Name graph_name, const Oid nsp_id);
37 | void delete_graph(const Name graph_name);
38 | void update_graph_name(const Name graph_name, const Name new_name);
39 |
40 | uint32 get_graph_oid(const char *graph_name);
41 | char *get_graph_namespace_name(const char *graph_name);
42 | bool graph_namespace_exists(Oid graph_oid);
43 |
44 | List *get_graphnames(void);
45 | void drop_graphs(List *graphnames);
46 |
47 | #define graph_exists(graph_name) OidIsValid(get_graph_oid(graph_name))
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/drivers/python/pyproject.toml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | # Unless required by applicable law or agreed to in writing,
10 | # software distributed under the License is distributed on an
11 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 | # KIND, either express or implied. See the License for the
13 | # specific language governing permissions and limitations
14 | # under the License.
15 |
16 | [build-system]
17 | requires = ["setuptools>=61.0", "wheel"]
18 | build-backend = "setuptools.build_meta"
19 |
20 | [project]
21 | name = "apache-age-python"
22 | version = "0.0.7"
23 | description = "Python driver support for Apache AGE"
24 | readme = "README.md"
25 | requires-python = ">=3.9"
26 | license = "Apache-2.0"
27 | keywords = ["Graph Database", "Apache AGE", "PostgreSQL"]
28 | authors = [
29 | {name = "Ikchan Kwon, Apache AGE", email = "dev-subscribe@age.apache.org"}
30 | ]
31 | classifiers = [
32 | "Programming Language :: Python :: 3.10",
33 | "Programming Language :: Python :: 3.11",
34 | "Programming Language :: Python :: 3.12",
35 | "Programming Language :: Python :: 3.13",
36 | "Programming Language :: Python :: 3.14",
37 | ]
38 | dependencies = [
39 | "psycopg",
40 | "antlr4-python3-runtime==4.11.1",
41 | ]
42 |
43 | [project.urls]
44 | Homepage = "https://github.com/apache/age/tree/master/drivers/python"
45 | Download = "https://github.com/apache/age/releases"
46 |
47 | [tool.setuptools]
48 | packages = ["age", "age.gen", "age.networkx"]
49 |
--------------------------------------------------------------------------------
/drivers/golang/parser/age_listener.go:
--------------------------------------------------------------------------------
1 | // Code generated from java-escape by ANTLR 4.11.1. DO NOT EDIT.
2 |
3 | package parser // Age
4 |
5 | import "github.com/antlr/antlr4/runtime/Go/antlr/v4"
6 |
7 | // AgeListener is a complete listener for a parse tree produced by AgeParser.
8 | type AgeListener interface {
9 | antlr.ParseTreeListener
10 |
11 | // EnterAgeout is called when entering the ageout production.
12 | EnterAgeout(c *AgeoutContext)
13 |
14 | // EnterVertex is called when entering the vertex production.
15 | EnterVertex(c *VertexContext)
16 |
17 | // EnterEdge is called when entering the edge production.
18 | EnterEdge(c *EdgeContext)
19 |
20 | // EnterPath is called when entering the path production.
21 | EnterPath(c *PathContext)
22 |
23 | // EnterValue is called when entering the value production.
24 | EnterValue(c *ValueContext)
25 |
26 | // EnterProperties is called when entering the properties production.
27 | EnterProperties(c *PropertiesContext)
28 |
29 | // EnterPair is called when entering the pair production.
30 | EnterPair(c *PairContext)
31 |
32 | // EnterArr is called when entering the arr production.
33 | EnterArr(c *ArrContext)
34 |
35 | // ExitAgeout is called when exiting the ageout production.
36 | ExitAgeout(c *AgeoutContext)
37 |
38 | // ExitVertex is called when exiting the vertex production.
39 | ExitVertex(c *VertexContext)
40 |
41 | // ExitEdge is called when exiting the edge production.
42 | ExitEdge(c *EdgeContext)
43 |
44 | // ExitPath is called when exiting the path production.
45 | ExitPath(c *PathContext)
46 |
47 | // ExitValue is called when exiting the value production.
48 | ExitValue(c *ValueContext)
49 |
50 | // ExitProperties is called when exiting the properties production.
51 | ExitProperties(c *PropertiesContext)
52 |
53 | // ExitPair is called when exiting the pair production.
54 | ExitPair(c *PairContext)
55 |
56 | // ExitArr is called when exiting the arr production.
57 | ExitArr(c *ArrContext)
58 | }
59 |
--------------------------------------------------------------------------------
/regress/sql/graphid.sql:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | LOAD 'age';
21 | SET search_path TO ag_catalog;
22 |
23 | -- basic comparisons
24 | SELECT '0'::graphid = '0'::graphid, '0'::graphid = '1'::graphid;
25 | SELECT '0'::graphid <> '0'::graphid, '0'::graphid <> '1'::graphid;
26 | SELECT '0'::graphid < '1'::graphid,
27 | '0'::graphid < '0'::graphid,
28 | '1'::graphid < '0'::graphid;
29 | SELECT '0'::graphid > '1'::graphid,
30 | '0'::graphid > '0'::graphid,
31 | '1'::graphid > '0'::graphid;
32 | SELECT '0'::graphid <= '1'::graphid,
33 | '0'::graphid <= '0'::graphid,
34 | '1'::graphid <= '0'::graphid;
35 | SELECT '0'::graphid >= '1'::graphid,
36 | '0'::graphid >= '0'::graphid,
37 | '1'::graphid >= '0'::graphid;
38 |
39 | -- b-tree index
40 | CREATE TABLE graphid_table (gid graphid);
41 | INSERT INTO graphid_table VALUES ('0'), ('1'), ('2');
42 | CREATE INDEX ON graphid_table (gid);
43 | SET enable_seqscan = OFF;
44 | EXPLAIN (COSTS FALSE) SELECT * FROM graphid_table WHERE gid = '1';
45 | EXPLAIN (COSTS FALSE) SELECT * FROM graphid_table WHERE gid > '0';
46 | SET enable_seqscan = ON;
47 | DROP TABLE graphid_table;
48 |
--------------------------------------------------------------------------------
/drivers/nodejs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "//": [
3 | "Licensed to the Apache Software Foundation (ASF) under one",
4 | "or more contributor license agreements. See the NOTICE file",
5 | "distributed with this work for additional information",
6 | "regarding copyright ownership. The ASF licenses this file",
7 | "to you under the Apache License, Version 2.0 (the",
8 | "\"License\"); you may not use this file except in compliance",
9 | "with the License. You may obtain a copy of the License at",
10 | "",
11 | "http://www.apache.org/licenses/LICENSE-2.0",
12 | "",
13 | "Unless required by applicable law or agreed to in writing,",
14 | "software distributed under the License is distributed on an",
15 | "\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY",
16 | "KIND, either express or implied. See the License for the",
17 | "specific language governing permissions and limitations",
18 | "under the License."
19 | ],
20 | "name": "pg-age",
21 | "version": "1.0.0-alpha",
22 | "main": "dist/index.js",
23 | "scripts": {
24 | "antlr4ts": "antlr4ts src/antlr4/Agtype.g4",
25 | "test": "jest --verbose ./test",
26 | "build": "rm -rf dist && tsc",
27 | "prepare": "npm run build"
28 | },
29 | "keywords": [],
30 | "author": "Alex Kwak ",
31 | "dependencies": {
32 | "antlr4ts": "^0.5.0-alpha.4",
33 | "pg": ">=6.0.0"
34 | },
35 | "devDependencies": {
36 | "@types/jest": "^26.0.20",
37 | "@types/pg": "^7.14.10",
38 | "@typescript-eslint/eslint-plugin": "^4.22.1",
39 | "@typescript-eslint/parser": "^4.22.1",
40 | "antlr4ts-cli": "^0.5.0-alpha.4",
41 | "eslint": "^7.25.0",
42 | "eslint-config-standard": "^16.0.2",
43 | "eslint-plugin-import": "^2.22.1",
44 | "eslint-plugin-jest": "^24.3.6",
45 | "eslint-plugin-node": "^11.1.0",
46 | "eslint-plugin-promise": "^4.3.1",
47 | "jest": "^26.6.3",
48 | "ts-jest": "^26.5.1",
49 | "typescript": "^4.1.5"
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/include/utils/load/ag_load_edges.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #include "access/heapam.h"
21 | #include "utils/load/age_load.h"
22 |
23 | #ifndef AG_LOAD_EDGES_H
24 | #define AG_LOAD_EDGES_H
25 |
26 | typedef struct {
27 | size_t row;
28 | char **header;
29 | size_t *header_len;
30 | size_t header_num;
31 | char **fields;
32 | size_t *fields_len;
33 | size_t alloc;
34 | size_t cur_field;
35 | int error;
36 | size_t header_row_length;
37 | size_t curr_row_length;
38 | char *graph_name;
39 | Oid graph_oid;
40 | char *label_name;
41 | int label_id;
42 | Oid label_seq_relid;
43 | char *start_vertex;
44 | char *end_vertex;
45 | bool load_as_agtype;
46 | batch_insert_state *batch_state;
47 | } csv_edge_reader;
48 |
49 |
50 | void edge_field_cb(void *field, size_t field_len, void *data);
51 | void edge_row_cb(int delim __attribute__((unused)), void *data);
52 |
53 | int create_edges_from_csv_file(char *file_path, char *graph_name, Oid graph_oid,
54 | char *label_name, int label_id,
55 | bool load_as_agtype);
56 |
57 | #endif /*AG_LOAD_EDGES_H */
58 |
59 |
--------------------------------------------------------------------------------
/src/include/utils/ag_cache.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_AG_CACHE_H
21 | #define AG_AG_CACHE_H
22 |
23 | /* graph_cache_data contains the same fields that ag_graph catalog table has */
24 | typedef struct graph_cache_data
25 | {
26 | Oid oid;
27 | NameData name;
28 | Oid namespace;
29 | } graph_cache_data;
30 |
31 | /* label_cache_data contains the same fields that ag_label catalog table has */
32 | typedef struct label_cache_data
33 | {
34 | NameData name;
35 | Oid graph;
36 | int32 id;
37 | char kind;
38 | Oid relation;
39 | NameData seq_name;
40 | } label_cache_data;
41 |
42 | /* callers of these functions must not modify the returned struct */
43 | graph_cache_data *search_graph_name_cache(const char *name);
44 | graph_cache_data *search_graph_namespace_cache(Oid namespace);
45 | label_cache_data *search_label_oid_cache(Oid oid);
46 | label_cache_data *search_label_name_graph_cache(const char *name, Oid graph);
47 | label_cache_data *search_label_graph_oid_cache(Oid graph, int32 id);
48 | label_cache_data *search_label_relation_cache(Oid relation);
49 | label_cache_data *search_label_seq_name_graph_cache(const char *name, Oid graph);
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/sql/agtype_string.sql:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | --
21 | -- agtype - string matching (`STARTS WITH`, `ENDS WITH`, `CONTAINS`, & =~)
22 | --
23 |
24 | CREATE FUNCTION ag_catalog.agtype_string_match_starts_with(agtype, agtype)
25 | RETURNS agtype
26 | LANGUAGE c
27 | STABLE
28 | RETURNS NULL ON NULL INPUT
29 | PARALLEL SAFE
30 | AS 'MODULE_PATHNAME';
31 |
32 | CREATE FUNCTION ag_catalog.agtype_string_match_ends_with(agtype, agtype)
33 | RETURNS agtype
34 | LANGUAGE c
35 | STABLE
36 | RETURNS NULL ON NULL INPUT
37 | PARALLEL SAFE
38 | AS 'MODULE_PATHNAME';
39 |
40 | CREATE FUNCTION ag_catalog.agtype_string_match_contains(agtype, agtype)
41 | RETURNS agtype
42 | LANGUAGE c
43 | IMMUTABLE
44 | RETURNS NULL ON NULL INPUT
45 | PARALLEL SAFE
46 | AS 'MODULE_PATHNAME';
47 |
48 | CREATE FUNCTION ag_catalog.age_eq_tilde(agtype, agtype)
49 | RETURNS agtype
50 | LANGUAGE c
51 | STABLE
52 | PARALLEL SAFE
53 | AS 'MODULE_PATHNAME';
54 |
55 | CREATE OPERATOR =~ (
56 | LEFTARG = agtype,
57 | RIGHTARG = agtype,
58 | FUNCTION = ag_catalog.age_eq_tilde
59 | );
60 |
61 | CREATE FUNCTION ag_catalog.age_is_valid_label_name(agtype)
62 | RETURNS boolean
63 | LANGUAGE c
64 | IMMUTABLE
65 | PARALLEL SAFE
66 | AS 'MODULE_PATHNAME';
67 |
--------------------------------------------------------------------------------
/age--1.6.0--y.y.y.sql:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | --* This is a TEMPLATE for upgrading from the previous version of Apache AGE
21 | --* Please adjust the below ALTER EXTENSION to reflect the -- correct version it
22 | --* is upgrading to.
23 |
24 | -- This will only work within a major version of PostgreSQL, not across
25 | -- major versions.
26 |
27 | -- complain if script is sourced in psql, rather than via CREATE EXTENSION
28 | \echo Use "ALTER EXTENSION age UPDATE TO '1.X.0'" to load this file. \quit
29 |
30 | --* Please add all additions, deletions, and modifications to the end of this
31 | --* file. We need to keep the order of these changes.
32 | --* REMOVE ALL LINES ABOVE, and this one, that start with --*
33 |
34 | CREATE FUNCTION ag_catalog._ag_enforce_edge_uniqueness2(graphid, graphid)
35 | RETURNS bool
36 | LANGUAGE c
37 | STABLE
38 | PARALLEL SAFE
39 | as 'MODULE_PATHNAME';
40 |
41 | CREATE FUNCTION ag_catalog._ag_enforce_edge_uniqueness3(graphid, graphid, graphid)
42 | RETURNS bool
43 | LANGUAGE c
44 | STABLE
45 | PARALLEL SAFE
46 | as 'MODULE_PATHNAME';
47 |
48 | CREATE FUNCTION ag_catalog._ag_enforce_edge_uniqueness4(graphid, graphid, graphid, graphid)
49 | RETURNS bool
50 | LANGUAGE c
51 | STABLE
52 | PARALLEL SAFE
53 | as 'MODULE_PATHNAME';
54 |
--------------------------------------------------------------------------------
/src/include/utils/load/ag_load_labels.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 |
21 | #ifndef AG_LOAD_LABELS_H
22 | #define AG_LOAD_LABELS_H
23 |
24 | #include "access/heapam.h"
25 | #include "utils/load/age_load.h"
26 |
27 | struct counts {
28 | long unsigned fields;
29 | long unsigned allvalues;
30 | long unsigned rows;
31 | };
32 |
33 | typedef struct {
34 | size_t row;
35 | char **header;
36 | size_t *header_len;
37 | size_t header_num;
38 | char **fields;
39 | size_t *fields_len;
40 | size_t alloc;
41 | size_t cur_field;
42 | int error;
43 | size_t header_row_length;
44 | size_t curr_row_length;
45 | char *graph_name;
46 | Oid graph_oid;
47 | char *label_name;
48 | int label_id;
49 | Oid label_seq_relid;
50 | bool id_field_exists;
51 | bool load_as_agtype;
52 | int curr_seq_num;
53 | batch_insert_state *batch_state;
54 | } csv_vertex_reader;
55 |
56 |
57 | void vertex_field_cb(void *field, size_t field_len, void *data);
58 | void vertex_row_cb(int delim __attribute__((unused)), void *data);
59 |
60 | int create_labels_from_csv_file(char *file_path, char *graph_name, Oid graph_oid,
61 | char *label_name, int label_id,
62 | bool id_field_exists, bool load_as_agtype);
63 |
64 | #endif /* AG_LOAD_LABELS_H */
65 |
--------------------------------------------------------------------------------
/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | # Build stage: Install necessary development tools for compilation and installation
20 | FROM postgres:17 AS build
21 |
22 | RUN apt-get update \
23 | && apt-get install -y --no-install-recommends --no-install-suggests \
24 | bison \
25 | build-essential \
26 | flex \
27 | postgresql-server-dev-17
28 |
29 | COPY . /age
30 |
31 | WORKDIR /age
32 |
33 | RUN make && make install
34 |
35 |
36 | # Final stage: Create a final image by copying the files created in the build stage
37 | FROM postgres:17
38 |
39 | RUN apt-get update \
40 | && apt-get install -y --no-install-recommends --no-install-suggests \
41 | locales
42 |
43 | RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
44 | && locale-gen \
45 | && update-locale LANG=en_US.UTF-8
46 |
47 | ENV LANG=en_US.UTF-8
48 | ENV LC_COLLATE=en_US.UTF-8
49 | ENV LC_CTYPE=en_US.UTF-8
50 |
51 | COPY --from=build /usr/lib/postgresql/17/lib/age.so /usr/lib/postgresql/17/lib/
52 | COPY --from=build /usr/share/postgresql/17/extension/age--1.6.0.sql /usr/share/postgresql/17/extension/
53 | COPY --from=build /usr/share/postgresql/17/extension/age.control /usr/share/postgresql/17/extension/
54 | COPY docker/docker-entrypoint-initdb.d/00-create-extension-age.sql /docker-entrypoint-initdb.d/00-create-extension-age.sql
55 |
56 | CMD ["postgres", "-c", "shared_preload_libraries=age"]
57 |
--------------------------------------------------------------------------------
/src/include/nodes/cypher_readfuncs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_CYPHER_READFUNCS_H
21 | #define AG_CYPHER_READFUNCS_H
22 |
23 | #include "nodes/extensible.h"
24 |
25 | /*
26 | * Deserialization functions for AGE's ExtensibleNodes. We assign
27 | * each node to its deserialization function in the DEFINE_NODE_METHODS
28 | * and DEFINE_NODE_METHODS_EXTENDED macros in ag_nodes.c.
29 |
30 | *
31 | * All functions are dependent on the pg_strtok function. We do not
32 | * setup pg_strtok. That is for the caller to do. By default that
33 | * is the responsibility of Postgres' nodeRead function. We assume
34 | * that was setup correctly.
35 | */
36 |
37 | void read_ag_node(ExtensibleNode *node);
38 |
39 | /* create data structures */
40 | void read_cypher_create_target_nodes(struct ExtensibleNode *node);
41 | void read_cypher_create_path(struct ExtensibleNode *node);
42 | void read_cypher_target_node(struct ExtensibleNode *node);
43 |
44 | /* set/remove data structures */
45 | void read_cypher_update_information(struct ExtensibleNode *node);
46 | void read_cypher_update_item(struct ExtensibleNode *node);
47 |
48 | /* delete data structures */
49 | void read_cypher_delete_information(struct ExtensibleNode *node);
50 | void read_cypher_delete_item(struct ExtensibleNode *node);
51 |
52 | void read_cypher_merge_information(struct ExtensibleNode *node);
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/drivers/nodejs/src/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | import { Client } from 'pg'
21 | import pgTypes from 'pg-types'
22 | import { CharStreams, CommonTokenStream } from 'antlr4ts'
23 | import { AgtypeLexer } from './antlr4/AgtypeLexer'
24 | import { AgtypeParser } from './antlr4/AgtypeParser'
25 | import CustomAgTypeListener from './antlr4/CustomAgTypeListener'
26 | import { ParseTreeWalker } from 'antlr4ts/tree'
27 |
28 | function AGTypeParse (input: string) {
29 | const chars = CharStreams.fromString(input)
30 | const lexer = new AgtypeLexer(chars)
31 | const tokens = new CommonTokenStream(lexer)
32 | const parser = new AgtypeParser(tokens)
33 | const tree = parser.agType()
34 | const printer = new CustomAgTypeListener()
35 | ParseTreeWalker.DEFAULT.walk(printer, tree)
36 | return printer.getResult()
37 | }
38 |
39 | async function setAGETypes (client: Client, types: typeof pgTypes) {
40 | await client.query(`
41 | CREATE EXTENSION IF NOT EXISTS age;
42 | LOAD 'age';
43 | SET search_path = ag_catalog, "$user", public;
44 | `)
45 |
46 | const oidResults = await client.query(`
47 | select typelem
48 | from pg_type
49 | where typname = '_agtype';`)
50 |
51 | if (oidResults.rows.length < 1) { throw new Error() }
52 |
53 | types.setTypeParser(oidResults.rows[0].typelem, AGTypeParse)
54 | }
55 |
56 | export { setAGETypes, AGTypeParse }
57 |
--------------------------------------------------------------------------------
/drivers/python/age/exceptions.py:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | # Unless required by applicable law or agreed to in writing,
10 | # software distributed under the License is distributed on an
11 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 | # KIND, either express or implied. See the License for the
13 | # specific language governing permissions and limitations
14 | # under the License.
15 |
16 | from psycopg.errors import *
17 |
18 | class AgeNotSet(Exception):
19 | def __init__(self, name):
20 | self.name = name
21 |
22 | def __repr__(self) :
23 | return 'AGE extension is not set.'
24 |
25 | class GraphNotFound(Exception):
26 | def __init__(self, name):
27 | self.name = name
28 |
29 | def __repr__(self) :
30 | return 'Graph[' + self.name + '] does not exist.'
31 |
32 |
33 | class GraphAlreadyExists(Exception):
34 | def __init__(self, name):
35 | self.name = name
36 |
37 | def __repr__(self) :
38 | return 'Graph[' + self.name + '] already exists.'
39 |
40 |
41 | class GraphNotSet(Exception):
42 | def __repr__(self) :
43 | return 'Graph name is not set.'
44 |
45 |
46 | class NoConnection(Exception):
47 | def __repr__(self) :
48 | return 'No Connection'
49 |
50 | class NoCursor(Exception):
51 | def __repr__(self) :
52 | return 'No Cursor'
53 |
54 | class SqlExecutionError(Exception):
55 | def __init__(self, msg, cause):
56 | self.msg = msg
57 | self.cause = cause
58 | super().__init__(msg, cause)
59 |
60 | def __repr__(self) :
61 | return 'SqlExecution [' + self.msg + ']'
62 |
63 | class AGTypeError(Exception):
64 | def __init__(self, msg, cause):
65 | self.msg = msg
66 | self.cause = cause
67 | super().__init__(msg, cause)
68 |
--------------------------------------------------------------------------------
/sql/age_query.sql:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | --
21 | -- functions for updating clauses
22 | --
23 |
24 | -- This function is defined as a VOLATILE function to prevent the optimizer
25 | -- from pulling up Query's for CREATE clauses.
26 | CREATE FUNCTION ag_catalog._cypher_create_clause(internal)
27 | RETURNS void
28 | LANGUAGE c
29 | AS 'MODULE_PATHNAME';
30 |
31 | CREATE FUNCTION ag_catalog._cypher_set_clause(internal)
32 | RETURNS void
33 | LANGUAGE c
34 | AS 'MODULE_PATHNAME';
35 |
36 | CREATE FUNCTION ag_catalog._cypher_delete_clause(internal)
37 | RETURNS void
38 | LANGUAGE c
39 | AS 'MODULE_PATHNAME';
40 |
41 | CREATE FUNCTION ag_catalog._cypher_merge_clause(internal)
42 | RETURNS void
43 | LANGUAGE c
44 | AS 'MODULE_PATHNAME';
45 |
46 | --
47 | -- query functions
48 | --
49 | CREATE FUNCTION ag_catalog.cypher(graph_name name = NULL,
50 | query_string cstring = NULL,
51 | params agtype = NULL)
52 | RETURNS SETOF record
53 | LANGUAGE c
54 | AS 'MODULE_PATHNAME';
55 |
56 | CREATE FUNCTION ag_catalog.get_cypher_keywords(OUT word text, OUT catcode "char",
57 | OUT catdesc text)
58 | RETURNS SETOF record
59 | LANGUAGE c
60 | STABLE
61 | RETURNS NULL ON NULL INPUT
62 | PARALLEL SAFE
63 | COST 10
64 | ROWS 60
65 | AS 'MODULE_PATHNAME';
66 | --
67 | -- End
68 | --
69 |
--------------------------------------------------------------------------------
/tools/git/commit-msg:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | #
20 | # This script checks the commit log message.
21 |
22 | if [ ! -s "$1" ] || ! grep -v '^#' "$1" | grep -q '[^[:space:]]'; then
23 | echo "Aborting commit due to empty commit message." >&2
24 | exit 1
25 | fi
26 |
27 | # Separate subject from body with a blank line
28 | line2=$(sed '2q;d' "$1")
29 | if [ -n "$line2" ] && echo "$line2" | grep -qv '^#'; then
30 | echo "FAIL: put a blank line to separate subject from body" >&2
31 | head -n 2 "$1" >&2
32 | exit 1
33 | fi
34 |
35 | # Limit the subject line to 50 characters
36 | subject=$(head -n 1 "$1")
37 | subject_len=$(printf "$subject" | wc -m)
38 | if [ $subject_len -gt 72 ]; then
39 | echo "FAIL: subject lines cannot be longer than 72 characters" >&2
40 | echo "$subject" >&2
41 | exit 1
42 | elif [ $subject_len -gt 50 ]; then
43 | echo "Subject lines less than or equal to 50 characters are preferred."
44 | fi
45 |
46 | # Capitalize the subject line
47 | if echo "$subject" | grep -qv '^[[:upper:]]'; then
48 | echo "FAIL: begin the subject line with a capital letter" >&2
49 | echo "$subject" >&2
50 | exit 1
51 | fi
52 |
53 | # Do not end the subject line with a period
54 | if echo "$subject" | grep -q '\.$'; then
55 | echo "FAIL: trailing punctuation is unnecessary in subject lines" >&2
56 | echo "$subject" >&2
57 | exit 1
58 | fi
59 |
60 | # Wrap the body at 72 characters
61 | lines=$(grep -nE '.{73,}' "$1")
62 | if [ -n "$lines" ]; then
63 | echo "FAIL: wrap the body at 72 characters" >&2
64 | echo "$lines" >&2
65 | exit 1
66 | fi
67 |
--------------------------------------------------------------------------------
/src/include/commands/label_commands.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_LABEL_COMMANDS_H
21 | #define AG_LABEL_COMMANDS_H
22 |
23 | #define LABEL_TYPE_VERTEX 'v'
24 | #define LABEL_TYPE_EDGE 'e'
25 |
26 | #define AG_DEFAULT_LABEL_EDGE "_ag_label_edge"
27 | #define AG_DEFAULT_LABEL_VERTEX "_ag_label_vertex"
28 |
29 | #define AG_VERTEX_COLNAME_ID "id"
30 | #define AG_VERTEX_COLNAME_PROPERTIES "properties"
31 |
32 | #define AG_ACCESS_FUNCTION_ID "age_id"
33 |
34 | #define AG_VERTEX_ACCESS_FUNCTION_ID "age_id"
35 | #define AG_VERTEX_ACCESS_FUNCTION_PROPERTIES "age_properties"
36 |
37 | #define AG_EDGE_COLNAME_ID "id"
38 | #define AG_EDGE_COLNAME_START_ID "start_id"
39 | #define AG_EDGE_COLNAME_END_ID "end_id"
40 | #define AG_EDGE_COLNAME_PROPERTIES "properties"
41 |
42 | #define AG_EDGE_ACCESS_FUNCTION_ID "age_id"
43 | #define AG_EDGE_ACCESS_FUNCTION_START_ID "age_start_id"
44 | #define AG_EDGE_ACCESS_FUNCTION_END_ID "age_end_id"
45 | #define AG_EDGE_ACCESS_FUNCTION_PROPERTIES "age_properties"
46 |
47 | #define IS_DEFAULT_LABEL_EDGE(str) \
48 | (str != NULL && strcmp(AG_DEFAULT_LABEL_EDGE, str) == 0)
49 | #define IS_DEFAULT_LABEL_VERTEX(str) \
50 | (str != NULL && strcmp(AG_DEFAULT_LABEL_VERTEX, str) == 0)
51 |
52 | #define IS_AG_DEFAULT_LABEL(x) \
53 | (IS_DEFAULT_LABEL_EDGE(x) || IS_DEFAULT_LABEL_VERTEX(x))
54 |
55 | void create_label(char *graph_name, char *label_name, char label_type,
56 | List *parents);
57 |
58 | Datum create_vlabel(PG_FUNCTION_ARGS);
59 |
60 | Datum create_elabel(PG_FUNCTION_ARGS);
61 |
62 | #endif
63 |
--------------------------------------------------------------------------------
/META.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ApacheAGE",
3 | "abstract": "Apache AGE is a PostgreSQL Extension that provides graph database functionality",
4 | "description": "Apache AGE is a PostgreSQL Extension that provides graph database functionality. AGE is an acronym for A Graph Extension, and is inspired by Bitnine's fork of PostgreSQL 10, AgensGraph, which is a multi-model database. The goal of the project is to create single storage that can handle both relational and graph model data so that users can use standard ANSI SQL along with openCypher, the Graph query language. A graph consists of a set of vertices (also called nodes) and edges, where each individual vertex and edge possesses a map of properties. A vertex is the basic object of a graph, that can exist independently of everything else in the graph. An edge creates a directed connection between two vertices. A graph database is simply composed of vertices and edges. This type of database is useful when the meaning is in the relationships between the data. Relational databases can easily handle direct relationships, but indirect relationships are more difficult to deal with in relational databases. A graph database stores relationship information as a first-class entity. Apache AGE gives you the best of both worlds, simultaneously.",
5 | "version": "1.3.0",
6 | "maintainer": [
7 | "users@age.apache.org"
8 | ],
9 | "license": "apache_2_0",
10 | "provides": {
11 | "ApacheAGE": {
12 | "abstract": "Apache AGE is a PostgreSQL Extension that provides graph database functionality",
13 | "file": "age--1.3.0.sql",
14 | "docfile": "README.md",
15 | "version": "1.3.0"
16 | }
17 | },
18 | "prereqs": {
19 | "runtime": {
20 | "requires": {
21 | "PostgreSQL": "14.0.0"
22 | }
23 | }
24 | },
25 | "resources": {
26 | "homepage": "https://github.com/apache/age/tree/master",
27 | "bugtracker": {
28 | "web": "https://github.com/apache/age/issues"
29 | },
30 | "repository": {
31 | "url": "https://github.com/apache/age.git",
32 | "web": "https://github.com/apache/age",
33 | "type": "git"
34 | }
35 | },
36 | "generated_by": "users@age.apache.org",
37 | "meta-spec": {
38 | "version": "1.0.0",
39 | "url": "http://pgxn.org/meta/spec.txt"
40 | },
41 | "tags": [
42 | "graphdb",
43 | "graph-database"
44 | ]
45 | }
46 |
--------------------------------------------------------------------------------
/src/include/parser/cypher_kwlist.h:
--------------------------------------------------------------------------------
1 | PG_KEYWORD("all", ALL, RESERVED_KEYWORD)
2 | PG_KEYWORD("analyze", ANALYZE, RESERVED_KEYWORD)
3 | PG_KEYWORD("and", AND, RESERVED_KEYWORD)
4 | PG_KEYWORD("as", AS, RESERVED_KEYWORD)
5 | PG_KEYWORD("asc", ASC, RESERVED_KEYWORD)
6 | PG_KEYWORD("ascending", ASCENDING, RESERVED_KEYWORD)
7 | PG_KEYWORD("by", BY, RESERVED_KEYWORD)
8 | PG_KEYWORD("call", CALL, RESERVED_KEYWORD)
9 | PG_KEYWORD("case", CASE, RESERVED_KEYWORD)
10 | PG_KEYWORD("coalesce", COALESCE, RESERVED_KEYWORD)
11 | PG_KEYWORD("contains", CONTAINS, RESERVED_KEYWORD)
12 | PG_KEYWORD("count", COUNT, RESERVED_KEYWORD)
13 | PG_KEYWORD("create", CREATE, RESERVED_KEYWORD)
14 | PG_KEYWORD("delete", DELETE, RESERVED_KEYWORD)
15 | PG_KEYWORD("desc", DESC, RESERVED_KEYWORD)
16 | PG_KEYWORD("descending", DESCENDING, RESERVED_KEYWORD)
17 | PG_KEYWORD("detach", DETACH, RESERVED_KEYWORD)
18 | PG_KEYWORD("distinct", DISTINCT, RESERVED_KEYWORD)
19 | PG_KEYWORD("else", ELSE, RESERVED_KEYWORD)
20 | PG_KEYWORD("end", END_P, RESERVED_KEYWORD)
21 | PG_KEYWORD("ends", ENDS, RESERVED_KEYWORD)
22 | PG_KEYWORD("exists", EXISTS, RESERVED_KEYWORD)
23 | PG_KEYWORD("explain", EXPLAIN, RESERVED_KEYWORD)
24 | PG_KEYWORD("false", FALSE_P, RESERVED_KEYWORD)
25 | PG_KEYWORD("in", IN, RESERVED_KEYWORD)
26 | PG_KEYWORD("is", IS, RESERVED_KEYWORD)
27 | PG_KEYWORD("limit", LIMIT, RESERVED_KEYWORD)
28 | PG_KEYWORD("match", MATCH, RESERVED_KEYWORD)
29 | PG_KEYWORD("merge", MERGE, RESERVED_KEYWORD)
30 | PG_KEYWORD("not", NOT, RESERVED_KEYWORD)
31 | PG_KEYWORD("null", NULL_P, RESERVED_KEYWORD)
32 | PG_KEYWORD("operator", OPERATOR, RESERVED_KEYWORD)
33 | PG_KEYWORD("optional", OPTIONAL, RESERVED_KEYWORD)
34 | PG_KEYWORD("or", OR, RESERVED_KEYWORD)
35 | PG_KEYWORD("order", ORDER, RESERVED_KEYWORD)
36 | PG_KEYWORD("remove", REMOVE, RESERVED_KEYWORD)
37 | PG_KEYWORD("return", RETURN, RESERVED_KEYWORD)
38 | PG_KEYWORD("set", SET, RESERVED_KEYWORD)
39 | PG_KEYWORD("skip", SKIP, RESERVED_KEYWORD)
40 | PG_KEYWORD("starts", STARTS, RESERVED_KEYWORD)
41 | PG_KEYWORD("then", THEN, RESERVED_KEYWORD)
42 | PG_KEYWORD("true", TRUE_P, RESERVED_KEYWORD)
43 | PG_KEYWORD("union", UNION, RESERVED_KEYWORD)
44 | PG_KEYWORD("unwind", UNWIND, RESERVED_KEYWORD)
45 | PG_KEYWORD("verbose", VERBOSE, RESERVED_KEYWORD)
46 | PG_KEYWORD("when", WHEN, RESERVED_KEYWORD)
47 | PG_KEYWORD("where", WHERE, RESERVED_KEYWORD)
48 | PG_KEYWORD("with", WITH, RESERVED_KEYWORD)
49 | PG_KEYWORD("xor", XOR, RESERVED_KEYWORD)
50 | PG_KEYWORD("yield", YIELD, RESERVED_KEYWORD)
--------------------------------------------------------------------------------
/src/include/utils/graphid.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_GRAPHID_H
21 | #define AG_GRAPHID_H
22 |
23 | #include "utils/fmgroids.h"
24 | #include "utils/syscache.h"
25 |
26 | #include "catalog/ag_namespace.h"
27 | #include "catalog/pg_type.h"
28 |
29 | typedef int64 graphid;
30 |
31 | #define F_GRAPHIDEQ F_INT8EQ
32 |
33 | #define LABEL_ID_MIN 1
34 | #define LABEL_ID_MAX PG_UINT16_MAX
35 | #define INVALID_LABEL_ID 0
36 |
37 | #define label_id_is_valid(id) (id >= LABEL_ID_MIN && id <= LABEL_ID_MAX)
38 |
39 | #define ENTRY_ID_MIN INT64CONST(0)
40 | /* 0x0000ffffffffffff */
41 | #define ENTRY_ID_MAX INT64CONST(281474976710655)
42 | #define INVALID_ENTRY_ID INT64CONST(0)
43 |
44 | #define entry_id_is_valid(id) (id >= ENTRY_ID_MIN && id <= ENTRY_ID_MAX)
45 |
46 | #define ENTRY_ID_BITS (32 + 16)
47 | #define ENTRY_ID_MASK INT64CONST(0x0000ffffffffffff)
48 |
49 | #define DATUM_GET_GRAPHID(d) DatumGetInt64(d)
50 | #define GRAPHID_GET_DATUM(x) Int64GetDatum(x)
51 |
52 | #define AG_GETARG_GRAPHID(a) DATUM_GET_GRAPHID(PG_GETARG_DATUM(a))
53 | #define AG_RETURN_GRAPHID(x) return GRAPHID_GET_DATUM(x)
54 |
55 | /* Oid accessors for GRAPHID */
56 | #define GRAPHIDOID get_GRAPHIDOID()
57 | #define GRAPHIDARRAYOID get_GRAPHIDARRAYOID()
58 |
59 | #define GET_LABEL_ID(id) \
60 | (((uint64)id) >> ENTRY_ID_BITS)
61 |
62 | graphid make_graphid(const int32 label_id, const int64 entry_id);
63 | int32 get_graphid_label_id(const graphid gid);
64 | int64 get_graphid_entry_id(const graphid gid);
65 | Oid get_GRAPHIDOID(void);
66 | Oid get_GRAPHIDARRAYOID(void);
67 | void clear_global_Oids_GRAPHID(void);
68 |
69 | #endif
70 |
--------------------------------------------------------------------------------
/regress/sql/drop.sql:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | LOAD 'age';
21 | SET search_path TO ag_catalog;
22 |
23 | SELECT create_graph('drop');
24 |
25 | DROP EXTENSION age;
26 |
27 | SELECT nspname FROM pg_catalog.pg_namespace WHERE nspname = 'drop';
28 |
29 | SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname = 'ag_catalog';
30 |
31 | -- Recreate the extension and validate we can recreate a graph
32 | CREATE EXTENSION age;
33 |
34 | SELECT create_graph('drop');
35 |
36 | -- Create a schema that uses the agtype, so we can't just drop age.
37 | CREATE SCHEMA other_schema;
38 |
39 | CREATE TABLE other_schema.tbl (id agtype);
40 |
41 | -- Should Fail because agtype can't be dropped
42 | DROP EXTENSION age;
43 |
44 | -- Check the graph still exist, because the DROP command failed
45 | SELECT nspname FROM pg_catalog.pg_namespace WHERE nspname = 'drop';
46 |
47 | -- Should succeed, delete the 'drop' schema and leave 'other_schema'
48 | DROP EXTENSION age CASCADE;
49 |
50 | -- 'other_schema' should exist, 'drop' should be deleted
51 | SELECT nspname FROM pg_catalog.pg_namespace WHERE nspname IN ('other_schema', 'drop');
52 |
53 | -- issue 1305
54 | CREATE EXTENSION age;
55 | LOAD 'age';
56 | SET search_path TO ag_catalog;
57 | SELECT create_graph('issue_1305');
58 | SELECT create_vlabel('issue_1305', 'n');
59 | SELECT create_elabel('issue_1305', 'r');
60 | SELECT drop_label('issue_1305', 'r', false);
61 | SELECT drop_label('issue_1305', 'r');
62 | SELECT drop_label('issue_1305', 'n', false);
63 | SELECT drop_label('issue_1305', 'n');
64 | SELECT * FROM drop_graph('issue_1305', true);
65 |
66 | -- END
67 | DROP EXTENSION age CASCADE;
68 |
--------------------------------------------------------------------------------
/src/include/nodes/cypher_copyfuncs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #ifndef AG_CYPHER_COPYFUNCS_H
21 | #define AG_CYPHER_COPYFUNCS_H
22 |
23 | /*
24 | * Functions that let AGE's ExtensibleNodes be compatible with
25 | * Postgres' copyObject. We assign each node to its copy function
26 | * in the DEFINE_NODE_METHODS and DEFINE_NODE_METHODS_EXTENDED
27 | * macros in ag_nodes.c
28 | */
29 |
30 | void copy_ag_node(ExtensibleNode *newnode, const ExtensibleNode *oldnode);
31 |
32 | /* create data structures */
33 | void copy_cypher_create_target_nodes(ExtensibleNode *newnode,
34 | const ExtensibleNode *from);
35 | void copy_cypher_create_path(ExtensibleNode *newnode,
36 | const ExtensibleNode *from);
37 | void copy_cypher_target_node(ExtensibleNode *newnode,
38 | const ExtensibleNode *from);
39 |
40 | /* set/remove data structures */
41 | void copy_cypher_update_information(ExtensibleNode *newnode,
42 | const ExtensibleNode *from);
43 | void copy_cypher_update_item(ExtensibleNode *newnode,
44 | const ExtensibleNode *from);
45 |
46 | /* delete data structures */
47 | void copy_cypher_delete_information(ExtensibleNode *newnode,
48 | const ExtensibleNode *from);
49 | void copy_cypher_delete_item(ExtensibleNode *newnode,
50 | const ExtensibleNode *from);
51 |
52 | /* merge data structure */
53 | void copy_cypher_merge_information(ExtensibleNode *newnode,
54 | const ExtensibleNode *from);
55 | #endif
56 |
--------------------------------------------------------------------------------
/.asf.yaml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 |
19 | notifications:
20 | commits: commits@age.apache.org
21 | pullrequests: commits@age.apache.org
22 | discussions: dev@age.apache.org
23 |
24 | github:
25 | description: "Graph database optimized for fast analysis and real-time data processing.
26 | It is provided as an extension to PostgreSQL."
27 | homepage: https://age.apache.org
28 | labels:
29 | - postgresql
30 | - graph-database
31 | - analytics
32 | - postgresql-extension
33 | - graphdb
34 | - multi-model-dbms
35 | - agensgraph
36 | - age-database
37 | features:
38 | wiki: true
39 | issues: true
40 | projects: true
41 | discussions: true
42 |
43 | enabled_merge_buttons:
44 | squash: true
45 | merge: false
46 | rebase: true
47 |
48 | protected_branches:
49 | master:
50 | required_pull_request_reviews:
51 | required_approving_review_count: 1
52 |
53 | PG17:
54 | required_pull_request_reviews:
55 | required_approving_review_count: 1
56 |
57 | PG16:
58 | required_pull_request_reviews:
59 | required_approving_review_count: 1
60 |
61 | PG15:
62 | required_pull_request_reviews:
63 | required_approving_review_count: 1
64 |
65 | PG14:
66 | required_pull_request_reviews:
67 | required_approving_review_count: 1
68 |
69 | PG13:
70 | required_pull_request_reviews:
71 | required_approving_review_count: 1
72 |
73 | PG12:
74 | required_pull_request_reviews:
75 | required_approving_review_count: 1
76 |
77 | PG11:
78 | required_pull_request_reviews:
79 | required_approving_review_count: 1
80 |
--------------------------------------------------------------------------------
/drivers/Agtype.g4:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | grammar Agtype;
21 |
22 | agType
23 | : agValue EOF
24 | ;
25 |
26 | agValue
27 | : value typeAnnotation?
28 | ;
29 |
30 | value
31 | : STRING #StringValue
32 | | INTEGER #IntegerValue
33 | | floatLiteral #FloatValue
34 | | 'true' #TrueBoolean
35 | | 'false' #FalseBoolean
36 | | 'null' #NullValue
37 | | obj #ObjectValue
38 | | array #ArrayValue
39 | ;
40 |
41 | obj
42 | : '{' pair (',' pair)* '}'
43 | | '{' '}'
44 | ;
45 |
46 | pair
47 | : STRING ':' agValue
48 | ;
49 |
50 | array
51 | : '[' agValue (',' agValue)* ']'
52 | | '[' ']'
53 | ;
54 |
55 | typeAnnotation
56 | : '::' IDENT
57 | ;
58 |
59 | IDENT
60 | : [A-Z_a-z][$0-9A-Z_a-z]*
61 | ;
62 |
63 | STRING
64 | : '"' (ESC | SAFECODEPOINT)* '"'
65 | ;
66 |
67 | fragment ESC
68 | : '\\' (["\\/bfnrt] | UNICODE)
69 | ;
70 |
71 | fragment UNICODE
72 | : 'u' HEX HEX HEX HEX
73 | ;
74 |
75 | fragment HEX
76 | : [0-9a-fA-F]
77 | ;
78 |
79 | fragment SAFECODEPOINT
80 | : ~ ["\\\u0000-\u001F]
81 | ;
82 |
83 | INTEGER
84 | : '-'? INT
85 | ;
86 |
87 | fragment INT
88 | : '0' | [1-9] [0-9]*
89 | ;
90 |
91 | floatLiteral
92 | : RegularFloat
93 | | ExponentFloat
94 | | '-'? 'Infinity'
95 | | 'NaN'
96 | ;
97 |
98 | RegularFloat
99 | : '-'? INT DECIMAL
100 | ;
101 |
102 | ExponentFloat
103 | : '-'? INT DECIMAL? SCIENTIFIC
104 | ;
105 |
106 | fragment DECIMAL
107 | : '.' [0-9]+
108 | ;
109 |
110 | fragment SCIENTIFIC
111 | : [Ee][+-]? [0-9]+
112 | ;
113 |
114 | WS
115 | : [ \t\n\r] + -> skip
116 | ;
117 |
--------------------------------------------------------------------------------
/drivers/golang/README.md:
--------------------------------------------------------------------------------
1 | # age AGType parser and driver support for Golang
2 |
3 | AGType parser and driver support for [Apache AGE](https://age.apache.org/), graph extension for PostgreSQL.
4 |
5 | ### Features
6 | * Unmarshal AGE result data(AGType) to Vertex, Edge, Path
7 | * Cypher query support for 3rd. Party sql driver (enables to use cypher queries directly)
8 |
9 | ### Prerequisites (Required)
10 | * Java 11, or greater, installed.
11 | * Go 1.18, or greater, installed.
12 | * This module runs on the golang standard api [database/sql](https://golang.org/pkg/database/sql/) and [antlr4-python3](https://github.com/antlr/antlr4/tree/master/runtime/Go/antlr)
13 | * ANTLR 4.11.1, or greater, installed.
14 |
15 | ### Installation (From source)
16 | Run (Windows): install.bat
17 | Run (Linux & OSX):
18 | ```
19 | cd age/drivers/golang
20 | ./install.sh
21 | ```
22 |
23 | ### Go get
24 | ```
25 | go get github.com/apache/age/drivers/golang
26 | ```
27 | ### gomod
28 | ```
29 | require github.com/apache/age/drivers/golang {version}
30 | ```
31 |
32 | Check [latest version](https://github.com/apache/age/releases)
33 |
34 | ### For more information about [Apache AGE](https://age.apache.org/)
35 | * Apache Age : https://age.apache.org/
36 | * GitHub : https://github.com/apache/age
37 | * Document : https://age.apache.org/docs/
38 |
39 | ### Check that Apache AGE is loaded on your PostgreSQL database
40 | Connect to your containerized Postgres instance and then run the following commands:
41 | ```(sql)
42 | # psql
43 | CREATE EXTENSION age;
44 | LOAD 'age';
45 | SET search_path = ag_catalog, "$user", public;
46 | ```
47 |
48 | ### Test
49 | For the tests to work, please make sure the following has been done.
50 | * The driver has been successfully installed following the instructions above.
51 | * Make sure the database you will run tests against has Apache AGE installed.
52 | * Make sure to modify the DSN value in age/drivers/golang/age/age_test.go
53 | * Make sure the DSN has the correct database and connect string.
54 | * Make sure the database has a graph called testGraph created.
55 |
56 | ```
57 | cd age/drivers/golang/age
58 | go test . -v
59 |
60 | ```
61 |
62 | ### Samples
63 | * Usage 1: using database/sql API and Cypher execution function 'ExecCypher'
64 | Sample : [samples/sql_api_sample.go](samples/sql_api_sample.go)
65 |
66 | * Usage 2: using Age Wrapper
67 | Sample : [samples/age_wrapper_sample.go](samples/age_wrapper_sample.go)
68 |
69 | * Run Samples : [samples/main.go](samples/main.go)
70 |
71 |
72 | ### License
73 | Apache-2.0 License
74 |
--------------------------------------------------------------------------------
/drivers/nodejs/src/antlr4/Agtype.g4:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | grammar Agtype;
21 |
22 | agType
23 | : agValue EOF
24 | ;
25 |
26 | agValue
27 | : value typeAnnotation?
28 | ;
29 |
30 | value
31 | : STRING #StringValue
32 | | INTEGER #IntegerValue
33 | | floatLiteral #FloatValue
34 | | 'true' #TrueBoolean
35 | | 'false' #FalseBoolean
36 | | 'null' #NullValue
37 | | obj #ObjectValue
38 | | array #ArrayValue
39 | ;
40 |
41 | obj
42 | : '{' pair (',' pair)* '}'
43 | | '{' '}'
44 | ;
45 |
46 | pair
47 | : STRING ':' agValue
48 | ;
49 |
50 | array
51 | : '[' agValue (',' agValue)* ']'
52 | | '[' ']'
53 | ;
54 |
55 | typeAnnotation
56 | : '::' IDENT
57 | ;
58 |
59 | IDENT
60 | : [A-Z_a-z][$0-9A-Z_a-z]*
61 | ;
62 |
63 | STRING
64 | : '"' (ESC | SAFECODEPOINT)* '"'
65 | ;
66 |
67 | fragment ESC
68 | : '\\' (["\\/bfnrt] | UNICODE)
69 | ;
70 |
71 | fragment UNICODE
72 | : 'u' HEX HEX HEX HEX
73 | ;
74 |
75 | fragment HEX
76 | : [0-9a-fA-F]
77 | ;
78 |
79 | fragment SAFECODEPOINT
80 | : ~ ["\\\u0000-\u001F]
81 | ;
82 |
83 | INTEGER
84 | : '-'? INT
85 | ;
86 |
87 | fragment INT
88 | : '0' | [1-9] [0-9]*
89 | ;
90 |
91 | floatLiteral
92 | : RegularFloat
93 | | ExponentFloat
94 | | '-'? 'Infinity'
95 | | 'NaN'
96 | ;
97 |
98 | RegularFloat
99 | : '-'? INT DECIMAL
100 | ;
101 |
102 | ExponentFloat
103 | : '-'? INT DECIMAL? SCIENTIFIC
104 | ;
105 |
106 | fragment DECIMAL
107 | : '.' [0-9]+
108 | ;
109 |
110 | fragment SCIENTIFIC
111 | : [Ee][+-]? [0-9]+
112 | ;
113 |
114 | WS
115 | : [ \t\n\r] + -> skip
116 | ;
117 |
--------------------------------------------------------------------------------
/.github/workflows/installcheck.yaml:
--------------------------------------------------------------------------------
1 | name: Build / Regression
2 |
3 | on:
4 | push:
5 | branches: [ "master" ]
6 | pull_request:
7 | branches: [ "master" ]
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 |
13 | steps:
14 | - name: Get latest commit id of PostgreSQL 17
15 | run: |
16 | echo "PG_COMMIT_HASH=$(git ls-remote https://git.postgresql.org/git/postgresql.git refs/heads/REL_17_STABLE | awk '{print $1}')" >> $GITHUB_ENV
17 |
18 | - name: Cache PostgreSQL 17
19 | uses: actions/cache@v3
20 | id: pg17cache
21 | with:
22 | path: ~/pg17
23 | key: ${{ runner.os }}-v1-pg17-${{ env.PG_COMMIT_HASH }}
24 |
25 | - name: Install necessary dependencies
26 | run: |
27 | sudo apt-get update
28 | sudo apt-get install -y build-essential libreadline-dev zlib1g-dev flex bison
29 |
30 | - name: Install PostgreSQL 17 and some extensions
31 | if: steps.pg17cache.outputs.cache-hit != 'true'
32 | run: |
33 | git clone --depth 1 --branch REL_17_STABLE https://git.postgresql.org/git/postgresql.git ~/pg17source
34 | cd ~/pg17source
35 | ./configure --prefix=$HOME/pg17 CFLAGS="-std=gnu99 -ggdb -O0" --enable-cassert
36 | make install -j$(nproc) > /dev/null
37 | cd contrib
38 | cd fuzzystrmatch
39 | make PG_CONFIG=$HOME/pg17/bin/pg_config install -j$(nproc) > /dev/null
40 | cd ../pg_trgm
41 | make PG_CONFIG=$HOME/pg17/bin/pg_config install -j$(nproc) > /dev/null
42 |
43 | - uses: actions/checkout@v3
44 |
45 | - name: Build AGE
46 | id: build
47 | run: |
48 | make PG_CONFIG=$HOME/pg17/bin/pg_config install -j$(nproc)
49 |
50 | - name: Pull and build pgvector
51 | id: pgvector
52 | run: |
53 | git clone https://github.com/pgvector/pgvector.git
54 | cd pgvector
55 | make PG_CONFIG=$HOME/pg17/bin/pg_config install -j$(nproc) > /dev/null
56 |
57 | - name: Regression tests
58 | id: regression_tests
59 | run: |
60 | make PG_CONFIG=$HOME/pg17/bin/pg_config installcheck EXTRA_TESTS="pgvector fuzzystrmatch pg_trgm"
61 | continue-on-error: true
62 |
63 | - name: Dump regression test errors
64 | if: steps.regression_tests.outcome != 'success'
65 | run: |
66 | echo "Dump section begin."
67 | cat $HOME/work/age/age/regress/regression.diffs
68 | echo "Dump section end."
69 | exit 1
70 |
--------------------------------------------------------------------------------
/drivers/jdbc/lib/src/main/java/org/apache/age/jdbc/base/AgtypeFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.age.jdbc.base;
21 |
22 | import org.apache.age.jdbc.base.type.AgtypeList;
23 | import org.apache.age.jdbc.base.type.AgtypeMap;
24 |
25 | /**
26 | * Factory for creating Agtype objects.
27 | *
28 | * @see Agtype
29 | */
30 | public class AgtypeFactory {
31 |
32 | /**
33 | * Creates an Agtype object.
34 | *
35 | * @param obj Object to store in the an Agtype Object.
36 | * @return new Agtype Object
37 | * @throws InvalidAgtypeException Thrown if the object passed is not a {@link Agtype valid
38 | * Agtype}
39 | */
40 | public static Agtype create(Object obj) throws InvalidAgtypeException {
41 | if (obj == null) {
42 | return new Agtype(null);
43 | } else if (obj instanceof Integer) {
44 | return new Agtype(((Integer) obj).longValue());
45 | } else if (obj instanceof Long) {
46 | return new Agtype(obj);
47 | } else if (obj instanceof String) {
48 | return new Agtype(obj);
49 | } else if (obj instanceof Boolean) {
50 | return new Agtype(obj);
51 | } else if (obj instanceof Double) {
52 | return new Agtype(obj);
53 | } else if (obj instanceof AgtypeList) {
54 | return new Agtype(obj);
55 | } else if (obj instanceof AgtypeMap) {
56 | return new Agtype(obj);
57 | } else {
58 | String s = String
59 | .format("%s is not a valid Agtype value", obj.getClass().getSimpleName());
60 | throw new InvalidAgtypeException(s);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/include/utils/load/age_load.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #include "commands/sequence.h"
21 | #include "utils/builtins.h"
22 | #include "utils/lsyscache.h"
23 |
24 | #include "catalog/ag_graph.h"
25 | #include "catalog/ag_label.h"
26 | #include "commands/label_commands.h"
27 | #include "commands/graph_commands.h"
28 | #include "utils/ag_cache.h"
29 |
30 | #ifndef AGE_ENTITY_CREATOR_H
31 | #define AGE_ENTITY_CREATOR_H
32 |
33 | #define BATCH_SIZE 1000
34 |
35 | typedef struct batch_insert_state
36 | {
37 | EState *estate;
38 | ResultRelInfo *resultRelInfo;
39 | TupleTableSlot **slots;
40 | int num_tuples;
41 | int max_tuples;
42 | } batch_insert_state;
43 |
44 | agtype* create_empty_agtype(void);
45 |
46 | agtype* create_agtype_from_list(char **header, char **fields,
47 | size_t fields_len, int64 vertex_id,
48 | bool load_as_agtype);
49 | agtype* create_agtype_from_list_i(char **header, char **fields,
50 | size_t fields_len, size_t start_index,
51 | bool load_as_agtype);
52 | void insert_vertex_simple(Oid graph_oid, char *label_name, graphid vertex_id,
53 | agtype *vertex_properties);
54 | void insert_edge_simple(Oid graph_oid, char *label_name, graphid edge_id,
55 | graphid start_id, graphid end_id,
56 | agtype* end_properties);
57 | void insert_batch(batch_insert_state *batch_state);
58 |
59 | void init_batch_insert(batch_insert_state **batch_state,
60 | char *label_name, Oid graph_oid);
61 | void finish_batch_insert(batch_insert_state **batch_state);
62 |
63 | #endif /* AGE_ENTITY_CREATOR_H */
64 |
--------------------------------------------------------------------------------
/drivers/jdbc/lib/src/main/java/org/apache/age/jdbc/base/type/AgtypeListImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.apache.age.jdbc.base.type;
21 |
22 | import java.util.ArrayList;
23 | import java.util.stream.Stream;
24 | import org.apache.age.jdbc.base.AgtypeUtil;
25 | import org.apache.age.jdbc.base.InvalidAgtypeException;
26 |
27 | public class AgtypeListImpl extends ArrayList