Details

    Description

      MDEV-11275 adds support for CAST(expr AS VARCHAR(N)) for sql_mode=ORACLE.

      CAST(expr AS VARCHAR(N)) should also be supported not only in sql_mode=ORACLE, but in other modes as well, it's supported by many popular databases:

      CAST(expr AS VARCHAR(N)) is supported by:

      • Oracle
      • SQL Server
      • PostgreSQL
      • SQLite
      • IBM DB2
      • Sybase/SAP ASE

      CAST(expr AS VARCHAR) (without length) is supported by:

      • SQL Server
      • PostgreSQL
      • SQLite
      • Sybase/SAP ASE

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov added a comment - - edited

            Monty wrote:

            Yes, we should [support CAST AS VARCHAR for other sql_modes], but I am not sure how this would differ from CAST(... CHAR), except for a length check.

            In particular, what should the result be for:

            CREATE TABLE t1 SELECT CAST("A" AS VARCHAR(10));

            Logically I assume this should create a VARCHAR(10) column, but can we really detect that in our current code without making this a special case?
            (Maybe this will work automatically, but I can't test this just now)

            The problem with special cases is how to handle expressions:
            CONCAT(CAST("A" AS VARCHAR(10)), "")

            bar Alexander Barkov added a comment - - edited Monty wrote: Yes, we should [support CAST AS VARCHAR for other sql_modes] , but I am not sure how this would differ from CAST(... CHAR), except for a length check. In particular, what should the result be for: CREATE TABLE t1 SELECT CAST("A" AS VARCHAR(10)); Logically I assume this should create a VARCHAR(10) column, but can we really detect that in our current code without making this a special case? (Maybe this will work automatically, but I can't test this just now) The problem with special cases is how to handle expressions: CONCAT(CAST("A" AS VARCHAR(10)), "")
            greenman Ian Gilfillan added a comment -

            Running

            SELECT CAST(123 AS VARCHAR(10)) FROM DUAL;

            seems to work in non-Oracle mode from MariaDB 10.3.11.

            greenman Ian Gilfillan added a comment - Running SELECT CAST(123 AS VARCHAR(10)) FROM DUAL; seems to work in non-Oracle mode from MariaDB 10.3.11.

            People

              Unassigned Unassigned
              bar Alexander Barkov
              Votes:
              2 Vote for this issue
              Watchers:
              6 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.