Update of /cvsroot/monetdb/sql/src/server
In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1625/src/server
Modified Files:
Tag: Feb2010
bin_optimizer.mx rel_subquery.mx sql_psm.mx sql_rel2bin.mx
sql_statement.mx
Log Message:
the select statements didn't get pushed through the diffs and unions anymore.
Reason we added lots of 'st_alias'es around statements during the development
of the relational version. These st_aliases are now handled correctly fixing
the push down.
Index: sql_rel2bin.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_rel2bin.mx,v
retrieving revision 1.144
retrieving revision 1.144.2.1
diff -u -d -r1.144 -r1.144.2.1
--- sql_rel2bin.mx 10 Jan 2010 15:33:35 -0000 1.144
+++ sql_rel2bin.mx 30 Jan 2010 09:18:25 -0000 1.144.2.1
@@ -861,8 +861,9 @@
stmt *op1 = stmt_dup(select->op1.stval);
op1 = push_semijoin(op1, s);
+ op1 = stmt_unop(op1, sql_dup_func(select->op4.funcval));
stmt_destroy(select);
- return stmt_unop(op1, sql_dup_func(select->op4.funcval));
+ return op1;
}
if (select->type == st_binop) {
stmt *op1 = stmt_dup(select->op1.stval);
Index: sql_psm.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_psm.mx,v
retrieving revision 1.73
retrieving revision 1.73.2.1
diff -u -d -r1.73 -r1.73.2.1
--- sql_psm.mx 10 Jan 2010 15:33:35 -0000 1.73
+++ sql_psm.mx 30 Jan 2010 09:18:25 -0000 1.73.2.1
@@ -152,7 +152,6 @@
dlist *qname = n->next->data.lval;
char *name = qname_table(qname);
char *sname = qname_schema(qname);
- //stmt *ret, *r;
sql_subtype ctype = *sql_bind_localtype("bat");
if (sname) /* not allowed here */
@@ -169,12 +168,7 @@
return NULL;
ctype.comp_type =
(sql_table*)((atom*)((sql_exp*)rel->exps->t->data)->l)->data.val.pval;
-//find_basetable(ret);
-
- //r = stmt_var(_strdup(name), &ctype, 1, sql->frame );
- //rel = rel_basetable(ctype.comp_type, name);
stack_push_rel_var(sql, name, rel_dup(rel), &ctype);
- //stmt_destroy(ret);
return rel_bin(sql, rel);
}
Index: bin_optimizer.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/bin_optimizer.mx,v
retrieving revision 1.25
retrieving revision 1.25.2.1
diff -u -d -r1.25 -r1.25.2.1
--- bin_optimizer.mx 10 Jan 2010 15:33:34 -0000 1.25
+++ bin_optimizer.mx 30 Jan 2010 09:18:21 -0000 1.25.2.1
@@ -223,7 +223,7 @@
case st_join:
/* fetch join, look at the join operands */
- if (s->flag == cmp_equal &&
+ if (isEqJoin(s) &&
s->op1.stval->t && s->op1.stval->t == s->op2.stval->h)
return is_reduced(s->op1.stval) +
is_reduced(s->op2.stval);
@@ -280,7 +280,7 @@
/* push through the projection joins */
if (s->flag == 0 &&
- j->type == st_join && j->flag == cmp_equal &&
+ isEqJoin(j) &&
j->op1.stval->t && j->op1.stval->t == j->op2.stval->h) {
stmt *l = stmt_dup(j->op1.stval);
stmt *r = stmt_dup(j->op2.stval);
@@ -301,7 +301,7 @@
the topn into the right part */
if (s->flag != 0 /* topn, ie limit and orderby */ &&
j->type == st_join &&
- ((j->flag == cmp_equal &&
+ ((isEqJoin(j) &&
!is_reduced(j) &&
j->op1.stval->t && j->op1.stval->t == j->op2.stval->h) ||
j->flag == cmp_all)) {
@@ -381,8 +381,7 @@
if (os->op1.stval->type == st_join) {
j = os->op1.stval;
/* equi join on same base table */
- if (j->type == st_join &&
- j->flag == cmp_equal &&
+ if (isEqJoin(j) &&
j->op1.stval->t == j->op2.stval->h ) {
stmt *l = stmt_dup(j->op1.stval);
stmt *r = stmt_dup(j->op2.stval);
@@ -442,7 +441,7 @@
* if join on oids from the same table then
* right kdiff is not needed
*/
- if (s->type == st_join && s->flag == cmp_equal &&
+ if (isEqJoin(s) &&
s->op1.stval->t == s->op2.stval->h &&
s->op2.stval->type == st_diff){
stmt *old = s->op2.stval;
@@ -477,6 +476,16 @@
case st_uselect2: {
stmt *res = NULL;
+ /* push down the select through st_alias */
+ if (s->op1.stval->type == st_alias) {
+ stmt *a = s->op1.stval;
+
+ s = push_select( s, stmt_dup(a->op1.stval));
+ s = stmt_alias(s, table_name(a), column_name(a));
+ res = bin_optimizer(c, s);
+ stmt_destroy(s);
+ return res;
+ }
/* push down the select through st_diff */
if (s->op1.stval->type == st_diff && s->flag != cmp_notequal) {
stmt *d = s->op1.stval;
Index: sql_statement.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_statement.mx,v
retrieving revision 1.197
retrieving revision 1.197.2.1
diff -u -d -r1.197 -r1.197.2.1
--- sql_statement.mx 10 Jan 2010 15:33:35 -0000 1.197
+++ sql_statement.mx 30 Jan 2010 09:18:25 -0000 1.197.2.1
@@ -241,6 +241,9 @@
extern stmt *stmt_uselectN(stmt *l, stmt *r, sql_subfunc *op);
extern stmt *stmt_likeselect(stmt *op1, stmt *op2, stmt *op3, comp_type
cmptype);
+#define isEqJoin(j) \
+ (j->type == st_join && (j->flag == cmp_equal || j->flag == cmp_project))
+
extern stmt *stmt_semijoin(stmt *op1, stmt *op2);
extern stmt *stmt_relselect_init(void);
Index: rel_subquery.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/rel_subquery.mx,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -u -d -r1.12 -r1.12.2.1
--- rel_subquery.mx 7 Jan 2010 15:24:32 -0000 1.12
+++ rel_subquery.mx 30 Jan 2010 09:18:25 -0000 1.12.2.1
@@ -27,7 +27,6 @@
#include "sql_semantic.h"
extern stmt *select_into(mvc *sql, symbol *sq, exp_kind ek );
-extern stmt *flat_subquery(mvc *sql, symbol *sq);
extern stmt *value_exp(mvc *sql, symbol *se, int f, exp_kind knd);
extern stmt *logical_value_exp(mvc *sql, symbol *sc, int f, exp_kind knd);
@@ -346,21 +345,6 @@
}
stmt *
-flat_subquery(mvc *sql, symbol *sq)
-{
- stmt *s = NULL;
- exp_kind ek = {type_value, card_relation, TRUE};
-
- s = _subquery(sql, sq, ek);
- if (s && s->type == st_ordered) {
- stmt *n = sql_reorder(stmt_dup(s->op1.stval),
stmt_dup(s->op2.stval));
- stmt_destroy(s);
- s = n;
- }
- return s;
-}
-
-stmt *
value_exp(mvc *sql, symbol *sq, int f, exp_kind ek)
{
int is_last = 0;
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins