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

XMLISVALID returns 1 for invalid XML after a previous row stopped inside xs:any

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • N/A
    • 13.3
    • XML Functions
    • None

    Description

      Content of xs:any and xs:anyType is skipped through one shared item, MY_XML_VALIDATION_DATA::annotation, which counts nesting in m_level. If validation stops inside such content (row 1 is not well-formed), m_level keeps its value; reset_types() does not reset it. On the next row the closing tag of the skipped element only decrements the level, the closing tag of R pops the annotation, and the end check of R (required z) never runs.

      SET @s= '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="R"><xs:complexType><xs:sequence>
        <xs:any/>
        <xs:element name="z" type="xs:int"/>
      </xs:sequence></xs:complexType></xs:element>
      </xs:schema>';
      CREATE TABLE t (id INT, x TEXT);
      INSERT INTO t VALUES (1, '<R><x><y>'), (2, '<R><x/></R>');
      SELECT XMLISVALID('<R><x/></R>', @s);
      --echo # BUG if row 2 = 1, same document as above
      SELECT id, XMLISVALID(x, @s) FROM t ORDER BY id;
      DROP TABLE t;

      13.2.0-MariaDB-asan-debug-log source revision: bd45fd917d4ef23ca1c4f62ca63473c08c03c8de
       
      SET @s= '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="R"><xs:complexType><xs:sequence>
        <xs:any/>
        <xs:element name="z" type="xs:int"/>
      </xs:sequence></xs:complexType></xs:element>
      </xs:schema>';
      CREATE TABLE t (id INT, x TEXT);
      INSERT INTO t VALUES (1, '<R><x><y>'), (2, '<R><x/></R>');
      SELECT XMLISVALID('<R><x/></R>', @s);
      XMLISVALID('<R><x/></R>', @s)
      0
      # BUG if row 2 = 1, same document as above
      SELECT id, XMLISVALID(x, @s) FROM t ORDER BY id;
      id	XMLISVALID(x, @s)
      1	0
      2	1
      DROP TABLE t;

      Attachments

        Issue Links

          Activity

            People

              holyfoot Alexey Botchkov
              alice Alice Sherepa
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.