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

Pushdown from HAVING: Item_func is immutable while arguments are not

    XMLWordPrintable

Details

    • Bug
    • Status: Stalled (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.9.8, 11.3.0, 10.10(EOL), 10.11, 11.0(EOL), 11.1(EOL), 11.2(EOL)
    • 10.11
    • Optimizer, Server
    • Ubuntu 20.04

    Description

      Run these queries in release build:

      CREATE TABLE t0 ( c12 INT , c41 INT ) ;
      INSERT INTO t0 ( c12 , c41 ) SELECT -128 AS c9 , -66 AS c36 ;
      ALTER TABLE t0 ADD COLUMN c40 INT AFTER c41 ;
      INSERT INTO t0 VALUES ( DEFAULT , DEFAULT , DEFAULT ) , ( DEFAULT , DEFAULT , DEFAULT ) ;
      SELECT t0 . c41 AS c38 FROM ( SELECT c40 AS c51 , ( SELECT c41 AS c58 FROM t0 LIMIT 1 ) - LTRIM ( 103 ) AS c2 , -69 AS c58 FROM t0 ) AS t1 JOIN t0 ON t0 . c12 = t0 . c40 WHERE OCT ( + NULLIF ( REVERSE ( c12 ) IS NOT NULL , -49 ) ) NOT LIKE LOG ( 55 NOT LIKE SUBSTRING( -34 , ABS ( 21 ) - FORMAT ( 4 IS NULL , TRUNCATE ( 74 , -1279808445404668877 ) IS NULL IS NULL ) ) , -31 ) GROUP BY c58 , c51 , c41 HAVING c51 = 53 REGEXP EXP ( t1 . c58 ) ;
      

      Will trigger Segmentation fault:

      GDB info:
      Thread 17 "mariadbd" received signal SIGSEGV, Segmentation fault.
      [Switching to Thread 0x7fffd1c17300 (LWP 3411)]
      0x0000000001380fec in Item_direct_view_ref::used_tables (this=<optimized out>) at /home/wx/mariadb-11.3.0/sql/item.cc:10831
      10831	            (null_ref_table != NO_NULL_TABLE && !null_ref_table->const_table ?
      (gdb) p null_ref_table
      $40 = (TABLE *) 0x0
       
      #0  0x0000000001380fec in Item_direct_view_ref::used_tables (this=<optimized out>) at /home/wx/mariadb-11.3.0/sql/item.cc:10831
      #1  0x0000000000c18d46 in get_sort_by_table (a=0x6290000b27a0, b=0x6290000b27a0, tables=..., const_tables=<optimized out>) at /home/wx/mariadb-11.3.0/sql/sql_select.cc:27982
      #2  make_join_statistics (join=0x6290000b4cb0, tables_list=..., keyuse_array=0x6290000b5010) at /home/wx/mariadb-11.3.0/sql/sql_select.cc:5905
      #3  JOIN::optimize_inner (this=<optimized out>) at /home/wx/mariadb-11.3.0/sql/sql_select.cc:2624
      #4  0x0000000000bfc156 in JOIN::optimize (this=this@entry=0x6290000b4cb0) at /home/wx/mariadb-11.3.0/sql/sql_select.cc:1944
      #5  0x0000000000be4fdf in mysql_select (thd=<optimized out>, thd@entry=0x62b00016c218, tables=<optimized out>, fields=..., conds=<optimized out>, og_num=<optimized out>, order=<optimized out>, group=0x6290000b27a0, having=0x6290000b4238, proc_param=0x0, select_options=<optimized out>, result=0x6290000b31d8, unit=0x62b0001704a8, select_lex=0x629000091618) at /home/wx/mariadb-11.3.0/sql/sql_select.cc:5235
      #6  0x0000000000be4596 in handle_select (thd=thd@entry=0x62b00016c218, lex=<optimized out>, lex@entry=0x62b0001703c8, result=<optimized out>, result@entry=0x6290000b31d8, setup_tables_done_option=<optimized out>, setup_tables_done_option@entry=0) at /home/wx/mariadb-11.3.0/sql/sql_select.cc:628
      #7  0x0000000000b3df18 in execute_sqlcom_select (thd=0x62b00016c218, all_tables=<optimized out>) at /home/wx/mariadb-11.3.0/sql/sql_parse.cc:6013
      #8  0x0000000000b2cd51 in mysql_execute_command (thd=0x62b00016c218, is_called_from_prepared_stmt=<optimized out>) at /home/wx/mariadb-11.3.0/sql/sql_parse.cc:3912
      #9  0x0000000000b1fe79 in mysql_parse (thd=thd@entry=0x62b00016c218, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>, parser_state@entry=0x7fffd242ca80) at /home/wx/mariadb-11.3.0/sql/sql_parse.cc:7734
      #10 0x0000000000b19069 in dispatch_command (command=<optimized out>, thd=0x62b00016c218, packet=<optimized out>, packet_length=<optimized out>, blocking=<optimized out>) at /home/wx/mariadb-11.3.0/sql/sql_parse.cc:1893
      #11 0x0000000000b20b71 in do_command (thd=0x62b00016c218, blocking=true) at /home/wx/mariadb-11.3.0/sql/sql_parse.cc:1406
      #12 0x0000000000f03476 in do_handle_one_connection (connect=<optimized out>, put_in_cache=<optimized out>) at /home/wx/mariadb-11.3.0/sql/sql_connect.cc:1445
      #13 0x0000000000f02eb9 in handle_one_connection (arg=arg@entry=0x608001ccee38) at /home/wx/mariadb-11.3.0/sql/sql_connect.cc:1347
      #14 0x0000000001a00c1b in pfs_spawn_thread (arg=0x617000005498) at /home/wx/mariadb-11.3.0/storage/perfschema/pfs.cc:2201
      #15 0x00007ffff79f7609 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
      #16 0x00007ffff770f133 in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      Attachments

        Issue Links

          Activity

            People

              igor Igor Babaev
              Xin Wen Xin Wen
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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