2011-06-30 17:46:53 +02:00
|
|
|
/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
|
2001-12-06 13:10:51 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2006-12-23 20:17:15 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2001-12-06 13:10:51 +01:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
2001-04-11 13:04:03 +02:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2001-12-06 13:10:51 +01:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2019-05-11 20:29:06 +02:00
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
|
2001-04-25 00:11:29 +02:00
|
|
|
|
2006-02-24 17:34:15 +01:00
|
|
|
#include <my_global.h>
|
|
|
|
#include <mysql.h>
|
|
|
|
#include <mysqld_error.h>
|
|
|
|
#include <my_pthread.h>
|
2001-04-11 13:04:03 +02:00
|
|
|
#include <my_sys.h>
|
|
|
|
#include <mysys_err.h>
|
|
|
|
#include <m_string.h>
|
|
|
|
#include <m_ctype.h>
|
|
|
|
#include "errmsg.h"
|
|
|
|
#include <violite.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <time.h>
|
2009-10-09 14:30:54 +02:00
|
|
|
#include <sql_common.h>
|
2010-03-29 17:13:53 +02:00
|
|
|
#include "embedded_priv.h"
|
2003-09-16 13:06:25 +02:00
|
|
|
#include "client_settings.h"
|
2001-04-11 13:04:03 +02:00
|
|
|
#ifdef HAVE_PWD_H
|
|
|
|
#include <pwd.h>
|
|
|
|
#endif
|
2010-07-15 13:16:06 +02:00
|
|
|
#if !defined(__WIN__)
|
2001-04-11 13:04:03 +02:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#ifdef HAVE_SELECT_H
|
|
|
|
# include <select.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_SELECT_H
|
|
|
|
#include <sys/select.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_UN_H
|
|
|
|
# include <sys/un.h>
|
|
|
|
#endif
|
|
|
|
#ifndef INADDR_NONE
|
|
|
|
#define INADDR_NONE -1
|
|
|
|
#endif
|
|
|
|
|
2004-05-26 18:40:27 +02:00
|
|
|
extern ulong net_buffer_length;
|
|
|
|
extern ulong max_allowed_packet;
|
|
|
|
|
2010-07-15 13:16:06 +02:00
|
|
|
#if defined(__WIN__)
|
2001-04-11 13:04:03 +02:00
|
|
|
#define ERRNO WSAGetLastError()
|
|
|
|
#define perror(A)
|
|
|
|
#else
|
|
|
|
#include <errno.h>
|
|
|
|
#define ERRNO errno
|
|
|
|
#define SOCKET_ERROR -1
|
|
|
|
#define closesocket(A) close(A)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_GETPWUID
|
|
|
|
struct passwd *getpwuid(uid_t);
|
|
|
|
char* getlogin(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __WIN__
|
|
|
|
static my_bool is_NT(void)
|
|
|
|
{
|
|
|
|
char *os=getenv("OS");
|
|
|
|
return (os && !strcmp(os, "Windows_NT")) ? 1 : 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-06-19 19:11:01 +02:00
|
|
|
int mysql_init_character_set(MYSQL *mysql);
|
2001-04-11 13:04:03 +02:00
|
|
|
|
|
|
|
MYSQL * STDCALL
|
|
|
|
mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
2003-06-18 12:58:57 +02:00
|
|
|
const char *passwd, const char *db,
|
2003-01-20 15:59:45 +01:00
|
|
|
uint port, const char *unix_socket,ulong client_flag)
|
2001-04-11 13:04:03 +02:00
|
|
|
{
|
2003-09-26 12:33:13 +02:00
|
|
|
char name_buff[USERNAME_LENGTH];
|
2004-01-07 18:30:15 +01:00
|
|
|
|
2001-04-11 13:04:03 +02:00
|
|
|
DBUG_ENTER("mysql_real_connect");
|
2009-09-30 12:28:15 +02:00
|
|
|
DBUG_PRINT("enter",("host: %s db: %s user: %s (libmysqld)",
|
2001-04-11 13:04:03 +02:00
|
|
|
host ? host : "(Null)",
|
|
|
|
db ? db : "(Null)",
|
|
|
|
user ? user : "(Null)"));
|
|
|
|
|
2009-10-09 14:30:54 +02:00
|
|
|
/* Test whether we're already connected */
|
|
|
|
if (mysql->server_version)
|
|
|
|
{
|
|
|
|
set_mysql_error(mysql, CR_ALREADY_CONNECTED, unknown_sqlstate);
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
2005-01-03 16:21:54 +01:00
|
|
|
if (!host || !host[0])
|
|
|
|
host= mysql->options.host;
|
|
|
|
|
2003-09-11 19:24:14 +02:00
|
|
|
if (mysql->options.methods_to_use == MYSQL_OPT_USE_REMOTE_CONNECTION ||
|
|
|
|
(mysql->options.methods_to_use == MYSQL_OPT_GUESS_CONNECTION &&
|
2004-09-25 18:56:52 +02:00
|
|
|
host && *host && strcmp(host,LOCAL_HOST)))
|
2003-12-18 12:51:22 +01:00
|
|
|
DBUG_RETURN(cli_mysql_real_connect(mysql, host, user,
|
|
|
|
passwd, db, port,
|
|
|
|
unix_socket, client_flag));
|
2003-06-18 12:58:57 +02:00
|
|
|
|
2003-06-17 18:32:31 +02:00
|
|
|
mysql->methods= &embedded_methods;
|
|
|
|
|
2001-04-11 13:04:03 +02:00
|
|
|
/* use default options */
|
|
|
|
if (mysql->options.my_cnf_file || mysql->options.my_cnf_group)
|
|
|
|
{
|
|
|
|
mysql_read_default_options(&mysql->options,
|
|
|
|
(mysql->options.my_cnf_file ?
|
|
|
|
mysql->options.my_cnf_file : "my"),
|
|
|
|
mysql->options.my_cnf_group);
|
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.
Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.
Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost.
The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.
Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
client/mysqldump.c:
Pass my_free directly as its signature is compatible with the
callback type -- which wasn't the case for free_table_ent.
2010-07-08 23:20:08 +02:00
|
|
|
my_free(mysql->options.my_cnf_file);
|
|
|
|
my_free(mysql->options.my_cnf_group);
|
2001-04-11 13:04:03 +02:00
|
|
|
mysql->options.my_cnf_file=mysql->options.my_cnf_group=0;
|
2017-12-18 14:15:48 +01:00
|
|
|
|
|
|
|
if (mysql->options.protocol == UINT_MAX32)
|
|
|
|
goto error;
|
2001-04-11 13:04:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!db || !db[0])
|
|
|
|
db=mysql->options.db;
|
2002-06-17 13:24:51 +02:00
|
|
|
|
2003-09-26 12:33:13 +02:00
|
|
|
if (!user || !user[0])
|
|
|
|
user=mysql->options.user;
|
|
|
|
|
2004-01-07 18:30:15 +01:00
|
|
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
2003-09-26 12:33:13 +02:00
|
|
|
if (!passwd)
|
|
|
|
{
|
|
|
|
passwd=mysql->options.password;
|
|
|
|
#if !defined(DONT_USE_MYSQL_PWD)
|
|
|
|
if (!passwd)
|
|
|
|
passwd=getenv("MYSQL_PWD"); /* get it from environment */
|
|
|
|
#endif
|
|
|
|
}
|
2004-01-07 18:30:15 +01:00
|
|
|
mysql->passwd= passwd ? my_strdup(passwd,MYF(0)) : NULL;
|
|
|
|
#endif /*!NO_EMBEDDED_ACCESS_CHECKS*/
|
2003-09-26 12:33:13 +02:00
|
|
|
if (!user || !user[0])
|
|
|
|
{
|
|
|
|
read_user_name(name_buff);
|
2004-01-07 18:30:15 +01:00
|
|
|
if (name_buff[0])
|
2003-09-26 12:33:13 +02:00
|
|
|
user= name_buff;
|
|
|
|
}
|
|
|
|
|
2004-01-07 18:30:15 +01:00
|
|
|
if (!user)
|
|
|
|
user= "";
|
2006-02-24 17:34:15 +01:00
|
|
|
/*
|
|
|
|
We need to alloc some space for mysql->info but don't want to
|
|
|
|
put extra 'my_free's in mysql_close.
|
|
|
|
So we alloc it with the 'user' string to be freed at once
|
|
|
|
*/
|
2020-01-29 13:50:26 +01:00
|
|
|
mysql->user= my_strdup(PSI_NOT_INSTRUMENTED, user, MYF(0));
|
2003-09-26 12:33:13 +02:00
|
|
|
|
2001-04-25 00:11:29 +02:00
|
|
|
port=0;
|
|
|
|
unix_socket=0;
|
2002-06-17 13:24:51 +02:00
|
|
|
|
2009-09-11 14:52:08 +02:00
|
|
|
client_flag|=mysql->options.client_flag;
|
2005-05-09 13:26:06 +02:00
|
|
|
/* Send client information for access check */
|
|
|
|
client_flag|=CLIENT_CAPABILITIES;
|
|
|
|
if (client_flag & CLIENT_MULTI_STATEMENTS)
|
|
|
|
client_flag|= CLIENT_MULTI_RESULTS;
|
2010-03-29 17:13:53 +02:00
|
|
|
/*
|
|
|
|
no compression in embedded as we don't send any data,
|
|
|
|
and no pluggable auth, as we cannot do a client-server dialog
|
|
|
|
*/
|
|
|
|
client_flag&= ~(CLIENT_COMPRESS | CLIENT_PLUGIN_AUTH);
|
2005-05-09 13:26:06 +02:00
|
|
|
if (db)
|
|
|
|
client_flag|=CLIENT_CONNECT_WITH_DB;
|
|
|
|
|
2020-01-29 13:50:26 +01:00
|
|
|
mysql->info_buffer= my_malloc(PSI_NOT_INSTRUMENTED, MYSQL_ERRMSG_SIZE, MYF(0));
|
2006-07-18 13:43:39 +02:00
|
|
|
mysql->thd= create_embedded_thd(client_flag);
|
2001-04-11 13:04:03 +02:00
|
|
|
|
2006-06-01 14:06:42 +02:00
|
|
|
init_embedded_mysql(mysql, client_flag);
|
2001-04-11 13:04:03 +02:00
|
|
|
|
2006-06-19 19:11:01 +02:00
|
|
|
if (mysql_init_character_set(mysql))
|
2003-09-26 12:33:13 +02:00
|
|
|
goto error;
|
|
|
|
|
2006-07-13 19:32:18 +02:00
|
|
|
if (check_embedded_connection(mysql, db))
|
2001-04-11 13:04:03 +02:00
|
|
|
goto error;
|
|
|
|
|
2003-06-24 11:10:35 +02:00
|
|
|
mysql->server_status= SERVER_STATUS_AUTOCOMMIT;
|
2001-04-25 00:11:29 +02:00
|
|
|
|
2002-12-19 09:27:46 +01:00
|
|
|
if (mysql->options.init_commands)
|
2001-04-11 13:04:03 +02:00
|
|
|
{
|
2002-12-19 09:27:46 +01:00
|
|
|
DYNAMIC_ARRAY *init_commands= mysql->options.init_commands;
|
|
|
|
char **ptr= (char**)init_commands->buffer;
|
|
|
|
char **end= ptr + init_commands->elements;
|
|
|
|
|
|
|
|
for (; ptr<end; ptr++)
|
|
|
|
{
|
|
|
|
MYSQL_RES *res;
|
|
|
|
if (mysql_query(mysql,*ptr))
|
|
|
|
goto error;
|
|
|
|
if (mysql->fields)
|
|
|
|
{
|
2003-09-18 15:28:42 +02:00
|
|
|
if (!(res= (*mysql->methods->use_result)(mysql)))
|
2002-12-19 09:27:46 +01:00
|
|
|
goto error;
|
|
|
|
mysql_free_result(res);
|
|
|
|
}
|
|
|
|
}
|
2001-04-11 13:04:03 +02:00
|
|
|
}
|
|
|
|
|
2017-09-19 19:45:17 +02:00
|
|
|
DBUG_PRINT("exit",("Mysql handler: %p", mysql));
|
2001-04-11 13:04:03 +02:00
|
|
|
DBUG_RETURN(mysql);
|
|
|
|
|
|
|
|
error:
|
Bug#12713 "Error in a stored function called from a SELECT doesn't
cause ROLLBACK of statement", part 1. Review fixes.
Do not send OK/EOF packets to the client until we reached the end of
the current statement.
This is a consolidation, to keep the functionality that is shared by all
SQL statements in one place in the server.
Currently this functionality includes:
- close_thread_tables()
- log_slow_statement().
After this patch and the subsequent patch for Bug#12713, it shall also include:
- ha_autocommit_or_rollback()
- net_end_statement()
- query_cache_end_of_result().
In future it may also include:
- mysql_reset_thd_for_next_command().
include/mysql_com.h:
Rename now unused members of NET: no_send_ok, no_send_error, report_error.
These were server-specific variables related to the client/server
protocol. They have been made obsolete by this patch.
Previously the same members of NET were used to store the error message
both on the client and on the server.
The error message was stored in net.last_error (client: mysql->net.last_error,
server: thd->net.last_error).
The error code was stored in net.last_errno (client: mysql->net.last_errno,
server: thd->net.last_errno).
The server error code and message are now stored elsewhere
(in the Diagnostics_area), thus NET members are no longer used by the
server.
Rename last_error to client_last_error, last_errno to client_last_errno
to avoid potential bugs introduced by merges.
include/mysql_h.ic:
Update the ABI file to reflect a rename.
Renames do not break the binary compatibility.
libmysql/libmysql.c:
Rename last_error to client_last_error, last_errno to client_last_errno.
This is necessary to ensure no unnoticed bugs introduced by merged
changesets.
Remove net.report_error, net.no_send_ok, net.no_send_error.
libmysql/manager.c:
Rename net.last_errno to net.client_last_errno.
libmysqld/lib_sql.cc:
Rename net.last_errno to net.client_last_errno.
Update the embedded implementation of the client-server protocol to
reflect the refactoring of protocol.cc.
libmysqld/libmysqld.c:
Rename net.last_errno to net.client_last_errno.
mysql-test/r/events.result:
Update to reflect the change in mysql_rm_db(). Now we drop stored
routines and events for a given database name only if there
is a directory for this database name. ha_drop_database() and
query_cache_invalidate() are called likewise.
Previously we would attempt to drop routines/events even if database
directory was not found (it worked, since routines and events are stored
in tables). This fixes Bug 29958 "Weird message on DROP DATABASE if mysql.proc
does not exist".
The change was done because the previous code used to call send_ok()
twice, which led to an assertion failure when asserts against it were
added by this patch.
mysql-test/r/grant.result:
Fix the patch for Bug 16470, now FLUSH PRIVILEGES produces an error
if mysql.procs_priv is missing.
This fixes the assert that send_ok() must not called after send_error()
(the original patch for Bug 16470 was prone to this).
mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result:
Produce a more detailed error message.
mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result:
Produce a more detailed error message.
mysql-test/t/grant.test:
Update the test, now FLUSH PRIVILEGES returns an error if mysql.procs_priv
is missing.
server-tools/instance-manager/mysql_connection.cc:
Rename net.last_errno to net.client_last_errno.
sql/ha_ndbcluster_binlog.cc:
Add asserts.
Use getters to access statement status information.
Add a comment why run_query() is broken. Reset the diagnostics area
in the end of run_query() to fulfill the invariant that the diagnostics_area
is never assigned twice per statement (see the comment in the code
when this can happen). We still do not clear thd->is_fatal_error and
thd->is_slave_error, which may lead to bugs, I consider the whole affair
as something to be dealt with separately.
sql/ha_partition.cc:
fatal_error() doesn't set an error by itself. Perhaps we should
remove this method altogether and instead add a flag to my_error
to set thd->is_fatal_error property.
Meanwhile, this change is a part of inspection made to the entire source
code with the goal to ensure that fatal_error()
is always accompanied by my_error().
sql/item_func.cc:
There is no net.last_error anymore. Remove the obsolete assignment.
sql/log_event.cc:
Use getters to access statement error status information.
sql/log_event_old.cc:
Use getters to access statement error status information.
sql/mysqld.cc:
Previously, if a continue handler for an error was found, my_message_sql()
would not set an error in THD. Since the current statement
must be aborted in any case, find_handler() had a hack to assign
thd->net.report_error to 1.
Remove this hack. Set an error in my_message_sql() even if the continue
handler is found. The error will be cleared anyway when the handler
is executed. This is one action among many in this patch to ensure the
invariant that whenever thd->is_error() is TRUE, we have a message in
thd->main_da.message().
sql/net_serv.cc:
Use a full-blown my_error() in net_serv.cc to report an error,
instead of just setting net->last_errno. This ensures the invariant that
whenever thd->is_error() returns TRUE, we have a message in
thd->main_da.message().
Remove initialization of removed NET members.
sql/opt_range.cc:
Use my_error() instead of just raising thd->net.report_error.
This ensures the invariant that whenever thd->is_error() returns TRUE,
there is a message in thd->main_da.message().
sql/opt_sum.cc:
Move invocation of fatal_error() right next to the place where
we set the error message. That makes it easier to track that whenever
fatal_error() is called, there is a message in THD.
sql/protocol.cc:
Rename send_ok() and send_eof() to net_send_ok() and net_send_eof()
respectively. These functions write directly to the network and are not
for use anywhere outside the client/server protocol code.
Remove the code that was responsible for cases when either there is
no error code, or no error message, or both.
Instead the calling code ensures that they are always present. Asserts
are added to enforce the invariant.
Instead of a direct access to thd->server_status and thd->total_warn_count
use function parameters, since these from now on don't always come directly
from THD.
Introduce net_end_statement(), the single-entry-point replacement API for
send_ok(), send_eof() and net_send_error().
Implement Protocol::end_partial_result_set to use in select_send::abort()
when there is a continue handler.
sql/protocol.h:
Update declarations.
sql/repl_failsafe.cc:
Use getters to access statement status information in THD.
Rename net.last_error to net.client_last_error.
sql/rpl_record.cc:
Set an error message in prepare_record() if there is no default
value for the field -- later we do print this message to the client.
sql/rpl_rli.cc:
Use getters to access statement status information in THD.
sql/slave.cc:
In create_table_from_dump() (a common function that is used in
LOAD MASTER TABLE SQL statement and COM_LOAD_MASTER_DATA), instead of hacks
with no_send_ok, clear the diagnostics area when mysql_rm_table() succeeded.
Update has_temporary_error() to work correctly when no error is set.
This is the case when Incident_log_event is executed: it always returns
an error but does not set an error message.
Use getters to access error status information.
sql/sp_head.cc:
Instead of hacks with no_send_error, work through the diagnostics area
interface to suppress sending of OK/ERROR packets to the client.
Move query_cache_end_of_result before log_slow_statement(), similarly
to how it's done in dispatch_command().
sql/sp_rcontext.cc:
Remove hacks with assignment of thd->net.report_error, they are not
necessary any more (see the changes in mysqld.cc).
sql/sql_acl.cc:
Use getters to access error status information in THD.
sql/sql_base.cc:
Access thd->main_da.sql_errno() only if there is an error. This fixes
a bug when auto-discovery, that was effectively disabled under pre-locking.
sql/sql_binlog.cc:
Remove hacks with no_send_ok/no_send_error, they are not necessary
anymore: the caller is responsible for network communication.
sql/sql_cache.cc:
Disable sending of OK/ERROR/EOF packet in the end of dispatch_command
if the response has been served from the query cache. This raises the
question whether we should store EOF packet in the query cache at all,
or generate it anew for each statement (we should generate it anew), but
this is to be addressed separately.
sql/sql_class.cc:
Implement class Diagnostics_area. Please see comments in sql_class.h
for details.
Fix a subtle coding mistake in select_send::send_data: when on slave,
an error in Item::send() was ignored.
The problem became visible due to asserts that the diagnostics area is
never double assigned.
Remove initialization of removed NET members.
In select_send::abort() do not call select_send::send_eof(). This is
not inheritance-safe. Even if a stored procedure continue handler is
found, the current statement is aborted, not succeeded.
Instead introduce a Protocol API to send the required response,
Protocol::end_partial_result_set().
This simplifies implementation of select_send::send_eof(). No need
to add more asserts that there is no error, there is an assert inside
Diagnostics_area::set_ok_status() already.
Leave no trace of no_send_* in the code.
sql/sql_class.h:
Declare class Diagnostics_area.
Remove the hack with no_send_ok from
Substatement_state.
Provide inline implementations of send_ok/send_eof.
Add commetns.
sql/sql_connect.cc:
Remove hacks with no_send_error.
Since now an error in THD is always set if net->error, it's not necessary
to check both net->error and thd->is_error() in the do_command loop.
Use thd->main_da.message() instead of net->last_errno.
Remove the hack with is_slave_error in sys_init_connect. Since now we do not
reset the diagnostics area in net_send_error (it's reset at the beginning
of the next statement), we can access it safely even after
execute_init_command.
sql/sql_db.cc:
Update the code to satisfy the invariant that the diagnostics area is never
assigned twice.
Incidentally, this fixes Bug 29958 "Weird message on DROP DATABASE if
mysql.proc does not exist".
sql/sql_delete.cc:
Change multi-delete to abort in abort(), as per select_send protocol.
Fixes the merge error with the test for Bug 29136
sql/sql_derived.cc:
Use getters to access error information.
sql/sql_insert.cc:
Use getters to access error information.
sql-common/client.c:
Rename last_error to client_last_error, last_errno to client_last_errno.
sql/sql_parse.cc:
Remove hacks with no_send_error. Deploy net_end_statement().
The story of COM_SHUTDOWN is interesting. Long story short, the server
would become on its death's door, and only no_send_ok/no_send_error assigned
by send_ok()/net_send_error() would hide its babbling from the client.
First of all, COM_QUIT does not require a response. So, the comment saying
"Let's send a response to possible COM_QUIT" is not only groundless
(even mysqladmin shutdown/mysql_shutdown() doesn't send COM_QUIT after
COM_SHUTDOWN), it's plainly incorrect.
Secondly, besides this additional 'OK' packet to respond to a hypothetical
COM_QUIT, there was the following code in dispatch_command():
if (thd->killed)
thd->send_kill_message();
if (thd->is_error()
net_send_error(thd);
This worked out really funny for the thread through which COM_SHUTDOWN
was delivered: we would get COM_SHUTDOWN, say okay, say okay again,
kill everybody, get the kill signal ourselves, and then attempt to say
"Server shutdown in progress" to the client that is very likely long gone.
This all became visible when asserts were added that the Diagnostics_area
is not assigned twice.
Move query_cache_end_of_result() to the end of dispatch_command(), since
net_send_eof() has been moved there. This is safe, query_cache_end_of_result()
is a no-op if there is no started query in the cache.
Consistently use select_send interface to call abort() or send_eof()
depending on the operation result.
Remove thd->fatal_error() from reset_master(), it was a no-op.
in hacks with no_send_error woudl save us
from complete breakage of the client/server protocol.
Consistently use select_send::abort() whenever there is an error,
and select_send::send_eof() in case of success.
The issue became visible due to added asserts.
sql/sql_partition.cc:
Always set an error in THD whenever there is a call to fatal_error().
sql/sql_prepare.cc:
Deploy class Diagnostics_area.
Remove the unnecessary juggling with the protocol in
Select_fetch_protocol_binary::send_eof(). EOF packet format is
protocol-independent.
sql/sql_select.cc:
Call fatal_error() directly in opt_sum_query.
Call my_error() whenever we call thd->fatal_error().
sql/sql_servers.cc:
Use getters to access error information in THD.
sql/sql_show.cc:
Use getters to access error information in THD.
Add comments.
Call my_error() whenever we call fatal_error().
sql/sql_table.cc:
Replace hacks with no_send_ok with the interface of the diagnostics area.
Clear the error if ENOENT error in ha_delete_table().
sql/sql_update.cc:
Introduce multi_update::abort(), which is the proper way to abort a
multi-update. This fixes the merge conflict between this patch and
the patch for Bug 29136.
sql/table.cc:
Use a getter to access error information in THD.
sql/tztime.cc:
Use a getter to access error information in THD.
2007-12-12 16:21:01 +01:00
|
|
|
DBUG_PRINT("error",("message: %u (%s)",
|
Bug#34655 Compile error
Rename client_last_error to last_error and client_last_errno to last_errno
to not break connectors which use the internal net structure for error handling.
include/mysql_com.h:
Rename client_last_error to last_error, client_last_errno to last_errno.
include/mysql_h.ic:
Rename client_last_error to last_error, client_last_errno to last_errno.
libmysql/libmysql.c:
Rename client_last_error to last_error, client_last_errno to last_errno.
libmysql/manager.c:
Rename client_last_error to last_error, client_last_errno to last_errno.
libmysqld/lib_sql.cc:
Rename client_last_error to last_error, client_last_errno to last_errno.
libmysqld/libmysqld.c:
Rename client_last_error to last_error, client_last_errno to last_errno.
server-tools/instance-manager/mysql_connection.cc:
Rename client_last_error to last_error, client_last_errno to last_errno.
sql/log_event.cc:
Rename client_last_error to last_error, client_last_errno to last_errno.
sql-common/client.c:
Rename client_last_error to last_error, client_last_errno to last_errno.
sql/log_event_old.cc:
Rename client_last_error to last_error, client_last_errno to last_errno.
sql/net_serv.cc:
Rename client_last_error to last_error, client_last_errno to last_errno.
sql/repl_failsafe.cc:
Rename client_last_error to last_error, client_last_errno to last_errno.
2008-02-28 18:55:46 +01:00
|
|
|
mysql->net.last_errno,
|
|
|
|
mysql->net.last_error));
|
2001-04-11 13:04:03 +02:00
|
|
|
{
|
|
|
|
/* Free alloced memory */
|
|
|
|
my_bool free_me=mysql->free_me;
|
2009-10-09 14:30:54 +02:00
|
|
|
free_old_query(mysql);
|
2001-04-11 13:04:03 +02:00
|
|
|
mysql->free_me=0;
|
|
|
|
mysql_close(mysql);
|
|
|
|
mysql->free_me=free_me;
|
|
|
|
}
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|