cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to update a procedure previously registered with apoc.custom.asProcedure

wirselix
Node Clone

Hi apoc community

Context:

  • neo4j version: 3.4.7 (hosted on https://app.graphenedb.com/)
  • apoc version: apoc-3.4.0.3-all
  • topic is related to apoc.custom.asProcedure

Problem
I am playing around with the new apoc.custom.asProcedure functionality (a big thanks to @stefan.armbruster)
It works, registering a custom procedures was successful, same for calling the procedure.

First version of the procedure I have registered

CALL apoc.custom.asProcedure('treeitemlist',
  substring(reduce(s="", x in [
  'MATCH (z:C_tree_item)'
,'WHERE'
,'NOT z:T_tree_item_start'
,'AND  z:T_tree_item_end'  <-------THIS LINE CONTAINS THE ERROR . should have been: AND NOT z:....
,'WITH z order by z.line_index'
,'WITH collect(z) AS items'
,'RETURN items'
  ] | s+" "+x),1),'read',
  [['items','LIST OF NODE']],[])

Unfortunately I made a mistake in my registered cypher statement (see source code above) when calling 'apoc.custom.asProcedure'.
I tried to fix it by calling again apoc.custom.asProcedure (see source code below), with the same procedure name but updated cypher statement. Still the registered procedure 'treeitemlist' is executed with the wrong cypher statement.

Next try to register procedure 'treeitemlist' with the correct cypher statement

CALL apoc.custom.asProcedure('treeitemlist',
  substring(reduce(s="", x in [
  'MATCH (z:C_tree_item)'
,'WHERE'
,'NOT z:T_tree_item_start'
,'AND  NOT z:T_tree_item_end'  <------THIS TIME THE STATEMENT IS CORRECT
,'WITH z order by z.line_index'
,'WITH collect(z) AS items'
,'RETURN items'
  ] | s+" "+x),1),'read',
  [['items','LIST OF NODE']],[])

Seems that once a procedure is registered it is imposible to change the cypher statement. Is this correct?
That raises some more generic questions, but I will create a dedicated topic for them

Best
Markus

2 REPLIES 2

Can you try to execute the following statement before overriding the custom procedure :

call dbms.clearQueryCaches()

Hi Christophe
Here is what i tried today:
1:cleared the query caches as suggested
2: perform an override of the custom procedure,
3: call the custom function -> still old behavior.
3: Restart DBMS
4: call the custom function -> now it works, the custom functions behavior has changed

Probably some caching behavior within the DBMS, that still holds the hold cypher functions for the custom procedure.

And this behavior is reproducible. only after DBMS start the change of the cypher statement in the custom procedure become visible

Best
Markus