• Tatiana A. Nurnberg's avatar
    Bug#43746: YACC return wrong query string when parse 'load data infile' sql statement · 4102363f
    Tatiana A. Nurnberg authored
    "load data" statements were written to the binlog as a mix of the original statement
    and bits recreated from parse-info. This relied on implementation details and broke
    with IGNORE_SPACES and versioned comments.
    
    We now completely resynthesize the query for LOAD DATA for binlog (which among other
    things normalizes them somewhat with regard to case, spaces, etc.).
    We have already parsed the query properly, so we make use of that rather
    than mix-and-match string literals and parsed items.
    This should make us safe with regard to versioned comments, even those
    spanning multiple tokens. Also no longer affected by IGNORE_SPACES.
    
    mysql-test/r/mysqlbinlog.result:
      LOAD DATA INFILE normalized
    mysql-test/suite/binlog/r/binlog_killed_simulate.result:
      LOAD DATA INFILE normalized
    mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result:
      LOAD DATA INFILE normalized
    mysql-test/suite/binlog/r/binlog_stm_blackhole.result:
      LOAD DATA INFILE normalized
    mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
      LOAD DATA INFILE normalized
    mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result:
      LOAD DATA INFILE normalized
    mysql-test/suite/rpl/r/rpl_loaddata.result:
      LOAD DATA INFILE normalized
    mysql-test/suite/rpl/r/rpl_loaddata_fatal.result:
      LOAD DATA INFILE normalized; offsets adjusted to reflect that
    mysql-test/suite/rpl/r/rpl_loaddata_map.result:
      LOAD DATA INFILE normalized
    mysql-test/suite/rpl/r/rpl_loaddatalocal.result:
      test for #43746 - trying to break LOAD DATA part of parser
    mysql-test/suite/rpl/r/rpl_stm_log.result:
      LOAD DATA INFILE normalized
    mysql-test/suite/rpl/t/rpl_loaddatalocal.test:
      try to break the LOAD DATA part of the parser (test for #43746)
    mysql-test/t/mysqlbinlog.test:
      LOAD DATA INFILE normalized; adjust offsets to reflect that
    sql/log_event.cc:
      clean up Load_log_event::print_query and friends so they don't print
      excess spaces. add support for printing charset names to print_query.
    sql/log_event.h:
      We already have three places where we synthesize LOAD DATA queries.
      Better use one of those!
    sql/sql_lex.h:
      When binlogging LOAD DATA statements, we make up the statement to
      be logged (from the parse-info, rather than substrings of the
      original query) now. Consequently, we no longer need (string-)
      pointers into the original query.
    sql/sql_load.cc:
      Completely rewrote write_execute_load_query_log_event() to synthesize the
      LOAD DATA statement wholesale, rather than piece it together from
      synthesized bits and literal excerpts from the original query. This
      will not only give us a nice, normalized statement (all uppercase,
      no excess spaces, etc.), it will also handle comments, including
      versioned comments right, which is certainly more than we can say
      about the previous incarnation.
    sql/sql_yacc.yy:
      We're no longer assembling LOAD DATA statements from bodyparts of the
      original query, so some bookkeeping in the parser can go.
    4102363f
binlog_row_mix_innodb_myisam.result 31.6 KB