Assertion `! is_set()' failed in Diagnostics_area::set_ok_status(THD*, ha_rows, ulonglong, const char*) on CREATE .. SELECT with ER_SUBQUERY_NO_1_ROW

Bug #934597 reported by Elena Stepanova on 2012-02-18
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Released
Sergey Petrunia

Bug Description

Version: '5.3.4-MariaDB-rc-debug-log'
mysqld: void Diagnostics_area::set_ok_status(THD*, ha_rows, ulonglong, const char*): Assertion `! is_set()' failed.

#8 0xb73bf014 in __assert_fail () from /lib/
#9 0x082b5458 in Diagnostics_area::set_ok_status (this=0x93efd98, thd=0x93eeae0, affected_rows_arg=0,
    last_insert_id_arg=0, message_arg=0xae83734f "Records: 0 Duplicates: 0 Warnings: 0")
#10 0x081ecc73 in my_ok (thd=0x93eeae0, affected_rows=0, id=0,
    message=0xae83734f "Records: 0 Duplicates: 0 Warnings: 0") at sql_class.h:2699
#11 0x08390ca3 in select_insert::send_eof (this=0x945ec50) at
#12 0x083927c5 in select_create::send_eof (this=0x945ec50) at
#13 0x0836ae4b in return_zero_rows (join=0x946f8d8, result=0x945ec50, tables=..., fields=...,
    send_row=false, select_options=2416200192,
    info=0x8936114 "Impossible WHERE noticed after reading const tables", having=0x0) at
#14 0x08356def in JOIN::exec (this=0x946f8d8) at
#15 0x08359589 in mysql_select (thd=0x93eeae0, rref_pointer_array=0x93f067c, tables=0x945e080, wild_num=0,
    fields=..., conds=0x945ebb8, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0,
    select_options=2416200192, result=0x945ec50, unit=0x93f0260, select_lex=0x93f0540) at
#16 0x083512a3 in handle_select (thd=0x93eeae0, lex=0x93f0204, result=0x945ec50, setup_tables_done_option=0)
#17 0x082e4b17 in mysql_execute_command (thd=0x93eeae0) at
#18 0x082eea54 in mysql_parse (thd=0x93eeae0,
    rawbuf=0x945dc10 "CREATE TABLE t AS \nSELECT a AS field1 FROM t1 \nWHERE ( SELECT alias1.a\nFROM t1 AS alias1\n) IS NOT NULL", length=102, found_semicolon=0xae838234) at
#19 0x082e1435 in dispatch_command (command=COM_QUERY, thd=0x93eeae0,
    packet=0x9448351 "CREATE TABLE t AS \nSELECT a AS field1 FROM t1 \nWHERE ( SELECT alias1.a\nFROM t1 AS alias1\n) IS NOT NULL", packet_length=102) at
#20 0x082e08df in do_command (thd=0x93eeae0) at
#21 0x082dd865 in handle_one_connection (arg=0x93eeae0) at
#22 0xb764db25 in start_thread () from /lib/

bzr version-info
revision-id: <email address hidden>
date: 2012-02-16 20:15:57 +0400
build-date: 2012-02-18 04:08:37 +0400
revno: 3424

Could not reproduce on MariaDB 5.2, 5.5, MySQL 5.1.60, 5.5.20

Query (0x945dc10): CREATE TABLE t AS SELECT a AS field1 FROM t1 WHERE ( SELECT alias1.a FROM t1 AS alias1 ) IS NOT NULL
Connection ID (thread ID): 2

Minimal optimizer_switch: in_to_exists=on
Full optimizer_switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on

# Test case:

INSERT INTO t1 VALUES ('u'),('k');
 SELECT a AS field1 FROM t1
 WHERE ( SELECT alias1.a
         FROM t1 AS alias1
       ) IS NOT NULL;

# End of test case

Changed in maria:
assignee: Sergei (sergii) → Sergey Petrunia (sergefp)
Sergey Petrunia (sergefp) wrote :

Not repeatable in the latest 5.3 tree:

    -> SELECT a AS field1 FROM t1
    -> WHERE ( SELECT alias1.a
    -> FROM t1 AS alias1
    -> ) IS NOT NULL;
Query OK, 0 rows affected, 1 warning (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> show warnings\G
*************************** 1. row ***************************
  Level: Error
   Code: 1242
Message: Subquery returns more than 1 row
1 row in set (0.00 sec)

Sergey Petrunia (sergefp) wrote :

Tried 5.3 with:

revno: 3424
revision-id: <email address hidden>

compiled with ./BUILD/compile-pentium-debug-max-no-ndb on x86_64. Still was unable to repeat.

Changed in maria:
assignee: Sergey Petrunia (sergefp) → Elena Stepanova (elenst)
Sergey Petrunia (sergefp) wrote :

Elena could you help with repeating this bug?

Elena Stepanova (elenst) wrote :

I've rebuilt the latest 5.3, the bug is still reproducible for me on revision-id: <email address hidden> (revno: 3437), openSUSE 11.3, both i686 and x86_64, built with the same BUILD/compile-pentium-debug-max-no-ndb. I've set up a test tree on the remote test machine so we could share the environment, details on the IRC.

Changed in maria:
assignee: Elena Stepanova (elenst) → Sergey Petrunia (sergefp)
Sergey Petrunia (sergefp) wrote :

Ok, here is why I was unable to repeat: the bug only show up when binary logging is disabled.

Sergey Petrunia (sergefp) wrote :

The problem does not show up when the error occurs inside

It only shows up when
- The "subquery returns > 1 row" error occurs when checking
  exec_const_cond (that is, at execution phase we find out that
  there won't be any matching rows).
- After that, select_insert::send_eof() fails to deal with error state.

Attempts to repeat this situation with a failure in other clause than
exec_const_cond were not successfull: I can either
- get an error in select_insert::send_data(), which is handled
- get an error elsewhere, which causes a general error condition and a
  call to select_create::abort() (and not ::send_data).

Changed in maria:
status: New → Fix Committed
Elena Stepanova (elenst) wrote :

Fix released with 5.3.5-ga.

Changed in maria:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers