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

CREATE SERVER persists invalid JSON when an option identifier contains a double quote

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 11.8, 12.3, 13.1, 12.3.3
    • 11.8, 12.3, 13.1
    • Server
    • None
    • Linux/amd64

    Description

      CREATE SERVER accepts a backtick-quoted option identifier containing a double quote, but persists the quote unescaped in mysql.servers.Options. This produces malformed metadata for the server definition: JSON_VALID(Options) returns 0, while an otherwise equivalent option identifier without the quote produces valid JSON. The behavior was observed on MariaDB 12.3.3 on Linux/amd64.

      Source inspection indicates that the server-options JSON writer escapes option values but not option names, while SHOW CREATE SERVER correctly quotes the SQL identifier.

      Reproducer

      Run the following SQL:

      -- Oracle: both accepted server definitions must persist valid JSON options.
      -- The second name is a legal backtick-quoted identifier containing a quote.
      DROP SERVER IF EXISTS plain_options;
      DROP SERVER IF EXISTS quoted_options;
      CREATE SERVER plain_options FOREIGN DATA WRAPPER foo
        OPTIONS (`tag` 'v');
      CREATE SERVER quoted_options FOREIGN DATA WRAPPER foo
        OPTIONS (`tag"x` 'v');
      SHOW CREATE SERVER plain_options;
      SHOW CREATE SERVER quoted_options;
      SELECT Server_name, Options, JSON_VALID(Options) AS valid_json
      FROM mysql.servers
      WHERE Server_name IN ('plain_options','quoted_options')
      ORDER BY Server_name;
      DROP SERVER plain_options;
      DROP SERVER quoted_options;
      SELECT COUNT(*) AS remaining_objects FROM mysql.servers
      WHERE Server_name IN ('plain_options','quoted_options');
      SELECT 1 AS post_test_health;

      Both server definitions are accepted. The plain option name is stored as valid JSON, while the quoted name is stored with an unescaped double quote and is invalid:

      Server_name	Options	valid_json
      plain_options	{"tag": "v"}	1
      quoted_options	{"tag"x": "v"}	0

      Both accepted server definitions should persist valid JSON, so JSON_VALID(Options) should return 1 for both rows. A parser-accepted SQL identifier must be JSON-escaped when it is used as a key in mysql.servers.Options.

      This occurs when a CREATE SERVER option uses a backtick-quoted identifier containing a double quote.

      Attachments

        Issue Links

          Activity

            People

              ycp Yuchen Pei
              Wren Qin
              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.