I am changing pg-pool to cater cypher queries for Apache AGE and I have the following code, which takes the select statement. From that it gets the FROM clause, then from the FROM clause it gets the function names. So now I want that function arguments also. How would I do that. The code is as follows:
if (IsA(node, SelectStmt))
{
SelectStmt *stmt = (SelectStmt *) node;
List* fromClause = stmt->fromClause;
ListCell *fl;
//Match the first cypher function call in the FROM clause. Could be multiple tables
// e.g. FROM table1, table2, cypher(),table3....
foreach(fl, fromClause)
{
Node *n = lfirst(fl);
if (IsA(n, RangeFunction))
{
RangeFunction *rf = (RangeFunction*) n;
List* functions = rf->functions;
if (functions->length == 1)
{
List *sublist = (List *) lfirst(list_head(functions));
FuncCall *fntree = (FuncCall *) lfirst(list_head(sublist));
StringInfoData str;
initStringInfo(&str);
_outNode(&str,fntree->funcname);
if (!strcmp("\"cypher\"",str.data)){
return true;
}
}
}
}
}