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

JSON_TABLE: Decimal type with M equal D causes Assertion `scale <= precision' failure

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • N/A
    • N/A
    • Data types, JSON
    • None

    Description

      select * from json_table('{"a":0}',"$" columns(a decimal(1,1) path '$.a')) foo;
      ERROR 2013 (HY000): Lost connection to MySQL server during query
      

      bb-10.5-hf 6dfb3fab2

      mysqld: /data/src/bb-10.5-hf/strings/decimal.c:1466: decimal_bin_size: Assertion `precision > 0' failed.
      200418 17:46:19 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007fb3749f2102 in __GI___assert_fail (assertion=0x561a92c71ba0 "scale <= precision", file=0x561a92c712c0 "/data/src/bb-10.5-hf/strings/decimal.c", line=1467, function=0x561a92c72300 <__PRETTY_FUNCTION__.14938> "decimal_bin_size") at assert.c:101
      #8  0x0000561a91f360b5 in decimal_bin_size (precision=1, scale=2) at /data/src/bb-10.5-hf/strings/decimal.c:1467
      #9  0x0000561a903850ab in my_decimal_get_binary_size (precision=1, scale=2) at /data/src/bb-10.5-hf/sql/my_decimal.h:324
      #10 0x0000561a90935106 in Field_new_decimal::Field_new_decimal (this=0x619000081c10, ptr_arg=0x0, len_arg=2, null_ptr_arg=0x561a920781c0 "", null_bit_arg=1 '\001', unireg_check_arg=Field::NONE, field_name_arg=0x62b000086458, dec_arg=2 '\002', zero_arg=false, unsigned_arg=true) at /data/src/bb-10.5-hf/sql/field.cc:3185
      #11 0x0000561a9078aa98 in Type_handler_newdecimal::make_table_field_from_def (this=0x561a93aec220 <type_handler_newdecimal>, share=0x62200000ff68, mem_root=0x62200000fe60, name=0x62b000086458, rec=..., bit=..., attr=0x62b000086428, flags=0) at /data/src/bb-10.5-hf/sql/sql_type.cc:7730
      #12 0x0000561a9081f849 in Create_json_table::add_json_table_fields (this=0x7fb350e23c70, thd=0x62b00007e270, table=0x62200000f190, jt=0x62b000085a48) at /data/src/bb-10.5-hf/sql/table_function.cc:649
      #13 0x0000561a9082005c in create_table_for_function (thd=0x62b00007e270, sql_table=0x62b000086a50) at /data/src/bb-10.5-hf/sql/table_function.cc:688
      #14 0x0000561a900794a0 in open_and_process_table (thd=0x62b00007e270, tables=0x62b000086a50, counter=0x7fb350e24230, flags=0, prelocking_strategy=0x7fb350e243b0, has_prelocking_list=false, ot_ctx=0x7fb350e24130) at /data/src/bb-10.5-hf/sql/sql_base.cc:3729
      #15 0x0000561a9007cb72 in open_tables (thd=0x62b00007e270, options=..., start=0x7fb350e24270, counter=0x7fb350e24230, flags=0, prelocking_strategy=0x7fb350e243b0) at /data/src/bb-10.5-hf/sql/sql_base.cc:4318
      #16 0x0000561a90081f9a in open_and_lock_tables (thd=0x62b00007e270, options=..., tables=0x62b000086a50, derived=true, flags=0, prelocking_strategy=0x7fb350e243b0) at /data/src/bb-10.5-hf/sql/sql_base.cc:5213
      #17 0x0000561a8ffde825 in open_and_lock_tables (thd=0x62b00007e270, tables=0x62b000086a50, derived=true, flags=0) at /data/src/bb-10.5-hf/sql/sql_base.h:504
      #18 0x0000561a90215fc0 in execute_sqlcom_select (thd=0x62b00007e270, all_tables=0x62b000086a50) at /data/src/bb-10.5-hf/sql/sql_parse.cc:6059
      #19 0x0000561a902054fb in mysql_execute_command (thd=0x62b00007e270) at /data/src/bb-10.5-hf/sql/sql_parse.cc:3904
      #20 0x0000561a90221836 in mysql_parse (thd=0x62b00007e270, rawbuf=0x62b000085290 "select * from json_table('{\"a\":0}',\"$\" columns(a decimal(2,2) path '$.a')) foo", length=78, parser_state=0x7fb350e25a90, is_com_multi=false, is_next_command=false) at /data/src/bb-10.5-hf/sql/sql_parse.cc:7918
      #21 0x0000561a901f808c in dispatch_command (command=COM_QUERY, thd=0x62b00007e270, packet=0x6290000d7271 "select * from json_table('{\"a\":0}',\"$\" columns(a decimal(2,2) path '$.a')) foo", packet_length=78, is_com_multi=false, is_next_command=false) at /data/src/bb-10.5-hf/sql/sql_parse.cc:1844
      #22 0x0000561a901f4ace in do_command (thd=0x62b00007e270) at /data/src/bb-10.5-hf/sql/sql_parse.cc:1363
      #23 0x0000561a9060d072 in do_handle_one_connection (connect=0x6100000046b0, put_in_cache=true) at /data/src/bb-10.5-hf/sql/sql_connect.cc:1422
      #24 0x0000561a9060c908 in handle_one_connection (arg=0x6100000045b0) at /data/src/bb-10.5-hf/sql/sql_connect.cc:1319
      #25 0x00007fb37526cfa3 in start_thread (arg=<optimized out>) at pthread_create.c:486
      #26 0x00007fb374abb4cf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      CAST works, so it doesn't seem to be a generic problem:

      select cast(0 as decimal(1,1));
      +-------------------------+
      | cast(0 as decimal(1,1)) |
      +-------------------------+
      |                     0.0 |
      +-------------------------+
      1 row in set (0.001 sec)
      

      Attachments

        Issue Links

          Activity

            People

              holyfoot Alexey Botchkov
              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.