Zendesk's Maxwell Compatibility (#119)

* Binlog router: Introduce maxwell_compatibility flag

* Binlog router: Handle 'server vars' query

This is a step towards using MaxScale with Zendesk's Maxwell.

* Binlog router: Handle results charset query

* Binlog router: Handle sql_mode query

* Binlog router: Handle server_id query

* Binlog router: Handle 'binlog vars' queries

* Binlog router: Handle @@lower_case_table_names query

* Binlog router: Handle @@global.binlog_checksum query

* Binlog router: DRY Maxwell SQL queries
This commit is contained in:
Adam Szkoda
2017-02-13 16:40:01 +01:00
committed by MassimilianoPinto
parent fdc66c660c
commit 825782799f
6 changed files with 300 additions and 39 deletions

View File

@ -637,6 +637,30 @@ blr_master_response(ROUTER_INSTANCE *router, GWBUF *buf)
}
router->saved_master.utf8 = buf;
blr_cache_response(router, "utf8", buf);
if (router->maxwell_compat)
{
buf = blr_make_query(router->master, "SET character_set_results = NULL");
router->master_state = BLRM_RESULTS_CHARSET;
router->master->func.write(router->master, buf);
}
else
{
buf = blr_make_query(router->master, "SELECT 1");
router->master_state = BLRM_SELECT1;
router->master->func.write(router->master, buf);
}
break;
case BLRM_RESULTS_CHARSET:
gwbuf_free(buf);
buf = blr_make_query(router->master, MYSQL_CONNECTOR_SQL_MODE_QUERY);
router->master_state = BLRM_SQL_MODE;
router->master->func.write(router->master, buf);
break;
case BLRM_SQL_MODE:
gwbuf_free(buf);
buf = blr_make_query(router->master, "SELECT 1");
router->master_state = BLRM_SELECT1;
router->master->func.write(router->master, buf);
@ -697,6 +721,44 @@ blr_master_response(ROUTER_INSTANCE *router, GWBUF *buf)
}
router->saved_master.map = buf;
blr_cache_response(router, "map", buf);
// Query for Server Variables
buf = blr_make_query(router->master, MYSQL_CONNECTOR_SERVER_VARS_QUERY);
router->master_state = BLRM_SERVER_VARS;
router->master->func.write(router->master, buf);
break;
case BLRM_SERVER_VARS:
if (router->saved_master.server_vars)
{
GWBUF_CONSUME_ALL(router->saved_master.server_vars);
}
router->saved_master.server_vars = buf;
blr_cache_response(router, "server_vars", buf);
buf = blr_make_query(router->master, "SELECT IF(@@global.log_bin, 'ON', 'OFF'), @@global.binlog_format, @@global.binlog_row_image");
router->master_state = BLRM_BINLOG_VARS;
router->master->func.write(router->master, buf);
break;
case BLRM_BINLOG_VARS:
if (router->saved_master.binlog_vars)
{
GWBUF_CONSUME_ALL(router->saved_master.binlog_vars);
}
router->saved_master.binlog_vars = buf;
blr_cache_response(router, "binlog_vars", buf);
buf = blr_make_query(router->master, "select @@lower_case_table_names");
router->master_state = BLRM_LOWER_CASE_TABLES;
router->master->func.write(router->master, buf);
break;
case BLRM_LOWER_CASE_TABLES:
if (router->saved_master.lower_case_tables)
{
GWBUF_CONSUME_ALL(router->saved_master.lower_case_tables);
}
router->saved_master.lower_case_tables = buf;
blr_cache_response(router, "lower_case_tables", buf);
buf = blr_make_registration(router);
router->master_state = BLRM_REGISTER;
router->master->func.write(router->master, buf);