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

MEDIUMTEXT gets truncated to TINYTEXT in assoc array RECORD field

    XMLWordPrintable

Details

    • Bug
    • Status: Stalled (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 12.1(EOL), 12.2(EOL), 12.3, 13.0, 13.1, 13.3, 13.3.1
    • 12.3
    • Data types, Stored routines
    • None
    • Can result in unexpected behaviour
    • Q4/2026 Server Maintenance

    Description

      This MDEV is waiting for the patch to get merged into 13.1, so 13.1 tests with package wide TYPEs can be added.

      MEDIUMTEXT gets truncated to TEXT in assoc array RECORD field

      The problem is repeatable starting from 12.1, where associated arrays where introduced.

      SET sql_mode=ORACLE;
      DELIMITER $$
      DECLARE
        TYPE rec_t IS RECORD (s MEDIUMTEXT);
        TYPE tab_t IS TABLE OF rec_t INDEX BY INTEGER;
        t tab_t;
        r rec_t;
      BEGIN
        r.s:= RPAD('s', 1000, 's');
        SELECT LENGTH(r.s);
        CREATE OR REPLACE TABLE t1 AS SELECT r.s AS s;
        SHOW CREATE TABLE t1;
        DROP TABLE t1;
      END;
      $$
      DELIMITER ;
      

      +-------------+
      | LENGTH(r.s) |
      +-------------+
      |         255 |
      +-------------+
      1 row in set (0.001 sec)
       
      +-------+---------------------------------------------------+
      | Table | Create Table                                      |
      +-------+---------------------------------------------------+
      | t1    | CREATE TABLE "t1" (
        "s" tinytext DEFAULT NULL
      ) |
      +-------+---------------------------------------------------+
      1 row in set (0.070 sec)
       
      Query OK, 1 row affected (0.109 sec)
      

      Notice the length was truncated to 255 bytes and the data type was changed from MEDIUMTEXT to TEXT.

      The same problem is repeatable with 13.1 with a package-wide data type:

      SET sql_mode=ORACLE;
      DELIMITER $$
      CREATE OR REPLACE PACKAGE pk0 AS
        TYPE rec_t IS RECORD (s MEDIUMTEXT);
        TYPE tab_t IS TABLE OF rec_t INDEX BY INTEGER;
      END;
      $$
      DECLARE
        t pk0.tab_t;
        r pk0.rec_t;
      BEGIN
        r.s:= RPAD('s', 1000, 's');
        SELECT LENGTH(r.s);
        CREATE OR REPLACE TABLE t1 AS SELECT r.s AS s;
        SHOW CREATE TABLE t1;
        DROP TABLE t1;
      END;
      $$
      DELIMITER ;
      DROP PACKAGE pk0;
      

      +-------------+
      | LENGTH(r.s) |
      +-------------+
      |         255 |
      +-------------+
      1 row in set (0.001 sec)
       
      +-------+---------------------------------------------------+
      | Table | Create Table                                      |
      +-------+---------------------------------------------------+
      | t1    | CREATE TABLE "t1" (
        "s" tinytext DEFAULT NULL
      ) |
      +-------+---------------------------------------------------+
      1 row in set (0.061 sec)
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 4h 43m
                  4h 43m
                  Remaining:
                  Remaining Estimate - 4h 43m
                  4h 43m
                  Logged:
                  Time Spent - Not Specified
                  Not Specified

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.