Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv22178/src/backends/monet5

Modified Files:
        sql_optimizer.mx sql_scenario.mx 
Log Message:
fixed test output

we use the inline and empty set optimizers again.

For the empty set optimzer we had to add some row counts for tables/columns
which are to be updated in the rest of the plan (ie also detect special
sql.append functions)



Index: sql_scenario.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_scenario.mx,v
retrieving revision 1.254
retrieving revision 1.255
diff -u -d -r1.254 -r1.255
--- sql_scenario.mx     20 Mar 2007 07:14:58 -0000      1.254
+++ sql_scenario.mx     20 Mar 2007 18:29:09 -0000      1.255
@@ -344,9 +344,6 @@
                /* TODO reset global variables */
        }
 
-       c->yycur = 0;           /* make sure we don't reuse the used input */
-       c->fdin->eof = 1;       /* force prompt on first iteration */
-
        initSQLreferences();
        return MAL_SUCCEED;
 }

Index: sql_optimizer.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_optimizer.mx,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -d -r1.142 -r1.143
--- sql_optimizer.mx    20 Mar 2007 07:14:58 -0000      1.142
+++ sql_optimizer.mx    20 Mar 2007 18:29:09 -0000      1.143
@@ -267,8 +267,9 @@
 common term optimizer, because the first bind has a side-effect.
 @c
 typedef struct {
-       int idx,mode,bid;
+       int idx,mode;
        str schema,table, column;
+       InstrPtr p;
 } SQLbind;
 
 static void
@@ -279,7 +280,7 @@
        InstrPtr *rest= (InstrPtr*) alloca(sizeof(InstrPtr)*mb->stop);
        int n=1,rtop=0;
        SQLbind *bind= (SQLbind*) alloca(sizeof(SQLbind)*mb->stop/2);
-       int j,k=0, mode;
+       int j,k=0;
 
        for(i=1; i<mb->stop; i++){
                InstrPtr p = getInstrPtr(mb,i);
@@ -292,20 +293,41 @@
                        char *cname;
                        int not_null = 0;
                        BAT *b;
+                       lng rows = 0;
 
                        cname = p->argc>3? getVarConstant(mb, 
getArg(p,3)).val.sval:0 ;
-                       if(  f== bindRef){
-                               for(j=0; j<k; j++)
-                               if( strcmp(sname,bind[j].schema)==0 &&
-                                   strcmp(tname,bind[j].table)==0 &&
-                                       bind[j].column && 
strcmp(cname,bind[j].column)== 0
-                                ){
-                                       mode= getVarConstant(mb, 
getArg(p,4)).val.ival;
-                                       /* catch alias bindings */
-                                       if(     bind[j].mode == mode )
-                                               break;
+                       if (f == bindRef) {
+                               int mode = getVarConstant(mb, 
getArg(p,4)).val.ival;
+                               /* Mark to be updated columns */
+                               if (mode == INS || mode == UPD)
+                                       rows++;
+                               for(j=0; j<k; j++) {
+                                       if( strcmp(sname,bind[j].schema)==0 &&
+                                               strcmp(tname,bind[j].table)==0 
&&
+                                               bind[j].column && 
strcmp(cname,bind[j].column)==0) {
+                                               if (bind[j].mode == mode ||
+                                                  (bind[j].mode == RD_INS && 
mode == INS) ||
+                                                  (bind[j].mode == RD_UPD && 
mode == UPD) ||
+                                                  (bind[j].mode == INS && mode 
== RD_INS) ||
+                                                  (bind[j].mode == UPD && mode 
== RD_UPD) ){
+                                                       if (bind[j].mode != 
mode &&
+                                                               (mode == INS || 
mode == UPD)) {
+                                                               PropertySet ps;
+                                                               lng *rows;
+                                                               bind[j].mode = 
mode;
+                                                               
getArg(bind[j].p,4) = getArg(p,4);
+                                                               ps = 
getProps(mb,bind[j].idx);
+                                                               assert(ps);
+                                                               rows = 
getPropertyValue(ps,"rows"); 
+                                                               assert(rows);
+                                                               (*rows) ++;
+                                                       }
+                                                       break;
+                                               }
+                                       }
                                }
                                if( j== k){
+                                       bind[k].p = p;
                                        bind[k].idx= getArg(p,0);
                                        bind[k].schema = sname;
                                        bind[k].table = tname;
@@ -325,28 +347,26 @@
                        mb->stmt[n++] = p;
                        if( f == binddbatRef) {
                                b= mvc_bind_dbat(m, sname, tname,
-                               getVarConstant(mb, getArg(p,3)).val.ival);
+                                       getVarConstant(mb, 
getArg(p,3)).val.ival);
                        } else if( f == bindidxRef) {
                                b= mvc_bind_idxbat(m, sname, tname,
-                               getVarConstant(mb, getArg(p,3)).val.sval,
-                               getVarConstant(mb, getArg(p,4)).val.ival);
+                                       getVarConstant(mb, 
getArg(p,3)).val.sval,
+                                       getVarConstant(mb, 
getArg(p,4)).val.ival);
                        } else {
-                               char *cname =
-                                   getVarConstant(mb, getArg(p,3)).val.sval;
+                               char *cname = getVarConstant(mb, 
getArg(p,3)).val.sval;
                                sql_schema *s = mvc_bind_schema(m, sname);
                                sql_table *t = mvc_bind_table(m, s, tname);
                                sql_column *c = mvc_bind_column(m, t, cname);
 
                                b= mvc_bind(m, sname, tname, cname,
-                               getVarConstant(mb, getArg(p,4)).val.ival);
+                                       getVarConstant(mb, 
getArg(p,4)).val.ival);
                                not_null = c->null;
                        }       
                        if( b ) {
-                               lng rows = BATcount(b);
                                int k = getArg(p,0);
                                bit t = TRUE;
 
-                               bind[j].bid= b->batCacheid;
+                               rows += BATcount(b);
                                getVarConstant(mb, k).val.bval = b->batCacheid;
                                if (mb->var[k]->props == 0)
                                        mb->var[k]->props = newPropertySet();
@@ -357,6 +377,37 @@
                                BBPunfix(b->batCacheid);
                                actions++;
                        }
+               } else if (getModuleId(p) == sqlRef && 
+                               f == appendRef && p->argc == 6 ) {
+                       char *sname = getVarConstant(mb, getArg(p,1)).val.sval;
+                       char *tname = getVarConstant(mb, getArg(p,2)).val.sval;
+                       char *cname = getVarConstant(mb, getArg(p,3)).val.sval;
+                       int mode = getVarConstant(mb, getArg(p,4)).val.ival;
+                       for(j=0; j<k; j++) {
+                               if( strcmp(sname,bind[j].schema)==0 &&
+                                   strcmp(tname,bind[j].table)==0 &&
+                                   bind[j].column && 
strcmp(cname,bind[j].column)==0 &&
+                                   (bind[j].mode == mode ||
+                                   (bind[j].mode == RD_INS && mode == INS) ||
+                                   (bind[j].mode == RD_UPD && mode == UPD) ||
+                                   (bind[j].mode == INS && mode == RD_INS) ||
+                                   (bind[j].mode == UPD && mode == RD_UPD)) ){
+                                       if (bind[j].mode != mode) { 
+                                               PropertySet ps;
+                                               lng *rows;
+
+                                               bind[j].mode = mode;
+                                               getArg(bind[j].p,4) = 
getArg(p,4);
+                                               ps = getProps(mb,bind[j].idx);
+                                               assert(ps);
+                                               rows = 
getPropertyValue(ps,"rows"); 
+                                               assert(rows);
+                                               (*rows) ++;
+                                       }
+                                       break;
+                               }
+                       }
+                       rest[rtop++]= p;
                } else {
                        rest[rtop++]= p;
                }
@@ -374,7 +425,7 @@
        "inline,"
        "costModel,"
        "coercions,"
-       /*"emptySet,"  */
+       "emptySet," 
        /* "joinselect," */
        "accessmode,"
        "aliases,"


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to