-
Notifications
You must be signed in to change notification settings - Fork 12
PMM-7896 Updated DB discovery query #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
result = append(result, databaseName) | ||
} | ||
|
||
if rows.Err() != nil { | ||
return nil, errors.New(fmt.Sprintln("error retrieving rows:", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci-lint] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "errors.New(fmt.Sprintln("error retrieving rows:", err))" (goerr113)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be fmt.Errorf
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to change it because upstream is not using newer libraries.
The correct way would be use errors.Wrap
. There are other parts where the exporting is comparing error types instead using errors.As
, etc, but to not to differ too much from upstream, I didn't want to change them.
If you take a look, it is a copy of the error 2 lines above.
result = append(result, databaseName) | ||
} | ||
|
||
if rows.Err() != nil { | ||
return nil, errors.New(fmt.Sprintln("error retrieving rows:", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be fmt.Errorf
?
FROM pg_database | ||
WHERE datallowconn = true | ||
AND datistemplate = false | ||
AND has_database_privilege(current_user, datname, 'connect')` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please aline this query? :)
Carlos Salguero seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Updated the database discovery query to list only the databases the current user has access to.
For RDS instances, the original query was returning the
rdsadmin
database but that's an RDS internal DB and no other users has access to it so, connections were failing.