Skip to content
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

fix(inputs.mysql): Revert slices declarations with zero initial length #12409

Merged
merged 1 commit into from
Dec 19, 2022
Merged

fix(inputs.mysql): Revert slices declarations with zero initial length #12409

merged 1 commit into from
Dec 19, 2022

Conversation

zak-pawel
Copy link
Collaborator

Reverts (mysql.go only): #12371
Fixes: #12398

Pointer to rawBytes := sql.RawBytes{} wrongly used (instead of pointer to slice).
In that case, enforcing slices declarations with zero initial length doesn't make much sense.

@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Dec 16, 2022
@powersj powersj added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Dec 16, 2022
@srebhan srebhan changed the title fix: Revert slices declarations with zero initial length in mysql plugin fix(inputs.mysql): Revert slices declarations with zero initial length Dec 19, 2022
@srebhan srebhan added area/mysql plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Dec 19, 2022
@srebhan srebhan merged commit 9b24184 into influxdata:master Dec 19, 2022
@utking
Copy link
Contributor

utking commented Dec 24, 2022

The slice declaration does not change anything. But how the pointer is used does. A simple example to show that the pointers (for t and vals[i]) have different addresses in memory would be

for i := range items {
    t := sql.RawBytes{}
    vals = append(vals, t)
    valPtrs = append(valPtrs, &t)
    fmt.Printf("%p:%p\n", &t, vals[i])
}

That is, having valPtrs = append(valPtrs, &rawBytes) reverted to use a slice index again would be enough, and would satisfy the linter.

srebhan pushed a commit that referenced this pull request Jan 30, 2023
…ngth (#12409)

Co-authored-by: Pawel Zak <Pawel Zak>
(cherry picked from commit 9b24184)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/mysql fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mysql_slave_Slave_SQL_Running metric is missing after update to 1.25.0
4 participants