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

Incorrect NULL handling in UPDATE ... RETURNING result

    XMLWordPrintable

Details

    • Q2/2026 Server Maintenance

    Description

      If the field value is NULL, the UPDATE ... RETURNING statement returns the old value as an empty string instead of NULL

      13.0.0-dbg>create or replace table t1(a varchar(10));
      Query OK, 0 rows affected (0.022 sec)
       
      13.0.0-dbg>insert into t1 values();
      Query OK, 1 row affected (0.002 sec)
       
      13.0.0-dbg>select * from t1;
      +------+
      | a    |
      +------+
      | NULL |
      +------+
      1 row in set (0.000 sec)
       
      13.0.0-dbg>update t1 set a = 'a' returning old_value(a) as old, a as new;
      +------+------+
      | old  | new  |
      +------+------+
      |      | a    |
      +------+------+
      1 row in set (0.003 sec)
       
      13.0.0-dbg>
      

      when we set the field value to NULL, both old and new values return as NULL

      13.0.0-dbg>create or replace table t1(a varchar(10));
      Query OK, 0 rows affected (0.021 sec)
       
      13.0.0-dbg>insert into t1 values('');
      Query OK, 1 row affected (0.002 sec)
       
      13.0.0-dbg>select * from t1;
      +------+
      | a    |
      +------+
      |      |
      +------+
      1 row in set (0.001 sec)
       
      13.0.0-dbg>update t1 set a=NULL returning old_value(a) as old, a as new;
      +------+------+
      | old  | new  |
      +------+------+
      | NULL | NULL |
      +------+------+
      1 row in set (0.002 sec)
       
      13.0.0-dbg>
      

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.