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

JSON_OBJECT() doesn't honour datatype in function

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5, 10.6, 10.10
    • 10.5, 10.6, 10.11, 11.1, 11.2
    • JSON
    • None
    • Linux

    Description

      Also happens with json_array()

      DELIMITER //
      CREATE OR REPLACE FUNCTION json_function_test ( a INT )
          RETURNS JSON
      BEGIN
          DECLARE `_id` INT UNSIGNED;
          DECLARE `_id2` INT UNSIGNED;
          DECLARE `_id3` INT UNSIGNED DEFAULT 9;
       
          SET @_temp = UNIX_TIMESTAMP();
          SET _id    = UNIX_TIMESTAMP();
          SET _id2   = 444;
       
          return JSON_OBJECT("argument_int", a, "_id",_id, "_id2",_id2, "_id3", _id3, "temp_var", @_temp) ;
      END;//
      DELIMITER ;
       
      select json_function_test(123);
      

      Everything is a string:

      {"argument_int": "123", "_id": "1692396866", "_id2": "444", "_id3": "9", "temp_var": "1692396866"}
      

      select JSON_OBJECT("temp_var",@_temp, "a",UNIX_TIMESTAMP());
      | {"temp_var": "1692396982", "a": 1692397120}          |
      

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

      In 10.3 in the other hand, the results are different:

      select JSON_OBJECT("temp_var",@_temp, "a",UNIX_TIMESTAMP());
      | {"temp_var": 1692397171, "a": 1692397176}            |
      

      Attachments

        Activity

          People

            rucha174 Rucha Deodhar
            elvena Martín Alfano
            Votes:
            1 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.