From 52cda0fb8a8df9ac37c7dabc401052c0476560cf Mon Sep 17 00:00:00 2001 From: Ben Osheroff Date: Thu, 26 Nov 2015 07:53:45 -0800 Subject: [PATCH] SCHEMA is an alias for DATABASE --- src/main/antlr4/com/zendesk/maxwell/schema/ddl/mysql.g4 | 5 +---- .../java/com/zendesk/maxwell/schema/ddl/DDLParserTest.java | 7 +++++++ 2 files changed, 8 insertions(+), 4 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 15c1b43b7..f25f4791b 100644 --- a/src/main/antlr4/com/zendesk/maxwell/schema/ddl/mysql.g4 +++ b/src/main/antlr4/com/zendesk/maxwell/schema/ddl/mysql.g4 @@ -14,11 +14,8 @@ statement: | BEGIN ; - - - create_database: - CREATE DATABASE if_not_exists? name (default_character_set | default_collate)*; + CREATE (DATABASE | SCHEMA) if_not_exists? name (default_character_set | default_collate)*; create_table: create_table_preamble 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 18b53417c..d9e8a4958 100644 --- a/src/test/java/com/zendesk/maxwell/schema/ddl/DDLParserTest.java +++ b/src/test/java/com/zendesk/maxwell/schema/ddl/DDLParserTest.java @@ -360,6 +360,13 @@ public void testCreateDatabase() { assertThat(create.encoding, is("latin1")); } + @Test + public void testCreateSchema() { + List changes = parse("CREATE SCHEMA if not exists `foo`"); + DatabaseCreate create = (DatabaseCreate) changes.get(0); + assertThat(create.dbName, is("foo")); + } + @Test public void testCommentSyntax() { List changes = parse("CREATE DATABASE if not exists `foo` default character set='latin1' /* generate by server */");