[MXS-1048] ShemaRouter can't handle backquoted database names Created: 2016-12-07  Updated: 2016-12-20  Resolved: 2016-12-13

Status: Closed
Project: MariaDB MaxScale
Component/s: schemarouter
Affects Version/s: 2.0.2
Fix Version/s: 2.0.3

Type: Bug Priority: Major
Reporter: Wade Rossmann Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None
Environment:

Centos7 x64



 Description   

It seems that SchemaRouter does not attempt to strip backquotes from database names, instead using the string as-is which fails to match databases that actually exist. For example:

USE statements:

info   : > Cmd: COM_QUERY, type: QUERY_TYPE_SESSION_WRITE, stmt: USE `foo_db`;
info   : change_current_db: INIT_DB with database '`foo_db`'
error  : Changing database failed.
 
info   : > Cmd: COM_QUERY, type: QUERY_TYPE_SESSION_WRITE, stmt: USE foo_db;
info   : change_current_db: INIT_DB with database 'foo_db'
info   : change_current_db: database is on server: 'srv-foo'.

SHOW TABLES FROM statements:

info   : > Cmd: COM_QUERY, type: QUERY_TYPE_SHOW_TABLES, stmt: SHOW TABLES FROM `foo_db`;
info   : schemarouter: SHOW TABLES query, current database '' on server '(null)'
info   : schemarouter: SHOW TABLES query, current database '' on server '(null)'
info   : schemarouter: Routing query to first available backend.
info   : Route query to     wrongserver.example.com:3306 <
 
info   : > Cmd: COM_QUERY, type: QUERY_TYPE_SHOW_TABLES, stmt: SHOW TABLES FROM foo_db;
info   : schemarouter: SHOW TABLES with specific database 'foo_db' on server 'srv_foo'
info   : Route query to     rightserver.example.com:3306 <

As a note on testing this, the mysql CLI seems to intercept USE statements and issue what I assume is an API call to the server instead. This makes the statement successful regardless of backquoting, and I wasted quite a bit of time trying to decipher this behaviour.

For reference, the above show up in the logs as:

info   : > Cmd: COM_QUERY, type: QUERY_TYPE_READ, stmt: SELECT DATABASE()
info   : schemarouter: Routing query to first available backend.
info   : Route query to     wrongserver.example.com:3306 <
info   : schemarouter: returning reply [RSET] state [READY]  session [0xb9d190]
info   : > Cmd: COM_INIT_DB, type: QUERY_TYPE_SESSION_WRITE, stmt: foo_db
info   : change_current_db: INIT_DB with database 'foo_db'
info   : change_current_db: database is on server: 'srv-foo'.
info   : schemarouter: INIT_DB for database 'foo_db' on server 'srv-foo'
info   : Route query to     rightserver.example.com:3306 <



 Comments   
Comment by markus makela [ 2016-12-13 ]

Backquoted database names are now properly processed.

Comment by Wade Rossmann [ 2016-12-20 ]

You are the man now, dawg.

Generated at Thu Feb 08 04:03:51 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.