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

optimizer_join_limit_pref_ratio: assertion when the ORDER BY table becomes constant

    XMLWordPrintable

Details

    Description

      CREATE TABLE t1 (a INT KEY,b INT, KEY(b)) ;
      SET optimizer_join_limit_pref_ratio=1;
      INSERT INTO t1 VALUES (2,NULL);
      SET SESSION sql_select_limit=1;
      INSERT INTO t1 VALUES (5,NULL);
      SELECT * FROM t1 NATURAL JOIN t1 AS t2 WHERE t1.b=NULL ORDER BY t1.a;
      

      Leads to:

      CS 10.6.20 9849e3f948c7c0337220353fd34460b2f383a287 (Debug)

      mariadbd: /test/10.6_dbg/sql/sql_select.cc:9792: bool greedy_search(JOIN*, table_map, uint, uint, uint): 
      Assertion `join->best_read < double(1.79769313486231570814527423731704357e+308L)' failed.
      

      CS 10.6.20 9849e3f948c7c0337220353fd34460b2f383a287 (Debug)

      Core was generated by `/test/MD161024-mariadb-10.6.20-linux-x86_64-dbg/bin/mariadbd --no-defaults --ma'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      [Current thread is 1 (Thread 0x14cf84aa8700 (LWP 21261))]
      (gdb) bt
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #1  0x000014cf8efaf859 in __GI_abort () at abort.c:79
      #2  0x000014cf8efaf729 in __assert_fail_base (fmt=0x14cf8f145588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55f88e388e28 "join->best_read < double(1.79769313486231570814527423731704357e+308L)", file=0x55f88e387bf8 "/test/10.6_dbg/sql/sql_select.cc", line=9792, function=<optimized out>) at assert.c:92
      #3  0x000014cf8efc0fd6 in __GI___assert_fail (assertion=assertion@entry=0x55f88e388e28 "join->best_read < double(1.79769313486231570814527423731704357e+308L)", file=file@entry=0x55f88e387bf8 "/test/10.6_dbg/sql/sql_select.cc", line=line@entry=9792, function=function@entry=0x55f88e388df0 "bool greedy_search(JOIN*, table_map, uint, uint, uint)") at assert.c:101
      #4  0x000055f88d6d6bb9 in greedy_search (join=join@entry=0x14cf48015f70, remaining_tables=remaining_tables@entry=2, search_depth=search_depth@entry=62, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /test/10.6_dbg/sql/sql_select.cc:9792
      #5  0x000055f88d6d7d50 in choose_plan (join=join@entry=0x14cf48015f70, join_tables=2) at /test/10.6_dbg/sql/sql_select.cc:9316
      #6  0x000055f88d7033ef in make_join_statistics (join=join@entry=0x14cf48015f70, tables_list=<optimized out>, keyuse_array=keyuse_array@entry=0x14cf48016298) at /test/10.6_dbg/sql/sql_select.cc:6124
      #7  0x000055f88d70a300 in JOIN::optimize_inner (this=this@entry=0x14cf48015f70) at /test/10.6_dbg/sql/sql_select.cc:2610
      #8  0x000055f88d70a80b in JOIN::optimize (this=this@entry=0x14cf48015f70) at /test/10.6_dbg/sql/sql_select.cc:1927
      #9  0x000055f88d70a8e4 in mysql_select (thd=thd@entry=0x14cf48000d48, tables=0x14cf48013aa0, fields=@0x14cf48013728: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14cf48013a50, last = 0x14cf48017390, elements = 2}, <No data fields>}, conds=0x14cf48015260, og_num=1, order=0x14cf48015df8, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14cf48015f48, unit=0x14cf48005130, select_lex=0x14cf48013468) at /test/10.6_dbg/sql/sql_select.cc:5179
      #10 0x000055f88d70b138 in handle_select (thd=thd@entry=0x14cf48000d48, lex=lex@entry=0x14cf48005068, result=result@entry=0x14cf48015f48, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.6_dbg/sql/sql_select.cc:573
      #11 0x000055f88d683695 in execute_sqlcom_select (thd=thd@entry=0x14cf48000d48, all_tables=0x14cf48013aa0) at /test/10.6_dbg/sql/sql_parse.cc:6396
      #12 0x000055f88d690310 in mysql_execute_command (thd=thd@entry=0x14cf48000d48, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.6_dbg/sql/sql_parse.cc:3988
      #13 0x000055f88d67c8df in mysql_parse (thd=thd@entry=0x14cf48000d48, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14cf84aa7300) at /test/10.6_dbg/sql/sql_parse.cc:8181
      #14 0x000055f88d68b504 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14cf48000d48, packet=packet@entry=0x14cf4800afd9 "SELECT * FROM t1 natural join t1 as t2 where t1.b=NULL order by t1.a", packet_length=packet_length@entry=68, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_class.h:1419
      #15 0x000055f88d68dea0 in do_command (thd=0x14cf48000d48, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_parse.cc:1410
      #16 0x000055f88d7e9ff0 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55f890dbf8e8, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1417
      #17 0x000055f88d7ea5ad in handle_one_connection (arg=arg@entry=0x55f890dbf8e8) at /test/10.6_dbg/sql/sql_connect.cc:1319
      #18 0x000055f88dc6c404 in pfs_spawn_thread (arg=0x55f890dbc568) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
      #19 0x000014cf8f4c0609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #20 0x000014cf8f0ac133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.6.20 (dbg), 10.11.10 (dbg), 11.2.6 (dbg), 11.4.4 (dbg), 11.6.2 (dbg), 11.7.0 (dbg)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.5.27 (dbg), 10.5.27 (opt), 10.6.20 (opt), 10.11.10 (opt), 11.2.6 (opt), 11.4.4 (opt), 11.6.2 (opt), 11.7.0 (opt)

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.