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

FLUSH TABLES truncates a schema comment at an embedded newline

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3, 13.1, 12.3.3
    • 10.11, 11.4, 11.8, 12.3, 13.1
    • Server
    • None
    • MariaDB 12.3.3 binary distribution on x86_64 Debian GNU/Linux

    Description

      A schema comment containing an embedded newline is returned correctly immediately after ALTER DATABASE, but loses the newline and all following text after FLUSH TABLES reloads the database options. A plain-text comment remains unchanged.

      Steps to reproduce

      1. Save the following as test.sql.
      2. Run it with mariadb --batch --raw < test.sql.

      SET SESSION sql_mode='';
      SET SESSION lock_wait_timeout=5;
      CREATE DATABASE comment_db COMMENT 'alpha beta';
      SHOW WARNINGS;
      SELECT 'control_warm' AS phase, HEX(SCHEMA_COMMENT) AS comment_hex
        FROM information_schema.SCHEMATA
        WHERE SCHEMA_NAME='comment_db';
      FLUSH TABLES;
      SELECT 'control_cold' AS phase, HEX(SCHEMA_COMMENT) AS comment_hex
        FROM information_schema.SCHEMATA
        WHERE SCHEMA_NAME='comment_db';
      ALTER DATABASE comment_db COMMENT 'alpha\nbeta';
      SHOW WARNINGS;
      SELECT 'newline_warm' AS phase, HEX(SCHEMA_COMMENT) AS comment_hex
        FROM information_schema.SCHEMATA
        WHERE SCHEMA_NAME='comment_db';
      FLUSH TABLES;
      SELECT 'newline_cold' AS phase, HEX(SCHEMA_COMMENT) AS comment_hex
        FROM information_schema.SCHEMATA
        WHERE SCHEMA_NAME='comment_db';
      SELECT 'newline_recached' AS phase, HEX(SCHEMA_COMMENT) AS comment_hex
        FROM information_schema.SCHEMATA
        WHERE SCHEMA_NAME='comment_db';
      DROP DATABASE comment_db;

      Actual result

      The plain-text control remains stable. The newline comment initially contains the complete byte sequence for alpha\nbeta, but after FLUSH TABLES it contains only alpha and remains truncated on the next read. No warnings are reported.

      phase          comment_hex
      control_warm   616C7068612062657461
      control_cold   616C7068612062657461
      newline_warm   616C7068610A62657461
      newline_cold   616C706861
      newline_recached 616C706861

      Expected result

      All three newline-comment reads should return 616C7068610A62657461. Clearing the cache must not change accepted schema-comment bytes when the database options are reloaded.

      This occurs when a schema comment contains a newline and its cached database options are reloaded after FLUSH TABLES.

      Attachments

        Activity

          People

            sanja Oleksandr Byelkin
            Milo liu
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.