Changeset: f37e6abcd44c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f37e6abcd44c
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_cat.c
sql/backends/monet5/sql_cquery.c
sql/include/sql_catalog.h
sql/server/rel_psm.c
sql/server/rel_select.c
sql/server/rel_semantic.c
sql/server/sql_mvc.h
sql/server/sql_parser.h
sql/server/sql_parser.y
sql/server/sql_scan.c
Branch: timetrails
Log Message:
Trying to add add START CONTINUE PROCEDURE name (args) statements but with no
luck :(
diffs (truncated from 514 to 300 lines):
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -17,6 +17,7 @@
#include "rel_updates.h"
#include "rel_optimizer.h"
#include "sql_env.h"
+#include "sql_cquery.h"
#define OUTER_ZERO 64
@@ -168,7 +169,7 @@ static stmt *column(backend *be, stmt *v
return val;
}
-static stmt *Column(backend *be, stmt *val )
+static stmt *RelColumn(backend *be, stmt *val )
{
if (val->nrcols == 0)
val = const_column(be, val);
@@ -453,7 +454,22 @@ exp_bin(backend *be, sql_exp *e, stmt *l
if (f->func->rel)
s = stmt_func(be, stmt_list(be, l), sa_strdup(sql->sa,
f->func->base.name), f->func->rel, (f->func->type == F_UNION));
else
- s = stmt_Nop(be, stmt_list(be, l), e->f);
+ s = stmt_Nop(be, stmt_list(be, l), e->f);
+
+ if (f->func->type == F_CONTINUOUS_PROCEDURE) {
+ char *petrinetResponse;
+ char *sname = f->func->s->base.name;
+ char *fname = f->func->base.name;
+ if (!CQlocate(sname, fname)) { //if the continuous
procedure is not registered in the catalog then we register it
+ petrinetResponse =
CQregisterInternal(MCgetClient(sql->clientid), sname, fname);
+ }
+ if (!petrinetResponse) {
+ petrinetResponse = CQresumeInternal(sname,
fname);
+ }
+ if (petrinetResponse) {
+ return sql_error(sql, 02, "M0M27!START
CONTINUOUS PROCEDURE internal error: %s", petrinetResponse);
+ }
+ }
} break;
case e_aggr: {
list *attr = e->l;
@@ -1851,7 +1867,7 @@ rel2bin_join(backend *be, sql_rel *rel,
/* as append isn't save, we append to a new copy */
if (rel->op == op_left || rel->op == op_full || rel->op ==
op_right)
- s = Column(be, s);
+ s = RelColumn(be, s);
if (rel->op == op_left || rel->op == op_full)
s = stmt_append(be, s, stmt_project(be, ld, c));
if (rel->op == op_right || rel->op == op_full)
@@ -1868,7 +1884,7 @@ rel2bin_join(backend *be, sql_rel *rel,
/* as append isn't save, we append to a new copy */
if (rel->op == op_left || rel->op == op_full || rel->op ==
op_right)
- s = Column(be, s);
+ s = RelColumn(be, s);
if (rel->op == op_left || rel->op == op_full)
s = stmt_append(be, s, stmt_const(be, ld,
(c->flag&OUTER_ZERO)?stmt_atom_lng(be, 0):stmt_atom(be, atom_general(sql->sa,
tail_type(c), NULL))));
if (rel->op == op_right || rel->op == op_full)
@@ -2119,7 +2135,7 @@ rel2bin_union(backend *be, sql_rel *rel,
const char *nme = column_name(sql->sa, c1);
stmt *s;
- s = stmt_append(be, Column(be, c1), c2);
+ s = stmt_append(be, RelColumn(be, c1), c2);
s = stmt_alias(be, s, rnme, nme);
list_append(l, s);
}
diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c
--- a/sql/backends/monet5/sql_cat.c
+++ b/sql/backends/monet5/sql_cat.c
@@ -726,17 +726,16 @@ static str
continuous_procedure(mvc *sql, char *sname, char *cpname, int fid, int action)
{
sql_schema *s = NULL;
- char *F;
- Client cntxt;
+ char *F = NULL;
str petrinetResponse = MAL_SUCCEED;
switch (action) {
- case START_CONTINUOUS_PROCEDURE:
- F = "START CONTINUOUS PROCEDURE";
- break;
case INTERRUPT_CONTINUOUS_PROCEDURE:
F = "INTERRUPT CONTINUOUS PROCEDURE";
break;
+ case CONTINUE_CONTINUOUS_PROCEDURE:
+ F = "CONTINUE CONTINUOUS PROCEDURE";
+ break;
case HALT_CONTINUOUS_PROCEDURE:
F = "HALT CONTINUOUS PROCEDURE";
break;
@@ -754,19 +753,12 @@ continuous_procedure(mvc *sql, char *sna
return sql_message("3F000!%s: access denied for
%s to schema ;'%s'", F, stack_get_string(sql, "current_user"), s->base.name);
}
switch (action) {
- case START_CONTINUOUS_PROCEDURE: {
- if(!CQlocate(sname, cpname)) {
//if the continuous procedure is not registered in the catalog then we register
it
- cntxt =
MCgetClient(sql->clientid);
- petrinetResponse =
CQregisterInternal(cntxt, sname, cpname);
- }
- if(!petrinetResponse) {
- petrinetResponse =
CQresumeInternal(sname, cpname);
- }
- }
- break;
case INTERRUPT_CONTINUOUS_PROCEDURE:
petrinetResponse =
CQpauseInternal(sname, cpname);
break;
+ case CONTINUE_CONTINUOUS_PROCEDURE:
+ petrinetResponse =
CQresumeInternal(sname, cpname);
+ break;
case HALT_CONTINUOUS_PROCEDURE:
petrinetResponse =
CQderegisterInternal(sname, cpname);
break;
diff --git a/sql/backends/monet5/sql_cquery.c b/sql/backends/monet5/sql_cquery.c
--- a/sql/backends/monet5/sql_cquery.c
+++ b/sql/backends/monet5/sql_cquery.c
@@ -441,7 +441,7 @@ CQregisterInternal(Client cntxt, str mod
sig = getInstrPtr(mb,0);
i = CQlocate(getModuleId(sig), getFunctionId(sig));
if (i != pnettop)
- throw(MAL,"cquery.register","Duplicate registration of
continuous procedure");
+ throw(MAL,"cquery.register","Duplicate registration of
continuous procedure %s.%s", modnme, fcnnme);
#ifdef DEBUG_CQUERY
fprintf(stderr, "#cquery register %s.%s\n",
getModuleId(sig),getFunctionId(sig));
@@ -466,7 +466,7 @@ CQregisterInternal(Client cntxt, str mod
MT_lock_set(&ttrLock);
if( CQlocate(getModuleId(sig), getFunctionId(sig)) != pnettop){
freeSymbol(s);
- throw(MAL,"cquery.register","Duplicate registration of
continuous procedure");
+ throw(MAL,"cquery.register","Duplicate registration of
continuous procedure %s.%s", modnme, fcnnme);
}
pnet[pnettop].mod = GDKstrdup(modnme);
pnet[pnettop].fcn = GDKstrdup(fcnnme);
diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h
--- a/sql/include/sql_catalog.h
+++ b/sql/include/sql_catalog.h
@@ -310,8 +310,10 @@ typedef struct sql_arg {
#define LANG_EXT(l) (l>FUNC_LANG_SQL)
#define START_CONTINUOUS_PROCEDURE 1 /* this might stay here I think... */
-#define INTERRUPT_CONTINUOUS_PROCEDURE 2
-#define HALT_CONTINUOUS_PROCEDURE 3
+#define RESTART_CONTINUOUS_PROCEDURE 2 /* currently not using it */
+#define INTERRUPT_CONTINUOUS_PROCEDURE 3
+#define CONTINUE_CONTINUOUS_PROCEDURE 4
+#define HALT_CONTINUOUS_PROCEDURE 5
typedef struct sql_func {
sql_base base;
diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c
--- a/sql/server/rel_psm.c
+++ b/sql/server/rel_psm.c
@@ -149,11 +149,12 @@ psm_set_exp(mvc *sql, dnode *n)
}
static sql_exp*
-rel_psm_call(mvc * sql, symbol *se)
+rel_psm_call(mvc * sql, int token, symbol *se)
{
sql_subtype *t;
sql_exp *res = NULL;
- exp_kind ek = {type_value, card_none, FALSE};
+ int card = (token == SQL_START_CONTINUOUS_PROCEDURE) ?
card_continuous_procedure : card_none;
+ exp_kind ek = {type_value, card, FALSE};
sql_rel *rel = NULL;
res = rel_value_exp(sql, &rel, se, sql_sel, ek);
@@ -616,7 +617,7 @@ sequential_block (mvc *sql, sql_subtype
reslist = rel_psm_case(sql, restype, restypelist,
s->data.lval->h, is_func);
break;
case SQL_CALL:
- res = rel_psm_call(sql, s->data.sym);
+ res = rel_psm_call(sql, s->token, s->data.sym);
break;
case SQL_RETURN:
/*If it is not a function it cannot have a return
statement*/
@@ -1455,14 +1456,14 @@ rel_change_continuous_procedure(mvc *sql
int action;
switch (token) {
- case SQL_START_CONTINUOUS_PROCEDURE:
- F = "START CONTINUOUS PROCEDURE";
- action = START_CONTINUOUS_PROCEDURE;
- break;
case SQL_INTERRUPT_CONTINUOUS_PROCEDURE:
F = "INTERRUPT CONTINUOUS PROCEDURE";
action = INTERRUPT_CONTINUOUS_PROCEDURE;
break;
+ case SQL_CONTINUE_CONTINUOUS_PROCEDURE:
+ F = "CONTINUE CONTINUOUS PROCEDURE";
+ action = CONTINUE_CONTINUOUS_PROCEDURE;
+ break;
case SQL_HALT_CONTINUOUS_PROCEDURE:
F = "HALT CONTINUOUS PROCEDURE";
action = HALT_CONTINUOUS_PROCEDURE;
@@ -1545,7 +1546,8 @@ rel_psm(mvc *sql, symbol *s)
sql->type = Q_SCHEMA;
break;
case SQL_CALL:
- ret = rel_psm_stmt(sql->sa, rel_psm_call(sql, s->data.sym));
+ case SQL_START_CONTINUOUS_PROCEDURE:
+ ret = rel_psm_stmt(sql->sa, rel_psm_call(sql, s->token,
s->data.sym));
sql->type = Q_UPDATE;
break;
case SQL_CREATE_TABLE_LOADER:
@@ -1582,8 +1584,9 @@ rel_psm(mvc *sql, symbol *s)
ret = psm_analyze(sql, "analyze", l->h->data.lval /* qualified
table name */, l->h->next->data.lval /* opt list of column */,
l->h->next->next->data.sym /* opt_sample_size */,
l->h->next->next->next->data.i_val);
sql->type = Q_UPDATE;
} break;
- case SQL_START_CONTINUOUS_PROCEDURE:
+
case SQL_INTERRUPT_CONTINUOUS_PROCEDURE:
+ case SQL_CONTINUE_CONTINUOUS_PROCEDURE:
case SQL_HALT_CONTINUOUS_PROCEDURE: {
dlist *l = s->data.lval;
dlist *qname = l->h->data.lval;
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -26,7 +26,7 @@
#endif
#define VALUE_FUNC(f) (f->func->type == F_FUNC || f->func->type == F_FILT)
-#define check_card(card,f) ((card == card_none && !f->res) ||
(CARD_VALUE(card) && f->res && VALUE_FUNC(f)) || card == card_loader || (card
== card_relation && f->func->type == F_UNION))
+#define check_card(card,f) ((card == card_none && !f->res) ||
(CARD_VALUE(card) && f->res && VALUE_FUNC(f)) || card == card_loader || card ==
card_continuous_procedure || (card == card_relation && f->func->type ==
F_UNION))
static void
rel_setsubquery(sql_rel*r)
@@ -693,8 +693,24 @@ static sql_exp *
rel_op_(mvc *sql, sql_schema *s, char *fname, exp_kind ek)
{
sql_subfunc *f = NULL;
- int type = (ek.card == card_loader)?F_LOADER:((ek.card ==
card_none)?F_PROC:
- ((ek.card == card_relation)?F_UNION:F_FUNC));
+ int type;
+
+ switch (ek.card) {
+ case card_loader:
+ type = F_LOADER;
+ break;
+ case card_none:
+ type = F_PROC;
+ break;
+ case card_relation:
+ type = F_UNION;
+ break;
+ case card_continuous_procedure:
+ type = F_CONTINUOUS_PROCEDURE;
+ break;
+ default:
+ type = F_FUNC;
+ }
f = sql_bind_func(sql->sa, s, fname, NULL, NULL, type);
if (f && check_card(ek.card, f)) {
@@ -1786,10 +1802,25 @@ static sql_exp*
_rel_nop( mvc *sql, sql_schema *s, char *fname, list *tl, list *exps,
sql_subtype *obj_type, int nr_args, exp_kind ek)
{
sql_subfunc *f = NULL;
- int table_func = (ek.card == card_relation);
- int type = (ek.card == card_loader)?F_LOADER:((ek.card ==
card_none)?F_PROC:
- ((ek.card == card_relation)?F_UNION:F_FUNC));
- int filt = (type == F_FUNC)?F_FILT:type;
+ int table_func = (ek.card == card_relation), type, filt;
+
+ switch (ek.card) {
+ case card_loader:
+ type = F_LOADER;
+ break;
+ case card_none:
+ type = F_PROC;
+ break;
+ case card_relation:
+ type = F_UNION;
+ break;
+ case card_continuous_procedure:
+ type = F_CONTINUOUS_PROCEDURE;
+ break;
+ default:
+ type = F_FUNC;
+ }
+ filt = (type == F_FUNC)?F_FILT:type;
f = bind_func_(sql, s, fname, tl, type);
if (f) {
@@ -2855,8 +2886,24 @@ rel_unop_(mvc *sql, sql_exp *e, sql_sche
{
sql_subfunc *f = NULL;
sql_subtype *t = NULL;
- int type = (card == card_loader)?F_LOADER:((card == card_none)?F_PROC:
- ((card == card_relation)?F_UNION:F_FUNC));
+ int type;
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list