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

Does simple UDF not reset when re-call in the nested sub query?

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.7.3
    • Fix Version/s: None
    • Component/s: Plugins
    • Labels:
      None
    • Environment:
      Windows 64bit

      Description

      Hi.

      When call a very simple test udf function in the sub query,
      it seem not reset internal values. Am I something wrong?
      --------------------
      [udf summary]
      1. have init/deinit/xxxx_my_sum.
      2. data structure = data->_sum
      (to sum/cumulate all values)
      3. data->_sum += (*((double*)args->args[0]));

      [query summary]

      select
       *,
       if(running_sum > 0, 1, 0) as result -- HERE! when refer inner udf's alias, it runs twice
      from
      (
        select
          xxxx_my_sum(field_a) as running_sum
         from TableA
      ) as test
      

      --------------------

      as above that simple.
      in this case, as the result xxxx_my_sum value doubled. Means called twice as a sub query and by the outer query.
      How to make the result only one set of sum?(means eventhough called multiple times, want to reset udf inner value _sum every time query restart)

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            npdmailing@gmail.com Mitchell Lee
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.