Bug #34763 item_subselect.cc:1235:Item_in_subselect::row_value_transformer:Assertion failed
Submitted: 22 Feb 20:20 Modified: 14 Apr 21:22
Reporter: Gleb Shchepa
Status: Closed
Category:Server: Optimizer Severity:S3 (Non-critical)
Version:5.0+ OS:Any
Assigned to: Gleb Shchepa Target Version:5.0+,5.1.24
Triage: D1 (Critical)

[22 Feb 20:20] Gleb Shchepa
Description:
Query:
  SELECT ROW(1, 2) IN (SELECT a, 3) FROM t1 GROUP BY a;

mysqld:
 item_subselect.cc:1235: Item_subselect::trans_res
Item_in_subselect::row_value_transformer(JOIN*): Assertion `left_expr->fixed &&
select_lex->ref_pointer_array[i]->fixed' failed.

Stack trace:
#3  0xb7d1e7a5 in __assert_fail () from /lib/libc.so.6
#4  0x0819c75a in Item_in_subselect::row_value_transformer (this=0x873d108, 
    join=0x8742aa0) at item_subselect.cc:1235
#5  0x0819ecd7 in Item_in_subselect::select_in_like_transformer (
    this=0x873d108, join=0x8742aa0, func=0x86b7958) at item_subselect.cc:1490
#6  0x0819edb4 in Item_in_subselect::select_transformer (this=0x873d108, 
    join=0x8742aa0) at item_subselect.cc:1401
#7  0x08256731 in JOIN::prepare (this=0x8742aa0, rref_pointer_array=0x873cd44, 
    tables_init=0x0, wild_num=0, conds_init=0x0, og_num=0, order_init=0x0, 
    group_init=0x0, having_init=0x0, proc_param_init=0x0, 
    select_lex_arg=0x873cc20, unit_arg=0x873cdc8) at sql_select.cc:501
#8  0x0819bab2 in subselect_single_select_engine::prepare (this=0x873d1b8)
    at item_subselect.cc:1652
#9  0x0819f582 in Item_subselect::fix_fields (this=0x873d108, 
    thd_param=0x8704210, ref=0x873d1e4) at item_subselect.cc:154
#10 0x0819f877 in Item_in_subselect::fix_fields (this=0x873d108, 
    thd_arg=0x8704210, ref=0x873d1e4) at item_subselect.cc:1520
#11 0x08222463 in setup_fields (thd=0x8704210, ref_pointer_array=0x873e350, 
    fields=@0x8705240, set_query_id=true, sum_func_list=0x873e290, 
    allow_sum_func=true) at sql_base.cc:5112
---Type <return> to continue, or q <return> to quit---
#12 0x08256440 in JOIN::prepare (this=0x873d550, rref_pointer_array=0x87052d0, 
    tables_init=0x873d260, wild_num=0, conds_init=0x0, og_num=1, 
    order_init=0x0, group_init=0x873d4a8, having_init=0x0, 
    proc_param_init=0x0, select_lex_arg=0x87051ac, unit_arg=0x8704f74)
    at sql_select.cc:467
#13 0x0825727f in mysql_select (thd=0x8704210, rref_pointer_array=0x87052d0, 
    tables=0x873d260, wild_num=0, fields=@0x8705240, conds=0x0, og_num=1, 
    order=0x0, group=0x873d4a8, having=0x0, proc_param=0x0, 
    select_options=2156153344, result=0x873d538, unit=0x8704f74, 
    select_lex=0x87051ac) at sql_select.cc:2274
#14 0x0825b702 in handle_select (thd=0x8704210, lex=0x8704f1c, 
    result=0x873d538, setup_tables_done_option=0) at sql_select.cc:257
#15 0x081ef6d5 in mysql_execute_command (thd=0x8704210) at sql_parse.cc:2736
#16 0x081f7afc in mysql_parse (thd=0x8704210, 
    inBuf=0x873ca50 "SELECT ROW(1, 2) IN (SELECT a, 3) FROM t1 GROUP BY a", 
    length=52, found_semicolon=0xb72ce1b0) at sql_parse.cc:6174

How to repeat:
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

CREATE TABLE t1 (a INT);

SELECT ROW(1, 2) IN (SELECT a, 3) FROM t1 GROUP BY a;

DROP TABLE t1;
[22 Feb 21:02] Miguel Solorzano
Thank you for the bug report.

c:\dbs>5.1\bin\mysqld --standalone --console
080222 10:48:55  InnoDB: Started; log sequence number 0 46409
080222 10:48:56 [Note] Event Scheduler: Loaded 0 events
080222 10:48:56 [Note] 5.1\bin\mysqld: ready for connections.
Version: '5.1.24-rc-nt-debug-log'  socket: ''  port: 3306  Source distribution
Assertion failed: left_expr->fixed && select_lex->ref_pointer_array[i]->fixed, file
.\item_subselect.cc, line 1291
[14 Mar 19:46] Gleb Shchepa
Release build fails with unexpected error message:

Server version: 5.0.60 Source distribution

mysql> CREATE TABLE t1 (a INT);
Query OK, 0 rows affected (0.02 sec)

mysql> INSERT INTO t1 VALUES(1);
Query OK, 1 row affected (0.00 sec)

mysql> SELECT ROW(1, 2) IN (SELECT a, 2) FROM t1 GROUP BY a;
ERROR 1247 (42S22): Reference '<list ref>' not supported (forward reference in item
list)
[14 Mar 20:16] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/44035

ChangeSet@1.2598, 2008-03-14 23:11:59+04:00, gshchepa@host.loc +4 -0
  Fixed bug #34763.
  
  Queries like:
  
    SELECT ROW(1, 2) IN (SELECT t1.a, 2)
      FROM t1 GROUP BY t1.a
  
  or 
  
    SELECT ROW(1, 2) IN (SELECT t1.a, 2 FROM t2)
      FROM t1 GROUP BY t1.a
  
  lead to assertion failure in the
  Item_in_subselect::row_value_transformer method in debugging
  build, or to unexpected error message in release build:
  
    ERROR 1247 (42S22): Reference '<list ref>' not supported (forward
                        reference in item list)
  
  Unexpected error message and assertion failure have been
  eliminated.
[28 Mar 10:21] Bugs System
Pushed into 5.1.24-rc
[28 Mar 10:22] Bugs System
Pushed into 5.0.60
[31 Mar 15:58] Bugs System
Pushed into 6.0.5-alpha
[14 Apr 21:22] Paul DuBois
Noted in 5.0.60, 5.1.24, 6.0.5 changelogs.

Queries such as SELECT ROW(1, 2) IN (SELECT t1.a, 2) FROM t1 GROUP BY
t1.a (combining row constructors and subqueries in the FROM clause)
could lead to assertion failure or unexpected error messages.