Bug #57491 thd->main_da.is_ok() assert in embedded
Submitted: 15 Oct 2010 19:43 Modified: 23 May 2011 17:40
Reporter: Sergei Golubchik Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Embedded Library ( libmysqld ) Severity:S2 (Serious)
Version:5.1 OS:Any
Assigned to: CPU Architecture:Any

[15 Oct 2010 19:43] Sergei Golubchik
Description:
when a client that uses libmysqld calls my_error (directly or indirectly) it gets server's behavior for my_error - that is, my_message_sql gets called, it checks the handlers, does lots of other server specific stuff, and in particular checks thd->main_da.is_ok(). All the above is wrong when my_error() is called from the client code, but the check on thd->main_da.is_ok() is particularly easy to trigger.

How to repeat:
for example,

% libmysqld/examples/mysql
mysql> \T foo/bar
mysql: sql_class.cc:565: void Diagnostics_area::set_error_status(THD*, uint, const char*): Assertion `! is_set() || can_overwrite_status' failed.
Abort
%

Suggested fix:
eh. perhaps set

  error_handler_hook= my_message_sql;

every time the client calls into libmysqld and reset it back when returning to the client code?
[16 Oct 2010 14:56] MySQL Verification Team
Thank you for the bug report. Verified as described:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 0
Server version: 5.1.53-embedded-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>  \T foo/bar
mysql: sql_class.cc:565: void Diagnostics_area::set_error_status(THD*, uint, const char*): Assertion `! is_set() || can_overwrite_status' failed.
Aborted
[18 Oct 2010 21:48] Sergei Golubchik
perhaps juggling with (global) error_handler_hook will be not enough, and a proper fix may need a per-thread flag
[23 May 2011 17:40] Paul DuBois
Noted in 5.1.58, 5.5.14, 5.6.3 changelogs.

An embedded client would abort rather than issue an error message if
it issued a TEE command (\T file_name) and the directory containing
the file did not exist. This occurred because the wrong error handler
was called. 

CHANGESET - http://lists.mysql.com/commits/137766