Serious bug? DB corrupted on Xquery replace
Friday, 25 March 2011 · 2 messages
LW
Hi Charles,
Quoted text · Charles F. Munat · 2 lines
Am 25.03.2011 00:19, schrieb Charles F. Munat: > I backed up to BaseX 6.5 and tried again and everything worked perfectly.
which version of BaseX did you use when the corruption happened? The 6.5.2-SNAPSHOT builds contained a severe storage bug that was fixed with version 6.6.
Quoted text · Charles F. Munat · 2 lines
> I had to switch to a back-up copy. I then tried simply inserting the > seminars one at a time. This didn't work either.
could you send me the backup so I can reproduce and hunt down the bug? That would definitely speed up the process.
Quoted text · Charles F. Munat · 1 line
> Have I done something dumb, or is there a problem here?
Looks like our fault, not yours.
BTW:
Quoted text · Charles F. Munat · 3 lines
> I wanted to add some new seminars to this list. I was working from a > spreadsheet, which I converted to tab-separated values and then used > regular expressions to rewrite each line as a <seminar/> element.
We provide a quite convenient CSV parser [1], it can be easily configured to read tab-separated files, too.
Quoted text · Charles F. Munat · 1 line
> I don't know to do multiple replaces in a single query
You can simply separate the update statements by commas, building a sequence:
Quoted text · Charles F. Munat · 6 lines
> let $node-to-modify := //node[@id eq 42] > return ( > rename node $node-to-modify as 'foo', > insert node attribute bar { '21' } into $node-to-modify, > delete node $node-to-modify/@useless-attribute > )
Using that technique you can easily restructure your database completely within one query.
Hope this helps,
cheers Leo
__________
[1] http://docs.basex.org/wiki/Parsers#CSV_Parser
CM
Charles F. Munat25 Mar 2011 01:19 #
I have a database with a structure thus:
/data/functions/seminars/seminar
I wanted to add some new seminars to this list. I was working from a spreadsheet, which I converted to tab-separated values and then used regular expressions to rewrite each line as a <seminar/> element.
I don't know to do multiple replaces in a single query, so I did this instead:
let $seminars := /data/functions/seminars
let $xs := $seminars/seminar
return replace node $seminars with
<seminars>
{$xs}
<seminar/>
<seminar/>
<seminar/>
<seminar/>
<seminar/>
</seminars>This corrupted the database to the point where it was unusable. (First error was that there were multiple docs. Then I tracked it down to an index out of bounds error.)
I had to switch to a back-up copy. I then tried simply inserting the seminars one at a time. This didn't work either.
I backed up to BaseX 6.5 and tried again and everything worked perfectly.
Have I done something dumb, or is there a problem here?
Thanks!
Chas.
Written for BaseX 6.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery