[Monetdb-developers] [Monetdb-pf-checkins] pathfinder/compiler/algebra builtins.c, , 1.79, 1.80

Jan Rittinger rittinge at in.tum.de
Thu Feb 14 21:59:41 CET 2008


Lefteris,

sorry if my commit message was a bit misleading.

fn:name comes in two flavors fn:name() and fn:name(node()?). The first 
one is transformed into the second one during parse tree to core 
compilation. (This means we do not have to cope with the first function 
in the algebra.)

In my commit messages I wanted to refer to empty sequences (not missing 
parameters) like e.g. in

let $a := if (1=2) then <a/> else ()
return fn:name($a)

where the empty string (and not the empty sequence) needs to be returned.

Cheers,
Jan

On 02/14/2008 05:31 PM, Torsten Grust wrote with possible deletions:
> Lefteris,
> 
> I think Jan is talking an empty input _relation_ (in the loop
> lifting sense) not the absence of the argument in the actual
> function call.
> 
> Cheers,
>     --Torsten
> 
> On Feb 14, 2008, at 15:37, Lefteris wrote:
> 
>> Jan, is this the correct way to cope with empty input?
>>
>> The xquery function specs say that if input is ommited then it
>> defaults to the context item (.)
>>
>> That also is expresed in xquery_fo.c with the .arity = 0 version of  
>> fn:name etc.
>> If that is true, shouldn't be dealed at the core level?
>>
>> lefteris
>>
>> On Wed, Feb 13, 2008 at 9:54 PM, Jan Rittinger
>> <tsheyar at users.sourceforge.net> wrote:
>>> Update of /cvsroot/monetdb/pathfinder/compiler/algebra
>>> In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18492/algebra
>>>
>>> Modified Files:
>>>        builtins.c
>>> Log Message:
>>> -- Fix the translation of fn:name, fn:local-name, and fn:namespace- 
>>> uri.
>>>   (All three have to cope with empty input.)
>>>
>>>
>>> Index: builtins.c
>>> ===================================================================
>>> RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/builtins.c,v
>>> retrieving revision 1.79
>>> retrieving revision 1.80
>>> diff -u -d -r1.79 -r1.80
>>> --- builtins.c  6 Feb 2008 16:36:28 -0000       1.79
>>> +++ builtins.c  13 Feb 2008 20:54:17 -0000      1.80
>>> @@ -2350,6 +2350,10 @@
>>>  * is not even the right function to use there, because the  
>>> constructors
>>>  * should do their job based on _statically-known namespace  
>>> declarations_,
>>>  * not in-scope declarations.
>>> + *
>>> + * Furthermore a cast from string to xs:QName is only allowed at  
>>> compile
>>> + * time on constant strings. At runtime a cast to xs:QName is only  
>>> allowed
>>> + * for QNames inputs.
>>>  */
>>>  struct PFla_pair_t
>>>  PFbui_fn_resolve_qname (const PFla_op_t *loop, bool ordering,
>>> @@ -2416,22 +2420,34 @@
>>>  struct PFla_pair_t
>>>  PFbui_fn_name (const PFla_op_t *loop, bool ordering, struct  
>>> PFla_pair_t *args)
>>>  {
>>> -    (void) loop; (void) ordering;
>>> +    (void) ordering;
>>>
>>> -    return (struct PFla_pair_t) {
>>> -        .rel = project (
>>> -                   fun_1to1 (
>>> -                       project (args[0].rel,
>>> -                                proj (att_iter, att_iter),
>>> -                                proj (att_pos, att_pos),
>>> -                                proj (att_item, att_item)),
>>> -                       alg_fun_fn_name,
>>> -                       att_res,
>>> -                       attlist(att_item)),
>>> -                   proj (att_iter, att_iter),
>>> -                   proj (att_pos, att_pos),
>>> -                   proj (att_item, att_res)),
>>> -        .frag = PFla_empty_set() };
>>> +    PFla_op_t *strings = project (
>>> +                             fun_1to1 (
>>> +                                 project (args[0].rel,
>>> +                                          proj (att_iter, att_iter),
>>> +                                          proj (att_pos, att_pos),
>>> +                                          proj (att_item,  
>>> att_item)),
>>> +                                 alg_fun_fn_name,
>>> +                                 att_res,
>>> +                                 attlist(att_item)),
>>> +                             proj (att_iter, att_iter),
>>> +                             proj (att_pos, att_pos),
>>> +                             proj (att_item, att_res));
>>> +
>>> +    PFla_op_t *res = disjunion (
>>> +                         strings,
>>> +                         attach (
>>> +                             attach (
>>> +                                 difference (
>>> +                                     loop,
>>> +                                     project (
>>> +                                         strings,
>>> +                                         proj (att_iter,  
>>> att_iter))),
>>> +                                 att_pos, lit_nat (1)),
>>> +                             att_item, lit_str ("")));
>>> +
>>> +    return (struct PFla_pair_t) { .rel = res, .frag =  
>>> PFla_empty_set() };
>>>  }
>>>
>>>  /* ------------------- */
>>> @@ -2442,22 +2458,34 @@
>>>  PFbui_fn_local_name (const PFla_op_t *loop, bool ordering,
>>>                      struct PFla_pair_t *args)
>>>  {
>>> -    (void) loop; (void) ordering;
>>> +    (void) ordering;
>>>
>>> -    return (struct PFla_pair_t) {
>>> -        .rel = project (
>>> -                   fun_1to1 (
>>> -                       project (args[0].rel,
>>> -                                proj (att_iter, att_iter),
>>> -                                proj (att_pos, att_pos),
>>> -                                proj (att_item, att_item)),
>>> -                       alg_fun_fn_local_name,
>>> -                       att_res,
>>> -                       attlist(att_item)),
>>> -                   proj (att_iter, att_iter),
>>> -                   proj (att_pos, att_pos),
>>> -                   proj (att_item, att_res)),
>>> -        .frag = args[0].frag };
>>> +    PFla_op_t *strings = project (
>>> +                             fun_1to1 (
>>> +                                 project (args[0].rel,
>>> +                                          proj (att_iter, att_iter),
>>> +                                          proj (att_pos, att_pos),
>>> +                                          proj (att_item,  
>>> att_item)),
>>> +                                 alg_fun_fn_local_name,
>>> +                                 att_res,
>>> +                                 attlist(att_item)),
>>> +                             proj (att_iter, att_iter),
>>> +                             proj (att_pos, att_pos),
>>> +                             proj (att_item, att_res));
>>> +
>>> +    PFla_op_t *res = disjunion (
>>> +                         strings,
>>> +                         attach (
>>> +                             attach (
>>> +                                 difference (
>>> +                                     loop,
>>> +                                     project (
>>> +                                         strings,
>>> +                                         proj (att_iter,  
>>> att_iter))),
>>> +                                 att_pos, lit_nat (1)),
>>> +                             att_item, lit_str ("")));
>>> +
>>> +    return (struct PFla_pair_t) { .rel = res, .frag =  
>>> PFla_empty_set() };
>>>  }
>>>
>>>  /* --------------------- */
>>> @@ -2468,22 +2496,34 @@
>>>  PFbui_fn_namespace_uri (const PFla_op_t *loop, bool ordering,
>>>                         struct PFla_pair_t *args)
>>>  {
>>> -    (void) loop; (void) ordering;
>>> +    (void) ordering;
>>>
>>> -    return (struct PFla_pair_t) {
>>> -        .rel = project (
>>> -                   fun_1to1 (
>>> -                       project (args[0].rel,
>>> -                                proj (att_iter, att_iter),
>>> -                                proj (att_pos, att_pos),
>>> -                                proj (att_item, att_item)),
>>> -                       alg_fun_fn_namespace_uri,
>>> -                       att_res,
>>> -                       attlist(att_item)),
>>> -                   proj (att_iter, att_iter),
>>> -                   proj (att_pos, att_pos),
>>> -                   proj (att_item, att_res)),
>>> -        .frag = args[0].frag };
>>> +    PFla_op_t *strings = project (
>>> +                             fun_1to1 (
>>> +                                 project (args[0].rel,
>>> +                                          proj (att_iter, att_iter),
>>> +                                          proj (att_pos, att_pos),
>>> +                                          proj (att_item,  
>>> att_item)),
>>> +                                 alg_fun_fn_namespace_uri,
>>> +                                 att_res,
>>> +                                 attlist(att_item)),
>>> +                             proj (att_iter, att_iter),
>>> +                             proj (att_pos, att_pos),
>>> +                             proj (att_item, att_res));
>>> +
>>> +    PFla_op_t *res = disjunion (
>>> +                         strings,
>>> +                         attach (
>>> +                             attach (
>>> +                                 difference (
>>> +                                     loop,
>>> +                                     project (
>>> +                                         strings,
>>> +                                         proj (att_iter,  
>>> att_iter))),
>>> +                                 att_pos, lit_nat (1)),
>>> +                             att_item, lit_str ("")));
>>> +
>>> +    return (struct PFla_pair_t) { .rel = res, .frag =  
>>> PFla_empty_set() };
>>>  }
>>>
>>>  /* --------------- */
>>>
>>>
>>> -------------------------------------------------------------------------
>>> This SF.net email is sponsored by: Microsoft
>>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>>> _______________________________________________
>>> Monetdb-pf-checkins mailing list
>>> Monetdb-pf-checkins at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins
>>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Microsoft
>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>> _______________________________________________
>> Monetdb-developers mailing list
>> Monetdb-developers at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/monetdb-developers
> 

-- 
Jan Rittinger
Database Systems
Technische Universität München (Germany)
http://www-db.in.tum.de/~rittinge/




More information about the developers-list mailing list