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

Modified Files:
        sql_bpm.mx 
Log Message:
Add some commands to:
        bind location of a fragment (I get the location id)
        set a location for a fragment ( I set and location id)
        add a location (I add a location to catalog and I get its id)

Note: To set a new location to a fragment:
        first you need to add the location and i
        then set the id returned to the fragement. 
I decide to do like this to avoid long MAL commands, so the code it is easy to 
read and debug ;)



Index: sql_bpm.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_bpm.mx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- sql_bpm.mx  11 Jan 2008 10:51:58 -0000      1.5
+++ sql_bpm.mx  19 Jan 2008 23:45:32 -0000      1.6
@@ -38,6 +38,20 @@
 address Cparts
 comment "Check if the number of partions is still valid";
 
+module distribution;
+
+command bind_host(sname:str, tname:str, cname:str, part:int):int
+address dist_bind_host_wrap
+comment "Bind location id for a partition fragment";
+
+command set_host(sname:str, tname:str, cname:str, part:int, host:int):int
+address dist_set_host_wrap
+comment "Set location id for a partition fragment";
+
+command add_host(host:str, por:int, dbname:str, user:str, passwd:str):int
+address dist_add_host_wrap
+comment "Add a location for a partition fragment";
+
 @h
 #ifndef _SQL_BPM_H_
 #define _SQL_BPM_H_
@@ -47,6 +61,9 @@
 sql5_export str mat_bind_idxbat_wrap(int *bid, str *sname, str *tname, str 
*cname, int *access, int *part);
 sql5_export str inc_parts_wrap(int *d, str *sname, str *tname);
 sql5_export str Cparts(int *d, str *sname, str *tname, str *cname, int 
*access, int *parts);
+sql5_export str dist_bind_host_wrap(int *host, str *sname, str *tname, str 
*cname, int *part);
+sql5_export str dist_set_host_wrap(int *bid, str *sname, str *tname, str 
*cname, int *part, int *host);
+sql5_export str dist_add_host_wrap(int *id, str *host, int *port, str *dbname, 
str *user, str *passwd);
 
 #endif /* _SQL_BPM_H_ */
 
@@ -221,3 +238,71 @@
        return MAL_SUCCEED;
 }
 
+static int
+dist_bind(mvc *m, char *sname, char *tname, char *cname, int part)
+{
+       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);
+       sql_bpm *p = c->data;
+
+       if (p->nr <= part) {
+               return 0;
+       } else {
+               return *(int *) p->parts[part].host;
+       }
+}
+
+
+str
+dist_bind_host_wrap(int *host, str *sname, str *tname, str *cname, int *part)
+{
+       mvc *m = NULL;
+       str msg = getContext(&m, NULL);
+
+       if (msg)
+               return msg;
+       if ((*host = dist_bind(m, *sname, *tname, *cname, *part)))
+               return MAL_SUCCEED;
+       throw(SQL, "dist.bind", "limitation in transaction scope");
+}
+
+static int
+dist_set(mvc *m, char *sname, char *tname, char *cname, int part, int host)
+{
+       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);
+       sql_bpm *p = c->data;
+
+       if (p->nr <= part) {
+               return 0;
+       } else {
+               
+               return bpm_set_part_location(p, part, host, NULL, 0, NULL, 
NULL, NULL);
+       }
+}
+
+str 
+dist_set_host_wrap(int *bid, str *sname, str *tname, str *cname, int *part, 
int *host)
+{
+       mvc *m = NULL;
+       str msg = getContext(&m, NULL);
+       
+       if (msg)
+               return msg;
+       if ((*bid = dist_set(m, *sname, *tname, *cname, *part, *host)))
+               return MAL_SUCCEED;
+       throw(SQL, "dist.set", "limitation in transaction scope");
+}
+
+str 
+dist_add_host_wrap(int *id, str *host, int *port, str *dbname, str *user, str 
*passwd)
+{
+       bpmHost bpmH = bpm_host_create(*host, *port, *dbname, *user, *passwd);
+       if (bpmH && (*id = *(int *) bpmH->host))
+               return MAL_SUCCEED;
+       throw(SQL, "dist.add", "limitation in transaction scope");
+
+}
+


-------------------------------------------------------------------------
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-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to