diff --git a/Documentation/Getting-Started/Configuration-Guide.md b/Documentation/Getting-Started/Configuration-Guide.md index 722e88068..bec5bc220 100644 --- a/Documentation/Getting-Started/Configuration-Guide.md +++ b/Documentation/Getting-Started/Configuration-Guide.md @@ -519,6 +519,35 @@ This will log all statements that cannot be parsed completely. This may be useful if you suspect that MariaDB MaxScale routes statements to the wrong server (e.g. to a slave instead of to a master). +#### `sql_mode` + +Specifies whether the query classifier parser should initially expect _MariaDB_ +or _PL/SQL_ kind of SQL. + +The allowed values are: + `default`: The parser expects regular _MariaDB_ SQL. + `oracle` : The parser expects PL/SQL. + +``` +sql_mode=oracle +``` + +The default value is `default`, which is also used if no value is specified +or if `sql_mode=` is not present at all. At runtime, MariaDB MaxScale will +recognize statements like +``` +set sql_mode=oracle; +``` +and +``` +set sql_mode=default; +``` +and change mode accordingly. + +Note that MariaDB MaxScale is **not** explicitly aware of the sql mode of +the server, so the value of `sql_mode` should reflect the sql mode used +when the server is started. + ### Service A service represents the database service that MariaDB MaxScale offers to the diff --git a/include/maxscale/config.h b/include/maxscale/config.h index 813eaaf43..21156f85e 100644 --- a/include/maxscale/config.h +++ b/include/maxscale/config.h @@ -23,6 +23,7 @@ #include #include +#include MXS_BEGIN_DECLS @@ -74,6 +75,7 @@ typedef struct bool skip_permission_checks; /**< Skip service and monitor permission checks */ char qc_name[PATH_MAX]; /**< The name of the query classifier to load */ char* qc_args; /**< Arguments for the query classifier */ + qc_sql_mode_t qc_sql_mode; /**< The query classifier sql mode */ } MXS_CONFIG; /** diff --git a/server/core/config.c b/server/core/config.c index d3065c7d6..06e39f521 100644 --- a/server/core/config.c +++ b/server/core/config.c @@ -13,36 +13,6 @@ /** * @file config.c - Read the gateway.cnf configuration file - * - * @verbatim - * Revision History - * - * Date Who Description - * 21/06/13 Mark Riddoch Initial implementation - * 08/07/13 Mark Riddoch Addition on monitor module support - * 23/07/13 Mark Riddoch Addition on default monitor password - * 06/02/14 Massimiliano Pinto Added support for enable/disable root user in services - * 14/02/14 Massimiliano Pinto Added enable_root_user in the service_params list - * 11/03/14 Massimiliano Pinto Added Unix socket support - * 11/05/14 Massimiliano Pinto Added version_string support to service - * 19/05/14 Mark Riddoch Added unique names from section headers - * 29/05/14 Mark Riddoch Addition of filter definition - * 23/05/14 Massimiliano Pinto Added automatic set of maxscale-id: first listening ipv4_raw + port + pid - * 28/05/14 Massimiliano Pinto Added detect_replication_lag parameter - * 28/08/14 Massimiliano Pinto Added detect_stale_master parameter - * 09/09/14 Massimiliano Pinto Added localhost_match_wildcard_host parameter - * 12/09/14 Mark Riddoch Addition of checks on servers list and - * internal router suppression of messages - * 30/10/14 Massimiliano Pinto Added disable_master_failback parameter - * 07/11/14 Massimiliano Pinto Addition of monitor timeouts for connect/read/write - * 20/02/15 Markus Mäkelä Added connection_timeout parameter for services - * 05/03/15 Massimiliano Pinto Added notification_feedback support - * 20/04/15 Guillaume Lefranc Added available_when_donor parameter - * 22/04/15 Martin Brampton Added disable_master_role_setting parameter - * 26/01/16 Martin Brampton Transfer SSL processing to listener - * 31/05/16 Martin Brampton Implement connection throttling, initially no queue - * - * @endverbatim */ #include @@ -1305,6 +1275,22 @@ handle_global_item(const char *name, const char *value) { gateway.qc_args = MXS_STRDUP_A(value); } + else if (strcmp(name, "sql_mode") == 0) + { + if ((*value == 0) || (strcasecmp(value, "default") == 0)) + { + gateway.qc_sql_mode = QC_SQL_MODE_DEFAULT; + } + else if (strcasecmp(value, "oracle") == 0) + { + gateway.qc_sql_mode = QC_SQL_MODE_ORACLE; + } + else + { + MXS_ERROR("'%s' is not a valid value for '%s'. Allowed values are 'DEFAULT' and " + "'ORACLE'. Using 'DEFAULT' as default.", value, name); + } + } else if (strcmp(name, "log_throttling") == 0) { if (*value == 0) diff --git a/server/core/gateway.cc b/server/core/gateway.cc index 8333a6d6f..4b0874aea 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -1897,7 +1897,7 @@ int main(int argc, char **argv) cnf = config_get_global_options(); ss_dassert(cnf); - if (!qc_setup(cnf->qc_name, QC_SQL_MODE_DEFAULT, cnf->qc_args)) + if (!qc_setup(cnf->qc_name, cnf->qc_sql_mode, cnf->qc_args)) { const char* logerr = "Failed to initialise query classifier library."; print_log_n_stderr(true, true, logerr, logerr, eno);