Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-10764 PL/SQL parser - Phase 2
  3. MDEV-10574

sql_mode=ORACLE: IS NULL and empty strings

    XMLWordPrintable

Details

    Description

      Oracle does not distinguish between empty strings and NULL.
      MariadDB should do the same when running with sql_mode=ORACLE.

      Example:

      DROP TABLE t1;
      CREATE TABLE t1 (id INT NOT NULL, s VARCHAR(10) NOT NULL);
      INSERT INTO t1 VALUES (1, '');
      

      INSERT INTO t1 VALUES (1, '')
                                *
      ERROR at line 1:
      ORA-01400: cannot insert NULL into ("SYSTEM"."T1"."S")
      

      Example:

      DROP TABLE t1;
      CREATE TABLE t1 (id INT NOT NULL, s VARCHAR(10));
      INSERT INTO t1 VALUES (0, NULL);
      INSERT INTO t1 VALUES (1, '');
      INSERT INTO t1 VALUES (2, 'test');
      SELECT * FROM t1 WHERE s IS NULL;
      

      	ID S
      ---------- ----------
      	 0
      	 1
      

      Example:

      SELECT '' AS c1, NULL AS c2 FROM DUAL;
      

       
      C C
      - -
      
      

      Example:

      DROP TABLE t1;
      CREATE TABLE t1 (v VARCHAR(10), c CHAR(10));
      INSERT INTO t1 VALUES ('','');
      SELECT v,c FROM t1;
      

      V	   C
      ---------- ----------
      
      

      Example:

      DROP TABLE t1;
      CREATE TABLE t1 (v VARCHAR(10));
      INSERT INTO t1 VALUES ('');
      SELECT * FROM t1 WHERE v='';
      

      no rows selected
      

      Example:

      DROP TABLE t1;
      CREATE TABLE t1 (v VARCHAR(10));
      INSERT INTO t1 VALUES ('');
      SELECT * FROM t1 WHERE v IS NULL;
      

      V
      ----------
      
      

      Example:

      DROP TABLE t1;
      CREATE TABLE t1 (c CHAR(10));
      INSERT INTO t1 VALUES ('');
      SELECT * FROM t1 WHERE c='';
      

      no rows selected
      

      Example:

      DROP TABLE t1;
      CREATE TABLE t1 (c CHAR(10));
      INSERT INTO t1 VALUES ('');
      SELECT * FROM t1 WHERE c IS NULL;
      

      C
      ----------
      
      

      Example:

      DROP TABLE t1;
      CREATE TABLE t1 (v VARCHAR(10));
      INSERT INTO t1 VALUES ('');
      SELECT v||'A' FROM t1;
      

      V||'A'
      -----------
      A
      
      

      Attachments

        Issue Links

          Activity

            People

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