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

A case expression with ROW arguments in THEN crashes

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 12.0(EOL)
    • 12.0.1
    • Data types
    • None

    Description

      This searched CASE statement:

      SELECT CASE WHEN TRUE THEN ROW(1,2) ELSE ROW(2,1) END;
      

      crashes with the following stack trace:

      #4  0x00007ffff7254c57 in __assert_fail () from /lib64/libc.so.6
      #5  0x00005555563f114f in Type_handler_hybrid_field_type::aggregate_for_result
          (this=0x7fff84019b90, funcname=..., items=0x7fff84019bf8, nitems=2, 
          treat_bit_as_number=true) at /home/bar/maria-git/12.0/sql/sql_type.cc:1899
      #6  0x000055555658f61e in Item_func_case::aggregate_then_and_else_arguments (
          this=0x7fff84019ae0, thd=0x7fff84000dc8, start=1)
          at /home/bar/maria-git/12.0/sql/item_cmpfunc.cc:3381
      #7  0x000055555658f4cc in Item_func_case_searched::fix_length_and_dec (
          this=0x7fff84019ae0, thd=0x7fff84000dc8)
      

      on DEBUG_ASSERT in aggregate_for_result:

      │     1891 bool Type_handler_hybrid_field_type::                               │
      │     1892 aggregate_for_result(const LEX_CSTRING &funcname, Item **items, uint│
      │     1893                      bool treat_bit_as_number)                      │
      │     1894 {                                                                   │
      │     1895   bool bit_and_non_bit_mixture_found= false;                        │
      │     1896   uint32 max_display_length;                                        │
      │     1897   if (!nitems || items[0]->result_type() == ROW_RESULT)             │
      │     1898   {                                                                 │
      │  >  1899     DBUG_ASSERT(0);                                                 │
      │     1900     set_handler(&type_handler_null);                                │
      │     1901     return true;                                                    │
      │     1902   } 
      

      The problem was introduced by the patch for MDEV-20034.

      A similar simple CASE statement does not crash:

      SELECT CASE TRUE WHEN TRUE THEN ROW(1,2) ELSE ROW(2,1) END;
      

      ERROR 1241 (21000): Operand should contain 1 column(s)
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.