Skip to content

Fix: charset latin1 #1036

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

Open
wants to merge 41 commits into
base: master
Choose a base branch
from

Conversation

sigalikanevsky
Copy link

No description provided.

eitamring and others added 30 commits January 6, 2022 15:02
…ests

Removed FlushBinlog which was only used for testing
…deleted_while_reading

Fix/eitam/add skip when table is deleted while reading
…_decode

Added support to convert byte to string dynamically
…_to_date

Change mysql_date default zero based value to nil
…_to_date

Change mysql_MYSQL_TYPE_TIMESTAMP2 and MYSQL_TYPE_TIMESTAMP to be def…
…_to_date

Change decodeDatetime2 default to zero
Change decodeTimestamp2 to return nil in case sec = 0
…p_log

Changed SP is missing to debug level
@dveeden
Copy link
Collaborator

dveeden commented May 19, 2025

@sigalikanevsky There are merge conflicts that need to be fixed. This is also missing either a link to an issue or a good description about what this is fixing exactly.

Is this only fixing latin1 related things? Or is it adding more character set support? What about collations? Does it support setting the collation in addition to or in place of the character set?

@@ -65,6 +65,10 @@ func NewCanal(cfg *Config) (*Canal, error) {

c.ctx, c.cancel = context.WithCancel(context.Background())

if cfg.WaitTimeBetweenConnectionSeconds > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems odd, why replace all configs with 5 seconds?

@@ -142,7 +143,15 @@ func (c *Canal) runSyncBinlog() error {
case *replication.QueryEvent:
stmts, _, err := c.parser.Parse(string(e.Query), "", "")
if err != nil {
log.Errorf("parse query(%s) err %v, will skip this event", e.Query, err)
msg := err.Error()
if strings.Contains(strings.ToLower(msg), strings.ToLower("procedure")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if strings.Contains(strings.ToLower(msg), strings.ToLower("procedure")) {
if strings.Contains(strings.ToLower(msg), "procedure") {

@@ -697,7 +707,8 @@ func (b *BinlogSyncer) onStream(s *BinlogStreamer) {
return
}

log.Errorf("retry sync err: %v, wait 1s and retry again", err)
log.Errorf("retry sync err: %v, wait %s s and retry again", err, b.cfg.WaitTimeBetweenConnectionSeconds)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
log.Errorf("retry sync err: %v, wait %s s and retry again", err, b.cfg.WaitTimeBetweenConnectionSeconds)
log.Errorf("retry sync err: %v, wait %ss and retry again", err, b.cfg.WaitTimeBetweenConnectionSeconds)

@@ -1182,6 +1220,33 @@ func decodeString(data []byte, length int) (v string, n int) {
return
}

// Replaces smart quotes with ASCII equivalents
func replaceUnsupportedLatin1Characters(s string) string {
s = string(bytes.ReplaceAll([]byte(s), []byte("‘"), []byte("'")))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should avoid repeatedly converting to/from string

@@ -1182,6 +1220,33 @@ func decodeString(data []byte, length int) (v string, n int) {
return
}

// Replaces smart quotes with ASCII equivalents
func replaceUnsupportedLatin1Characters(s string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func replaceUnsupportedLatin1Characters(s string) string {
func replaceUnsupportedLatin1Characters(s []byte) string {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants