• unknown's avatar
    Fix for BUG#2703 · 0aa48dc5
    unknown authored
    "MySQL server does not detect if garbage chars at the end of query":
    
    Detect garbage chars at the end of the query or at the end of a query
    for a prepared statement (which happens if mysql_real_query() or mysql_prepare()
    were called with a too big 'length' parameter (bigger than the real intended
    length of the query: then we receive a query + garbage characters from the
    client). This resulted in garbage chars written into the binlog.
    Now instead the client receives something like:
    'You have an error in your SQL syntax.  Check the manual that corresponds
    to your MySQL server version for the right syntax to use near '!stmt'
    at line 1' i.e. the server is pointing at the weird tail of the query
    (this '!stmt' are the garbage chars sent by the client).
    All tests pass, except mysqldump.test and ctype_utf8.test but they failed
    before the patch.
    
    
    sql/sql_parse.cc:
      Detect garbage chars at the end of the query
      (which happens if mysql_real_query() was called with a too big 'length'
      parameter (bigger than the real intended length of the query: then
      we receive a query + garbage characters from the client).
    sql/sql_prepare.cc:
      Detect garbage chars at the end of the query
      (which happens if mysql_prepare() was called with a too big 'length'
      parameter (bigger than the real intended length of the query: then
      we receive a query + garbage characters from the client).
    tests/client_test.c:
      The change to sql_parse.cc and sql_prepare.cc rightfully gives many
      syntax errors to tests/client_test.c which is full of
      mysql_prepare(mysql, "SHOW TABLES", 100).
      Correcting all these commands.
    0aa48dc5
client_test.c 211 KB