Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

fix scan null string error #150

Merged
merged 2 commits into from
Sep 9, 2020
Merged

Conversation

lichunzhu
Copy link
Contributor

What problem does this PR solve?

Dumpling use []string to parse metadata variables, which can't handle null variable.

[2020/09/09 15:46:07.651 +08:00] [INFO] [log.go:70] ["get global metadata failed"] [task=coa-sync-prod] [unit=dump] [error="sql: Scan error on column index 43, name \"SQL_Remaining_Delay\": converting NULL to string is unsupported"] [errorVerbose="err = sql: Scan error on column index 43, name \"SQL_Remaining_Delay\": converting NULL to string is unsupported

What is changed and how it works?

Use []sql.NullString instead of []string.

Check List

Tests

  • Unit test
  • Integration test

Related changes

  • Need to cherry-pick to the release branch

Release note

  • fix the problem that dumpling fails to parse metadata when some variables are NULL

Copy link
Collaborator

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rest LGTM

mock.ExpectQuery("SELECT @@default_master_connection").WillReturnError(fmt.Errorf("mock error"))
mock.ExpectQuery("SHOW SLAVE STATUS").WillReturnRows(sqlmock.NewRows([]string{"SQL_Remaining_Delay"}).AddRow(nil))

testFilePath := "/test"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe c.MkDir or something in /tmp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't write file to disk since we don't use writeGlobalMetaData. So I think it's okay.

@lance6716
Copy link
Collaborator

LGTM

@kennytm kennytm merged commit a45daad into pingcap:master Sep 9, 2020
@lichunzhu lichunzhu deleted the fixScanNullString branch September 9, 2020 09:29
tisonkun pushed a commit to tisonkun/dumpling that referenced this pull request Oct 20, 2021
tisonkun pushed a commit to tisonkun/dumpling that referenced this pull request Oct 20, 2021
tisonkun pushed a commit to tisonkun/dumpling that referenced this pull request Oct 20, 2021
tisonkun pushed a commit to tisonkun/dumpling that referenced this pull request Oct 20, 2021
tisonkun pushed a commit to tisonkun/tidb that referenced this pull request Oct 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants