Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR to merge master branch into PG15 branch #1158

Merged
merged 8 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<img src="https://img.shields.io/badge/Release-v1.3.0-FFA500?labelColor=gray&style=flat&link=https://github.com/apache/age/releases"/>
</a>
&nbsp;
<a href="https://www.postgresql.org/docs/14/index.html">
<img src="https://img.shields.io/badge/Version-Postgresql 15-00008B?labelColor=gray&style=flat&link=https://www.postgresql.org/docs/14/index.html"/>
<a href="https://www.postgresql.org/docs/15/index.html">
<img src="https://img.shields.io/badge/Version-Postgresql 15-00008B?labelColor=gray&style=flat&link=https://www.postgresql.org/docs/15/index.html"/>
</a>
&nbsp;
<a href="https://github.com/apache/age/issues">
Expand Down Expand Up @@ -131,8 +131,8 @@ Apache AGE is intended to be simple to install and run. It can be installed with
&nbsp;Install PostgreSQL
</h4>

You will need to install an AGE compatible version of Postgres<a>, for now AGE supports Postgres 11, 12, 13 & 14. Supporting the latest versions is on AGE roadmap.
You will need to install an AGE compatible version of Postgres<a>, for now AGE supports Postgres 11, 12, 13, 14 & 15. Supporting the latest versions is on AGE roadmap.

<h4>
&nbsp;Installation via Package Manager
</h4>
Expand All @@ -149,7 +149,7 @@ sudo apt install postgresql
&nbsp;Installation From Source Code
</h4>

You can <a href="https://www.postgresql.org/ftp/source/"> download the Postgres </a> source code and install your own instance of Postgres. You can read instructions on how to install from source code for different versions on the <a href="https://www.postgresql.org/docs/14/installation.html">official Postgres Website.</a>
You can <a href="https://www.postgresql.org/ftp/source/"> download the Postgres </a> source code and install your own instance of Postgres. You can read instructions on how to install from source code for different versions on the <a href="https://www.postgresql.org/docs/15/installation.html">official Postgres Website.</a>



Expand All @@ -158,7 +158,7 @@ You can <a href="https://www.postgresql.org/ftp/source/"> download the Postgres

Clone the <a href="https://github.com/apache/age">github repository</a> or download the <a href="https://github.com/apache/age/releases">download an official release.
</a>
Run the pg_config utility and check the version of PostgreSQL. Currently, only PostgreSQL versions 11, 12, 13 & 14 are supported. If you have any other version of Postgres, you will need to install PostgreSQL version 11, 12, 13, or 14.
Run the pg_config utility and check the version of PostgreSQL. Currently, only PostgreSQL versions 11, 12, 13, 14 & 15 are supported. If you have any other version of Postgres, you will need to install PostgreSQL version 11, 12, 13, 14, or 15.
<br>

```bash
Expand Down
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Release Notes for Apache AGE release 0.0.0 for PG 15

Apache AGE 0.0.0 - Release Notes

NOTE: This is an initial release of PG14. There are no upgrade
NOTE: This is an initial release of PG15. There are no upgrade
scripts to this release.

**************************************************************
jrgemignani marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
17 changes: 13 additions & 4 deletions age--1.3.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ AS 'MODULE_PATHNAME';
CREATE FUNCTION ag_catalog._label_name(graph_oid oid, graphid)
RETURNS cstring
LANGUAGE c
STABLE
IMMUTABLE
PARALLEL SAFE
AS 'MODULE_PATHNAME';

Expand Down Expand Up @@ -3104,18 +3104,19 @@ AS 'MODULE_PATHNAME';
CREATE FUNCTION ag_catalog._agtype_build_vertex(graphid, cstring, agtype)
RETURNS agtype
LANGUAGE c
STABLE
IMMUTABLE
CALLED ON NULL INPUT
PARALLEL SAFE
AS 'MODULE_PATHNAME';

--
-- agtype - edge
--
CREATE FUNCTION ag_catalog._agtype_build_edge(graphid, graphid, graphid, cstring, agtype)
CREATE FUNCTION ag_catalog._agtype_build_edge(graphid, graphid, graphid,
cstring, agtype)
RETURNS agtype
LANGUAGE c
STABLE
IMMUTABLE
CALLED ON NULL INPUT
PARALLEL SAFE
AS 'MODULE_PATHNAME';
Expand Down Expand Up @@ -3546,6 +3547,14 @@ RETURNS NULL ON NULL INPUT
PARALLEL SAFE
AS 'MODULE_PATHNAME';

CREATE FUNCTION ag_catalog.age_tostringlist(variadic "any")
RETURNS agtype
LANGUAGE c
IMMUTABLE
RETURNS NULL ON NULL INPUT
PARALLEL SAFE
AS 'MODULE_PATHNAME';

CREATE FUNCTION ag_catalog.age_size(variadic "any")
RETURNS agtype
LANGUAGE c
Expand Down
139 changes: 136 additions & 3 deletions regress/expected/expr.out
Original file line number Diff line number Diff line change
Expand Up @@ -2917,9 +2917,9 @@ $$) AS (toFloatList agtype);
SELECT * FROM cypher('expr', $$
RETURN toFloatList(['1.9432', 8.6222, '9.4111212', 344.22])
$$) AS (toFloatList agtype);
tofloatlist
-----------------------------------------
[1.9432, 8.6222, 9.4111212, 344.220001]
tofloatlist
-------------------------------------
[1.9432, 8.6222, 9.4111212, 344.22]
(1 row)

SELECT * FROM cypher('expr', $$
Expand Down Expand Up @@ -3284,6 +3284,69 @@ ERROR: function ag_catalog.age_tostring() does not exist
LINE 1: SELECT * FROM cypher('expr', $$ RETURN toString() $$) AS (re...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
-- toStringList() --
SELECT * FROM cypher('expr', $$
RETURN toStringList([5, 10, 7.8, 9, 1.3])
$$) AS (toStringList agtype);
tostringlist
--------------------------------
["5", "10", "7.8", "9", "1.3"]
(1 row)

SELECT * FROM cypher('expr', $$
RETURN toStringList(['test', 89, 'again', 7.1, 9])
$$) AS (toStringList agtype);
tostringlist
-------------------------------------
["test", "89", "again", "7.1", "9"]
(1 row)

SELECT * FROM cypher('expr', $$
RETURN toStringList([null, false, true, 'string'])
$$) AS (toStringList agtype);
tostringlist
------------------------------
[null, null, null, "string"]
(1 row)

SELECT * FROM cypher('expr', $$
RETURN toStringList([9.123456789, 5.123, 1.12345, 0.123123])
$$) AS (toStringList agtype);
tostringlist
-------------------------------------------------
["9.123456789", "5.123", "1.12345", "0.123123"]
(1 row)

-- should return null
SELECT * FROM cypher('expr', $$
RETURN toStringList([null])
$$) AS (toStringList agtype);
tostringlist
--------------
[null]
(1 row)

SELECT * FROM cypher('expr', $$
RETURN toStringList([true, false, true, true])
$$) AS (toStringList agtype);
tostringlist
--------------------------
[null, null, null, null]
(1 row)

-- should fail
SELECT * FROM cypher('expr', $$
RETURN toStringList([['a', b]])
$$) AS (toStringList agtype);
ERROR: could not find rte for b
LINE 2: RETURN toStringList([['a', b]])
^
SELECT * FROM cypher('expr', $$
RETURN toStringList([test])
$$) AS (toStringList agtype);
ERROR: could not find rte for test
LINE 2: RETURN toStringList([test])
^
--
-- reverse(string)
--
Expand Down Expand Up @@ -6913,9 +6976,79 @@ SELECT * FROM cypher('graph_395', $$ MATCH (p:Project)-[:Has]->(t:Task)-[:Assign
{"pn": "Project B", "tasks": [{"tn": "Task C", "users": [{"id": 1407374883553282, "label": "Person", "properties": {"age": 43, "name": "Bob"}}::vertex]}]}
(2 rows)

---
--- Fix: Segmentation fault when using specific names for tables #1124
---
--- The following are just a few commands to test SQLValueFunction types
---
SELECT count(*) FROM CURRENT_ROLE;
count
-------
1
(1 row)

SELECT count(*) FROM CURRENT_USER;
count
-------
1
(1 row)

SELECT count(*) FROM USER;
count
-------
1
(1 row)

SELECT count(*) FROM SESSION_USER;
count
-------
1
(1 row)

SELECT * FROM CURRENT_CATALOG;
current_catalog
--------------------
contrib_regression
(1 row)

SELECT * FROM CURRENT_SCHEMA;
current_schema
----------------
ag_catalog
(1 row)

SELECT * FROM create_graph('issue_1124');
NOTICE: graph "issue_1124" has been created
create_graph
--------------

(1 row)

SELECT results, pg_typeof(user) FROM cypher('issue_1124', $$ CREATE (u) RETURN u $$) AS (results agtype), user;
results | pg_typeof
----------------------------------------------------------------+-----------
{"id": 281474976710657, "label": "", "properties": {}}::vertex | name
(1 row)

SELECT results, pg_typeof(user) FROM cypher('issue_1124', $$ MATCH (u) RETURN u $$) AS (results agtype), user;
results | pg_typeof
----------------------------------------------------------------+-----------
{"id": 281474976710657, "label": "", "properties": {}}::vertex | name
(1 row)

--
-- Cleanup
--
SELECT * FROM drop_graph('issue_1124', true);
NOTICE: drop cascades to 2 other objects
DETAIL: drop cascades to table issue_1124._ag_label_vertex
drop cascades to table issue_1124._ag_label_edge
NOTICE: graph "issue_1124" has been dropped
drop_graph
------------

(1 row)

SELECT * FROM drop_graph('graph_395', true);
NOTICE: drop cascades to 7 other objects
DETAIL: drop cascades to table graph_395._ag_label_vertex
Expand Down
45 changes: 45 additions & 0 deletions regress/sql/expr.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,33 @@ SELECT * FROM age_toString(agtype_in(null));
-- should fail
SELECT * FROM age_toString();
SELECT * FROM cypher('expr', $$ RETURN toString() $$) AS (results agtype);
-- toStringList() --
SELECT * FROM cypher('expr', $$
RETURN toStringList([5, 10, 7.8, 9, 1.3])
$$) AS (toStringList agtype);
SELECT * FROM cypher('expr', $$
RETURN toStringList(['test', 89, 'again', 7.1, 9])
$$) AS (toStringList agtype);
SELECT * FROM cypher('expr', $$
RETURN toStringList([null, false, true, 'string'])
$$) AS (toStringList agtype);
SELECT * FROM cypher('expr', $$
RETURN toStringList([9.123456789, 5.123, 1.12345, 0.123123])
$$) AS (toStringList agtype);
-- should return null
SELECT * FROM cypher('expr', $$
RETURN toStringList([null])
$$) AS (toStringList agtype);
SELECT * FROM cypher('expr', $$
RETURN toStringList([true, false, true, true])
$$) AS (toStringList agtype);
-- should fail
SELECT * FROM cypher('expr', $$
RETURN toStringList([['a', b]])
$$) AS (toStringList agtype);
SELECT * FROM cypher('expr', $$
RETURN toStringList([test])
$$) AS (toStringList agtype);

--
-- reverse(string)
Expand Down Expand Up @@ -2810,9 +2837,27 @@ SELECT * FROM cypher('graph_395', $$ MATCH (p:Project)-[:Has]->(t:Task)-[:Assign
WITH p, collect(task) AS tasks
WITH {pn: p.name, tasks:tasks} AS project
RETURN project $$) AS (p agtype);

---
--- Fix: Segmentation fault when using specific names for tables #1124
---
--- The following are just a few commands to test SQLValueFunction types
---

SELECT count(*) FROM CURRENT_ROLE;
SELECT count(*) FROM CURRENT_USER;
SELECT count(*) FROM USER;
SELECT count(*) FROM SESSION_USER;
SELECT * FROM CURRENT_CATALOG;
SELECT * FROM CURRENT_SCHEMA;
SELECT * FROM create_graph('issue_1124');
SELECT results, pg_typeof(user) FROM cypher('issue_1124', $$ CREATE (u) RETURN u $$) AS (results agtype), user;
SELECT results, pg_typeof(user) FROM cypher('issue_1124', $$ MATCH (u) RETURN u $$) AS (results agtype), user;

--
-- Cleanup
--
SELECT * FROM drop_graph('issue_1124', true);
SELECT * FROM drop_graph('graph_395', true);
SELECT * FROM drop_graph('chained', true);
SELECT * FROM drop_graph('VLE', true);
Expand Down
30 changes: 30 additions & 0 deletions src/backend/parser/cypher_analyze.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@ static bool convert_cypher_walker(Node *node, ParseState *pstate)
parser_errposition(pstate, exprLocation((Node *)funcexpr))));
}

/*
* From PG -
* SQLValueFunction - parameterless functions with special grammar
* productions.
*
* These are a special case that needs to be ignored.
*
* TODO: This likely needs to be done with XmlExpr types, and maybe
* a few others too.
*/
if (IsA(funcexpr, SQLValueFunction))
{
return false;
}

return expression_tree_walker((Node *)funcexpr->args,
convert_cypher_walker, pstate);
}
Expand Down Expand Up @@ -296,6 +311,21 @@ static bool is_rte_cypher(RangeTblEntry *rte)
*/
static bool is_func_cypher(FuncExpr *funcexpr)
{
/*
* From PG -
* SQLValueFunction - parameterless functions with special grammar
* productions.
*
* These are a special case that needs to be ignored.
*
* TODO: This likely needs to be done with XmlExpr types, and maybe
* a few others too.
*/
if (IsA(funcexpr, SQLValueFunction))
{
return false;
}

return is_oid_ag_func(funcexpr->funcid, "cypher");
}

Expand Down
11 changes: 7 additions & 4 deletions src/backend/parser/cypher_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,14 @@ static Node *transform_A_Const(cypher_parsestate *cpstate, A_Const *ac)
d = boolean_to_agtype(boolVal(&ac->val));
break;
default:
if (ac->isnull) {
if (ac->isnull)
{
is_null = true;
} else {
ereport(ERROR,
(errmsg_internal("unrecognized node type: %d", nodeTag(&ac->val))));
}
else
{
ereport(ERROR, (errmsg_internal("unrecognized node type: %d",
nodeTag(&ac->val))));
return NULL;
}
}
Expand Down
Loading