Update of /cvsroot/monetdb/pathfinder/compiler/debug
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23023/compiler/debug

Modified Files:
      Tag: PF_ROX
        logdebug.c physdebug.c 
Log Message:
propagated changes of Wednesday Jan 30 2008 - Saturday Feb 09 2008
from the development trunk to the PF_ROX branch


Index: logdebug.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/debug/logdebug.c,v
retrieving revision 1.89
retrieving revision 1.89.2.1
diff -u -d -r1.89 -r1.89.2.1
--- logdebug.c  18 Jan 2008 16:11:37 -0000      1.89
+++ logdebug.c  9 Feb 2008 08:40:29 -0000       1.89.2.1
@@ -44,6 +44,7 @@
 #include "mem.h"
 #include "prettyp.h"
 #include "oops.h"
+#include "subtyping.h" /* step printing */
 #include "pfstrings.h"
 
 /** Node names to print out for all the Algebra tree nodes. */
@@ -243,7 +244,7 @@
             break;
 
         case aat_qname:
-            PFarray_printf (s, "%s", PFqname_str (a.val.qname));
+            PFarray_printf (s, "%s", PFesc_string (PFqname_str (a.val.qname)));
             break;
 
         default:
@@ -292,9 +293,13 @@
                "true" : "false");
     else if (a.type == aat_qname)
         PFarray_printf (
-           s, "<value type=\"%s\">%s</value>",
+           s, "<value type=\"%s\">"
+              "<qname prefix=\"%s\" uri=\"%s\" local=\"%s\"/>"
+              "</value>",
            PFalg_simple_type_str (a.type),
-           PFqname_str (a.val.qname));
+           PFqname_prefix (a.val.qname),
+           PFqname_uri (a.val.qname),
+           PFqname_loc (a.val.qname));
     else
         PFarray_printf (s, "<value type=\"node\"/>");
 
@@ -603,6 +608,7 @@
         case la_num_gt:
         case la_bool_and:
         case la_bool_or:
+        case la_to:
             PFarray_printf (dot, "%s (%s:<%s, %s>)", a_id[n->kind],
                             PFatt_str (n->sem.binary.res),
                             PFatt_str (n->sem.binary.att1),
@@ -615,15 +621,6 @@
                             PFatt_str (n->sem.unary.att));
            break;
 
-        case la_to:
-            PFarray_printf (dot, "%s (%s:<%s,%s>/%s)",
-                            a_id[n->kind],
-                            PFatt_str (n->sem.to.res),
-                            PFatt_str (n->sem.to.att1),
-                            PFatt_str (n->sem.to.att2),
-                            PFatt_str (n->sem.to.part));
-           break;
-
         case la_avg:
         case la_max:
         case la_min:
@@ -812,14 +809,10 @@
         }   break;
 
         case la_doc_tbl:
-            PFarray_printf (dot, "%s (%s, %s%s%s)", 
+            PFarray_printf (dot, "%s (%s:<%s>)", 
                             a_id[n->kind],
-                            PFatt_str (n->sem.doc_tbl.iter),
-                            PFatt_str (n->sem.doc_tbl.item_res),
-                            n->sem.doc_tbl.item_res != n->sem.doc_tbl.item
-                            ? ":" : "",
-                            n->sem.doc_tbl.item_res != n->sem.doc_tbl.item
-                            ? PFatt_str (n->sem.doc_tbl.item) : "");
+                            PFatt_str (n->sem.doc_tbl.res),
+                            PFatt_str (n->sem.doc_tbl.att));
             break;
 
         case la_doc_access:
@@ -1782,6 +1775,7 @@
         case la_num_gt:
         case la_bool_and:
         case la_bool_or:
+        case la_to:
             PFarray_printf (xml,
                             "    <content>\n"
                             "      <column name=\"%s\" new=\"true\"/>\n"
@@ -1805,23 +1799,6 @@
                             PFatt_str (n->sem.unary.att));
             break;
 
-        case la_to:
-            PFarray_printf (xml,
-                            "    <content>\n"
-                            "      <column name=\"%s\" new=\"true\"/>\n"
-                            "      <column name=\"%s\" new=\"false\""
-                                         " function=\"start\"/>\n"
-                            "      <column name=\"%s\" new=\"false\""
-                                         " function=\"end\"/>\n"
-                            "      <column name=\"%s\" new=\"false\""
-                                         " function=\"partition\"/>\n"
-                            "    </content>\n",
-                            PFatt_str (n->sem.to.res),
-                            PFatt_str (n->sem.to.att1),
-                            PFatt_str (n->sem.to.att2),
-                            PFatt_str (n->sem.to.part));
-            break;
-
         case la_avg:
         case la_max:
         case la_min:
@@ -1934,6 +1911,13 @@
         case la_step_join:
         case la_guide_step:
         case la_guide_step_join:
+        {
+            PFty_t ty     = n->sem.step.ty;
+            char  *kind   = NULL,
+                  *prefix = NULL,
+                  *uri    = NULL,
+                  *local  = NULL;
+            
             PFarray_printf (xml, "    <content>\n      <step axis=\"");
                 
             /* print out XPath axis */
@@ -1943,7 +1927,7 @@
                     PFarray_printf (xml, "ancestor");
                     break;
                 case alg_anc_s:
-                    PFarray_printf (xml, "anc-or-self");
+                    PFarray_printf (xml, "ancestor-or-self");
                     break;
                 case alg_attr:
                     PFarray_printf (xml, "attribute");
@@ -1955,13 +1939,13 @@
                     PFarray_printf (xml, "descendant");
                     break;
                 case alg_desc_s:
-                    PFarray_printf (xml, "desc-or-self");
+                    PFarray_printf (xml, "descendant-or-self");
                     break;
                 case alg_fol:
                     PFarray_printf (xml, "following");
                     break;
                 case alg_fol_s:
-                    PFarray_printf (xml, "fol-sibling");
+                    PFarray_printf (xml, "following-sibling");
                     break;
                 case alg_par:
                     PFarray_printf (xml, "parent");
@@ -1970,7 +1954,7 @@
                     PFarray_printf (xml, "preceding");
                     break;
                 case alg_prec_s:
-                    PFarray_printf (xml, "prec-sibling");
+                    PFarray_printf (xml, "preceding-sibling");
                     break;
                 case alg_self:
                     PFarray_printf (xml, "self");
@@ -1979,7 +1963,144 @@
                         "unknown XPath axis in dot output");
             }
 
-            PFarray_printf (xml, "\" type=\"%s\"", PFty_str (n->sem.step.ty));
+            if (PFty_subtype (ty, PFty_xs_anyAttribute ())) {
+                
+                /* This is a test for attribute nodes */
+                kind = "attribute";
+
+                /* Is it just a generic attribute kind test?
+                   (e.g. .../attribute()) */
+                if (PFty_subtype (PFty_xs_anyAttribute (), ty))
+                    ;
+                /* Is it a test on attribute kind and local name only? */
+                else if (PFty_subtype (
+                            PFty_attr (
+                                PFqname (PFns_wild,
+                                         PFqname_loc (
+                                             PFty_name (PFty_defn (ty)))),
+                                PFty_xs_anySimpleType ()),
+                            ty))
+                    local = PFqname_loc (PFty_name (PFty_defn (ty)));
+                /* Or maybe a test on attribute kind and namespace only? */
+                else if (PFty_subtype (
+                            PFty_attr (
+                                PFqname (
+                                    PFqname_ns (PFty_name (PFty_defn (ty))),
+                                    NULL),
+                                PFty_xs_anySimpleType ()),
+                            ty)) {
+                    prefix = PFqname_prefix (PFty_name (PFty_defn (ty)));
+                    uri    = PFqname_uri (PFty_name (PFty_defn (ty)));
+                }
+                /* A test on attribute kind and full QName? */
+                else if (PFty_subtype (
+                            PFty_attr (PFty_name (PFty_defn (ty)),
+                                       PFty_xs_anySimpleType ()),
+                            ty)) {
+                    prefix = PFqname_prefix (PFty_name (PFty_defn (ty)));
+                    uri    = PFqname_uri (PFty_name (PFty_defn (ty)));
+                    local = PFqname_loc (PFty_name (PFty_defn (ty)));
+                }
+                /*
+                 * If we couldn't figure out what attribute test we got,
+                 * give up.
+                 *
+                 * NOTE: The surface language actually allows such tests. We
+                 *       just cannot implement them (yet):
+                 *
+                 *        doc("foo")/attribute::attribute(shoeSize, xs:integer)
+                 */
+                else
+                    PFoops (OOPS_FATAL,
+                            "Problem with an XPath step: cannot evaluate "
+                            "node test `%s'", PFty_str (ty));
+            }
+            else if (PFty_subtype (ty, PFty_xs_anyElement ())) {
+
+                /* This is a test for element nodes */
+                kind = "element";
+
+                /* Is it just a generic element kind test?
+                   (e.g. .../element()) */
+                if (PFty_subtype (PFty_xs_anyElement (), ty))
+                    ;
+                /* Is it a test on element kind and local name only? */
+                else if (PFty_subtype (
+                            PFty_elem (
+                                PFqname (PFns_wild,
+                                         PFqname_loc (
+                                             PFty_name (PFty_defn (ty)))),
+                                PFty_xs_anyType ()),
+                            ty))
+                    local = PFqname_loc (PFty_name (PFty_defn (ty)));
+                /* Or maybe a test on element kind and namespace only? */
+                else if (PFty_subtype (
+                            PFty_elem (
+                                PFqname (
+                                    PFqname_ns (PFty_name (PFty_defn (ty))),
+                                                NULL),
+                                       PFty_xs_anyType ()),
+                            ty)) {
+                    prefix = PFqname_prefix (PFty_name (PFty_defn (ty)));
+                    uri    = PFqname_uri (PFty_name (PFty_defn (ty)));
+                }
+                /* A test on element kind and full QName? */
+                else if (PFty_subtype (
+                            PFty_elem (PFty_name (PFty_defn (ty)),
+                                       PFty_xs_anyType ()),
+                            ty)) {
+                    prefix = PFqname_prefix (PFty_name (PFty_defn (ty)));
+                    uri    = PFqname_uri (PFty_name (PFty_defn (ty)));
+                    local = PFqname_loc (PFty_name (PFty_defn (ty)));
+                }
+                /*
+                 * If we couldn't figure out what element test we got, give up.
+                 *
+                 * NOTE: The surface language actually allows such tests. We
+                 *       just cannot implement them (yet):
+                 *
+                 *        doc("foo")/child::element(shoeSize, xs:integer)
+                 */
+                else
+                    PFoops (OOPS_FATAL,
+                            "Problem with an XPath step: cannot evaluate "
+                            "node test `%s'", PFty_str (ty));
+            }
+            else if (PFty_subtype (ty, PFty_text ())) {
+                /* This is a test for text nodes */
+                kind = "textnode";
+            }
+            else if (PFty_subtype (ty, PFty_comm ())) {
+                /* This is a test for comment nodes */
+                kind = "comment";
+            }
+            else if (PFty_subtype (ty, PFty_pi (NULL))) {
+                /* This is a test for processing-instruction nodes */
+                kind = "processing-instruction";
+
+                /* lookup target if any */
+                if (!PFty_subtype (PFty_pi (NULL), ty))
+                    local = PFqname_loc (PFty_name (PFty_defn (ty)));
+            }
+            else if (PFty_subtype (PFty_xs_anyNode (), ty)) {
+                /* If all these cases did not apply,
+                   it is probably a node() test. */
+                kind = "node";
+            }
+            /* If we still couldn't find out, we probably need to give up. */
+            else
+                PFoops (OOPS_FATAL,
+                        "Problem with an XPath step: cannot evaluate "
+                        "node test `%s'", PFty_str (ty));
+
+            PFarray_printf (xml, "\" kind=\"%s\"", kind);
+            if (prefix) {
+                PFarray_printf (xml, " prefix=\"%s\"", prefix);
+                PFarray_printf (xml, " uri=\"%s\"", uri);
+            }
+            if (local) {
+                PFarray_printf (xml, " name=\"%s\"", local);
+            }
             
             if (n->kind == la_guide_step || n->kind == la_guide_step_join) {
                 bool first = true;
@@ -2013,7 +2134,7 @@
                                 "    </content>\n",
                                 PFatt_str (n->sem.step.item_res),
                                 PFatt_str (n->sem.step.item));
-            break;
+        }   break;
 
         case la_doc_index_join:
         {    
@@ -2043,12 +2164,10 @@
             PFarray_printf (xml,
                             "    <content>\n"
                             "      <column name=\"%s\" new=\"true\"/>\n"
-                            "      <column name=\"%s\" function=\"iter\"/>\n"
-                            "      <column name=\"%s\" function=\"item\"/>\n"
+                            "      <column name=\"%s\" new=\"false\"/>\n"
                             "    </content>\n",
-                            PFatt_str (n->sem.doc_tbl.item_res),
-                            PFatt_str (n->sem.doc_tbl.iter),
-                            PFatt_str (n->sem.doc_tbl.item));
+                            PFatt_str (n->sem.doc_tbl.res),
+                            PFatt_str (n->sem.doc_tbl.att));
             break;
 
         case la_doc_access:

Index: physdebug.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/debug/physdebug.c,v
retrieving revision 1.50
retrieving revision 1.50.2.1
diff -u -d -r1.50 -r1.50.2.1
--- physdebug.c 14 Jan 2008 14:03:28 -0000      1.50
+++ physdebug.c 9 Feb 2008 08:40:29 -0000       1.50.2.1
@@ -83,6 +83,7 @@
     , [pa_bool_not]        = "NOT"
     , [pa_bool_and_atom]   = "AND (atom)"
     , [pa_bool_or_atom]    = "OR (atom)"
+    , [pa_to]              = "op:to"
     , [pa_avg]             = "AVG"
     , [pa_min]             = "MAX"
     , [pa_max]             = "MIN"
@@ -139,95 +140,6 @@
     , [pa_string_join]     = "fn:string-join"
 };
 
[...992 lines suppressed...]
-    if (root) {
-
-        /* initialize array to hold dot output */
-        PFarray_t *xml = PFarray (sizeof (char));
-
-        PFarray_printf (xml, "<physical_query_plan>\n");
-
-        root->node_id = 1;
-        pa_xml (xml, root, root->node_id + 1);
-        PFpa_dag_reset (root);
-        reset_node_id (root);
-        PFpa_dag_reset (root);
-
-        PFarray_printf (xml, "</physical_query_plan>\n");
-        /* put content of array into file */
-        fprintf (f, "%s", (char *) xml->base);
-    }
-}
-
 /* vim:set shiftwidth=4 expandtab: */


-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to