Hi Jean,
I’m glad to tell that the inlining bug has just been fixed by our team member Leo. You are invited to check out the latest snapshot.
I am not sure to understand well this parameter. Does it means that it is possible to inline function in XQUERY ?
User-defined functions can be "inlined" by the query compiler; this allows better optimizations in the next steps. As an example, the following query...
declare function f($a) { $a * $a }; f(2) + f(3)
…will be rewritten to…
let $a := 2 return $a * $a + let $a := 3 return $a * $a
…which will then be simplified to
2*2 + 3*3 …and… 13
This all is done by the query optimizer, i.e. it happens before the query is eventually evaluated.
Christian ___________________________
On Fri, Nov 22, 2013 at 3:06 PM, jean-marc Mercier jeanmarc.mercier@gmail.com wrote:
Christian,
Thx very much for your workaround. I did not succeed using the GUI and executing »SET INLINELIMIT 0«. However, it seems that there exists several way to set this parameter without the GUI. I tested successfully the two following methods:
- Set the parameter before the query as follow : (# db:INLINELIMIT 0 #)
{fn:count($insert())} However, it is somehow tedious to write all queries that way.
- Edit the file .basex, adding the line "INLINELIMIT = 0" after #Local
Options. I would prefer this method, would you have no objection.
I am not sure to understand well this parameter. Does it means that it is possible to inline function in XQUERY ? This is quite close to template mechanism programming !
Cheers,
Jean-Marc
2013/11/22 Christian Grün christian.gruen@gmail.com
Hi Jean-Marc,
the bug you encountered is due to a newly feature (called “function inlining”) we’ve introduced just recently. It will be fixed soon [2]. Until then, you can simply disable it by setting INLINELIMIT to 0 [1] This can e.g. be done by choosing »Command« in the dropdown box of the GUI main window, and executing the command »SET INLINELIMIT 0«.
Thanks for the reproducible code, Christian
[1] http://docs.basex.org/wiki/Options#INLINELIMIT [2] https://github.com/BaseXdb/basex/issues/796 ___________________________
On Fri, Nov 22, 2013 at 10:28 AM, jean-marc Mercier jeanmarc.mercier@gmail.com wrote:
Hi,
Within my environment, I am experiencing some frustrating behavior of the Xquery Basex engine. I've done my best to single out the problem in the following XQUERY code :
declare function local:wtf($x as item() ) {function() { $x}}; declare function local:dummy($f,$x) { if(fn:empty($f())) then local:wtf($x) else local:wtf(())};
declare variable $insert := local:dummy(function(){ () }, function() { (), ()} ); fn:count($insert())
The issues are :
- executing this code yields an "Improper use? Potential bug?"
exception (see details further on). 2) If I change the execution query to be fn:count(local:dummy(function(){ () }, function() { (), ()} )()) ( I just copy and pasted the value of $insert into the fn:count(..) ) then the query is executed normally, returning "1". 3) If I change the function declaration local:wtf as follow declare function local:wtf($x) {function() { $x}}; (I just removed "as item()"), then the query is executed normally, returning "1".
Can you reproduce it with another environment ?
Cheers,
Jean-Marc
Improper use? Potential bug? Your feedback is welcome: Contact: basex-talk@mailman.uni-konstanz.de Version: BaseX 7.8 beta 6aeaebf Java: Oracle Corporation, 1.7.0_05 OS: Windows 7, amd64 Stack Trace: java.lang.NullPointerException at org.basex.query.value.item.FuncItem.inlineExpr(FuncItem.java:308) at org.basex.query.func.DynFuncCall.optimize(DynFuncCall.java:58) at org.basex.query.func.DynFuncCall.compile(DynFuncCall.java:39) at org.basex.query.expr.Arr.compile(Arr.java:40) at org.basex.query.func.StandardFunc.compile(StandardFunc.java:60) at org.basex.query.MainModule.compile(MainModule.java:63) at org.basex.query.QueryCompiler.compile(QueryCompiler.java:70) at org.basex.query.QueryCompiler.compile(QueryCompiler.java:61) at org.basex.query.QueryContext.analyze(QueryContext.java:270) at org.basex.query.QueryContext.compile(QueryContext.java:253) at org.basex.query.QueryProcessor.compile(QueryProcessor.java:71) at org.basex.core.cmd.AQuery.query(AQuery.java:81) at org.basex.core.cmd.XQuery.run(XQuery.java:22) at org.basex.core.Command.run(Command.java:323) at org.basex.core.Command.execute(Command.java:92) at org.basex.server.LocalSession.execute(LocalSession.java:121) at org.basex.server.Session.execute(Session.java:37) at org.basex.core.Main.execute(Main.java:146) at org.basex.BaseX.<init>(BaseX.java:119) at org.basex.BaseX.main(BaseX.java:38)
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk