Index: configure.ag =================================================================== RCS file: /cvsroot/monetdb/pathfinder/configure.ag,v retrieving revision 1.83 diff -u -r1.83 configure.ag --- configure.ag 1 Nov 2006 07:17:34 -0000 1.83 +++ configure.ag 1 Nov 2006 20:58:58 -0000 @@ -37,9 +37,6 @@ dnl Check for Monet AM_MONETDB_DEFAULTS() AM_MONETDB_COMPILER() -if test "x$have_c99" != xyes; then - AC_MSG_ERROR([Pathfinder requires a C99 compliant C compiler, but your C compiler does not seem to be C99 compliant.]) -fi AM_MONETDB_TOOLS() AM_MONETDB_OPTIONS() AM_MONETDB_LIBS() Index: compiler/scope.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/scope.c,v retrieving revision 1.10 diff -u -r1.10 scope.c --- compiler/scope.c 19 Jun 2006 08:56:15 -0000 1.10 +++ compiler/scope.c 1 Nov 2006 20:58:58 -0000 @@ -253,9 +253,11 @@ void PFscope_append (PFscope_t *s1, const PFscope_t *s2, bool allow_override) { - for (unsigned int h = 0; h < SCOPE_HASH_SZ; h++) + unsigned int i = 0, h = 0; - for (unsigned int i = 0; i < PFarray_last (s2->hash[h]); i++) { + for (h = 0; h < SCOPE_HASH_SZ; h++) + + for (i = 0; i < PFarray_last (s2->hash[h]); i++) { if (!allow_override && PFscope_lookup ( Index: compiler/algebra/alg_dag.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/alg_dag.c,v retrieving revision 1.4 diff -u -r1.4 alg_dag.c --- compiler/algebra/alg_dag.c 8 Aug 2006 13:42:06 -0000 1.4 +++ compiler/algebra/alg_dag.c 1 Nov 2006 20:58:58 -0000 @@ -39,11 +39,13 @@ static void la_prepare_reset (PFla_op_t *n) { + unsigned int i = 0; + assert (n); if (n->bit_reset) return; - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) la_prepare_reset (n->child[i]); n->bit_reset = true; @@ -53,11 +55,13 @@ static void pa_prepare_reset (PFpa_op_t *n) { + unsigned int i = 0; + assert (n); if (n->bit_reset) return; - for (unsigned int i = 0; i < PFPA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFPA_OP_MAXCHILD && n->child[i]; i++) pa_prepare_reset (n->child[i]); n->bit_reset = true; @@ -68,11 +72,13 @@ static void la_dag_bit_reset (PFla_op_t *n) { + unsigned int i = 0; + assert (n); if (!n->bit_reset) return; - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) la_dag_bit_reset (n->child[i]); n->bit_reset = false; @@ -84,11 +90,13 @@ static void pa_dag_bit_reset (PFpa_op_t *n) { + unsigned int i = 0; + assert (n); if (!n->bit_reset) return; - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) pa_dag_bit_reset (n->child[i]); n->bit_reset = false; @@ -100,11 +108,13 @@ static void in_out_bit_reset (PFla_op_t *n) { + unsigned int i = 0; + assert (n); if (!n->bit_reset) return; - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) in_out_bit_reset (n->child[i]); n->bit_reset = false; @@ -116,11 +126,13 @@ static void in_bit_reset (PFla_op_t *n) { + unsigned int i = 0; + assert (n); if (!n->bit_reset) return; - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) in_bit_reset (n->child[i]); n->bit_reset = false; @@ -131,11 +143,13 @@ static void out_bit_reset (PFla_op_t *n) { + unsigned int i = 0; + assert (n); if (!n->bit_reset) return; - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) out_bit_reset (n->child[i]); n->bit_reset = false; Index: compiler/algebra/algebra_cse.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/algebra_cse.c,v retrieving revision 1.41 diff -u -r1.41 algebra_cse.c --- compiler/algebra/algebra_cse.c 12 Oct 2006 09:02:39 -0000 1.41 +++ compiler/algebra/algebra_cse.c 1 Nov 2006 20:58:58 -0000 @@ -156,6 +156,7 @@ /* now look at semantic content */ switch (a->kind) { + unsigned int i = 0; case la_lit_tbl: case la_empty_tbl: @@ -163,7 +164,7 @@ if (a->schema.count != b->schema.count) return false; - for (unsigned int i = 0; i < a->schema.count; i++) + for (i = 0; i < a->schema.count; i++) if (a->schema.items[i].name != b->schema.items[i].name || a->schema.items[i].type != b->schema.items[i].type) return false; @@ -171,7 +172,7 @@ if (a->sem.lit_tbl.count != b->sem.lit_tbl.count) return false; - for (unsigned int i = 0; i < a->sem.lit_tbl.count; i++) + for (i = 0; i < a->sem.lit_tbl.count; i++) if (!tuple_eq (a->sem.lit_tbl.tuples[i], b->sem.lit_tbl.tuples[i])) return false; @@ -202,7 +203,7 @@ if (a->sem.proj.count != b->sem.proj.count) return false; - for (unsigned int i = 0; i < a->sem.proj.count; i++) + for (i = 0; i < a->sem.proj.count; i++) if (a->sem.proj.items[i].new != b->sem.proj.items[i].new || a->sem.proj.items[i].old != b->sem.proj.items[i].old) return false; @@ -258,7 +259,7 @@ if (a->sem.rownum.attname != b->sem.rownum.attname) return false; - for (unsigned int i = 0; i < a->sem.rownum.sortby.count; i++) + for (i = 0; i < a->sem.rownum.sortby.count; i++) if (a->sem.rownum.sortby.atts[i] != b->sem.rownum.sortby.atts[i]) return false; @@ -418,12 +419,13 @@ la_cse (PFla_op_t *n) { PFarray_t *a; + unsigned int i = 0; /* skip operator if cse has been already applied */ if (SEEN(n)) return n; - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) { + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) { if (n->child[i]->kind == la_dummy) n->child[i] = n->child[i]->child[0]; @@ -445,7 +447,7 @@ = a = PFarray (sizeof (PFla_op_t *)); /* see if we already saw that subexpression */ - for (unsigned int i = 0; i < PFarray_last (a); i++) + for (i = 0; i < PFarray_last (a); i++) if (subexp_eq (n, *(PFla_op_t **) PFarray_at (a, i))) return *(PFla_op_t **) PFarray_at (a, i); Index: compiler/algebra/builtins.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/builtins.c,v retrieving revision 1.40 diff -u -r1.40 builtins.c --- compiler/algebra/builtins.c 19 Jun 2006 08:56:15 -0000 1.40 +++ compiler/algebra/builtins.c 1 Nov 2006 20:58:59 -0000 @@ -84,7 +84,8 @@ PFla_op_t *res = NULL; PFalg_type_t item_types = 0; bool found = false; - for (unsigned int i = 0; i < n->schema.count; i++) { + unsigned int i = 0; + for (i = 0; i < n->schema.count; i++) { if (n->schema.items[i].name == att_item) { found = true; item_types = n->schema.items[i].type; @@ -96,7 +97,7 @@ "attribute `%s' referenced in type switch not found", PFatt_str (att_item)); - for (unsigned int i = 0; i < count; i++) { + for (i = 0; i < count; i++) { PFalg_type_t ty = item_types & types[i]; if (ty == item_types) { res = cnst (n, types[i], params); Index: compiler/algebra/core2alg.brg =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/core2alg.brg,v retrieving revision 1.33 diff -u -r1.33 core2alg.brg --- compiler/algebra/core2alg.brg 14 Oct 2006 09:51:00 -0000 1.33 +++ compiler/algebra/core2alg.brg 1 Nov 2006 20:58:59 -0000 @@ -346,6 +346,7 @@ the current rule */ PFcnode_t *kids[MAX_KIDS]; /* leaf nodes of this rule */ bool topdown; /* is this a top-down rule? */ + unsigned short i = 0; assert(p); @@ -355,7 +356,7 @@ assert(rule); /* initialize the kids[] vector */ - for (unsigned short i = 0; i < MAX_KIDS; i++) + for (i = 0; i < MAX_KIDS; i++) kids[i] = NULL; /* @@ -428,7 +429,7 @@ * Recursively invoke compilation. This means bottom-up compilation. */ if (!topdown) - for (unsigned short i = 0; nts[i]; i++) + for (i = 0; nts[i]; i++) reduce (kids[i], nts[i]); switch (rule) { @@ -715,6 +716,8 @@ PFalg_attlist_t sortby; if (R(p)->kind == c_orderby) { + unsigned int i = 0; + /* don't include columns inner and outer */ sortby.count = map_count - 2 + 2; sortby.atts = PFmalloc (sortby.count * @@ -722,13 +725,15 @@ /* starting from attribute sort add consecutive attributes ... */ - for (unsigned int i = 0; i < sortby.count - 2; i++) + for (i = 0; i < sortby.count - 2; i++) sortby.atts[i] = att_sort << i; /* ... and complete sortby list with attributes iter and pos */ sortby.atts[sortby.count - 2] = att_iter; sortby.atts[sortby.count - 1] = att_pos; } else { + unsigned int i = 0; + /* don't include columns inner and outer */ sortby.count = map_count - 2 + 1; sortby.atts = PFmalloc (sortby.count * @@ -736,7 +741,7 @@ /* starting from attribute sort add consecutive attributes ... */ - for (unsigned int i = 0; i < sortby.count - 1; i++) + for (i = 0; i < sortby.count - 1; i++) sortby.atts[i] = att_sort << i; /* ... and complete sortby list with attribute pos */ sortby.atts[sortby.count - 1] = att_pos; @@ -885,13 +890,15 @@ map = var_map; map_count = 3; } else { + PFalg_proj_t *atts = NULL; + unsigned int i = 0; + /* extend the backmapping relation map with * (a) position information of the for-loop input sequence and * (b) the current iteration values */ map_count++; - PFalg_proj_t *atts = PFmalloc (map_count * - sizeof (PFalg_proj_t)); + atts = PFmalloc (map_count * sizeof (PFalg_proj_t)); /* column outer remains the same */ atts[0].new = att_outer; atts[0].old = att_outer; @@ -899,7 +906,7 @@ atts[1].new = att_inner; atts[1].old = att_iter1; /* copy all old sort columns */ - for (unsigned i = 2; i < map_count - 1; i++) + for (i = 2; i < map_count - 1; i++) atts[i].new = atts[i].old = att_sort << (i - 2); /* we now have on additional sort column generated @@ -1163,6 +1170,7 @@ PFty_t t; PFalg_simple_type_t algty; PFalg_atom_t atom; + unsigned int i = 0; /* translate order expression */ reduce (kids[0], nts[0]); @@ -1237,7 +1245,7 @@ atts[1].new = att_inner; atts[1].old = att_inner; /* copy all old sort columns */ - for (unsigned i = 2; i < map_count - 1; i++) + for (i = 2; i < map_count - 1; i++) atts[i].new = atts[i].old = att_sort << (i - 2); /* we now have on additional sort column generated @@ -1696,13 +1704,14 @@ PFarray_t *old_env; PFarray_t *old_fun_args; + unsigned int i = 0; /* (1) Save current variable environment and create a new one. */ old_env = env; env = PFarray (sizeof (PFla_env_t)); - for (unsigned int i = 0; i < PFarray_last (old_env); i++) + for (i = 0; i < PFarray_last (old_env); i++) *((PFla_env_t *) PFarray_add (env)) = *((PFla_env_t *) PFarray_at (old_env, i)); @@ -1735,11 +1744,13 @@ } else { + unsigned int i = 0; + /* * Otherwise bind parameter variables to the argument * values and invoke compilation for function body. */ - for (unsigned int i = 0; i < p->sem.apply.fun->arity; i++) { + for (i = 0; i < p->sem.apply.fun->arity; i++) { PFla_pair_t curr_arg = *(PFla_pair_t *) PFarray_at (fun_args, i); @@ -2065,8 +2076,8 @@ break; default: { - unsigned int count = 0; - for (unsigned int i = 0; i < A(p).rel->schema.count; i++) + unsigned int count = 0, i = 0; + for (i = 0; i < A(p).rel->schema.count; i++) if (A(p).rel->schema.items[i].name == att_iter || A(p).rel->schema.items[i].name == att_pos || A(p).rel->schema.items[i].name == att_item) Index: compiler/algebra/intro_rec_border.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/intro_rec_border.c,v retrieving revision 1.1 diff -u -r1.1 intro_rec_border.c --- compiler/algebra/intro_rec_border.c 12 Oct 2006 15:57:57 -0000 1.1 +++ compiler/algebra/intro_rec_border.c 1 Nov 2006 20:58:59 -0000 @@ -95,9 +95,11 @@ } break; - default: + default: { + unsigned int i = 0; + /* follow the children until a base or a leaf is reached */ - for (unsigned int i = 0; i < PFPA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFPA_OP_MAXCHILD && n->child[i]; i++) base_path = introduce_rec_borders_worker (n->child[i], bases) || base_path; @@ -118,6 +120,7 @@ R(n)->prop = L(R(n))->prop; } break; + } } if (base_path) IN(n) = true; @@ -200,10 +203,12 @@ in_reset (R(n)); } break; - default: - for (unsigned int i = 0; i < PFPA_OP_MAXCHILD && n->child[i]; i++) + default: { + unsigned int i = 0; + for (i = 0; i < PFPA_OP_MAXCHILD && n->child[i]; i++) introduce_rec_borders (n->child[i]); break; + } } } Index: compiler/algebra/logical.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/logical.c,v retrieving revision 1.28 diff -u -r1.28 logical.c --- compiler/algebra/logical.c 17 Oct 2006 17:47:20 -0000 1.28 +++ compiler/algebra/logical.c 1 Nov 2006 20:58:59 -0000 @@ -167,13 +167,14 @@ case la_proxy_base: { PFla_op_t *ret = la_op_wire1 (la_dummy, n); + unsigned int i = 0; ret->schema.count = n->schema.count; ret->schema.items = PFmalloc (ret->schema.count * sizeof (*ret->schema.items)); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; return ret; @@ -199,6 +200,7 @@ PFalg_att_t pos, PFalg_att_t item) { PFla_op_t *ret = la_op_wire2 (la_serialize, doc, alg); + unsigned int i = 0; ret->sem.serialize.pos = pos; ret->sem.serialize.item = item; @@ -208,7 +210,7 @@ = PFmalloc (ret->schema.count * sizeof (*ret->schema.items)); /* copy schema from alg */ - for (unsigned int i = 0; i < alg->schema.count; i++) + for (i = 0; i < alg->schema.count; i++) ret->schema.items[i] = alg->schema.items[i]; return ret; @@ -381,6 +383,7 @@ PFalg_att_t attname, PFalg_atom_t value) { PFla_op_t *ret = la_op_wire1 (la_attach, n); + unsigned int i = 0; /* result schema is input schema plus new columns */ ret->schema.count = n->schema.count + 1; @@ -388,7 +391,7 @@ = PFmalloc (ret->schema.count * sizeof (*ret->schema.items)); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; /* add new column */ @@ -2024,6 +2027,7 @@ PFalg_att_t res, PFalg_att_t qn, PFalg_att_t val) { PFla_op_t *ret = la_op_wire1 (la_attribute, rel); + unsigned int i = 0; /* allocate memory for the result schema; it's the qname schema plus an additional column with the attribute references */ @@ -2032,7 +2036,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from argument 'rel' ... */ - for (unsigned int i = 0; i < rel->schema.count; i++) + for (i = 0; i < rel->schema.count; i++) ret->schema.items[i] = rel->schema.items[i]; /* ... and add the result column */ @@ -2058,6 +2062,7 @@ PFla_textnode (const PFla_op_t *cont, PFalg_att_t res, PFalg_att_t item) { PFla_op_t *ret = la_op_wire1 (la_textnode, cont); + unsigned int i = 0; /* allocate memory for the result schema; it's the input schema plus an additional column with the textnode references */ @@ -2066,7 +2071,7 @@ = PFmalloc (ret->schema.count * sizeof (*ret->schema.items)); /* copy schema from argument 'cont' ... */ - for (unsigned int i = 0; i < cont->schema.count; i ++) + for (i = 0; i < cont->schema.count; i ++) ret->schema.items[i] = cont->schema.items[i]; /* ... and add the result column */ @@ -2205,6 +2210,7 @@ PFla_roots (const PFla_op_t *n) { PFla_op_t *ret = la_op_wire1 (la_roots, n); + unsigned int i = 0; /* allocate memory for the result schema */ ret->schema.count = n->schema.count; @@ -2212,7 +2218,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; return ret; @@ -2639,6 +2645,7 @@ PFla_op_t *PFla_proxy_base (const PFla_op_t *n) { PFla_op_t *ret = la_op_wire1 (la_proxy_base, n); + unsigned int i = 0; /* allocate memory for the result schema */ ret->schema.count = n->schema.count; @@ -2646,7 +2653,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; return ret; Index: compiler/algebra/ordering.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/ordering.c,v retrieving revision 1.6 diff -u -r1.6 ordering.c --- compiler/algebra/ordering.c 19 Jun 2006 08:56:15 -0000 1.6 +++ compiler/algebra/ordering.c 1 Nov 2006 20:58:59 -0000 @@ -55,9 +55,10 @@ { /* construct new PFord_ordering_t object */ PFord_ordering_t ret = PFordering (); + unsigned int i = 0; /* copy existing orderings to return value */ - for (unsigned int i = 0; i < PFarray_last (ordering); i++) + for (i = 0; i < PFarray_last (ordering); i++) *((PFalg_att_t *) PFarray_add (ret)) = *((PFalg_att_t *) PFarray_at (ordering, i)); @@ -83,12 +84,14 @@ bool PFord_implies (const PFord_ordering_t a, const PFord_ordering_t b) { + unsigned int i = 0; + /* For a to imply b, it must at least have as many attributes. */ if (PFord_count (a) < PFord_count (b)) return false; /* Attribute list of b must be a prefix of attribute list of a. */ - for (unsigned int i = 0; i < PFord_count (b); i++) + for (i = 0; i < PFord_count (b); i++) if (PFord_order_at (a, i) != PFord_order_at (b, i)) return false; @@ -106,10 +109,11 @@ PFord_str (const PFord_ordering_t o) { PFarray_t *a = PFarray (sizeof (char)); + unsigned int i = 0; PFarray_printf (a, "<"); - for (unsigned int i = 0; i < PFord_count (o); i++) + for (i = 0; i < PFord_count (o); i++) PFarray_printf (a, "%s%s", i ? "," : "", PFatt_str (PFord_order_at (o, i))); @@ -142,23 +146,24 @@ PFord_intersect (const PFord_set_t a, const PFord_set_t b) { PFord_set_t ret = PFord_set (); + unsigned int i = 0, j = 0, k = 0; /* * For each ordering in a search for the longest prefix with * any ordering in b. */ - for(unsigned int i = 0; i < PFord_set_count (a); i++) { + for (i = 0; i < PFord_set_count (a); i++) { PFord_ordering_t ai = PFord_set_at (a, i); PFord_ordering_t best_prefix = PFordering (); - for (unsigned int j = 0; j < PFord_set_count (b); j++) { + for (j = 0; j < PFord_set_count (b); j++) { PFord_ordering_t bj = PFord_set_at (b, j); PFord_ordering_t prefix = PFordering (); /* compute the longest prefix of the current ordering in a and b */ - for (unsigned int k = 0; + for (k = 0; k < PFord_count (ai) && k < PFord_count (bj) && PFord_order_at (ai, k) == PFord_order_at (bj, k); k++) @@ -237,18 +242,18 @@ PFord_prefixes (PFord_set_t a) { PFord_set_t ret = PFord_set (); + unsigned int i = 0, j = 0, k = 0; - for (unsigned int i = 0; i < PFord_set_count (a); i++) { + for (i = 0; i < PFord_set_count (a); i++) { PFord_ordering_t ai = PFord_set_at (a, i); PFord_ordering_t prefix = PFordering (); - for (unsigned int j = 0; j < PFord_count (ai); j++) { + for (j = 0; j < PFord_count (ai); j++) { prefix = PFord_refine (prefix, PFord_order_at (ai, j)); /* make sure we do not already have that prefix in the list */ - unsigned int k; for (k = 0; k < PFord_set_count (ret); k++) if (PFord_implies (prefix, PFord_set_at (ret, k)) && PFord_implies (PFord_set_at (ret, k), prefix)) @@ -278,6 +283,7 @@ PFord_permutations (const PFord_ordering_t ordering) { PFord_set_t ret = PFord_set (); + unsigned int i = 0, j = 0; /* * End of recursion: If we get an empty ordering, return a @@ -286,20 +292,20 @@ if (PFord_count (ordering) == 0) return PFord_set_add (ret, PFordering ()); - for (unsigned int i = 0; i < PFord_count (ordering); i++) { + for (i = 0; i < PFord_count (ordering); i++) { /* Compute all permutations with attribute at position i removed. */ PFord_ordering_t removed = PFordering (); PFord_set_t subperms; - for (unsigned int j = 0; j < PFord_count (ordering); j++) + for (j = 0; j < PFord_count (ordering); j++) if (j != i) removed = PFord_refine (removed, PFord_order_at (ordering, j)); subperms = PFord_permutations (removed); /* Refine all this permutations with the attribute at position i. */ - for (unsigned int j = 0; j < PFarray_last (subperms); j++) + for (j = 0; j < PFarray_last (subperms); j++) PFord_set_add (ret, PFord_refine (PFord_set_at (subperms, j), PFord_order_at (ordering, i))); Index: compiler/algebra/physical.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/physical.c,v retrieving revision 1.23 diff -u -r1.23 physical.c --- compiler/algebra/physical.c 12 Oct 2006 15:57:03 -0000 1.23 +++ compiler/algebra/physical.c 1 Nov 2006 20:59:00 -0000 @@ -216,8 +216,9 @@ if (count == 1) { PFord_ordering_t ord = PFordering (); + unsigned int i = 0; - for (unsigned int i = 0; i < attlist.count; i++) + for (i = 0; i < attlist.count; i++) ord = PFord_refine (ord, attlist.atts[i]); ret->orderings = PFord_permutations (ord); @@ -250,6 +251,7 @@ PFpa_empty_tbl (PFalg_schema_t schema) { PFpa_op_t *ret; /* return value we are building */ + unsigned int i = 0; /* instantiate the new algebra operator node */ ret = leaf (pa_empty_tbl); @@ -259,7 +261,7 @@ ret->schema.items = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema */ - for (unsigned int i = 0; i < schema.count; i++) + for (i = 0; i < schema.count; i++) ret->schema.items[i] = schema.items[i]; /* play safe: set these fields */ @@ -267,7 +269,7 @@ ret->sem.lit_tbl.tuples = NULL; PFord_ordering_t ord = PFordering (); - for (unsigned int i = 0; i < schema.count; i++) + for (i = 0; i < schema.count; i++) ord = PFord_refine (ord, schema.items[i].name); ret->orderings = PFord_permutations (ord); @@ -315,6 +317,7 @@ PFalg_att_t attname, PFalg_atom_t value) { PFpa_op_t *ret = wire1 (pa_attach, n); + unsigned int i = 0, j = 0, k = 0; /* result schema is input schema plus new columns */ ret->schema.count = n->schema.count + 1; @@ -322,7 +325,7 @@ = PFmalloc (ret->schema.count * sizeof (*ret->schema.items)); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; /* add new column */ @@ -347,17 +350,17 @@ in = PFord_set_add (PFord_set (), PFordering ()); /* Iterate over all the input orderings... */ - for (unsigned int i = 0; i < PFord_set_count (in); i++) { + for (i = 0; i < PFord_set_count (in); i++) { PFord_ordering_t current_in = PFord_set_at (in, i); PFord_ordering_t prefix = PFordering (); /* interleave the new column everywhere possible */ - for (unsigned int j = 0; j <= PFord_count (current_in); j++) { + for (j = 0; j <= PFord_count (current_in); j++) { PFord_ordering_t ord = PFord_refine (prefix, attname); - for (unsigned int k = j; k < PFord_count (current_in); k++) + for (k = j; k < PFord_count (current_in); k++) ord = PFord_refine (ord, PFord_order_at (current_in, k)); PFord_set_add (ret->orderings, ord); @@ -405,8 +408,9 @@ PFpa_cross (const PFpa_op_t *a, const PFpa_op_t *b) { PFpa_op_t *ret = wire2 (pa_cross, a, b); - unsigned int i; - unsigned int j; + unsigned int i = 0; + unsigned int j = 0; + unsigned int k = 0; PFord_ordering_t ord; assert (a); assert (b); @@ -427,16 +431,16 @@ /* ---- cross product orderings ---- */ /* consider all orderings of a */ - for (unsigned int i = 0; i < PFord_set_count (a->orderings); i++) { + for (i = 0; i < PFord_set_count (a->orderings); i++) { /* refine by all the orderings in b */ - for (unsigned int j = 0; j < PFord_set_count (b->orderings); j++) { + for (j = 0; j < PFord_set_count (b->orderings); j++) { /* Ordering of a is the major ordering */ ord = PFord_set_at (a->orderings, i); /* refine attribute by attribute with current ordering of b */ - for (unsigned int k = 0; + for (k = 0; k < PFord_count (PFord_set_at (b->orderings, j)); k++) ord = PFord_refine ( @@ -458,7 +462,9 @@ static bool contains_att (PFalg_schema_t s, PFalg_att_t att) { - for (unsigned int i = 0; i < s.count; i++) + unsigned int i = 0; + + for (i = 0; i < s.count; i++) if (s.items[i].name == att) return true; @@ -474,6 +480,7 @@ const PFpa_op_t *n1, const PFpa_op_t *n2) { PFpa_op_t *ret = wire2 (pa_leftjoin, n1, n2); + unsigned int i = 0, j = 0, k = 0; /* see if we can find attribute att1 in n1 */ if (contains_att (n1->schema, att1) && contains_att (n2->schema, att2)) { @@ -494,11 +501,11 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n1 */ - for (unsigned int i = 0; i < n1->schema.count; i++) + for (i = 0; i < n1->schema.count; i++) ret->schema.items[i] = n1->schema.items[i]; /* copy schema from n2 */ - for (unsigned int i = 0; i < n2->schema.count; i++) + for (i = 0; i < n2->schema.count; i++) ret->schema.items[n1->schema.count + i] = n2->schema.items[i]; /* ---- LeftJoin: orderings ---- */ @@ -516,7 +523,7 @@ ret->orderings = PFord_set (); - for (unsigned int i = 0; i < PFord_set_count (n1->orderings); i++) { + for (i = 0; i < PFord_set_count (n1->orderings); i++) { PFord_ordering_t left_ordering = PFord_set_at (n1->orderings, i); @@ -528,7 +535,7 @@ */ bool found = false; - for (unsigned int j = 0; j < PFord_count (left_ordering); j++) { + for (j = 0; j < PFord_count (left_ordering); j++) { if (PFord_order_at (left_ordering, j) == ret->sem.eqjoin.att1) /* Hey, we found the left join attribute. */ @@ -548,7 +555,7 @@ = PFord_refine (ord, ret->sem.eqjoin.att2); /* Fill up with the remaining ordering of left relation */ - for (unsigned int k = j; k < PFord_count (left_ordering); k++) + for (k = j; k < PFord_count (left_ordering); k++) ord2 = PFord_refine (ord2, PFord_order_at (left_ordering, j)); @@ -583,6 +590,7 @@ const PFpa_op_t *n1, const PFpa_op_t *n2) { PFpa_op_t *ret = wire2 (pa_eqjoin, n1, n2); + unsigned int i = 0; /* see if we can find attribute att1 in n1 */ if (contains_att (n1->schema, att1) && contains_att (n2->schema, att2)) { @@ -603,11 +611,11 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n1 */ - for (unsigned int i = 0; i < n1->schema.count; i++) + for (i = 0; i < n1->schema.count; i++) ret->schema.items[i] = n1->schema.items[i]; /* copy schema from n2 */ - for (unsigned int i = 0; i < n2->schema.count; i++) + for (i = 0; i < n2->schema.count; i++) ret->schema.items[n1->schema.count + i] = n2->schema.items[i]; /* ---- EqJoin: orderings ---- */ @@ -649,13 +657,14 @@ PFpa_project (const PFpa_op_t *n, unsigned int count, PFalg_proj_t *proj) { PFpa_op_t *ret = wire1 (pa_project, n); + unsigned int i = 0, j = 0; ret->sem.proj.count = count; ret->sem.proj.items = PFmalloc (ret->sem.proj.count * sizeof (*ret->sem.proj.items)); - for (unsigned int i = 0 ; i < ret->sem.proj.count; i++) + for (i = 0; i < ret->sem.proj.count; i++) ret->sem.proj.items[i] = proj[i]; /* allocate space for result schema */ @@ -663,9 +672,7 @@ ret->schema.items = PFmalloc (count * sizeof (*(ret->schema.items))); /* check for sanity and set result schema */ - for (unsigned int i = 0; i < ret->sem.proj.count; i++) { - - unsigned int j; + for (i = 0; i < ret->sem.proj.count; i++) { /* lookup old name in n's schema * and use its type for the result schema */ @@ -680,7 +687,7 @@ /* did we find the attribute? */ if (j >= n->schema.count) - PFoops (OOPS_FATAL, + PFoops (OOPS_FATAL, "attribute `%s' referenced in projection not found", PFatt_str (ret->sem.proj.items[i].old)); } @@ -691,12 +698,12 @@ * From our argument pass all those ordering prefixes that * are still in the schema */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) { + for (i = 0; i < PFord_set_count (n->orderings); i++) { PFord_ordering_t ni = PFord_set_at (n->orderings, i); PFord_ordering_t prefix = PFordering (); - for (unsigned int j = 0; j < PFord_count (ni); j++) { + for (j = 0; j < PFord_count (ni); j++) { unsigned int k; for (k = 0; k < ret->sem.proj.count; k++) @@ -732,6 +739,7 @@ PFpa_select (const PFpa_op_t *n, PFalg_att_t att) { PFpa_op_t *ret = wire1 (pa_select, n); + unsigned int i = 0; /* allocate memory for the result schema */ ret->schema.count = n->schema.count; @@ -739,14 +747,14 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; /* keep the ordering we got in the `ord' argument */ ret->sem.select.att = att; /* ---- Select: orderings ---- */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* ---- Select: costs ---- */ @@ -763,7 +771,8 @@ PFpa_append_union (const PFpa_op_t *n1, const PFpa_op_t *n2) { PFpa_op_t *ret = wire2 (pa_append_union, n1, n2); - unsigned int i, j; + unsigned int i = 0, j = 0; + unsigned int a1 = 0, a2 = 0; /* see if both operands have same number of attributes */ if (n1->schema.count != n2->schema.count) @@ -803,9 +812,9 @@ * ------------------------------------------- * e1 U e2 : [a] */ - for (unsigned int a1 = 0; a1 < PFprop_const_count (n1->prop); a1++) { + for (a1 = 0; a1 < PFprop_const_count (n1->prop); a1++) { - for (unsigned int a2 = 0; a2 < PFprop_const_count (n2->prop); a2++) + for (a2 = 0; a2 < PFprop_const_count (n2->prop); a2++) if (PFprop_const_at (n1->prop, a1) == PFprop_const_at (n2->prop, a2) && PFalg_atom_comparable (PFprop_const_val_at (n1->prop, a1), PFprop_const_val_at (n2->prop, a2)) @@ -862,7 +871,9 @@ PFord_ordering_t ord) { PFpa_op_t *ret = wire2 (pa_merge_union, n1, n2); - unsigned int i, j; + unsigned int i = 0, j = 0; + unsigned int a1 = 0, a2 = 0; + unsigned int o1 = 0, o2 = 0; /* see if both operands have same number of attributes */ if (n1->schema.count != n2->schema.count) @@ -906,7 +917,7 @@ #ifndef NDEBUG { bool ordered = false; - for (unsigned int i = 0; i < PFord_set_count (n1->orderings); i++) + for (i = 0; i < PFord_set_count (n1->orderings); i++) if (PFord_implies (PFord_set_at (n1->orderings, i), ord)) { ordered = true; break; @@ -917,7 +928,7 @@ PFord_str (ord)); ordered = false; - for (unsigned int i = 0; i < PFord_set_count (n2->orderings); i++) + for (i = 0; i < PFord_set_count (n2->orderings); i++) if (PFord_implies (PFord_set_at (n2->orderings, i), ord)) { ordered = true; break; @@ -937,9 +948,9 @@ * ----------------------------------------------------- * e1 U_{[o1,...,oi]} e2 : [o_1,..,oi,a,ok,..on] */ - for (unsigned int a1 = 0; a1 < PFprop_const_count (n1->prop); a1++) { + for (a1 = 0; a1 < PFprop_const_count (n1->prop); a1++) { - for (unsigned int a2 = 0; a2 < PFprop_const_count (n2->prop); a2++) + for (a2 = 0; a2 < PFprop_const_count (n2->prop); a2++) if (PFprop_const_at (n1->prop, a1) == PFprop_const_at (n2->prop, a2) && PFalg_atom_comparable (PFprop_const_val_at (n1->prop, a1), PFprop_const_val_at (n2->prop, a2)) @@ -949,9 +960,9 @@ PFord_ordering_t o = PFord_refine (ord, PFprop_const_at (n1->prop, a1)); - for (unsigned int o1= 0; o1 < PFord_count (n1->orderings); o1++) + for (o1= 0; o1 < PFord_count (n1->orderings); o1++) if (PFord_implies (PFord_set_at (n1->orderings, o1), o)) - for (unsigned int o2 = 0; + for (o2 = 0; o2 < PFord_count (n2->orderings); o2++) if (PFord_implies (PFord_set_at (n2->orderings, o2), o)) { @@ -1081,6 +1092,7 @@ PFpa_sort_distinct (const PFpa_op_t *n, PFord_ordering_t ord) { PFpa_op_t *ret = wire1 (pa_sort_distinct, n); + unsigned int i = 0; /* allocate memory for the result schema */ ret->schema.count = n->schema.count; @@ -1088,14 +1100,14 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; /* keep the ordering we got in the `ord' argument */ ret->sem.sort_distinct.ord = ord; /* ---- SortDistinct: orderings ---- */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* ---- SortDistinct: costs ---- */ @@ -1115,6 +1127,7 @@ PFpa_std_sort (const PFpa_op_t *n, PFord_ordering_t required) { PFpa_op_t *ret = wire1 (pa_std_sort, n); + unsigned int i = 0; /* allocate memory for the result schema */ ret->schema.count = n->schema.count; @@ -1122,7 +1135,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; ret->sem.sortby.required = required; @@ -1147,6 +1160,7 @@ PFord_ordering_t existing, PFord_ordering_t required) { PFpa_op_t *ret = wire1 (pa_refine_sort, n); + unsigned int i = 0; /* allocate memory for the result schema */ ret->schema.count = n->schema.count; @@ -1154,7 +1168,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; assert (PFord_implies (required, existing)); @@ -1182,6 +1196,7 @@ PFpa_op_t *ret = wire1 (op, n); PFalg_simple_type_t t1 = 0; PFalg_simple_type_t t2 = 0; + unsigned int i = 0; assert (n); @@ -1191,7 +1206,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) { + for (i = 0; i < n->schema.count; i++) { ret->schema.items[i] = n->schema.items[i]; @@ -1218,7 +1233,7 @@ ret->sem.binary.att2 = att2; /* ---- NumAdd: orderings ---- */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* @@ -1243,6 +1258,7 @@ { PFpa_op_t *ret = wire1 (op, n); PFalg_simple_type_t t1 = 0; + unsigned int i = 0; assert (n); @@ -1252,7 +1268,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) { + for (i = 0; i < n->schema.count; i++) { ret->schema.items[i] = n->schema.items[i]; @@ -1278,7 +1294,7 @@ ret->sem.bin_atom.att2 = att2; /* ---- NumAdd: orderings ---- */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* @@ -1306,6 +1322,7 @@ PFalg_simple_type_t t1 = 0; PFalg_simple_type_t t2 = 0; #endif + unsigned int i = 0; assert (n); @@ -1315,7 +1332,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) { + for (i = 0; i < n->schema.count; i++) { ret->schema.items[i] = n->schema.items[i]; @@ -1345,7 +1362,7 @@ ret->sem.binary.att2 = att2; /* ---- NumAdd: orderings ---- */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* @@ -1372,6 +1389,7 @@ #ifndef NDEBUG PFalg_simple_type_t t1 = 0; #endif + unsigned int i = 0; assert (n); @@ -1381,7 +1399,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) { + for (i = 0; i < n->schema.count; i++) { ret->schema.items[i] = n->schema.items[i]; @@ -1410,7 +1428,7 @@ ret->sem.bin_atom.att2 = att2; /* ---- NumAdd: orderings ---- */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* @@ -1561,6 +1579,7 @@ { PFpa_op_t *ret = wire1 (op, n); PFalg_simple_type_t t1 = 0; + unsigned int i = 0; assert (n); @@ -1570,7 +1589,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) { + for (i = 0; i < n->schema.count; i++) { ret->schema.items[i] = n->schema.items[i]; @@ -1590,7 +1609,7 @@ ret->sem.unary.att = att; /* ---- UnaryArith: orderings ---- */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* @@ -1741,6 +1760,7 @@ { PFpa_op_t *ret = wire1 (pa_merge_rownum, n); PFord_ordering_t ord = PFordering (); + unsigned int i = 0; ret->sem.rownum.attname = new_att; ret->sem.rownum.part = part; @@ -1751,14 +1771,14 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; ret->schema.items[ret->schema.count - 1] = (PFalg_schm_item_t) { .name = new_att, .type = aat_nat }; /* ---- MergeRowNum: orderings ---- */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* of course, the new attribute is also a valid ordering */ @@ -1790,6 +1810,7 @@ PFalg_att_t part) { PFpa_op_t *ret = wire1 (pa_hash_rownum, n); + unsigned int i = 0; assert (!"FIXME: hash_rownum: orderings not implemented yet!"); @@ -1802,7 +1823,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; ret->schema.items[ret->schema.count - 1] @@ -1816,6 +1837,7 @@ PFalg_att_t new_att, PFalg_att_t part) { PFpa_op_t *ret = wire1 (pa_number, n); + unsigned int i = 0, j = 0, k = 0; ret->sem.number.attname = new_att; ret->sem.number.part = part; @@ -1826,7 +1848,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; ret->schema.items[ret->schema.count - 1] @@ -1847,17 +1869,17 @@ in = PFord_set_add (PFord_set (), PFordering ()); /* Iterate over all the input orderings... */ - for (unsigned int i = 0; i < PFord_set_count (in); i++) { + for (i = 0; i < PFord_set_count (in); i++) { PFord_ordering_t current_in = PFord_set_at (in, i); PFord_ordering_t prefix = PFordering (); /* interleave the new column everywhere possible */ - for (unsigned int j = 0; j <= PFord_count (current_in); j++) { + for (j = 0; j <= PFord_count (current_in); j++) { PFord_ordering_t ord = PFord_refine (prefix, new_att); - for (unsigned int k = j; k < PFord_count (current_in); k++) + for (k = j; k < PFord_count (current_in); k++) ord = PFord_refine (ord, PFord_order_at (current_in, k)); PFord_set_add (ret->orderings, ord); @@ -1903,7 +1925,7 @@ ret->sem.type.res = res; /* ordering stays the same */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* costs */ ret->cost = n->cost + 1; @@ -1921,6 +1943,7 @@ PFalg_simple_type_t ty) { PFpa_op_t *ret = wire1 (pa_type_assert, n); + unsigned int i = 0; assert (n); @@ -1930,7 +1953,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n and change type of column */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) { if (att == n->schema.items[i].name) { @@ -1945,7 +1968,7 @@ ret->sem.type.ty = ty; /* ordering stays the same */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* costs */ ret->cost = n->cost + 1; @@ -1958,6 +1981,7 @@ PFalg_att_t att, PFalg_simple_type_t ty) { PFpa_op_t *ret = wire1 (pa_cast, n); + unsigned int i = 0; ret->schema.count = n->schema.count + 1; ret->schema.items @@ -1967,13 +1991,13 @@ ret->sem.cast.ty = ty; ret->sem.cast.res = res; - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; ret->schema.items[ret->schema.count - 1] = (PFalg_schm_item_t) { .name = res, .type = ty }; /* ---- Cast: orderings ---- */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* ---- Cast: costs ---- */ @@ -1999,8 +2023,9 @@ #ifndef NDEBUG unsigned short found = 0; + unsigned int i = 0; - for (unsigned int i = 0; i < ctx->schema.count; i++) + for (i = 0; i < ctx->schema.count; i++) if (ctx->schema.items[i].name == iter || ctx->schema.items[i].name == item) found++; @@ -2329,8 +2354,12 @@ #ifndef NDEBUG unsigned short found = 0; + unsigned int i = 0; - for (unsigned int i = 0; i < rel->schema.count; i++) + /* If the input is sorted by `iter', the output will be as well. */ + bool sorted_by_iter = false; + + for (i = 0; i < rel->schema.count; i++) if (rel->schema.items[i].name == iter || rel->schema.items[i].name == item) found++; @@ -2358,10 +2387,7 @@ /* ---- doc_tbl: orderings ---- */ - /* If the input is sorted by `iter', the output will be as well. */ - bool sorted_by_iter = false; - - for (unsigned int i = 0; i < PFord_set_count (rel->orderings); i++) + for (i = 0; i < PFord_set_count (rel->orderings); i++) if (PFord_implies (PFord_set_at (rel->orderings, i), PFord_refine (PFordering (), iter))) { sorted_by_iter = true; @@ -2416,7 +2442,7 @@ ret->sem.doc_access.doc_col = doc_col; /* ordering stays the same */ - for (unsigned int i = 0; i < PFord_set_count (alg->orderings); i++) + for (i = 0; i < PFord_set_count (alg->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (alg->orderings, i)); /* costs */ ret->cost = doc->cost + alg->cost + 1; @@ -2438,8 +2464,9 @@ #ifndef NDEBUG unsigned short found = 0; + unsigned int i = 0; - for (unsigned int i = 0; i < qname->schema.count; i++) + for (i = 0; i < qname->schema.count; i++) if (qname->schema.items[i].name == iter || qname->schema.items[i].name == item) found++; @@ -2450,7 +2477,7 @@ found = 0; - for (unsigned int i = 0; i < content->schema.count; i++) + for (i = 0; i < content->schema.count; i++) if (content->schema.items[i].name == iter || content->schema.items[i].name == pos || content->schema.items[i].name == item) @@ -2514,8 +2541,9 @@ #ifndef NDEBUG unsigned short found = 0; + unsigned int i = 0; - for (unsigned int i = 0; i < rel->schema.count; i++) + for (i = 0; i < rel->schema.count; i++) if (rel->schema.items[i].name == val || rel->schema.items[i].name == qn) found++; @@ -2535,7 +2563,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from argument 'rel' ... */ - for (unsigned int i = 0; i < rel->schema.count; i++) + for (i = 0; i < rel->schema.count; i++) ret->schema.items[i] = rel->schema.items[i]; /* ... and add the result column */ @@ -2547,7 +2575,7 @@ ret->sem.attr.res = res; /* ---- attribute: orderings ---- */ - for (unsigned int i = 0; i < PFord_set_count (rel->orderings); i++) + for (i = 0; i < PFord_set_count (rel->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (rel->orderings, i)); /* ---- attribute: costs ---- */ @@ -2566,6 +2594,7 @@ PFalg_att_t item) { PFpa_op_t *ret; + unsigned int i = 0; ret = wire1 (pa_textnode, rel); @@ -2574,7 +2603,7 @@ ret->schema.items = PFmalloc (ret->schema.count * sizeof (*ret->schema.items)); - for (unsigned int i = 0; i < rel->schema.count; i ++) + for (i = 0; i < rel->schema.count; i ++) ret->schema.items[i] = rel->schema.items[i]; ret->schema.items[ret->schema.count - 1] @@ -2584,7 +2613,7 @@ ret->sem.textnode.res = res; /* ---- textnode: orderings ---- */ - for (unsigned int i = 0; i < PFord_set_count (rel->orderings); i++) + for (i = 0; i < PFord_set_count (rel->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (rel->orderings, i)); /* ---- textnode: costs ---- */ @@ -2599,6 +2628,7 @@ PFalg_att_t iter, PFalg_att_t pos, PFalg_att_t item) { PFpa_op_t *ret = wire2 (pa_merge_adjacent, fragment, n); + unsigned int i = 0; ret->sem.ii.iter = iter; ret->sem.ii.item = item; @@ -2609,7 +2639,7 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n and change type of column */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; /* result is in iter|pos order */ @@ -2629,6 +2659,7 @@ PFpa_roots (const PFpa_op_t *n) { PFpa_op_t *ret = wire1 (pa_roots, n); + unsigned int i = 0; /* allocate memory for the result schema */ ret->schema.count = n->schema.count; @@ -2636,13 +2667,13 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; /* ---- Roots: orderings ---- */ /* `Rel' part of (Frag, Rel) pair inherits orderings of its argument */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* ---- Roots: costs ---- */ @@ -2709,6 +2740,7 @@ PFalg_att_t att, char *err_string) { PFpa_op_t *ret = wire2 (pa_cond_err, n, err); + unsigned int i = 0; assert (n); assert (err); @@ -2720,14 +2752,14 @@ = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items))); /* copy schema from n */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) ret->schema.items[i] = n->schema.items[i]; ret->sem.err.att = att; ret->sem.err.str = err_string; /* ordering stays the same */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* costs */ ret->cost = n->cost + err->cost + 1; @@ -2760,7 +2792,7 @@ ret->schema.items[i] = res->schema.items[i]; /* ordering stays the same as the result ordering */ - for (unsigned int i = 0; i < PFord_set_count (res->orderings); i++) + for (i = 0; i < PFord_set_count (res->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (res->orderings, i)); /* costs */ @@ -2910,7 +2942,7 @@ ret->schema.items[i] = seed->schema.items[i]; /* ordering stays the same as the base ordering */ - for (unsigned int i = 0; i < PFord_set_count (base->orderings); i++) + for (i = 0; i < PFord_set_count (base->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (base->orderings, i)); /* costs */ @@ -2986,7 +3018,7 @@ ret->schema.items[i] = n->schema.items[i]; /* ordering stays the same as the input */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* costs */ @@ -3026,7 +3058,7 @@ ret->sem.binary.res = res; /* ordering stays the same */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* costs */ @@ -3066,7 +3098,7 @@ ret->sem.binary.res = res; /* ordering stays the same */ - for (unsigned int i = 0; i < PFord_set_count (n->orderings); i++) + for (i = 0; i < PFord_set_count (n->orderings); i++) PFord_set_add (ret->orderings, PFord_set_at (n->orderings, i)); /* costs */ Index: compiler/algebra/planner.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/planner.c,v retrieving revision 1.28 diff -u -r1.28 planner.c --- compiler/algebra/planner.c 18 Oct 2006 17:48:30 -0000 1.28 +++ compiler/algebra/planner.c 1 Nov 2006 20:59:00 -0000 @@ -187,13 +187,15 @@ { PFplanlist_t *ret = new_planlist (); PFplanlist_t *sorted = new_planlist (); + unsigned int i = 0; + unsigned int j = 0; assert (n); assert (n->kind == la_serialize); assert (L(n)); assert (L(n)->plans); assert (R(n)); assert (R(n)->plans); /* The serialize operator requires its input to be properly sorted. */ - for (unsigned int i = 0; i < PFarray_last (R(n)->plans); i++) + for (i = 0; i < PFarray_last (R(n)->plans); i++) add_plans (sorted, ensure_ordering ( *(plan_t **) PFarray_at (R(n)->plans, i), @@ -203,8 +205,8 @@ sorted = prune_plans (sorted); /* for each remaining plan, generate a Serialize operator */ - for (unsigned int i = 0; i < PFarray_last (sorted); i++) - for (unsigned int j = 0; j < PFarray_last (L(n)->plans); j++) + for (i = 0; i < PFarray_last (sorted); i++) + for (j = 0; j < PFarray_last (L(n)->plans); j++) add_plan (ret, serialize ( *(plan_t **) PFarray_at (L(n)->plans, j), @@ -230,13 +232,14 @@ { PFplanlist_t *ret = new_planlist (); plan_t *plan = NULL; + unsigned int i = 0; PFalg_attlist_t attlist; attlist.count = n->schema.count; attlist.atts = PFmalloc (attlist.count * sizeof (*attlist.atts)); - for (unsigned int i = 0; i < attlist.count; i++) + for (i = 0; i < attlist.count; i++) attlist.atts[i] = n->schema.items[i].name; /* @@ -287,12 +290,13 @@ plan_attach (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int r = 0; assert (n); assert (n->kind == la_attach); assert (L(n)); assert (L(n)->plans); /* consider each plan in R */ - for (unsigned int r = 0; r < PFarray_last (L(n)->plans); r++) + for (r = 0; r < PFarray_last (L(n)->plans); r++) add_plan (ret, attach (*(plan_t **) PFarray_at (L(n)->plans, r), n->sem.attach.attname, @@ -311,6 +315,8 @@ static void cross_worker (PFplanlist_t *ret, const plan_t *a, const plan_t *b) { + unsigned int i = 0; + /* add the cross product plan */ add_plan (ret, cross (a, b)); @@ -320,7 +326,7 @@ PFalg_tuple_t t = a->sem.lit_tbl.tuples[0]; plan_t *plan = (plan_t *) b; - for (unsigned int i = 0; i < t.count; i++) { + for (i = 0; i < t.count; i++) { plan = attach (plan, a->schema.items[i].name, t.atoms[i]); /* assign logical properties to the additional physical node as well */ @@ -344,14 +350,16 @@ plan_cross (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int r = 0; + unsigned int s = 0; assert (n); assert (n->kind == la_cross); assert (L(n)); assert (L(n)->plans); assert (R(n)); assert (R(n)->plans); /* combine each plan in R with each plan in S */ - for (unsigned int r = 0; r < PFarray_last (L(n)->plans); r++) - for (unsigned int s = 0; s < PFarray_last (R(n)->plans); s++) { + for (r = 0; r < PFarray_last (L(n)->plans); r++) + for (s = 0; s < PFarray_last (R(n)->plans); s++) { cross_worker (ret, *(plan_t **) PFarray_at (L(n)->plans, r), *(plan_t **) PFarray_at (R(n)->plans, s)); cross_worker (ret, *(plan_t **) PFarray_at (R(n)->plans, s), @@ -437,15 +445,17 @@ static PFplanlist_t * plan_eqjoin (const PFla_op_t *n) { - PFplanlist_t *ret = new_planlist (); + PFplanlist_t *ret = new_planlist (); + unsigned int r = 0; + unsigned int s = 0; assert (n); assert (n->kind == la_eqjoin); assert (L(n)); assert (L(n)->plans); assert (R(n)); assert (R(n)->plans); /* combine each plan in R with each plan in S */ - for (unsigned int r = 0; r < PFarray_last (L(n)->plans); r++) - for (unsigned int s = 0; s < PFarray_last (R(n)->plans); s++) { + for (r = 0; r < PFarray_last (L(n)->plans); r++) + for (s = 0; s < PFarray_last (R(n)->plans); s++) { join_worker (ret, n->sem.eqjoin.att1, n->sem.eqjoin.att2, *(plan_t **) PFarray_at (L(n)->plans, r), *(plan_t **) PFarray_at (R(n)->plans, s)); @@ -469,12 +479,13 @@ plan_project (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int r = 0; assert (n); assert (n->kind == la_project); assert (L(n)); assert (L(n)->plans); /* consider each plan in R */ - for (unsigned int r = 0; r < PFarray_last (L(n)->plans); r++) + for (r = 0; r < PFarray_last (L(n)->plans); r++) add_plan (ret, project (*(plan_t **) PFarray_at (L(n)->plans, r), n->sem.proj.count, n->sem.proj.items)); @@ -493,12 +504,13 @@ plan_select (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int r = 0; assert (n); assert (n->kind == la_select); assert (L(n)); assert (L(n)->plans); /* consider each plan in R */ - for (unsigned int r = 0; r < PFarray_last (L(n)->plans); r++) + for (r = 0; r < PFarray_last (L(n)->plans); r++) add_plan (ret, select_ (*(plan_t **) PFarray_at (L(n)->plans, r), n->sem.select.att)); @@ -513,7 +525,9 @@ static PFalg_simple_type_t type_of (PFalg_schema_t schema, PFalg_att_t att) { - for (unsigned int i = 0; i < schema.count; i++) + unsigned int i = 0; + + for (i = 0; i < schema.count; i++) if (schema.items[i].name == att) return schema.items[i].type; @@ -547,10 +561,13 @@ plan_disjunion (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int r = 0; + unsigned int s = 0; + unsigned int i = 0; /* Consider each combination of plans in R and S */ - for (unsigned int r = 0; r < PFarray_last (L(n)->plans); r++) - for (unsigned int s = 0; s < PFarray_last (R(n)->plans); s++) { + for (r = 0; r < PFarray_last (L(n)->plans); r++) + for (s = 0; s < PFarray_last (R(n)->plans); s++) { plan_t *R = *(plan_t **) PFarray_at (L(n)->plans, r); plan_t *S = *(plan_t **) PFarray_at (R(n)->plans, s); @@ -566,7 +583,7 @@ */ PFord_set_t prefixes = PFord_set (); - for (unsigned int i = 0; i < PFord_set_count (common); i++) { + for (i = 0; i < PFord_set_count (common); i++) { PFalg_att_t att = PFord_order_at (PFord_set_at (common, i), 0); @@ -584,7 +601,7 @@ prefixes = PFord_unique (prefixes); /* and generate plans */ - for (unsigned int i = 0; i < PFord_set_count (prefixes); i++) + for (i = 0; i < PFord_set_count (prefixes); i++) add_plan (ret, merge_union (R, S, PFord_set_at (prefixes, i))); /* of course we can always do AppendUnion */ @@ -597,7 +614,7 @@ PFord_unique ( PFord_intersect (R->orderings, S->orderings))); - for (unsigned int i = 0; i < PFord_set_count (prefixes); i++) + for (i = 0; i < PFord_set_count (prefixes); i++) add_plan (ret, merge_union ( R, S, PFord_set_at (prefixes, i))); #endif } @@ -612,15 +629,17 @@ plan_intersect (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int l = 0; + unsigned int r = 0; assert (n); assert (n->kind == la_intersect); assert (L(n)); assert (L(n)->plans); assert (R(n)); assert (R(n)->plans); /* consider each plan in L */ - for (unsigned int l = 0; l < PFarray_last (L(n)->plans); l++) + for (l = 0; l < PFarray_last (L(n)->plans); l++) /* and each plan in R */ - for (unsigned int r = 0; r < PFarray_last (R(n)->plans); r++) + for (r = 0; r < PFarray_last (R(n)->plans); r++) add_plan (ret, intersect ( *(plan_t **) PFarray_at (L(n)->plans, l), @@ -640,15 +659,17 @@ plan_difference (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int l = 0; + unsigned int r = 0; assert (n); assert (n->kind == la_difference); assert (L(n)); assert (L(n)->plans); assert (R(n)); assert (R(n)->plans); /* consider each plan in L */ - for (unsigned int l = 0; l < PFarray_last (L(n)->plans); l++) + for (l = 0; l < PFarray_last (L(n)->plans); l++) /* and each plan in R */ - for (unsigned int r = 0; r < PFarray_last (R(n)->plans); r++) + for (r = 0; r < PFarray_last (R(n)->plans); r++) add_plan (ret, difference ( *(plan_t **) PFarray_at (L(n)->plans, l), @@ -673,20 +694,21 @@ PFord_ordering_t ord = PFordering (); PFord_set_t perms; PFplanlist_t *sorted; + unsigned int i = 0, p = 0; - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) if (!PFprop_const (n->prop, n->schema.items[i].name)) ord = PFord_refine (ord, n->schema.items[i].name); perms = PFord_permutations (ord); /* consider all possible orderings (permutations) */ - for (unsigned int p = 0; p < PFord_set_count (perms); p++) { + for (p = 0; p < PFord_set_count (perms); p++) { sorted = new_planlist (); /* consider all input plans and sort them */ - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plans (sorted, ensure_ordering ( *(plan_t **) PFarray_at (L(n)->plans, i), @@ -696,7 +718,7 @@ sorted = prune_plans (sorted); /* on each of the remaining, do a SortDistinct */ - for (unsigned int i = 0; i < PFarray_last (sorted); i++) + for (i = 0; i < PFarray_last (sorted); i++) add_plan (ret, sort_distinct (*(plan_t **) PFarray_at (sorted, i), PFord_set_at (perms, p))); @@ -745,6 +767,7 @@ switch (n->kind) { + unsigned int i = 0; case la_num_add: case la_num_multiply: @@ -754,8 +777,7 @@ /* consider NumAddConst if attribute att1 is known to be constant */ if (PFprop_const (L(n)->prop, n->sem.binary.att1)) - for (unsigned int i = 0; - i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plan (ret, op_atom[n->kind] ( *(plan_t **) PFarray_at (L(n)->plans,i), @@ -775,8 +797,7 @@ /* consider NumAddConst if attribute att2 is known to be constant */ if (PFprop_const (L(n)->prop, n->sem.binary.att2)) - for (unsigned int i = 0; - i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plan (ret, op_atom[n->kind] ( *(plan_t **) PFarray_at (L(n)->plans,i), @@ -791,7 +812,7 @@ assert (op[n->kind]); - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plan (ret, op[n->kind] ( *(plan_t **) PFarray_at (L(n)->plans, i), @@ -810,8 +831,9 @@ plan_unary (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int i = 0; - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) switch (n->kind) { case la_num_neg: @@ -843,6 +865,7 @@ plan_aggr (PFpa_op_kind_t kind, const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int i = 0; assert (n); assert (n->kind == la_avg || n->kind == la_max @@ -850,7 +873,7 @@ assert (L(n)); assert (L(n)->plans); /* consider each plan in n */ - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plan (ret, aggr (kind, *(plan_t **) PFarray_at (L(n)->plans, i), @@ -873,12 +896,13 @@ plan_count (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int i = 0; assert (n); assert (n->kind == la_count); assert (L(n)); assert (L(n)->plans); /* consider each plan in n */ - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plan (ret, hash_count ( *(plan_t **) PFarray_at (L(n)->plans, i), @@ -919,6 +943,7 @@ PFplanlist_t *ret = new_planlist (); PFplanlist_t *sorted = new_planlist (); PFord_ordering_t ord; + unsigned int i = 0, j = 0; assert (n); assert (n->kind == la_rownum); assert (L(n)); assert (L(n)->plans); @@ -933,11 +958,11 @@ ord = PFord_refine (ord, n->sem.rownum.part); /* then we refine by all the attributes in the sortby parameter */ - for (unsigned int i = 0; i < n->sem.rownum.sortby.count; i++) + for (i = 0; i < n->sem.rownum.sortby.count; i++) ord = PFord_refine (ord, n->sem.rownum.sortby.atts[i]); /* ensure correct input ordering for MergeRowNumber */ - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plans (sorted, ensure_ordering ( *(plan_t **) PFarray_at (L(n)->plans, i), ord)); @@ -946,8 +971,8 @@ sorted = prune_plans (sorted); /* for each remaining plan, generate a MergeRowNumber operator */ - for (unsigned int i = 0; i < PFarray_last (sorted); i++) - for (unsigned int j = 0; j < PFarray_last (L(n)->plans); j++) + for (i = 0; i < PFarray_last (sorted); i++) + for (j = 0; j < PFarray_last (L(n)->plans); j++) add_plan (ret, merge_rownum (*(plan_t **) PFarray_at (sorted, i), n->sem.rownum.attname, n->sem.rownum.part)); @@ -960,13 +985,14 @@ { PFplanlist_t *ret = new_planlist (); plan_t *cheapest_unordered = NULL; + unsigned int i = 0; assert (n); assert (n->kind == la_number); assert (L(n)); assert (L(n)->plans); /* find the cheapest plan for our argument */ - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) if (!cheapest_unordered || costless (*(plan_t **) PFarray_at (L(n)->plans, i), cheapest_unordered)) @@ -987,8 +1013,9 @@ plan_type (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int i = 0; - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plan (ret, type (*(plan_t **) PFarray_at (L(n)->plans, i), n->sem.type.att, n->sem.type.ty, n->sem.type.res)); @@ -1004,8 +1031,9 @@ plan_type_assert (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int i = 0; - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plan (ret, type_assert ( *(plan_t **) PFarray_at (L(n)->plans, i), @@ -1025,12 +1053,13 @@ plan_cast (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int r = 0; assert (n); assert (n->kind == la_cast); assert (L(n)); assert (L(n)->plans); /* consider each plan in R */ - for (unsigned int r = 0; r < PFarray_last (L(n)->plans); r++) + for (r = 0; r < PFarray_last (L(n)->plans); r++) add_plan (ret, cast (*(plan_t **) PFarray_at (L(n)->plans, r), n->sem.type.res, @@ -1051,6 +1080,8 @@ PFpa_op_t* (*llscj) (const PFpa_op_t *, const PFpa_op_t *, const PFty_t, const PFord_ordering_t, const PFord_ordering_t, PFalg_att_t, PFalg_att_t) = NULL; + unsigned short i = 0, o = 0; + unsigned int j = 0, k = 0, l = 0; #ifndef NDEBUG /* ensure that input and output columns have the same name */ @@ -1102,12 +1133,12 @@ n->sem.scjoin.iter) }; /* consider the two possible input orderings */ - for (unsigned short i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) { PFplanlist_t *ordered = new_planlist (); /* sort all plans according to this input ordering */ - for (unsigned int j = 0; j < PFarray_last (R(n)->plans); j++) { + for (j = 0; j < PFarray_last (R(n)->plans); j++) { add_plans (ordered, ensure_ordering ( *(plan_t **) PFarray_at (R(n)->plans, j), @@ -1116,8 +1147,8 @@ /* generate plans for each input and each output ordering */ - for (unsigned int k = 0; k < PFarray_last (ordered); k++) - for (unsigned int l = 0; l < PFarray_last (L(n)->plans); l++) + for (k = 0; k < PFarray_last (ordered); k++) + for (l = 0; l < PFarray_last (L(n)->plans); l++) /* the evaluation of the attribute axis keeps the input order */ if (n->sem.scjoin.axis == alg_attr) add_plan ( @@ -1130,7 +1161,7 @@ n->sem.scjoin.iter, n->sem.scjoin.item)); else - for (unsigned short o = 0; o < 2; o++) + for (o = 0; o < 2; o++) add_plan ( ret, llscj (*(plan_t **) PFarray_at (L(n)->plans, @@ -1162,6 +1193,7 @@ PFplanlist_t *ordered = new_planlist (); plan_t *cheapest_unordered = NULL; plan_t *cheapest_ordered = NULL; + unsigned int i = 0; #ifndef NDEBUG /* ensure that input and output columns have the same name */ @@ -1169,7 +1201,7 @@ #endif /* find the cheapest plan for our argument */ - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) if (!cheapest_unordered || costless (*(plan_t **) PFarray_at (L(n)->plans, i), cheapest_unordered)) @@ -1177,13 +1209,13 @@ = *(plan_t **) PFarray_at (L(n)->plans, i); /* an ordering by `iter' is typically helpful -> sort all plans */ - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plans (ordered, ensure_ordering ( *(plan_t **) PFarray_at (L(n)->plans, i), PFord_refine (PFordering (), n->sem.doc_tbl.iter))); - for (unsigned int i = 0; i < PFarray_last (ordered); i++) + for (i = 0; i < PFarray_last (ordered); i++) if (!cheapest_ordered || costless (*(plan_t **) PFarray_at (ordered, i), cheapest_ordered)) @@ -1216,14 +1248,16 @@ plan_doc_access (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int i = 0; + unsigned int j = 0; assert (n); assert (n->kind == la_doc_access); assert (L(n)); assert (L(n)->plans); assert (R(n)); assert (R(n)->plans); /* for each plan, generate a doc_access operator */ - for (unsigned int i = 0; i < PFarray_last (R(n)->plans); i++) - for (unsigned int j = 0; j < PFarray_last (L(n)->plans); j++) + for (i = 0; i < PFarray_last (R(n)->plans); i++) + for (j = 0; j < PFarray_last (L(n)->plans); j++) add_plan (ret, doc_access ( *(plan_t **) PFarray_at (L(n)->plans, j), @@ -1255,6 +1289,7 @@ PFalg_att_t iter = n->sem.elem.iter_qn; PFalg_att_t pos = n->sem.elem.pos_val; PFalg_att_t item = n->sem.elem.item_qn; + unsigned int i = 0; #ifndef NDEBUG /* ensure that matching columns (iter, pos, item) have the same name */ @@ -1265,27 +1300,27 @@ #endif /* find the cheapest plan for the fragments */ - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) if (!cheapest_frag_plan || costless (*(plan_t **) PFarray_at (L(n)->plans, i), cheapest_frag_plan)) cheapest_frag_plan = *(plan_t **) PFarray_at (L(n)->plans, i); /* find the cheapest plan for the qnames */ - for (unsigned int i = 0; i < PFarray_last (L(R(n))->plans); i++) + for (i = 0; i < PFarray_last (L(R(n))->plans); i++) add_plans (ordered_qn, ensure_ordering ( *(plan_t **) PFarray_at (L(R(n))->plans, i), PFord_refine (PFordering (), iter))); - for (unsigned int i = 0; i < PFarray_last (ordered_qn); i++) + for (i = 0; i < PFarray_last (ordered_qn); i++) if (!cheapest_qn_plan || costless (*(plan_t **) PFarray_at (ordered_qn, i), cheapest_qn_plan)) cheapest_qn_plan = *(plan_t **) PFarray_at (ordered_qn, i); /* find the cheapest plan for the content */ - for (unsigned int i = 0; i < PFarray_last (R(R(n))->plans); i++) + for (i = 0; i < PFarray_last (R(R(n))->plans); i++) add_plans (ordered_cont, ensure_ordering ( *(plan_t **) PFarray_at (R(R(n))->plans, i), @@ -1293,7 +1328,7 @@ PFord_refine (PFordering (), iter), pos))); - for (unsigned int i = 0; i < PFarray_last (ordered_cont); i++) + for (i = 0; i < PFarray_last (ordered_cont); i++) if (!cheapest_cont_plan || costless (*(plan_t **) PFarray_at (ordered_cont, i), cheapest_cont_plan)) @@ -1324,9 +1359,10 @@ { PFplanlist_t *ret = new_planlist (); plan_t *cheapest_plan = NULL; + unsigned int i = 0; /* find the cheapest plan */ - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) if (!cheapest_plan || costless (*(plan_t **) PFarray_at (L(n)->plans, i), cheapest_plan)) @@ -1352,9 +1388,10 @@ { PFplanlist_t *ret = new_planlist (); plan_t *cheapest_plan = NULL; + unsigned int i = 0; /* find the cheapest plan */ - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) if (!cheapest_plan || costless (*(plan_t **) PFarray_at (L(n)->plans, i), cheapest_plan)) @@ -1381,6 +1418,7 @@ PFalg_att_t iter = n->sem.merge_adjacent.iter_in; PFalg_att_t pos = n->sem.merge_adjacent.pos_in; PFalg_att_t item = n->sem.merge_adjacent.item_in; + unsigned int i = 0; #ifndef NDEBUG /* ensure that matching columns (iter, pos, item) have the same name */ @@ -1395,7 +1433,7 @@ assert (R(n)); assert (R(n)->plans); /* find the cheapest plan for the fragments */ - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) if (!cheapest_frag_plan || costless (*(plan_t **) PFarray_at (L(n)->plans, i), cheapest_frag_plan)) @@ -1403,7 +1441,7 @@ /* The merge_adjacent_text_node operator requires its inputs to be properly sorted. */ - for (unsigned int i = 0; i < PFarray_last (R(n)->plans); i++) + for (i = 0; i < PFarray_last (R(n)->plans); i++) add_plans (sorted, ensure_ordering ( *(plan_t **) PFarray_at (R(n)->plans, i), @@ -1411,7 +1449,7 @@ PFord_refine (PFordering (), iter), pos))); - for (unsigned int i = 0; i < PFarray_last (sorted); i++) + for (i = 0; i < PFarray_last (sorted); i++) if (!cheapest_sorted || costless (*(plan_t **) PFarray_at (sorted, i), cheapest_sorted)) @@ -1435,8 +1473,9 @@ plan_roots (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int i = 0; - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plan (ret, roots (*(plan_t **) PFarray_at (L(n)->plans, i))); return ret; @@ -1450,8 +1489,9 @@ plan_fragment (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int i = 0; - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plan (ret, fragment (*(plan_t **) PFarray_at (L(n)->plans, i))); @@ -1466,9 +1506,11 @@ plan_frag_union (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int i = 0; + unsigned int j = 0; - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) - for (unsigned int j = 0; j < PFarray_last (R(n)->plans); j++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) + for (j = 0; j < PFarray_last (R(n)->plans); j++) add_plan (ret, frag_union ( *(plan_t **) PFarray_at (L(n)->plans, i), @@ -1502,9 +1544,11 @@ plan_cond_err (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int i = 0; + unsigned int j = 0; - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) - for (unsigned int j = 0; j < PFarray_last (R(n)->plans); j++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) + for (j = 0; j < PFarray_last (R(n)->plans); j++) add_plan (ret, cond_err ( *(plan_t **) PFarray_at (L(n)->plans, i), @@ -1522,8 +1566,9 @@ plan_concat (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int i = 0; - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plan (ret, fn_concat (*(plan_t **) PFarray_at (L(n)->plans, i), n->sem.binary.res, @@ -1541,8 +1586,9 @@ plan_contains (const PFla_op_t *n) { PFplanlist_t *ret = new_planlist (); + unsigned int i = 0; - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plan (ret, fn_contains (*(plan_t **) PFarray_at (L(n)->plans, i), n->sem.binary.res, @@ -1570,6 +1616,7 @@ PFalg_att_t iter = n->sem.string_join.iter; PFalg_att_t pos = n->sem.string_join.pos; PFalg_att_t item = n->sem.string_join.item; + unsigned int i = 0, j = 0; #ifndef NDEBUG /* ensure that matching columns (iter, pos, item) have the same name */ @@ -1584,22 +1631,22 @@ assert (R(n)); assert (R(n)->plans); /* The string_join operator requires its inputs to be properly sorted. */ - for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++) + for (i = 0; i < PFarray_last (L(n)->plans); i++) add_plans (sorted_n1, ensure_ordering ( *(plan_t **) PFarray_at (L(n)->plans, i), PFord_refine (PFord_refine (PFordering (), iter), pos))); - for (unsigned int i = 0; i < PFarray_last (R(n)->plans); i++) + for (i = 0; i < PFarray_last (R(n)->plans); i++) add_plans (sorted_n2, ensure_ordering ( *(plan_t **) PFarray_at (R(n)->plans, i), PFord_refine (PFordering (), iter))); /* for each remaining plan, generate a string_join operator */ - for (unsigned int i = 0; i < PFarray_last (sorted_n1); i++) - for (unsigned int j = 0; j < PFarray_last (sorted_n2); j++) + for (i = 0; i < PFarray_last (sorted_n1); i++) + for (j = 0; j < PFarray_last (sorted_n2); j++) add_plan (ret, string_join ( *(plan_t **) PFarray_at (sorted_n1, i), @@ -1634,6 +1681,8 @@ plan_t *cheapest_res_plan = NULL; plan_t *cheapest_params = NULL; PFla_op_t *cur; + unsigned int plan = 0; + unsigned int i = 0, j = 0, k = 0; assert (n->kind == la_rec_fix); @@ -1643,7 +1692,7 @@ add_plan (params, rec_nil ()); /* assign logical properties to physical node as well */ - for (unsigned int plan = 0; plan < PFarray_last (params); plan++) + for (plan = 0; plan < PFarray_last (params); plan++) (*(plan_t **) PFarray_at (params, plan))->prop = PFprop(); /* collect the plans for all parameters @@ -1658,7 +1707,7 @@ arg = new_planlist (); new_params = new_planlist (); - for (unsigned int i = 0; i < PFarray_last (LL(cur)->plans); i++) + for (i = 0; i < PFarray_last (LL(cur)->plans); i++) add_plans (seed, ensure_ordering ( *(plan_t **) PFarray_at (LL(cur)->plans, i), @@ -1666,7 +1715,7 @@ seed = prune_plans (seed); - for (unsigned int i = 0; i < PFarray_last (LR(cur)->plans); i++) + for (i = 0; i < PFarray_last (LR(cur)->plans); i++) add_plans (recursion, ensure_ordering ( *(plan_t **) PFarray_at (LR(cur)->plans, i), @@ -1677,9 +1726,9 @@ base = L(cur)->sem.rec_arg.base->plans; /* create new arguments */ - for (unsigned int i = 0; i < PFarray_last (seed); i++) - for (unsigned int j = 0; j < PFarray_last (recursion); j++) - for (unsigned int k = 0; k < PFarray_last (base); k++) + for (i = 0; i < PFarray_last (seed); i++) + for (j = 0; j < PFarray_last (recursion); j++) + for (k = 0; k < PFarray_last (base); k++) add_plan (arg, rec_arg ( *(plan_t **) PFarray_at (seed, i), @@ -1687,20 +1736,20 @@ *(plan_t **) PFarray_at (base, k))); /* assign logical properties to physical node as well */ - for (unsigned int plan = 0; plan < PFarray_last (arg); plan++) + for (plan = 0; plan < PFarray_last (arg); plan++) (*(plan_t **) PFarray_at (arg, plan))->prop = L(cur)->prop; /* create new paramters (new argument + list of paramters obtained so far) */ - for (unsigned int i = 0; i < PFarray_last (arg); i++) - for (unsigned int j = 0; j < PFarray_last (params); j++) + for (i = 0; i < PFarray_last (arg); i++) + for (j = 0; j < PFarray_last (params); j++) add_plan (new_params, rec_param ( *(plan_t **) PFarray_at (arg, i), *(plan_t **) PFarray_at (params, j))); /* assign logical properties to physical node as well */ - for (unsigned int plan = 0; plan < PFarray_last (new_params); plan++) + for (plan = 0; plan < PFarray_last (new_params); plan++) (*(plan_t **) PFarray_at (new_params, plan))->prop = cur->prop; params = new_params; @@ -1711,7 +1760,7 @@ that might evaluate the recursion more than once */ /* find the cheapest plan for the params */ - for (unsigned int i = 0; i < PFarray_last (params); i++) + for (i = 0; i < PFarray_last (params); i++) if (!cheapest_params || costless (*(plan_t **) PFarray_at (params, i), cheapest_params)) @@ -1721,7 +1770,7 @@ res = R(n)->plans; /* find the cheapest plan for the result */ - for (unsigned int i = 0; i < PFarray_last (res); i++) + for (i = 0; i < PFarray_last (res); i++) if (!cheapest_res_plan || costless (*(plan_t **) PFarray_at (res, i), cheapest_res_plan)) @@ -1740,6 +1789,7 @@ plan_recursion_base (PFla_op_t *n, PFord_ordering_t ord) { PFplanlist_t *plans = new_planlist (); + unsigned int plan = 0; add_plan (plans, rec_base (n->schema, ord)); @@ -1747,7 +1797,7 @@ n->plans = plans; /* assign logical properties to physical node as well */ - for (unsigned int plan = 0; plan < PFarray_last (plans); plan++) + for (plan = 0; plan < PFarray_last (plans); plan++) (*(plan_t **) PFarray_at (plans, plan))->prop = n->prop; } @@ -1882,6 +1932,8 @@ /* the best suitable ordering in `unordered' we found so far */ PFord_ordering_t best_order = PFordering (); + unsigned int j = 0, k = 0, plan = 0; + /* * If the output does not need to be sorted * just return the unordered input. @@ -1894,14 +1946,14 @@ /* * See if we can benefit from some existing sorting */ - for (unsigned int j = 0; j < PFord_set_count (unordered->orderings); j++) { + for (j = 0; j < PFord_set_count (unordered->orderings); j++) { /* the existing order we currently look at */ PFord_ordering_t existing = PFord_set_at (unordered->orderings, j); PFord_ordering_t prefix = PFordering (); /* collect the common prefix of required and existing ordering */ - for (unsigned int k = 0; + for (k = 0; k < PFord_count (required) && k < PFord_count (existing) && PFord_order_at (required, k) == PFord_order_at (existing, k); k++) @@ -1943,7 +1995,7 @@ add_plan (ret, std_sort (unordered, required)); /* assign logical properties to the additional physical node as well */ - for (unsigned int plan = 0; plan < PFarray_last (ret); plan++) + for (plan = 0; plan < PFarray_last (ret); plan++) (*(plan_t **) PFarray_at (ret, plan))->prop = unordered->prop; return ret; @@ -1957,17 +2009,18 @@ prune_plans (PFplanlist_t *planlist) { PFplanlist_t *ret = new_planlist (); + unsigned int i = 0, j = 0; /* Iterate over all plans. Add it to the return value if there's * not yet a better plan. */ - for (unsigned int i = 0; i < PFarray_last (planlist); i++) { + for (i = 0; i < PFarray_last (planlist); i++) { /* assume there is no better plan */ bool found_better = false; /* but maybe there is one already in our return list */ - for (unsigned int j = 0; j < PFarray_last (ret); j++) + for (j = 0; j < PFarray_last (ret); j++) if (better_or_equal (*(plan_t **) PFarray_at (ret, j), *(plan_t **) PFarray_at (planlist, i))) { found_better = true; @@ -1976,7 +2029,7 @@ /* if not, is there a better plan to follow in `planlist'? */ if (!found_better) - for (unsigned int j = i + 1; j < PFarray_last (planlist); j++) + for (j = i + 1; j < PFarray_last (planlist); j++) if (better_or_equal (*(plan_t **) PFarray_at (planlist, j), *(plan_t **) PFarray_at (planlist, i))) { found_better = true; @@ -2018,16 +2071,18 @@ static bool better_or_equal (const plan_t *a, const plan_t *b) { + unsigned int i = 0, j = 0; + /* If a does not cost less than b, return false. */ if (costless (b, a)) return false; /* a is only better than b if it satisfies *all* the orderings in b. */ - for (unsigned int i = 0; i < PFord_set_count (b->orderings); i++) { + for (i = 0; i < PFord_set_count (b->orderings); i++) { bool satisfied = false; - for (unsigned int j = 0; j < PFord_set_count (a->orderings); j++) { + for (j = 0; j < PFord_set_count (a->orderings); j++) { /* * If the this order in a implies the current order in b, * we are satisfied. @@ -2073,6 +2128,7 @@ plan_subexpression (PFla_op_t *n) { PFplanlist_t *plans = NULL; + unsigned int i = 0, plan = 0; /* * Skip if we already compiled this subexpression. @@ -2089,7 +2145,7 @@ default: /* translate bottom-up (ensure that the fragment information is translated after the value part) */ - for (unsigned int i = PFLA_OP_MAXCHILD; i > 0; i--) + for (i = PFLA_OP_MAXCHILD; i > 0; i--) if (n->child[i - 1]) plan_subexpression (n->child[i - 1]); } @@ -2196,7 +2252,7 @@ /* generate plans for the body of the recursion for each ordering */ - for (unsigned int i = 0; i < PFord_set_count (orderings); i++) { + for (i = 0; i < PFord_set_count (orderings); i++) { ord = PFord_set_at (orderings, i); cur = L(n); @@ -2243,7 +2299,7 @@ to different node constructions for the same constructor. */ /* find the cheapest plan for the recursion */ - for (unsigned int i = 0; i < PFarray_last (rec_list); i++) + for (i = 0; i < PFarray_last (rec_list); i++) if (!cheapest_rec_plan || costless (*(plan_t **) PFarray_at (rec_list, i), cheapest_rec_plan)) @@ -2273,7 +2329,7 @@ n->plans = plans; /* assign logical properties to physical node as well */ - for (unsigned int plan = 0; plan < PFarray_last (plans); plan++) + for (plan = 0; plan < PFarray_last (plans); plan++) (*(plan_t **) PFarray_at (plans, plan))->prop = n->prop; } @@ -2299,6 +2355,7 @@ PFplan (PFla_op_t *root) { PFpa_op_t *ret = NULL; + unsigned int i = 0; /* compute all interesting plans for root */ plan_subexpression (root); @@ -2309,7 +2366,7 @@ ret = *(plan_t **) PFarray_at (root->plans, 0); - for (unsigned int i = 1; i < PFarray_last (root->plans); i++) + for (i = 1; i < PFarray_last (root->plans); i++) if (costless (*(plan_t **) PFarray_at (root->plans, i), ret)) ret = *(plan_t **) PFarray_at (root->plans, i); Index: compiler/algebra/properties.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/properties.c,v retrieving revision 1.22 diff -u -r1.22 properties.c --- compiler/algebra/properties.c 2 Aug 2006 10:02:22 -0000 1.22 +++ compiler/algebra/properties.c 1 Nov 2006 20:59:00 -0000 @@ -132,11 +132,13 @@ static void create_prop (PFla_op_t *n) { + unsigned int i = 0; + assert (n); if (n->bit_dag) return; - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) create_prop (n->child[i]); n->bit_dag = true; Index: compiler/algebra/map/intro_proxy.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/map/intro_proxy.c,v retrieving revision 1.10 diff -u -r1.10 intro_proxy.c --- compiler/algebra/map/intro_proxy.c 24 Oct 2006 09:29:49 -0000 1.10 +++ compiler/algebra/map/intro_proxy.c 1 Nov 2006 20:59:00 -0000 @@ -403,6 +403,7 @@ PFla_op_t *entry, int join) { int cur_op, res_op; + unsigned int i = 0; assert (p); assert (exit); @@ -449,7 +450,7 @@ res_op = OP_UNDEF; /* traverse children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) { + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) { join = only_eqjoin_refs_worker (p->child[i], exit, entry, cur_op); /* Bail out if we found a mismatch */ if (join == OP_NOJOIN) @@ -2049,7 +2050,7 @@ req_count = proxy1->sem.proxy.req_cols.count; req_col_names = PFmalloc (req_count * sizeof (PFalg_proj_t)); - for (unsigned int i = 0; i < req_count; i++) { + for (i = 0; i < req_count; i++) { cur_col = proxy1->sem.proxy.req_cols.atts[i]; req_col_names[i] = PFalg_proj (cur_col, cur_col); } @@ -2261,7 +2262,9 @@ static bool node_in_list (PFla_op_t *p, PFarray_t *node_list) { - for (unsigned int i = 0; i < PFarray_last (node_list); i++) + unsigned int i = 0; + + for (i = 0; i < PFarray_last (node_list); i++) if (*(PFla_op_t **) PFarray_at (node_list, i) == p) return true; return false; @@ -2277,6 +2280,7 @@ bool (* check_entry) (PFla_op_t *)) { PFla_op_t *node; + unsigned int i = 0; assert (p); assert (checked_nodes); @@ -2288,7 +2292,7 @@ SEEN(p) = true; /* traverse children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) { + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) { node = find_proxy_entry (p->child[i], checked_nodes, check_entry); if (node) return node; } @@ -2322,6 +2326,7 @@ bool (* check_exit) (PFla_op_t *, PFla_op_t *)) { PFla_op_t *node; + unsigned int i = 0; assert (p); @@ -2346,7 +2351,7 @@ IN(p) = true; /* traverse children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) { + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) { node = find_proxy_exit (p->child[i], entry, exit, exit_refs, check_exit); /* store the first exit node we find */ if (node && !exit) @@ -2377,6 +2382,8 @@ static void find_conflicts (PFla_op_t *p, PFarray_t *conflict_list) { + unsigned int i = 0; + assert (p); assert (conflict_list); @@ -2398,7 +2405,7 @@ *(PFla_op_t **) PFarray_add (conflict_list) = p->sem.rec_arg.base; /* traverse children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) find_conflicts (p->child[i], conflict_list); } Index: compiler/algebra/map/map_ori_names.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/map/map_ori_names.c,v retrieving revision 1.4 diff -u -r1.4 map_ori_names.c --- compiler/algebra/map/map_ori_names.c 10 Oct 2006 14:02:43 -0000 1.4 +++ compiler/algebra/map/map_ori_names.c 1 Nov 2006 20:59:00 -0000 @@ -75,7 +75,9 @@ static PFla_op_t * lookup (PFarray_t *map, PFla_op_t *unq) { - for (unsigned int i = 0; i < PFarray_last (map); i++) + unsigned int i = 0; + + for (i = 0; i < PFarray_last (map); i++) if (((ori_unq_map *) PFarray_at (map, i))->unq == unq) return ((ori_unq_map *) PFarray_at (map, i))->ori; @@ -101,11 +103,11 @@ PFalg_proj_t *projlist = PFmalloc (c->schema.count * sizeof (PFalg_proj_t)); bool renamed = false; - unsigned int count = 0; + unsigned int count = 0, i = 0; ori_free = free_attr ? ONAME(p, free_attr) : att_NULL; - for (unsigned int i = 0; i < c->schema.count; i++) { + for (i = 0; i < c->schema.count; i++) { ori_old = c->schema.items[i].name; /* Enforce projection if column free_attr @@ -172,6 +174,7 @@ map_ori_names (PFla_op_t *p, PFarray_t *map) { PFla_op_t *res = NULL; + unsigned int i = 0; assert (p); @@ -182,7 +185,7 @@ SEEN(p) = true; /* apply name mapping for children bottom up */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) map_ori_names (p->child[i], map); /* action code */ @@ -201,7 +204,7 @@ attlist.atts = PFmalloc (attlist.count * sizeof (PFalg_attlist_t)); - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) attlist.atts[i] = ONAME(p, p->schema.items[i].name); res = PFla_lit_tbl_ (attlist, @@ -216,7 +219,7 @@ schema.items = PFmalloc (schema.count * sizeof (PFalg_schema_t)); - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) schema.items[i] = (struct PFalg_schm_item_t) { .name = ONAME(p, p->schema.items[i].name), @@ -268,7 +271,7 @@ sizeof (PFalg_proj_t)); count = 0; - for (unsigned int i = 0; i < right->schema.count; i++) { + for (i = 0; i < right->schema.count; i++) { ori_old = right->schema.items[i].name; /* lookup unique name for column @a ori_old */ @@ -315,7 +318,7 @@ aware eqjoin operator. */ projlist = PFmalloc (p->schema.count * sizeof (PFalg_proj_t)); - for (unsigned int i = 0; i < p->schema.count; i++) { + for (i = 0; i < p->schema.count; i++) { ori = ONAME(p, p->schema.items[i].name); projlist[i] = proj (ori, ori); } @@ -328,14 +331,14 @@ PFalg_proj_t *projlist = PFmalloc (p->schema.count * sizeof (PFalg_proj_t)); PFalg_att_t new, old; - unsigned int count = 0; + unsigned int count = 0, j = 0; bool renamed = false; left = O(L(p)); - for (unsigned int i = 0; i < left->schema.count; i++) { + for (i = 0; i < left->schema.count; i++) { old = left->schema.items[i].name; - for (unsigned int j = 0; j < p->sem.proj.count; j++) + for (j = 0; j < p->sem.proj.count; j++) /* we may get multiple hits */ if (old == PFprop_ori_name_left ( p->prop, @@ -431,7 +434,7 @@ sortby.atts = PFmalloc (sortby.count * sizeof (PFalg_attlist_t)); - for (unsigned int i = 0; i < sortby.count; i++) + for (i = 0; i < sortby.count; i++) sortby.atts[i] = ONAME(p, p->sem.rownum.sortby.atts[i]); res = rownum (SEC_PROJ(LEFT, p, p->sem.rownum.attname), @@ -604,7 +607,7 @@ count == L(p)->schema.count && count == R(p)->schema.count); - for (unsigned int i = 0; i < count; i++) { + for (i = 0; i < count; i++) { unq = p->sem.rec_arg.base->schema.items[i].name; base_ori = ONAME(p->sem.rec_arg.base, unq); seed_ori = ONAME(L(p), unq); @@ -635,7 +638,7 @@ schema.items = PFmalloc (schema.count * sizeof (PFalg_schema_t)); - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) schema.items[i] = (struct PFalg_schm_item_t) { .name = ONAME(p, p->schema.items[i].name), Index: compiler/algebra/map/map_unq_names.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/map/map_unq_names.c,v retrieving revision 1.4 diff -u -r1.4 map_unq_names.c --- compiler/algebra/map/map_unq_names.c 10 Oct 2006 14:02:43 -0000 1.4 +++ compiler/algebra/map/map_unq_names.c 1 Nov 2006 20:59:00 -0000 @@ -70,7 +70,9 @@ static PFla_op_t * lookup (PFarray_t *map, PFla_op_t *ori) { - for (unsigned int i = 0; i < PFarray_last (map); i++) + unsigned int i = 0; + + for (i = 0; i < PFarray_last (map); i++) if (((ori_unq_map *) PFarray_at (map, i))->ori == ori) return ((ori_unq_map *) PFarray_at (map, i))->unq; @@ -109,6 +111,7 @@ map_unq_names (PFla_op_t *p, PFarray_t *map) { PFla_op_t *res = NULL; + unsigned int i = 0; assert (p); @@ -119,7 +122,7 @@ SEEN(p) = true; /* apply name mapping for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) map_unq_names (p->child[i], map); /* action code */ @@ -137,7 +140,7 @@ attlist.atts = PFmalloc (attlist.count * sizeof (PFalg_attlist_t)); - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) attlist.atts[i] = UNAME(p, p->schema.items[i].name); res = PFla_lit_tbl_ (attlist, @@ -152,7 +155,7 @@ schema.items = PFmalloc (schema.count * sizeof (PFalg_schema_t)); - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) schema.items[i] = (struct PFalg_schm_item_t) { .name = UNAME(p, p->schema.items[i].name), @@ -187,7 +190,7 @@ count1 = 0; count2 = 0; - for (unsigned int i = 0; i < left->schema.count; i++) { + for (i = 0; i < left->schema.count; i++) { unq = left->schema.items[i].name; ori = PFprop_ori_name_left (p->prop, unq); assert (ori); @@ -197,7 +200,7 @@ unq); } - for (unsigned int i = 0; i < right->schema.count; i++) { + for (i = 0; i < right->schema.count; i++) { unq = right->schema.items[i].name; ori = PFprop_ori_name_right (p->prop, unq); assert (ori); @@ -240,7 +243,7 @@ count2 = 0; projlist2[count2++] = proj (att2_unq, att2_unq); - for (unsigned int i = 0; i < right->schema.count; i++) { + for (i = 0; i < right->schema.count; i++) { r_unq = right->schema.items[i].name; ori = PFprop_ori_name_right (p->prop, r_unq); assert (ori); @@ -271,12 +274,12 @@ PFalg_proj_t *projlist = PFmalloc (p->schema.count * sizeof (PFalg_proj_t)); PFalg_att_t unq; - unsigned int count = 0; + unsigned int count = 0, j = 0; left = U(L(p)); - for (unsigned int i = 0; i < left->schema.count; i++) - for (unsigned int j = 0; j < p->sem.proj.count; j++) + for (i = 0; i < left->schema.count; i++) + for (j = 0; j < p->sem.proj.count; j++) if ((unq = UNAME(p, p->sem.proj.items[j].new)) == left->schema.items[i].name) { projlist[count++] = proj (unq, unq); @@ -312,7 +315,7 @@ projlist2 = PFmalloc (p->schema.count * sizeof (PFalg_proj_t)); - for (unsigned int i = 0; i < p->schema.count; i++) { + for (i = 0; i < p->schema.count; i++) { ori = p->schema.items[i].name; unq = UNAME(p, ori); projlist1[i] = proj (unq, @@ -394,7 +397,7 @@ sortby.atts = PFmalloc (sortby.count * sizeof (PFalg_attlist_t)); - for (unsigned int i = 0; i < sortby.count; i++) + for (i = 0; i < sortby.count; i++) sortby.atts[i] = UNAME(p, p->sem.rownum.sortby.atts[i]); res = rownum (U(L(p)), @@ -566,7 +569,7 @@ PFalg_proj_t *projlist = PFmalloc (p->schema.count * sizeof (PFalg_proj_t)); - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) projlist[i] = proj (UNAME(p, p->schema.items[i].name), UNAME(R(p), p->schema.items[i].name)); @@ -584,7 +587,7 @@ schema.items = PFmalloc (schema.count * sizeof (PFalg_schema_t)); - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) schema.items[i] = (struct PFalg_schm_item_t) { .name = UNAME(p, p->schema.items[i].name), Index: compiler/algebra/map/resolve_proxy.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/map/resolve_proxy.c,v retrieving revision 1.2 diff -u -r1.2 resolve_proxy.c --- compiler/algebra/map/resolve_proxy.c 27 Sep 2006 12:03:50 -0000 1.2 +++ compiler/algebra/map/resolve_proxy.c 1 Nov 2006 20:59:00 -0000 @@ -43,6 +43,8 @@ static void resolve_proxies (PFla_op_t *p) { + unsigned int i = 0; + assert (p); /* look at each node only once */ @@ -52,7 +54,7 @@ SEEN(p) = true; /* traverse children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) resolve_proxies (p->child[i]); if (p->kind == la_proxy || p->kind == la_proxy_base) Index: compiler/algebra/opt/opt_complex.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_complex.c,v retrieving revision 1.12 diff -u -r1.12 opt_complex.c --- compiler/algebra/opt/opt_complex.c 27 Oct 2006 10:09:02 -0000 1.12 +++ compiler/algebra/opt/opt_complex.c 1 Nov 2006 20:59:00 -0000 @@ -59,6 +59,7 @@ static void opt_complex (PFla_op_t *p) { + unsigned int i = 0; assert (p); /* rewrite each node only once */ @@ -68,7 +69,7 @@ SEEN(p) = true; /* apply complex optimization for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) opt_complex (p->child[i]); /* action code */ @@ -93,7 +94,7 @@ PFalg_tuple_t *tuples = PFmalloc (count * sizeof (*(tuples)));; - for (unsigned int i = 0; i < count; i++) { + for (i = 0; i < count; i++) { tuples[i].atoms = PFmalloc (sizeof (*(tuples[i].atoms))); tuples[i].atoms[0] = p->sem.attach.value; tuples[i].count = 1; @@ -107,7 +108,7 @@ references. (Columns that are not required may be still referenced by the following operators.) */ - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) proj[i] = PFalg_proj (p->schema.items[i].name, p->sem.attach.attname); @@ -151,7 +152,7 @@ bool right_arg_req = false; /* discard join attributes as one of them always remains */ - for (unsigned int i = 0; i < L(p)->schema.count; i++) { + for (i = 0; i < L(p)->schema.count; i++) { left_arg_req = left_arg_req || (PFprop_unq_name ( L(p)->prop, @@ -179,12 +180,12 @@ sizeof (PFalg_proj_t)); unsigned int count = 0; - for (unsigned int i = 0; i < L(p)->schema.count; i++) + for (i = 0; i < L(p)->schema.count; i++) proj[count++] = PFalg_proj ( L(p)->schema.items[i].name, p->sem.eqjoin.att2); - for (unsigned int i = 0; i < R(p)->schema.count; i++) + for (i = 0; i < R(p)->schema.count; i++) proj[count++] = PFalg_proj ( R(p)->schema.items[i].name, R(p)->schema.items[i].name); @@ -194,7 +195,7 @@ } /* discard join attributes as one of them always remains */ - for (unsigned int i = 0; i < R(p)->schema.count; i++) { + for (i = 0; i < R(p)->schema.count; i++) { right_arg_req = right_arg_req || (PFprop_unq_name ( R(p)->prop, @@ -222,12 +223,12 @@ sizeof (PFalg_proj_t)); unsigned int count = 0; - for (unsigned int i = 0; i < L(p)->schema.count; i++) + for (i = 0; i < L(p)->schema.count; i++) proj[count++] = PFalg_proj ( L(p)->schema.items[i].name, L(p)->schema.items[i].name); - for (unsigned int i = 0; i < R(p)->schema.count; i++) + for (i = 0; i < R(p)->schema.count; i++) proj[count++] = PFalg_proj ( R(p)->schema.items[i].name, p->sem.eqjoin.att1); Index: compiler/algebra/opt/opt_const.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_const.c,v retrieving revision 1.12 diff -u -r1.12 opt_const.c --- compiler/algebra/opt/opt_const.c 27 Sep 2006 12:03:50 -0000 1.12 +++ compiler/algebra/opt/opt_const.c 1 Nov 2006 20:59:00 -0000 @@ -65,13 +65,14 @@ { PFla_op_t *rel; unsigned int count = 0; + unsigned int i = 0; PFalg_proj_t *atts = PFmalloc ((p->schema.count - 1) * sizeof (PFalg_proj_t)); /* avoid attach if @a att is the only column */ if (p->schema.count == 1) return p; - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) if (p->schema.items[i].name != att) atts[count++] = PFalg_proj (p->schema.items[i].name, p->schema.items[i].name); @@ -85,6 +86,7 @@ static void opt_const (PFla_op_t *p, bool no_attach) { + unsigned int i = 0; assert (p); /* rewrite each node only once */ @@ -94,7 +96,7 @@ SEEN(p) = true; /* apply constant optimization for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) opt_const (p->child[i], no_attach); /* avoid applying rules that only introduce new attach @@ -205,7 +207,7 @@ left_atts = PFmalloc (L(p)->schema.count * sizeof (PFalg_proj_t)); - for (unsigned int i = 0; i < L(p)->schema.count; i++) + for (i = 0; i < L(p)->schema.count; i++) left_atts[i] = PFalg_proj (L(p)->schema.items[i].name, L(p)->schema.items[i].name); @@ -226,7 +228,7 @@ right_atts = PFmalloc (L(p)->schema.count * sizeof (PFalg_proj_t)); - for (unsigned int i = 0; i < R(p)->schema.count; i++) + for (i = 0; i < R(p)->schema.count; i++) right_atts[i] = PFalg_proj (R(p)->schema.items[i].name, R(p)->schema.items[i].name); @@ -279,7 +281,7 @@ right_atts = PFmalloc (R(p)->schema.count * sizeof (PFalg_proj_t)); - for (unsigned int i = 0; i < R(p)->schema.count; i++) + for (i = 0; i < R(p)->schema.count; i++) right_atts[i] = PFalg_proj (R(p)->schema.items[i].name, R(p)->schema.items[i].name); @@ -314,7 +316,7 @@ left_atts = PFmalloc (L(p)->schema.count * sizeof (PFalg_proj_t)); - for (unsigned int i = 0; i < L(p)->schema.count; i++) + for (i = 0; i < L(p)->schema.count; i++) left_atts[i] = PFalg_proj (L(p)->schema.items[i].name, L(p)->schema.items[i].name); @@ -378,7 +380,7 @@ bool all_const = true; bool all_match = true; - for (unsigned int i = 0; i < p->schema.count; i++) { + for (i = 0; i < p->schema.count; i++) { att = p->schema.items[i].name; all_const = all_const && PFprop_const_left (p->prop, att) && @@ -413,7 +415,7 @@ case la_distinct: { - unsigned int i, count; + unsigned int count; /* check number of non-constant columns */ for (count = 0, i = 0; i < p->schema.count; i++) @@ -602,7 +604,7 @@ PFalg_att_t *atts = PFmalloc (p->sem.rownum.sortby.count * sizeof (PFalg_att_t)); - for (unsigned int i = 0; i < p->sem.rownum.sortby.count; i++) + for (i = 0; i < p->sem.rownum.sortby.count; i++) if (!PFprop_const (p->prop, p->sem.rownum.sortby.atts[i])) atts[count++] = p->sem.rownum.sortby.atts[i]; Index: compiler/algebra/opt/opt_dom.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_dom.c,v retrieving revision 1.5 diff -u -r1.5 opt_dom.c --- compiler/algebra/opt/opt_dom.c 19 Jun 2006 08:56:15 -0000 1.5 +++ compiler/algebra/opt/opt_dom.c 1 Nov 2006 20:59:00 -0000 @@ -57,6 +57,7 @@ static void opt_dom (PFla_op_t *p) { + unsigned int i = 0; assert (p); /* rewrite each node only once */ @@ -66,7 +67,7 @@ SEEN(p) = true; /* apply domain optimization for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) opt_dom (p->child[i]); /* action code */ @@ -78,8 +79,9 @@ * the result of the difference operation will be empty. */ unsigned int all_subdom = 0; - for (unsigned int i = 0; i < L(p)->schema.count; i++) - for (unsigned int j = 0; j < R(p)->schema.count; j++) + unsigned int j = 0; + for (i = 0; i < L(p)->schema.count; i++) + for (j = 0; j < R(p)->schema.count; j++) if (L(p)->schema.items[i].name == R(p)->schema.items[j].name && PFprop_subdom ( Index: compiler/algebra/opt/opt_general.brg =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_general.brg,v retrieving revision 1.14 diff -u -r1.14 opt_general.brg --- compiler/algebra/opt/opt_general.brg 27 Oct 2006 09:58:52 -0000 1.14 +++ compiler/algebra/opt/opt_general.brg 1 Nov 2006 20:59:01 -0000 @@ -335,7 +335,7 @@ bool rewritten = false; short old_state_label; - unsigned short i; + unsigned short i = 0; do { assert (STATE_LABEL (p)); @@ -346,7 +346,7 @@ assert (rule); /* initialize the kids[] vector */ - for (unsigned short i = 0; i < MAX_KIDS; i++) + for (i = 0; i < MAX_KIDS; i++) kids[i] = NULL; /* @@ -413,7 +413,8 @@ tuple). */ if (R(p)->sem.lit_tbl.count == 1) { PFla_op_t *ret = L(p); - for (unsigned int i = 0; i < R(p)->schema.count; i++) + unsigned int i = 0; + for (i = 0; i < R(p)->schema.count; i++) ret = PFla_attach (ret, R(p)->schema.items[i].name, R(p)->sem.lit_tbl.tuples[0].atoms[i]); *p = *(ret); @@ -426,7 +427,8 @@ tuple). */ if (L(p)->sem.lit_tbl.count == 1) { PFla_op_t *ret = R(p); - for (unsigned int i = 0; i < L(p)->schema.count; i++) + unsigned int i = 0; + for (i = 0; i < L(p)->schema.count; i++) ret = PFla_attach (ret, L(p)->schema.items[i].name, L(p)->sem.lit_tbl.tuples[0].atoms[i]); *p = *(ret); @@ -445,8 +447,9 @@ * avoid a 1:1 column check.) */ bool renamed = false; + unsigned int i = 0; - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) renamed = renamed || (p->sem.proj.items[i].new != p->sem.proj.items[i].old); @@ -463,7 +466,8 @@ /* only rewrite if there are more than one columns */ if (p->schema.count > 1) { bool found = false, rewrite = true; - for (unsigned int i = 0; i < p->schema.count; i++) + unsigned int i = 0; + for (i = 0; i < p->schema.count; i++) if (p->sem.proj.items[i].old == L(p)->sem.attach.attname) { found = true; rewrite = rewrite && @@ -476,9 +480,9 @@ if (found && rewrite) { PFalg_proj_t *proj = PFmalloc ((p->schema.count - 1) * sizeof (PFalg_proj_t)); - unsigned int count = 0; + unsigned int count = 0, j = 0; - for (unsigned int j = 0; j < p->schema.count; j++) + for (j = 0; j < p->schema.count; j++) if (L(p)->sem.attach.attname != p->sem.proj.items[j].old) proj[count++] = p->sem.proj.items[j]; @@ -801,8 +805,9 @@ /* replace rownum by projection if it only contains one sort (and no partioning) criterion that is of type nat */ if (!p->sem.rownum.part && - p->sem.rownum.sortby.count == 1) - for (unsigned int i = 0; i < p->schema.count; i++) { + p->sem.rownum.sortby.count == 1) { + unsigned int i = 0; + for (i = 0; i < p->schema.count; i++) { PFalg_att_t cur_col = p->schema.items[i].name; if (cur_col == p->sem.rownum.sortby.atts[0] && @@ -828,6 +833,7 @@ break; } } + } break; /* Rel: number (number (Rel)) */ @@ -837,8 +843,9 @@ PFalg_proj_t *proj = PFmalloc ( p->schema.count * sizeof (PFalg_proj_t)); + unsigned int i = 0; /* copy property list */ - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) if (p->sem.number.attname == p->schema.items[i].name) proj[i] = PFalg_proj (p->sem.number.attname, L(p)->sem.number.attname); @@ -861,8 +868,9 @@ PFalg_proj_t *proj = PFmalloc ( (count + 1) * sizeof (PFalg_proj_t)); + unsigned int i = 0; /* copy property list */ - for (unsigned int i = 0; i < count; i++) + for (i = 0; i < count; i++) proj[i] = L(p)->sem.proj.items[i]; proj[count] = PFalg_proj (p->sem.number.attname, @@ -963,7 +971,8 @@ * type, replace it by a projection. */ bool cast_req = true; - for (unsigned int i = 0; i < p->schema.count; i++) + unsigned int i = 0; + for (i = 0; i < p->schema.count; i++) if (p->sem.type.att == p->schema.items[i].name && p->sem.type.ty == p->schema.items[i].type) { cast_req = false; @@ -973,8 +982,9 @@ if (!cast_req) { PFalg_proj_t *proj = PFmalloc (p->schema.count * sizeof (PFalg_proj_t)); + unsigned int j = 0; - for (unsigned int j = 0; j < p->schema.count; j++) + for (j = 0; j < p->schema.count; j++) if (p->schema.items[j].name != p->sem.type.res) { proj[j] = PFalg_proj (p->schema.items[j].name, p->schema.items[j].name); Index: compiler/algebra/opt/opt_icol.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_icol.c,v retrieving revision 1.12 diff -u -r1.12 opt_icol.c --- compiler/algebra/opt/opt_icol.c 27 Sep 2006 12:03:50 -0000 1.12 +++ compiler/algebra/opt/opt_icol.c 1 Nov 2006 20:59:01 -0000 @@ -63,6 +63,7 @@ opt_icol (PFla_op_t *p) { bool bottom_up = true; + unsigned int i = 0; assert (p); @@ -84,7 +85,7 @@ if (bottom_up) /* apply icol optimization for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) opt_icol (p->child[i]); /* action code */ @@ -102,22 +103,23 @@ /* create list of tuples each containing a list of atoms */ PFalg_tuple_t *tuples = PFmalloc (p->sem.lit_tbl.count * sizeof (*(tuples)));; - for (unsigned int i = 0; i < p->sem.lit_tbl.count; i++) + for (i = 0; i < p->sem.lit_tbl.count; i++) tuples[i].atoms = PFmalloc (count * sizeof (*(tuples[i].atoms))); count = 0; - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) if (PFprop_icol (p->prop, p->schema.items[i].name)) { + unsigned int j = 0; /* retain matching values in literal table */ atts[count] = p->schema.items[i].name; - for (unsigned int j = 0; j < p->sem.lit_tbl.count; j++) + for (j = 0; j < p->sem.lit_tbl.count; j++) tuples[j].atoms[count] = p->sem.lit_tbl.tuples[j].atoms[i]; count++; } - for (unsigned int i = 0; i < p->sem.lit_tbl.count; i++) + for (i = 0; i < p->sem.lit_tbl.count; i++) tuples[i].count = count; *p = *PFla_lit_tbl_ (PFalg_attlist_ (count, atts), @@ -125,6 +127,7 @@ tuples); SEEN(p) = true; } else if (!count && p->schema.count > 1) { + unsigned int j = 0; /* prune everything except one column */ /* create new list of attributes */ @@ -133,13 +136,13 @@ /* create list of tuples each containing a list of atoms */ PFalg_tuple_t *tuples = PFmalloc (p->sem.lit_tbl.count * sizeof (*(tuples)));; - for (unsigned int i = 0; i < p->sem.lit_tbl.count; i++) + for (i = 0; i < p->sem.lit_tbl.count; i++) tuples[i].atoms = PFmalloc (1 * sizeof (*(tuples[i].atoms))); /* retain matching values in literal table */ atts[0] = p->schema.items[0].name; - for (unsigned int j = 0; j < p->sem.lit_tbl.count; j++) { + for (j = 0; j < p->sem.lit_tbl.count; j++) { tuples[j].atoms[0] = PFalg_lit_nat (42); tuples[j].count = 1; } @@ -163,7 +166,7 @@ sizeof (*(schema.items))); count = 0; /* throw out all columns that are not in the icols list */ - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) if (PFprop_icol (p->prop, p->schema.items[i].name)) { schema.items[count++] = p->schema.items[i]; } @@ -201,13 +204,14 @@ unsigned int count = PFprop_icols_count (p->prop); if (count < p->schema.count) { PFalg_proj_t *proj; + unsigned int j = 0; /* ensure that at least one column remains! */ count = count?count:1; proj = PFmalloc (count * sizeof (PFalg_proj_t)); count = 0; - for (unsigned int j = 0; j < p->sem.proj.count; j++) + for (j = 0; j < p->sem.proj.count; j++) if (PFprop_icol (p->prop, p->sem.proj.items[j].new)) proj[count++] = p->sem.proj.items[j]; @@ -240,7 +244,7 @@ PFalg_proj_t *atts = PFmalloc (icols.count * sizeof (PFalg_proj_t)); - for (unsigned int i = 0; i < icols.count; i++) + for (i = 0; i < icols.count; i++) atts[i] = PFalg_proj (icols.atts[i], icols.atts[i]); ret = PFla_project_ (L(p), icols.count, atts); @@ -257,7 +261,7 @@ PFla_op_t *ret; PFalg_proj_t *atts = PFmalloc (1 * sizeof (PFalg_proj_t)); - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) if (PFprop_icol_left (p->prop, p->schema.items[i].name)) { atts[0] = PFalg_proj (p->schema.items[i].name, @@ -493,7 +497,7 @@ sizeof (PFalg_schema_t)); schema.count = L(p)->schema.count; - for (unsigned int i = 0; i < L(p)->schema.count; i++) + for (i = 0; i < L(p)->schema.count; i++) schema.items[i] = L(p)->schema.items[i]; p->sem.rec_arg.base->schema = schema; @@ -514,7 +518,7 @@ proj = PFmalloc (L(p)->schema.count * sizeof (PFalg_proj_t)); - for (unsigned int i = 0; i < L(p)->schema.count; i++) + for (i = 0; i < L(p)->schema.count; i++) proj[i] = PFalg_proj (L(p)->schema.items[i].name, L(p)->schema.items[i].name); Index: compiler/algebra/opt/opt_join_pd.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_join_pd.c,v retrieving revision 1.8 diff -u -r1.8 opt_join_pd.c --- compiler/algebra/opt/opt_join_pd.c 31 Oct 2006 09:57:19 -0000 1.8 +++ compiler/algebra/opt/opt_join_pd.c 1 Nov 2006 20:59:01 -0000 @@ -120,13 +120,15 @@ static bool contains_node_worker (PFla_op_t *n, PFla_op_t *m) { + unsigned int i = 0; + if (n == m) return true; if (n->bit_in) return false; - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) if (contains_node_worker (n->child[i], m)) return true; @@ -231,6 +233,7 @@ PFla_op_t *lp, *rp; PFalg_att_t latt, ratt; bool modified = false; + unsigned int c = 0, i = 0; assert (p); @@ -245,7 +248,7 @@ PFalg_proj_t *proj = PFmalloc (p->schema.count * sizeof (PFalg_proj_t)); - unsigned int i, j, count = 0; + unsigned int j, count = 0; for (i = 0; i < p->schema.count; i++) for (j = 0; j < L(p)->schema.count; j++) if (p->sem.proj.items[i].old == @@ -282,7 +285,7 @@ PFalg_proj_t *proj_list = PFmalloc (p->schema.count * sizeof (PFalg_proj_t)); - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) proj_list[i] = proj (p->schema.items[i].name, p->schema.items[i].name); @@ -292,7 +295,7 @@ /* action code that tries to push an equi-join underneath its operands */ - for (unsigned int c = 0; c < 2; c++) { + for (c = 0; c < 2; c++) { /* only process equi-joins */ if (p->kind != la_eqjoin_unq) break; @@ -359,7 +362,7 @@ (the one with the join argument) to push down the equi-join */ bool in_left = false; - for (unsigned int i = 0; i < L(lp)->schema.count; i++) + for (i = 0; i < L(lp)->schema.count; i++) if (L(lp)->schema.items[i].name == latt) { in_left = true; break; @@ -421,7 +424,6 @@ !contains_node (rp, L(lp))) { /* ensure that column of upper eqjoin is not created on the other side */ - unsigned int i; PFla_op_t *new_number; PFalg_proj_t *proj = PFmalloc (L(lp)->schema.count * sizeof (PFalg_proj_t)); @@ -462,7 +464,6 @@ !contains_node (rp, R(lp))) { /* ensure that column of upper eqjoin is not created on the other side */ - unsigned int i; PFla_op_t *new_number; PFalg_proj_t *proj = PFmalloc (R(lp)->schema.count * sizeof (PFalg_proj_t)); @@ -536,7 +537,7 @@ break; /* check for renaming */ - for (unsigned int i = 0; i < lp->sem.proj.count; i++) + for (i = 0; i < lp->sem.proj.count; i++) renamed = renamed || (lp->sem.proj.items[i].new != lp->sem.proj.items[i].old); @@ -556,14 +557,14 @@ /* add all columns of the left argument (without the join arguments) */ - for (unsigned int i = 0; i < lp->schema.count; i++) { + for (i = 0; i < lp->schema.count; i++) { cur = lp->schema.items[i].name; if (!is_join_att (p, cur)) proj_list[count++] = proj (cur, cur); } /* add all columns of the right argument (without duplicates and join arguments) */ - for (unsigned int i = 0; i < rp->schema.count; i++) { + for (i = 0; i < rp->schema.count; i++) { cur = rp->schema.items[i].name; if (!is_join_att (p, cur)) { unsigned int j; @@ -584,7 +585,6 @@ modified = true; } else if (L(lp) == rp) { - unsigned int i; PFalg_proj_t proj; bool same_join_col = false; @@ -779,7 +779,7 @@ proj_list = PFmalloc (lp->schema.count * sizeof (*(proj_list))); - for (unsigned int i = 0; i < lp->schema.count; i++) { + for (i = 0; i < lp->schema.count; i++) { cur = lp->schema.items[i].name; if (cur != latt) proj_list[count++] = proj (cur, cur); @@ -795,7 +795,7 @@ sortby.count = lp->sem.rownum.sortby.count; sortby.atts = PFmalloc (sortby.count * sizeof (PFalg_att_t)); - for (unsigned int i = 0; i < sortby.count; i++) { + for (i = 0; i < sortby.count; i++) { cur = lp->sem.rownum.sortby.atts[i]; if (cur != latt) sortby.atts[i] = cur; @@ -848,7 +848,7 @@ proj_list = PFmalloc (lp->schema.count * sizeof (*(proj_list))); - for (unsigned int i = 0; i < lp->schema.count; i++) { + for (i = 0; i < lp->schema.count; i++) { cur = lp->schema.items[i].name; if (cur != latt) proj_list[count++] = proj (cur, cur); @@ -956,7 +956,7 @@ proj_list = PFmalloc (lp->schema.count * sizeof (*(proj_list))); - for (unsigned int i = 0; i < lp->schema.count; i++) { + for (i = 0; i < lp->schema.count; i++) { cur = lp->schema.items[i].name; if (cur != latt) proj_list[count++] = proj (cur, cur); @@ -1000,7 +1000,7 @@ proj_list = PFmalloc (lp->schema.count * sizeof (*(proj_list))); - for (unsigned int i = 0; i < lp->schema.count; i++) { + for (i = 0; i < lp->schema.count; i++) { cur = lp->schema.items[i].name; if (cur != latt) proj_list[count++] = proj (cur, cur); @@ -1071,7 +1071,7 @@ SEEN(p) = true; /* apply join_pushdown for the children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) modified = join_pushdown (p->child[i]) || modified; return modified; Index: compiler/algebra/opt/opt_key.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_key.c,v retrieving revision 1.9 diff -u -r1.9 opt_key.c --- compiler/algebra/opt/opt_key.c 27 Sep 2006 12:03:50 -0000 1.9 +++ compiler/algebra/opt/opt_key.c 1 Nov 2006 20:59:01 -0000 @@ -57,6 +57,8 @@ static void opt_key (PFla_op_t *p) { + unsigned int i = 0; + assert (p); /* rewrite each node only once */ @@ -66,13 +68,13 @@ SEEN(p) = true; /* apply key-related optimization for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) opt_key (p->child[i]); /* action code */ switch (p->kind) { case la_distinct: - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) if (PFprop_key_left (p->prop, p->schema.items[i].name)) { *p = *PFla_dummy (L(p)); p->prop = PFprop (); @@ -128,7 +130,7 @@ PFalg_att_t *atts = PFmalloc (p->sem.rownum.sortby.count * sizeof (PFalg_att_t)); - for (unsigned int i = 0; i < p->sem.rownum.sortby.count; i++) { + for (i = 0; i < p->sem.rownum.sortby.count; i++) { atts[count++] = p->sem.rownum.sortby.atts[i]; if (PFprop_key_left (p->prop, p->sem.rownum.sortby.atts[i])) @@ -158,15 +160,16 @@ /* if there already exists a key column with the same type we can replace the number operator by a projection. */ - for (unsigned int i = 0; i < p->schema.count; i++) + for (i = 0; i < p->schema.count; i++) if (PFprop_key_left (p->prop, p->schema.items[i].name) && p->sem.number.attname != p->schema.items[i].name && p->schema.items[i].type == aat_nat) { PFalg_proj_t *proj = PFmalloc ( p->schema.count * sizeof (PFalg_proj_t)); + unsigned int j = 0; /* copy property list */ - for (unsigned int j = 0; j < p->schema.count; j++) + for (j = 0; j < p->schema.count; j++) if (p->sem.number.attname == p->schema.items[j].name) proj[j] = PFalg_proj (p->sem.number.attname, p->schema.items[i].name); Index: compiler/algebra/opt/opt_mvd.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_mvd.c,v retrieving revision 1.8 diff -u -r1.8 opt_mvd.c --- compiler/algebra/opt/opt_mvd.c 17 Oct 2006 17:57:36 -0000 1.8 +++ compiler/algebra/opt/opt_mvd.c 1 Nov 2006 20:59:01 -0000 @@ -95,7 +95,9 @@ static bool att_present (PFla_op_t *p, PFalg_att_t att) { - for (unsigned int i = 0; i < p->schema.count; i++) + unsigned int i = 0; + + for (i = 0; i < p->schema.count; i++) if (p->schema.items[i].name == att) return true; @@ -240,6 +242,7 @@ { bool modified = false; bool cross_cross = false; + unsigned int i = 0; assert (p); @@ -250,7 +253,7 @@ SEEN(p) = true; /* apply complex optimization for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) modified = opt_mvd (p->child[i]) || modified ; /** @@ -385,14 +388,14 @@ /* Split project operator and push it beyond the cross product. */ if (is_cross (L(p))) { PFalg_proj_t *proj_list1, *proj_list2; - unsigned int count1 = 0, count2 = 0; + unsigned int count1 = 0, count2 = 0, j = 0; /* create first projection list */ proj_list1 = PFmalloc (LL(p)->schema.count * sizeof (*(proj_list1))); - for (unsigned int i = 0; i < LL(p)->schema.count; i++) - for (unsigned int j = 0; j < p->sem.proj.count; j++) + for (i = 0; i < LL(p)->schema.count; i++) + for (j = 0; j < p->sem.proj.count; j++) if (LL(p)->schema.items[i].name == p->sem.proj.items[j].old) { proj_list1[count1++] = p->sem.proj.items[j]; @@ -403,8 +406,8 @@ proj_list2 = PFmalloc (LR(p)->schema.count * sizeof (*(proj_list1))); - for (unsigned int i = 0; i < LR(p)->schema.count; i++) - for (unsigned int j = 0; j < p->sem.proj.count; j++) + for (i = 0; i < LR(p)->schema.count; i++) + for (j = 0; j < p->sem.proj.count; j++) if (LR(p)->schema.items[i].name == p->sem.proj.items[j].old) { proj_list2[count2++] = p->sem.proj.items[j]; @@ -671,14 +674,15 @@ if (is_cross (L(p)) && p->sem.rownum.part) { bool part, sortby; + unsigned int j = 0; /* first check the dependencies of the left cross product input */ part = false; sortby = false; - for (unsigned int i = 0; i < LL(p)->schema.count; i++) { + for (i = 0; i < LL(p)->schema.count; i++) { if (LL(p)->schema.items[i].name == p->sem.rownum.part) part = true; - for (unsigned int j = 0; j < p->sem.rownum.sortby.count; j++) + for (j = 0; j < p->sem.rownum.sortby.count; j++) if (LL(p)->schema.items[i].name == p->sem.rownum.sortby.atts[j]) { sortby = true; @@ -700,10 +704,10 @@ /* then check the dependencies of the right cross product input */ part = false; sortby = false; - for (unsigned int i = 0; i < LR(p)->schema.count; i++) { + for (i = 0; i < LR(p)->schema.count; i++) { if (LR(p)->schema.items[i].name == p->sem.rownum.part) part = true; - for (unsigned int j = 0; j < p->sem.rownum.sortby.count; j++) + for (j = 0; j < p->sem.rownum.sortby.count; j++) if (LR(p)->schema.items[i].name == p->sem.rownum.sortby.atts[j]) { sortby = true; Index: compiler/algebra/opt/opt_reqval.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_reqval.c,v retrieving revision 1.5 diff -u -r1.5 opt_reqval.c --- compiler/algebra/opt/opt_reqval.c 19 Jun 2006 08:56:15 -0000 1.5 +++ compiler/algebra/opt/opt_reqval.c 1 Nov 2006 20:59:01 -0000 @@ -47,6 +47,8 @@ static void opt_reqvals (PFla_op_t *p) { + unsigned int i = 0; + assert (p); /* nothing to do if we already visited that node */ @@ -57,7 +59,7 @@ property we can replace every expression, where at least one column has a constant value that differs its required value, by an empty table. */ - for (unsigned int i = 0; i < p->schema.count; i++) { + for (i = 0; i < p->schema.count; i++) { PFalg_att_t att = p->schema.items[i].name; if (PFprop_reqval (p->prop, att) && PFprop_const (p->prop, att) && @@ -70,7 +72,7 @@ } /* infer properties for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++) opt_reqvals (p->child[i]); /* mark node as visited */ Index: compiler/algebra/prop/prop_card.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_card.c,v retrieving revision 1.11 diff -u -r1.11 prop_card.c --- compiler/algebra/prop/prop_card.c 17 Oct 2006 17:57:36 -0000 1.11 +++ compiler/algebra/prop/prop_card.c 1 Nov 2006 20:59:01 -0000 @@ -199,6 +199,8 @@ static void prop_infer (PFla_op_t *n) { + unsigned int i = 0; + assert (n); /* nothing to do if we already visited that node */ @@ -206,7 +208,7 @@ return; /* infer properties for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) prop_infer (n->child[i]); n->bit_dag = true; Index: compiler/algebra/prop/prop_const.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_const.c,v retrieving revision 1.14 diff -u -r1.14 prop_const.c --- compiler/algebra/prop/prop_const.c 10 Oct 2006 14:02:43 -0000 1.14 +++ compiler/algebra/prop/prop_const.c 1 Nov 2006 20:59:01 -0000 @@ -54,10 +54,12 @@ bool PFprop_const (const PFprop_t *prop, PFalg_att_t attr) { + unsigned int i = 0; + assert (prop); if (!prop->constants) return false; - for (unsigned int i = 0; i < PFarray_last (prop->constants); i++) + for (i = 0; i < PFarray_last (prop->constants); i++) if (attr == ((const_t *) PFarray_at (prop->constants, i))->attr) return true; @@ -71,10 +73,12 @@ bool PFprop_const_left (const PFprop_t *prop, PFalg_att_t attr) { + unsigned int i = 0; + assert (prop); if (!prop->l_constants) return false; - for (unsigned int i = 0; i < PFarray_last (prop->l_constants); i++) + for (i = 0; i < PFarray_last (prop->l_constants); i++) if (attr == ((const_t *) PFarray_at (prop->l_constants, i))->attr) return true; @@ -88,10 +92,12 @@ bool PFprop_const_right (const PFprop_t *prop, PFalg_att_t attr) { + unsigned int i = 0; + assert (prop); if (!prop->r_constants) return false; - for (unsigned int i = 0; i < PFarray_last (prop->r_constants); i++) + for (i = 0; i < PFarray_last (prop->r_constants); i++) if (attr == ((const_t *) PFarray_at (prop->r_constants, i))->attr) return true; @@ -102,9 +108,11 @@ static PFalg_atom_t const_val (PFarray_t *constants, PFalg_att_t attr) { + unsigned int i = 0; + assert (constants); - for (unsigned int i = 0; i < PFarray_last (constants); i++) + for (i = 0; i < PFarray_last (constants); i++) if (attr == ((const_t *) PFarray_at (constants, i))->attr) return ((const_t *) PFarray_at (constants, i))->value; @@ -219,7 +227,9 @@ static void copy (PFarray_t *base, PFarray_t *content) { - for (unsigned int i = 0; i < PFarray_last (content); i++) + unsigned int i = 0; + + for (i = 0; i < PFarray_last (content); i++) *(const_t *) PFarray_add (base) = *(const_t *) PFarray_at (content, i); } @@ -230,6 +240,8 @@ static void infer_const (PFla_op_t *n) { + unsigned int i = 0, j = 0; + /* first get the properties of the children */ if (L(n)) copy (n->prop->l_constants, L(n)->prop->constants); if (R(n)) copy (n->prop->r_constants, R(n)->prop->constants); @@ -271,8 +283,8 @@ case la_dummy: /* propagate information from both input operators */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) - for (unsigned int j = 0; + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (j = 0; j < PFprop_const_count (n->child[i]->prop); j++) if (!PFprop_const (n->prop, PFprop_const_at (n->child[i]->prop, j))) @@ -290,16 +302,17 @@ * Now consider more specific stuff from various rules. */ switch (n->kind) { + unsigned int col = 0, row = 0; case la_lit_tbl: /* check for constant columns */ - for (unsigned int col = 0; col < n->schema.count; col++) { + for (col = 0; col < n->schema.count; col++) { bool constant = true; PFalg_atom_t val; - for (unsigned int row = 0; row < n->sem.lit_tbl.count; row++) + for (row = 0; row < n->sem.lit_tbl.count; row++) if (row == 0) val = n->sem.lit_tbl.tuples[row].atoms[col]; else @@ -331,7 +344,7 @@ * projection does not affect properties, except for the * column name change. */ - for (unsigned int i = 0; i < n->sem.proj.count; i++) + for (i = 0; i < n->sem.proj.count; i++) if (PFprop_const (L(n)->prop, n->sem.proj.items[i].old)) PFprop_mark_const (n->prop, n->sem.proj.items[i].new, @@ -353,8 +366,8 @@ * add all attributes that are constant in both input relations * and additionally both contain the same value */ - for (unsigned int i = 0; i < PFprop_const_count (L(n)->prop); i++) - for (unsigned int j = 0; + for (i = 0; i < PFprop_const_count (L(n)->prop); i++) + for (j = 0; j < PFprop_const_count (R(n)->prop); j++) if (PFprop_const_at (L(n)->prop, i) == PFprop_const_at (R(n)->prop, j) && @@ -375,7 +388,7 @@ case la_difference: case la_cond_err: /* propagate information from the first input operator */ - for (unsigned int j = 0; + for (j = 0; j < PFprop_const_count (L(n)->prop); j++) if (!PFprop_const (n->prop, PFprop_const_at (L(n)->prop, j))) @@ -404,7 +417,7 @@ att2 = n->sem.binary.att2; ty = 0; - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) if (n->schema.items[i].name == n->sem.binary.att1) { ty = n->schema.items[i].type; break; @@ -643,6 +656,8 @@ static void prop_infer (PFla_op_t *n) { + unsigned int i = 0; + assert (n); /* nothing to do if we already visited that node */ @@ -650,7 +665,7 @@ return; /* infer properties for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) prop_infer (n->child[i]); n->bit_dag = true; Index: compiler/algebra/prop/prop_dom.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_dom.c,v retrieving revision 1.19 diff -u -r1.19 prop_dom.c --- compiler/algebra/prop/prop_dom.c 17 Oct 2006 17:59:32 -0000 1.19 +++ compiler/algebra/prop/prop_dom.c 1 Nov 2006 20:59:01 -0000 @@ -68,10 +68,12 @@ dom_t PFprop_dom (const PFprop_t *prop, PFalg_att_t attr) { + unsigned int i = 0; + assert (prop); if (!prop->domains) return 0; - for (unsigned int i = 0; i < PFarray_last (prop->domains); i++) + for (i = 0; i < PFarray_last (prop->domains); i++) if (attr == ((dom_pair_t *) PFarray_at (prop->domains, i))->attr) return ((dom_pair_t *) PFarray_at (prop->domains, i))->dom; @@ -85,10 +87,12 @@ dom_t PFprop_dom_left (const PFprop_t *prop, PFalg_att_t attr) { + unsigned int i = 0; + assert (prop); if (!prop->l_domains) return 0; - for (unsigned int i = 0; i < PFarray_last (prop->l_domains); i++) + for (i = 0; i < PFarray_last (prop->l_domains); i++) if (attr == ((dom_pair_t *) PFarray_at (prop->l_domains, i))->attr) return ((dom_pair_t *) PFarray_at (prop->l_domains, i))->dom; @@ -102,10 +106,12 @@ dom_t PFprop_dom_right (const PFprop_t *prop, PFalg_att_t attr) { + unsigned int i = 0; + assert (prop); if (!prop->r_domains) return 0; - for (unsigned int i = 0; i < PFarray_last (prop->r_domains); i++) + for (i = 0; i < PFarray_last (prop->r_domains); i++) if (attr == ((dom_pair_t *) PFarray_at (prop->r_domains, i))->attr) return ((dom_pair_t *) PFarray_at (prop->r_domains, i))->dom; @@ -129,13 +135,15 @@ static bool check_occurrence (PFarray_t *subdoms, unsigned int pos) { + unsigned int i = 0; + dom_t dom = ((subdom_t *) PFarray_at (subdoms, pos))->dom; - for (unsigned int i = 0; i < PFarray_last (subdoms); i++) + for (i = 0; i < PFarray_last (subdoms); i++) if (dom == ((subdom_t *) PFarray_at (subdoms, i))->subdom) return true; - for (unsigned int i = 0; i < pos; i++) + for (i = 0; i < pos; i++) if (dom == ((subdom_t *) PFarray_at (subdoms, i))->dom) return true; @@ -153,13 +161,15 @@ assert (prop); if (prop->subdoms) { + unsigned int i = 0; + PFarray_printf (f, "dr_header [label=\"domain -> " "subdomain\\nrelationships (# = %i)\"];\n" "node1 -> dr_header;\n", PFarray_last (prop->subdoms)); - for (unsigned int i = 0; i < PFarray_last (prop->subdoms); i++) { + for (i = 0; i < PFarray_last (prop->subdoms); i++) { dom = ((subdom_t *) PFarray_at (prop->subdoms, i))->dom; subdom = ((subdom_t *) PFarray_at (prop->subdoms, i))->subdom; @@ -191,11 +201,13 @@ assert (prop); if (prop->subdoms) { + unsigned int i = 0; + PFarray_printf (f, " \n", PFarray_last (prop->subdoms)); - for (unsigned int i = 0; i < PFarray_last (prop->subdoms); i++) { + for (i = 0; i < PFarray_last (prop->subdoms); i++) { a = ((subdom_t *) PFarray_at (prop->subdoms, i))->dom; b = ((subdom_t *) PFarray_at (prop->subdoms, i))->subdom; @@ -209,12 +221,13 @@ } if (prop->disjdoms) { + unsigned int i = 0; PFarray_printf (f, " \n", PFarray_last (prop->disjdoms)); - for (unsigned int i = 0; i < PFarray_last (prop->disjdoms); i++) { + for (i = 0; i < PFarray_last (prop->disjdoms); i++) { a = ((disjdom_t *) PFarray_at (prop->disjdoms, i))->dom1; b = ((disjdom_t *) PFarray_at (prop->disjdoms, i))->dom2; @@ -235,13 +248,15 @@ bool PFprop_disjdom (const PFprop_t *p, dom_t a, dom_t b) { + unsigned int i = 0; + assert (p); assert (p->disjdoms); if (a == b) return false; - for (unsigned int i = 0; i < PFarray_last (p->disjdoms); i++) { + for (i = 0; i < PFarray_last (p->disjdoms); i++) { disjdom_t d = *(disjdom_t *) PFarray_at (p->disjdoms, i); @@ -263,6 +278,7 @@ PFarray_t *subdomains; bool insert, duplicate; dom_t subdom, dom, subitem; + unsigned int i = 0, j = 0; assert (prop); assert (prop->subdoms); @@ -280,7 +296,7 @@ subdomains = PFarray (sizeof (dom_t)); *(dom_t *) PFarray_add (subdomains) = in_subdom; - for (unsigned int i = PFarray_last (prop->subdoms); i > 0; --i) { + for (i = PFarray_last (prop->subdoms); i > 0; --i) { subdom = ((subdom_t *) PFarray_at (prop->subdoms, i))->subdom; dom = ((subdom_t *) PFarray_at (prop->subdoms, i))->dom; insert = false; @@ -289,7 +305,7 @@ /* check for each item in the subdomains list if the match occurs or the superdomain is already in the list of subdomains */ - for (unsigned int j = 0; j < PFarray_last (subdomains); j++) { + for (j = 0; j < PFarray_last (subdomains); j++) { subitem = *(dom_t *) PFarray_at (subdomains, j); if (subdom == subitem) { @@ -322,6 +338,7 @@ PFarray_t *domains1, *domains2, *merge_doms; bool insert, duplicate; dom_t subdom, dom, subitem; + unsigned int i = 0, j = 0; assert (prop); assert (prop->subdoms); @@ -338,13 +355,13 @@ domains2 = PFarray (sizeof (dom_t)); *(dom_t *) PFarray_add (domains2) = dom2; - for (unsigned int i = PFarray_last (prop->subdoms); i > 0; --i) { + for (i = PFarray_last (prop->subdoms); i > 0; --i) { subdom = ((subdom_t *) PFarray_at (prop->subdoms, i))->subdom; dom = ((subdom_t *) PFarray_at (prop->subdoms, i))->dom; insert = false; duplicate = false; - for (unsigned int j = 0; j < PFarray_last (domains1); j++) { + for (j = 0; j < PFarray_last (domains1); j++) { subitem = *(dom_t *) PFarray_at (domains1, j); if (subdom == subitem) insert = true; @@ -356,7 +373,7 @@ insert = false; duplicate = false; - for (unsigned int j = 0; j < PFarray_last (domains2); j++) { + for (j = 0; j < PFarray_last (domains2); j++) { subitem = *(dom_t *) PFarray_at (domains2, j); if (subdom == subitem) insert = true; @@ -369,9 +386,9 @@ /* intersect both domain lists */ merge_doms = PFarray (sizeof (dom_t)); - for (unsigned int i = 0; i < PFarray_last (domains1); i++) { + for (i = 0; i < PFarray_last (domains1); i++) { dom1 = *(dom_t *) PFarray_at (domains1, i); - for (unsigned int j = 0; j < PFarray_last (domains2); j++) { + for (j = 0; j < PFarray_last (domains2); j++) { dom2 = *(dom_t *) PFarray_at (domains2, j); if (dom1 == dom2) *(dom_t *) PFarray_add (merge_doms) = dom1; } @@ -388,7 +405,7 @@ return dom1; /* find the leaf node (of the domain tree) */ - for (unsigned int i = 1; i < PFarray_last (merge_doms); i++) { + for (i = 1; i < PFarray_last (merge_doms); i++) { dom2 = *(dom_t *) PFarray_at (merge_doms, i); if (!dom1 /* undecided */ || PFprop_subdom (prop, dom2, dom1)) @@ -413,8 +430,10 @@ static void copy_child_domains (PFla_op_t *n) { + unsigned int i = 0; + if (L(n)) - for (unsigned int i = 0; i < L(n)->schema.count; i++) { + for (i = 0; i < L(n)->schema.count; i++) { *(dom_pair_t *) PFarray_add (n->prop->l_domains) = (dom_pair_t) { .attr = L(n)->schema.items[i].name, .dom = PFprop_dom ( @@ -423,7 +442,7 @@ } if (R(n)) - for (unsigned int i = 0; i < R(n)->schema.count; i++) { + for (i = 0; i < R(n)->schema.count; i++) { *(dom_pair_t *) PFarray_add (n->prop->r_domains) = (dom_pair_t) { .attr = R(n)->schema.items[i].name, .dom = PFprop_dom ( @@ -479,11 +498,13 @@ static void bulk_add_dom (PFprop_t *prop, PFla_op_t *child) { + unsigned int i = 0; + assert (prop); assert (child); assert (child->prop); - for (unsigned int i = 0; i < child->schema.count; i++) { + for (i = 0; i < child->schema.count; i++) { add_dom (prop, child->schema.items[i].name, PFprop_dom (child->prop, child->schema.items[i].name)); @@ -496,6 +517,8 @@ static unsigned int infer_dom (PFla_op_t *n, unsigned int id) { + unsigned int i = 0; + switch (n->kind) { case la_serialize: bulk_add_dom (n->prop, R(n)); @@ -503,13 +526,13 @@ case la_lit_tbl: /* create new domains for all attributes */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) add_dom (n->prop, n->schema.items[i].name, id++); break; case la_empty_tbl: /* assign each attribute the empty domain (1) */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) add_dom (n->prop, n->schema.items[i].name, EMPTYDOM); break; @@ -553,7 +576,7 @@ } /* copy domains and update domains of join arguments */ - for (unsigned int i = 0; i < L(n)->schema.count; i++) + for (i = 0; i < L(n)->schema.count; i++) if ((cur_dom = PFprop_dom ( L(n)->prop, L(n)->schema.items[i].name)) @@ -566,7 +589,7 @@ add_dom (n->prop, L(n)->schema.items[i].name, id++); } - for (unsigned int i = 0; i < R(n)->schema.count; i++) + for (i = 0; i < R(n)->schema.count; i++) if ((cur_dom = PFprop_dom ( R(n)->prop, R(n)->schema.items[i].name)) @@ -582,7 +605,7 @@ case la_project: /* bind all existing domains to the possibly new names */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) add_dom (n->prop, n->sem.proj.items[i].new, PFprop_dom (L(n)->prop, n->sem.proj.items[i].old)); @@ -590,7 +613,7 @@ case la_select: /* create new subdomains for all attributes */ - for (unsigned int i = 0; i < L(n)->schema.count; i++) { + for (i = 0; i < L(n)->schema.count; i++) { add_subdom (n->prop, PFprop_dom (L(n)->prop, L(n)->schema.items[i].name), @@ -602,7 +625,7 @@ case la_disjunion: /* create new superdomains for all existing attributes */ - for (unsigned int i = 0; i < L(n)->schema.count; i++) { + for (i = 0; i < L(n)->schema.count; i++) { unsigned int j; dom_t dom1, dom2, union_dom, cdom; @@ -647,7 +670,7 @@ case la_intersect: /* create new subdomains for all existing attributes */ - for (unsigned int i = 0; i < L(n)->schema.count; i++) { + for (i = 0; i < L(n)->schema.count; i++) { unsigned int j; for (j = 0; j < R(n)->schema.count; j++) if (L(n)->schema.items[i].name == @@ -683,7 +706,7 @@ * those in the right argument. */ /* create new subdomains for all existing attributes */ - for (unsigned int i = 0; i < L(n)->schema.count; i++) { + for (i = 0; i < L(n)->schema.count; i++) { add_dom (n->prop, L(n)->schema.items[i].name, id); @@ -703,7 +726,7 @@ case la_distinct: /* create new subdomains for all existing attributes */ - for (unsigned int i = 0; i < L(n)->schema.count; i++) { + for (i = 0; i < L(n)->schema.count; i++) { add_subdom (n->prop, PFprop_dom (L(n)->prop, L(n)->schema.items[i].name), @@ -872,7 +895,7 @@ case la_rec_base: /* create new domains for all attributes */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) add_dom (n->prop, n->schema.items[i].name, id++); break; @@ -907,6 +930,8 @@ prop_infer (PFla_op_t *n, PFarray_t *subdoms, PFarray_t *disjdoms, unsigned int cur_dom_id) { + unsigned int i = 0; + assert (n); /* nothing to do if we already visited that node */ @@ -914,7 +939,7 @@ return cur_dom_id; /* infer properties for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) cur_dom_id = prop_infer (n->child[i], subdoms, disjdoms, cur_dom_id); n->bit_dag = true; Index: compiler/algebra/prop/prop_icol.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_icol.c,v retrieving revision 1.11 diff -u -r1.11 prop_icol.c --- compiler/algebra/prop/prop_icol.c 10 Oct 2006 14:02:43 -0000 1.11 +++ compiler/algebra/prop/prop_icol.c 1 Nov 2006 20:59:01 -0000 @@ -138,9 +138,10 @@ intersect_ocol (PFalg_att_t icols, PFalg_schema_t schema_ocols) { PFalg_att_t ocols = 0; + unsigned int j = 0; /* intersect attributes */ - for (unsigned int j = 0; j < schema_ocols.count; j++) + for (j = 0; j < schema_ocols.count; j++) ocols |= schema_ocols.items[j].name; return icols & ocols; @@ -186,7 +187,8 @@ else if (n->kind == la_rec_arg) { /* the required columns of the body are all the columns of the schema */ - for (unsigned int i = 0; i < n->schema.count; i++) + unsigned int i = 0; + for (i = 0; i < n->schema.count; i++) n->prop->r_icols = union_ (n->prop->r_icols, n->schema.items[i].name); /* infer the icols property of the operators in the @@ -205,6 +207,7 @@ static void prop_infer_icols (PFla_op_t *n, PFalg_att_t icols) { + unsigned int i = 0; /* for element construction we need a special translation and therefore skip the default inference of the children */ bool skip_children = false; @@ -256,7 +259,7 @@ case la_project: n->prop->l_icols = 0; /* rename icols columns from new to old */ - for (unsigned int i = 0; i < n->sem.proj.count; i++) + for (i = 0; i < n->sem.proj.count; i++) if (n->prop->icols & n->sem.proj.items[i].new) n->prop->l_icols = union_ (n->prop->l_icols, n->sem.proj.items[i].old); @@ -275,7 +278,7 @@ might infer non-matching columns */ if (!n->prop->l_icols) { /* try to use a constant as it might get pruned later */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) if (PFprop_const (n->prop, n->schema.items[i].name)) { n->prop->l_icols = n->schema.items[i].name; break; @@ -305,7 +308,7 @@ extend the icols with all ocols */ n->prop->l_icols = n->prop->icols; - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) n->prop->l_icols = union_ (n->prop->l_icols, n->schema.items[i].name); @@ -387,7 +390,7 @@ n->prop->l_icols = diff (n->prop->l_icols, n->sem.rownum.attname); - for (unsigned int i = 0; i < n->sem.rownum.sortby.count; i++) + for (i = 0; i < n->sem.rownum.sortby.count; i++) n->prop->l_icols = union_ (n->prop->l_icols, n->sem.rownum.sortby.atts[i]); @@ -641,7 +644,7 @@ if (!skip_children) /* infer properties for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) prop_infer_icols (n->child[i], /* infer the respective icols property */ i==0?n->prop->l_icols:n->prop->r_icols); @@ -651,6 +654,8 @@ static void prop_infer (PFla_op_t *n) { + unsigned int i = 0; + assert (n); /* count number of incoming edges @@ -665,7 +670,7 @@ n->state_label = 1; /* infer properties for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) prop_infer (n->child[i]); n->bit_dag = true; Index: compiler/algebra/prop/prop_key.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_key.c,v retrieving revision 1.14 diff -u -r1.14 prop_key.c --- compiler/algebra/prop/prop_key.c 10 Oct 2006 14:02:43 -0000 1.14 +++ compiler/algebra/prop/prop_key.c 1 Nov 2006 20:59:01 -0000 @@ -54,9 +54,11 @@ static bool key_worker (PFarray_t *keys, PFalg_att_t attr) { + unsigned int i = 0; + if (!keys) return false; - for (unsigned int i = 0; i < PFarray_last (keys); i++) + for (i = 0; i < PFarray_last (keys); i++) if (attr == *(PFalg_att_t *) PFarray_at (keys, i)) return true; @@ -120,6 +122,7 @@ PFprop_keys_to_attlist (const PFprop_t *prop) { PFalg_attlist_t new_list; + unsigned int i = 0; new_list.count = keys_count (prop); new_list.atts = PFmalloc (new_list.count * sizeof (*(new_list.atts))); @@ -127,7 +130,7 @@ if (!prop->keys) return new_list; - for (unsigned int i = 0; i < PFarray_last (prop->keys); i++) + for (i = 0; i < PFarray_last (prop->keys); i++) new_list.atts[i] = *(PFalg_att_t *) PFarray_at (prop->keys, i); return new_list; @@ -154,10 +157,11 @@ union_list (PFarray_t *a, PFarray_t *b) { PFalg_att_t cur; + unsigned int i = 0; assert (a && b); - for (unsigned int i = 0; i < PFarray_last (b); i++) { + for (i = 0; i < PFarray_last (b); i++) { cur = *(PFalg_att_t *) PFarray_at (b, i); if (!key_worker (a, cur)) *(PFalg_att_t *) PFarray_add (a) = cur; @@ -167,7 +171,9 @@ static void copy (PFarray_t *base, PFarray_t *content) { - for (unsigned int i = 0; i < PFarray_last (content); i++) + unsigned int i = 0; + + for (i = 0; i < PFarray_last (content); i++) *(PFalg_att_t *) PFarray_add (base) = *(PFalg_att_t *) PFarray_at (content, i); } @@ -178,6 +184,8 @@ static void infer_key (PFla_op_t *n) { + unsigned int i = 0; + /* copy key properties of children into current node */ if (L(n)) copy (n->prop->l_keys, L(n)->prop->keys); if (R(n)) copy (n->prop->r_keys, R(n)->prop->keys); @@ -191,10 +199,10 @@ case la_lit_tbl: /* all columns are key */ if (n->sem.lit_tbl.count == 1) - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) union_ (n->prop->keys, n->schema.items[i].name); else - for (unsigned int i = 0; i < n->schema.count; i++) { + for (i = 0; i < n->schema.count; i++) { unsigned int j = 0; unsigned int k = 0; @@ -234,7 +242,7 @@ if (L(n)->prop->domains && R(n)->prop->domains && n->prop->disjdoms) { - for (unsigned int i = 0; + for (i = 0; i < PFarray_last (L(n)->prop->keys); i++) { PFalg_att_t key_att @@ -296,7 +304,7 @@ case la_project: /* rename keys columns from old to new */ - for (unsigned int i = 0; i < n->sem.proj.count; i++) + for (i = 0; i < n->sem.proj.count; i++) if (key_worker (L(n)->prop->keys, n->sem.proj.items[i].old)) union_ (n->prop->keys, n->sem.proj.items[i].new); break; @@ -496,6 +504,8 @@ static void prop_infer (PFla_op_t *n) { + unsigned int i = 0; + assert (n); /* nothing to do if we already visited that node */ @@ -503,7 +513,7 @@ return; /* infer properties for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) prop_infer (n->child[i]); n->bit_dag = true; Index: compiler/algebra/prop/prop_ocol.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_ocol.c,v retrieving revision 1.12 diff -u -r1.12 prop_ocol.c --- compiler/algebra/prop/prop_ocol.c 12 Oct 2006 09:46:32 -0000 1.12 +++ compiler/algebra/prop/prop_ocol.c 1 Nov 2006 20:59:01 -0000 @@ -63,9 +63,11 @@ bool PFprop_ocol (const PFla_op_t *n, PFalg_att_t attr) { + unsigned int i = 0; + assert (n); - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) if (attr == n->schema.items[i].name) return true; @@ -80,13 +82,14 @@ copy_ocols (PFalg_schema_t ori, unsigned int size) { PFalg_schema_t ret; + unsigned int i = 0; assert (ori.count <= size); ret.items = PFmalloc (size * sizeof (*(ret.items))); ret.count = ori.count; - for (unsigned int i = 0; i < ori.count; i++) + for (i = 0; i < ori.count; i++) ret.items[i] = ori.items[i]; return ret; @@ -99,6 +102,8 @@ static void infer_ocol (PFla_op_t *n) { + unsigned int i = 0; + switch (n->kind) { case la_serialize: @@ -122,7 +127,7 @@ ocols (n) = copy_ocols (ocols (L(n)), ocols_count (L(n)) + ocols_count (R(n))); - for (unsigned int i = 0; i < ocols_count (R(n)); i++) { + for (i = 0; i < ocols_count (R(n)); i++) { ocol_at (n, ocols_count(n)) = ocol_at (R(n), i); ocols_count (n)++; } @@ -131,11 +136,12 @@ case la_project: { PFarray_t *proj_list = PFarray (sizeof (PFalg_proj_t)); + unsigned int j = 0; /* prune projection list according to the ocols of its argument */ - for (unsigned int i = 0; i < n->sem.proj.count; i++) - for (unsigned int j = 0; j < ocols_count (L(n)); j++) + for (i = 0; i < n->sem.proj.count; i++) + for (j = 0; j < ocols_count (L(n)); j++) if (n->sem.proj.items[i].old == ocol_at (L(n), j).name) { *(PFalg_proj_t *) PFarray_add (proj_list) @@ -150,8 +156,8 @@ new_ocols (n, PFarray_last (proj_list)); /* copy ocols and projection list during the second pass */ - for (unsigned int i = 0; i < PFarray_last (proj_list); i++) - for (unsigned int j = 0; j < ocols_count (L(n)); j++) + for (i = 0; i < PFarray_last (proj_list); i++) + for (j = 0; j < ocols_count (L(n)); j++) if ((*(PFalg_proj_t *) PFarray_at (proj_list, i)).old == ocol_at (L(n), j).name) { n->sem.proj.items[i] = @@ -169,7 +175,7 @@ case la_disjunion: { - unsigned int i, j; + unsigned int j; /* see if both operands have same number of attributes */ if (ocols_count (L(n)) != ocols_count (R(n))) @@ -201,7 +207,7 @@ case la_intersect: { - unsigned int i, j; + unsigned int j; /* see if both operands have same number of attributes */ if (ocols_count (L(n)) != ocols_count (R(n))) @@ -245,7 +251,7 @@ int ix1 = -1; int ix2 = -1; /* verify that 'att1' and 'att2' are attributes of n ... */ - for (unsigned int i = 0; i < ocols_count (L(n)); i++) { + for (i = 0; i < ocols_count (L(n)); i++) { if (n->sem.binary.att1 == ocol_at (L(n), i).name) ix1 = i; /* remember array index of att1 */ else if (n->sem.binary.att2 == ocol_at (L(n), i).name) @@ -272,7 +278,7 @@ { int ix = -1; /* verify that 'att1' and 'att2' are attributes of n ... */ - for (unsigned int i = 0; i < ocols_count (L(n)); i++) { + for (i = 0; i < ocols_count (L(n)); i++) { if (n->sem.unary.att == ocol_at (L(n), i).name) ix = i; /* remember array index of att */ } @@ -320,7 +326,7 @@ /* verify that attributes 'att' and 'part' are attributes of n * and include them into the result schema */ - for (unsigned int i = 0; i < ocols_count (L(n)); i++) { + for (i = 0; i < ocols_count (L(n)); i++) { if (n->sem.aggr.att == ocol_at (L(n), i).name) { ocol_at (n, 0) = ocol_at (L(n), i); ocol_at (n, 0).name = n->sem.aggr.res; @@ -346,7 +352,7 @@ /* copy the partitioning attribute */ if (n->sem.aggr.part) - for (unsigned int i = 0; i < ocols_count (L(n)); i++) + for (i = 0; i < ocols_count (L(n)); i++) if (ocol_at (L(n), i).name == n->sem.aggr.part) { ocol_at (n, 1) = ocol_at (L(n), i); break; @@ -378,7 +384,7 @@ new_ocols (n, ocols_count (L(n))); /* copy schema from 'n' argument */ - for (unsigned int i = 0; i < ocols_count (L(n)); i++) + for (i = 0; i < ocols_count (L(n)); i++) { if (n->sem.type.att == ocol_at (L(n), i).name) { @@ -532,7 +538,7 @@ case la_rec_arg: { - unsigned int i, j; + unsigned int j; /* see if both operands have same number of attributes */ if (ocols_count (L(n)) != ocols_count (R(n)) || @@ -706,12 +712,14 @@ break; } - if (bottom_up) + if (bottom_up) { + unsigned int i = 0; /* infer properties for children bottom-up (ensure that the fragment information is translated after the value part) */ - for (unsigned int i = PFLA_OP_MAXCHILD; i > 0; i--) + for (i = PFLA_OP_MAXCHILD; i > 0; i--) if (n->child[i - 1]) prop_infer (n->child[i - 1]); + } n->bit_dag = true; Index: compiler/algebra/prop/prop_ori_names.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_ori_names.c,v retrieving revision 1.6 diff -u -r1.6 prop_ori_names.c --- compiler/algebra/prop/prop_ori_names.c 10 Oct 2006 14:02:43 -0000 1.6 +++ compiler/algebra/prop/prop_ori_names.c 1 Nov 2006 20:59:01 -0000 @@ -70,9 +70,11 @@ static PFalg_att_t find_ori_name (PFarray_t *np_list, PFalg_att_t attr) { + unsigned int i = 0; + if (!np_list) return 0; - for (unsigned int i = 0; i < PFarray_last (np_list); i++) + for (i = 0; i < PFarray_last (np_list); i++) if (attr == ((name_pair_t *) PFarray_at (np_list, i))->unq) return ((name_pair_t *) PFarray_at (np_list, i))->ori; @@ -143,8 +145,9 @@ { PFarray_t *ret = PFarray (sizeof (name_pair_t)); name_pair_t np; + unsigned int i = 0; - for (unsigned int i = 0; i < PFarray_last (np_list); i++) { + for (i = 0; i < PFarray_last (np_list); i++) { np = *(name_pair_t *) PFarray_at (np_list, i); if (np.unq != unq) *(name_pair_t *) PFarray_add (ret) = np; @@ -164,12 +167,13 @@ patch_ori_names (PFarray_t *np_list, PFarray_t *child_np_list) { PFalg_att_t child_unq, child_ori, unq, ori; + unsigned int i = 0, j = 0; - for (unsigned int i = 0; i < PFarray_last (child_np_list); i++) { + for (i = 0; i < PFarray_last (child_np_list); i++) { child_unq = ((name_pair_t *) PFarray_at (child_np_list, i))->unq; child_ori = ((name_pair_t *) PFarray_at (child_np_list, i))->ori; - for (unsigned int j = 0; j < PFarray_last (np_list); j++) { + for (j = 0; j < PFarray_last (np_list); j++) { unq = ((name_pair_t *) PFarray_at (np_list, j))->unq; ori = ((name_pair_t *) PFarray_at (np_list, j))->ori; @@ -192,13 +196,14 @@ PFalg_att_t unq, ori; PFalg_att_t par_unq, par_ori; PFarray_t *np_list; + unsigned int i = 0; assert (n); np_list = n->prop->name_pairs; /* include (possibly) new matching columns in the name pairs list */ - for (unsigned int i = 0; i < PFarray_last (par_np_list); i++) { + for (i = 0; i < PFarray_last (par_np_list); i++) { par_unq = ((name_pair_t *) PFarray_at (par_np_list, i))->unq; par_ori = ((name_pair_t *) PFarray_at (par_np_list, i))->ori; @@ -206,7 +211,7 @@ if (find_ori_name (np_list, par_unq)) continue; /* name pair is missing - add it to the name pairs list ... */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) /* ... if it correspond to a column of the current schema */ if (n->schema.items[i].name == par_unq) { /* The proposed original column name is already @@ -230,7 +235,7 @@ /* create new names for the remaining names that are visible in the current operator but not referenced by parent operators */ - for (unsigned int i = 0; i < n->schema.count; i++) { + for (i = 0; i < n->schema.count; i++) { unq = n->schema.items[i].name; if (!find_ori_name (np_list, unq)) { PFalg_att_t ori = PFalg_ori_name (unq, FREE(n)); @@ -257,12 +262,12 @@ case la_cross: /* only infer matching columns to the children */ - for (unsigned int i = 0; i < L(n)->schema.count; i++) { + for (i = 0; i < L(n)->schema.count; i++) { unq = L(n)->schema.items[i].name; ori = find_ori_name (np_list, unq); add_name_pair (n->prop->l_name_pairs, ori, unq); } - for (unsigned int i = 0; i < R(n)->schema.count; i++) { + for (i = 0; i < R(n)->schema.count; i++) { unq = R(n)->schema.items[i].name; ori = find_ori_name (np_list, unq); add_name_pair (n->prop->r_name_pairs, ori, unq); @@ -291,7 +296,7 @@ } /* create name pair list for the left operand */ - for (unsigned int i = 0; i < L(n)->schema.count; i++) { + for (i = 0; i < L(n)->schema.count; i++) { unq = L(n)->schema.items[i].name; ori = find_ori_name (np_list, unq); add_name_pair (n->prop->l_name_pairs, ori, unq); @@ -315,7 +320,7 @@ /* make new original name available to right operand */ add_name_pair (n->prop->r_name_pairs, ori, att2); /* copy all remaining name pairs */ - for (unsigned int i = 0; i < R(n)->schema.count; i++) { + for (i = 0; i < R(n)->schema.count; i++) { unq = R(n)->schema.items[i].name; /* discard left join column */ if (unq != att1) { @@ -326,7 +331,7 @@ } else /* create name pair list for the right operand */ - for (unsigned int i = 0; i < R(n)->schema.count; i++) { + for (i = 0; i < R(n)->schema.count; i++) { unq = R(n)->schema.items[i].name; ori = find_ori_name (np_list, unq); add_name_pair (n->prop->r_name_pairs, ori, unq); @@ -337,7 +342,7 @@ /* Infer only columns that are used in the projection. Renamings do not have to be mapped. Conflicting names are patched by the function patch_ori_names(). */ - for (unsigned int i = 0; i < n->sem.proj.count; i++) { + for (i = 0; i < n->sem.proj.count; i++) { ori = find_ori_name (np_list, n->sem.proj.items[i].new); add_name_pair (n->prop->l_name_pairs, ori, @@ -531,6 +536,7 @@ { PFarray_t *child_np_list; PFalg_att_t unq1, unq2, ori1, ori2; + unsigned int j = 0; /* child_np_list is expected to be equal to np_list, meaning that the constructor in the child node @@ -540,11 +546,11 @@ /* make sure that no projection is required after the roots operator */ - for (unsigned int i = 0; i < PFarray_last (child_np_list); i++) { + for (i = 0; i < PFarray_last (child_np_list); i++) { unq1 = ((name_pair_t *) PFarray_at (child_np_list, i))->unq; ori1 = ((name_pair_t *) PFarray_at (child_np_list, i))->ori; - for (unsigned int j = 0; j < PFarray_last (np_list); j++) { + for (j = 0; j < PFarray_last (np_list); j++) { unq2 = ((name_pair_t *) PFarray_at (np_list, j))->unq; ori2 = ((name_pair_t *) PFarray_at (np_list, j))->ori; @@ -667,6 +673,8 @@ static void prop_infer (PFla_op_t *n) { + unsigned int i = 0; + assert (n); /* count number of incoming edges @@ -681,7 +689,7 @@ EDGE(n) = 1; /* infer properties for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) prop_infer (n->child[i]); n->bit_dag = true; Index: compiler/algebra/prop/prop_reqval.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_reqval.c,v retrieving revision 1.12 diff -u -r1.12 prop_reqval.c --- compiler/algebra/prop/prop_reqval.c 10 Oct 2006 16:26:04 -0000 1.12 +++ compiler/algebra/prop/prop_reqval.c 1 Nov 2006 20:59:01 -0000 @@ -172,11 +172,12 @@ prop_infer_reqvals (R(n), rv); break; - case la_project: + case la_project: { + unsigned int i = 0; rv.name = 0; rv.val = 0; /* rename reqvals columns from new to old */ - for (unsigned int i = 0; i < n->sem.proj.count; i++) + for (i = 0; i < n->sem.proj.count; i++) if (n->prop->reqvals.name & n->sem.proj.items[i].new) { rv.name = union_ (rv.name, n->sem.proj.items[i].old); /* keep values but map them to the old column name */ @@ -185,6 +186,7 @@ } prop_infer_reqvals (L(n), rv); break; + } case la_select: /* introduce new required value column */ @@ -367,6 +369,8 @@ static void prop_infer (PFla_op_t *n) { + unsigned int i = 0; + assert (n); /* count number of incoming edges @@ -381,7 +385,7 @@ n->state_label = 1; /* infer properties for children */ - for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++) prop_infer (n->child[i]); n->bit_dag = true; Index: compiler/algebra/prop/prop_unq_names.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_unq_names.c,v retrieving revision 1.8 diff -u -r1.8 prop_unq_names.c --- compiler/algebra/prop/prop_unq_names.c 12 Oct 2006 09:46:32 -0000 1.8 +++ compiler/algebra/prop/prop_unq_names.c 1 Nov 2006 20:59:01 -0000 @@ -53,9 +53,11 @@ static PFalg_att_t find_unq_name (PFarray_t *np_list, PFalg_att_t attr) { + unsigned int i = 0; + if (!np_list) return 0; - for (unsigned int i = 0; i < PFarray_last (np_list); i++) + for (i = 0; i < PFarray_last (np_list); i++) if (attr == ((name_pair_t *) PFarray_at (np_list, i))->ori) return ((name_pair_t *) PFarray_at (np_list, i))->unq; @@ -125,11 +127,13 @@ static void bulk_add_name_pairs (PFarray_t *np_list, PFla_op_t *child) { + unsigned int i = 0; + assert (np_list); assert (child); assert (child->prop); - for (unsigned int i = 0; i < child->schema.count; i++) { + for (i = 0; i < child->schema.count; i++) { add_name_pair (np_list, child->schema.items[i].name, PFprop_unq_name (child->prop, @@ -144,6 +148,7 @@ infer_unq_names (PFla_op_t *n, unsigned int id) { PFarray_t *np_list = n->prop->name_pairs; + unsigned int i = 0; switch (n->kind) { case la_serialize: @@ -153,7 +158,7 @@ case la_lit_tbl: case la_empty_tbl: /* create new unique names for all attributes */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) new_name_pair (np_list, n->schema.items[i].name, id++); break; @@ -180,7 +185,7 @@ left_np_list = n->prop->l_name_pairs; right_np_list = n->prop->r_name_pairs; - for (unsigned int i = 0; i < L(n)->schema.count; i++) { + for (i = 0; i < L(n)->schema.count; i++) { ori = L(n)->schema.items[i].name; child_unq = PFprop_unq_name (L(n)->prop, ori); @@ -198,7 +203,7 @@ add_name_pair (np_list, ori, unq); add_name_pair (left_np_list, ori, child_unq); } - for (unsigned int i = 0; i < R(n)->schema.count; i++) { + for (i = 0; i < R(n)->schema.count; i++) { ori = R(n)->schema.items[i].name; child_unq = PFprop_unq_name (R(n)->prop, ori); @@ -239,7 +244,7 @@ left_np_list = n->prop->l_name_pairs; right_np_list = n->prop->r_name_pairs; - for (unsigned int i = 0; i < L(n)->schema.count; i++) { + for (i = 0; i < L(n)->schema.count; i++) { ori = L(n)->schema.items[i].name; child_unq = PFprop_unq_name (L(n)->prop, ori); @@ -255,7 +260,7 @@ add_name_pair (left_np_list, ori, child_unq); } - for (unsigned int i = 0; i < R(n)->schema.count; i++) { + for (i = 0; i < R(n)->schema.count; i++) { ori = R(n)->schema.items[i].name; child_unq = PFprop_unq_name (R(n)->prop, ori); @@ -291,7 +296,7 @@ case la_project: /* bind all existing unique names to the possibly new names */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) add_name_pair (np_list, n->sem.proj.items[i].new, PFprop_unq_name (L(n)->prop, @@ -318,7 +323,7 @@ n->prop->l_name_pairs = PFarray (sizeof (name_pair_t)); n->prop->r_name_pairs = PFarray (sizeof (name_pair_t)); - for (unsigned int i = 0; i < n->schema.count; i++) { + for (i = 0; i < n->schema.count; i++) { ori = n->schema.items[i].name; l_unq = PFprop_unq_name (L(n)->prop, ori); r_unq = PFprop_unq_name (R(n)->prop, ori); @@ -645,12 +650,15 @@ break; } - if (bottom_up) + if (bottom_up) { + unsigned int i = 0; + /* infer properties for children bottom-up (ensure that the fragment information is translated after the value part) */ - for (unsigned int i = PFLA_OP_MAXCHILD; i > 0; i--) + for (i = PFLA_OP_MAXCHILD; i > 0; i--) if (n->child[i - 1]) cur_col_id = prop_infer (n->child[i - 1], cur_col_id); + } n->bit_dag = true; reset_property (n); Index: compiler/core/coreopt.brg =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/core/coreopt.brg,v retrieving revision 1.37 diff -u -r1.37 coreopt.brg --- compiler/core/coreopt.brg 31 Oct 2006 11:46:06 -0000 1.37 +++ compiler/core/coreopt.brg 1 Nov 2006 20:59:01 -0000 @@ -389,12 +389,13 @@ static bool reduce (PFcnode_t * p, int goalnt) { - int rule; /* rule number that matches for this node */ - short *nts; /* target non-terminals for the leaf nodes of - the current rule */ - PFcnode_t * kids[MAX_KIDS]; /* leaf nodes of this rule */ - bool rewritten; - short old_state_label; + int rule; /* rule number that matches for this node */ + short *nts; /* target non-terminals for the leaf nodes of + the current rule */ + PFcnode_t * kids[MAX_KIDS]; /* leaf nodes of this rule */ + bool rewritten; + short old_state_label; + unsigned short i = 0; do { /* determine rule that matches for this non-terminal */ @@ -405,7 +406,7 @@ /* PFinfo (OOPS_NOTICE, "match for rule %i", rule); */ /* initialize the kids[] vector */ - for (unsigned short i = 0; i < MAX_KIDS; i++) + for (i = 0; i < MAX_KIDS; i++) kids[i] = NULL; /* @@ -518,7 +519,7 @@ * Recursively invoke compilation. * This means bottom-up compilation. */ - for (unsigned short i = 0; nts[i]; i++) + for (i = 0; nts[i]; i++) if ((rewritten = reduce (kids[i], nts[i]))) break; /* abort if a subtree was rewritten */ } @@ -1068,12 +1069,13 @@ * what's going on here. */ unsigned short h = hash (p->sem.var); + unsigned int i = 0; /* * Look up this variable in the variable replacement * environment. If we find it there, do the replacement. */ - for (unsigned int i = 0; i < PFarray_last (var_env[h]); i++) + for (i = 0; i < PFarray_last (var_env[h]); i++) if (((bind_t *) PFarray_at (var_env[h], i))->var == p->sem.var) { *p = *((bind_t *) PFarray_at (var_env[h], i))->atom; @@ -1141,10 +1143,11 @@ PFcnode_t * PFcoreopt (PFcnode_t *r) { + unsigned short i = 0; assert (r); /* set up variable replacement environment */ - for (unsigned short i = 0; i < HASH_BUCKETS; i++) + for (i = 0; i < HASH_BUCKETS; i++) var_env[i] = PFarray (sizeof (bind_t)); /* label the Core tree bottom up */ Index: compiler/core/fs.brg =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/core/fs.brg,v retrieving revision 1.44 diff -u -r1.44 fs.brg --- compiler/core/fs.brg 31 Oct 2006 09:28:27 -0000 1.44 +++ compiler/core/fs.brg 1 Nov 2006 20:59:02 -0000 @@ -740,10 +740,11 @@ static void process_fun_sigs (PFpnode_t *p, int goalnt) { - int rule; /* rule number that matches for this node */ - short *nts; /* target non-terminals for the leaf nodes of + int rule; /* rule number that matches for this node */ + short *nts; /* target non-terminals for the leaf nodes of the current rule */ - PFpnode_t *kids[MAX_KIDS]; /* leaf nodes of this rule */ + PFpnode_t *kids[MAX_KIDS]; /* leaf nodes of this rule */ + unsigned short i = 0; /* determine rule that matches for this non-terminal */ rule = PFfs_rule (STATE_LABEL (p), goalnt); @@ -752,7 +753,7 @@ assert (rule); /* initialize the kids[] vector */ - for (unsigned short i = 0; i < MAX_KIDS; i++) + for (i = 0; i < MAX_KIDS; i++) kids[i] = NULL; /* @@ -847,7 +848,7 @@ case 23: /* These are the interesting paths to follow */ - for (unsigned short i = 0; nts[i]; i++) + for (i = 0; nts[i]; i++) process_fun_sigs (kids[i], nts[i]); break; @@ -863,12 +864,13 @@ static void reduce (PFpnode_t * p, int goalnt) { - int rule; /* rule number that matches for this node */ - short *nts; /* target non-terminals for the leaf nodes of - the current rule */ - PFpnode_t *kids[MAX_KIDS]; /* leaf nodes of this rule */ - bool topdown; /* is this a top-down rule? */ - PFcnode_t *c; /* temporary helper variable */ + int rule; /* rule number that matches for this node */ + short *nts; /* target non-terminals for the leaf nodes of + the current rule */ + PFpnode_t *kids[MAX_KIDS]; /* leaf nodes of this rule */ + bool topdown; /* is this a top-down rule? */ + PFcnode_t *c; /* temporary helper variable */ + unsigned short i = 0; /* determine rule that matches for this non-terminal */ rule = PFfs_rule (STATE_LABEL (p), goalnt); @@ -877,7 +879,7 @@ assert (rule); /* initialize the kids[] vector */ - for (unsigned short i = 0; i < MAX_KIDS; i++) + for (i = 0; i < MAX_KIDS; i++) kids[i] = NULL; /* @@ -925,7 +927,7 @@ * Recursively invoke compilation. This means bottom-up compilation. */ if (!topdown) - for (unsigned short i = 0; nts[i]; i++) + for (i = 0; nts[i]; i++) reduce (kids[i], nts[i]); /* Index: compiler/core/simplify.brg =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/core/simplify.brg,v retrieving revision 1.24 diff -u -r1.24 simplify.brg --- compiler/core/simplify.brg 24 Oct 2006 15:20:00 -0000 1.24 +++ compiler/core/simplify.brg 1 Nov 2006 20:59:02 -0000 @@ -400,13 +400,14 @@ static bool reduce (PFcnode_t *p, int goalnt) { - int rule; /* rule number that matches for this node */ - short *nts; /* target non-terminals for the leaf nodes of - the current rule */ - PFcnode_t * kids[MAX_KIDS]; /* leaf nodes of this rule */ - short old_state_label, old_state_label2; - bool manual; - bool rewrite_again; + int rule; /* rule number that matches for this node */ + short *nts; /* target non-terminals for the leaf nodes of + the current rule */ + PFcnode_t * kids[MAX_KIDS]; /* leaf nodes of this rule */ + short old_state_label, old_state_label2; + bool manual; + bool rewrite_again; + unsigned short i = 0; old_state_label = STATE_LABEL(p); @@ -424,7 +425,7 @@ */ /* initialize the kids[] vector */ - for (unsigned short i = 0; i < MAX_KIDS; i++) + for (i = 0; i < MAX_KIDS; i++) kids[i] = NULL; /* @@ -640,12 +641,13 @@ * what's going on here. */ unsigned short h = hash (p->sem.var); + unsigned int i = 0; /* * Look up this variable in the variable replacement * environment. If we find it there, do the replacement. */ - for (unsigned int i = 0; i < PFarray_last (var_env[h]); i++) + for (i = 0; i < PFarray_last (var_env[h]); i++) if (((bind_t *) PFarray_at (var_env[h], i))->var == p->sem.var) { *p = *((bind_t *) PFarray_at (var_env[h], i))->atom; @@ -670,11 +672,13 @@ old_state_label2 = STATE_LABEL(p); - if ( ! manual ) - for (unsigned int i = 0; nts[i]; i++) { + if ( ! manual ) { + unsigned int i = 0; + for (i = 0; nts[i]; i++) { while (reduce (kids[i], nts[i])) relabel (p, kids); } + } if (old_state_label != STATE_LABEL(p) || old_state_label2 != STATE_LABEL(p)) @@ -736,10 +740,11 @@ PFcnode_t * PFsimplify (PFcnode_t *r) { + unsigned short i = 0; assert (r); /* set up variable replacement environment */ - for (unsigned short i = 0; i < HASH_BUCKETS; i++) + for (i = 0; i < HASH_BUCKETS; i++) var_env[i] = PFarray (sizeof (bind_t)); /* label the Core tree bottom up */ Index: compiler/debug/logdebug.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/debug/logdebug.c,v retrieving revision 1.39 diff -u -r1.39 logdebug.c --- compiler/debug/logdebug.c 10 Oct 2006 14:02:44 -0000 1.39 +++ compiler/debug/logdebug.c 1 Nov 2006 20:59:02 -0000 @@ -307,7 +307,7 @@ static unsigned int la_dot (PFarray_t *dot, PFla_op_t *n, unsigned int node_id) { - unsigned int c; + unsigned int c = 0, i = 0; assert(n->node_id); static char *color[] = { @@ -398,7 +398,7 @@ PFarray_printf (dot, ")"); /* print out tuples in table, if table is not empty */ - for (unsigned int i = 0; i < n->sem.lit_tbl.count; i++) { + for (i = 0; i < n->sem.lit_tbl.count; i++) { PFarray_printf (dot, "\\n["); for (c = 0; c < n->sem.lit_tbl.tuples[i].count; c++) { @@ -758,6 +758,7 @@ char *fmt = PFstate.format; bool all = false; + unsigned int pre = 0; while (*fmt) { if (*fmt == '+') @@ -770,24 +771,24 @@ PFarray_printf (dot, "\\ncard: %i", PFprop_card (n->prop)); /* list attributes marked const */ - for (unsigned int i = 0; + for (i = 0; i < PFprop_const_count (n->prop); i++) PFarray_printf (dot, i ? ", %s" : "\\nconst: %s", PFatt_str ( PFprop_const_at (n->prop, i))); /* list icols attributes */ - for (unsigned int i = 0; i < icols.count; i++) + for (i = 0; i < icols.count; i++) PFarray_printf (dot, i ? ", %s" : "\\nicols: %s", PFatt_str (icols.atts[i])); /* list keys attributes */ - for (unsigned int i = 0; i < keys.count; i++) + for (i = 0; i < keys.count; i++) PFarray_printf (dot, i ? ", %s" : "\\nkeys: %s", PFatt_str (keys.atts[i])); /* list required value columns and their values */ - for (unsigned int pre = 0, i = 0; i < n->schema.count; i++) { + for (pre = 0, i = 0; i < n->schema.count; i++) { PFalg_att_t att = n->schema.items[i].name; if (PFprop_reqval (n->prop, att)) PFarray_printf ( @@ -798,7 +799,7 @@ } /* list attributes and their corresponding domains */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) if (PFprop_dom (n->prop, n->schema.items[i].name)) { PFarray_printf (dot, i ? ", %s " : "\\ndom: %s ", PFatt_str (n->schema.items[i].name)); @@ -808,7 +809,7 @@ } /* list attributes and their unique names */ - for (unsigned int i = 0; i < n->schema.count; i++) { + for (i = 0; i < n->schema.count; i++) { PFalg_att_t ori = n->schema.items[i].name; PFalg_att_t unq = PFprop_unq_name (n->prop, ori); if (unq) { @@ -834,7 +835,7 @@ } /* list attributes and their original names */ - for (unsigned int i = 0; i < n->schema.count; i++) { + for (i = 0; i < n->schema.count; i++) { PFalg_att_t unq = n->schema.items[i].name; PFalg_att_t ori = PFprop_ori_name (n->prop, unq); if (ori) { @@ -868,7 +869,7 @@ switch (*fmt) { /* list attributes marked const if requested */ case 'c': - for (unsigned int i = 0; + for (i = 0; i < PFprop_const_count (n->prop); i++) PFarray_printf (dot, i ? ", %s" : "\\nconst: %s", PFatt_str ( @@ -879,7 +880,7 @@ { PFalg_attlist_t icols = PFprop_icols_to_attlist (n->prop); - for (unsigned int i = 0; i < icols.count; i++) + for (i = 0; i < icols.count; i++) PFarray_printf (dot, i ? ", %s" : "\\nicols: %s", PFatt_str (icols.atts[i])); } break; @@ -984,7 +985,8 @@ static unsigned int la_xml (PFarray_t *xml, PFla_op_t *n, unsigned int node_id) { - unsigned int c; + unsigned int c = 0, i = 0; + PFalg_simple_type_t t = 0; assert(n->node_id); @@ -1006,10 +1008,10 @@ * */ PFarray_printf (xml, " \n"); - for (unsigned int i = 0; i < n->schema.count; i++) { + for (i = 0; i < n->schema.count; i++) { PFarray_printf (xml, " prop); i++) PFarray_printf (xml, " \n", @@ -1114,7 +1116,7 @@ { PFalg_attlist_t icols = PFprop_icols_to_attlist (n->prop); - for (unsigned int i = 0; i < icols.count; i++) + for (i = 0; i < icols.count; i++) PFarray_printf (xml, " \n", PFatt_str (icols.atts[i])); @@ -1137,7 +1139,7 @@ " \n", PFatt_str (n->schema.items[c].name)); /* print out tuples in table, if table is not empty */ - for (unsigned int i = 0; i < n->sem.lit_tbl.count; i++) + for (i = 0; i < n->sem.lit_tbl.count; i++) PFarray_printf (xml, " %s\n", xml_literal (n->sem.lit_tbl @@ -1678,6 +1680,8 @@ static void reset_node_id (PFla_op_t *n) { + unsigned int c = 0; + if (n->bit_dag) return; else @@ -1685,7 +1689,7 @@ n->node_id = 0; - for (unsigned int c = 0; c < PFLA_OP_MAXCHILD && n->child[c]; c++) + for (c = 0; c < PFLA_OP_MAXCHILD && n->child[c]; c++) reset_node_id (n->child[c]); } Index: compiler/debug/physdebug.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/debug/physdebug.c,v retrieving revision 1.27 diff -u -r1.27 physdebug.c --- compiler/debug/physdebug.c 12 Oct 2006 15:57:04 -0000 1.27 +++ compiler/debug/physdebug.c 1 Nov 2006 20:59:02 -0000 @@ -345,7 +345,7 @@ static unsigned int pa_dot (PFarray_t *dot, PFpa_op_t *n, unsigned int node_id) { - unsigned int c; + unsigned int c = 0, d = 0; assert(n->node_id); static char *color[] = { @@ -455,7 +455,7 @@ PFarray_printf (dot, ")"); /* print out tuples in table, if table is not empty */ - for (unsigned int d = 0; d < n->sem.lit_tbl.count; d++) { + for (d = 0; d < n->sem.lit_tbl.count; d++) { PFarray_printf (dot, "\\n["); for (c = 0; c < n->sem.lit_tbl.tuples[d].count; c++) { PFarray_printf ( @@ -744,6 +744,7 @@ char *fmt = PFstate.format; bool all = false; + unsigned int i = 0, pre = 0; while (*fmt) { if (*fmt == '+') @@ -759,24 +760,24 @@ PFarray_printf (dot, "\\ncard: %i", PFprop_card (n->prop)); /* list attributes marked const */ - for (unsigned int i = 0; + for (i = 0; i < PFprop_const_count (n->prop); i++) PFarray_printf (dot, i ? ", %s" : "\\nconst: %s", PFatt_str ( PFprop_const_at (n->prop, i))); /* list icols attributes */ - for (unsigned int i = 0; i < icols.count; i++) + for (i = 0; i < icols.count; i++) PFarray_printf (dot, i ? ", %s" : "\\nicols: %s", PFatt_str (icols.atts[i])); /* list keys attributes */ - for (unsigned int i = 0; i < keys.count; i++) + for (i = 0; i < keys.count; i++) PFarray_printf (dot, i ? ", %s" : "\\nkeys: %s", PFatt_str (keys.atts[i])); /* list required value columns and their values */ - for (unsigned int pre = 0, i = 0; i < n->schema.count; i++) { + for (pre = 0, i = 0; i < n->schema.count; i++) { PFalg_att_t att = n->schema.items[i].name; if (PFprop_reqval (n->prop, att)) PFarray_printf ( @@ -787,7 +788,7 @@ } /* list attributes and their corresponding domains */ - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) if (PFprop_dom (n->prop, n->schema.items[i].name)) { PFarray_printf (dot, i ? ", %s " : "\\ndom: %s ", PFatt_str (n->schema.items[i].name)); @@ -798,7 +799,7 @@ /* list orderings if requested */ PFarray_printf (dot, "\\norderings:"); - for (unsigned int i = 0; + for (i = 0; i < PFarray_last (n->orderings); i++) PFarray_printf ( dot, "\\n%s", @@ -813,6 +814,8 @@ fmt = PFstate.format; while (!all && *fmt) { + unsigned int i = 0; + switch (*fmt) { /* list costs if requested */ @@ -822,7 +825,7 @@ /* list attributes marked const if requested */ case 'c': - for (unsigned int i = 0; + for (i = 0; i < PFprop_const_count (n->prop); i++) PFarray_printf (dot, i ? ", %s" : "\\nconst: %s", PFatt_str ( @@ -834,7 +837,7 @@ { PFalg_attlist_t icols = PFprop_icols_to_attlist (n->prop); - for (unsigned int i = 0; + for (i = 0; i < icols.count; i++) PFarray_printf (dot, i ? ", %s" : "\\nicols: %s", PFatt_str (icols.atts[i])); @@ -843,7 +846,7 @@ /* list orderings if requested */ case 'o': PFarray_printf (dot, "\\norderings:"); - for (unsigned int i = 0; + for (i = 0; i < PFarray_last (n->orderings); i++) PFarray_printf ( dot, "\\n%s", @@ -918,7 +921,7 @@ static unsigned int pa_xml (PFarray_t *xml, PFpa_op_t *n, unsigned int node_id) { - unsigned int c; + unsigned int c = 0, i = 0; assert(n->node_id); /* open up label */ @@ -939,7 +942,7 @@ " \n", PFatt_str (n->schema.items[c].name)); /* print out tuples in table, if table is not empty */ - for (unsigned int i = 0; i < n->sem.lit_tbl.count; i++) + for (i = 0; i < n->sem.lit_tbl.count; i++) PFarray_printf (xml, " %s\n", xml_literal (n->sem.lit_tbl @@ -1024,8 +1027,6 @@ case pa_std_sort: case pa_refine_sort: { - unsigned int i; - PFarray_printf (xml, " \n"); for (c = 0; c < PFord_count (n->sem.sortby.existing); c++) @@ -1615,6 +1616,8 @@ static void reset_node_id (PFpa_op_t *n) { + unsigned int c = 0; + if (n->bit_dag) return; else @@ -1622,7 +1625,7 @@ n->node_id = 0; - for (unsigned int c = 0; c < PFLA_OP_MAXCHILD && n->child[c]; c++) + for (c = 0; c < PFLA_OP_MAXCHILD && n->child[c]; c++) reset_node_id (n->child[c]); } Index: compiler/mem/bitset.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/mem/bitset.c,v retrieving revision 1.3 diff -u -r1.3 bitset.c --- compiler/mem/bitset.c 31 Oct 2006 09:50:22 -0000 1.3 +++ compiler/mem/bitset.c 1 Nov 2006 20:59:02 -0000 @@ -66,12 +66,13 @@ { unsigned int size = PFarray_last (b); unsigned int unit_pos = UNIT_IDX (pos); + unsigned int i = 0; if (unit_pos >= size) PFarray_nadd (b, unit_pos - size + 1); /* Initialize new allocated part of array */ - for (unsigned int i = size; i <= unit_pos; i++) + for (i = size; i <= unit_pos; i++) BITSET_UNIT_AT (b, i) = 0; if (value) @@ -96,9 +97,10 @@ void PFbitset_or (PFbitset_t *base, PFbitset_t *ext) { unsigned int ext_size = PFarray_last (ext); unsigned int base_size = PFarray_last (base); + unsigned int i = 0; if (ext_size > base_size) /* ensure capacity */ PFarray_nadd (base, ext_size - base_size); - for (unsigned int i = 0; i < ext_size; i++) + for (i = 0; i < ext_size; i++) BITSET_UNIT_AT (base, i) |= BITSET_UNIT_AT (ext, i); } Index: compiler/mil/mil_dce.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/mil_dce.c,v retrieving revision 1.8 diff -u -r1.8 mil_dce.c --- compiler/mil/mil_dce.c 16 Oct 2006 14:06:59 -0000 1.8 +++ compiler/mil/mil_dce.c 1 Nov 2006 20:59:02 -0000 @@ -46,10 +46,12 @@ /** Adds recursivly all variables to the set of the used variables. */ static void add_vars_to_used (PFmil_t *root, PFbitset_t *used_vars) { + unsigned int i = 0; + if (root->kind == m_var) PFbitset_set (used_vars, root->sem.ident, true); else { - for (unsigned int i = 0; i < MIL_MAXCHILD + for (i = 0; i < MIL_MAXCHILD && root->child[i] != NULL; i++) add_vars_to_used(root->child[i], used_vars); } @@ -67,8 +69,9 @@ { /* new node, replacing this expression node. */ PFmil_t *new_op = PFmil_nop(); + unsigned int i = 0; - for (unsigned int i = 0; i < MIL_MAXCHILD && root->child[i] != NULL; i++) { + for (i = 0; i < MIL_MAXCHILD && root->child[i] != NULL; i++) { PFmil_t *param_op = mil_dce_worker (root->child[i], used_vars, dirty_vars, change); @@ -116,6 +119,7 @@ mil_dce_worker (PFmil_t *root, PFbitset_t *used_vars, PFbitset_t *dirty_vars, bool change) { + unsigned int i = 0; #ifdef NDEBUG /* Only used for debugging */ @@ -126,11 +130,12 @@ case m_seq: { + int i = 0; /* descend in reverse pre-order, collect the used variables * from the end to beginning of the program. */ PFmil_t *new_child; - for (int i = MIL_MAXCHILD; --i >= 0;) + for (i = MIL_MAXCHILD; --i >= 0;) if (root->child[i] != NULL) { new_child = mil_dce_worker (root->child[i], used_vars, @@ -384,7 +389,7 @@ #ifndef NDEBUG /* update dirty vars */ - for (unsigned int i = 0; i < MIL_MAXCHILD + for (i = 0; i < MIL_MAXCHILD && root->child[i] != NULL; i++) mil_dce_worker (root->child[i], used_vars, @@ -423,7 +428,7 @@ #ifndef NDEBUG /* update dirty vars */ - for (unsigned int i = 0; i < MIL_MAXCHILD + for (i = 0; i < MIL_MAXCHILD && root->child[i] != NULL; i++) mil_dce_worker (root->child[i], used_vars, dirty_vars, change); #endif Index: compiler/mil/milgen.brg =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milgen.brg,v retrieving revision 1.52 diff -u -r1.52 milgen.brg --- compiler/mil/milgen.brg 18 Oct 2006 08:07:00 -0000 1.52 +++ compiler/mil/milgen.brg 1 Nov 2006 20:59:03 -0000 @@ -321,11 +321,12 @@ { static unsigned int varno = PF_MIL_RES_VAR_COUNT; mvar_t *var = NULL; + unsigned int i = 0; assert (mvars); assert (varno < 10000); - for (unsigned int i = 0; i < PFarray_last (mvars); i++) + for (i = 0; i < PFarray_last (mvars); i++) if ((var = (mvar_t *) PFarray_at (mvars, i))->pins == 0) { var->pins = pins; return var; @@ -442,7 +443,9 @@ static mvar_t * env_mvar_unsafe (const PFarray_t *env, PFalg_att_t att, PFalg_simple_type_t ty) { - for (unsigned int i = 0; i < PFarray_last (env); i++) { + unsigned int i = 0; + + for (i = 0; i < PFarray_last (env); i++) { env_t entry = *(env_t *) PFarray_at ((PFarray_t *) env, i); @@ -460,13 +463,15 @@ env_mvar (const PFarray_t *env, PFalg_att_t att, PFalg_simple_type_t ty) { mvar_t *mvar = env_mvar_unsafe (env, att, ty); + unsigned int i = 0; + if (mvar) return mvar; #ifndef NDEBUG fprintf (stderr, "looking for att: %s, ty: 0x%X\n", PFatt_str (att), ty); fprintf (stderr, "environment looks like:\n"); - for (unsigned int i = 0; i < PFarray_last (env); i++) { + for (i = 0; i < PFarray_last (env); i++) { env_t entry = *(env_t *) PFarray_at ((PFarray_t *) env, i); fprintf (stderr, " att: %s, type: 0x%X, mvar->name: %s\n", @@ -597,6 +602,7 @@ short *nts; /* target non-terminals for the leaf nodes of the current rule */ PFpa_op_t *kids[MAX_KIDS]; /* leaf nodes of this rule */ + unsigned short i = 0; assert (p); @@ -607,7 +613,7 @@ assert(rule); /* initialize the kids[] vector */ - for (unsigned short i = 0; i < MAX_KIDS; i++) + for (i = 0; i < MAX_KIDS; i++) kids[i] = NULL; /* @@ -640,13 +646,14 @@ /* Rel: rec_border (Rel) */ case 136: if (!p->env) { + unsigned int i = 0; /* translate sub-DAG starting at the border */ reduce (p, goalnt); assert (p->env); /* increase the pin count by one to avoid releasing the variables before the end of the while loop and remember which variables to unpin afterwards */ - for (unsigned int i = 0; i < env_count (p->env); i++) { + for (i = 0; i < env_count (p->env); i++) { pin (env_at (p->env, i).mvar, 1); *(mvar_t **) PFarray_add (border_vars) = env_at (p->env, i).mvar; @@ -655,7 +662,7 @@ break; default: - for (unsigned short i = 0; nts[i]; i++) + for (i = 0; nts[i]; i++) reduce_border (kids[i], nts[i], border_vars); } } @@ -673,6 +680,7 @@ short *nts; /* target non-terminals for the leaf nodes of the current rule */ PFpa_op_t *kids[MAX_KIDS]; /* leaf nodes of this rule */ + unsigned short i = 0; assert (p); /* reduce1 should be called only once for each pattern */ @@ -688,7 +696,7 @@ assert(rule); /* initialize the kids[] vector */ - for (unsigned short i = 0; i < MAX_KIDS; i++) + for (i = 0; i < MAX_KIDS; i++) kids[i] = NULL; /* @@ -704,7 +712,8 @@ switch (rule) { /* Rec: rec_param (rec_arg (Rel, Rel), Rec) */ - case 132: + case 132: { + unsigned int i = 0; /* only generate MIL code for the seed */ reduce (kids[0], nts[0]); @@ -716,7 +725,7 @@ (base and paramter both refer to the same environment) and additionally for each parameter to avoid that the variable is overwritten during generation of the recursion. */ - for (unsigned int i = 0; i < env_count (LL(p)->env); i++) { + for (i = 0; i < env_count (LL(p)->env); i++) { mvar_t *tmp = new_var (p->refctr + L(p)->sem.rec_arg.base->refctr); @@ -744,21 +753,25 @@ the recursion body */ reduce_border (kids[1], nts[1], border_vars); break; + } /* Rec: rec_param (rec_arg (empty_tbl, Rel), Rec) */ - case 133: + case 133: { + unsigned int col = 0; + PFalg_simple_type_t t = 0; + /* relink the enviroment of arg to its base */ L(p)->sem.rec_arg.base->env = p->env; /* For each column and type in the empty table generate a new bat and assign it to the variables used by the recursion. */ - for (unsigned int col = 0; col < LL(p)->schema.count; col++) { + for (col = 0; col < LL(p)->schema.count; col++) { if (!LL(p)->schema.items[col].type) PFoops (OOPS_FATAL, "empty sequence should never occur in MIL generation."); - for (PFalg_simple_type_t t = 1; t; t <<= 1) + for (t = 1; t; t <<= 1) if (t & LL(p)->schema.items[col].type) { mvar_t *tmp = new_var (p->refctr + L(p)->sem.rec_arg.base->refctr); @@ -785,6 +798,7 @@ the recursion body */ reduce_border (kids[0], nts[0], border_vars); break; + } /* Rec: rec_nil */ case 134: @@ -800,8 +814,11 @@ #ifndef NDEBUG execute (comment ("End rule (reduce1): \"%s\"", PFmilgen_string[rule])); - for (unsigned int i = 0; i < PFarray_last (p->env); i++) - assert (((env_t *) PFarray_at (p->env, i))->mvar->pins); + { + unsigned int i = 0; + for (i = 0; i < PFarray_last (p->env); i++) + assert (((env_t *) PFarray_at (p->env, i))->mvar->pins); + } #endif #ifndef NDEBUG @@ -830,6 +847,7 @@ PFpa_op_t *kids[MAX_KIDS]; /* leaf nodes of this rule */ int pos_body; /* position of the recursion body in the list of kids */ + unsigned short i = 0; /* reduce2 should be only called after reduce1 */ if (!p->env) @@ -844,7 +862,7 @@ assert(rule); /* initialize the kids[] vector */ - for (unsigned short i = 0; i < MAX_KIDS; i++) + for (i = 0; i < MAX_KIDS; i++) kids[i] = NULL; /* @@ -865,7 +883,9 @@ case 132: pos_body = 1; /* discard the seed */ /* Rec: rec_param (rec_arg (empty_tbl, Rel), Rec) */ - case 133: + case 133: { + unsigned int i = 0; + /* only generate MIL code for the seed */ reduce (kids[pos_body], nts[pos_body]); /* translate all the remaining parts of the body */ @@ -876,7 +896,7 @@ /* Reassign the variables. Thus the initial seed relations are overwritten by the result of the recursion */ - for (unsigned int i = 0; i < PFarray_last (p->env); i++) { + for (i = 0; i < PFarray_last (p->env); i++) { env_t entry = env_at (p->env, i); /* find the corresponding variable in res for the variable in p */ @@ -891,6 +911,7 @@ unpin (tmp, 1); } break; + } /* Rec: rec_nil */ case 134: @@ -906,8 +927,11 @@ #ifndef NDEBUG execute (comment ("End rule (reduce2): \"%s\"", PFmilgen_string[rule])); - for (unsigned int i = 0; i < PFarray_last (p->env); i++) - assert (((env_t *) PFarray_at (p->env, i))->mvar->pins); + { + unsigned int i = 0; + for (i = 0; i < PFarray_last (p->env); i++) + assert (((env_t *) PFarray_at (p->env, i))->mvar->pins); + } #endif #ifndef NDEBUG @@ -936,6 +960,7 @@ PFpa_op_t *kids[MAX_KIDS]; /* leaf nodes of this rule */ int pos_list; /* position of the param list in the list of kids */ + unsigned short i = 0; /* reduce3 should be only called after reduce1 */ if (!p->env) @@ -950,7 +975,7 @@ assert(rule); /* initialize the kids[] vector */ - for (unsigned short i = 0; i < MAX_KIDS; i++) + for (i = 0; i < MAX_KIDS; i++) kids[i] = NULL; /* @@ -971,17 +996,19 @@ case 132: pos_list = 2; /* discard the seed */ /* Rec: rec_param (rec_arg (empty_tbl, Rel), Rec) */ - case 133: + case 133: { + unsigned int i = 0; /* translate all the remaining parts of the list */ reduce3 (kids[pos_list], nts[pos_list]); /* release the remaining pins that ensured that the recursion input arguments were not overwritten during the recursion. */ - for (unsigned int i = 0; i < PFarray_last (p->env); i++) { + for (i = 0; i < PFarray_last (p->env); i++) { unpin (env_at (p->env, i).mvar, p->refctr); } break; + } /* Rec: rec_nil */ case 134: @@ -1022,6 +1049,7 @@ the current rule */ PFpa_op_t *kids[MAX_KIDS]; /* leaf nodes of this rule */ bool topdown; /* is this a top-down rule? */ + unsigned short i = 0; if (p->env) return; @@ -1033,7 +1061,7 @@ assert(rule); /* initialize the kids[] vector */ - for (unsigned short i = 0; i < MAX_KIDS; i++) + for (i = 0; i < MAX_KIDS; i++) kids[i] = NULL; /* @@ -1065,7 +1093,7 @@ * the value part) */ if (!topdown) - for (unsigned short i = MAX_KIDS; i > 0; i--) + for (i = MAX_KIDS; i > 0; i--) if (kids[i - 1]) reduce (kids[i - 1], nts[i - 1]); @@ -1482,7 +1510,7 @@ var (strVAL->name)))))))))); /* - for (unsigned int i = 0; i < env_count (R(p)->env); i++) { + for (i = 0; i < env_count (R(p)->env); i++) { if (i) args = arg (args, var (env_at (R(p)->env, i).mvar->name)); @@ -1604,11 +1632,13 @@ } break; /* Rel: lit_tbl */ - case 10: + case 10: { + unsigned int col = 0, row = 0; + PFalg_simple_type_t t = 0; /* iterate over table columns */ - for (unsigned int col = 0; col < p->schema.count; col++) - for (PFalg_simple_type_t t = 1; t; t <<= 1) + for (col = 0; col < p->schema.count; col++) + for (t = 1; t; t <<= 1) if (t & p->schema.items[col].type) { /* special support for QNames */ if (t == aat_qname) @@ -1627,7 +1657,7 @@ new (type (m_void), implty (t)), lit_oid (0)))); - for (unsigned int row = 0; + for (row = 0; row < p->sem.lit_tbl.count; row++) execute ( append ( @@ -1666,7 +1696,7 @@ new (type (m_void), implty (t)), lit_oid (0)))); - for (unsigned int row = 0; + for (row = 0; row < p->sem.lit_tbl.count; row++) execute ( append ( @@ -1682,6 +1712,7 @@ } break; + } /* Rel: empty_tbl */ case 11: @@ -1693,8 +1724,9 @@ /* Rel: attach (Rel) */ case 12: { + unsigned int i = 0; /* copy all the existing variables */ - for (unsigned int i = 0; i < PFarray_last (L(p)->env); i++) { + for (i = 0; i < PFarray_last (L(p)->env); i++) { env_t entry = env_at (L(p)->env, i); @@ -1721,6 +1753,7 @@ mvar_t *v = new_var (1); mvar_t *v1 = new_var (1); mvar_t *v2 = new_var (1); + unsigned int i = 0; if (!env_count (L(p)->env) || !env_count (R(p)->env)) PFoops (OOPS_FATAL, "Cross does not cope with empty schemas"); @@ -1738,7 +1771,7 @@ assgn (var (v2->name), reverse (mark (reverse (var (v->name)), lit_oid (0))))); - for (unsigned int i = 0; i < env_count (L(p)->env); i++) { + for (i = 0; i < env_count (L(p)->env); i++) { mvar_t *tmp = new_var (p->refctr); /* expand variables */ execute ( @@ -1757,7 +1790,7 @@ env_at (L(p)->env, i).ty, tmp); } - for (unsigned int i = 0; i < env_count (R(p)->env); i++) { + for (i = 0; i < env_count (R(p)->env); i++) { mvar_t *tmp = new_var (p->refctr); /* expand variables */ execute ( @@ -1800,10 +1833,13 @@ mvar_t *r = NULL; mvar_t *tmp1 = new_var (1); mvar_t *tmp[2] = { [0] = new_var (1), [1] = new_var (1) }; + PFalg_simple_type_t t = 0; + unsigned int i = 0; + unsigned short c = 0; assert (lty == rty); - for (PFalg_simple_type_t t = 1; t; t <<= 1) { + for (t = 1; t; t <<= 1) { if (t == lty && t == rty) { l = env_mvar_unsafe (L(p)->env, p->sem.eqjoin.att1, t); r = env_mvar_unsafe (R(p)->env, p->sem.eqjoin.att2, t); @@ -1825,8 +1861,8 @@ unpin (tmp1, 1); - for (unsigned short c = 0; c < 2; c++) { - for (unsigned int i = 0; i < env_count (p->child[c]->env); i++) + for (c = 0; c < 2; c++) { + for (i = 0; i < env_count (p->child[c]->env); i++) { mvar_t *v = new_var (p->refctr); @@ -1859,12 +1895,16 @@ /* Rel: project (Rel) */ case 20: + { + unsigned int i = 0; + PFalg_simple_type_t t = 0; + /* * Algebra projection is a no-op. We only fill the * environment in node p appropriately. */ - for (unsigned int i = 0; i < p->sem.proj.count; i++) - for (PFalg_simple_type_t t = 1; t; t <<= 1) + for (i = 0; i < p->sem.proj.count; i++) + for (t = 1; t; t <<= 1) if (t & type_of (L(p), p->sem.proj.items[i].old)) { mvar_t *v = env_mvar (L(p)->env, @@ -1877,11 +1917,13 @@ } break; + } /* Rel: select (Rel) */ case 21: { mvar_t *v = new_var (1); + unsigned int i = 0; /* * For the predicate column c do @@ -1900,7 +1942,7 @@ /* * Then join any BAT in L(p)'s environment with v */ - for (unsigned int i = 0; i < env_count (L(p)->env); i++) { + for (i = 0; i < env_count (L(p)->env); i++) { mvar_t *w = new_var (p->refctr); execute ( @@ -1927,9 +1969,12 @@ /* Rel: append_union (Rel, Rel) */ case 22: + { + unsigned int i = 0; + PFalg_simple_type_t t = 0; - for (unsigned int i = 0; i < p->schema.count; i++) - for (PFalg_simple_type_t t = 1; t; t <<= 1) + for (i = 0; i < p->schema.count; i++) + for (t = 1; t; t <<= 1) if (t & p->schema.items[i].type) { mvar_t *v = new_var (p->refctr); @@ -1988,7 +2033,7 @@ env_add (p->env, p->schema.items[i].name, t, v); } - break; + } break; /* Rel: append_union (hash_count (Rel), attach ( @@ -2003,9 +2048,11 @@ RLL(p)->schema.count == 1 && RLR(p)->schema.count == 1 && L(p)->sem.count.part != att_NULL) { + unsigned int i = 0; + PFalg_simple_type_t t = 0; - for (unsigned int i = 0; i < LL(p)->schema.count; i++) - for (PFalg_simple_type_t t = 1; t; t <<= 1) + for (i = 0; i < LL(p)->schema.count; i++) + for (t = 1; t; t <<= 1) if (t & LL(p)->schema.items[i].type) { if (t != LL(p)->schema.items[i].type) @@ -2053,7 +2100,7 @@ /* the relation in hash_count is used twice in this pattern - the DAG however counts only one reference - thus we increase the pin count of the affected variables */ - for (unsigned int i = 0; i < PFarray_last (LL(p)->env); i++) + for (i = 0; i < PFarray_last (LL(p)->env); i++) pin (env_at (LL(p)->env, i).mvar, 1); } else @@ -2069,6 +2116,7 @@ PFmil_t *args; bool single_column_grouping = true; mvar_t *v = NULL; + unsigned int i = 0, j = 0; /* * If the grouping parameter for MergeUnion is just a @@ -2106,8 +2154,7 @@ * (2) An order-aware implementation could set ordering * properties correctly right away. */ - for (unsigned int i = 1; - i < PFord_count (p->sem.merge_union.ord); i++) { + for (i = 1; i < PFord_count (p->sem.merge_union.ord); i++) { single_column_grouping = false; @@ -2144,14 +2191,14 @@ * effects... */ if (PFord_count (p->sem.merge_union.ord) > 1) - for (unsigned int i = 0; i < 2; i++) + for (i = 0; i < 2; i++) grouping[i] = chk_order (ctmap (grouping[i])); /* first two arguments of merged_union() are the grouping atts */ args = arg (grouping[0], grouping[1]); - for (unsigned int i = 0; i < p->schema.count; i++) { + for (i = 0; i < p->schema.count; i++) { /* * If we group by a single column, then we don't need @@ -2160,11 +2207,13 @@ if (!single_column_grouping || p->schema.items[i].name != PFord_order_at (p->sem.merge_union.ord, 0)) { + PFalg_simple_type_t t = 0; + unsigned short j = 0; - for (PFalg_simple_type_t t = 1; t; t <<= 1) + for (t = 1; t; t <<= 1) if (t & p->schema.items[i].type) { - for (unsigned short j = 0; j <= 1; j++) + for (j = 0; j <= 1; j++) /* * If t is among the operand's types, use the * corresponding BAT, otherwise substitute a @@ -2190,10 +2239,10 @@ /* execute merged_union() and assign it to v */ execute (assgn (var (v->name), merged_union (args))); - unsigned int j = 1; + j = 1; /* now extract all the result BATs */ - for (unsigned int i = 0; i < p->schema.count; i++) { + for (i = 0; i < p->schema.count; i++) { /* * If we group by a single column, then the grouping @@ -2202,8 +2251,9 @@ if (!single_column_grouping || p->schema.items[i].name != PFord_order_at (p->sem.merge_union.ord, 0)) { + PFalg_simple_type_t t = 0; - for (PFalg_simple_type_t t = 1; t; t <<= 1) + for (t = 1; t; t <<= 1) if (t & p->schema.items[i].type) { mvar_t *w = new_var (p->refctr); @@ -2240,6 +2290,7 @@ mvar_t *is; unsigned int shared_cols; PFmil_t *intersection; + unsigned int col = 0; /* prepare as many result variables and temporary variables as there will be result columns */ @@ -2249,7 +2300,7 @@ env_count(L(p)->env)); shared_cols = 0; - for (unsigned int col = 0; col < env_count (L(p)->env); col++) { + for (col = 0; col < env_count (L(p)->env); col++) { /* in the rhs argument, try to find the column that coresponds (name, type) with the column in the lhs */ r[shared_cols] = env_mvar_unsafe (R(p)->env, @@ -2276,7 +2327,7 @@ /* compute intersection (column-by-column) */ intersection = var (res[0]->name); - for (unsigned int col = 1; col < shared_cols; col++) + for (col = 1; col < shared_cols; col++) intersection = sintersect (intersection, var (res[col]->name)); is = new_var (1); @@ -2284,7 +2335,7 @@ assgn (var (is->name), reverse (mark (tunique (intersection), lit_oid (0))))); - for (unsigned int col = 0; col < shared_cols; col++) + for (col = 0; col < shared_cols; col++) execute ( assgn (var (res[col]->name), leftjoin (var (is->name), var (r[col]->name)))); @@ -2301,6 +2352,7 @@ unsigned int shared_cols; mvar_t *is; PFmil_t *intersection; + unsigned int col = 0; /* prepare as many result variables and temporary variables as there will be result columns */ @@ -2310,7 +2362,7 @@ env_count(L(p)->env)); shared_cols = 0; - for (unsigned int col = 0; col < env_count (L(p)->env); col++) { + for (col = 0; col < env_count (L(p)->env); col++) { /* in the rhs argument, try to find the column that coresponds (name, type) with the column in the lhs */ r = env_mvar_unsafe (R(p)->env, env_at (L(p)->env, col).att, @@ -2337,13 +2389,13 @@ /* compute intersection (column-by-column) */ intersection = var (res[0]->name); - for (unsigned int col = 1; col < shared_cols; col++) + for (col = 1; col < shared_cols; col++) intersection = sintersect (intersection, var (res[col]->name)); is = new_var (1); execute (assgn (var (is->name), intersection)); - for (unsigned int col = 0; col < shared_cols; col++) + for (col = 0; col < shared_cols; col++) execute ( assgn (var (res[col]->name), reverse ( @@ -2372,6 +2424,8 @@ mvar_t *first_sort_var = NULL; bool initialized = false; PFpa_op_t *rel; + unsigned int i = 0; + PFalg_simple_type_t t = 0; if (L(p)->kind == pa_std_sort || L(p)->kind == pa_refine_sort) rel = LL(p); @@ -2383,9 +2437,9 @@ execute (assgn (var (v->name), var (env_at (rel->env, 0).mvar->name))); - for (unsigned int i = 0; + for (i = 0; i < PFord_count (p->sem.sort_distinct.ord); i++) { - for (PFalg_simple_type_t t = 1; t; t <<= 1) { + for (t = 1; t; t <<= 1) { if (t & type_of (rel, PFord_order_at (p->sem.sort_distinct.ord, i))) { @@ -2442,7 +2496,7 @@ * * out := v.join (in); */ - for (unsigned int i = 0; i < env_count (rel->env); i++) { + for (i = 0; i < env_count (rel->env); i++) { mvar_t *out = new_var (p->refctr); execute ( @@ -2482,10 +2536,12 @@ { unsigned int count = 0; mvar_t *v = new_var (1); + unsigned int i = 0; + PFalg_simple_type_t t = 0; - for (unsigned int i = 0; + for (i = 0; i < PFord_count (p->sem.sortby.required); i++) - for (PFalg_simple_type_t t = 1; t; t <<= 1) + for (t = 1; t; t <<= 1) if (t & type_of (L(p), PFord_order_at (p->sem.sortby.required, i))) { @@ -2524,7 +2580,7 @@ execute (assgn (var (v->name), reverse (mark (var (v->name), lit_oid (0))))); - for (unsigned int i = 0; i < env_count (L(p)->env); i++) { + for (i = 0; i < env_count (L(p)->env); i++) { mvar_t *a = new_var (p->refctr); execute ( @@ -2554,14 +2610,15 @@ { mvar_t *v = new_var (1); bool initialized = false; + unsigned int i = 0; + PFalg_simple_type_t t = 0; /* * Create a MonetDB grp object according to the already * existing order. */ - for (unsigned int i = 0; - i < PFord_count (p->sem.sortby.existing); i++) { - for (PFalg_simple_type_t t = 1; t; t <<= 1) { + for (i = 0; i < PFord_count (p->sem.sortby.existing); i++) { + for (t = 1; t; t <<= 1) { if (t & type_of (L(p), PFord_order_at (p->sem.sortby.existing, i))) { @@ -2595,7 +2652,7 @@ /* * Now do the remaining sorting */ - for (unsigned int i = PFord_count (p->sem.sortby.existing); + for (i = PFord_count (p->sem.sortby.existing); i < PFord_count (p->sem.sortby.required); i++) { /* * Be careful to implement document order on @@ -2616,7 +2673,7 @@ PFord_order_at (p->sem.sortby.required, i))))); - for (PFalg_simple_type_t t = 1; t; t <<= 1) + for (t = 1; t; t <<= 1) if (t & type_of (L(p), PFord_order_at (p->sem.sortby.required, i))) { @@ -2637,7 +2694,7 @@ assgn (var (v->name), reverse (mark (var (v->name), lit_oid (0))))); - for (unsigned int i = 0; i < env_count (L(p)->env); i++) { + for (i = 0; i < env_count (L(p)->env); i++) { mvar_t *a = new_var (p->refctr); execute ( @@ -2766,8 +2823,11 @@ /* Rel: hash_count (Rel) */ case 66: if (p->sem.count.part != att_NULL) { - for (unsigned int i = 0; i < L(p)->schema.count; i++) - for (PFalg_simple_type_t t = 1; t; t <<= 1) + unsigned int i = 0; + PFalg_simple_type_t t = 0; + + for (i = 0; i < L(p)->schema.count; i++) + for (t = 1; t; t <<= 1) if (t & L(p)->schema.items[i].type) { if (t != L(p)->schema.items[i].type) @@ -2851,9 +2911,10 @@ case 71: { mvar_t *v = new_var (p->refctr); + unsigned int i = 0; /* copy all the attributes from our argument */ - for (unsigned int i = 0; i < env_count (L(p)->env); i++) { + for (i = 0; i < env_count (L(p)->env); i++) { pin (env_at (L(p)->env, i).mvar, p->refctr); @@ -2899,11 +2960,12 @@ case 73: { mvar_t *res = new_var (p->refctr); + unsigned int i = 0; assert (env_count (L(p)->env)); /* copy all the attributes */ - for (unsigned int i = 0; i < env_count (L(p)->env); i++) { + for (i = 0; i < env_count (L(p)->env); i++) { pin (env_at (L(p)->env, i).mvar, p->refctr); env_add (p->env, env_at (L(p)->env, i).att, @@ -2941,12 +3003,13 @@ case 74: { mvar_t *res = new_var (p->refctr); + unsigned int i = 0; /* and put the result into p's environment */ env_add (p->env, p->sem.type.res, aat_bln, res); /* everything from p's child */ - for (unsigned int i = 0; i < PFarray_last (L(p)->env); i++) { + for (i = 0; i < PFarray_last (L(p)->env); i++) { env_t entry = env_at (L(p)->env, i); @@ -2988,9 +3051,11 @@ break; /* Rel: type_assert (Rel) */ - case 75: + case 75: { + unsigned int i = 0; + /* copy all the attributes */ - for (unsigned int i = 0; i < env_count (L(p)->env); i++) { + for (i = 0; i < env_count (L(p)->env); i++) { pin (env_at (L(p)->env, i).mvar, p->refctr); env_add (p->env, env_at (L(p)->env, i).att, @@ -2998,28 +3063,31 @@ env_at (L(p)->env, i).mvar); } break; + } /* Rel: cast (Rel) */ - case 76: - for (unsigned int i = 0; i < L(p)->schema.count; i++) - { + case 76: { + unsigned int i = 0; + + for (i = 0; i < L(p)->schema.count; i++) { bool att_needed = true; mvar_t *v = NULL; /* cast as qname requires additional document access */ if (L(p)->schema.items[i].name == p->sem.cast.att && p->sem.cast.ty == aat_qname) { + bool qn = false; + PFalg_simple_type_t t = 0; v = new_var (p->refctr); - for (PFalg_simple_type_t t = 1; t; t <<= 1) + for (t = 1; t; t <<= 1) if ((t & L(p)->schema.items[i].type) && (t != aat_str && t != aat_uA && t != aat_qname)) PFoops (OOPS_FATAL, "cast to type QName is only possible " "for type QName and type string.%i", t); - bool qn = false; /* nothing to do - just assign it to a new variable */ if (L(p)->schema.items[i].type & aat_qname) @@ -3082,10 +3150,11 @@ else if (L(p)->schema.items[i].name == p->sem.cast.att) { unsigned int parts = 0; + PFalg_simple_type_t t = 0; v = new_var (p->refctr); - for (PFalg_simple_type_t t = 1; t; t <<= 1) + for (t = 1; t; t <<= 1) if (t & L(p)->schema.items[i].type) { PFmil_t *casted = NULL; @@ -3121,7 +3190,9 @@ } if (att_needed) { - for (PFalg_simple_type_t t = 1; t; t <<= 1) + PFalg_simple_type_t t = 0; + + for (t = 1; t; t <<= 1) if (t & L(p)->schema.items[i].type) { mvar_t *v = env_mvar (L(p)->env, @@ -3133,6 +3204,7 @@ } } } break; + } /* Rel: llscj_anc (FragList, Rel) */ case 80: @@ -3458,9 +3530,10 @@ case 101: { mvar_t *str = new_var (p->refctr); + unsigned int i = 0; /* copy all the attributes */ - for (unsigned int i = 0; i < env_count (R(p)->env); i++) { + for (i = 0; i < env_count (R(p)->env); i++) { pin (env_at (R(p)->env, i).mvar, p->refctr); env_add (p->env, env_at (R(p)->env, i).att, @@ -3690,6 +3763,7 @@ /* result BATs */ mvar_t *attr = new_var (p->refctr); mvar_t *frag = new_var (p->refctr); + unsigned int i = 0; env_add (p->env, p->sem.attr.res, aat_attr, attr); env_add (p->env, p->sem.attr.res, aat_afrag, frag); @@ -3707,7 +3781,7 @@ unpin (v, 1); /* copy all the existing variables of the qname relation */ - for (unsigned int i = 0; i < PFarray_last (L(p)->env); i++) { + for (i = 0; i < PFarray_last (L(p)->env); i++) { env_t entry = env_at (L(p)->env, i); @@ -3725,6 +3799,7 @@ /* result BATs */ mvar_t *pre = new_var (p->refctr); mvar_t *frag = new_var (p->refctr); + unsigned int i = 0; env_add (p->env, p->sem.textnode.res, aat_pre, pre); env_add (p->env, p->sem.textnode.res, aat_pfrag, frag); @@ -3740,7 +3815,7 @@ unpin (v, 1); /* copy all the existing variables */ - for (unsigned int i = 0; i < PFarray_last (L(p)->env); i++) { + for (i = 0; i < PFarray_last (L(p)->env); i++) { env_t entry = env_at (L(p)->env, i); @@ -3772,9 +3847,10 @@ case 110: { PFmil_t *iter = NULL, *pre = NULL, *pfrag = NULL; + unsigned int i = 0; /* copy all the existing variables */ - for (unsigned int i = 0; i < PFarray_last (R(p)->env); i++) { + for (i = 0; i < PFarray_last (R(p)->env); i++) { env_t entry = env_at (R(p)->env, i); if (entry.att == p->sem.ii.iter && entry.ty == aat_nat) { @@ -3815,9 +3891,11 @@ } break; /* Rel: roots (FragRel) */ - case 120: + case 120: { + unsigned int i = 0; + /* copy all the attributes from our argument */ - for (unsigned int i = 0; i < env_count (L(p)->env); i++) { + for (i = 0; i < env_count (L(p)->env); i++) { pin (env_at (L(p)->env, i).mvar, p->refctr); @@ -3827,6 +3905,7 @@ env_at (L(p)->env, i).mvar); } break; + } /* Frag: fragment (FragRel) */ case 121: @@ -3841,7 +3920,9 @@ break; /* Rel: cond_err (Rel, Rel) */ - case 130: + case 130: { + unsigned int i = 0; + execute ( if_ (exist (reverse (VAR (R(p)->env, p->sem.err.att, aat_bln)), lit_bit (false)), @@ -3849,7 +3930,7 @@ nop ())); /* copy all the attributes */ - for (unsigned int i = 0; i < env_count (L(p)->env); i++) { + for (i = 0; i < env_count (L(p)->env); i++) { pin (env_at (L(p)->env, i).mvar, p->refctr); env_add (p->env, env_at (L(p)->env, i).att, @@ -3857,6 +3938,7 @@ env_at (L(p)->env, i).mvar); } break; + } /* Rel: rec_fix (Rec, Rel) */ case 131: @@ -3865,6 +3947,7 @@ PFarray_t *res_env; mvar_t *old_count, *new_count; PFarray_t *border_vars = PFarray (sizeof (mvar_t *)); + unsigned int i = 0; /* Generate code for the seeds and bind them to the new variables. In addition generate code for all expressions that are @@ -3921,7 +4004,7 @@ unpin (old_count, 1); /* copy all the result attributes */ - for (unsigned int i = 0; i < env_count (res_env); i++) { + for (i = 0; i < env_count (res_env); i++) { pin (env_at (res_env, i).mvar, p->refctr); @@ -3933,7 +4016,7 @@ /* release the additional pins of the variables representing the recursion invariant expressions */ - for (unsigned int i = 0; i < PFarray_last (border_vars); i++) + for (i = 0; i < PFarray_last (border_vars); i++) unpin (*(mvar_t **) PFarray_at (border_vars, i), 1); /* release all the pins of the while loop arguments */ @@ -3941,7 +4024,7 @@ /* ensure that the child of p (the first argument) still has one pin left to release (see bottom of function reduce) */ - for (unsigned int i = 0; i < PFarray_last (L(p)->env); i++) + for (i = 0; i < PFarray_last (L(p)->env); i++) pin (env_at (L(p)->env, i).mvar, 1); } break; @@ -3967,8 +4050,10 @@ break; /* Rel: rec_border (Rel) */ - case 136: - for (unsigned int i = 0; i < env_count (L(p)->env); i++) { + case 136: { + unsigned int i = 0; + + for (i = 0; i < env_count (L(p)->env); i++) { pin (env_at (L(p)->env, i).mvar, p->refctr); env_add (p->env, @@ -3977,6 +4062,7 @@ env_at (L(p)->env, i).mvar); } break; + } /* Rel: concat (Rel) */ case 140: @@ -3987,6 +4073,7 @@ case 141: { mvar_t *res = new_var (p->refctr); + unsigned int i = 0; /* do the containment checks: [search](strings,search_strs).[!=](-1).[oid]() */ @@ -4005,7 +4092,7 @@ env_add (p->env, p->sem.binary.res, aat_bln, res); /* everything from p's child */ - for (unsigned int i = 0; i < PFarray_last (L(p)->env); i++) { + for (i = 0; i < PFarray_last (L(p)->env); i++) { env_t entry = env_at (L(p)->env, i); @@ -4052,21 +4139,29 @@ break; } - for (unsigned short c = 0; nts[c]; c++) - for (unsigned int i = 0; i < PFarray_last (kids[c]->env); i++) - unpin (((env_t *) PFarray_at (kids[c]->env, i))->mvar, 1); + { + unsigned short c = 0; + unsigned int i = 0; + + for (c = 0; nts[c]; c++) + for (i = 0; i < PFarray_last (kids[c]->env); i++) + unpin (((env_t *) PFarray_at (kids[c]->env, i))->mvar, 1); + } #ifndef NDEBUG execute (comment ("End rule: \"%s\"", PFmilgen_string[rule])); - for (unsigned int i = 0; i < PFarray_last (p->env); i++) - assert (((env_t *) PFarray_at (p->env, i))->mvar->pins); + { + unsigned int i = 0; + for (i = 0; i < PFarray_last (p->env); i++) + assert (((env_t *) PFarray_at (p->env, i))->mvar->pins); + } #endif #ifndef NDEBUG /* Debugging only: assign column names to BATs */ /* switch off debugging information as it triggers errors in MonetDB... - for (unsigned int i = 0; i < env_count (p->env); i++) + for (i = 0; i < env_count (p->env); i++) execute (col_name (var (env_at (p->env, i).mvar->name), lit_str (PFatt_str (env_at (p->env, i).att)))); */ @@ -4077,9 +4172,11 @@ static PFalg_simple_type_t type_of (PFpa_op_t *n, PFalg_att_t att) { + unsigned int i = 0; + assert (n); - for (unsigned int i = 0; i < n->schema.count; i++) + for (i = 0; i < n->schema.count; i++) if (n->schema.items[i].name == att) return n->schema.items[i].type; @@ -4663,6 +4760,7 @@ PFpa_op_t *p, PFalg_simple_type_t arg_ty, PFalg_simple_type_t ret_ty) { mvar_t *res = new_var (p->refctr); + unsigned int i = 0; /* do the arithmetics */ execute ( @@ -4674,7 +4772,7 @@ env_add (p->env, p->sem.binary.res, ret_ty, res); /* everything from p's child */ - for (unsigned int i = 0; i < PFarray_last (L(p)->env); i++) { + for (i = 0; i < PFarray_last (L(p)->env); i++) { env_t entry = env_at (L(p)->env, i); @@ -4716,6 +4814,7 @@ node_comp (PFmil_t * (*op) (const PFmil_t *, const PFmil_t *), PFpa_op_t *p) { mvar_t *res = new_var (p->refctr); + unsigned int i = 0; if (op == PFmil_mgt) { /* do the comparison: @@ -4748,7 +4847,7 @@ env_add (p->env, p->sem.binary.res, aat_bln, res); /* everything from p's child */ - for (unsigned int i = 0; i < PFarray_last (L(p)->env); i++) { + for (i = 0; i < PFarray_last (L(p)->env); i++) { env_t entry = env_at (L(p)->env, i); @@ -4814,6 +4913,7 @@ PFalg_simple_type_t arg_ty, PFalg_simple_type_t ret_ty) { mvar_t *res = new_var (p->refctr); + unsigned int i = 0; /* do the arithmetics */ execute ( @@ -4825,7 +4925,7 @@ env_add (p->env, p->sem.bin_atom.res, ret_ty, res); /* everything from p's child */ - for (unsigned int i = 0; i < PFarray_last (L(p)->env); i++) { + for (i = 0; i < PFarray_last (L(p)->env); i++) { env_t entry = env_at (L(p)->env, i); @@ -4887,6 +4987,7 @@ { mvar_t *res = new_var (p->refctr); PFalg_simple_type_t ty = type_of (L(p), p->sem.unary.att); + unsigned int i = 0; /* do the arithmetics */ execute ( @@ -4897,7 +4998,7 @@ env_add (p->env, p->sem.unary.res, ty, res); /* everything from p's child */ - for (unsigned int i = 0; i < PFarray_last (L(p)->env); i++) { + for (i = 0; i < PFarray_last (L(p)->env); i++) { env_t entry = env_at (L(p)->env, i); @@ -4932,15 +5033,16 @@ PFalg_type_t poly_att_type = 0; PFalg_type_t poly_part_type = 0; PFalg_type_t poly_res_type = 0; + unsigned int i = 0; /* determine res type */ - for (unsigned int i = 0; i < p->schema.count; i++) { + for (i = 0; i < p->schema.count; i++) { if (p->schema.items[i].name == res) { poly_res_type = p->schema.items[i].type; break; } } /* determine att and part type */ - for (unsigned int i = 0; i < L(p)->schema.count; i++) { + for (i = 0; i < L(p)->schema.count; i++) { if (L(p)->schema.items[i].name == part) poly_part_type = L(p)->schema.items[i].type; else if (L(p)->schema.items[i].name == att) @@ -5026,6 +5128,8 @@ static void inc_refctr (PFpa_op_t *n) { + unsigned int i = 0; + assert (n); /* count number of incoming edges */ @@ -5037,7 +5141,7 @@ else SEEN(n) = true; - for (unsigned int i = 0; i < PFPA_OP_MAXCHILD && n->child[i]; i++) + for (i = 0; i < PFPA_OP_MAXCHILD && n->child[i]; i++) inc_refctr (n->child[i]); } @@ -5075,6 +5179,8 @@ PFmil_t * PFmilgen (PFpa_op_t *n) { + unsigned int i = 0; + assert (n); /* set counters in algebra tree nodes */ @@ -5099,7 +5205,7 @@ #ifndef NDEBUG mvar_t *var = NULL; - for (unsigned int i = 0; i < PFarray_last (mvars); i++) + for (i = 0; i < PFarray_last (mvars); i++) if ((var = (mvar_t *) PFarray_at (mvars, i))->pins) { if (var->pins == 1) PFinfo (OOPS_WARNING, @@ -5113,7 +5219,7 @@ #endif /* prepend variable declarations before the actual program */ - for (unsigned int i = 0; i < PFarray_last (mvars); i++) + for (i = 0; i < PFarray_last (mvars); i++) milprog = seq (declare (var (((mvar_t *) PFarray_at (mvars, i))->name)), milprog); Index: compiler/mil/milprint_summer.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milprint_summer.c,v retrieving revision 1.294 diff -u -r1.294 milprint_summer.c --- compiler/mil/milprint_summer.c 31 Oct 2006 17:38:19 -0000 1.294 +++ compiler/mil/milprint_summer.c 1 Nov 2006 20:59:04 -0000 @@ -9313,8 +9313,9 @@ assert (!is_rpc); assert (fun->arity == 2); bool found = false; + unsigned int i = 0; /* choose one implementation. */ - for (unsigned int i = 0; i < fun->sig_count && !found; i++) { + for (i = 0; i < fun->sig_count && !found; i++) { if (PFty_promotable (TY(L(c)), fun->sigs[i].par_ty[0]) && PFty_promotable (TY(RL(c)), @@ -10943,9 +10944,11 @@ expand_flwr (R(c), ret); break; - default: - for (unsigned int i = 0; i < PFCNODE_MAXCHILD && c->child[i]; i++) + default: { + unsigned int i = 0; + for (i = 0; i < PFCNODE_MAXCHILD && c->child[i]; i++) expand_flwr (c->child[i], ret); + } } } Index: compiler/parser/parser.y =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/parser/parser.y,v retrieving revision 1.47 diff -u -r1.47 parser.y --- compiler/parser/parser.y 24 Oct 2006 15:20:02 -0000 1.47 +++ compiler/parser/parser.y 1 Nov 2006 20:59:05 -0000 @@ -2837,7 +2837,9 @@ static void add_to_module_wl (char rpc, char*id, char *ns, char *uri) { - for (unsigned int i = 0; i < PFarray_last (modules); i++) + unsigned int i = 0; + + for (i = 0; i < PFarray_last (modules); i++) if ( !strcmp (((module_t *) PFarray_at (modules, i))->uri, uri) ) return; @@ -2847,9 +2849,11 @@ static char * get_rpc_uri(char *prefix){ + unsigned int i = 0; + if (!prefix) return NULL; - for (unsigned int i = 0; i < PFarray_last (modules); i++){ + for (i = 0; i < PFarray_last (modules); i++){ module_t *m = (module_t *) PFarray_at(modules, i); if ( m->rpc && (strcmp (m->id, prefix) == 0)) return m->uri; @@ -2956,11 +2960,12 @@ PFpnode_t *module; PFloc_t noloc = (PFloc_t) { .first_row = 0, .first_col = 0, .last_row = 0, .last_col = 0}; + unsigned int i = 0; /* only accept module from now on */ module_only = true; - for (unsigned int i = 0; i < PFarray_last (modules); i++) { + for (i = 0; i < PFarray_last (modules); i++) { module = parse_module (((module_t *) PFarray_at (modules, i))->ns, ((module_t *) PFarray_at (modules, i))->uri); Index: compiler/semantics/functions.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/semantics/functions.c,v retrieving revision 1.29 diff -u -r1.29 functions.c --- compiler/semantics/functions.c 19 Jun 2006 08:56:20 -0000 1.29 +++ compiler/semantics/functions.c 1 Nov 2006 20:59:05 -0000 @@ -247,11 +247,14 @@ add_ufun (n); return; - default: + default: { + unsigned int i = 0; + /* recurse */ - for (unsigned int i = 0; + for (i = 0; (i < PFPNODE_MAXCHILD) && (n->child[i]); i++) add_ufuns (n->child[i]); + } } } @@ -387,10 +390,11 @@ { PFfun_t *fun = *funs; unsigned int i = 0; + unsigned int s = 0; fprintf (stderr, "function name: %s\n", PFqname_str (fun->qname)); if (fun->builtin) { - for (unsigned int s = 0; s < fun->sig_count; s++) { + for (s = 0; s < fun->sig_count; s++) { PFfun_sig_t *sig = fun->sigs + s; fprintf (stderr, "\treturn type : %s\n", PFty_str (sig->ret_ty)); @@ -494,6 +498,7 @@ PFvar_t **params) { PFfun_t *n; + unsigned int i = 0; n = (PFfun_t *) PFmalloc (sizeof (PFfun_t)); @@ -509,7 +514,7 @@ n->sig_count = sig_count; /* assert (sig_count); */ n->sigs = (PFfun_sig_t *) PFmalloc (sig_count * sizeof (PFfun_sig_t)); - for (unsigned int i = 0; i < sig_count; i++) { + for (i = 0; i < sig_count; i++) { /* copy array of formal parameter types (if present) */ if (arity > 0 && sigs) { n->sigs[i].par_ty = (PFty_t *) PFmalloc (arity * sizeof (PFty_t)); Index: compiler/semantics/normalize.brg =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/semantics/normalize.brg,v retrieving revision 1.11 diff -u -r1.11 normalize.brg --- compiler/semantics/normalize.brg 24 Oct 2006 15:20:02 -0000 1.11 +++ compiler/semantics/normalize.brg 1 Nov 2006 20:59:05 -0000 @@ -653,6 +653,7 @@ bool rewritten; short old_state_label; PFpnode_t * c; + unsigned int i = 0; do { /* determine rule that matches for this non-terminal */ @@ -661,7 +662,7 @@ /* PFinfo (OOPS_NOTICE, "match for rule %i", rule); */ /* initialize the kids[] vector */ - for (unsigned short i = 0; i < MAX_KIDS; i++) + for (i = 0; i < MAX_KIDS; i++) kids[i] = NULL; /* @@ -674,7 +675,6 @@ /* * Recursively invoke compilation. This means bottom-up compilation. */ - unsigned short i; rewritten = false; for (i = 0; nts[i]; i++) if ((rewritten = reduce (kids[i], nts[i], varcount))) Index: compiler/semantics/ns.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/semantics/ns.c,v retrieving revision 1.26 diff -u -r1.26 ns.c --- compiler/semantics/ns.c 27 Oct 2006 09:45:17 -0000 1.26 +++ compiler/semantics/ns.c 1 Nov 2006 20:59:05 -0000 @@ -262,9 +262,11 @@ static char * ns_lookup (const char *prefix) { + unsigned int i = 0; + assert (prefix); - for (unsigned int i = PFarray_last (stat_known_ns); i; i--) { + for (i = PFarray_last (stat_known_ns); i; i--) { assert(((PFns_t *) PFarray_at (stat_known_ns, i-1))->prefix); if (! strcmp (prefix, ((PFns_t *) PFarray_at (stat_known_ns, i-1))->prefix)) { @@ -284,8 +286,9 @@ copy_ns_env (const PFns_map_t *src) { PFns_map_t *dest = PFarray (sizeof (PFns_t)); + unsigned int i = 0; - for (unsigned int i = 0; i < PFarray_last (src); i++) + for (i = 0; i < PFarray_last (src); i++) *((PFns_t *) PFarray_add (dest)) = *((PFns_t *) PFarray_at ((PFns_map_t *) src, i)); Index: compiler/semantics/subtyping.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/semantics/subtyping.c,v retrieving revision 1.41 diff -u -r1.41 subtyping.c --- compiler/semantics/subtyping.c 26 Oct 2006 13:57:39 -0000 1.41 +++ compiler/semantics/subtyping.c 1 Nov 2006 20:59:05 -0000 @@ -2493,6 +2493,7 @@ void PFty_debug_subtyping (void) { + unsigned int i = 0; /* * Pairs of types that will be tested. Feel free to add more. */ @@ -2522,7 +2523,7 @@ fprintf (stderr, "--------------------------------\n"); fprintf (stderr, "\n"); - for (unsigned int i = 0; i < sizeof (types) / sizeof (*types); i++) + for (i = 0; i < sizeof (types) / sizeof (*types); i++) fprintf (stderr, "%s <: %s : %s\n", PFty_str (types[i].t1), PFty_str (types[i].t2), Index: compiler/semantics/typecheck.brg =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/semantics/typecheck.brg,v retrieving revision 1.44 diff -u -r1.44 typecheck.brg --- compiler/semantics/typecheck.brg 31 Oct 2006 09:28:27 -0000 1.44 +++ compiler/semantics/typecheck.brg 1 Nov 2006 20:59:05 -0000 @@ -345,10 +345,11 @@ static void reduce (PFcnode_t * p, int goalnt) { - int rule; /* rule number that matches for this node */ - short *nts; /* target non-terminals for the leaf nodes of + int rule; /* rule number that matches for this node */ + short *nts; /* target non-terminals for the leaf nodes of the current rule */ - PFcnode_t *kids[MAX_KIDS]; /* leaf nodes of this rule */ + PFcnode_t *kids[MAX_KIDS]; /* leaf nodes of this rule */ + unsigned short i = 0; /* determine rule that matches for this non-terminal */ rule = PFtypecheck_rule (STATE_LABEL (p), goalnt); @@ -357,7 +358,7 @@ /* PFinfo (OOPS_NOTICE, "match for rule %i", rule); */ /* initialize the kids[] vector */ - for (unsigned short i = 0; i < MAX_KIDS; i++) + for (i = 0; i < MAX_KIDS; i++) kids[i] = NULL; /* @@ -396,7 +397,7 @@ * Recursively invoke compilation. * This means bottom-up compilation. */ - for (unsigned short i = 0; nts[i]; i++) + for (i = 0; nts[i]; i++) reduce (kids[i], nts[i]); } @@ -1271,6 +1272,7 @@ */ PFarray_t *args_str = PFarray (sizeof (char)); char semi = ':'; + unsigned int i = 0, j = 0, k = 0; do { PFarray_printf (args_str, "%c %s", @@ -1287,18 +1289,18 @@ PFinfo (OOPS_TYPECHECK, "maybe you meant:"); - for (unsigned int i = 0; i < PFarray_last (fns); i++) { + for (i = 0; i < PFarray_last (fns); i++) { PFfun_t *fn = *(PFfun_t **) PFarray_at (fns, i); - for (unsigned j = 0; j < fn->sig_count; j++) { + for (j = 0; j < fn->sig_count; j++) { args_str = PFarray (sizeof (char)); PFfun_sig_t *sig = fn->sigs + j; PFarray_printf (args_str, "%s (", PFqname_str (fn->qname)); - for (unsigned int k = 0; k < fn->arity; k++) { + for (k = 0; k < fn->arity; k++) { PFarray_printf (args_str, "%s%s", k ? ", " : "", PFty_str (sig->par_ty[k])); @@ -1522,6 +1524,7 @@ } if (fn->sig_count > 1) { + PFty_t c1, c2; /* TODO: initialise correctly */ /* special handing for functions with multiple signatures, * but one implementation ("dynamic overloading") */ @@ -1535,24 +1538,25 @@ PFty_t arg2_type = PFty_defn (TY(L(R(args)))); /* iterate through the possible types of argument 1 */ - for (PFty_t c1 = PFty_normalize_choice (arg1_type); + for (c1 = PFty_normalize_choice (arg1_type); c1.type != ty_none; c1 = next_choice (c1)) { PFty_t t1 = next_type (c1); /* iterate through the possible types of argument 2 */ - for (PFty_t c2 = PFty_normalize_choice (arg2_type); + for (c2 = PFty_normalize_choice (arg2_type); c2.type != ty_none; c2 = next_choice (c2)) { PFty_t t2 = next_type (c2); bool found = false; + unsigned int i = 0; /* for every combination, check if we have a matching * signature. */ - for (unsigned int i = 0; + for (i = 0; i < fn->sig_count && !found; i++) { PFfun_sig_t *sig = fn->sigs + i; Index: compiler/semantics/varscope.c =================================================================== RCS file: /cvsroot/monetdb/pathfinder/compiler/semantics/varscope.c,v retrieving revision 1.17 diff -u -r1.17 varscope.c --- compiler/semantics/varscope.c 25 Sep 2006 11:11:40 -0000 1.17 +++ compiler/semantics/varscope.c 1 Nov 2006 20:59:05 -0000 @@ -586,16 +586,18 @@ } break; - default: + default: { + int child = 0; /* unsigned */ /* * For all other cases just traverse the whole tree recursively. */ - for (int child = 0; + for (child = 0; child < PFPNODE_MAXCHILD && n->child[child]; child++) scope_lib_mod (n->child[child]); break; + } } } Index: runtime/serialize.mx =================================================================== RCS file: /cvsroot/monetdb/pathfinder/runtime/serialize.mx,v retrieving revision 1.78 diff -u -r1.78 serialize.mx --- runtime/serialize.mx 19 Sep 2006 12:27:44 -0000 1.78 +++ runtime/serialize.mx 1 Nov 2006 20:59:06 -0000 @@ -743,6 +743,7 @@ oid first = 0; BUN bun; BAT* batbat = NULL; + int i = 0, j = 0; if ( !(bun = BUNfnd(ctx->ws,&first)) ) { fatal_err(ctx,"initWsMatrix: cannot find ws-bat[0]"); return PROBLEM; @@ -757,8 +758,8 @@ if ( !( ctx->wsMatrix = (wsBatDescr*) GDKmalloc(ctx->wsConts*WS_BATS*sizeof(wsBatDescr))) ) { return PROBLEM; } - for(int i=0; iwsConts; i++) { - for(int j=0; jwsConts; i++) { + for(j=0; jwsMatrix[WSMI(i,j)]; @@ -776,8 +777,10 @@ static bool disposeWsMatrix(XqueryCtx* ctx) { - for(int i=0; iwsConts; i++) { - for(int j=0; jwsConts; i++) { + for(j=0; jwsMatrix[WSMI(i,j)]; Index: runtime/serialize_dflt.mx =================================================================== RCS file: /cvsroot/monetdb/pathfinder/runtime/serialize_dflt.mx,v retrieving revision 1.17 diff -u -r1.17 serialize_dflt.mx --- runtime/serialize_dflt.mx 24 Oct 2006 16:02:48 -0000 1.17 +++ runtime/serialize_dflt.mx 1 Nov 2006 20:59:06 -0000 @@ -94,8 +94,9 @@ new_dflt_ws () { dflt_ws_t *dflt_ws_ = GDKmalloc (sizeof (dflt_ws_t)); + int i = 0; - for(int i = 0; i < UCHAR_MAX; i++) + for(i = 0; i < UCHAR_MAX; i++) /* special character mapping table */ dflt_ws_->isspecial_tab[i] = 0;