Skip to content

Commit

Permalink
session: fix a bug that upgrading from 3.1.1 to 4.0 fails (#17293) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored May 20, 2020
1 parent 6098373 commit 9432ebb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ const (
version44 = 44
// version45 introduces CONFIG_PRIV for SET CONFIG statements.
version45 = 45
// version46 fix a bug in v3.1.1.
version46 = 46
)

var (
Expand Down Expand Up @@ -432,6 +434,7 @@ var (
upgradeToVer43,
upgradeToVer44,
upgradeToVer45,
upgradeToVer46,
}
)

Expand Down Expand Up @@ -1045,6 +1048,18 @@ func upgradeToVer45(s Session, ver int64) {
mustExecute(s, "UPDATE HIGH_PRIORITY mysql.user SET Config_priv='Y' where Super_priv='Y'")
}

// In v3.1.1, we wrongly replace the context of upgradeToVer39 with upgradeToVer44. If we upgrade from v3.1.1 to a newer version,
// upgradeToVer39 will be missed. So we redo upgradeToVer39 here to make sure the upgrading from v3.1.1 succeed.
func upgradeToVer46(s Session, ver int64) {
if ver >= version46 {
return
}
doReentrantDDL(s, "ALTER TABLE mysql.user ADD COLUMN `Reload_priv` ENUM('N','Y') DEFAULT 'N'", infoschema.ErrColumnExists)
doReentrantDDL(s, "ALTER TABLE mysql.user ADD COLUMN `File_priv` ENUM('N','Y') DEFAULT 'N'", infoschema.ErrColumnExists)
mustExecute(s, "UPDATE HIGH_PRIORITY mysql.user SET Reload_priv='Y' where Super_priv='Y'")
mustExecute(s, "UPDATE HIGH_PRIORITY mysql.user SET File_priv='Y' where Super_priv='Y'")
}

// updateBootstrapVer updates bootstrap version variable in mysql.TiDB table.
func updateBootstrapVer(s Session) {
// Update bootstrap version.
Expand Down
2 changes: 1 addition & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ func CreateSessionWithDomain(store kv.Storage, dom *domain.Domain) (*session, er

const (
notBootstrapped = 0
currentBootstrapVersion = version45
currentBootstrapVersion = version46
)

func getStoreBootstrapVersion(store kv.Storage) int64 {
Expand Down

0 comments on commit 9432ebb

Please sign in to comment.