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

UUID() should be treated as stochastic for the purposes of forcing query materialization

    XMLWordPrintable

Details

    Description

      When compiling/running relatively simple queries that construct JSON objects it seems like the query engine is re-computing function calls instead of using the actual value when extracting JSON data.

      For example, given the query:

      WITH RECURSIVE iter AS
      (
      	SELECT 1 AS 'i'
      	UNION 
      	SELECT i + 1
      	FROM iter 
      	WHERE i < 10
      ),
      json_data AS 
      (
      	SELECT
      		JSON_OBJECT(
      			'UUID', UUID()
      		) AS 'Data'
      	FROM iter 
      )
      SELECT
      	JSON_EXTRACT(jd.`Data`, '$.UUID') AS 'Extracted',
      	jd.`Data`
      FROM json_data jd
      

      you would expect the `Extracted` value to be the same as the value that was computed in the `Data` JSON_OBJECT, but it is actually different.

      With this query I was able to get the same results for iter generating numbers up to 1,000,000, although in another query that consisted of more joins then I did not see this behavior; in that case the extracted UUID was the same as the originally computed UUID.

      Attachments

        Activity

          People

            Johnston Rex Johnston
            edyck Ezra Dyck
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.