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

JSON_TABLE: Success of query execution depends on the outcome of previous queries

Details

    • Bug
    • Status: Closed (View Workflow)
    • Blocker
    • Resolution: Fixed
    • N/A
    • 10.6.0
    • JSON
    • None

    Description

      This is a problem with possibly wide-spread consequences.

      Here the first query is valid, and the second one works too as probably expected (at least I don't see why it shouldn't):

      title=bb-10.6-mdev17399-psergey2 8b533cc1d5

      MariaDB [test]> select * from json_table('[]', '$' COLUMNS(x FOR ORDINALITY)) a;
      +------+
      | x    |
      +------+
      |    1 |
      +------+
      1 row in set (0.000 sec)
       
      MariaDB [test]> select min(x) from json_table('[]', '$' COLUMNS(x FOR ORDINALITY)) a;
      +--------+
      | min(x) |
      +--------+
      |      1 |
      +--------+
      1 row in set (0.000 sec)
      

      Now let's make the first query invalid (missing the alias), run it and repeat the 2nd query without any modifications:

      MariaDB [test]> select * from json_table('[]', '$' COLUMNS(x FOR ORDINALITY));
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
       
      MariaDB [test]> select min(x) from json_table('[]', '$' COLUMNS(x FOR ORDINALITY)) a;
      ERROR 1111 (HY000): Invalid use of group function
      

      So, now the second query fails, and it continues failing upon further executions:

      MariaDB [test]> select min(x) from json_table('[]', '$' COLUMNS(x FOR ORDINALITY)) a;
      ERROR 1111 (HY000): Invalid use of group function
      MariaDB [test]> 
      MariaDB [test]> select min(x) from json_table('[]', '$' COLUMNS(x FOR ORDINALITY)) a;
      ERROR 1111 (HY000): Invalid use of group function
      

      But if we fix the first one, run it successfully, and repeat the 2nd one, it works again:

      MariaDB [test]> select * from json_table('[]', '$' COLUMNS(x FOR ORDINALITY)) a;
      +------+
      | x    |
      +------+
      |    1 |
      +------+
      1 row in set (0.000 sec)
       
      MariaDB [test]> select min(x) from json_table('[]', '$' COLUMNS(x FOR ORDINALITY)) a;
      +--------+
      | min(x) |
      +--------+
      |      1 |
      +--------+
      1 row in set (0.001 sec)
      

      In MySQL, nothing of the kind happens, the 2nd query consistently succeeds.

      Attachments

        Issue Links

          Activity

            elenst Elena Stepanova created issue -
            elenst Elena Stepanova made changes -
            Field Original Value New Value
            elenst Elena Stepanova made changes -
            Assignee Sergei Petrunia [ psergey ] Alexey Botchkov [ holyfoot ]
            holyfoot Alexey Botchkov made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            holyfoot Alexey Botchkov made changes -
            issue.field.resolutiondate 2021-03-16 08:27:08.0 2021-03-16 08:27:08.101
            holyfoot Alexey Botchkov made changes -
            Fix Version/s 10.6.0 [ 24431 ]
            Fix Version/s 10.6 [ 24028 ]
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Closed [ 6 ]
            psergei Sergei Petrunia made changes -
            Assignee Alexey Botchkov [ holyfoot ] Sergei Petrunia [ psergey ]
            psergei Sergei Petrunia made changes -
            Assignee Sergei Petrunia [ psergey ] Alexey Botchkov [ holyfoot ]
            elenst Elena Stepanova made changes -
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 120111 ] MariaDB v4 [ 159025 ]

            People

              holyfoot Alexey Botchkov
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.