Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-4004

Empty variable names allowed and break replication

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5.29
    • Fix Version/s: 5.5.31
    • Component/s: None
    • Labels:

      Description

      The original description can be found further in this field

      The problem is reproducible with MySQL 5.1-5.6 and filed as http://bugs.mysql.com/bug.php?id=68135.

      A variable can be created with an empty name. Apparently, it's confusing (see the original request below) and potentially error-prone; but it also causes problems with binary logging and replication:

      SET @`` = 1;
      CREATE TABLE t1 AS SELECT @`` AS f;
      SHOW BINLOG EVENTS;
      ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
      

      Consequently, replication fails with ER_SLAVE_RELAY_LOG_READ_FAILURE.

      Currently it's only reproducible on maria/5.5, but not on maria/5.1, 5.2, 5.3 or 10.0-base. However, I suppose it's just a matter of time, since it came to maria/5.5 with the last mysql-5.1.67 merge, and it exists in all current trees of MySQL.

      Test case:

      
      --source include/master-slave.inc
      --source include/have_binlog_format_statement.inc
      
      SET @`` = 1;
      CREATE TABLE t1 AS SELECT @`` AS f;
      
      --sync_slave_with_master
      

      ==================================

      Original description

      I'm not sure if this is a bug or a feature request. Empty names seem to be allowed for variables. No warnings.
      Empty names are not allowed for schemas, tables, columns, views, etc.

      
      MariaDB [test]> SET @`` = 1;
      Query OK, 0 rows affected (0.00 sec)
      
      MariaDB [test]> SELECT @``;
      +------+
      | @``  |
      +------+
      |    1 |
      +------+
      1 row in set (0.07 sec)
      
      MariaDB [test]>
      
      

      The same happens with local vars in stored routines:

      
      DROP FUNCTION IF EXISTS `test`;
      CREATE FUNCTION `test`()
      	RETURNS BOOLEAN
      BEGIN
      	DECLARE `` TINYINT UNSIGNED;
      	SET `` = 1;
      	RETURN ``;
      END;
      
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              elenst Elena Stepanova added a comment -

              Hi Federico,

              I suppose as a feature request it wouldn't stand much of a chance, not because it's unreasonable, but because it would almost inevitably cause compatibility issues – replication from an old slave to a new master, stored procedures which use an empty name, etc., and of course for MariaDb also compatibility with the upstream.

              However, it turns out there is a bug with empty names, most likely a regression, which causes replication problems. I've updated the description and refiled it to MySQL bug base, and mentioned your request there, too. I doubt, however, that the bug will make Oracle forbid empty names, on the same reason of breaking compatibility with older versions; and if they don't, we can't either.

              Thanks for the report, it revealed a serious issue.

              Show
              elenst Elena Stepanova added a comment - Hi Federico, I suppose as a feature request it wouldn't stand much of a chance, not because it's unreasonable, but because it would almost inevitably cause compatibility issues – replication from an old slave to a new master, stored procedures which use an empty name, etc., and of course for MariaDb also compatibility with the upstream. However, it turns out there is a bug with empty names, most likely a regression, which causes replication problems. I've updated the description and refiled it to MySQL bug base, and mentioned your request there, too. I doubt, however, that the bug will make Oracle forbid empty names, on the same reason of breaking compatibility with older versions; and if they don't, we can't either. Thanks for the report, it revealed a serious issue.
              Hide
              f_razzoli Federico Razzoli added a comment -

              Hi Elena
              I agree that it is serious, for this reason: I can hardly beilive that someone wants to use an empty name. I did it, but my SQL was generated by a buggy PHP script. In such cases, a warning would make debugging easier.
              However, I admit that in some weird cases buggy code can provide the expected output, so I understand that breaking compatibility is a bad thing.

              Show
              f_razzoli Federico Razzoli added a comment - Hi Elena I agree that it is serious, for this reason: I can hardly beilive that someone wants to use an empty name. I did it, but my SQL was generated by a buggy PHP script. In such cases, a warning would make debugging easier. However, I admit that in some weird cases buggy code can provide the expected output, so I understand that breaking compatibility is a bad thing.
              Hide
              elenst Elena Stepanova added a comment -

              A comment from the corresponding MySQL bug report:

              "
              Fixed in 5.1+. Documented in the 5.1.69, 5.5.31, 5.6.11, and 5.7.1 changelogs as follows:

              A zero-length name for a user variable was incorrectly considered to be a sign of data corruption and thus was not written to the binary log.
              "

              So I suppose they haven't made an empty name illegal.

              Show
              elenst Elena Stepanova added a comment - A comment from the corresponding MySQL bug report: " Fixed in 5.1+. Documented in the 5.1.69, 5.5.31, 5.6.11, and 5.7.1 changelogs as follows: A zero-length name for a user variable was incorrectly considered to be a sign of data corruption and thus was not written to the binary log. " So I suppose they haven't made an empty name illegal.
              Hide
              serg Sergei Golubchik added a comment -

              fixed by the mysql-5.5.31 merge

              Show
              serg Sergei Golubchik added a comment - fixed by the mysql-5.5.31 merge

                People

                • Assignee:
                  serg Sergei Golubchik
                  Reporter:
                  f_razzoli Federico Razzoli
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: