Changeset: 2e614006ce84 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2e614006ce84
Modified Files:
        sql/backends/monet5/rel_bin.c
        sql/test/SQLancer/Tests/sqlancer06.stable.out
Branch: Oct2020
Log Message:

When generating insertion code, look for alignment between updatable indexes on 
tables and the SQL plan. Also removed redundant checks I added yesterday


diffs (67 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
@@ -3960,7 +3960,7 @@ rel2bin_insert(backend *be, sql_rel *rel
                return sql_error(sql, 02, SQLSTATE(27000) "INSERT INTO: 
triggers failed for table '%s'", t->base.name);
 
        if (t->idxs.set)
-       for (n = t->idxs.set->h; n && m; n = n->next, m = m->next) {
+       for (n = t->idxs.set->h; n && m; n = n->next) {
                stmt *is = m->data;
                sql_idx *i = n->data;
 
@@ -3977,10 +3977,11 @@ rel2bin_insert(backend *be, sql_rel *rel
                        insert = is;
                if (is)
                        is = stmt_append_idx(be, i, is);
-       }
-
-       for (n = t->columns.set->h, m = inserts->op4.lval->h;
-               n && m; n = n->next, m = m->next) {
+               /* If the index doesn't hold delta structures, don't update the 
'm' variable */
+               m = m->next;
+       }
+
+       for (n = t->columns.set->h, m = inserts->op4.lval->h; n && m; n = 
n->next, m = m->next) {
 
                stmt *ins = m->data;
                sql_column *c = n->data;
@@ -4940,7 +4941,7 @@ rel2bin_update(backend *be, sql_rel *rel
                        update_idx = bin_find_column(be, update, ce->l, ce->r);
                        if (update_idx)
                                is = update_idx;
-                       if ((hash_index(i->type) && list_length(i->columns) <= 
1) || !idx_has_column(i->type)) {
+                       if (hash_index(i->type) && list_length(i->columns) <= 
1) {
                                is = NULL;
                                update_idx = NULL;
                        }
diff --git a/sql/test/SQLancer/Tests/sqlancer06.stable.out 
b/sql/test/SQLancer/Tests/sqlancer06.stable.out
--- a/sql/test/SQLancer/Tests/sqlancer06.stable.out
+++ b/sql/test/SQLancer/Tests/sqlancer06.stable.out
@@ -373,6 +373,26 @@ stdout of test 'sqlancer06` in directory
 #INSERT INTO t1(c0) VALUES(TIME '09:41:58');
 [ 1    ]
 #DROP TABLE t1;
+#CREATE TABLE t0(c0 TIME NULL PRIMARY KEY, c1 TIMESTAMP);
+#CREATE TABLE IF NOT EXISTS t1(c0 TIMESTAMP, c1 INTERVAL SECOND);
+#CREATE TABLE t2(LIKE t1); 
+#INSERT INTO t1(c1) VALUES(INTERVAL '1520729315' SECOND);
+[ 1    ]
+#CREATE ORDERED INDEX i0 ON t0 (c0);
+#INSERT INTO t2(c0) VALUES(TIMESTAMP '1970-01-02 17:11:53');
+[ 1    ]
+#CREATE UNIQUE INDEX i1 ON t0 (c0, c1);
+#INSERT INTO t0(c0) VALUES(TIME '20:35:54');
+[ 1    ]
+#SELECT CAST(TIMESTAMP '1970-01-01 19:30:21' = ALL(SELECT DISTINCT t2.c0 FROM 
t1, t2) AS INT) as count FROM t2, t0 LEFT OUTER JOIN t1 ON NOT EXISTS (SELECT 
DISTINCT t2.c0 FROM t1, t0, t2);
+% . # table_name
+% count # name
+% int # type
+% 1 # length
+[ 0    ]
+#DROP TABLE t0;
+#DROP TABLE t1;
+#DROP TABLE t2;
 
 # 19:38:32 >  
 # 19:38:32 >  "Done."
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to