Changeset: be33f10eda11 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/be33f10eda11
Added Files:
sql/test/BugTracker-2025/Tests/7686-delete-all-empty-table.test
Modified Files:
sql/server/rel_statistics.c
sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.test
sql/test/BugTracker-2025/Tests/All
sql/test/astro/Tests/astro.test
Branch: Mar2025
Log Message:
prune relational semijoins on empty leftside
diffs (85 lines):
diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c
--- a/sql/server/rel_statistics.c
+++ b/sql/server/rel_statistics.c
@@ -1071,6 +1071,10 @@ rel_get_statistics_(visitor *v, sql_rel
set_count_prop(v->sql->sa, rel,
get_rel_count(l));
}
}
+ if (can_be_pruned && is_semi(rel->op)) {
+ if (get_rel_count(rel->l) == 0)
+ return rel->l;
+ }
break;
case op_project:
if (l) {
diff --git
a/sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.test
b/sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.test
---
a/sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.test
+++
b/sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.test
@@ -6,6 +6,9 @@ CREATE TABLE sys.myfunctions ("id" INTEG
"schema_id" INTEGER,"system" BOOLEAN,"semantics" BOOLEAN)
statement ok
+insert into sys.myfunctions values( 10000000, 'test', 'func', 'mod', 0, 0,
false, false, false, 2000, true, false);
+
+statement ok
CREATE VIEW sys.commented_function_signatures_6542 AS
SELECT f.id AS fid,
s.name AS schema,
@@ -52,7 +55,7 @@ project (
| | | | | | | | | | select (
| | | | | | | | | | | table("sys"."args") [ "args"."func_id" NOT NULL as
"p"."func_id", "args"."inout" NOT NULL as "p"."inout", "args"."number" NOT NULL
as "p"."number" ]
| | | | | | | | | | ) [ ("p"."inout" NOT NULL) = (tinyint(1) "1") ]
-| | | | | | | | | ) [ ("f"."id" NOT NULL UNIQUE) = ("p"."func_id" NOT NULL) ]
+| | | | | | | | | ) [ boolean(1) "false" ]
| | | | | | | | ) [ "f"."id" NOT NULL, "p"."number" ] [ "f"."id" PART ASC NOT
NULL, "p"."number" ASC ]
| | | | | | | ) [ "f"."id" NOT NULL, "p"."number" ] [ "f"."id" PART ASC NOT
NULL, "p"."number" NULLS LAST ]
| | | | | | ) [ "f"."id" NOT NULL, "p"."number" ] [ "f"."id" ASC NOT NULL,
"p"."number" ASC ]
diff --git a/sql/test/BugTracker-2025/Tests/7686-delete-all-empty-table.test
b/sql/test/BugTracker-2025/Tests/7686-delete-all-empty-table.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2025/Tests/7686-delete-all-empty-table.test
@@ -0,0 +1,17 @@
+statement ok
+create table a(i int)
+
+statement ok
+create table b as select value as i from generate_series(0,10000000)
+
+query T
+plan delete from a where i in (select i from b where i % 2 = 0)
+----
+REF 1 (2)
+table("sys"."a") [ "a"."i" NOT NULL UNIQUE, "a"."%TID%" NOT NULL UNIQUE ]
+delete(
+| & REF 1
+| project (
+| | & REF 1
+| ) [ "a"."%TID%" NOT NULL UNIQUE ]
+)
diff --git a/sql/test/BugTracker-2025/Tests/All
b/sql/test/BugTracker-2025/Tests/All
--- a/sql/test/BugTracker-2025/Tests/All
+++ b/sql/test/BugTracker-2025/Tests/All
@@ -26,3 +26,4 @@ 7671-lag-over-empty-bat
7674-rel_find_designated_index_crash
7680-union-all
7682_trigger_crash
+7686-delete-all-empty-table
diff --git a/sql/test/astro/Tests/astro.test b/sql/test/astro/Tests/astro.test
--- a/sql/test/astro/Tests/astro.test
+++ b/sql/test/astro/Tests/astro.test
@@ -70,14 +70,7 @@ update(
| & REF 1
| project (
| | left outer join (
-| | | semijoin (
-| | | | & REF 1 ,
-| | | | project (
-| | | | | select (
-| | | | | | table("sys"."cm_flux") [ "cm_flux"."runcat" NOT NULL UNIQUE,
"cm_flux"."filter" NOT NULL UNIQUE, "cm_flux"."active" NOT NULL UNIQUE ]
-| | | | | ) [ ("cm_flux"."active" NOT NULL UNIQUE) = (boolean(1) "true"),
(varchar(1)["cm_flux"."filter" NOT NULL UNIQUE] NOT NULL) = (varchar(1) "g") ]
-| | | | ) [ "cm_flux"."runcat" NOT NULL UNIQUE, "cm_flux"."filter" NOT NULL
UNIQUE ]
-| | | ) [ ("cm_flux"."runcat" NOT NULL UNIQUE) = ("fluxz"."runcat" NOT NULL
UNIQUE), ("cm_flux"."filter" NOT NULL UNIQUE) = ("fluxz"."filter" NOT NULL
UNIQUE) ],
+| | | & REF 1 ,
| | | single project (
| | | | select (
| | | | | table("sys"."cm_flux") [ "cm_flux"."runcat" NOT NULL UNIQUE,
"cm_flux"."filter" NOT NULL UNIQUE, "cm_flux"."f_datapoints" NOT NULL UNIQUE,
"cm_flux"."active" NOT NULL UNIQUE, "cm_flux"."avg_flux" NOT NULL UNIQUE,
"cm_flux"."avg_fluxsq" NOT NULL UNIQUE, "cm_flux"."avg_w" NOT NULL UNIQUE,
"cm_flux"."avg_wflux" NOT NULL UNIQUE, "cm_flux"."avg_wfluxsq" NOT NULL UNIQUE,
"cm_flux"."avg_dec_zone_deg" NOT NULL UNIQUE ]
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]