Skip to content
This repository was archived by the owner on Aug 10, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion canal/canal.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func (c *Canal) checkBinlogRowFormat() error {

func isSafeIdentifier(s string) bool {
for _, r := range s {
if !(unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' || r == '-') {
if !(unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' || r == '-' || r == ' ') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This addition will make space also a valid char like letters, digits etc.
Now sure this is our intention here. Why not just replace space with "_"? Already from Backend side, not here...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hey Aaron,

We can't normalize (replace space with _) on the backend side because of how the binlog listener works:

  1. The binlog streams events by actual table name - When MySQL sends binlog events, they contain the exact table name as it exists in the database (tbl_some_name _CC_triggered_email_list with the space)
  2. We filter which tables to listen to using IncludeTableRegex - This regex must match the exact table name from the binlog events
  3. If we normalize before receiving from backend:
    - Backend sends us tbl_...GI_CC... (normalized, with underscore)
    - Binlog streams events for tbl_..._GI CC... (actual name, with space)
    - They won't match → we miss all events for that table

The table name in IncludeTableRegex must be identical to what MySQL has, otherwise the binlog listener won't capture those events. We're not creating the space - we're just allowing it to pass through because the customer's MySQL database actually has a table with a space in its name.

return false
}
}
Expand Down
4 changes: 3 additions & 1 deletion canal/canal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import (
"flag"
"fmt"
"github.com/DATA-DOG/go-sqlmock"

Check failure on line 6 in canal/canal_test.go

View workflow job for this annotation

GitHub Actions / golangci

File is not properly formatted (goimports)

Check failure on line 6 in canal/canal_test.go

View workflow job for this annotation

GitHub Actions / golangci

File is not properly formatted (goimports)
"github.com/stretchr/testify/assert"
"strings"
"testing"
Expand Down Expand Up @@ -508,8 +508,10 @@
{"unicode letters", "tàble", true},
{"chinese characters", "表格", true},

// Space is valid (MySQL allows spaces in identifiers when quoted)
{"space", "my table", true},

// Invalid identifiers
{"space", "my table", false},
{"dot", "my.table", false},
{"at symbol", "@table", false},
{"hash symbol", "#table", false},
Expand Down
Loading