On the way to

MySQL Proxy: replicating into memcache

I have another small side project:

  • translating Row based log-records into Statement ones.

Our support team was asking for it since a while and it was a nice PoC that I can decode RBR events nicely.

Running MySQL 5.1 (with binlog_format = ROW) I issued:

mysql> INSERT INTO cols_pk VALUES \
     ( 3, "varchar", "char" ), ( 4, NULL, NULL );

... and have let mysql-binlog-dump decode the row-based log-events into SQL statements:

$ ./mysql-binlog-dump \
  --binlog-file=/home/jan/datadir/mysql-bin.000010

-- mysql-binlog-dump.c:256: db = test
BEGIN

-- mysql-binlog-dump.c:220:
CREATE TABLE test.cols_pk (
  field_0 INT NOT NULL,
  field_1 VARCHAR(64) DEFAULT NULL,
  field_2 CHAR(64) DEFAULT NULL
)

-- mysql-binlog-dump.c:506:
INSERT INTO test.cols_pk VALUES
  (3, 'varchar', 'char')

-- mysql-binlog-dump.c:506:
INSERT INTO test.cols_pk VALUES
  (4, NULL, NULL)

-- mysql-binlog-dump.c:256: db = test
COMMIT

We have to create new field-names as the RBR-events only contain column-numbers. The CREATE TABLE statement (in the same fashion) isn't providing any PK or Index information.

BTW, mysql-binlog-dump is part of the proxy-svn tree.


Comments

Enable javascript to load comments.