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

Wrong data type for COALEASCE(?,1) in prepared statements

    XMLWordPrintable

Details

    Description

      This script:

      DROP TABLE IF EXISTS t1;
      PREPARE stmt FROM "CREATE TABLE t1 AS SELECT CONCAT(COALESCE(?,1)) AS a, CONCAT(CASE WHEN TRUE THEN ? ELSE 1 END) AS b";
      SET @a=1;
      EXECUTE stmt USING @a,@a;
      SHOW CREATE TABLE t1;
      

      returns

      +-------+------------------------------------------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                                                   |
      +-------+------------------------------------------------------------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `a` varbinary(21) DEFAULT NULL,
        `b` varchar(21) CHARACTER SET utf8 DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+------------------------------------------------------------------------------------------------------------------------------------------------+
      

      Column type for COALESCE is wrong, while for CASE is Ok.

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.