Skip to content

Commit

Permalink
planner/core: infoschema tables should show global temp tables (#55379)
Browse files Browse the repository at this point in the history
close #55375
  • Loading branch information
tangenta authored Aug 13, 2024
1 parent 3c30925 commit bbe5266
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/planner/core/memtable_infoschema_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ func findNameAndAppendToTableMap(
return errors.Trace(err)
}
tblInfo := tbl.Meta()
if tblInfo.TempTableType != model.TempTableNone {
if tblInfo.TempTableType == model.TempTableLocal {
continue
}
tables[tblInfo.ID] = tblInfo
Expand All @@ -453,7 +453,7 @@ func findTablesByID(
continue
}
tblInfo := tbl.Meta()
if tblInfo.TempTableType != model.TempTableNone {
if tblInfo.TempTableType == model.TempTableLocal {
continue
}
if len(tableNames) > 0 {
Expand Down Expand Up @@ -514,7 +514,7 @@ func findTableAndSchemaByName(
return nil, nil, errors.Trace(err)
}
tblInfo := tbl.Meta()
if tblInfo.TempTableType != model.TempTableNone {
if tblInfo.TempTableType == model.TempTableLocal {
continue
}
tableMap[tblInfo.ID] = schemaAndTable{s, tblInfo}
Expand Down
11 changes: 11 additions & 0 deletions tests/integrationtest/r/infoschema/infoschema.result
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,14 @@ select count(1) from information_schema.statistics where table_name = 'temp_tabl
count(1)
0
drop table temp_table;
create global temporary table temp_table(a int, index idx(a)) on commit delete rows;
select count(1) from information_schema.tables where table_schema = 'infoschema__infoschema';
count(1)
1
select count(1) from information_schema.tables where table_name = 'temp_table';
count(1)
1
select count(1) from information_schema.statistics where table_name = 'temp_table';
count(1)
1
drop table temp_table;
7 changes: 6 additions & 1 deletion tests/integrationtest/t/infoschema/infoschema.test
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,14 @@ select * from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where table_schema = 'db1' ord
drop database db1;
drop database db2;

# TestTemporaryTableShouldNotAppear
# TestLocalTemporaryTableShouldNotAppear
create temporary table temp_table (a int, index idx(a));
select count(1) from information_schema.tables where table_schema = 'infoschema__infoschema';
select count(1) from information_schema.tables where table_name = 'temp_table';
select count(1) from information_schema.statistics where table_name = 'temp_table';
drop table temp_table;
create global temporary table temp_table(a int, index idx(a)) on commit delete rows;
select count(1) from information_schema.tables where table_schema = 'infoschema__infoschema';
select count(1) from information_schema.tables where table_name = 'temp_table';
select count(1) from information_schema.statistics where table_name = 'temp_table';
drop table temp_table;

0 comments on commit bbe5266

Please sign in to comment.