Changeset: e58d856a620a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e58d856a620a
Modified Files:
        monetdb5/mal/mal_session.c
        monetdb5/modules/mal/wlcr.c
        sql/backends/monet5/Makefile.ag
        sql/backends/monet5/sql_wlcr.c
        sql/scripts/60_wlcr.sql
Branch: wlcr
Log Message:

Save the state before patching MAL parser


diffs (176 lines):

diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c
--- a/monetdb5/mal/mal_session.c
+++ b/monetdb5/mal/mal_session.c
@@ -572,8 +572,8 @@ MALparser(Client c)
        c->yycur = 0;
 
        /* check for unfinished blocks */
-       if (c->blkmode)
-               return MAL_SUCCEED;
+       //if (c->blkmode)
+               //return MAL_SUCCEED;
        /* empty files should be skipped as well */
        if (c->curprg->def->stop == 1)
                return MAL_SUCCEED;
@@ -618,8 +618,8 @@ MALengine(Client c)
        MalBlkRecord oldstate = *c->curprg->def;
        oldstate.stop = 0;
 
-       if (c->blkmode)
-               return MAL_SUCCEED;
+       //if (c->blkmode)
+               //return MAL_SUCCEED;
        prg = c->curprg;
        if (prg == NULL)
                throw(SYNTAX, "mal.engine", SYNTAX_SIGNATURE);
diff --git a/monetdb5/modules/mal/wlcr.c b/monetdb5/modules/mal/wlcr.c
--- a/monetdb5/modules/mal/wlcr.c
+++ b/monetdb5/modules/mal/wlcr.c
@@ -117,7 +117,7 @@ WLCRmaster(Client cntxt, MalBlkPtr mb, M
        if( fscanf(fd,"%d %d", &wlcr_batch, &wlcr_threshold) != 3)
                fprintf(fd,"0 %d\n", wlcr_threshold);
        fclose(fd);
-       mnstr_printf(cntxt->fdout,"#master wlcr_batch %d\n",wlcr_batch, 
wlcr_threshold);
+       mnstr_printf(cntxt->fdout,"#master wlcr_batch %d threshold 
%d\n",wlcr_batch, wlcr_threshold);
        return MAL_SUCCEED;
 }
 
diff --git a/sql/backends/monet5/Makefile.ag b/sql/backends/monet5/Makefile.ag
--- a/sql/backends/monet5/Makefile.ag
+++ b/sql/backends/monet5/Makefile.ag
@@ -64,7 +64,7 @@ headers_mal = {
        HEADERS = mal
        DIR = libdir/monetdb5
        SOURCES = sql_aggr_bte.mal  sql_aggr_flt.mal sql_aggr_dbl.mal  
sql_aggr_int.mal  sql_aggr_lng.mal \
-               sql_aggr_sht.mal  sql_decimal.mal  sql_inspect.mal \
+               sql_aggr_sht.mal  sql_decimal.mal  sql_inspect.mal sql_wlcr.mal\
                sql_rank.mal sqlcatalog.mal sql_transaction.mal  sql.mal
 }
 
@@ -91,7 +91,7 @@ headers_autoload_hge = {
 EXTRA_DIST = 40_sql.mal \
        41_sql_hge.mal sql_hge.mal sql_aggr_hge.mal sql_decimal_hge.mal \
        sql_aggr_bte.mal  sql_aggr_flt.mal  sql_aggr_int.mal  sql_aggr_lng.mal \
-       sql_aggr_sht.mal  sql_decimal.mal  sql_inspect.mal \
+       sql_aggr_sht.mal  sql_decimal.mal  sql_inspect.mal sql_wlcr.mal \
        sql_rank.mal sqlcatalog.mal sql_transaction.mal  sql.mal 
 
 EXTRA_DIST_DIR = Tests
diff --git a/sql/backends/monet5/sql_wlcr.c b/sql/backends/monet5/sql_wlcr.c
--- a/sql/backends/monet5/sql_wlcr.c
+++ b/sql/backends/monet5/sql_wlcr.c
@@ -6,6 +6,17 @@
  * Copyright 1997 - July 2008 CWI, August 2008 - 2017 MonetDB B.V.
  */
 
+/*
+ * A master can be replicated by taking a binary copy of the 'bat' directory.
+ * This should be done under control of the program monetdb, e.g.
+ * monetdb replica <masterlocation> <dbname>+
+ * 
+ * After restart of a mserver against the newly created image,
+ * the log files from the master are processed.
+ * Alternatively you start with an empty database.
+ *
+ * Since the wlcr files can be stored anywhere, the full path should be given.
+ */
 #include "monetdb_config.h"
 #include "sql.h"
 #include "wlcr.h"
@@ -13,23 +24,38 @@
 
 static str wlcr_master;
 static int wlcr_replaythreshold;
+static int wlcr_replaybatch;
 
 static str
 WLCRinit(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
-    int i = 1;
+    int i = 1, j,k,l;
+       char path[PATHLENGTH];
+       FILE *fd;
 
        (void) cntxt;
+       (void) k;
+       (void) l;
 
     wlcr_master = GDKgetenv("gdk_master");
     if (i< pci->argc+1 && getArgType(mb, pci, i) == TYPE_str){
         wlcr_master =  *getArgReference_str(stk,pci,i);
-        wlcr_master = GDKfilepath(0,wlcr_master,"batch",0);
         i++;
     }
        if( wlcr_master == NULL){
                throw(SQL,"wlcr.init","Can not access the wlcr directory");
        }
+       snprintf(path,PATHLENGTH,"%s%cwlcr", wlcr_master, DIR_SEP);
+       mnstr_printf(cntxt->fdout,"#Testing '%s'\n", path);
+       fd = fopen(path,"r");
+       if( fd == NULL){
+               throw(SQL,"wlcr.init","Can not access '%s'\n",path);
+       }
+       if( fscanf(fd,"%d %d %d", &j,&k,&l) != 3){
+               throw(SQL,"wlcr.init","'%s' does not have proper number of 
arguments\n",path);
+       }
+       wlcr_replaybatch = j;
+
     if ( i < pci->argc+1 && getArgType(mb, pci, i) == TYPE_int){
         wlcr_replaythreshold = *getArgReference_int(stk,pci,i);
        }
@@ -39,16 +65,42 @@ WLCRinit(Client cntxt, MalBlkPtr mb, Mal
 str
 WLCRreplay(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {      str msg;
+       int i;
+       char path[PATHLENGTH];
+       stream *fd;
+
        msg = WLCRinit(cntxt, mb, stk, pci);
        mnstr_printf(cntxt->fdout,"#Ready to start the replay against '%s' 
threshold %d", wlcr_master, wlcr_replaythreshold);
+
+       for( i= 0; i < wlcr_replaybatch; i++){
+               snprintf(path,PATHLENGTH,"%s%cwlcr_%06d", wlcr_master, 
DIR_SEP,i);
+               fd= open_rstream(path);
+               if( fd == NULL){
+                       throw(SQL,"wlcr.replay","'%s' can not be accessed 
\n",path);
+               }
+               close_stream(fd);
+       }
        return msg;
 }
 
 str
 WLCRsynchronize(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {      str msg;
+       int i;
+       char path[PATHLENGTH];
+       stream *fd;
+
        msg = WLCRinit(cntxt, mb, stk, pci);
        mnstr_printf(cntxt->fdout,"#Ready to start the synchronization against 
'%s' threshold %d", wlcr_master, wlcr_replaythreshold);
+
+       for( i= 0; i < wlcr_replaybatch; i++){
+               snprintf(path,PATHLENGTH,"%s%cwlcr_%06d", wlcr_master, 
DIR_SEP,i);
+               fd= open_rstream(path);
+               if( fd == NULL){
+                       throw(SQL,"wlcr.synchronize","'%s' can not be accessed 
\n",path);
+               }
+               close_stream(fd);
+       }
        return msg;
 }
 
diff --git a/sql/scripts/60_wlcr.sql b/sql/scripts/60_wlcr.sql
--- a/sql/scripts/60_wlcr.sql
+++ b/sql/scripts/60_wlcr.sql
@@ -32,6 +32,9 @@ external name wlcr.replay;
 create procedure wlcr.replay(path string, threshold int)
 external name wlcr.replay;
 
+create procedure wlcr.synchronize(path string)
+external name wlcr.synchronize;
+
 create procedure wlcr.synchronize()
 external name wlcr.synchronize;
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to