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

Lefteris lsidir at gmail.com
Thu Feb 14 15:37:34 CET 2008


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
>




More information about the developers-list mailing list