Hi,
I debugged what goes on inside StringParser in the command posted earlier. It seems that the parser makes an assumption that the ADD command should fit on a single line. It works OK when I replace the newlines with spaces in the XML content to be added. It seems to me like a rather serious bug. Am I missing something obvious? I would really like to be able to push multi-line content to BaseX. If ADD TO is not the way to do that, then what is?
The splitting of a command string into single lines has been done in
https://github.com/BaseXdb/basex/commit/fffde7fa12a7cec6882f603638ea3e3ef366...
As far as I understand this change was about making the StringParser support .bxs scripts that can contain more than one command on each line. The distinction between a .bxs script and a "normal" command is done via the "single" flag. For normal commands "single" is set to true. Perhaps the easiest solution would be to keep the current processing if single is false, but if single is true, just use the whole string. I tried to create a patch that does it. Is the patch I attached worth anything? It seems to solve my immediate problem with the particular query I posted. I really don't understand much about BaseX codebase (or about git for that matter :) ) Please review.
-- Antoni Myłka Software Engineer
basis06 AG, Birkenweg 61, CH-3013 Bern - Fon +41 31 311 32 22 http://www.basis06.ch - source of smart business
----- Ursprüngliche Mail ----- Von: "Antoni Mylka" amy@basis06.ch An: "basex-talk" basex-talk@mailman.uni-konstanz.de Gesendet: Montag, 12. November 2012 19:17:35 Betreff: Re: [basex-talk] Database corruption
Hi,
Two further questions:
1. What's the cleanest way to get a log containing the actual query strings? AFAIU BaseX doesn't use any logging framework and the BaseXServlet.service has a finally block that prints the request headers (if Prop.debug is enabled) but not the request body. I thought about writing my own Filter for that purpose.
2. I've been trying to update BaseX to the latest snapshot, but the queries generated by my application, that used to work with 7.2.1 and 7.3 don't seem to work now. The body of a POST looks like this (\n means a newline character):
<?xml version="1.0" encoding="UTF-8"?>\n <command xmlns="http://basex.org/rest"><text><![CDATA[\n ADD TO 5d03ebad-dc6a-492c-9527-bd2ce3830080\n <tx id="5d03ebad-dc6a-492c-9527-bd2ce3830080"\n dbId=""\n xmlns="http://our.namespace.com/xmlns/"\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xmlns:xs="http://www.w3.org/2001/XMLSchema"\n <commit />\n <skip />\n </tx>\n \n ]]></text></command>
Now the question is what's wrong with this query. I get a 400 Bad Request response with the following error message.
Stopped at line 1, column 43:\n Syntax: ADD (TO [path]) [input]\n Add resource to database.\n \n Adds [input] as [path] to the database.\n
As I said this used to work with 7.3. I tried to diff the StringParser class between 7.3 and the current trunk. It seems to use the InputParser on a single line and not on the entire query. I can't spot anything that would explain this behaviour though.
All kinds of comments welcome.
-- Antoni Myłka Software Engineer
basis06 AG, Birkenweg 61, CH-3013 Bern - Fon +41 31 311 32 22 http://www.basis06.ch - source of smart business