Update of /cvsroot/monetdb/pathfinder/compiler/algebra/prop
In directory
sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22998/compiler/algebra/prop
Modified Files:
prop_card.c
Log Message:
Simple recursion support for the SQL generator for
with $x seeded by expr recurse expr
SQL allows to express simple recursive statements using the
WITH RECURSIVE clause. In the core to algebra translation we
now have two recursion-strategies (for MIL and SQL) with different
behaviours.
The SQL variant, for example, cannot cope with non-DELTA evaluation
due to its inherent restrictions.
Index: prop_card.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_card.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- prop_card.c 15 Feb 2008 12:15:58 -0000 1.32
+++ prop_card.c 19 Mar 2008 10:58:46 -0000 1.33
@@ -52,6 +52,9 @@
return prop->card;
}
+
+static void prop_infer (PFla_op_t *n);
+
/**
* Infer properties about cardinalities; worker for prop_infer().
*/
@@ -208,13 +211,39 @@
/* recursion parameters do not have properties */
break;
- case la_rec_arg:
+ case la_rec_arg: {
+ PFla_op_t *base = n->sem.rec_arg.base;
+ /* infer the cardinality of the left child */
+ prop_infer (L(n));
+
+ /* set the base to the just inferred cardinality */
+ base->prop->card = L(n)->prop->card;
+
+ /* infer the cardinality of the body under the
+ * new circumstances */
+ prop_infer (R(n));
+
+ /* if the inferred cardinality is the same as
+ * the cardinality inferred for the base,
+ * we are sure that the recursion will return
+ * a result in any case */
+ if ((R(n)->prop) &&
+ (R(n)->prop->card == base->prop->card)) {
+ n->prop->card = R(n)->prop->card;
+ break;
+ }
+
+ /* in every other case we infer the cardinality
+ * like before: we infer nothing about the cardinality
+ * of the seed operator and infer the cardinality of
+ * the recursion body again */
+ base->prop->card = 0;
+ prop_infer (R(n));
n->prop->card = R(n)->prop->card;
- break;
+ } break;
case la_rec_base:
- /* infer no properties of the seed */
- n->prop->card = 0;
+ /* do nothing, magic happens in rec_arg */
break;
case la_fun_call:
@@ -229,15 +258,24 @@
static void
prop_infer (PFla_op_t *n)
{
+ bool topdown;
assert (n);
/* nothing to do if we already visited that node */
if (n->bit_dag)
return;
+ switch (n->kind) {
+ case la_rec_arg:
+ topdown = true;
+ default:
+ topdown = false;
+ }
+
/* infer properties for children */
- for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++)
- prop_infer (n->child[i]);
+ if (!topdown)
+ for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && n->child[i]; i++)
+ prop_infer (n->child[i]);
n->bit_dag = true;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins