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

SF erroneously caches an ancored return data type

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3, 13.0, 13.1, 13.2
    • 13.2
    • Data types, Stored routines
    • None

    Description

      CREATE OR REPLACE TABLE t1 (a INT);
      DROP TABLE IF EXISTS t2;
      DELIMITER $$
      CREATE OR REPLACE FUNCTION f1() RETURNS TYPE OF t1.a
      BEGIN
        RETURN 5;
      END;
      $$
      CREATE OR REPLACE PROCEDURE p1()
      BEGIN
        FOR i IN 1..2 DO
           -- The type of f1() is erroneously cached during the first execution
          CREATE OR REPLACE TABLE t2 AS SELECT f1() AS c1;
          SHOW CREATE TABLE t2;
          ALTER TABLE t1 MODIFY a TEXT;
        END FOR;
      END;
      $$
      DELIMITER ;
      CALL p1;
      

      returns the following output:

      +-------+-----------------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                          |
      +-------+-----------------------------------------------------------------------------------------------------------------------+
      | t2    | CREATE TABLE `t2` (
        `c1` int(11) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
      +-------+-----------------------------------------------------------------------------------------------------------------------+
      1 row in set (0.056 sec)
       
      +-------+-----------------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                          |
      +-------+-----------------------------------------------------------------------------------------------------------------------+
      | t2    | CREATE TABLE `t2` (
        `c1` int(11) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
      +-------+-----------------------------------------------------------------------------------------------------------------------+
      1 row in set (0.260 sec) 
      

      Notice, it creates an INT field both times. Whereas, during the second execution RETURNS TYPE OF t1.a should resolve to TEXT, according to ALTER inside p1.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 1h
                  1h

                  Git Integration

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