Skip to content
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

Cannot get real integer value when integer column set unsigned #104

Closed
pensz opened this issue Jul 25, 2016 · 1 comment
Closed

Cannot get real integer value when integer column set unsigned #104

pensz opened this issue Jul 25, 2016 · 1 comment

Comments

@pensz
Copy link

pensz commented Jul 25, 2016

example SQL:

CREATE TABLE `binlog_test` (
  `id` smallint(5) unsigned NOT NULL,
  `intid` int(10) unsigned DEFAULT NULL,
  `bigintid` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

insert into binlog_test set id = 41002, intid=4294967293, bigintid=9223372036854775817;

in binlog, we can see such statement:

### INSERT INTO t_db.binlog_test
### SET
###   @1=-24534 (41002) /* SHORTINT meta=0 nullable=0 is_null=0 */
###   @2=-3 (4294967293) /* INT meta=0 nullable=1 is_null=0 */
###   @3=-9223372036854775799 (9223372036854775817) /* LONGINT meta=0 nullable=1 is_null=0 */

when we use WriteRowsEventData.getRows, we get the negative numers, not the real value.

@shyiko
Copy link
Owner

shyiko commented Jul 25, 2016

Hi.

This issue is mentioned in readme.md/implementation-notes. The problem is - binary log doesn't have information about whether column is unsigned or not and so there is no way for mysql-binlog-connector-java to do the conversion automatically. You'll have to read the column definition (using something similar to #24 (comment)) and do the conversion yourself.

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

No branches or pull requests

2 participants