Uploaded image for project: 'MariaDB MaxScale'
  1. MariaDB MaxScale
  2. MXS-1048

ShemaRouter can't handle backquoted database names

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.0.3
    • Component/s: schemarouter
    • 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 <
      

        Attachments

          Activity

            People

            Assignee:
            markus makela markus makela
            Reporter:
            wrossmann Wade Rossmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration