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

sql_mode='ORACLE' incorrectly aligns data leading to disrepancies with oracle

    XMLWordPrintable

Details

    Description

      This testcase uses oracle and MariaDB compatible SQL (the first line gives an auto-ignored error on oracle, and succeeds on MariaDB, to align instances in operation).

      SET autocommit=0, sql_mode='ORACLE';
      CREATE TABLE t (c VARCHAR(5));
      INSERT INTO t (c) VALUES ('RIGHT');
      UPDATE t SET c='LEFT RIGHT';
      SELECT * FROM t;
      

      Leads to, on oracle:

      oracle

      SQL> SELECT * FROM t;
      C
      -----
      RIGHT
      

      Versus MariaDB:

      MDEV-35915-6 CS 12.2.0 ed3c63488a1613377d92ee3ade3fe6870e39b4db (Optimized, Clang 21.1.0-20250811) Build 24/09/2025

      12.2.0-opt>SELECT * FROM t;
      +-------+
      | c     |
      +-------+
      | LEFT  |
      +-------+
      1 row in set (0.000 sec)
      

      The reason is clear:

      oracle

      SQL> UPDATE t SET c='LEFT RIGHT'
                     *
      ERROR at line 1:
      ORA-12899: value too large for column "SYS"."T"."C" (actual: 10, maximum: 5)
      Help: https://docs.oracle.com/error-help/db/ora-12899/
      

      Whereas on MariaDB we see:

      MDEV-35915-6 CS 12.2.0 ed3c63488a1613377d92ee3ade3fe6870e39b4db (Optimized, Clang 21.1.0-20250811) Build 24/09/2025

      12.2.0-opt>UPDATE t SET c='LEFT RIGHT';
      Query OK, 0 rows affected, 1 warning (0.000 sec)
      Rows matched: 1  Changed: 0  Warnings: 1
       
      12.2.0-opt>SHOW WARNINGS;
      +---------+------+----------------------------------------+
      | Level   | Code | Message                                |
      +---------+------+----------------------------------------+
      | Warning | 1265 | Data truncated for column 'c' at row 1 |
      +---------+------+----------------------------------------+
      1 row in set (0.000 sec)
      

      Goal: achieve indentical results with oracle for indentical SQL on both sides when using sql_mode='ORACLE'.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              Roel Roel Van de Paar
              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.