Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions enginetest/enginetests.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,51 @@ func TestInfoSchema(t *testing.T, h Harness) {
}, nil, nil, nil)
})

t.Run("information_schema.processlist projection case", func(t *testing.T) {
e := mustNewEngine(t, h)
defer e.Close()

if IsServerEngine(e) {
t.Skip("skipping for server engine as the processlist returned from server differs")
}
p := sqle.NewProcessList()
p.AddConnection(1, "localhost")

ctx := NewContext(h)
ctx.Session.SetClient(sql.Client{Address: "localhost", User: "root"})
ctx.Session.SetConnectionId(1)
ctx.ProcessList = p
ctx.SetCurrentDatabase("")

p.ConnectionReady(ctx.Session)

ctx, err := p.BeginQuery(ctx, "SELECT foo")
require.NoError(t, err)

p.AddConnection(2, "otherhost")
sess2 := sql.NewBaseSessionWithClientServer("localhost", sql.Client{Address: "otherhost", User: "root"}, 2)
sess2.SetCurrentDatabase("otherdb")
p.ConnectionReady(sess2)
ctx2 := sql.NewContext(context.Background(), sql.WithPid(2), sql.WithSession(sess2))
ctx2, err = p.BeginQuery(ctx2, "SELECT bar")
require.NoError(t, err)
p.EndQuery(ctx2)

TestQueryWithContext(t, ctx, e, h,
"SELECT id, uSeR, hOST FROM information_schema.processlist ORDER BY id",
[]sql.Row{
{uint64(1), "root", "localhost"},
{uint64(2), "root", "otherhost"},
},
sql.Schema{
{Name: "id", Type: types.Uint64},
{Name: "uSeR", Type: types.MustCreateString(sqltypes.VarChar, 96, sql.Collation_Information_Schema_Default)},
{Name: "hOST", Type: types.MustCreateString(sqltypes.VarChar, 783, sql.Collation_Information_Schema_Default)},
},
nil, nil,
)
})

for _, tt := range queries.SkippedInfoSchemaQueries {
t.Run(tt.Query, func(t *testing.T) {
t.Skip()
Expand Down
5 changes: 3 additions & 2 deletions sql/planbuilder/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,9 @@ func (c scopeColumn) unwrapGetFieldAliasId() columnId {
}

func (c scopeColumn) withOriginal(col string) scopeColumn {
if !strings.EqualFold(c.db, sql.InformationSchemaDatabaseName) {
// info schema columns always presented as uppercase
// info schema columns always presented as uppercase, except for processlist
// can't reference information_schema.ProcessListTableName because of import cycles
if !strings.EqualFold(c.db, sql.InformationSchemaDatabaseName) || (strings.EqualFold(c.db, sql.InformationSchemaDatabaseName) && strings.EqualFold(c.table, "processlist")) {
c.originalCol = col
}
return c
Expand Down