Possible Optimization Bug (Or Maybe Document Insertion Bug)
Tuesday, 20 December 2011 · 1 message
AH
Alexander Holupirek20 Dec 2011 22:48 #
I can reproduce:
$ basex -c 'create db db <a/>;xquery insert node "text" before /a;optimize' Creating Database...
. 144.28 ms (1090 KB)
Indexing Text...
. 109.13 ms (1399 KB)
Indexing Attributes...
. 109.01 ms (1530 KB)
org.basex.core.BaseXException: Potential bug? Improper use? Your feedback is welcome: Contact: basex-talk at mailman.uni-konstanz.de
Version: BaseX 7.1 beta
Java: Apple Inc., 1.6.0_29
OS: Mac OS X, x86_64
Stack Trace:
java.lang.NullPointerException
org.basex.index.Names.index(Names.java:84)
org.basex.core.cmd.Optimize.optimize(Optimize.java:118)
org.basex.core.cmd.Optimize.run(Optimize.java:42)
org.basex.core.Command.run(Command.java:329)
org.basex.core.Command.exec(Command.java:310)
org.basex.core.Command.execute(Command.java:78)
org.basex.server.LocalSession.execute(LocalSession.java:142) org.basex.server.Session.execute(Session.java:38)
org.basex.core.Main.execute(Main.java:139)
org.basex.core.Main.execute(Main.java:120)
org.basex.BaseX.<init>(BaseX.java:77)
org.basex.BaseX.main(BaseX.java:52)
org.basex.core.Command.execute(Command.java:78)
org.basex.server.LocalSession.execute(LocalSession.java:142) org.basex.server.Session.execute(Session.java:38)
org.basex.core.Main.execute(Main.java:139)
org.basex.core.Main.execute(Main.java:120)
org.basex.BaseX.<init>(BaseX.java:77)
org.basex.BaseX.main(BaseX.java:52)
Potential bug? Improper use? Your feedback is welcome:
Contact: basex-talk at mailman.uni-konstanz.de
Version: BaseX 7.1 beta
Java: Apple Inc., 1.6.0_29
OS: Mac OS X, x86_64
Stack Trace:
java.lang.NullPointerException
org.basex.index.Names.index(Names.java:84)
org.basex.core.cmd.Optimize.optimize(Optimize.java:118)
org.basex.core.cmd.Optimize.run(Optimize.java:42)
org.basex.core.Command.run(Command.java:329)
org.basex.core.Command.exec(Command.java:310)
org.basex.core.Command.execute(Command.java:78)
org.basex.server.LocalSession.execute(LocalSession.java:142) org.basex.server.Session.execute(Session.java:38)
org.basex.core.Main.execute(Main.java:139)
org.basex.core.Main.execute(Main.java:120)
org.basex.BaseX.<init>(BaseX.java:77)
org.basex.BaseX.main(BaseX.java:52)
Quoted text · Dave Glick · 62 lines
On 20.12.2011, at 22:42, Dave Glick wrote: > Christian, > > Try the following: > > "create db db <a/>;xquery insert node "text" before /a;optimize" > > This gives me the error reported below. I ran it from the GUI, though I'm guessing that shouldn't make a difference. It appears as though the difference is in the insertion of text content (as opposed to node content). Though I now see three possible problems (or not) based on your example and its success: > > - A NullPointerException during optimize after inserting text content before the root element of a document. > - The ability to insert text content before the root element of a document (should this be allowed?) > - The ability to insert a second node before the root element of a document (should this be allowed?) > > Dave > > -----Original Message----- > From: Christian Grün [mailto:christian.gruen at gmail.com] > Sent: Tuesday, December 20, 2011 4:34 PM > To: Dave Glick > Cc: BaseX > Subject: Re: [basex-talk] Possible Optimization Bug (Or Maybe Document Insertion Bug) > > Dave, > > thanks for the valuable observation and the hints what could be the reason. I didn't manage to reproduce the problem, though. This is what I tried: > > basex -c "create db db <a/>;xquery insert node <b/> before /a;optimize" > > Do you have a little example that leads to the discussed problem? > Next, I'll also be glad to look at one of the documents with text before the root node that is erroneously accepted by our parser. > > Thanks! > Christian > ___________________________ > > On Tue, Dec 20, 2011 at 6:32 PM, Dave Glick <dglick at dracorp.com> wrote: >> Hello, >> >> I seem to have stumbled on a bug (or at least I think I have). Do the following: >> >> - Create a simple database with a single document >> - Insert a text node before the start of the document root ("insert >> node "test" before /root") >> - Attempt to optimize the database >> >> You will get a NullPointerException at org.basex.index.Names.index(Names.java:84). It appears as though the index is attempting to set statistics information for key id 0 (because the parent is a document), but the stats[] array only gets initialized with objects from index 1 and up. >> >> The other possibility is that text nodes should not be allowed before or after the document root element. I'm a little hazy on what the standards say in this regard. My understanding is that the document node can have prolog content before the root and other content after. I've also seen many documents which parse correctly that have text content before the opening tag (though again, this may not be strictly standard-compliant behavior). If this is the case, then the bug is probably that the insertion update operation is allowed to succeed. >> >> Dave >> >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Alexander Holupirek
|-- http://www.informatik.uni-konstanz.de/~holupire
|-- Database & Information Systems Group, U Konstanz
`-- Room E 221, 0049 7531 88 2188 (phone) 3577 (fax)
Written for BaseX 7.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery