List:Commits« Previous MessageNext Message »
From:holyfoot Date:February 17 2008 2:15pm
Subject:bk commit into 5.0 tree (holyfoot:1.2594) BUG#25097
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of holyfoot.  When holyfoot does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-02-17 18:15:01+04:00, holyfoot@stripped +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.

  client/mysql.cc@stripped, 2008-02-17 18:14:59+04:00, holyfoot@stripped +1 -0
    Bug #25097 mysql_server_init fails silently if no errmsg.sys is present.
    
    Show the error message on std_error

  libmysql/libmysql.c@stripped, 2008-02-17 18:14:59+04:00, holyfoot@stripped +1 -1
    Bug #25097 mysql_server_init fails silently if no errmsg.sys is present.
    
    mysql_sqlstate(NULL) returns 'unknown_sqlstate'

  libmysqld/lib_sql.cc@stripped, 2008-02-17 18:14:59+04:00, holyfoot@stripped +10 -0
    Bug #25097 mysql_server_init fails silently if no errmsg.sys is present.
    
    EMBEDDED_SERVER version of the vprint_msg_to_log() implemented

  sql-common/client.c@stripped, 2008-02-17 18:14:59+04:00, holyfoot@stripped +20 -6
    Bug #25097 mysql_server_init fails silently if no errmsg.sys is present.
    
    mysql_server_last_errno and mysql_server_last_error introduced
    to store errors not related to particular connections.
    
    mysql_error(NULL) and mysql_errno(NULL) now returns these
    mysql_server_last_error and errno respectively

  sql/log.cc@stripped, 2008-02-17 18:14:59+04:00, holyfoot@stripped +1 -6
    Bug #25097 mysql_server_init fails silently if no errmsg.sys is present.
    
    EMBEDDED_LIBRARY implementation of the vprint_msg_to_log() moved
    to lib_sql.cc

diff -Nrup a/client/mysql.cc b/client/mysql.cc
--- a/client/mysql.cc	2008-01-10 21:43:04 +04:00
+++ b/client/mysql.cc	2008-02-17 18:14:59 +04:00
@@ -420,6 +420,7 @@ int main(int argc,char *argv[])
   }
   if (mysql_server_init(emb_argc, emb_argv, (char**) server_default_groups))
   {
+    put_error(NULL);
     free_defaults(defaults_argv);
     my_end(0);
     exit(1);
diff -Nrup a/libmysql/libmysql.c b/libmysql/libmysql.c
--- a/libmysql/libmysql.c	2007-11-26 20:09:35 +04:00
+++ b/libmysql/libmysql.c	2008-02-17 18:14:59 +04:00
@@ -1486,7 +1486,7 @@ my_ulonglong STDCALL mysql_insert_id(MYS
 
 const char *STDCALL mysql_sqlstate(MYSQL *mysql)
 {
-  return mysql->net.sqlstate;
+  return mysql ? mysql->net.sqlstate : unknown_sqlstate;
 }
 
 uint STDCALL mysql_warning_count(MYSQL *mysql)
diff -Nrup a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
--- a/libmysqld/lib_sql.cc	2007-11-29 10:37:05 +04:00
+++ b/libmysqld/lib_sql.cc	2008-02-17 18:14:59 +04:00
@@ -47,6 +47,8 @@ C_MODE_START
 #include <sql_common.h>
 #include "embedded_priv.h"
 
+extern unsigned int mysql_server_last_errno;
+extern char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
 static my_bool emb_read_query_result(MYSQL *mysql);
 
 
@@ -1084,3 +1086,11 @@ bool Protocol::net_store_data(const char
   return false;
 }
 
+
+void vprint_msg_to_log(enum loglevel level __attribute__((unused)),
+                       const char *format, va_list argsi)
+{
+  vsnprintf(mysql_server_last_error, sizeof(mysql_server_last_error),
+           format, argsi);
+  mysql_server_last_errno= CR_UNKNOWN_ERROR;
+}
diff -Nrup a/sql/log.cc b/sql/log.cc
--- a/sql/log.cc	2007-12-17 12:45:20 +04:00
+++ b/sql/log.cc	2008-02-17 18:14:59 +04:00
@@ -2454,12 +2454,7 @@ static void print_buffer_to_nt_eventlog(
     void
 */
 
-#ifdef EMBEDDED_LIBRARY
-void vprint_msg_to_log(enum loglevel level __attribute__((unused)),
-                       const char *format __attribute__((unused)),
-                       va_list argsi __attribute__((unused)))
-{}
-#else /*!EMBEDDED_LIBRARY*/
+#ifndef EMBEDDED_LIBRARY
 static void print_buffer_to_file(enum loglevel level, const char *buffer)
 {
   time_t skr;
diff -Nrup a/sql-common/client.c b/sql-common/client.c
--- a/sql-common/client.c	2007-11-28 18:23:48 +04:00
+++ b/sql-common/client.c	2008-02-17 18:14:59 +04:00
@@ -131,6 +131,9 @@ static int wait_for_data(my_socket fd, u
 
 CHARSET_INFO *default_client_charset_info = &my_charset_latin1;
 
+/* Server error code and message */
+unsigned int mysql_server_last_errno;
+char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
 
 /****************************************************************************
   A modified version of connect().  my_connect() allows you to specify
@@ -752,10 +755,18 @@ void set_mysql_error(MYSQL *mysql, int e
   DBUG_PRINT("enter", ("error :%d '%s'", errcode, ER(errcode)));
   DBUG_ASSERT(mysql != 0);
 
-  net= &mysql->net;
-  net->last_errno= errcode;
-  strmov(net->last_error, ER(errcode));
-  strmov(net->sqlstate, sqlstate);
+  if (mysql)
+  {
+    net= &mysql->net;
+    net->last_errno= errcode;
+    strmov(net->last_error, ER(errcode));
+    strmov(net->sqlstate, sqlstate);
+  }
+  else
+  {
+    mysql_server_last_errno= errcode;
+    strmov(mysql_server_last_error, ER(errcode));
+  }
 
   DBUG_VOID_RETURN;
 }
@@ -1477,7 +1488,10 @@ mysql_init(MYSQL *mysql)
   if (!mysql)
   {
     if (!(mysql=(MYSQL*) my_malloc(sizeof(*mysql),MYF(MY_WME | MY_ZEROFILL))))
+    {
+      set_mysql_error(NULL, CR_OUT_OF_MEMORY, unknown_sqlstate);
       return 0;
+    }
     mysql->free_me=1;
   }
   else
@@ -3064,13 +3078,13 @@ unsigned int STDCALL mysql_num_fields(MY
 
 uint STDCALL mysql_errno(MYSQL *mysql)
 {
-  return mysql->net.last_errno;
+  return mysql ? mysql->net.last_errno : mysql_server_last_errno;
 }
 
 
 const char * STDCALL mysql_error(MYSQL *mysql)
 {
-  return mysql->net.last_error;
+  return mysql ? mysql->net.last_error : mysql_server_last_error;
 }
 
 
Thread
bk commit into 5.0 tree (holyfoot:1.2594) BUG#25097holyfoot17 Feb
  • Re: bk commit into 5.0 tree (holyfoot:1.2594) BUG#25097Sergei Golubchik19 Feb