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

Dynamic CREATE TABLE does not preserve the data type of SP variables with NULL value

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.2, 10.3, 10.4
    • Fix Version/s: 10.2
    • Component/s: None
    • Labels:
      None
    • Sprint:
      10.2.11

      Description

      DELIMITER $$
      BEGIN NOT ATOMIC
        DECLARE d0 DATETIME DEFAULT NULL;
        DECLARE d1 DATETIME DEFAULT '2001-01-01 00:00:00';
        DECLARE i0 INT DEFAULT NULL;
        DECLARE i1 INT DEFAULT 10;
        PREPARE stmt FROM 'CREATE OR REPLACE TABLE t1 AS SELECT ? AS c1,? AS c2,? AS c3,? AS c4';
        EXECUTE stmt USING d0,d1,i0,i1;
        DEALLOCATE PREPARE stmt;
        SHOW CREATE TABLE t1;
      END;
      $$
      DELIMITER ;
      

      +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                                                                                      |
      +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `c1` binary(0) DEFAULT NULL,
        `c2` datetime DEFAULT NULL,
        `c3` binary(0) DEFAULT NULL,
        `c4` bigint(21) NOT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      

      The expected data type for c0 should be DATETIME (like for c1).
      The expected data type for c3 should be BIGINT (like for c3).

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated: