Changeset: d4d4afd86c86 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d4d4afd86c86 Modified Files: sql/backends/monet5/rel_bin.c sql/backends/monet5/rel_bin.h sql/backends/monet5/sql_execute.c sql/backends/monet5/sql_gencode.c sql/backends/monet5/sql_statement.c Branch: pushcands Log Message:
Be more restrictive to stmt_affected_rows generation. More fixes for table statements diffs (137 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 @@ -6211,7 +6211,7 @@ rel_bin(backend *be, sql_rel *rel) } rel_bin_stmt * -output_rel_bin(backend *be, sql_rel *rel) +output_rel_bin(backend *be, sql_rel *rel, int top) { mvc *sql = be->mvc; list *refs = sa_list(sql->sa); @@ -6228,9 +6228,10 @@ output_rel_bin(backend *be, sql_rel *rel if (sqltype == Q_SCHEMA) sql->type = sqltype; /* reset */ - if (!is_ddl(rel->op) && sql->type == Q_TABLE && stmt_output(be, s) < 0) + if (!is_ddl(rel->op) && sql->type == Q_TABLE && stmt_output(be, s) < 0) { return NULL; - else if ((!is_ddl(rel->op) && sqltype == Q_UPDATE) || be->cur_append) { + } else if (top && (!is_ddl(rel->op) || rel->flag == ddl_list) && (sqltype == Q_UPDATE || be->cur_append)) { + /* only call stmt_affected_rows outside functions and ddl, however if the ddl is a list, it might be called. eg. merge statements */ if (be->cur_append) { /* finish the output bat */ stmt *last = s->cols->t->data; last->nr = be->cur_append; diff --git a/sql/backends/monet5/rel_bin.h b/sql/backends/monet5/rel_bin.h --- a/sql/backends/monet5/rel_bin.h +++ b/sql/backends/monet5/rel_bin.h @@ -13,6 +13,6 @@ #include "sql_statement.h" #include "mal_backend.h" -extern rel_bin_stmt *output_rel_bin(backend *be, sql_rel *rel); +extern rel_bin_stmt *output_rel_bin(backend *be, sql_rel *rel, int top); #endif /*_REL_BIN_H_*/ diff --git a/sql/backends/monet5/sql_execute.c b/sql/backends/monet5/sql_execute.c --- a/sql/backends/monet5/sql_execute.c +++ b/sql/backends/monet5/sql_execute.c @@ -767,7 +767,7 @@ RAstatement(Client c, MalBlkPtr mb, MalS /* generate MAL code, ignoring any code generation error */ setVarType(c->curprg->def, 0, 0); - if (backend_dumpstmt(b, c->curprg->def, rel, 1, 1, NULL) < 0) { + if (backend_dumpstmt(b, c->curprg->def, rel, 0, 1, NULL) < 0) { msg = createException(SQL,"RAstatement","Program contains errors"); // TODO: use macro definition. } else { SQLaddQueryToCache(c); diff --git a/sql/backends/monet5/sql_gencode.c b/sql/backends/monet5/sql_gencode.c --- a/sql/backends/monet5/sql_gencode.c +++ b/sql/backends/monet5/sql_gencode.c @@ -697,7 +697,7 @@ monet5_create_relational_function(mvc *m * by using the SQLstatment. */ static rel_bin_stmt * -sql_relation2stmt(backend *be, sql_rel *r) +sql_relation2stmt(backend *be, sql_rel *r, int top) { mvc *c = be->mvc; rel_bin_stmt *s = NULL; @@ -709,7 +709,7 @@ sql_relation2stmt(backend *be, sql_rel * if (c->emode == m_plan) { rel_print(c, r, 0); } else { - s = output_rel_bin(be, r); + s = output_rel_bin(be, r, top); } } return s; @@ -760,7 +760,7 @@ backend_dumpstmt(backend *be, MalBlkPtr } be->mvc_var = getDestVar(q); be->mb = mb; - if (!sql_relation2stmt(be, r)) { + if (!sql_relation2stmt(be, r, top)) { if (querylog) (void) pushInt(mb, querylog, mb->stop); return (be->mvc->errstr[0] == '\0') ? 0 : -1; @@ -860,7 +860,7 @@ backend_dumpproc(backend *be, Client c, } } - if ((res = backend_dumpstmt(be, mb, r, 1, 1, be->q ? be->q->f->query : NULL)) < 0) + if ((res = backend_dumpstmt(be, mb, r, m->emode == m_prepare, 1, be->q ? be->q->f->query : NULL)) < 0) goto cleanup; if (cq) { diff --git a/sql/backends/monet5/sql_statement.c b/sql/backends/monet5/sql_statement.c --- a/sql/backends/monet5/sql_statement.c +++ b/sql/backends/monet5/sql_statement.c @@ -506,6 +506,7 @@ stmt_table(backend *be, rel_bin_stmt *re if (s == NULL) return NULL; + s->nr = ((stmt*)relst->cols->h->data)->nr; s->op4.relstval = relst; s->flag = temp; s->nrcols = relst->nrcols; @@ -3038,6 +3039,9 @@ tail_set_type(stmt *st, sql_subtype *t) case st_list: st = st->op4.lval->h->data; continue; + case st_table: + st = st->op4.relstval->cols->h->data; + continue; case st_join: case st_join2: case st_joinN: @@ -3683,6 +3687,9 @@ tail_type(stmt *st) case st_order: st = st->op1; continue; + case st_table: + st = st->op4.relstval->cols->h->data; + continue; case st_list: st = st->op4.lval->h->data; continue; @@ -3733,8 +3740,6 @@ tail_type(stmt *st) /* fall through */ case st_exception: return NULL; - case st_table: - return sql_bind_localtype("bat"); default: assert(0); return NULL; @@ -3852,7 +3857,8 @@ const char * if (sa) return sa_strdup(sa, "single_value"); return "single_value"; - + case st_table: + return column_name(sa, st->op4.relstval->cols->h->data); case st_list: if (list_length(st->op4.lval)) return column_name(sa, st->op4.lval->h->data); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list