Bug #25097 mysql_server_init fails silently if no errmsg.sys is present
Submitted: 15 Dec 2006 15:45 Modified: 17 Mar 2008 20:29
Reporter: Philip Stoev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Embedded Library ( libmysqld ) Severity:S3 (Non-critical)
Version:5.1.14-beta OS:FreeBSD (FreeBSD)
Assigned to: Alexey Botchkov CPU Architecture:Any
Tags: qc
Triage: D4 (Minor) / R2 (Low) / E2 (Low)

[15 Dec 2006 15:45] Philip Stoev
Description:
Hello,

if the default, charsets directory is not present and --character-sets-dir is not specified, mysql_server_init() will return 1, indicating error, however the exact reason for the error is not available and no error message is printed out.

How to repeat:
Do:

cd mysql-source-dir/sql/share
make uninstall

or:

/bin/rm -f -r /usr/local/share/mysql

and then call mysql_server_init()

Suggested fix:
Printing errors to the console from a library is not really a good idea, since they may interfere with the output of the actual program that is using libmysqld. Therefore mysql_server_init() should return more descriptive values than just 0 or 1.
[15 Dec 2006 16:22] Philip Stoev
The behavoir in question is caused by the vprint_msg_to_log function being replaced by a void one if EMBEDDED_LIBRARY is defined.
[15 Dec 2006 16:35] Philip Stoev
The problem comes not from missing charsets but from missing errmsg.sys in the share directory. Please see bug #13717 -- the patch in that bug silences not only warnings, but fatal errors as well.
[18 Dec 2006 20:13] Miguel Solorzano
Thank you for the bug report. Currently for version 5.0.XX the Embedded
Library isn't supported. Please see: http://dev.mysql.com/doc/refman/5.0/en/libmysqld.html
[18 Dec 2006 20:21] Philip Stoev
Wow, I did not know that :-) ./configure --with-embedded-server runs for me and does produce libmysqld.a.

Anyway, I will re-open the bug if 5.1 has the same problem.
[18 Dec 2006 21:10] Philip Stoev
It appears that the bug is still present in 5.1.14-beta.

vprint_msg_to_log() still does nothing when EMBEDDED_LIBRARY is defined. vprint_msg_to_log() is called directly by option_error_reporter() and indirectly by sql_print_error(), so no errors will be printed for mysql_server_init().
[11 Feb 2008 7:25] Alexey Botchkov
So as errors here can appear 
I think we should add 'mysql_server_errno() and mysql_server_error()' functions
to the API in order to handle that kind of problems logically.
Other option could be to make mysql_errno(NULL) and mysql_error(NULL) to return
the 'server' errors.
[17 Feb 2008 14:23] 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/42456

ChangeSet@1.2594, 2008-02-17 18:15:01+04:00, holyfoot@mysql.com +5 -0
  Bug #25097 mysql_server_init fails silently if no errmsg.sys is present.
  
  There was no way to return an error from the client library
  if no MYSQL connections was established.
  So here i added variables to store that king of errors and
  made functions like mysql_error(NULL) to return these.
[27 Feb 2008 8:51] 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/43034

ChangeSet@1.2594, 2008-02-27 12:42:43+04:00, holyfoot@mysql.com +6 -0
  Bug #25097 mysql_server_init fails silently if no errmsg.sys is present.
  
  There was no way to return an error from the client library
  if no MYSQL connections was established.
  So here i added variables to store that king of errors and
  made functions like mysql_error(NULL) to return these.
[13 Mar 2008 19:28] Bugs System
Pushed into 6.0.5-alpha
[13 Mar 2008 19:35] Bugs System
Pushed into 5.1.24-rc
[13 Mar 2008 19:42] Bugs System
Pushed into 5.0.60
[17 Mar 2008 20:29] Paul Dubois
Noted in 5.0.60, 5.1.24, 6.0.5 changelogs.

The client library had no way to return an error if no connection had
been established. This caused problems such as mysql_library_init()
failing silently if no errmsg.sys file was available.
[30 Mar 2008 0:16] Jon Stephens
Fixed also documented for 5.1.23-ndb-6.3.11.