@@ -359,6 +359,95 @@ func TestInfoSchema(t *testing.T, h Harness) {
359359 )
360360 })
361361
362+ t .Run ("information_schema.processlist projection with alias case" , func (t * testing.T ) {
363+ e := mustNewEngine (t , h )
364+ defer e .Close ()
365+
366+ if IsServerEngine (e ) {
367+ t .Skip ("skipping for server engine as the processlist returned from server differs" )
368+ }
369+ p := sqle .NewProcessList ()
370+ p .AddConnection (1 , "localhost" )
371+
372+ ctx := NewContext (h )
373+ ctx .Session .SetClient (sql.Client {Address : "localhost" , User : "root" })
374+ ctx .Session .SetConnectionId (1 )
375+ ctx .ProcessList = p
376+ ctx .SetCurrentDatabase ("" )
377+
378+ p .ConnectionReady (ctx .Session )
379+
380+ ctx , err := p .BeginQuery (ctx , "SELECT foo" )
381+ require .NoError (t , err )
382+
383+ p .AddConnection (2 , "otherhost" )
384+ sess2 := sql .NewBaseSessionWithClientServer ("localhost" , sql.Client {Address : "otherhost" , User : "root" }, 2 )
385+ sess2 .SetCurrentDatabase ("otherdb" )
386+ p .ConnectionReady (sess2 )
387+ ctx2 := sql .NewContext (context .Background (), sql .WithPid (2 ), sql .WithSession (sess2 ))
388+ ctx2 , err = p .BeginQuery (ctx2 , "SELECT bar" )
389+ require .NoError (t , err )
390+ p .EndQuery (ctx2 )
391+
392+ TestQueryWithContext (t , ctx , e , h ,
393+ "SELECT id, uSeR, hOST FROM information_schema.processlist pl ORDER BY id" ,
394+ []sql.Row {
395+ {uint64 (1 ), "root" , "localhost" },
396+ {uint64 (2 ), "root" , "otherhost" },
397+ },
398+ sql.Schema {
399+ {Name : "id" , Type : types .Uint64 },
400+ {Name : "uSeR" , Type : types .MustCreateString (sqltypes .VarChar , 96 , sql .Collation_Information_Schema_Default )},
401+ {Name : "hOST" , Type : types .MustCreateString (sqltypes .VarChar , 783 , sql .Collation_Information_Schema_Default )},
402+ },
403+ nil , nil ,
404+ )
405+ })
406+
407+ t .Run ("information_schema.processlist projection with aliased join case" , func (t * testing.T ) {
408+ e := mustNewEngine (t , h )
409+ defer e .Close ()
410+
411+ if IsServerEngine (e ) {
412+ t .Skip ("skipping for server engine as the processlist returned from server differs" )
413+ }
414+ p := sqle .NewProcessList ()
415+ p .AddConnection (1 , "localhost" )
416+
417+ ctx := NewContext (h )
418+ ctx .Session .SetClient (sql.Client {Address : "localhost" , User : "root" })
419+ ctx .Session .SetConnectionId (1 )
420+ ctx .ProcessList = p
421+ ctx .SetCurrentDatabase ("" )
422+
423+ p .ConnectionReady (ctx .Session )
424+
425+ ctx , err := p .BeginQuery (ctx , "SELECT foo" )
426+ require .NoError (t , err )
427+
428+ p .AddConnection (2 , "otherhost" )
429+ sess2 := sql .NewBaseSessionWithClientServer ("localhost" , sql.Client {Address : "otherhost" , User : "root" }, 2 )
430+ sess2 .SetCurrentDatabase ("otherdb" )
431+ p .ConnectionReady (sess2 )
432+ ctx2 := sql .NewContext (context .Background (), sql .WithPid (2 ), sql .WithSession (sess2 ))
433+ ctx2 , err = p .BeginQuery (ctx2 , "SELECT bar" )
434+ require .NoError (t , err )
435+ p .EndQuery (ctx2 )
436+
437+ TestQueryWithContext (t , ctx , e , h ,
438+ "SELECT id, uSeR, hOST FROM information_schema.processlist pl join information_schema.schemata on true ORDER BY id limit 1" ,
439+ []sql.Row {
440+ {uint64 (1 ), "root" , "localhost" },
441+ },
442+ sql.Schema {
443+ {Name : "id" , Type : types .Uint64 },
444+ {Name : "uSeR" , Type : types .MustCreateString (sqltypes .VarChar , 96 , sql .Collation_Information_Schema_Default )},
445+ {Name : "hOST" , Type : types .MustCreateString (sqltypes .VarChar , 783 , sql .Collation_Information_Schema_Default )},
446+ },
447+ nil , nil ,
448+ )
449+ })
450+
362451 for _ , tt := range queries .SkippedInfoSchemaQueries {
363452 t .Run (tt .Query , func (t * testing.T ) {
364453 t .Skip ()
0 commit comments