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

After upgrading Mariadb to v10.6.19 a case in a view crashes server

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 10.6.19
    • 10.5.27
    • Server, Views
    • Docker linux (FROM mariadb:10.6.19)

    Description

      After upgrading Mariadb from v10.6.18 to v10.6.19
      A case in a select clause crashes the whole MariaDb server

      If you need more debug i can give it to you for sure.

      My examples in attachment

      On the failing case, we wrote the case like that

       case
              myfield when 1 then 0
              when null then 0
              else myfield
          end as myalias_
      

      On the successful case we wrote the case like that

       case
           *   when myfield = 1 then 0*
              when null then 0
              else myfield
          end as myalias_
      

      the fact is, this could happened everywhere we used a case keyword ...

      So could you please give us a feedback on this issue ?

      Sorry in advance if you have not put this bug on the right topic

      Best

      David

      Attachments

        1. 2024-09-17_16h43_50-1.png
          2024-09-17_16h43_50-1.png
          55 kB
        2. 2024-09-17_16h47_57.png
          2024-09-17_16h47_57.png
          10 kB
        3. 2024-09-18_08h25_06.png
          2024-09-18_08h25_06.png
          107 kB
        4. 2024-09-18_08h25_53.png
          2024-09-18_08h25_53.png
          6 kB
        5. databaseScheme.sql
          5 kB
        6. query.sql
          0.4 kB

        Issue Links

          Activity

            griesi009 Chris added a comment -

            Hi Daniel, I see the same issue after upgrading from 10.5.23-0+deb11u1 => 1:10.5.26-0+deb11u1. In my case there is no DISTINCT involved. It´s just a case switch in a view. When I remove the case it works. Still trying to narrow it down. just wanted to let you know that this is obviously a problem for more people. Will comeback if I narrowed it down

            griesi009 Chris added a comment - Hi Daniel, I see the same issue after upgrading from 10.5.23-0+deb11u1 => 1:10.5.26-0+deb11u1. In my case there is no DISTINCT involved. It´s just a case switch in a view. When I remove the case it works. Still trying to narrow it down. just wanted to let you know that this is obviously a problem for more people. Will comeback if I narrowed it down
            griesi009 Chris added a comment -

            Hi Daniel,

            I narrowed it down. I attached the needed table/view definition. databaseScheme.sql

            When you run the attached query query.sql mariadb crashes. As soon as you replace the case statement in the view with a fixed value it works. Hope it helps to reproduce it

            griesi009 Chris added a comment - Hi Daniel, I narrowed it down. I attached the needed table/view definition. databaseScheme.sql When you run the attached query query.sql mariadb crashes. As soon as you replace the case statement in the view with a fixed value it works. Hope it helps to reproduce it
            griesi009 Chris added a comment -

            Hi Daniel,

            when I replace the case statement with if(`sb`.`state` = 5, 0, NULL) AS `availability` it works

            griesi009 Chris added a comment - Hi Daniel, when I replace the case statement with if(`sb`.`state` = 5, 0, NULL) AS `availability` it works
            danblack Daniel Black added a comment -

            #9138 0x00000000008b7fb2 in Item_func_case_simple::do_build_clone(THD*) const ()
            #9139 0x00000000008b7fb2 in Item_func_case_simple::do_build_clone(THD*) const ()
            #9140 0x00000000008b7fb2 in Item_func_case_simple::do_build_clone(THD*) const ()
            #9141 0x00000000008b7fb2 in Item_func_case_simple::do_build_clone(THD*) const ()
            #9142 0x00000000008b7fb2 in Item_func_case_simple::do_build_clone(THD*) const ()
            #9143 0x00000000008b7fb2 in Item_func_case_simple::do_build_clone(THD*) const ()
            #9144 0x00000000008b7fb2 in Item_func_case_simple::do_build_clone(THD*) const ()
            #9145 0x000000000089c808 in Item_field::derived_field_transformer_for_where(THD*, unsigned char*) ()
            #9146 0x00000000008c77ee in Item_args::transform_args(THD*, Item* (Item::*)(THD*, unsigned char*), unsigned char*) ()
            #9147 0x00000000008c787b in Item_func::transform(THD*, Item* (Item::*)(THD*, unsigned char*), unsigned char*) ()
            #9148 0x00000000006afb34 in transform_condition_or_part(THD*, Item*, Item* (Item::*)(THD*, unsigned char*), unsigned char*) ()
            #9149 0x00000000006cdb2d in st_select_lex::pushdown_cond_into_where_clause(THD*, Item*, Item**, Item* (Item::*)(THD*, unsigned char*), unsigned char*) ()
            #9150 0x00000000006afd9b in pushdown_cond_for_derived(THD*, Item*, TABLE_LIST*) ()
            #9151 0x0000000000703435 in JOIN::optimize_inner() ()
            #9152 0x00000000007011d8 in JOIN::optimize() ()
            #9153 0x00000000006fd41e in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) ()
            #9154 0x00000000006fd323 in handle_select(THD*, LEX*, select_result*, unsigned long) ()
            #9155 0x00000000006e1c09 in execute_sqlcom_select(THD*, TABLE_LIST*) ()
            #9156 0x00000000006dcdb9 in mysql_execute_command(THD*, bool) ()
            #9157 0x00000000006d945c in mysql_parse(THD*, char*, unsigned int, Parser_state*) ()
            #9158 0x00000000006d7e7b in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) ()
            #9159 0x00000000006d97a7 in do_command(THD*, bool) ()
            #9160 0x00000000007ade82 in do_handle_one_connection(CONNECT*, bool) ()
            #9161 0x00000000007adce9 in handle_one_connection ()
            #9162 0x0000000000a15c85 in pfs_spawn_thread ()
            #9163 0x00007f09e2aa66d7 in start_thread () from /lib64/libc.so.6
            #9164 0x00007f09e2b2a60c in clone3 () from /lib64/libc.so.6
            

            danblack Daniel Black added a comment - #9138 0x00000000008b7fb2 in Item_func_case_simple::do_build_clone(THD*) const () #9139 0x00000000008b7fb2 in Item_func_case_simple::do_build_clone(THD*) const () #9140 0x00000000008b7fb2 in Item_func_case_simple::do_build_clone(THD*) const () #9141 0x00000000008b7fb2 in Item_func_case_simple::do_build_clone(THD*) const () #9142 0x00000000008b7fb2 in Item_func_case_simple::do_build_clone(THD*) const () #9143 0x00000000008b7fb2 in Item_func_case_simple::do_build_clone(THD*) const () #9144 0x00000000008b7fb2 in Item_func_case_simple::do_build_clone(THD*) const () #9145 0x000000000089c808 in Item_field::derived_field_transformer_for_where(THD*, unsigned char*) () #9146 0x00000000008c77ee in Item_args::transform_args(THD*, Item* (Item::*)(THD*, unsigned char*), unsigned char*) () #9147 0x00000000008c787b in Item_func::transform(THD*, Item* (Item::*)(THD*, unsigned char*), unsigned char*) () #9148 0x00000000006afb34 in transform_condition_or_part(THD*, Item*, Item* (Item::*)(THD*, unsigned char*), unsigned char*) () #9149 0x00000000006cdb2d in st_select_lex::pushdown_cond_into_where_clause(THD*, Item*, Item**, Item* (Item::*)(THD*, unsigned char*), unsigned char*) () #9150 0x00000000006afd9b in pushdown_cond_for_derived(THD*, Item*, TABLE_LIST*) () #9151 0x0000000000703435 in JOIN::optimize_inner() () #9152 0x00000000007011d8 in JOIN::optimize() () #9153 0x00000000006fd41e in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) () #9154 0x00000000006fd323 in handle_select(THD*, LEX*, select_result*, unsigned long) () #9155 0x00000000006e1c09 in execute_sqlcom_select(THD*, TABLE_LIST*) () #9156 0x00000000006dcdb9 in mysql_execute_command(THD*, bool) () #9157 0x00000000006d945c in mysql_parse(THD*, char*, unsigned int, Parser_state*) () #9158 0x00000000006d7e7b in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) () #9159 0x00000000006d97a7 in do_command(THD*, bool) () #9160 0x00000000007ade82 in do_handle_one_connection(CONNECT*, bool) () #9161 0x00000000007adce9 in handle_one_connection () #9162 0x0000000000a15c85 in pfs_spawn_thread () #9163 0x00007f09e2aa66d7 in start_thread () from /lib64/libc.so.6 #9164 0x00007f09e2b2a60c in clone3 () from /lib64/libc.so.6
            danblack Daniel Black added a comment -

            Thank you very much for the test case.

            I can confirm that by using your test case this has already been fixed for the next release.

            danblack Daniel Black added a comment - Thank you very much for the test case. I can confirm that by using your test case this has already been fixed for the next release.

            People

              danblack Daniel Black
              dgagnaire DGA
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.