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

Assertion `!tmp.is_null()' failed in cmp_item_fbt::cmp_not_null() on DECODE_ORACLE comparing a UUID, INET4 or INET6 value with a SET column

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 13.3
    • None
    • Server
    • None

    Description

      Problem

      DECODE_ORACLE with a UUID, INET4 or INET6 first argument and a SET column as a later argument aborts a debug build in cmp_item_fbt::cmp_not_null() (sql/sql_type_fixedbin.h). The same comparison with an ENUM, INT or DATE column, a VARCHAR column or a string literal does not.

      How to repeat

      Default sql_mode, fresh server:

      CREATE TABLE t (u UUID, s SET('x','y','z'));
      INSERT INTO t VALUES ('6ccd780c-baba-1026-9564-5b8c656024db', 'x,z');
      SELECT DECODE_ORACLE(u, s, 'one', 'other') FROM t;

      INET4 and INET6 behave the same:

      CREATE TABLE t (a INET4, s SET('x','y'));
      INSERT INTO t VALUES ('1.2.3.4', 'x');
      SELECT DECODE_ORACLE(a, s, 1, 2) FROM t;

      I started a fresh server on an empty data directory three times for each statement (debug build of 13.3.0 main, --no-defaults) and ran it once: the SELECT hit the assertion in 3 of 3 runs for UUID, for INET4 and for INET6 (CREATE TABLE t (u INET6, s SET('x','y')); INSERT INTO t VALUES ('::1', 'x');).

      Actual result

      Debug build, SIGABRT, the client loses the connection:

      sql/sql_type_fixedbin.h:768: virtual int Type_handler_fbt<UUID<false>, Type_collection_uuid>::cmp_item_fbt::cmp_not_null(const Value *): Assertion `!tmp.is_null()' failed.
        Type_handler_fbt<UUID<false>, Type_collection_uuid>::cmp_item_fbt::cmp_not_null(Value const*)
        Predicant_to_list_comparator::cmp_args_nulls_equal(THD*, Item_args*, unsigned int)
        Predicant_to_list_comparator::cmp_nulls_equal(THD*, Item_args*, unsigned int*)
        Item_func_decode_oracle::find_item()
        Item_func_case::str_op(String*)
        Item_func_hybrid_field_type::str_op_with_null_check(String*)
        Item_func_hybrid_field_type::val_str_from_str_op(String*)
        Type_handler_string_result::Item_func_hybrid_field_type_val_str(Item_func_hybrid_field_type*, String*)
        Item_func_hybrid_field_type::val_str(String*)
        Type_handler::Item_send_str(Item*, Protocol*, st_value*)

      The failing line is the check after the second argument has been converted to the fixed-binary type: Fbt_null tmp(val->m_string); DBUG_ASSERT(!tmp.is_null());. The text of the SET value (x,z, x) is not a valid UUID or address, so the conversion gives NULL. cmp_item_fbt::cmp(), next to it, handles a failed conversion by returning UNKNOWN; cmp_not_null(), which the NULL-equal path of DECODE_ORACLE calls, asserts instead.

      Notes

      Not affected (fresh-server runs on the unpatched debug build): DECODE_ORACLE(u, u, 1, 2), DECODE_ORACLE(s, u, 1, 2) and DECODE_ORACLE(u, 'x', 1, 2) (3 of 3 each), and DECODE_ORACLE(u, v, 'one', 'other') with v VARCHAR(10) holding abc (one run, returns other). On a debug build of the same commit that carries a small local hook in sql/sql_parse.cc, one run each did not crash for DECODE_ORACLE(u, e, 1, 2) (e ENUM), DECODE_ORACLE(u, i, 1, 2) (i INT), DECODE_ORACLE(u, d, 1, 2) (d DATE), CASE u WHEN s THEN 1 ELSE 2 END, u IN (s, u), or when the UUID or the SET value is NULL. A build of the same commit without assertions (the coverage build, with the same local hook) returns other for the UUID/SET statement above (2 of 2), so the problem is the assertion on this path, not a visible wrong result there.

      Attachments

        Activity

          People

            Unassigned Unassigned
            hacker_zheng Wang Zheng
            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.