- $table = $this->tableName( $table, 'raw' );
- if ( isset( $this->mSessionTempTables[$table] ) ) {
+ // Split database and table into proper variables as Database::tableName() returns
+ // shared tables prefixed with their database, which do not work in SHOW TABLES statements
+ list( $database, , $prefix, $table ) = $this->qualifiedTableComponents( $table );
+ $tableName = "{$prefix}{$table}";
+
+ if ( isset( $this->mSessionTempTables[$tableName] ) ) {