Open yuzefovich opened 3 days ago
Here's an optimizer test repro:
exec-ddl
CREATE TABLE table_1 (
col1_0 BOOL,
col1_1 REFCURSOR,
col1_2 PG_LSN,
col1_3 BOX2D,
col1_4 INT8,
col1_5 STRING,
col1_6 STRING,
col1_7 INT8,
col1_8 STRING AS (lower(NULL)) VIRTUAL,
col1_9 STRING,
foo_col DECIMAL,
PRIMARY KEY (col1_8),
INDEX (CAST(col1_3 AS STRING), CAST(col1_2 AS STRING))
);
----
opt disable=(MergeProjects,PruneProjectCols)
SELECT NULL
FROM table_1 AS tab_879
JOIN table_1 AS tab_880 ON true
FULL JOIN table_1 AS tab_881 ON true
JOIN table_1 ON true
JOIN table_1 AS tab_883 ON true
WHERE NOT EXISTS (SELECT NULL FROM table_1 AS tab_884 JOIN table_1 ON true)
OR NOT EXISTS (SELECT NULL FROM table_1 AS tab_886 JOIN table_1 AS tab_887 ON tab_886.col1_5 = tab_887.col1_5);
----
There's a bug in InlineProjectProject
, where we're mutating a Project
operator's Passthrough
set rather than copying it:
--- a/pkg/sql/opt/norm/inline_funcs.go
+++ b/pkg/sql/opt/norm/inline_funcs.go
@@ -245,7 +245,7 @@ func (c *CustomFuncs) InlineProjectProject(
}
// Add any outer passthrough columns that refer to inner synthesized columns.
- newPassthrough := passthrough
+ newPassthrough := passthrough.Copy()
if !newPassthrough.Empty() {
for i := range innerProjections {
item := &innerProjections[i]
The large number of columns and joins in the test is necessary to spill the removed columns into the large set, which is shared between passthrough
and newPassthrough
without the fix.
Extracted from here. On
crdb_test
binaries we getJira issue: CRDB-44942