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

XMLISVALID should be 0 returns 1 for strings that are not a single well-formed XML document

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • N/A
    • 13.2
    • XML Functions
    • None
    • Q3/2026 Server Maintenance, Q3/2026 Server Development, Q4/2026 Server Maintenance

    Description

      set @s='<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="r"><xs:complexType><xs:sequence><xs:element name="a" type="xs:int"/></xs:sequence></xs:complexType></xs:element></xs:schema>';
      create table t1 (name varchar(20), doc text);
      insert into t1 values
        ('empty', ''),
        ('whitespace only', '   '),
        ('text only', 'abc'),
        ('comment only', '<!--c-->'),
        ('two roots', '<r><a>1</a></r><r><a>1</a></r>'),
        ('leading text', 'x<r><a>1</a></r>'),
        ('trailing text', '<r><a>1</a></r>x'),
        ('unclosed', '<r><a>1</a>'),
        ('valid', '<r><a>1</a></r>');
      select name, doc, XMLISVALID(doc, @s), CAST(doc AS XMLTYPE)  from t1;
      

      MariaDB [test]> select name, doc, XMLISVALID(doc, @s), CAST(doc AS XMLTYPE)  from t1;
      +-----------------+--------------------------------+---------------------+----------------------+
      | name            | doc                            | XMLISVALID(doc, @s) | CAST(doc AS XMLTYPE) |
      +-----------------+--------------------------------+---------------------+----------------------+
      | empty           |                                |                   1 | NULL                 |
      | whitespace only |                                |                   1 | NULL                 |
      | text only       | abc                            |                   1 | NULL                 |
      | comment only    | <!--c-->                       |                   1 | NULL                 |
      | two roots       | <r><a>1</a></r><r><a>1</a></r> |                   1 | NULL                 |
      | leading text    | x<r><a>1</a></r>               |                   1 | NULL                 |
      | trailing text   | <r><a>1</a></r>x               |                   1 | NULL                 |
      | unclosed        | <r><a>1</a>                    |                   0 | NULL                 |
      | valid           | <r><a>1</a></r>                |                   1 | <r><a>1</a></r>      |
      +-----------------+--------------------------------+---------------------+----------------------+
      9 rows in set (0,002 sec)
      
      

      Attachments

        Issue Links

          Activity

            People

              holyfoot Alexey Botchkov
              alice Alice Sherepa
              Alexander Barkov Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 1d 19m
                  1d 19m
                  Remaining:
                  Remaining Estimate - 1d 19m
                  1d 19m
                  Logged:
                  Time Spent - Not Specified
                  Not Specified

                  Git Integration

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