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

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

        Issue Links

          Activity

            Transition Time In Source Status Execution Times
            Sergei Golubchik made transition -
            Open Confirmed
            4d 16h 58m 1
            Rex Johnston made transition -
            Confirmed In Progress
            140d 9h 43m 1
            Rex Johnston made transition -
            In Progress In Review
            93d 1h 52m 1
            Oleg Smirnov made transition -
            In Review Stalled
            1d 9h 58m 1
            Rex Johnston made transition -
            Stalled In Progress
            15h 57m 1
            Rex Johnston made transition -
            In Progress Closed
            3h 33m 1

            People

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