Skip to content

Commit

Permalink
session: fix tables_priv table schema (#33599) (#33604)
Browse files Browse the repository at this point in the history
close #33588
  • Loading branch information
ti-srebot authored Jun 17, 2022
1 parent 453960e commit 8c7825f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ const (
last_analyzed_at TIMESTAMP,
PRIMARY KEY (table_id, column_id) CLUSTERED
);`
// CreateTableCacheMetaTable stores the cached table meta lock information.
CreateTableCacheMetaTable = `CREATE TABLE IF NOT EXISTS mysql.table_cache_meta (
tid bigint(11) NOT NULL DEFAULT 0,
lock_type enum('NONE','READ', 'INTEND', 'WRITE') NOT NULL DEFAULT 'NONE',
lease bigint(20) NOT NULL DEFAULT 0,
oldReadLease bigint(20) NOT NULL DEFAULT 0,
PRIMARY KEY (tid)
);`
)

// bootstrap initiates system DB for a store.
Expand Down Expand Up @@ -528,11 +536,15 @@ const (
version77 = 77
// version78 updates mysql.stats_buckets.lower_bound, mysql.stats_buckets.upper_bound and mysql.stats_histograms.last_analyze_pos from BLOB to LONGBLOB.
version78 = 78
// version79 adds the mysql.table_cache_meta table
// And update mysql.tables_priv from SET('Select','Insert','Update') to SET('Select','Insert','Update','References').
version79 = 79
// Note: the version86 of master is merge into version79.
)

// currentBootstrapVersion is defined as a variable, so we can modify its value for testing.
// please make sure this is the largest version
var currentBootstrapVersion int64 = version78
var currentBootstrapVersion int64 = version79

var (
bootstrapVersion = []func(Session, int64){
Expand Down Expand Up @@ -614,6 +626,7 @@ var (
upgradeToVer76,
upgradeToVer77,
upgradeToVer78,
upgradeToVer79,
}
)

Expand Down Expand Up @@ -1612,6 +1625,14 @@ func upgradeToVer78(s Session, ver int64) {
doReentrantDDL(s, "ALTER TABLE mysql.stats_histograms MODIFY last_analyze_pos LONGBLOB DEFAULT NULL")
}

func upgradeToVer79(s Session, ver int64) {
if ver >= version79 {
return
}
doReentrantDDL(s, CreateTableCacheMetaTable)
doReentrantDDL(s, "ALTER TABLE mysql.tables_priv MODIFY COLUMN Column_priv SET('Select','Insert','Update','References')")
}

func writeOOMAction(s Session) {
comment := "oom-action is `log` by default in v3.0.x, `cancel` by default in v4.0.11+"
mustExecute(s, `INSERT HIGH_PRIORITY INTO %n.%n VALUES (%?, %?, %?) ON DUPLICATE KEY UPDATE VARIABLE_VALUE= %?`,
Expand Down

0 comments on commit 8c7825f

Please sign in to comment.