Update of /cvsroot/monetdb/pathfinder/compiler/algebra/prop
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24398/algebra/prop

Modified Files:
        prop_composite_key.c prop_const.c prop_dom.c prop_dom_nat.c 
        prop_guide.c prop_key.c prop_level.c prop_ocol.c 
        prop_ori_names.c prop_trace_names.c prop_unq_names.c 
Log Message:
-- Extended the PFarray_t type to store a ``clear'' bit
   that ensures that memory is erased during allocation.

-- Split up PFarray (size_t itemsize) into four variants

   o PFarray_default (size_t itemsize),
   o PFcarray_default (size_t itemsize),
   o PFarray (size_t itemsize, unsigned int slots), and
   o PFcarray (size_t itemsize, unsigned int slots)

   where the '_default' variants are currently seeded with 20 slots,
   the 'c' variants provide a cleared chunk of memory, and the slots
   argument indicates how much memory is initially allocated (#slots).

-- Added memory debugging support for arrays:
   If the environment variable ``PF_DEBUG_MEMORY'' is set the memory
   reallocation for arrays reports the function that requires more
   memory (and thus more slots for the storage).


REMARK: Currently the inital array sizes (#slots) are good guesses
        about the upper limit of required slots. Anybody adding new
        PFarray calls may start with a very low value. This way the
        the debug printing may report (reallocation) problems in
        comparison to a very high initial value whose consequences
        might not be directly visible.



Index: prop_unq_names.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_unq_names.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- prop_unq_names.c    18 Feb 2008 15:54:42 -0000      1.31
+++ prop_unq_names.c    17 Mar 2008 17:41:21 -0000      1.32
@@ -42,6 +42,8 @@
 /* Easily access subtree-parts */
 #include "child_mnemonic.h"
 
+#define ARRAY_SIZE(n) ((n)->schema.count > 10 ? (n)->schema.count : 10)
+
 /* worker for PFprop_unq_name* */
 static PFalg_att_t
 find_unq_name (PFarray_t *np_list, PFalg_att_t attr)
@@ -175,8 +177,10 @@
             PFarray_t *left_np_list, *right_np_list;
 
             /* initialize left and right name pair list */
-            n->prop->l_name_pairs = PFarray (sizeof (name_pair_t));
-            n->prop->r_name_pairs = PFarray (sizeof (name_pair_t));
+            n->prop->l_name_pairs = PFarray (sizeof (name_pair_t),
+                                             ARRAY_SIZE(L(n)));
+            n->prop->r_name_pairs = PFarray (sizeof (name_pair_t),
+                                             ARRAY_SIZE(R(n)));
 
             left_np_list  = n->prop->l_name_pairs;
             right_np_list = n->prop->r_name_pairs;
@@ -235,8 +239,10 @@
                 join_unq = att2_unq;
 
             /* initialize left and right name pair list */
-            n->prop->l_name_pairs = PFarray (sizeof (name_pair_t));
-            n->prop->r_name_pairs = PFarray (sizeof (name_pair_t));
+            n->prop->l_name_pairs = PFarray (sizeof (name_pair_t),
+                                             ARRAY_SIZE(L(n)));
+            n->prop->r_name_pairs = PFarray (sizeof (name_pair_t),
+                                             ARRAY_SIZE(R(n)));
 
             left_np_list  = n->prop->l_name_pairs;
             right_np_list = n->prop->r_name_pairs;
@@ -315,7 +321,8 @@
             bulk_add_name_pairs (np_list, L(n));
 
             /* make sure to know the name of the right join argument */
-            n->prop->r_name_pairs = PFarray (sizeof (name_pair_t));
+            n->prop->r_name_pairs = PFarray (sizeof (name_pair_t),
+                                             ARRAY_SIZE(R(n)));
             add_name_pair (n->prop->r_name_pairs,
                            n->sem.eqjoin.att2,
                            PFprop_unq_name (R(n)->prop,
@@ -349,8 +356,10 @@
                a list of name pairs for each operand. */
             PFalg_att_t ori, unq, l_unq, r_unq;
 
-            n->prop->l_name_pairs = PFarray (sizeof (name_pair_t));
-            n->prop->r_name_pairs = PFarray (sizeof (name_pair_t));
+            n->prop->l_name_pairs = PFarray (sizeof (name_pair_t),
+                                             ARRAY_SIZE(L(n)));
+            n->prop->r_name_pairs = PFarray (sizeof (name_pair_t),
+                                             ARRAY_SIZE(R(n)));
 
             for (unsigned int i = 0; i < n->schema.count; i++) {
                 ori = n->schema.items[i].name;
@@ -610,7 +619,8 @@
     if (n->prop->name_pairs)
         PFarray_last (n->prop->name_pairs) = 0;
     else
-        n->prop->name_pairs = PFarray (sizeof (name_pair_t));
+        n->prop->name_pairs = PFarray (sizeof (name_pair_t),
+                                       ARRAY_SIZE(n));
 
     n->prop->l_name_pairs = NULL;
     n->prop->r_name_pairs = NULL;

Index: prop_dom_nat.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_dom_nat.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- prop_dom_nat.c      15 Feb 2008 12:15:58 -0000      1.19
+++ prop_dom_nat.c      17 Mar 2008 17:41:18 -0000      1.20
@@ -82,9 +82,9 @@
     /* collect all the super domains for each input */
 
     /* start with the input domains as seed */
-    domains1 = PFarray (sizeof (dom_t));
+    domains1 = PFarray (sizeof (dom_t), 10);
     *(dom_t *) PFarray_add (domains1) = dom1;
-    domains2 = PFarray (sizeof (dom_t));
+    domains2 = PFarray (sizeof (dom_t), 10);
     *(dom_t *) PFarray_add (domains2) = dom2;
 
     for (unsigned int i = PFarray_last (prop->subdoms); i > 0; i--) {
@@ -117,7 +117,7 @@
     }
 
     /* intersect both domain lists */
-    merge_doms = PFarray (sizeof (dom_t));
+    merge_doms = PFarray (sizeof (dom_t), 10);
     for (unsigned int i = 0; i < PFarray_last (domains1); i++) {
         dom1 = *(dom_t *) PFarray_at (domains1, i);
         for (unsigned int j = 0; j < PFarray_last (domains2); j++) {
@@ -938,17 +938,24 @@
     if (n->prop->domains)
         PFarray_last (n->prop->domains) = 0;
     else
-        n->prop->domains   = PFarray (sizeof (dom_pair_t));
+        /* prepare the property for 10 columns */
+        n->prop->domains   = PFarray (sizeof (dom_pair_t), 10);
 
-    if (n->prop->l_domains)
-        PFarray_last (n->prop->l_domains) = 0;
-    else
-        n->prop->l_domains = PFarray (sizeof (dom_pair_t));
+    if (L(n)) {
+        if (n->prop->l_domains)
+            PFarray_last (n->prop->l_domains) = 0;
+        else
+            /* prepare the property for 10 columns */
+            n->prop->l_domains = PFarray (sizeof (dom_pair_t), 10);
+    }
 
-    if (n->prop->r_domains)
-        PFarray_last (n->prop->r_domains) = 0;
-    else
-        n->prop->r_domains = PFarray (sizeof (dom_pair_t));
+    if (R(n)) {
+        if (n->prop->r_domains)
+            PFarray_last (n->prop->r_domains) = 0;
+        else
+            /* prepare the property for 10 columns */
+            n->prop->r_domains = PFarray (sizeof (dom_pair_t), 10);
+    }
 
     /* copy all children domains */
     copy_child_domains (n);
@@ -969,8 +976,8 @@
      * Initialize domain property inference with an empty domain
      * relation list,
      */
-    PFarray_t *subdoms  = PFarray (sizeof (subdom_t));
-    PFarray_t *disjdoms = PFarray (sizeof (disjdom_t));
+    PFarray_t *subdoms  = PFarray (sizeof (subdom_t), 50);
+    PFarray_t *disjdoms = PFarray (sizeof (disjdom_t), 50);
 
     prop_infer (root, subdoms, disjdoms, 2);
 

Index: prop_const.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_const.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- prop_const.c        15 Feb 2008 12:15:58 -0000      1.37
+++ prop_const.c        17 Mar 2008 17:41:18 -0000      1.38
@@ -131,6 +131,7 @@
 PFprop_const_val_left (const PFprop_t *prop, PFalg_att_t attr)
 {
     assert (prop);
+    assert (prop->l_constants);
 
     return const_val (prop->l_constants, attr);
 }
@@ -145,6 +146,7 @@
 PFprop_const_val_right (const PFprop_t *prop, PFalg_att_t attr)
 {
     assert (prop);
+    assert (prop->r_constants);
 
     return const_val (prop->r_constants, attr);
 }
@@ -767,17 +769,24 @@
     if (n->prop->constants)
         PFarray_last (n->prop->constants) = 0;
     else
-        n->prop->constants   = PFarray (sizeof (const_t));
+        /* prepare the property for 10 constants */
+        n->prop->constants   = PFarray (sizeof (const_t), 10);
 
-    if (n->prop->l_constants)
-        PFarray_last (n->prop->l_constants) = 0;
-    else
-        n->prop->l_constants = PFarray (sizeof (const_t));
+    if (L(n)) {
+        if (n->prop->l_constants)
+            PFarray_last (n->prop->l_constants) = 0;
+        else
+            /* prepare the property for 10 constants */
+            n->prop->l_constants = PFarray (sizeof (const_t), 10);
+    }
 
-    if (n->prop->r_constants)
-        PFarray_last (n->prop->r_constants) = 0;
-    else
-        n->prop->r_constants = PFarray (sizeof (const_t));
+    if (R(n)) {
+        if (n->prop->r_constants)
+            PFarray_last (n->prop->r_constants) = 0;
+        else
+            /* prepare the property for 10 constants */
+            n->prop->r_constants = PFarray (sizeof (const_t), 10);
+    }
 
     /* infer information on constant columns */
     infer_const (n);

Index: prop_ocol.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_ocol.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- prop_ocol.c 1 Mar 2008 11:47:07 -0000       1.52
+++ prop_ocol.c 17 Mar 2008 17:41:19 -0000      1.53
@@ -154,7 +154,8 @@
 
         case la_project:
         {
-            PFarray_t *proj_list = PFarray (sizeof (PFalg_proj_t));
+            PFarray_t *proj_list = PFarray (sizeof (PFalg_proj_t),
+                                            n->sem.proj.count);
 
             /* prune projection list according to
                the ocols of its argument */

Index: prop_guide.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_guide.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- prop_guide.c        25 Feb 2008 08:58:42 -0000      1.24
+++ prop_guide.c        17 Mar 2008 17:41:18 -0000      1.25
@@ -95,7 +95,7 @@
     /* initialize new PF_guide_mapping element */
     *new_guide_mapping = (PFguide_mapping_t) {
         .column = guide_mapping->column,
-        .guide_list = PFarray(sizeof(PFguide_tree_t**)),
+        .guide_list = PFarray(sizeof(PFguide_tree_t**), 20),
     };
 
     /* insert all PFguide_tree_t** elements in the new list */
@@ -118,7 +118,7 @@
         return NULL;
 
     /* new list that will be the copy of guide_mapping list */
-    PFarray_t *new_guide_mapping_list = PFarray(sizeof(PFguide_mapping_t**));
+    PFarray_t *new_guide_mapping_list = PFarray(sizeof(PFguide_mapping_t**), 
20);
     /* PFguide_mapping_t elements to copy */
     PFguide_mapping_t *guide_mapping_element = NULL;
 
@@ -194,7 +194,7 @@
 {
     assert(n);
 
-    PFarray_t      *ancestors = PFarray(sizeof(PFguide_tree_t**));
+    PFarray_t      *ancestors = PFarray(sizeof(PFguide_tree_t**), 20);
     PFguide_tree_t *node      = n->parent;
 
     /* compute ancestors */
@@ -238,7 +238,7 @@
 static PFarray_t *
 getDescendantFromGuide(PFguide_tree_t *n, PFalg_step_spec_t spec)
 {
-    PFarray_t *descendant = PFarray (sizeof (PFguide_tree_t **));
+    PFarray_t *descendant = PFarray (sizeof (PFguide_tree_t **), 100);
     getDescendantFromGuideRec (n, spec, descendant);
     return descendant;
 }
@@ -302,7 +302,7 @@
 
     /* Create new array of PFguide_mapping_t*/
     if(guide_mapping_list == NULL)
-        guide_mapping_list = PFarray(sizeof(PFguide_mapping_t**));
+        guide_mapping_list = PFarray(sizeof(PFguide_mapping_t**), 20);
 
     /* look up if the column just exist */
     for(unsigned int i = 0; i < PFarray_last(guide_mapping_list); i++) {
@@ -327,7 +327,7 @@
     guide_mapping = (PFguide_mapping_t*)PFmalloc(sizeof(PFguide_mapping_t));
     *guide_mapping = (PFguide_mapping_t) {
         .column = column,
-        .guide_list = PFarray(sizeof(PFguide_tree_t**)),
+        .guide_list = PFarray(sizeof(PFguide_tree_t**), 20),
     };
 
     /* insert values in PFguide_mapping_t */
@@ -377,7 +377,7 @@
     assert(PROP(L(n)));
 
     PFarray_t *guide_mapping_list = MAPPING_LIST(L(n)),
-            *new_guide_mapping_list = PFarray(sizeof(PFguide_mapping_t**));
+            *new_guide_mapping_list = PFarray(sizeof(PFguide_mapping_t**), 20);
     PFguide_mapping_t *guide_mapping = NULL;
     PFalg_att_t new_column, old_column;
 
@@ -425,7 +425,7 @@
     PFguide_mapping_t  *guide_mapping = NULL;
     PFarray_t *guide_list = NULL;
     /* array without duplicate elements*/
-    PFarray_t  *new_guide_list = PFarray(sizeof(PFguide_tree_t**));
+    PFarray_t  *new_guide_list = PFarray(sizeof(PFguide_tree_t**), 20);
     PFguide_tree_t  *element = NULL, *element2 = NULL;
     bool add_element_bool = true; /* if true add the guide */
 
@@ -512,7 +512,7 @@
     /* get array of guide nodes */
     guide_list = guide_mapping->guide_list;
     if(guide_list == NULL) {
-        MAPPING_LIST(n) = PFarray(sizeof(PFguide_mapping_t**));;
+        MAPPING_LIST(n) = PFarray(sizeof(PFguide_mapping_t**), 20);
         return;
     }
 

Index: prop_dom.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_dom.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- prop_dom.c  16 Feb 2008 19:42:41 -0000      1.52
+++ prop_dom.c  17 Mar 2008 17:41:18 -0000      1.53
@@ -278,7 +278,7 @@
      * matches one item of the subdomains list, but the
      * expected result domain differs.
      */
-    subdomains = PFarray (sizeof (dom_t));
+    subdomains = PFarray (sizeof (dom_t), 50);
     *(dom_t *) PFarray_add (subdomains) = in_subdom;
 
     for (unsigned int i = PFarray_last (prop->subdoms); i > 0; i--) {
@@ -334,9 +334,9 @@
     /* collect all the super domains for each input */
 
     /* start with the input domains as seed */
-    domains1 = PFarray (sizeof (dom_t));
+    domains1 = PFarray (sizeof (dom_t), 10);
     *(dom_t *) PFarray_add (domains1) = dom1;
-    domains2 = PFarray (sizeof (dom_t));
+    domains2 = PFarray (sizeof (dom_t), 10);
     *(dom_t *) PFarray_add (domains2) = dom2;
 
     for (unsigned int i = PFarray_last (prop->subdoms); i > 0; i--) {
@@ -369,7 +369,7 @@
     }
 
     /* intersect both domain lists */
-    merge_doms = PFarray (sizeof (dom_t));
+    merge_doms = PFarray (sizeof (dom_t), 10);
     for (unsigned int i = 0; i < PFarray_last (domains1); i++) {
         dom1 = *(dom_t *) PFarray_at (domains1, i);
         for (unsigned int j = 0; j < PFarray_last (domains2); j++) {
@@ -1229,17 +1229,24 @@
     if (n->prop->domains)
         PFarray_last (n->prop->domains) = 0;
     else
-        n->prop->domains   = PFarray (sizeof (dom_pair_t));
+        /* prepare the property for 10 columns */
+        n->prop->domains   = PFarray (sizeof (dom_pair_t), 10);
 
-    if (n->prop->l_domains)
-        PFarray_last (n->prop->l_domains) = 0;
-    else
-        n->prop->l_domains = PFarray (sizeof (dom_pair_t));
+    if (L(n)) {
+        if (n->prop->l_domains)
+            PFarray_last (n->prop->l_domains) = 0;
+        else
+            /* prepare the property for 10 columns */
+            n->prop->l_domains = PFarray (sizeof (dom_pair_t), 10);
+    }
 
-    if (n->prop->r_domains)
-        PFarray_last (n->prop->r_domains) = 0;
-    else
-        n->prop->r_domains = PFarray (sizeof (dom_pair_t));
+    if (R(n)) {
+        if (n->prop->r_domains)
+            PFarray_last (n->prop->r_domains) = 0;
+        else
+            /* prepare the property for 10 columns */
+            n->prop->r_domains = PFarray (sizeof (dom_pair_t), 10);
+    }
 
     /* copy all children domains */
     copy_child_domains (n);
@@ -1260,8 +1267,8 @@
      * Initialize domain property inference with an empty domain
      * relation list,
      */
-    PFarray_t *subdoms  = PFarray (sizeof (subdom_t));
-    PFarray_t *disjdoms = PFarray (sizeof (disjdom_t));
+    PFarray_t *subdoms  = PFarray (sizeof (subdom_t), 50);
+    PFarray_t *disjdoms = PFarray (sizeof (disjdom_t), 50);
 
     prop_infer (root, subdoms, disjdoms, 2);
 

Index: prop_composite_key.c
===================================================================
RCS file: 
/cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_composite_key.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- prop_composite_key.c        16 Feb 2008 19:42:41 -0000      1.15
+++ prop_composite_key.c        17 Mar 2008 17:41:17 -0000      1.16
@@ -782,7 +782,8 @@
     if (n->prop->ckeys)
         PFarray_last (n->prop->ckeys) = 0;
     else
-        n->prop->ckeys   = PFarray (sizeof (PFalg_att_t));
+        /* prepare the property for 10 composite keys */
+        n->prop->ckeys   = PFarray (sizeof (PFalg_att_t), 10);
 
     /* infer information on composite key columns */
     infer_ckey (n);

Index: prop_level.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_level.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- prop_level.c        16 Feb 2008 19:42:41 -0000      1.15
+++ prop_level.c        17 Mar 2008 17:41:19 -0000      1.16
@@ -119,7 +119,7 @@
     assert (prop);
 
     if (!prop->level_mapping)
-        prop->level_mapping = PFarray (sizeof (level_t));
+        prop->level_mapping = PFarray (sizeof (level_t), 5);
 
     *(level_t *) PFarray_add (prop->level_mapping)
         = (level_t) { .attr = attr, .level = level };

Index: prop_trace_names.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_trace_names.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- prop_trace_names.c  15 Feb 2008 12:15:59 -0000      1.18
+++ prop_trace_names.c  17 Mar 2008 17:41:20 -0000      1.19
@@ -92,6 +92,12 @@
     assert (np_list);
     assert (par_np_list);
 
+    /* we do not trace along fragment edges */
+    if (n->kind == la_frag_union ||
+        n->kind == la_empty_frag ||
+        n->kind == la_fragment)
+        ;
+    else
     /* collect all name pair lists of the parent operators and
        include (possibly) new matching columns in the name pairs list */
     if (!PFarray_last (np_list))
@@ -195,7 +201,7 @@
             unsigned int j;
             /* if we have no additional name pair list then create one */
             if (!n->prop->l_name_pairs)
-               n->prop->l_name_pairs = PFarray (sizeof (name_pair_t));
+               n->prop->l_name_pairs = PFarray (sizeof (name_pair_t), 10);
 
             /* mark all columns that we do not see in the left child
                as unknown */
@@ -472,8 +478,10 @@
     EDGE(n) = 0;
 
     /* reset the name mapping structure */
-    if (n->prop->name_pairs) PFarray_last (n->prop->name_pairs) = 0;
-    else n->prop->name_pairs = PFarray (sizeof (name_pair_t));
+    if (n->prop->name_pairs)
+        PFarray_last (n->prop->name_pairs) = 0;
+    else
+        n->prop->name_pairs = PFarray (sizeof (name_pair_t), 10);
     
     if (n->prop->l_name_pairs) PFarray_last (n->prop->l_name_pairs) = 0;
 }
@@ -489,7 +497,7 @@
 {
     PFalg_attlist_t new_list;
     unsigned int    j;
-    PFarray_t      *map_list = PFarray (sizeof (name_pair_t)),
+    PFarray_t      *map_list = PFarray (sizeof (name_pair_t), list.count),
                    *new_map_list;
 
     /* collect number of incoming edges (parents) */

Index: prop_key.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_key.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- prop_key.c  16 Feb 2008 19:42:41 -0000      1.41
+++ prop_key.c  17 Mar 2008 17:41:18 -0000      1.42
@@ -742,17 +742,21 @@
     if (n->prop->keys)
         PFarray_last (n->prop->keys) = 0;
     else
-        n->prop->keys   = PFarray (sizeof (PFalg_att_t));
+        n->prop->keys   = PFarray (sizeof (PFalg_att_t), 10);
 
-    if (n->prop->l_keys)
-        PFarray_last (n->prop->l_keys) = 0;
-    else
-        n->prop->l_keys = PFarray (sizeof (PFalg_att_t));
+    if (L(n)) {
+        if (n->prop->l_keys)
+            PFarray_last (n->prop->l_keys) = 0;
+        else
+            n->prop->l_keys = PFarray (sizeof (PFalg_att_t), 10);
+    }
 
-    if (n->prop->r_keys)
-        PFarray_last (n->prop->r_keys) = 0;
-    else
-        n->prop->r_keys = PFarray (sizeof (PFalg_att_t));
+    if (R(n)) {
+        if (n->prop->r_keys)
+            PFarray_last (n->prop->r_keys) = 0;
+        else
+            n->prop->r_keys = PFarray (sizeof (PFalg_att_t), 10);
+    }
 
     /* infer information on key columns */
     infer_key (n, with_guide_info);

Index: prop_ori_names.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_ori_names.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- prop_ori_names.c    15 Feb 2008 12:15:59 -0000      1.30
+++ prop_ori_names.c    17 Mar 2008 17:41:19 -0000      1.31
@@ -53,6 +53,8 @@
 /* Easily access subtree-parts */
 #include "child_mnemonic.h"
 
+#define ARRAY_SIZE(n) ((n)->schema.count > 10 ? (n)->schema.count : 10)
+
 /* reuse the icols field to maintain the bitlist of free variables */
 #define FREE(n) ((n)->prop->l_icols)
 /* initial value for lists that encode free variables */
@@ -714,14 +716,27 @@
     EDGE(n) = 0;
 
     /* reset the original name information */
-    if (n->prop->name_pairs) PFarray_last (n->prop->name_pairs) = 0;
-    else n->prop->name_pairs = PFarray (sizeof (name_pair_t));
+    if (n->prop->name_pairs)
+        PFarray_last (n->prop->name_pairs) = 0;
+    else
+        n->prop->name_pairs = PFarray (sizeof (name_pair_t),
+                                       ARRAY_SIZE(n));
 
-    if (n->prop->l_name_pairs) PFarray_last (n->prop->l_name_pairs) = 0;
-    else n->prop->l_name_pairs = PFarray (sizeof (name_pair_t));
+    if (L(n)) {
+        if (n->prop->l_name_pairs)
+            PFarray_last (n->prop->l_name_pairs) = 0;
+        else
+            n->prop->l_name_pairs = PFarray (sizeof (name_pair_t),
+                                             ARRAY_SIZE(L(n)));
+    }
 
-    if (n->prop->r_name_pairs) PFarray_last (n->prop->r_name_pairs) = 0;
-    else n->prop->r_name_pairs = PFarray (sizeof (name_pair_t));
+    if (R(n)) {
+        if (n->prop->r_name_pairs)
+            PFarray_last (n->prop->r_name_pairs) = 0;
+        else
+            n->prop->r_name_pairs = PFarray (sizeof (name_pair_t),
+                                             ARRAY_SIZE(R(n)));
+    }
 
     /* reset the list of available column names */
     FREE(n) = ALL;
@@ -741,7 +756,7 @@
 
     /* infer new original names property */
     infer_ori_names (root,
-                     PFarray (sizeof (name_pair_t)));
+                     PFarray (sizeof (name_pair_t), 0));
 }
 
 /* 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