Update of /cvsroot/monetdb/pathfinder/compiler/mil
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25319/mil
Modified Files:
Tag: XQuery_0-24
mil.c mil_dce.c milgen.brg milprint.c
Log Message:
Added a non-multiplex version of mil operators "and" and "startswith"
Added a new mil statement "break_" to break out of a loop in mil
U milprint.c
Index: milprint.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milprint.c,v
retrieving revision 1.78.2.1
retrieving revision 1.78.2.2
diff -u -d -r1.78.2.1 -r1.78.2.2
--- milprint.c 5 Jun 2008 09:45:42 -0000 1.78.2.1
+++ milprint.c 5 Jun 2008 16:29:49 -0000 1.78.2.2
@@ -10,6 +10,7 @@
statements : statements statements <m_seq>
| 'if (' Expr ') {' stmts '} else {' stmts '}' <m_if>
| 'while (' Expr ') {' stmts '}' <m_while>
+ | 'break' <m_break>
| <nothing> <m_nop>
| '#' c <m_comment>
| statement ';' <otherwise>
@@ -126,6 +127,7 @@
| '[string](' expression ',' expression ')'<m_mstring>
| '[string](' exp ',' exp ',' exp ')' <m_mstring2>
| '[startsWith](' exp ',' exp ')' <m_mstarts_with>
+ | 'startsWith(' exp ',' exp ')' <m_starts_with>
| '[endsWith](' exp ',' exp ')' <m_mends_with>
| '[length](' expresion ')' <m_mlength>
| '[toUpper](' expresion ')' <m_mtoUpper>
@@ -313,6 +315,7 @@
, [m_mstring] = "[string]"
, [m_mstring2] = "[string]"
, [m_mstarts_with] = "[startsWith]"
+ , [m_starts_with] = "startsWith"
, [m_mends_with] = "[endsWith]"
, [m_mlength] = "[length]"
, [m_mtoUpper] = "[toUpper]"
@@ -503,6 +506,10 @@
milprintf ("})");
break;
+ case m_break:
+ milprintf ("break");
+ break;
+
/* statement : 'var' Variable */
case m_declare:
milprintf ("var ");
@@ -810,6 +817,8 @@
case m_mstring:
/* expression : '[startsWith](' exp ',' exp)' */
case m_mstarts_with:
+ /* expression : 'startsWith(' exp ',' exp)' */
+ case m_starts_with:
/* expression : '[endsWith](' exp ',' exp)' */
case m_mends_with:
/* expression : '[pcre_match](' exp ',' exp)' */
U mil.c
Index: mil.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/mil.c,v
retrieving revision 1.66.2.1
retrieving revision 1.66.2.2
diff -u -d -r1.66.2.1 -r1.66.2.2
--- mil.c 5 Jun 2008 09:45:41 -0000 1.66.2.1
+++ mil.c 5 Jun 2008 16:29:45 -0000 1.66.2.2
@@ -441,6 +441,15 @@
}
/**
+ * MIL break statement
+ */
+PFmil_t *
+PFmil_break ()
+{
+ return leaf (m_break);
+}
+
+/**
* Construct a combined variable declaration and its assignment.
* (Declare variable @a v and assign result of @a e to it.)
*
@@ -1363,6 +1372,13 @@
return wire3 (m_mstring2, a, b, c);
}
+/** StartsWith() function `[startsWith](a,b)' */
+PFmil_t *
+PFmil_starts_with (const PFmil_t *a, const PFmil_t *b)
+{
+ return wire2 (m_starts_with, a, b);
+}
+
/** Multiplexed startsWith() function `[startsWith](a,b)' */
PFmil_t *
PFmil_mstarts_with (const PFmil_t *a, const PFmil_t *b)
U milgen.brg
Index: milgen.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milgen.brg,v
retrieving revision 1.157.2.7
retrieving revision 1.157.2.8
diff -u -d -r1.157.2.7 -r1.157.2.8
--- milgen.brg 4 Jun 2008 23:44:27 -0000 1.157.2.7
+++ milgen.brg 5 Jun 2008 16:29:46 -0000 1.157.2.8
@@ -2481,7 +2481,7 @@
{
PFalg_simple_type_t ty;
PFmil_create_ws_t create;
- mvar_t *err, *time;
+ mvar_t *err, *time, *try;
PFalg_att_t pa_item = p->sem.serialize.item;
PFmil_t *oldmilprog, *bodymilprog;
@@ -2492,19 +2492,27 @@
milprog = nop ();
/* decide which type of new_ws should invoke */
- if (aat_update & type_of (L(p), pa_item))
- create = CREATE_UPDATE_WS;
- /* FIXME: there is a second case when it is a retry of update
- * we dont deal with this case right now because there is no loop
- */
- else if (aat_docmgmt & type_of (L(p), pa_item))
- create = CREATE_DOCMGM_WS;
- else
- create = CREATE_READ_ONLY_WS;
+ if (aat_update & type_of (L(p), pa_item)) {
+ try = new_var(1);
+ execute (
+ comment ("volatile variable environment "
+ "for an update query"),
+ assgn (var (PF_MIL_VAR_WS), new_ws (var (try->name))),
+ /* re-assign var(try) to be ready in case of a retry */
+ assgn (var (try->name),
+ add (var (try->name),
+ lit_int(1))));
+ } else {
+ if (aat_docmgmt & type_of (L(p), pa_item))
+ create = CREATE_DOCMGM_WS;
+ else
+ create = CREATE_READ_ONLY_WS;
+
+ execute (
+ comment ("volatile variable environment"),
+ assgn (var (PF_MIL_VAR_WS), new_ws (lit_int (create))));
+ }
- execute (
- comment ("volatile variable environment"),
- assgn (var (PF_MIL_VAR_WS), new_ws (lit_int (create))));
reduce (kids[0], nts[0]);
/* add timing information */
@@ -2930,9 +2938,6 @@
var (docmgmt->name)))))));
#ifdef HAVE_PFTIJAH
- /* INCOMPLETE, when the print is removed it is optimized out */
- /* added m_tj_docmgmt_tape to the non removable expressions */
- /* in mil_dce() but now the system crashed with a fatal() */
execute (
tj_docmgmt_tape (
var(PF_MIL_TIJAH_FTI_TAPE),
@@ -3436,14 +3441,40 @@
err = new_var (1);
- execute (
- catch_ (var (err->name), bodymilprog),
- if_ (not (isnil (var (PF_MIL_VAR_WS))),
- destroy_ws (var (PF_MIL_VAR_WS)),
- nop ()),
- if_ (not (isnil (var (err->name))),
- error (var (err->name)),
- nop ()));
+ /* update queries should loop around until they succeed */
+ if (aat_update & type_of (L(p), pa_item)) {
+
+ execute (
+ assgn (var (try->name), lit_int (CREATE_UPDATE_WS)),
+ assgn (var (err->name),
+ lit_str ("!ERROR: conflicting update")),
+ while_ (and (le (var (try->name), lit_int(3)),
+ not (isnil (var (err->name)))),
+ seq (if_ (not (starts_with (
+ var (err->name),
+ lit_str ("!ERROR: conflicting "
+ "update"))),
+ break_(),
+ nop()),
+ catch_ (var (err->name), bodymilprog),
+ if_ (not (isnil (var (PF_MIL_VAR_WS))),
+ destroy_ws (var (PF_MIL_VAR_WS)),
+ nop ()))),
+ if_ (not (isnil (var (err->name))),
+ error (var (err->name)),
+ nop ()));
+
+ unpin (try, 1);
+ } else {
+ execute (
+ catch_ (var (err->name), bodymilprog),
+ if_ (not (isnil (var (PF_MIL_VAR_WS))),
+ destroy_ws (var (PF_MIL_VAR_WS)),
+ nop ()),
+ if_ (not (isnil (var (err->name))),
+ error (var (err->name)),
+ nop ()));
+ }
unpin (err, 1);
} break; /* fold) */
U mil_dce.c
Index: mil_dce.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/mil_dce.c,v
retrieving revision 1.21
retrieving revision 1.21.2.1
diff -u -d -r1.21 -r1.21.2.1
--- mil_dce.c 24 Apr 2008 15:11:12 -0000 1.21
+++ mil_dce.c 5 Jun 2008 16:29:46 -0000 1.21.2.1
@@ -440,6 +440,7 @@
case m_destroy_ws:
case m_error:
case m_print:
+ case m_break:
case m_update_tape:
case m_docmgmt_tape:
#ifdef HAVE_PFTIJAH
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins