• Nirbhay Choubey's avatar
    Bug#14645196 MYSQL CLIENT'S USE COMMAND FAILS · f820334b
    Nirbhay Choubey authored
    WHEN DBNAME CONTAINS MULTIPLE QUOTES
    
    MySQL client's USE command might fail if the
    database name contains multiple quotes (backticks).
    
    The reason behind the failure being the method
    that client uses to remove/escape the quotes
    while parsing the USE command's option (dbname),
    where the option parsing might terminate if a
    matching quote is found.
    
    Also, C-APIs like mysql_select_db() expect a
    normalized dbname. Now, in certain cases, client
    might fail to normalize dbname similar to that of
    server and hence mysql_select_db() would fail.
    
    Fixed by getting the normalized dbname (indirectly)
    from the server by directly sending the "USE dbanme"
    as query to the server followed by a "SELECT DATABASE()".
    The above steps are only performed if number of quotes
    in the dbname is greater than 2. Once the normalized
    dbname is received, the original db is restored.
    f820334b
mysql.cc 139 KB