Skip to content

Commit

Permalink
Treat rds_superuser_role as a superuser
Browse files Browse the repository at this point in the history
This role was introduced in RDS for MySQL 8.0.36, and this role cannot be dropped

See https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.MasterAccounts.html
  • Loading branch information
monotypical committed Dec 2, 2024
1 parent 4ce1b3f commit 11dc266
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sqlengine/mysql_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,14 @@ func (d *MySQLEngine) ResetState() error {
func (d *MySQLEngine) listNonSuperUsers(logger lager.Logger) ([]string, error) {
users := []string{}

rows, err := d.db.Query(
"SELECT User FROM mysql.user WHERE Super_priv != 'Y' AND Host = '%' AND User != SUBSTRING_INDEX(CURRENT_USER(), '@', 1)",
)
rows, err := d.db.Query(`
SELECT User
FROM mysql.user
WHERE Super_priv != 'Y'
AND Host = '%'
AND User != SUBSTRING_INDEX(CURRENT_USER(), '@', 1)
AND User != 'rds_superuser_role'
`)
if err != nil {
logger.Error("sql-error", err)
return nil, err
Expand Down

0 comments on commit 11dc266

Please sign in to comment.