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

Exclude any index not backed with columns from the SQL plan


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
@@ -3966,7 +3966,7 @@ rel2bin_insert(backend *be, sql_rel *rel
 
                if (non_updatable_index(i->type)) /* Some indexes don't hold 
delta structures */
                        continue;
-               if (hash_index(i->type) && list_length(i->columns) <= 1)
+               if ((hash_index(i->type) && list_length(i->columns) <= 1) || 
!idx_has_column(i->type))
                        is = NULL;
                if (i->key && constraint) {
                        stmt *ckeys = sql_insert_key(be, inserts->op4.lval, 
i->key, is, pin);
@@ -4940,7 +4940,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) {
+                       if ((hash_index(i->type) && list_length(i->columns) <= 
1) || !idx_has_column(i->type)) {
                                is = NULL;
                                update_idx = NULL;
                        }
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -8820,7 +8820,7 @@ rel_rename_part(mvc *sql, sql_rel *p, ch
                        sql_idx *i = m->data;
                        char *iname = NULL;
 
-                       if (hash_index(i->type) && list_length(i->columns) <= 1)
+                       if ((hash_index(i->type) && list_length(i->columns) <= 
1) || !idx_has_column(i->type))
                                continue;
 
                        iname = sa_strconcat( sql->sa, "%", i->base.name);
diff --git a/sql/server/rel_rel.c b/sql/server/rel_rel.c
--- a/sql/server/rel_rel.c
+++ b/sql/server/rel_rel.c
@@ -833,7 +833,7 @@ rel_basetable(mvc *sql, sql_table *t, co
                        char *iname = NULL;
 
                        /* do not include empty indices in the plan */
-                       if ((hash_index(i->type) && list_length(i->columns) <= 
1) || i->type == no_idx || i->type == imprints_idx)
+                       if ((hash_index(i->type) && list_length(i->columns) <= 
1) || !idx_has_column(i->type))
                                continue;
 
                        if (i->type == join_idx)
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
@@ -123,6 +123,18 @@ stdout of test 'sqlancer06` in directory
 % 5 # length
 [ "false"      ]
 #ROLLBACK;
+#START TRANSACTION;
+#CREATE TABLE "sys"."t0" ("c0" DATE NOT NULL,CONSTRAINT "t0_c0_pkey" PRIMARY 
KEY ("c0"));
+#CREATE TABLE "sys"."t1" ("c0" DATE NOT NULL);
+#CREATE INDEX "i1" ON "sys"."t1" ("c0");
+#CREATE ORDERED INDEX "i2" ON "sys"."t1" ("c0");
+#create view v0(c0) as (select 1 from t0,t1 where ((t0.c0)>=(t1.c0)));
+#select '12' like 'i' from t0, t1 right outer join v0 on exists (select 'a' 
from t0, t1);
+% .%24 # table_name
+% %24 # name
+% boolean # type
+% 5 # length
+#ROLLBACK;
 
 # 19:38:32 >  
 # 19:38:32 >  "Done."
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to