From bf3083ff86f287526a200f7af5f6bde2d50b9ca9 Mon Sep 17 00:00:00 2001 From: Ben Osheroff Date: Sun, 30 Aug 2015 19:22:23 -0700 Subject: [PATCH] ignore the BINARY flag in string column creation a quick spelunk into the mysql source code shows that this flag only affects the collation of the column. We don't give even the slightest care about that, so we'll parse and ignore it. --- src/main/antlr4/com/zendesk/maxwell/schema/ddl/mysql.g4 | 1 - src/main/antlr4/imports/column_definitions.g4 | 4 +++- .../java/com/zendesk/maxwell/schema/ddl/DDLParserTest.java | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/antlr4/com/zendesk/maxwell/schema/ddl/mysql.g4 b/src/main/antlr4/com/zendesk/maxwell/schema/ddl/mysql.g4 index a97c445bd..ea1905d2e 100644 --- a/src/main/antlr4/com/zendesk/maxwell/schema/ddl/mysql.g4 +++ b/src/main/antlr4/com/zendesk/maxwell/schema/ddl/mysql.g4 @@ -27,7 +27,6 @@ create_table: | create_like_tbl ); -// TODO: support if-not-exists create_table_preamble: CREATE TEMPORARY? TABLE (IF NOT EXISTS)? table_name; create_specifications: '(' create_specification (',' create_specification)* ')'; diff --git a/src/main/antlr4/imports/column_definitions.g4 b/src/main/antlr4/imports/column_definitions.g4 index e859850f8..5a5f17e45 100644 --- a/src/main/antlr4/imports/column_definitions.g4 +++ b/src/main/antlr4/imports/column_definitions.g4 @@ -38,8 +38,10 @@ signed_type: // we need the UNSIGNED flag here string_type: // getting the encoding here col_type=(CHAR | VARCHAR) length? + BINARY? charset_def? - | col_type=(TINYTEXT | TEXT | MEDIUMTEXT | LONGTEXT) + | col_type=(TINYTEXT | TEXT | MEDIUMTEXT | LONGTEXT) + BINARY? charset_def? ; diff --git a/src/test/java/com/zendesk/maxwell/schema/ddl/DDLParserTest.java b/src/test/java/com/zendesk/maxwell/schema/ddl/DDLParserTest.java index a58a4f4a9..f9af60f41 100644 --- a/src/test/java/com/zendesk/maxwell/schema/ddl/DDLParserTest.java +++ b/src/test/java/com/zendesk/maxwell/schema/ddl/DDLParserTest.java @@ -358,4 +358,9 @@ public void testCurrentTimestamp() { assertThat(changes.size(), is(1)); } + @Test + public void testBinaryChar() { + List changes = parse("CREATE TABLE `foo` ( `id` char(16) BINARY character set 'utf8' )"); + assertThat(changes.size(), is(1)); + } }