The data setup doesn’t matter in this case. If I run this query select * from cypher('test', $$ match (a)-[]->(b) with a, count(*) as c return b $$) as (b agtype);
I get this
server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
Is this a known bug or is it something from my end?
Im using postgreSQL version 12.14 and apacheAGE 1.1.1
2
Answers
Looking at the query, I believe what you are trying to do is count the number of relationships that "a" has with "b" with the length of one edge between them. So, the number of edges in the graph. If this is the case, the proper way to do this would be something like:
Regarding the error, I used GDB to debug it and it stops at an error when it gets to
list_nth_cell
on thelist.c
file. The error that shows is:So maybe when it tries to count it, this n property is greater than the list length, which throws an error. My guess would be that the problem happens in the
count(*)
part of the query.This query should error out (as shown below) rather than terminating the server because you are trying to reference b which is not preserved by the WITH clause. Read more about WITH clause here.
The server crash was due to a bug that is fixed recently. See this issue https://github.com/apache/age/issues/329. So until now, the newest release that is v1.2.0 doesn’t incorporate this fix.
If you want to access b after WITH, you would have to pass it on
If you want to see the changes (i.e error instead of server crash), you would have to pull recent commits from PG12 branch (since you are using postgres 12) and rebuild age.