-
Notifications
You must be signed in to change notification settings - Fork 131
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
PMM-10891 PG Explain with placeholders. #1434
base: main
Are you sure you want to change the base?
Conversation
@@ -146,7 +146,7 @@ func (s *actionsServer) StartMySQLExplainAction(ctx context.Context, req *manage | |||
return nil, status.Errorf(codes.FailedPrecondition, "Cannot find right agent") | |||
} | |||
|
|||
err = s.a.StartMySQLExplainAction(ctx, res.ID, res.PMMAgentID, req.ServiceId, dsn, req.Query, req.QueryId, req.Placeholders, agentpb.MysqlExplainOutputFormat_MYSQL_EXPLAIN_OUTPUT_FORMAT_DEFAULT, files, tdp, agents[0].TLSSkipVerify) | |||
err = s.a.StartMySQLExplainAction(ctx, res.ID, res.PMMAgentID, req.ServiceId, dsn, req.Query, req.QueryId, req.Values, agentpb.MysqlExplainOutputFormat_MYSQL_EXPLAIN_OUTPUT_FORMAT_DEFAULT, files, tdp, agents[0].TLSSkipVerify) |
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] reported by reviewdog 🐶
SA1019: req.Query is deprecated: should not be used. (staticcheck)
@@ -174,7 +174,7 @@ | |||
return nil, status.Errorf(codes.FailedPrecondition, "Cannot find right agent") | |||
} | |||
|
|||
err = s.a.StartMySQLExplainAction(ctx, res.ID, res.PMMAgentID, req.ServiceId, dsn, req.Query, req.QueryId, req.Placeholders, agentpb.MysqlExplainOutputFormat_MYSQL_EXPLAIN_OUTPUT_FORMAT_JSON, files, tdp, agents[0].TLSSkipVerify) | |||
err = s.a.StartMySQLExplainAction(ctx, res.ID, res.PMMAgentID, req.ServiceId, dsn, req.Query, req.QueryId, req.Values, agentpb.MysqlExplainOutputFormat_MYSQL_EXPLAIN_OUTPUT_FORMAT_JSON, files, tdp, agents[0].TLSSkipVerify) |
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] reported by reviewdog 🐶
SA1019: req.Query is deprecated: should not be used. (staticcheck)
@@ -202,7 +202,7 @@ | |||
return nil, status.Errorf(codes.FailedPrecondition, "Cannot find right agent") | |||
} | |||
|
|||
err = s.a.StartMySQLExplainAction(ctx, res.ID, res.PMMAgentID, req.ServiceId, dsn, req.Query, req.QueryId, req.Placeholders, agentpb.MysqlExplainOutputFormat_MYSQL_EXPLAIN_OUTPUT_FORMAT_TRADITIONAL_JSON, files, tdp, agents[0].TLSSkipVerify) | |||
err = s.a.StartMySQLExplainAction(ctx, res.ID, res.PMMAgentID, req.ServiceId, dsn, req.Query, req.QueryId, req.Values, agentpb.MysqlExplainOutputFormat_MYSQL_EXPLAIN_OUTPUT_FORMAT_TRADITIONAL_JSON, files, tdp, agents[0].TLSSkipVerify) |
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] reported by reviewdog 🐶
SA1019: req.Query is deprecated: should not be used. (staticcheck)
@@ -127,7 +125,12 @@ func (a *mysqlExplainAction) Run(ctx context.Context) ([]byte, error) { | |||
func (a *mysqlExplainAction) sealed() {} | |||
|
|||
func (a *mysqlExplainAction) explainDefault(ctx context.Context, tx *sql.Tx) ([]byte, error) { | |||
rows, err := tx.QueryContext(ctx, fmt.Sprintf("EXPLAIN /* pmm-agent */ %s", a.query)) | |||
inter := []any{} | |||
for _, p := range a.params.Values { |
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.
Maybe you can use copy
here
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.
https://go.dev/play/p/9xfjslBdmv9
See example. Its not possible in this case.
"github.com/pkg/errors" | ||
"vitess.io/vitess/go/vt/proto/query" | ||
"vitess.io/vitess/go/vt/sqlparser" | ||
) | ||
|
||
var ( | ||
pgRegexp *regexp.Regexp | ||
pgRegexpErr error |
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] reported by reviewdog 🐶
the variable name pgRegexpErr
should conform to the errXxx
format (errname)
PMM-10891
Build: Percona-Lab/pmm-submodules#2921
Contains also some changes/improvements for MySQL implementation of this.