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

Modified Files:
        xml2lalg.c 
Log Message:
-- Changed the semantic content of the la_ref_tbl operator.
-- In the semantic content of the la_ref_tbl operator we now store the 
*positions* (w.r.t. the schema) of key attributes instead of their names, so 
that renamings of attribute names (e.g. by some plan optimization phases) don't 
have to be done additionally on this key attribute infos.

Index: xml2lalg.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/xmlimport/xml2lalg.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- xml2lalg.c  6 Dec 2007 08:42:44 -0000       1.4
+++ xml2lalg.c  6 Dec 2007 22:41:33 -0000       1.5
@@ -168,8 +168,8 @@
  * Macro return-type:  PFarray_t* 
  * XPath return-type:  element(key)+
  */
-#define PFLA_KEYINFOS(xpath) \
-            getPFLA_KeyInfos(ctx, nodePtr, xpath)
+#define PFLA_KEYINFOS(xpath, schema) \
+            getPFLA_KeyInfos(ctx, nodePtr, xpath, schema)
 
 
 /**              
@@ -386,7 +386,8 @@
 getPFLA_KeyInfos(
     XML2LALGContext* ctx, 
     xmlNodePtr nodePtr, 
-    const char* xpathExpression);
+    const char* xpathExpression,
+    PFalg_schema_t schema);
 
 PFalg_tuple_t* 
 getPFLA_Tuples(
@@ -765,13 +766,15 @@
                 </table>
              </content>             
             */
+
+            PFalg_schema_t schema = PFLA_SCHEMA("/content/table/column");
                                     
             newAlgNode = PFla_ref_tbl_ 
              (
              A2STR("/content/table/@name"),
-             PFLA_SCHEMA("/content/table/column"),
+             schema,
              AS2STRLST("/content/table/column/@tname"),
-             PFLA_KEYINFOS("/properties/keys/key")
+             PFLA_KEYINFOS("/properties/keys/key", schema)
              );
         }  
         break;
@@ -2359,7 +2362,8 @@
 getPFLA_KeyInfos(
     XML2LALGContext* ctx, 
     xmlNodePtr nodePtr, 
-    const char* xpathExpression)
+    const char* xpathExpression,
+    PFalg_schema_t schema)
 {
     /*
     (<key>
@@ -2367,7 +2371,7 @@
     </key>)+
     */
 
-    PFarray_t * keys = PFarray (sizeof (PFalg_att_t));
+    PFarray_t * keyPositions = PFarray (sizeof (int));
 
 
     xmlXPathObjectPtr keys_xml =  XPATH(xpathExpression);
@@ -2388,7 +2392,24 @@
             char* columnName = 
(char*)xmlXPathCastToString(XPATH2(keyColumn_xml, "/@name"));
             PFalg_att_t keyAttribute = 
ctx->convert2PFLA_attributeName(columnName);
 
-            *(PFalg_att_t *) PFarray_add (keys) = keyAttribute;
+            int keyPos = -1;
+
+            for (unsigned int k = 0; k < schema.count; k++) {
+
+
+                PFalg_schm_item_t schemaItem = schema.items[k];
+                if(schemaItem.name == keyAttribute) 
+                {
+                    keyPos = k;
+                    break;
+                }
+            }
+
+
+            assert(keyPos >= 0);
+
+
+            *(int*) PFarray_add (keyPositions) = keyPos;
 
 
         }
@@ -2397,7 +2418,7 @@
     }             
 
    
-    return keys;
+    return keyPositions;
 
 }
 


-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to