Bug #112080 No need call performance schema interface when open temporary table
Submitted: 16 Aug 2023 6:30 Modified: 16 Aug 2023 8:13
Reporter: xiaoyu bai Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[16 Aug 2023 6:30] xiaoyu bai
Description:
It calls psi when opening temporary table which is not necessary. 

How to repeat:
read code.

in handler::ha_open function

#ifdef HAVE_PSI_TABLE_INTERFACE
    PSI_table_share *share_psi = ha_table_share_psi(table_share);
    m_psi = PSI_TABLE_CALL(open_table)(share_psi, this);
#endif

Suggested fix:
if it's a temporary table ,no need call PSI_TABLE_CALL
[16 Aug 2023 8:13] xiaoyu bai
if (unlikely(pfs_table_share == nullptr)) {
    return nullptr;
  }]

will return nullptr for temporary table