-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat](binlog) Add Support recover binlog (#284)
- Loading branch information
Showing
21 changed files
with
1,482 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package record | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/selectdb/ccr_syncer/pkg/xerror" | ||
) | ||
|
||
type RecoverInfo struct { | ||
DbId int64 `json:"dbId"` | ||
NewDbName string `json:"newDbName"` | ||
TableId int64 `json:"tableId"` | ||
TableName string `json:"tableName"` | ||
NewTableName string `json:"newTableName"` | ||
PartitionId int64 `json:"partitionId"` | ||
PartitionName string `json:"partitionName"` | ||
NewPartitionName string `json:"newPartitionName"` | ||
} | ||
|
||
func NewRecoverInfoFromJson(data string) (*RecoverInfo, error) { | ||
var recoverInfo RecoverInfo | ||
err := json.Unmarshal([]byte(data), &recoverInfo) | ||
if err != nil { | ||
return nil, xerror.Wrap(err, xerror.Normal, "unmarshal create table error") | ||
} | ||
|
||
if recoverInfo.TableId == 0 { | ||
return nil, xerror.Errorf(xerror.Normal, "table id not found") | ||
} | ||
|
||
// table name must exist. partition name not checked since optional. | ||
if recoverInfo.TableName == "" { | ||
return nil, xerror.Errorf(xerror.Normal, "Table Name can not be null") | ||
} | ||
return &recoverInfo, nil | ||
} | ||
|
||
// String | ||
func (c *RecoverInfo) String() string { | ||
return fmt.Sprintf("RecoverInfo: DbId: %d, NewDbName: %s, TableId: %d, TableName: %s, NewTableName: %s, PartitionId: %d, PartitionName: %s, NewPartitionName: %s", | ||
c.DbId, c.NewDbName, c.TableId, c.TableName, c.NewTableName, c.PartitionId, c.PartitionName, c.NewPartitionName) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
regression-test/data/db_sync/partition/recover/test_ds_part_recover.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !target_sql_content -- | ||
3 0 | ||
3 1 | ||
3 2 | ||
5 0 | ||
5 1 | ||
5 2 | ||
|
||
-- !sql_source_content -- | ||
3 0 | ||
3 1 | ||
3 2 | ||
5 0 | ||
5 1 | ||
5 2 | ||
|
17 changes: 17 additions & 0 deletions
17
regression-test/data/db_sync/partition/recover1/test_ds_part_recover_new.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !target_sql_content -- | ||
3 0 | ||
3 1 | ||
3 2 | ||
5 0 | ||
5 1 | ||
5 2 | ||
|
||
-- !sql_source_content -- | ||
3 0 | ||
3 1 | ||
3 2 | ||
5 0 | ||
5 1 | ||
5 2 | ||
|
39 changes: 39 additions & 0 deletions
39
regression-test/data/db_sync/table/recover/test_ds_tbl_drop_recover.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !target_sql_content -- | ||
0 0 | ||
0 1 | ||
0 2 | ||
2 0 | ||
2 1 | ||
2 2 | ||
|
||
-- !sql_source_content -- | ||
0 0 | ||
0 1 | ||
0 2 | ||
2 0 | ||
2 1 | ||
2 2 | ||
|
||
-- !target_sql_content_2 -- | ||
0 0 | ||
0 1 | ||
0 2 | ||
2 0 | ||
2 1 | ||
2 2 | ||
3 0 | ||
3 1 | ||
3 2 | ||
|
||
-- !sql_source_content_2 -- | ||
0 0 | ||
0 1 | ||
0 2 | ||
2 0 | ||
2 1 | ||
2 2 | ||
3 0 | ||
3 1 | ||
3 2 | ||
|
39 changes: 39 additions & 0 deletions
39
regression-test/data/db_sync/table/recover1/test_ds_tbl_drop_recover_new.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !target_sql_content -- | ||
0 0 | ||
0 1 | ||
0 2 | ||
2 0 | ||
2 1 | ||
2 2 | ||
|
||
-- !sql_source_content -- | ||
0 0 | ||
0 1 | ||
0 2 | ||
2 0 | ||
2 1 | ||
2 2 | ||
|
||
-- !target_sql_content_2 -- | ||
0 0 | ||
0 1 | ||
0 2 | ||
2 0 | ||
2 1 | ||
2 2 | ||
3 0 | ||
3 1 | ||
3 2 | ||
|
||
-- !sql_source_content_2 -- | ||
0 0 | ||
0 1 | ||
0 2 | ||
2 0 | ||
2 1 | ||
2 2 | ||
3 0 | ||
3 1 | ||
3 2 | ||
|
77 changes: 77 additions & 0 deletions
77
regression-test/data/db_sync/table/recover2/test_ds_tbl_drop_recover2.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !target_sql_content_2 -- | ||
0 0 | ||
0 1 | ||
0 2 | ||
10 0 | ||
10 1 | ||
10 2 | ||
11 0 | ||
11 1 | ||
11 2 | ||
12 0 | ||
12 1 | ||
12 2 | ||
13 0 | ||
13 1 | ||
13 2 | ||
14 0 | ||
14 1 | ||
14 2 | ||
15 0 | ||
15 1 | ||
15 2 | ||
16 0 | ||
16 1 | ||
16 2 | ||
17 0 | ||
17 1 | ||
17 2 | ||
18 0 | ||
18 1 | ||
18 2 | ||
19 0 | ||
19 1 | ||
19 2 | ||
20 0 | ||
20 1 | ||
20 2 | ||
|
||
-- !sql_source_content_2 -- | ||
0 0 | ||
0 1 | ||
0 2 | ||
10 0 | ||
10 1 | ||
10 2 | ||
11 0 | ||
11 1 | ||
11 2 | ||
12 0 | ||
12 1 | ||
12 2 | ||
13 0 | ||
13 1 | ||
13 2 | ||
14 0 | ||
14 1 | ||
14 2 | ||
15 0 | ||
15 1 | ||
15 2 | ||
16 0 | ||
16 1 | ||
16 2 | ||
17 0 | ||
17 1 | ||
17 2 | ||
18 0 | ||
18 1 | ||
18 2 | ||
19 0 | ||
19 1 | ||
19 2 | ||
20 0 | ||
20 1 | ||
20 2 | ||
|
Oops, something went wrong.