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

Bad IS NULL result on an expression containing a ROW SP variable

Details

    Description

      DELIMITER /
      CREATE OR REPLACE PROCEDURE p1()
      BEGIN
        DECLARE r0 ROW(a INT, b VARCHAR(10));
        DECLARE r2 ROW(a INT, b VARCHAR(10)) DEFAULT (1,'b1');
        SET r0=r2;
        SELECT '02' AS stage, r0=r2, (r0=r2) IS NULL;
      END;
      /
      DELIMITER ;
      CALL p1;
      

      +-------+-------+-----------------+
      | stage | r0=r2 | (r0=r2) IS NULL |
      +-------+-------+-----------------+
      | 02    |     1 |               1 |
      +-------+-------+-----------------+
      

      The above result does not look correct. It says that r0=r2 is TRUE and is NULL at the same time.

      The problem goes away if I add the two lines marked with "NEW" in Field_row::sp_prepare_and_store_item:

      bool Field_row::sp_prepare_and_store_item(THD *thd, Item **value)
      {
      ...
        src->bring_value();
        if (m_table->sp_set_all_fields_from_item(thd, src))
        {
          set_null();         // NEW
          DBUG_RETURN(true);
        }
        set_notnull();        // NEW
        DBUG_RETURN(false);
      }
      

      Attachments

        Issue Links

          Activity

            There are no comments yet on this issue.

            People

              Unassigned Unassigned
              bar Alexander Barkov
              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.