Bugs item #2815820, was opened at 2009-07-02 16:30
Message generated for change (Comment added) made by stmane
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=482468&aid=2815820&group_id=56967

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: PF/compiler
Group: MonetDB4 "stable"
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Hans (hans_0_)
Assigned to: Nobody/Anonymous (nobody)
Summary: PF: Endless loop in innocent xquery

Initial Comment:
OS: Fedora core 10
Installed rpms version x.28.4

While executing the innocent looking xquery listed below with mclient the 
result is endless.
The message: "!ERROR: xquery_print_result_main: operation failed." is shown 
after a while.
When removing one of the two elements within element result  the result is 
small and as expected.

The situation happened in a real life situation and was reduced to this small 
xquery.

let $result := 
<document xid="5">
    <folder xid="6">
        <file xid="19">
            <slack xid="20">
                <properties>
                    <stream xend="507" xstart="544"/>
                    <streamname>#data</streamname>
                    <name>aap</name>
                </properties>
            </slack>
            <properties>
                <md5>xxx</md5>
                <sha1>yyy</sha1>
                <stream xend="123" xstart="456"/>
                <streamname>data</streamname>
                <name>noot</name>
            </properties>
        </file>
    </folder>
    <properties>
        <type>doc</type>
    </properties>
</document>
let $notedobjectsresult := for $notedxid in ("20","5")  
    return $resu...@xid=$notedxid]
let $subresult := $notedobjectsresult
let $nobj := count($subresult)                  
let $out := (                  
  for $i in (1 to $nobj)                  
   let $raw := exactly-one($subresult[$i])    
   return element { name($raw) } {                      
          $raw/properties/(name|stream)
   }
)                  
return element result {                      
  element attributes { for $a in distinct-values(for $j in $out/@* return 
name($j)) return element { $a } {} },
  element results    { $out }  
}                                   
<>

Regards,
Hans.

----------------------------------------------------------------------

>Comment By: Stefan Manegold (stmane)
Date: 2009-07-02 20:12

Message:
If I recall correctly from abroad, we recently changed (fixed) the
implementation/semantics of grouped aggregations to return NIL (NULL) for
empty groups.
Hence, the only alternative to your ifthenelse() work-around would be to
(re-)introduce "non-nil" alternative of the grouped aggregates (next to the
current "nil"-default ones) that would use a fixed (or parameterized)
non-nil "default" value for empty groups ...

Greetings from a "MonetDB-dominated" SIGMOD 2009 in Providence, RI!
(;-))


----------------------------------------------------------------------

Comment By: Jan Rittinger (tsheyar)
Date: 2009-07-02 17:37

Message:
I cooked down the problem to the following XQuery snippet: 

let $out := (
 for $a in (<a x="5"/>)[...@x=("5","20")]
 return <b>{ $a/xxx }</b>
)
return <c>{ $out/@*, $out }</c>

The problem is that '{sum}(empty_bat, bat_with_one_row)' that calculates
the size for node b returns a single row with a nil value in the tail. This
invalid size is added to the document representation and the serialization
interprets it incorrectly.

@MIL experts: Is there a nice solution to use a default value for {sum} or
do I need to add the following additional check?
 
res := {sum}(..., ...);
res := [ifthenelse]([isnil](res), res.project(0), res); 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=482468&aid=2815820&group_id=56967

------------------------------------------------------------------------------
_______________________________________________
Monetdb-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-bugs

Reply via email to