@@ -313,6 +313,51 @@ func TestInfoSchema(t *testing.T, h Harness) {
313313 }, nil , nil , nil )
314314 })
315315
316+ t .Run ("information_schema.processlist projection case" , func (t * testing.T ) {
317+ e := mustNewEngine (t , h )
318+ defer e .Close ()
319+
320+ if IsServerEngine (e ) {
321+ t .Skip ("skipping for server engine as the processlist returned from server differs" )
322+ }
323+ p := sqle .NewProcessList ()
324+ p .AddConnection (1 , "localhost" )
325+
326+ ctx := NewContext (h )
327+ ctx .Session .SetClient (sql.Client {Address : "localhost" , User : "root" })
328+ ctx .Session .SetConnectionId (1 )
329+ ctx .ProcessList = p
330+ ctx .SetCurrentDatabase ("" )
331+
332+ p .ConnectionReady (ctx .Session )
333+
334+ ctx , err := p .BeginQuery (ctx , "SELECT foo" )
335+ require .NoError (t , err )
336+
337+ p .AddConnection (2 , "otherhost" )
338+ sess2 := sql .NewBaseSessionWithClientServer ("localhost" , sql.Client {Address : "otherhost" , User : "root" }, 2 )
339+ sess2 .SetCurrentDatabase ("otherdb" )
340+ p .ConnectionReady (sess2 )
341+ ctx2 := sql .NewContext (context .Background (), sql .WithPid (2 ), sql .WithSession (sess2 ))
342+ ctx2 , err = p .BeginQuery (ctx2 , "SELECT bar" )
343+ require .NoError (t , err )
344+ p .EndQuery (ctx2 )
345+
346+ TestQueryWithContext (t , ctx , e , h ,
347+ "SELECT id, uSeR, hOST FROM information_schema.processlist ORDER BY id" ,
348+ []sql.Row {
349+ {uint64 (1 ), "root" , "localhost" },
350+ {uint64 (2 ), "root" , "otherhost" },
351+ },
352+ sql.Schema {
353+ {Name : "id" , Type : types .Uint64 },
354+ {Name : "uSeR" , Type : types .MustCreateString (sqltypes .VarChar , 96 , sql .Collation_Information_Schema_Default )},
355+ {Name : "hOST" , Type : types .MustCreateString (sqltypes .VarChar , 783 , sql .Collation_Information_Schema_Default )},
356+ },
357+ nil , nil ,
358+ )
359+ })
360+
316361 for _ , tt := range queries .SkippedInfoSchemaQueries {
317362 t .Run (tt .Query , func (t * testing.T ) {
318363 t .Skip ()
0 commit comments