Skip to content

Binary value being cut in case of zero byte at the end #2219

@sam0delkin

Description

@sam0delkin

Hi, i have a table where i storing IDs as binary UUIDs:

CREATE TABLE `test` (`id` binary(16) NOT NULL, PRIMARY KEY (`id`));

When i insert a new row with binary UUID which has a zero at the end:

INSERT INTO test (id) VALUES (UUID_TO_BIN('1f0727b7-2cc9-6910-920c-b12f2d100600'));

Maxwell provides a following JSON:

{"database":"app","table":"test","type":"insert","ts":1756363904,"xid":97707,"commit":true,"data":{"id":"HwcntyzJaRCSDLEvLRAG"}}

Notice the value HwcntyzJaRCSDLEvLRAG. Now let's try to base64 encode the binary UUID on the MySQL side:

SELECT BIN_TO_UUID(id), to_base64(id) FROM test;

->

BIN_TO_UUID(id) to_base64(id)
1f0727b7-2cc9-6910-920c-b12f2d100600 HwcntyzJaRCSDLEvLRAGAA==

After some investigation i found that HwcntyzJaRCSDLEvLRAG corresponds to 1f0727b7-2cc9-6910-920c-b12f2d1006 (without last zero byte).

So, Maxwell is cut the last byte in case of it's value is zero. I suppose Maxwell treat the last zero byte as the "null char".

I'm using maxwell v1.44.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions