Skip to content

Commit 7b14c48

Browse files
author
James Cor
committed
don't erase dual table projection
1 parent be58f51 commit 7b14c48

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

enginetest/queries/queries.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10171,6 +10171,18 @@ from typestable`,
1017110171
{2},
1017210172
},
1017310173
},
10174+
{
10175+
Query: "select ''",
10176+
Expected: []sql.Row{
10177+
{""},
10178+
},
10179+
},
10180+
{
10181+
Query: "select '' from dual",
10182+
Expected: []sql.Row{
10183+
{""},
10184+
},
10185+
},
1017410186

1017510187
{
1017610188
Query: "select @@sql_mode = 1",
@@ -10206,6 +10218,7 @@ from typestable`,
1020610218
{" └─ name: "},
1020710219
},
1020810220
},
10221+
1020910222
}
1021010223

1021110224
var KeylessQueries = []QueryTest{

sql/analyzer/optimization_rules.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
package analyzer
1616

1717
import (
18-
"strings"
18+
"github.com/dolthub/go-mysql-server/memory"
19+
"strings"
1920

2021
"github.com/dolthub/go-mysql-server/sql"
2122
"github.com/dolthub/go-mysql-server/sql/expression"
@@ -43,7 +44,9 @@ func eraseProjection(ctx *sql.Context, a *Analyzer, node sql.Node, scope *plan.S
4344
return transform.Node(node, func(node sql.Node) (sql.Node, transform.TreeIdentity, error) {
4445
project, ok := node.(*plan.Project)
4546
if ok {
46-
if project.Schema().CaseSensitiveEquals(project.Child.Schema()) {
47+
projSch := project.Schema()
48+
childSch := project.Child.Schema()
49+
if projSch.CaseSensitiveEquals(childSch) && !childSch.Equals(memory.DualTableSchema.Schema) {
4750
a.Log("project erased")
4851
return project.Child, transform.NewTree, nil
4952
}

0 commit comments

Comments
 (0)