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?

- 75,595
- 17
- 168
- 206

- 716
- 1
- 10
-
I have removed the "spi" tag as it is used for the *Serial Peripheral Interface* and not for *Server Programming Interface*. – Codo Jul 03 '23 at 19:47
3 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:
Datum result;
result = DirectFunctionCall2(numeric_add, num1, num2);
In this code snippet, the DirectFunctionCall2
function is used to call another function that adds two numeric values and returns the result.

- 763
- 1
- 12
The SPI mechanism should work fine, but I think transform_cypher_order_by
function is responsible for handling the ORDER BY
clause. You should experiment with it and see if it works.

- 433
- 9
Yes it is possible to use the server programming interface in PostgreSQL to work on and perform queries and access the server. Moreover, the ORDER BY query can also be used within the AGE function for custom domains.

- 205
- 2