Changeset: 27118ee8afe4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/27118ee8afe4 Modified Files: monetdb5/optimizer/opt_support.c sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_statement.c sql/backends/monet5/sql_statement.h sql/test/remote/Tests/partition_elim.test sql/test/remote/Tests/remote_info_missing.test Branch: balanced_union Log Message:
use mat.packIncrement to create multi unions diffs (194 lines): diff --git a/monetdb5/optimizer/opt_support.c b/monetdb5/optimizer/opt_support.c --- a/monetdb5/optimizer/opt_support.c +++ b/monetdb5/optimizer/opt_support.c @@ -264,6 +264,8 @@ isUpdateInstruction(InstrPtr p) && (getFunctionId(p) == appendRef || getFunctionId(p) == replaceRef || getFunctionId(p) == deleteRef)) return TRUE; + if (getModuleId(p) == matRef) + return TRUE; return FALSE; } 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 @@ -3877,7 +3877,7 @@ rel2bin_munion(backend *be, sql_rel *rel list *l, *rstmts; node *n, *m; stmt *rel_stmt = NULL, *sub; - int i, len = 0; + int i, len = 0, nr_unions = list_length((list*)rel->l); /* convert to stmt and store the munion operands in rstmts list */ rstmts = sa_list(sql->sa); @@ -3904,13 +3904,13 @@ rel2bin_munion(backend *be, sql_rel *rel const char *rnme = table_name(sql->sa, s); const char *nme = column_name(sql->sa, s); /* create a const column also from the first stmt */ - s = create_const_column(be, s); + s = stmt_pack(be, column(be, s), nr_unions); /* for every other rstmt */ for (m = rstmts->h->next; m; m = m->next) { stmt *t = list_fetch(((stmt*)m->data)->op4.lval, i); - if ( t == NULL) + if (t == NULL) return NULL; - s = stmt_append(be, s, t); + s = stmt_pack_add(be, s, column(be, t)); if (s == NULL) return NULL; } 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 @@ -3447,6 +3447,78 @@ stmt_append_bulk(backend *be, stmt *c, l } stmt * +stmt_pack(backend *be, stmt *c, int n) +{ + MalBlkPtr mb = be->mb; + InstrPtr q = NULL; + + if (c == NULL || c->nr < 0) + goto bailout; + q = newStmtArgs(mb, matRef, packIncrementRef, 3); + if (q == NULL) + goto bailout; + q = pushArgument(mb, q, c->nr); + q = pushInt(mb, q, n); + bool enabled = be->mvc->sa->eb.enabled; + be->mvc->sa->eb.enabled = false; + stmt *s = stmt_create(be->mvc->sa, st_append); + be->mvc->sa->eb.enabled = enabled; + if(!s) { + freeInstruction(q); + goto bailout; + } + s->op1 = c; + s->nrcols = c->nrcols; + s->key = c->key; + s->nr = getDestVar(q); + s->q = q; + pushInstruction(mb, q); + return s; + + bailout: + if (be->mvc->sa->eb.enabled) + eb_error(&be->mvc->sa->eb, be->mvc->errstr[0] ? be->mvc->errstr : mb->errors ? mb->errors : *GDKerrbuf ? GDKerrbuf : "out of memory", 1000); + return NULL; + +} + +stmt * +stmt_pack_add(backend *be, stmt *c, stmt *a) +{ + MalBlkPtr mb = be->mb; + InstrPtr q = NULL; + + if (c == NULL || a == NULL || c->nr < 0 || a->nr < 0) + goto bailout; + q = newStmtArgs(mb, matRef, packIncrementRef, 3); + if (q == NULL) + goto bailout; + q = pushArgument(mb, q, c->nr); + q = pushArgument(mb, q, a->nr); + bool enabled = be->mvc->sa->eb.enabled; + be->mvc->sa->eb.enabled = false; + stmt *s = stmt_create(be->mvc->sa, st_append); + be->mvc->sa->eb.enabled = enabled; + if(!s) { + freeInstruction(q); + goto bailout; + } + s->op1 = c; + s->op2 = a; + s->nrcols = c->nrcols; + s->key = c->key; + s->nr = getDestVar(q); + s->q = q; + pushInstruction(mb, q); + return s; + + bailout: + if (be->mvc->sa->eb.enabled) + eb_error(&be->mvc->sa->eb, be->mvc->errstr[0] ? be->mvc->errstr : mb->errors ? mb->errors : *GDKerrbuf ? GDKerrbuf : "out of memory", 1000); + return NULL; +} + +stmt * stmt_claim(backend *be, sql_table *t, stmt *cnt) { MalBlkPtr mb = be->mb; diff --git a/sql/backends/monet5/sql_statement.h b/sql/backends/monet5/sql_statement.h --- a/sql/backends/monet5/sql_statement.h +++ b/sql/backends/monet5/sql_statement.h @@ -174,6 +174,8 @@ extern stmt *stmt_append(backend *be, st extern stmt *stmt_append_bulk(backend *be, stmt *c, list *l); extern stmt *stmt_replace(backend *be, stmt *c, stmt *id, stmt *val); extern stmt *stmt_table_clear(backend *be, sql_table *t, int restart_sequences); +extern stmt *stmt_pack(backend *be, stmt *c, int nr); +extern stmt *stmt_pack_add(backend *be, stmt *c, stmt *values); extern stmt *stmt_export(backend *be, stmt *t, const char *sep, const char *rsep, const char *ssep, const char *null_string, int onclient, stmt *file); extern stmt *stmt_export_bin(backend *be, stmt *colstmt, bool byteswap, const char *filename, int on_client); diff --git a/sql/test/remote/Tests/partition_elim.test b/sql/test/remote/Tests/partition_elim.test --- a/sql/test/remote/Tests/partition_elim.test +++ b/sql/test/remote/Tests/partition_elim.test @@ -116,10 +116,6 @@ algebra.projection 6 algebra.select 3 -bat.append -4 -bat.new -2 bat.pack 5 language.dataflow @@ -127,7 +123,7 @@ 1 language.pass 6 mat.packIncrement -4 +8 querylog.define 1 sql.bind @@ -148,10 +144,6 @@ algebra.projection 6 algebra.select 3 -bat.append -4 -bat.new -2 bat.pack 5 language.dataflow @@ -159,7 +151,7 @@ 1 language.pass 6 mat.packIncrement -4 +8 querylog.define 1 sql.bind diff --git a/sql/test/remote/Tests/remote_info_missing.test b/sql/test/remote/Tests/remote_info_missing.test --- a/sql/test/remote/Tests/remote_info_missing.test +++ b/sql/test/remote/Tests/remote_info_missing.test @@ -5,8 +5,9 @@ statement ok delete from remote_user_info where table_id = (select id from sys._tables where name = 't1234') statement ok -drop table t1234; +drop table t1234 -query T -select name from sys._tables where name = 't1234'; +query T nosort +select name from sys._tables where name = 't1234' ---- + _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org