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

mariadb_upgrade utility failed to work when PATH variable is set on 12.3

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 12.3.1
    • 12.3.3
    • Upgrades
    • None
    • Related to install and upgrade
    • Correct mariadb-upgrade to work with non-default PATH set.

    Description

      Description

      We identified an issue when running `mariadb_upgrade` with the global PATH variable set.

      Example:
      Set PATH variable to `nonexist_db` before running `mariadb_upgrade`. The specified PATH is a arbitrary value which doesn't exist. Then, trigger the `mariadb_upgrade`

      Following error will be observed:

      ERROR 1305 (42000) at line 3211: FUNCTION extract_schema_from_file_name does not exist
      

      Root Cause

      This is because `mariadb_upgrade` utility calls SQLs in `mariadb_fix_privilege_tables_sql.c `, which is generated after the build. There is one line in the file trying to execute a function in a SELECT query like this:

       
      "USE sys;\n",
      ... 
        "SELECT extract_schema_from_file_name(file_name) AS table_schema,\n"
        "       extract_table_from_file_name(file_name) AS table_name,\n"
        "       SUM(count_read) AS count_read,\n"
        "       SUM(sum_number_of_bytes_read) AS sum_number_of_bytes_read,\n"
        "       SUM(sum_timer_read) AS sum_timer_read,\n"
        "       SUM(count_write) AS count_write,\n"
        "       SUM(sum_number_of_bytes_write) AS sum_number_of_bytes_write,\n"
        "       SUM(sum_timer_write) AS sum_timer_write,\n"
        "       SUM(count_misc) AS count_misc,\n"
        "       SUM(sum_timer_misc) AS sum_timer_misc\n"
      

      It was originally targeted at `sys` database, but it was redirected to an inexistent database `nonexist_db` due to the PATH variable.

      Fix proposal

      Change from

      SELECT extract_schema_from_file_name(file_name) AS table_schema
      

      to

      SELECT sys.extract_schema_from_file_name(file_name) AS table_schema
      

      in `scripts/sys_schema/views/p_s/x_ps_schema_table_statistics_io.sql`, which is the source to generate `mariadb_fix_privilege_tables_sql.c `

      Attachments

        Issue Links

          Activity

            People

              danblack Daniel Black
              tiangeng66 Geng Tian
              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.