Changeset: 2196a31686d0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2196a31686d0
Modified Files:
        sql/backends/monet5/rel_bin.c
        sql/server/rel_updates.c
Branch: returning
Log Message:

cleanup DELETE ... RETURNING code a bit


diffs (45 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
@@ -6685,11 +6685,6 @@ rel2bin_delete(backend *be, sql_rel *rel
                assert(0/*ddl statement*/);
 
        if (rel->r) { /* first construct the deletes relation */
-               if (rel->attr) {
-                       sql_rel* sel = ((sql_rel*) rel->r)->l;
-                       assert(is_select(sel->op));
-                       (void) rel_dup (sel); // required to prevent 
recalculating select in rel2bin_delete
-               }
                stmt *rows = subrel_bin(be, rel->r, refs);
                rows = subrel_project(be, rows, refs, rel->r);
                if (!rows)
@@ -6699,7 +6694,13 @@ rel2bin_delete(backend *be, sql_rel *rel
        }
 
        if (rel->attr) {
-               sql_rel* inner = rel->r?((sql_rel*) rel->r)->l:rel->l;
+               sql_rel* inner = rel->l;
+               if (rel_is_ref(inner)) {
+                       s = refs_find_rel(refs, inner);
+                       if (s)
+                               s->cand = tids;
+               }
+
                sql_rel* ret = rel_project(sql->sa, inner, rel->attr);
                s = subrel_bin(be, ret, refs);
                s = subrel_project(be, s, refs, rel);
diff --git a/sql/server/rel_updates.c b/sql/server/rel_updates.c
--- a/sql/server/rel_updates.c
+++ b/sql/server/rel_updates.c
@@ -1331,11 +1331,6 @@ delete_table(sql_query *query, dlist *qn
                        list *pexps = sa_list(sql->sa);
                        for (dnode *n = opt_returning->h; n; n = n->next) {
                                sql_rel* inner = r->l;
-                               if (r->r) {
-                                       sql_rel* sel = ((sql_rel*) r->r)->l;
-                                       assert(is_select(sel->op));
-                                       (void) rel_dup (sel); // required to 
prevent recalculating select in rel2bin_delete
-                               }
                                sql_exp *ce = rel_column_exp(query, &inner, 
n->data.sym, sql_sel | sql_no_subquery | sql_update_set);
                                if (ce == NULL)
                                        return sql_error(sql, 02, 
SQLSTATE(42000) "aggregate functions and subqueries are not allowed in 
RETURNING clause");
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to