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

UDF_ARGS "attribute_lengths" incorrect value

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5(EOL), 10.0(EOL), 10.1(EOL)
    • 5.5.58
    • OTHER
    • Arch Linux
      Linux kernel 4.4.23-1-lts
      Lenovo ThinkPad E540

    Description

      I try to use User Defined Function lib_mysqludf_json from https://github.com/mysqludf/lib_mysqludf_json with MariaDB 10.1.18 and found an incorrect behavior of UDF_ARGS attribute_lengths.

      typedef struct st_udf_args
      {
      ...
        unsigned long *attribute_lengths;     /* Length of attribute arguments */
      ...
      } UDF_ARGS;
      

      Example:
      When you use SELECT json_object("citizen_id") FROM ...
      you will have:

      args->attributes[0] = "citizen_id"
      args->attribute_lengths[0] = 12
      

      That's correct.

      When you use SELECT json_object(citizen_id AS citizen_id) FROM ...

      args->attributes[0] = citizen_id
      args->attribute_lengths[0] = 10
      

      That's also correct.

      But when you use SELECT json_object(citizen_id) FROM ...

      args->attributes[0] = citizen_id
      args->attribute_lengths[0] = 0
      

      That's incorrect. Correct value of attribute_lengths[0] is 10.

      That's not reproducable on MySQL. This is not lib_mysqludf_json incorrect behavior, it just uses standart struct UDF_ARGS.

      Attachments

        Activity

          Thanks for the report.

          Same in MySQL 5.5, but not reproducible with MySQL 5.6.

          MariaDB 10.1.19

          MariaDB [test]>  SELECT json_object(citizen_id) FROM citizens;
          ERROR 1123 (HY000): Can't initialize function 'json_object'; Invalid json member name - name cannot be empty
          MariaDB [test]>  SELECT json_object(citizen_id AS citizen_id) FROM citizens;
          +---------------------------------------+
          | json_object(citizen_id AS citizen_id) |
          +---------------------------------------+
          | {"citizen_id":1}                      |
          | {"citizen_id":2}                      |
          +---------------------------------------+
          2 rows in set (0.00 sec)
          

          MySQL 5.6

          MySQL [test]>  SELECT json_object(citizen_id) FROM citizens;
          +-------------------------+
          | json_object(citizen_id) |
          +-------------------------+
          | {"citizen_id":1}        |
          | {"citizen_id":2}        |
          +-------------------------+
          2 rows in set (0.00 sec)
          

          Both MySQL 5.7 and MariaDB 10.2 have native JSON_OBJECT, so it's not applicable there.

          elenst Elena Stepanova added a comment - Thanks for the report. Same in MySQL 5.5, but not reproducible with MySQL 5.6. MariaDB 10.1.19 MariaDB [test]> SELECT json_object(citizen_id) FROM citizens; ERROR 1123 (HY000): Can 't initialize function ' json_object'; Invalid json member name - name cannot be empty MariaDB [test]> SELECT json_object(citizen_id AS citizen_id) FROM citizens; + ---------------------------------------+ | json_object(citizen_id AS citizen_id) | + ---------------------------------------+ | { "citizen_id" :1} | | { "citizen_id" :2} | + ---------------------------------------+ 2 rows in set (0.00 sec) MySQL 5.6 MySQL [test]> SELECT json_object(citizen_id) FROM citizens; + -------------------------+ | json_object(citizen_id) | + -------------------------+ | { "citizen_id" :1} | | { "citizen_id" :2} | + -------------------------+ 2 rows in set (0.00 sec) Both MySQL 5.7 and MariaDB 10.2 have native JSON_OBJECT , so it's not applicable there.
          holyfoot Alexey Botchkov added a comment - http://lists.askmonty.org/pipermail/commits/2017-July/011308.html

          People

            holyfoot Alexey Botchkov
            Sirakuzi Alexander Sidorov
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.