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

Assertion `length > 0' failed in ptr_compare upon ORDER BY with bad conversion

    XMLWordPrintable

    Details

      Description

      SET sql_mode= '';
      CREATE TABLE t1 (pk INT PRIMARY KEY);
      INSERT INTO t1 VALUES (1),(2);
      SELECT * FROM t1 ORDER BY 'foo', CONVERT(pk, CHAR(0)) LIMIT 2;
       
      # Cleanup
      DROP TABLE t1;
      

      10.0 bcc677bb7

      mysqld: /data/src/10.0/mysys/ptr_cmp.c:94: ptr_compare: Assertion `length > 0' failed.
      180819 17:32:54 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007fec92194ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
      #8  0x0000000000e2966d in ptr_compare (compare_length=0x7fec94262f48, a=0x7fec8a859a38, b=0x7fec8a859a30) at /data/src/10.0/mysys/ptr_cmp.c:94
      #9  0x0000000000e2a66a in queue_insert (queue=0x7fec94262f60, element=0x7fec8a859a38 "L\232\205\212\354\177") at /data/src/10.0/mysys/queues.c:203
      #10 0x000000000083a5ef in Bounded_queue<unsigned char, unsigned char>::push (this=0x7fec94262f40, element=0x7fec94262e10 "") at /data/src/10.0/sql/bounded_queue.h:190
      #11 0x0000000000836e58 in find_all_keys (param=0x7fec94263000, select=0x7fec8abb13b0, fs_info=0x7fec94262f90, buffpek_pointers=0x7fec94263220, tempfile=0x7fec94263080, pq=0x7fec94262f40, found_rows=0x7fec942634c8) at /data/src/10.0/sql/filesort.cc:817
      #12 0x00000000008357e4 in filesort (thd=0x7fec8c2a2070, table=0x7fec8a89e470, sortorder=0x7fec8abb1900, s_length=1, select=0x7fec8abb13b0, max_rows=2, sort_positions=false, examined_rows=0x7fec942634d0, found_rows=0x7fec942634c8) at /data/src/10.0/sql/filesort.cc:297
      #13 0x00000000006b514c in create_sort_index (thd=0x7fec8c2a2070, join=0x7fec8a8facf0, order=0x7fec8a8fabd8, filesort_limit=2, select_limit=2, is_order_by=true) at /data/src/10.0/sql/sql_select.cc:20996
      #14 0x0000000000689f34 in JOIN::exec_inner (this=0x7fec8a8facf0) at /data/src/10.0/sql/sql_select.cc:3093
      #15 0x00000000006875fe in JOIN::exec (this=0x7fec8a8facf0) at /data/src/10.0/sql/sql_select.cc:2409
      #16 0x000000000068a9a0 in mysql_select (thd=0x7fec8c2a2070, rref_pointer_array=0x7fec8c2a63a0, tables=0x7fec8a8fa2c8, wild_num=1, fields=..., conds=0x0, og_num=2, order=0x7fec8a8fa970, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7fec8a8facd0, unit=0x7fec8c2a5a08, select_lex=0x7fec8c2a60f8) at /data/src/10.0/sql/sql_select.cc:3348
      #17 0x0000000000680a14 in handle_select (thd=0x7fec8c2a2070, lex=0x7fec8c2a5940, result=0x7fec8a8facd0, setup_tables_done_option=0) at /data/src/10.0/sql/sql_select.cc:377
      #18 0x0000000000654f07 in execute_sqlcom_select (thd=0x7fec8c2a2070, all_tables=0x7fec8a8fa2c8) at /data/src/10.0/sql/sql_parse.cc:5301
      #19 0x000000000064d45d in mysql_execute_command (thd=0x7fec8c2a2070) at /data/src/10.0/sql/sql_parse.cc:2557
      #20 0x0000000000657d64 in mysql_parse (thd=0x7fec8c2a2070, rawbuf=0x7fec8a8fa088 "SELECT * FROM t1 ORDER BY 'foo', CONVERT(pk, CHAR(0)) LIMIT 2", length=61, parser_state=0x7fec94264640) at /data/src/10.0/sql/sql_parse.cc:6637
      #21 0x000000000064a684 in dispatch_command (command=COM_QUERY, thd=0x7fec8c2a2070, packet=0x7fec8d7e5071 "SELECT * FROM t1 ORDER BY 'foo', CONVERT(pk, CHAR(0)) LIMIT 2", packet_length=61) at /data/src/10.0/sql/sql_parse.cc:1300
      #22 0x0000000000649984 in do_command (thd=0x7fec8c2a2070) at /data/src/10.0/sql/sql_parse.cc:1003
      #23 0x000000000076acdc in do_handle_one_connection (thd_arg=0x7fec8c2a2070) at /data/src/10.0/sql/sql_connect.cc:1377
      #24 0x000000000076aa4e in handle_one_connection (arg=0x7fec8c2a2070) at /data/src/10.0/sql/sql_connect.cc:1292
      #25 0x0000000000accef0 in pfs_spawn_thread (arg=0x7fec8c1a2370) at /data/src/10.0/storage/perfschema/pfs.cc:1861
      #26 0x00007fec93e98494 in start_thread (arg=0x7fec94265700) at pthread_create.c:333
      #27 0x00007fec9225193f in clone () from /lib/x86_64-linux-gnu/libc.so.6
      

      Reproducible on 10.0, 10.1, 10.2, with at least InnoDB and MyISAM.
      Couldn't reproduce on 10.3

        Attachments

          Activity

            People

            Assignee:
            varun Varun Gupta
            Reporter:
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: