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

Incorrect data size in CREATE TABLE when using JSON_INSERT in a subquery

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 10.11, 11.4, 11.8, 12.3, 13.1
    • N/A
    • JSON
    • None
    • Not for Release Notes

    Description

      Hi,

      The following test case shows the incorrect data size in CREATE TABLE when using JSON_INSERT in a subquery

      CREATE TABLE src(val LONGTEXT);
      INSERT INTO src VALUES(REPEAT('x',100));
       
      CREATE TABLE t2 AS
        SELECT JSON_INSERT('{"k1":"v1"}', '$.k3', val) AS j
        FROM src
        LIMIT 0;
       
      SHOW CREATE TABLE t2;
      -- t2	CREATE TABLE `t2` (
      --   `j` varchar(36) DEFAULT NULL
      -- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
      -- This is incorrect as the size of j is only 36, 122 is expected 
       
      INSERT IGNORE INTO t2
        SELECT JSON_INSERT('{"k1":"v1"}', '$.k3', val) AS j
        FROM src;
      -- Warning	1265	Data truncated for column 'j' at row 1
      

      Attachments

        Issue Links

          Activity

            People

              shipjain Shipra Jain
              ChiZhang Chi Zhang
              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.