Added configurable multistatement behavior

Whether all queries should be routed to the master after a multistatement
query is executed can now be controlled with the `strict_multi_stmt` option.

When the option is disabled queries executed after a multistatement query will
be routed normally.
This commit is contained in:
Markus Makela
2016-03-01 10:45:08 +02:00
parent ac007fa8f5
commit bf1a789376
4 changed files with 33 additions and 2 deletions

View File

@ -696,7 +696,10 @@ createInstance(SERVICE *service, char **options)
*/
router->bitmask = 0;
router->bitvalue = 0;
/** Enable strict multistatement handling by default */
router->rwsplit_config.rw_strict_multi_stmt = true;
/** Call this before refreshInstance */
if (options)
{
@ -1384,7 +1387,7 @@ static route_target_t get_route_target(ROUTER_CLIENT_SES *rses,
target_t use_sql_variables_in = rses->rses_config.rw_use_sql_variables_in;
route_target_t target = TARGET_UNDEFINED;
if (rses->forced_node == rses->rses_master_ref)
if (rses->rses_config.rw_strict_multi_stmt && rses->forced_node == rses->rses_master_ref)
{
target = TARGET_MASTER;
}
@ -4640,6 +4643,10 @@ static void rwsplit_process_router_options(
{
router->rwsplit_config.rw_master_reads = config_truth_value(value);
}
else if(strcmp(options[i],"strict_multi_stmt") == 0)
{
router->rwsplit_config.rw_strict_multi_stmt = config_truth_value(value);
}
}
} /*< for */
}