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

JSON_TABLE stores a JSON number into the column as its text: BIT(8) receives 49, YEAR receives 2000

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • None
    • N/A
    • JSON
    • None
    • Not for Release Notes

    Description

      A JSON number is handed to the column in its textual form, so column types whose numeric and string conversions differ get the string semantics:

      Reproduced on 10.11.19 (debug build):

      SELECT b + 0 FROM JSON_TABLE('[1]', '$[*]' COLUMNS(b BIT(8) PATH '$')) t;   -- 49
      SELECT y FROM JSON_TABLE('[0]', '$[*]' COLUMNS(y YEAR PATH '$')) t;         -- 2000
       
      CREATE TABLE ref (n BIT(8), y YEAR);
      INSERT INTO ref VALUES (1, 0);
      SELECT n + 0, y FROM ref;                                                   -- 1, 0000

      49 is the character '1'. Expected: the JSON number 1 is stored as 1 and the JSON number 0 as 0000, as a plain INSERT of the numbers does. INT columns are unaffected because the two conversions agree there.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              chunlingqin chunlingqin
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.