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

[PATCH] mysqlcheck wrongly escapes '.' in table names

Details

    Description

      mysqlcheck encloses dots in a table in backticks, this doesn't make sense though as never expects to see a db.table combination (database and table names are passed in as separate parameters)

      This breaks mysqlcheck, and indirectly mysql_upgrade, for tables with a dot in their name

      test case:

        CREATE TABLE test.`foo.bar`(id int primary key);

      then run

        mysqlcheck test foo.bar

      or

        mysql_upgrade --force

      This was introduced in revision 1810.3494.1 ( http://bazaar.launchpad.net/~mysql/mysql-server/5.6/revision/1810.3494.1 ) as part of a fix for http://bugs.mysql.com/bug.php?id=30654

      Attachments

        Activity

          hholzgra Hartmut Holzgraefe created issue -
          hholzgra Hartmut Holzgraefe added a comment - - edited

          proposed fix:

          === modified file 'client/mysqlcheck.c'
          --- client/mysqlcheck.c	2013-05-07 11:05:09 +0000
          +++ client/mysqlcheck.c	2014-04-17 12:57:31 +0000
          @@ -513,8 +513,6 @@
             {
               if (*p == '`')
                 extra_length++;
          -    else if (*p == '.')
          -      extra_length+= 2;
           
             }
             DBUG_RETURN((uint) ((p - name) + extra_length));
          @@ -529,11 +527,6 @@
             for (; *src; src++)
             {
               switch (*src) {
          -    case '.':            /* add backticks around '.' */
          -      *dest++= '`';
          -      *dest++= '.';
          -      *dest++= '`';
          -      break;
               case '`':            /* escape backtick character */
                 *dest++= '`';
                 /* fall through */

          hholzgra Hartmut Holzgraefe added a comment - - edited proposed fix: === modified file 'client/mysqlcheck.c' --- client/mysqlcheck.c 2013-05-07 11:05:09 +0000 +++ client/mysqlcheck.c 2014-04-17 12:57:31 +0000 @@ -513,8 +513,6 @@ { if (*p == '`') extra_length++; - else if (*p == '.') - extra_length+= 2; } DBUG_RETURN((uint) ((p - name) + extra_length)); @@ -529,11 +527,6 @@ for (; *src; src++) { switch (*src) { - case '.': /* add backticks around '.' */ - *dest++= '`'; - *dest++= '.'; - *dest++= '`'; - break; case '`': /* escape backtick character */ *dest++= '`'; /* fall through */

          proposed patch

          hholzgra Hartmut Holzgraefe added a comment - proposed patch
          hholzgra Hartmut Holzgraefe made changes -
          Field Original Value New Value
          Attachment mdev-6128.patch [ 29117 ]

          looks as if this is fixed in 5.7, but something is odd about it on launchpad

          check

          http://bazaar.launchpad.net/~mysql/mysql-server/5.6/annotate/head:/client/mysqlcheck.c#L52...

          and

          http://bazaar.launchpad.net/~mysql/mysql-server/5.7/annotate/head:/client/mysqlcheck.c#L52...

          the code escaping the '.' is gone in 5.7, but launchpad still lists the old changeset from 2007 for this part of the code?

          see also http://bugs.mysql.com/bug.php?id=72382

          hholzgra Hartmut Holzgraefe added a comment - looks as if this is fixed in 5.7, but something is odd about it on launchpad check http://bazaar.launchpad.net/~mysql/mysql-server/5.6/annotate/head:/client/mysqlcheck.c#L52 ... and http://bazaar.launchpad.net/~mysql/mysql-server/5.7/annotate/head:/client/mysqlcheck.c#L52 ... the code escaping the '.' is gone in 5.7, but launchpad still lists the old changeset from 2007 for this part of the code? see also http://bugs.mysql.com/bug.php?id=72382

          Oracle's actual fix change sets are here:

          http://bazaar.launchpad.net/~mysql/mysql-server/5.7/revision/7416
          http://bazaar.launchpad.net/~mysql/mysql-server/5.7/revision/7481

          looks as if there is a little more work needed as at some point it actually used db.table names internally ...

          my local 5.7 checkout also shows the wrong old changeset with "bzr annotate client/mysqlcheck.c",
          but "bzr log client/mysqlcheck.c" so there seems to be a bzr bug? Or has Oracle somehow managed to corrupt their 5.7 tree?

          hholzgra Hartmut Holzgraefe added a comment - Oracle's actual fix change sets are here: http://bazaar.launchpad.net/~mysql/mysql-server/5.7/revision/7416 http://bazaar.launchpad.net/~mysql/mysql-server/5.7/revision/7481 looks as if there is a little more work needed as at some point it actually used db.table names internally ... my local 5.7 checkout also shows the wrong old changeset with "bzr annotate client/mysqlcheck.c", but "bzr log client/mysqlcheck.c" so there seems to be a bzr bug? Or has Oracle somehow managed to corrupt their 5.7 tree?
          elenst Elena Stepanova made changes -
          Fix Version/s 10.0.12 [ 15201 ]
          Fix Version/s 5.5.38 [ 15400 ]
          Affects Version/s 5.5.37 [ 15000 ]
          Affects Version/s 10.0.10 [ 14500 ]
          Affects Version/s 10.0.7 [ 14100 ]
          Affects Version/s 10.0.7-galera [ 14800 ]
          Labels upstream
          elenst Elena Stepanova made changes -
          elenst Elena Stepanova made changes -
          elenst Elena Stepanova made changes -
          elenst Elena Stepanova made changes -
          Summary mysqlcheck wrongly escapes '.' in table names [PATCH] mysqlcheck wrongly escapes '.' in table names
          serg Sergei Golubchik made changes -
          Description mysqlcheck encloses dots in a table in backticks, this doesn't make sense though as never expects to see a db.table combination (database and table names are passed in as separate parameters)

          This breaks mysqlcheck, and indirectly mysql_upgrade, for tables with a dot in their name

          test case:

            CREATE TABLE test.`foo.bar`(id int primary key);

          then run

            mysqlcheck test foo.bar

          or

            mysql_upgrade --force

          This was introduced in revision 1810.3494.1 ( http://bazaar.launchpad.net/~mysql/mysql-server/5.6/revision/1810.3494.1 ) as part of a fix for http://bugs.mysql.com/bug.php?id=30654
          mysqlcheck encloses dots in a table in backticks, this doesn't make sense though as never expects to see a db.table combination (database and table names are passed in as separate parameters)

          This breaks mysqlcheck, and indirectly mysql_upgrade, for tables with a dot in their name

          test case:
          {code:sql}
            CREATE TABLE test.`foo.bar`(id int primary key);
          {code}
          then run
          {noformat}
            mysqlcheck test foo.bar
          {noformat}
          or
          {noformat}
            mysql_upgrade --force
          {noformat}
          This was introduced in revision 1810.3494.1 ( http://bazaar.launchpad.net/~mysql/mysql-server/5.6/revision/1810.3494.1 ) as part of a fix for http://bugs.mysql.com/bug.php?id=30654
          serg Sergei Golubchik made changes -
          Priority Minor [ 4 ] Major [ 3 ]
          serg Sergei Golubchik made changes -
          Priority Major [ 3 ] Minor [ 4 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 5.5.39 [ 15800 ]
          Fix Version/s 5.5.38 [ 15400 ]
          serg Sergei Golubchik made changes -
          Workflow defaullt [ 38946 ] MariaDB v2 [ 43150 ]
          serg Sergei Golubchik made changes -
          Fix Version/s 10.0.13 [ 16000 ]
          Fix Version/s 10.0.12 [ 15201 ]
          sanja Oleksandr Byelkin made changes -
          Assignee Oleksandr Byelkin [ sanja ]
          sanja Oleksandr Byelkin made changes -
          Priority Minor [ 4 ] Critical [ 2 ]
          sanja Oleksandr Byelkin made changes -
          Status Open [ 1 ] In Progress [ 3 ]

          test suite (just for record):

          CREATE TABLE test.`t.1` (id int);
           
          --echo mysqlcheck test t.1
          --exec $MYSQL_CHECK test t.1
           
          drop table test.`t.1`;

          sanja Oleksandr Byelkin added a comment - test suite (just for record): CREATE TABLE test.`t.1` (id int);   --echo mysqlcheck test t.1 --exec $MYSQL_CHECK test t.1   drop table test.`t.1`;

          patch is pushed to 5.5

          sanja Oleksandr Byelkin added a comment - patch is pushed to 5.5
          sanja Oleksandr Byelkin made changes -
          Component/s OTHER [ 10125 ]
          Fix Version/s 10.0.17 [ 18300 ]
          Fix Version/s 10.1.3 [ 18000 ]
          Fix Version/s 5.5.42 [ 18102 ]
          Fix Version/s 5.5 [ 15800 ]
          Fix Version/s 10.0 [ 16000 ]
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Closed [ 6 ]
          ratzpo Rasmus Johansson (Inactive) made changes -
          Workflow MariaDB v2 [ 43150 ] MariaDB v3 [ 66173 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 66173 ] MariaDB v4 [ 147807 ]

          People

            sanja Oleksandr Byelkin
            hholzgra Hartmut Holzgraefe
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.