-
Notifications
You must be signed in to change notification settings - Fork 1k
Add more MySQL-8.0 meta data to GTIDEvent and TableMapEvent #468
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
Conversation
names/primary key
Cool! We will take a look ASAP @huangjunwen |
@csuzhangxc @WangXiangUSTC This pr enhances the mysql 8.0 binlog replication protocol, PTAL |
can you help us test it for MariaDB 8.0? @huangjunwen |
ok, i will check the compatibility of MariaDB later |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, rest LGTM.
BTW, can you add some unit tests?
mysql/util.go
Outdated
case 1: | ||
u |= uint64(b[0]) | ||
default: | ||
panic(fmt.Errorf("BytesToUint64 byte slice length must be in range [1, 8]")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about returning an error instead of panic
as other func
did in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem
replication/event.go
Outdated
@@ -349,6 +350,18 @@ type GTIDEvent struct { | |||
GNO int64 | |||
LastCommitted int64 | |||
SequenceNumber int64 | |||
|
|||
// The followings are available only after MySQL-8.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding more details about these fields? (OriginalCommitTimestamp
and OriginalCommitTimestamp
were introduced in 8.0.1, TransactionLength
was introduced in 8.0.2, ImmediateServerVersion
and OriginalServerVersion
were introduced in 8.0.14).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem
replication/row_event.go
Outdated
continue | ||
} | ||
|
||
if collation, ok := collations[p]; ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use collations[i]
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... i
and p
are two different counters in this loop: i
is the index of all columns while p
is the index of character columns, here is an example to illustrate:
column | i | p |
---|---|---|
a int | 0 | n/a |
b char(8) | 1 | 0 |
c bigint | 2 | n/a |
d char(8) | 3 | 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 you're right, I found The column index is counted only in all character columns.
now.
Sure, i'd like to add some unit tests for both mysql and mariadb once i have time. |
can we merge it now? @GregoryIan @csuzhangxc |
I think we can merge it, and address comments later (in another PR) or let them go. |
Would you like to wait a while, i'm starting to write tests this morning ... |
👍 yep, we wait for your test case. This is very worthwhile, especially when encountering enum and set types, collation map will be wrong. |
… on types to implement them correctly.
@huangjunwen Cool, we will take a look ASAP |
I've removed types-related helper methods in TableMapEvent now. This is because these types-related optional meta data is stored in a compact format: for example, signedness bitmap only stores the signedness of numeric fields, default charset/column charset only stores collation id of character fields... If we want to reconstruct the mapping of column index -> meta (signedness/collation id, ...), we need to know whether the field is considerred as a numeric field or a character field ... But there are many corner cases here, more investigation is needed to implement correctly. So i've decided not to implement them in this pr and open another issue to track this later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM Cool, let's make it perfect later |
Hi @GregoryIan @siddontang What do we expect on the commit standard in a PR to merge?
and some merge commits
These commits are essential but they can be organized and cleaned before the merge, do we bother to do so? |
This pr adds more meta data added after MySQL-8.0:
GTIDEvent:
TableMapEvent:
These can be hopefully to solve #427 if using MySQL-8.0
Example GTIDEvent dump (MySQL-8.0):
Example GTIDEvent dump for the same event (MySQL-5.7):
Example TableMapEvent dump (MySQL-8.0):
Example TableMapEvent dump for the same event (MySQL-5.7):
ref: