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

Assertion `precision > 0' failed in decimal_bin_size upon SELECT with GROUP BY, IFNULL, DIV

    XMLWordPrintable

Details

    Description

      Yet another one which looks a bit different from MDEV-15873, MDEV-12059, MDEV-20754.

      CREATE TABLE t1 (a INT);
      INSERT INTO t1 VALUES (1),(2);
      SELECT a FROM t1 GROUP BY a, IFNULL( ( NULL DIV ( 2008 >> 0 ) ), @x := 0 );
       
      # Cleanup
      DROP TABLE t1;
      

      10.2 959fc0c0

      mysqld: /data/src/10.2/strings/decimal.c:1466: decimal_bin_size: Assertion `precision > 0' failed.
      200220 22:08:02 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f5c302e1f12 in __GI___assert_fail (assertion=0x563f9f854725 "precision > 0", file=0x563f9f8544a0 "/data/src/10.2/strings/decimal.c", line=1466, function=0x563f9f8549a0 <__PRETTY_FUNCTION__.11547> "decimal_bin_size") at assert.c:101
      #8  0x0000563f9f3eb048 in decimal_bin_size (precision=0, scale=0) at /data/src/10.2/strings/decimal.c:1466
      #9  0x0000563f9ea59207 in my_decimal_get_binary_size (precision=0, scale=0) at /data/src/10.2/sql/my_decimal.h:263
      #10 0x0000563f9ec257d7 in Field_new_decimal::Field_new_decimal (this=0x7f5c1806db58, len_arg=0, maybe_null_arg=false, name=0x0, dec_arg=0 '\000', unsigned_arg=false) at /data/src/10.2/sql/field.cc:3141
      #11 0x0000563f9ec25959 in Field_new_decimal::create_from_item (mem_root=0x7f5c1806d1a0, item=0x7f5c18013430) at /data/src/10.2/sql/field.cc:3186
      #12 0x0000563f9ea3d1ad in Item::create_tmp_field (this=0x7f5c18013430, group=false, table=0x7f5c1806c6e8, convert_int_length=9) at /data/src/10.2/sql/sql_select.cc:16339
      #13 0x0000563f9e8fd651 in Item::create_tmp_field (this=0x7f5c18013430, group=false, table=0x7f5c1806c6e8) at /data/src/10.2/sql/item.h:1868
      #14 0x0000563f9ea3d2b2 in create_tmp_field_from_item (thd=0x7f5c18000af0, item=0x7f5c18013430, table=0x7f5c1806c6e8, copy_func=0x7f5c2a613930, modify_item=true) at /data/src/10.2/sql/sql_select.cc:16382
      #15 0x0000563f9ea3da1f in create_tmp_field (thd=0x7f5c18000af0, table=0x7f5c1806c6e8, item=0x7f5c18013430, type=Item::FUNC_ITEM, copy_func=0x7f5c2a613930, from_field=0x7f5c1806d798, default_field=0x7f5c1806d778, group=true, modify_item=true, table_cant_handle_bit_fields=false, make_copy_field=false) at /data/src/10.2/sql/sql_select.cc:16602
      #16 0x0000563f9ea3ee56 in create_tmp_table (thd=0x7f5c18000af0, param=0x7f5c180153a0, fields=..., group=0x7f5c18012de0, distinct=false, save_sum_fields=false, select_options=2147748608, rows_limit=18446744073709551615, table_alias=0x563f9f465ea2 "", do_not_open=true, keep_row_order=false) at /data/src/10.2/sql/sql_select.cc:16975
      #17 0x0000563f9ea1a8f7 in JOIN::create_postjoin_aggr_table (this=0x7f5c18013640, tab=0x7f5c18014c30, table_fields=0x7f5c18013960, table_group=0x7f5c18012de0, save_sum_fields=false, distinct=false, keep_row_order=false) at /data/src/10.2/sql/sql_select.cc:2964
      #18 0x0000563f9ea19146 in JOIN::make_aggr_tables_info (this=0x7f5c18013640) at /data/src/10.2/sql/sql_select.cc:2566
      #19 0x0000563f9ea17d05 in JOIN::optimize_inner (this=0x7f5c18013640) at /data/src/10.2/sql/sql_select.cc:2237
      #20 0x0000563f9ea13e1f in JOIN::optimize (this=0x7f5c18013640) at /data/src/10.2/sql/sql_select.cc:1113
      #21 0x0000563f9ea1d32a in mysql_select (thd=0x7f5c18000af0, tables=0x7f5c180126a8, wild_num=0, fields=..., conds=0x0, og_num=2, order=0x0, group=0x7f5c18012de0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f5c18013620, unit=0x7f5c180046e8, select_lex=0x7f5c18004e28) at /data/src/10.2/sql/sql_select.cc:3810
      #22 0x0000563f9ea115c4 in handle_select (thd=0x7f5c18000af0, lex=0x7f5c18004628, result=0x7f5c18013620, setup_tables_done_option=0) at /data/src/10.2/sql/sql_select.cc:361
      #23 0x0000563f9e9dcd48 in execute_sqlcom_select (thd=0x7f5c18000af0, all_tables=0x7f5c180126a8) at /data/src/10.2/sql/sql_parse.cc:6224
      #24 0x0000563f9e9d3751 in mysql_execute_command (thd=0x7f5c18000af0) at /data/src/10.2/sql/sql_parse.cc:3531
      #25 0x0000563f9e9e0bea in mysql_parse (thd=0x7f5c18000af0, rawbuf=0x7f5c18012448 "SELECT a FROM t1 GROUP BY a, IFNULL( ( NULL DIV ( 2008 >> 0 ) ), @x := 0 )", length=74, parser_state=0x7f5c2a615200, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:7739
      #26 0x0000563f9e9cef43 in dispatch_command (command=COM_QUERY, thd=0x7f5c18000af0, packet=0x7f5c1808c841 "SELECT a FROM t1 GROUP BY a, IFNULL( ( NULL DIV ( 2008 >> 0 ) ), @x := 0 )", packet_length=74, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1831
      #27 0x0000563f9e9cd897 in do_command (thd=0x7f5c18000af0) at /data/src/10.2/sql/sql_parse.cc:1384
      #28 0x0000563f9eb228d3 in do_handle_one_connection (connect=0x563fa1a019f0) at /data/src/10.2/sql/sql_connect.cc:1336
      #29 0x0000563f9eb2263e in handle_one_connection (arg=0x563fa1a019f0) at /data/src/10.2/sql/sql_connect.cc:1241
      #30 0x0000563f9f33e6de in pfs_spawn_thread (arg=0x563fa1a68150) at /data/src/10.2/storage/perfschema/pfs.cc:1869
      #31 0x00007f5c3226a4a4 in start_thread (arg=0x7f5c2a616700) at pthread_create.c:456
      #32 0x00007f5c3039ed0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97
      

      Reproducible on 5.5, 10.1, 10.2.
      Not reproducible on 10.3+.
      No obvious problem on a non-debug build, including non-debug-ASAN.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              elenst Elena Stepanova
              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.