I was wondering if I could utilize SPI to access the server and perform a query to return an agtype
value. I wanted to implement a function that uses an already created one but then perform an ORDER BY
and then return the agtype
results from there. Would that be possible? If this is not possible, how could call another age_
function inside another and retrieve it’s results and use ODER BY
with it?
Question posted in PostgreSQL
The official documentation can be found here.
The official documentation can be found here.
2
Answers
I don’t know about the SPI (Server Programming Interface), but you could look in fmgr.h for the
DirectFunctionCall
family of functions, which provide various ways to call other functions inside C.Here’s an example that demonstrates the usage:
In this code snippet, the
DirectFunctionCall2
function is used to call another function that adds two numeric values and returns the result.The SPI mechanism should work fine, but I think
transform_cypher_order_by
function is responsible for handling theORDER BY
clause. You should experiment with it and see if it works.