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

debian-start erroneously reports issues due to table names not being escaped properly

Details

    Description

      Every time I restart my MariaDB server, it comes up with multiple instances of the same two errors in an email to me titled "WARNING: mariadb-check has found corrupt tables".

      However, these tables are NOT corrupt. There are two errors occurring here which are BOTH due to the table names not being escaped properly:

      • The use of a '-' symbol in the database table name which the script calling mariadb-check isn't escaping
      • The use of a space character in the database table name which the script calling mariadb-check isn't escaping

      The two examples (also showing that they both work when the database and table names are escaped with a back-tick) are:

      MariaDB [(none)]> select count(*) into @discard from mydatabase.mytable-dev;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-dev' at line 1
      MariaDB [(none)]> select count(*) into @discard from `mydatabase`.`mytable-dev`;
      Query OK, 1 row affected (0.000 sec)
       
      MariaDB [(none)]>

      and

      MariaDB [(none)]> select count(*) into @discard from mydatabase.mytable name;
      ERROR 1146 (42S02): Table 'mydatabase.mytable' doesn't exist
      MariaDB [(none)]> select count(*) into @discard from `mydatabase`.`mytable name`;
      Query OK, 1 row affected (0.001 sec)
       
      MariaDB [(none)]>

      I have traced this down to a the following change to debian/additions/debian-start.inc.sh:
      https://github.com/MariaDB/server/commit/2adaf5c261df948dc89a2c2520000f8f886184b4

      I have fixed my local copy by replacing the 4 instances of the now-superflous '\'' with a single back-tick. The upstream change author seems to have missed that the reason for the apostrophe combination was that the text was previously enclosed with single-quotes. I don't quite understand why the back-ticks were removed.

      Happy to submit a push / merge request of my change into the repository, if I can get access to do so.

      Attachments

        Issue Links

          Activity

            alexpresland477 Alex Presland added a comment -

            Looks good to me. I see that you haven't included the comment changes, which leaves the code mis-matching the comments.

            Not sure what testing that I can do, but I'll have a deeper look this weekend.

            alexpresland477 Alex Presland added a comment - Looks good to me. I see that you haven't included the comment changes, which leaves the code mis-matching the comments. Not sure what testing that I can do, but I'll have a deeper look this weekend.

            Sorry totally somehow ignored them. Now PR is updated with comments also. I was wondering why this have been made and found it comes from Debian commit: https://salsa.debian.org/mariadb-team/mariadb-server/-/commit/0300a9157cc69f75e01ac9c0d6e033d8be661492 which removes back-ticks and leaves \' as there were before bit obscure \'` combination.
            Bug is bit difficult to test as it needs crashed MyISAM tables (Aria is auto recovery) which should be fixed. Only way I found is to install in docker/podman and then just kill the server and see if there is error first and then after restart there should not be.

            illuusio Tuukka Pasanen added a comment - Sorry totally somehow ignored them. Now PR is updated with comments also. I was wondering why this have been made and found it comes from Debian commit: https://salsa.debian.org/mariadb-team/mariadb-server/-/commit/0300a9157cc69f75e01ac9c0d6e033d8be661492 which removes back-ticks and leaves \' as there were before bit obscure \'` combination. Bug is bit difficult to test as it needs crashed MyISAM tables (Aria is auto recovery) which should be fixed. Only way I found is to install in docker/podman and then just kill the server and see if there is error first and then after restart there should not be.
            alexpresland477 Alex Presland added a comment -

            I found it easy to test this change. Before my change, I got an email for every table with "-" or " " (space) in the name when the database was restarted. After the change I didn't. I did parallel testing to look a the queries generated by the script both before and after my change, and the output post-change looked good.

            alexpresland477 Alex Presland added a comment - I found it easy to test this change. Before my change, I got an email for every table with "-" or " " (space) in the name when the database was restarted. After the change I didn't. I did parallel testing to look a the queries generated by the script both before and after my change, and the output post-change looked good.

            Ok this is good indicator that it's fixed. I'll test can that be used as testing point that this won't comeback.

            illuusio Tuukka Pasanen added a comment - Ok this is good indicator that it's fixed. I'll test can that be used as testing point that this won't comeback.
            alexpresland477 Alex Presland added a comment -

            Another good indication that my fix was working is that when the MariaDB packages were upgraded the /usr/share/mysql/debian-start.inc.sh file reverted to its original version and I started getting the erroneous emails again every time the server was rebooted and/or MariaDB was restarted. I've re-patched my local copy and the erroneous email is no longer generated on restart.

            alexpresland477 Alex Presland added a comment - Another good indication that my fix was working is that when the MariaDB packages were upgraded the /usr/share/mysql/debian-start.inc.sh file reverted to its original version and I started getting the erroneous emails again every time the server was rebooted and/or MariaDB was restarted. I've re-patched my local copy and the erroneous email is no longer generated on restart.

            People

              Unassigned Unassigned
              alexpresland477 Alex Presland
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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