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

Behavior of SELECT (CAST 'N/A' AS INT) varys depending on CTE + INSERT

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.5.5
    • None
    • None
    • Windows 10, 10.5.5-MariaDB, tested in HeidiSQL and also command line.

    Description

      Please see steps to reproduce as follows....

      CREATE TABLE `a` (
      `someField` VARCHAR(50) NULL DEFAULT NULL
      )
      COLLATE='utf8_general_ci'
      ENGINE=InnoDB
      ;

      /* This fails correctly with an INT conversion error (1292)

      INSERT INTO A
      WITH CTE AS (SELECT CAST(LTRIM(RTRIM('N/A')) AS INT) AS someNumber WHERE CAST(LTRIM(RTRIM('N/A')) AS INT) = 0)
      SELECT 'blah' FROM CTE; */

      /* but this runs okay with the CAST changing 'N/A' to a 0, only when you attempt any INSERT do you get an error

      WITH CTE AS (SELECT CAST(LTRIM(RTRIM('N/A')) AS INT) AS someNumber WHERE CAST(LTRIM(RTRIM('N/A')) AS INT) = 0)
      SELECT 'blah' FROM CTE; */

      DROP TABLE A;

      /* Which one is the preferred behavior? Can we get it consistent please! */

      Attachments

        Activity

          People

            Unassigned Unassigned
            danc Daniel Challis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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