According to instructions Apache AGE docs wrote a function:
CREATE OR REPLACE FUNCTION sh_univeronto.f_example() RETURNS TABLE(res ag_catalog.agtype) LANGUAGE plpgsql AS $function$
begin
LOAD 'age';
SET search_path TO ag_catalog, public;
PREPARE cypher_stored_procedure(ag_catalog.agtype) as
SELECT *
FROM ag_catalog.cypher('sh_univeronto', $$
MATCH (v:gr_main)
WHERE v.unoid = $unoid_val
RETURN v
$$, $1)
AS (v agtype);
EXECUTE cypher_stored_procedure('{"unoid_val": "222eee33"}');
-- other code
END;
$function$;
Error_1)
If I call 1st time: SELECT sh_univeronto.f_example();
gives an error message:
SQL Error [42883]: ERROR: function cypher_stored_procedure(unknown) does not exist No function matches the given name and argument types. You might need to add explicit type casts. PL/pgSQL function sh_univeronto.f_example() line 42 at EXECUTE
Error_2) If I call for the 2nd time, it gives an error:
SQL Error [42P05]: ERROR: prepared statement "cypher_stored_procedure" already exists
SQL statement "PREPARE cypher_stored_procedure(ag_catalog.agtype) as
SELECT *
FROM ag_catalog.cypher('sh_univeronto', $$
MATCH (v:gr_main)
WHERE v.unoid = $unoid_val
RETURN v
$$, $1)
AS (v agtype)"
PL/pgSQL function sh_univeronto.f_example() line 33 at SQL statement
If I add DEALLOCATE ALL; then again Error_1 occurs
About Error_2 found recommendations about PgBouncer:
- Configure the PostgreSQL "Pooling mode" to "session"
- To cancel the session state, use the option server_reset_query in configuration PgBouncer - in file pgbouncer.ini
But I don't have PgBouncer on the server. I didn't find pgbouncer.ini
How to eliminate Error_1 and Error_2?