*: use session time_zone for is.tables and show table status (#32449)

ref pingcap/tidb#26642
This commit is contained in:
Mattias Jonsson
2022-02-28 23:09:45 +01:00
committed by GitHub
parent f9a324829b
commit 584ae75df5
5 changed files with 41 additions and 5 deletions

View File

@ -512,13 +512,17 @@ func (e *memtableRetriever) setDataFromTables(ctx context.Context, sctx sessionc
var rows [][]types.Datum
createTimeTp := mysql.TypeDatetime
loc := sctx.GetSessionVars().TimeZone
if loc == nil {
loc = time.Local
}
for _, schema := range schemas {
for _, table := range schema.Tables {
collation := table.Collate
if collation == "" {
collation = mysql.DefaultCollationName
}
createTime := types.NewTime(types.FromGoTime(table.GetUpdateTime()), createTimeTp, types.DefaultFsp)
createTime := types.NewTime(types.FromGoTime(table.GetUpdateTime().In(loc)), createTimeTp, types.DefaultFsp)
createOptions := ""

View File

@ -500,7 +500,7 @@ func (e *ShowExec) fetchShowTableStatus(ctx context.Context) error {
snapshot = e.ctx.GetSessionVars().SnapshotTS
}
rows, _, err := exec.ExecRestrictedSQL(ctx, []sqlexec.OptionFuncAlias{sqlexec.ExecOptionWithSnapshot(snapshot)},
rows, _, err := exec.ExecRestrictedSQL(ctx, []sqlexec.OptionFuncAlias{sqlexec.ExecOptionWithSnapshot(snapshot), sqlexec.ExecOptionUseCurSession},
`SELECT table_name, engine, version, row_format, table_rows,
avg_row_length, data_length, max_data_length, index_length,
data_free, auto_increment, create_time, update_time, check_time,