2016-02-09 11:27:40 +01:00
|
|
|
/* Copyright (c) 2003, 2016, Oracle and/or its affiliates.
|
2020-09-23 11:42:30 +02:00
|
|
|
Copyright (c) 2009, 2020, MariaDB
|
2003-05-31 12:15:46 +02: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.
|
2003-05-31 12:15:46 +02:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
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 Street, Fifth Floor, Boston, MA 02110-1335 USA */
|
2003-05-31 12:15:46 +02:00
|
|
|
|
2003-06-03 12:02:57 +02:00
|
|
|
/*
|
|
|
|
This file is included by both libmysql.c (the MySQL client C API)
|
|
|
|
and the mysqld server to connect to another MYSQL server.
|
|
|
|
|
|
|
|
The differences for the two cases are:
|
|
|
|
|
|
|
|
- Things that only works for the client:
|
|
|
|
- Trying to automaticly determinate user name if not supplied to
|
|
|
|
mysql_real_connect()
|
|
|
|
- Support for reading local file with LOAD DATA LOCAL
|
|
|
|
- SHARED memory handling
|
|
|
|
- Prepared statements
|
|
|
|
|
|
|
|
- Things that only works for the server
|
|
|
|
- Alarm handling on connect
|
|
|
|
|
|
|
|
In all other cases, the code should be idential for the client and
|
|
|
|
server.
|
|
|
|
*/
|
|
|
|
|
2003-05-31 12:15:46 +02:00
|
|
|
#include <my_global.h>
|
2013-03-25 23:03:13 +01:00
|
|
|
#include <my_default.h>
|
2003-05-31 12:15:46 +02:00
|
|
|
#include "mysql.h"
|
2013-10-03 17:00:44 +02:00
|
|
|
#include "hash.h"
|
2003-06-17 18:32:31 +02:00
|
|
|
|
2004-06-25 20:56:23 +02:00
|
|
|
/* Remove client convenience wrappers */
|
|
|
|
#undef max_allowed_packet
|
|
|
|
#undef net_buffer_length
|
|
|
|
|
2003-06-17 18:32:31 +02:00
|
|
|
#ifdef EMBEDDED_LIBRARY
|
|
|
|
|
|
|
|
#undef MYSQL_SERVER
|
|
|
|
|
|
|
|
#ifndef MYSQL_CLIENT
|
|
|
|
#define MYSQL_CLIENT
|
|
|
|
#endif
|
|
|
|
|
2007-06-15 20:32:16 +02:00
|
|
|
#define CLI_MYSQL_REAL_CONNECT STDCALL cli_mysql_real_connect
|
2003-06-17 18:32:31 +02:00
|
|
|
|
|
|
|
#undef net_flush
|
|
|
|
my_bool net_flush(NET *net);
|
|
|
|
|
|
|
|
#else /*EMBEDDED_LIBRARY*/
|
2003-12-21 01:07:45 +01:00
|
|
|
#define CLI_MYSQL_REAL_CONNECT STDCALL mysql_real_connect
|
2003-06-17 18:32:31 +02:00
|
|
|
#endif /*EMBEDDED_LIBRARY*/
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
|
2003-05-31 12:15:46 +02:00
|
|
|
#include <my_sys.h>
|
|
|
|
#include <mysys_err.h>
|
|
|
|
#include <m_string.h>
|
|
|
|
#include <m_ctype.h>
|
|
|
|
#include "mysql_version.h"
|
|
|
|
#include "mysqld_error.h"
|
|
|
|
#include "errmsg.h"
|
|
|
|
#include <violite.h>
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
|
2011-01-11 10:07:37 +01:00
|
|
|
#if !defined(__WIN__)
|
2003-05-31 12:15:46 +02:00
|
|
|
#include <my_pthread.h> /* because of signal() */
|
2011-01-11 10:07:37 +01:00
|
|
|
#endif /* !defined(__WIN__) */
|
2003-05-31 12:15:46 +02:00
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <time.h>
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
|
2003-05-31 12:15:46 +02:00
|
|
|
#ifdef HAVE_PWD_H
|
|
|
|
#include <pwd.h>
|
|
|
|
#endif
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
|
2010-07-15 13:16:06 +02:00
|
|
|
#if !defined(__WIN__)
|
2003-05-31 12:15:46 +02:00
|
|
|
#ifdef HAVE_SELECT_H
|
|
|
|
# include <select.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_SELECT_H
|
|
|
|
#include <sys/select.h>
|
|
|
|
#endif
|
2010-07-15 13:16:06 +02:00
|
|
|
#endif /* !defined(__WIN__) */
|
2003-05-31 12:15:46 +02:00
|
|
|
#ifdef HAVE_SYS_UN_H
|
|
|
|
# include <sys/un.h>
|
|
|
|
#endif
|
|
|
|
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
#ifndef _WIN32
|
2003-05-31 12:15:46 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#define SOCKET_ERROR -1
|
2018-02-20 22:17:36 +01:00
|
|
|
#define INVALID_SOCKET -1
|
2003-05-31 12:15:46 +02:00
|
|
|
#endif
|
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
#ifdef __WIN__
|
|
|
|
#define CONNECT_TIMEOUT 20
|
|
|
|
#else
|
|
|
|
#define CONNECT_TIMEOUT 0
|
|
|
|
#endif
|
|
|
|
|
2003-05-31 12:15:46 +02:00
|
|
|
#include "client_settings.h"
|
2017-05-03 21:22:59 +02:00
|
|
|
#include <ssl_compat.h>
|
2003-05-31 12:15:46 +02:00
|
|
|
#include <sql_common.h>
|
2010-03-29 17:13:53 +02:00
|
|
|
#include <mysql/client_plugin.h>
|
2012-01-06 12:43:18 +01:00
|
|
|
#include <my_context.h>
|
|
|
|
#include <mysql_async.h>
|
2010-03-29 17:13:53 +02:00
|
|
|
|
2019-01-25 23:12:35 +01:00
|
|
|
typedef enum {
|
|
|
|
ALWAYS_ACCEPT, /* heuristics is disabled, use CLIENT_LOCAL_FILES */
|
|
|
|
WAIT_FOR_QUERY, /* heuristics is enabled, not sending files */
|
|
|
|
ACCEPT_FILE_REQUEST /* heuristics is enabled, ready to send a file */
|
|
|
|
} auto_local_infile_state;
|
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
#define native_password_plugin_name "mysql_native_password"
|
|
|
|
#define old_password_plugin_name "mysql_old_password"
|
2003-05-31 12:15:46 +02:00
|
|
|
|
2015-01-19 17:31:59 +01:00
|
|
|
uint mariadb_deinitialize_ssl= 1;
|
2003-06-14 10:37:42 +02:00
|
|
|
uint mysql_port=0;
|
|
|
|
char *mysql_unix_port= 0;
|
|
|
|
const char *unknown_sqlstate= "HY000";
|
2003-06-05 22:19:56 +02:00
|
|
|
const char *not_error_sqlstate= "00000";
|
2008-02-27 09:42:43 +01:00
|
|
|
const char *cant_connect_sqlstate= "08001";
|
2003-06-04 09:21:49 +02:00
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
static void mysql_close_free_options(MYSQL *mysql);
|
|
|
|
static void mysql_close_free(MYSQL *mysql);
|
2009-05-20 19:34:37 +02:00
|
|
|
static void mysql_prune_stmt_list(MYSQL *mysql);
|
2012-10-01 13:15:29 +02:00
|
|
|
static int cli_report_progress(MYSQL *mysql, char *packet, uint length);
|
2003-06-14 10:37:42 +02:00
|
|
|
|
2006-06-19 19:11:01 +02:00
|
|
|
CHARSET_INFO *default_client_charset_info = &my_charset_latin1;
|
|
|
|
|
2008-02-27 09:42:43 +01:00
|
|
|
/* Server error code and message */
|
|
|
|
unsigned int mysql_server_last_errno;
|
|
|
|
char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
|
2004-08-21 05:07:32 +02:00
|
|
|
|
2012-08-14 16:23:34 +02:00
|
|
|
/**
|
|
|
|
Convert the connect timeout option to a timeout value for VIO
|
|
|
|
functions (vio_socket_connect() and vio_io_wait()).
|
|
|
|
|
|
|
|
@param mysql Connection handle (client side).
|
|
|
|
|
|
|
|
@return The timeout value in milliseconds, or -1 if no timeout.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int get_vio_connect_timeout(MYSQL *mysql)
|
|
|
|
{
|
|
|
|
int timeout_ms;
|
|
|
|
uint timeout_sec;
|
|
|
|
|
|
|
|
/*
|
|
|
|
A timeout of 0 means no timeout. Also, the connect_timeout
|
|
|
|
option value is in seconds, while VIO timeouts are measured
|
|
|
|
in milliseconds. Hence, check for a possible overflow. In
|
|
|
|
case of overflow, set to no timeout.
|
|
|
|
*/
|
|
|
|
timeout_sec= mysql->options.connect_timeout;
|
|
|
|
|
|
|
|
if (!timeout_sec || (timeout_sec > INT_MAX/1000))
|
|
|
|
timeout_ms= -1;
|
|
|
|
else
|
|
|
|
timeout_ms= (int) (timeout_sec * 1000);
|
|
|
|
|
|
|
|
return timeout_ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-31 21:48:41 +01:00
|
|
|
/**
|
|
|
|
Set the internal error message to mysql handler
|
|
|
|
|
|
|
|
@param mysql connection handle (client side)
|
|
|
|
@param errcode CR_ error code, passed to ER macro to get
|
|
|
|
error text
|
|
|
|
@parma sqlstate SQL standard sqlstate
|
|
|
|
*/
|
|
|
|
|
|
|
|
void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate)
|
|
|
|
{
|
|
|
|
NET *net;
|
|
|
|
DBUG_ENTER("set_mysql_error");
|
|
|
|
DBUG_PRINT("enter", ("error :%d '%s'", errcode, ER(errcode)));
|
|
|
|
DBUG_ASSERT(mysql != 0);
|
|
|
|
|
2008-02-27 10:00:59 +01:00
|
|
|
if (mysql)
|
|
|
|
{
|
|
|
|
net= &mysql->net;
|
2008-03-12 09:19:46 +01:00
|
|
|
net->last_errno= errcode;
|
|
|
|
strmov(net->last_error, ER(errcode));
|
2008-02-27 10:00:59 +01:00
|
|
|
strmov(net->sqlstate, sqlstate);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mysql_server_last_errno= errcode;
|
|
|
|
strmov(mysql_server_last_error, ER(errcode));
|
|
|
|
}
|
2007-10-31 21:48:41 +01:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Clear possible error state of struct NET
|
|
|
|
|
|
|
|
@param net clear the state of the argument
|
|
|
|
*/
|
|
|
|
|
|
|
|
void net_clear_error(NET *net)
|
|
|
|
{
|
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
|
|
|
net->last_errno= 0;
|
|
|
|
net->last_error[0]= '\0';
|
2007-10-31 21:48:41 +01:00
|
|
|
strmov(net->sqlstate, not_error_sqlstate);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set an error message on the client.
|
|
|
|
|
|
|
|
@param mysql connection handle
|
|
|
|
@param errcode CR_* errcode, for client errors
|
|
|
|
@param sqlstate SQL standard sql state, unknown_sqlstate for the
|
|
|
|
majority of client errors.
|
|
|
|
@param format error message template, in sprintf format
|
|
|
|
@param ... variable number of arguments
|
|
|
|
*/
|
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
void set_mysql_extended_error(MYSQL *mysql, int errcode,
|
2007-10-31 21:48:41 +01:00
|
|
|
const char *sqlstate,
|
|
|
|
const char *format, ...)
|
|
|
|
{
|
|
|
|
NET *net;
|
|
|
|
va_list args;
|
|
|
|
DBUG_ENTER("set_mysql_extended_error");
|
|
|
|
DBUG_PRINT("enter", ("error :%d '%s'", errcode, format));
|
|
|
|
DBUG_ASSERT(mysql != 0);
|
|
|
|
|
|
|
|
net= &mysql->net;
|
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
|
|
|
net->last_errno= errcode;
|
2007-10-31 21:48:41 +01:00
|
|
|
va_start(args, format);
|
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
|
|
|
my_vsnprintf(net->last_error, sizeof(net->last_error)-1,
|
2007-10-31 21:48:41 +01:00
|
|
|
format, args);
|
|
|
|
va_end(args);
|
|
|
|
strmov(net->sqlstate, sqlstate);
|
|
|
|
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Create a named pipe connection
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __WIN__
|
|
|
|
|
2007-10-31 22:55:25 +01:00
|
|
|
HANDLE create_named_pipe(MYSQL *mysql, uint connect_timeout, char **arg_host,
|
2003-05-02 18:07:41 +02:00
|
|
|
char **arg_unix_socket)
|
|
|
|
{
|
|
|
|
HANDLE hPipe=INVALID_HANDLE_VALUE;
|
2004-02-22 07:09:32 +01:00
|
|
|
char pipe_name[1024];
|
2003-05-02 18:07:41 +02:00
|
|
|
DWORD dwMode;
|
|
|
|
int i;
|
|
|
|
char *host= *arg_host, *unix_socket= *arg_unix_socket;
|
|
|
|
|
|
|
|
if ( ! unix_socket || (unix_socket)[0] == 0x00)
|
|
|
|
unix_socket = mysql_unix_port;
|
|
|
|
if (!host || !strcmp(host,LOCAL_HOST))
|
|
|
|
host=LOCAL_HOST_NAMEDPIPE;
|
|
|
|
|
2004-02-22 07:09:32 +01:00
|
|
|
|
|
|
|
pipe_name[sizeof(pipe_name)-1]= 0; /* Safety if too long string */
|
|
|
|
strxnmov(pipe_name, sizeof(pipe_name)-1, "\\\\", host, "\\pipe\\",
|
|
|
|
unix_socket, NullS);
|
|
|
|
DBUG_PRINT("info",("Server name: '%s'. Named Pipe: %s", host, unix_socket));
|
2003-05-02 18:07:41 +02:00
|
|
|
|
|
|
|
for (i=0 ; i < 100 ; i++) /* Don't retry forever */
|
|
|
|
{
|
2004-02-22 07:09:32 +01:00
|
|
|
if ((hPipe = CreateFile(pipe_name,
|
2003-05-02 18:07:41 +02:00
|
|
|
GENERIC_READ | GENERIC_WRITE,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
OPEN_EXISTING,
|
2009-11-02 23:19:58 +01:00
|
|
|
FILE_FLAG_OVERLAPPED,
|
2003-05-02 18:07:41 +02:00
|
|
|
NULL )) != INVALID_HANDLE_VALUE)
|
|
|
|
break;
|
|
|
|
if (GetLastError() != ERROR_PIPE_BUSY)
|
|
|
|
{
|
2007-10-31 15:16:53 +01:00
|
|
|
set_mysql_extended_error(mysql, CR_NAMEDPIPEOPEN_ERROR,
|
|
|
|
unknown_sqlstate, ER(CR_NAMEDPIPEOPEN_ERROR),
|
|
|
|
host, unix_socket, (ulong) GetLastError());
|
2003-05-02 18:07:41 +02:00
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
/* wait for for an other instance */
|
2004-02-22 07:09:32 +01:00
|
|
|
if (! WaitNamedPipe(pipe_name, connect_timeout*1000) )
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2007-10-31 15:16:53 +01:00
|
|
|
set_mysql_extended_error(mysql, CR_NAMEDPIPEWAIT_ERROR, unknown_sqlstate,
|
|
|
|
ER(CR_NAMEDPIPEWAIT_ERROR),
|
|
|
|
host, unix_socket, (ulong) GetLastError());
|
2003-05-02 18:07:41 +02:00
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hPipe == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
2007-10-31 15:16:53 +01:00
|
|
|
set_mysql_extended_error(mysql, CR_NAMEDPIPEOPEN_ERROR, unknown_sqlstate,
|
|
|
|
ER(CR_NAMEDPIPEOPEN_ERROR), host, unix_socket,
|
|
|
|
(ulong) GetLastError());
|
2003-05-02 18:07:41 +02:00
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
dwMode = PIPE_READMODE_BYTE | PIPE_WAIT;
|
|
|
|
if ( !SetNamedPipeHandleState(hPipe, &dwMode, NULL, NULL) )
|
|
|
|
{
|
|
|
|
CloseHandle( hPipe );
|
2007-10-31 15:16:53 +01:00
|
|
|
set_mysql_extended_error(mysql, CR_NAMEDPIPESETSTATE_ERROR,
|
|
|
|
unknown_sqlstate, ER(CR_NAMEDPIPESETSTATE_ERROR),
|
|
|
|
host, unix_socket, (ulong) GetLastError());
|
2003-05-02 18:07:41 +02:00
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
*arg_host=host ; *arg_unix_socket=unix_socket; /* connect arg */
|
|
|
|
return (hPipe);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
/**
|
2003-05-02 18:07:41 +02:00
|
|
|
Read a packet from server. Give error message if socket was down
|
|
|
|
or packet is an error message
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
|
|
|
|
@retval packet_error An error occurred during reading.
|
|
|
|
Error message is set.
|
|
|
|
@retval
|
|
|
|
*/
|
2003-05-02 18:07:41 +02:00
|
|
|
ulong
|
A fix and a test case for Bug#15752 "Lost connection to MySQL server
when calling a SP from C API"
The bug was caused by lack of checks for misuse in mysql_real_query.
A stored procedure always returns at least one result, which is the
status of execution of the procedure itself.
This result, or so-called OK packet, is similar to a result
returned by INSERT/UPDATE/CREATE operations: it contains the overall
status of execution, the number of affected rows and the number of
warnings. The client test program attached to the bug did not read this
result and ivnoked the next query. In turn, libmysql had no check for
such scenario and mysql_real_query was simply trying to send that query
without reading the pending response, thus messing up the communication
protocol.
The fix is to return an error from mysql_real_query when it's called
prior to retrieval of all pending results.
client/mysqlbinlog.cc:
net_safe_read -> cli_safe_read
include/mysql.h:
Remove a private function from the public header.
include/mysql_com.h:
Remove a define that is never used.
include/sql_common.h:
Add a declaration for cli_safe_read - a function that reads one packet
from the server.
libmysql/libmysql.c:
net_safe_read -> cli_safe_read
Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
using a connection which has pending result sets.
sql-common/client.c:
Actual fix for Bug#15752: if the server has pending result sets for
the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
another query. Similarly to the behaviour of mysql_use_result(),
multiple result sets block the connection and must be fetched
before it can be used for another query.
This uncovered an error in the protocol: the server doesn't drop
SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
a multi-query like SELECT 1; SELECT syntax_error; SELECT 2;
the client has no way to know that the server won't ever come to
execution of the third query and won't return any result sets for it.
For now, fix it in cli_safe_read, as a proper fix requires extension
of the client-server protocol.
sql/protocol.cc:
Remove a name that is never used.
sql/slave.cc:
net_safe_read -> cli_safe_read
tests/mysql_client_test.c:
Make 'query' a local variable to avoid name clash.
Add a test case for Bug#15752 "Lost connection to MySQL server when
calling an SP from C API"
2006-07-24 12:56:53 +02:00
|
|
|
cli_safe_read(MYSQL *mysql)
|
2016-10-21 10:02:51 +02:00
|
|
|
{
|
|
|
|
ulong reallen = 0;
|
|
|
|
return cli_safe_read_reallen(mysql, &reallen);
|
|
|
|
}
|
|
|
|
|
|
|
|
ulong
|
|
|
|
cli_safe_read_reallen(MYSQL *mysql, ulong* reallen)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
NET *net= &mysql->net;
|
|
|
|
ulong len=0;
|
|
|
|
|
2011-07-01 14:08:30 +02:00
|
|
|
restart:
|
2003-05-02 18:07:41 +02:00
|
|
|
if (net->vio != 0)
|
2016-10-21 10:02:51 +02:00
|
|
|
len= my_net_read_packet_reallen(net, 0, reallen);
|
2003-05-02 18:07:41 +02:00
|
|
|
|
|
|
|
if (len == packet_error || len == 0)
|
|
|
|
{
|
2006-11-20 21:42:06 +01:00
|
|
|
DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %lu",
|
2017-03-02 06:53:07 +01:00
|
|
|
net->vio ? vio_description(net->vio) : NULL, len));
|
2003-07-28 17:16:11 +02:00
|
|
|
#ifdef MYSQL_SERVER
|
2012-08-17 15:46:34 +02:00
|
|
|
if (net->vio && (net->last_errno == ER_NET_READ_INTERRUPTED))
|
2003-07-28 17:16:11 +02:00
|
|
|
return (packet_error);
|
|
|
|
#endif /*MYSQL_SERVER*/
|
2003-05-02 18:07:41 +02:00
|
|
|
end_server(mysql);
|
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
|
|
|
set_mysql_error(mysql, net->last_errno == ER_NET_PACKET_TOO_LARGE ?
|
2004-03-12 13:21:48 +01:00
|
|
|
CR_NET_PACKET_TOO_LARGE: CR_SERVER_LOST, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
return (packet_error);
|
|
|
|
}
|
|
|
|
if (net->read_pos[0] == 255)
|
|
|
|
{
|
|
|
|
if (len > 3)
|
|
|
|
{
|
2012-10-01 13:15:29 +02:00
|
|
|
char *pos= (char*) net->read_pos+1;
|
2011-07-01 14:08:30 +02:00
|
|
|
uint last_errno=uint2korr(pos);
|
|
|
|
|
|
|
|
if (last_errno == 65535 &&
|
2016-01-17 21:21:39 +01:00
|
|
|
(mysql->server_capabilities & CLIENT_PROGRESS_OBSOLETE))
|
2011-07-01 14:08:30 +02:00
|
|
|
{
|
|
|
|
if (cli_report_progress(mysql, pos+2, (uint) (len-3)))
|
|
|
|
{
|
|
|
|
/* Wrong packet */
|
|
|
|
set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate);
|
|
|
|
return (packet_error);
|
|
|
|
}
|
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
net->last_errno= last_errno;
|
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
pos+=2;
|
|
|
|
len-=2;
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
if (protocol_41(mysql) && pos[0] == '#')
|
2003-05-31 12:15:46 +02:00
|
|
|
{
|
2013-06-06 21:32:29 +02:00
|
|
|
strmake_buf(net->sqlstate, pos+1);
|
2003-05-31 12:15:46 +02:00
|
|
|
pos+= SQLSTATE_LENGTH+1;
|
|
|
|
}
|
A fix for Bug#35289: Too many connections -- wrong SQL state
in some case.
ER_CON_COUNT_ERROR is defined with SQL state 08004. However, this SQL state is not always
returned.
This error can be thrown in two cases:
1. when an ordinary user (a user w/o SUPER privilege) is connecting,
and the number of active user connections is equal or greater than
max_connections.
2. when a user is connecting and the number of active user connections is
already (max_connections + 1) -- that means that no more connections will
be accepted regardless of the user credentials.
In the 1-st case, SQL state is correct.
The bug happens in the 2-nd case -- on UNIX the client gets 00000 SQL state, which is
absolutely wrong (00000 means "not error SQL state); on Windows
the client accidentally gets HY000 (which means "unknown SQL state).
The cause of the problem is that the server rejects extra connection
prior to read a packet with client capabilities. Thus, the server
does not know if the client supports SQL states or not (if the client
supports 4.1 protocol or not). So, the server supposes the worst and
does not send SQL state at all.
The difference in behavior on UNIX and Windows occurs because on Windows
CLI_MYSQL_REAL_CONNECT() invokes create_shared_memory(), which returns
an error (in default configuration, where shared memory is not configured).
Then, the client does not reset this error, so when the connection is
rejected, SQL state is HY000 (from the error from create_shared_memory()).
The bug appeared after test case for Bug#33507 -- before that, this behavior
just had not been tested.
The fix is to 1) reset the error after create_shared_memory();
2) set SQL state to 'unknown error' if it was not received from
the server.
A separate test case is not required, since the behavior is already
tested in connect.test.
Note for doc-team: the manual should be updated to say that under
some circumstances, 'Too many connections' has HY000 SQL state.
mysql-test/r/connect.result:
Update result file.
sql-common/client.c:
1. Reset an error from create_shared_memory();
2. Set SQL state to 'unknown error' if it was not received from
the server.
2008-03-14 13:58:27 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
The SQL state hasn't been received -- it should be reset to HY000
|
|
|
|
(unknown error sql state).
|
|
|
|
*/
|
|
|
|
|
|
|
|
strmov(net->sqlstate, unknown_sqlstate);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
(void) strmake(net->last_error,(char*) pos,
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
MY_MIN((uint) len,(uint) sizeof(net->last_error)-1));
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
else
|
2004-03-12 13:21:48 +01:00
|
|
|
set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
|
A fix and a test case for Bug#15752 "Lost connection to MySQL server
when calling a SP from C API"
The bug was caused by lack of checks for misuse in mysql_real_query.
A stored procedure always returns at least one result, which is the
status of execution of the procedure itself.
This result, or so-called OK packet, is similar to a result
returned by INSERT/UPDATE/CREATE operations: it contains the overall
status of execution, the number of affected rows and the number of
warnings. The client test program attached to the bug did not read this
result and ivnoked the next query. In turn, libmysql had no check for
such scenario and mysql_real_query was simply trying to send that query
without reading the pending response, thus messing up the communication
protocol.
The fix is to return an error from mysql_real_query when it's called
prior to retrieval of all pending results.
client/mysqlbinlog.cc:
net_safe_read -> cli_safe_read
include/mysql.h:
Remove a private function from the public header.
include/mysql_com.h:
Remove a define that is never used.
include/sql_common.h:
Add a declaration for cli_safe_read - a function that reads one packet
from the server.
libmysql/libmysql.c:
net_safe_read -> cli_safe_read
Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
using a connection which has pending result sets.
sql-common/client.c:
Actual fix for Bug#15752: if the server has pending result sets for
the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
another query. Similarly to the behaviour of mysql_use_result(),
multiple result sets block the connection and must be fetched
before it can be used for another query.
This uncovered an error in the protocol: the server doesn't drop
SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
a multi-query like SELECT 1; SELECT syntax_error; SELECT 2;
the client has no way to know that the server won't ever come to
execution of the third query and won't return any result sets for it.
For now, fix it in cli_safe_read, as a proper fix requires extension
of the client-server protocol.
sql/protocol.cc:
Remove a name that is never used.
sql/slave.cc:
net_safe_read -> cli_safe_read
tests/mysql_client_test.c:
Make 'query' a local variable to avoid name clash.
Add a test case for Bug#15752 "Lost connection to MySQL server when
calling an SP from C API"
2006-07-24 12:56:53 +02:00
|
|
|
/*
|
|
|
|
Cover a protocol design error: error packet does not
|
|
|
|
contain the server status. Therefore, the client has no way
|
|
|
|
to find out whether there are more result sets of
|
|
|
|
a multiple-result-set statement pending. Luckily, in 5.0 an
|
|
|
|
error always aborts execution of a statement, wherever it is
|
|
|
|
a multi-statement or a stored procedure, so it should be
|
|
|
|
safe to unconditionally turn off the flag here.
|
|
|
|
*/
|
|
|
|
mysql->server_status&= ~SERVER_MORE_RESULTS_EXISTS;
|
2004-03-12 13:21:48 +01:00
|
|
|
|
2003-05-31 12:15:46 +02:00
|
|
|
DBUG_PRINT("error",("Got error: %d/%s (%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
|
|
|
net->last_errno,
|
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
|
|
|
net->sqlstate,
|
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
|
|
|
net->last_error));
|
2003-05-02 18:07:41 +02:00
|
|
|
return(packet_error);
|
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2003-05-31 12:15:46 +02:00
|
|
|
void free_rows(MYSQL_DATA *cur)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
if (cur)
|
|
|
|
{
|
|
|
|
free_root(&cur->alloc,MYF(0));
|
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(cur);
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-20 21:06:25 +01:00
|
|
|
my_bool
|
2003-06-17 18:32:31 +02:00
|
|
|
cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
BitKeeper/etc/ignore:
added libmysqld/ha_ndbcluster_cond.cc
---
added debian/defs.mk debian/control
client/completion_hash.cc:
Remove not needed casts
client/my_readline.h:
Remove some old types
client/mysql.cc:
Simplify types
client/mysql_upgrade.c:
Remove some old types
Update call to dirname_part
client/mysqladmin.cc:
Remove some old types
client/mysqlbinlog.cc:
Remove some old types
Change some buffers to be uchar to avoid casts
client/mysqlcheck.c:
Remove some old types
client/mysqldump.c:
Remove some old types
Remove some not needed casts
Change some string lengths to size_t
client/mysqlimport.c:
Remove some old types
client/mysqlshow.c:
Remove some old types
client/mysqlslap.c:
Remove some old types
Remove some not needed casts
client/mysqltest.c:
Removed some old types
Removed some not needed casts
Updated hash-get-key function arguments
Updated parameters to dirname_part()
client/readline.cc:
Removed some old types
Removed some not needed casts
Changed some string lengths to use size_t
client/sql_string.cc:
Removed some old types
dbug/dbug.c:
Removed some old types
Changed some string lengths to use size_t
Changed some prototypes to avoid casts
extra/comp_err.c:
Removed some old types
extra/innochecksum.c:
Removed some old types
extra/my_print_defaults.c:
Removed some old types
extra/mysql_waitpid.c:
Removed some old types
extra/perror.c:
Removed some old types
extra/replace.c:
Removed some old types
Updated parameters to dirname_part()
extra/resolve_stack_dump.c:
Removed some old types
extra/resolveip.c:
Removed some old types
include/config-win.h:
Removed some old types
include/decimal.h:
Changed binary strings to be uchar* instead of char*
include/ft_global.h:
Removed some old types
include/hash.h:
Removed some old types
include/heap.h:
Removed some old types
Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable
include/keycache.h:
Removed some old types
include/m_ctype.h:
Removed some old types
Changed some string lengths to use size_t
Changed character length functions to return uint
unsigned char -> uchar
include/m_string.h:
Removed some old types
Changed some string lengths to use size_t
include/my_alloc.h:
Changed some string lengths to use size_t
include/my_base.h:
Removed some old types
include/my_dbug.h:
Removed some old types
Changed some string lengths to use size_t
Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage
include/my_getopt.h:
Removed some old types
include/my_global.h:
Removed old types:
my_size_t -> size_t
byte -> uchar
gptr -> uchar *
include/my_list.h:
Removed some old types
include/my_nosys.h:
Removed some old types
include/my_pthread.h:
Removed some old types
include/my_sys.h:
Removed some old types
Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read()
Changed some string lengths to use size_t
my_malloc() / my_free() now uses void *
Updated parameters to dirname_part() & my_uncompress()
include/my_tree.h:
Removed some old types
include/my_trie.h:
Removed some old types
include/my_user.h:
Changed some string lengths to use size_t
include/my_vle.h:
Removed some old types
include/my_xml.h:
Removed some old types
Changed some string lengths to use size_t
include/myisam.h:
Removed some old types
include/myisammrg.h:
Removed some old types
include/mysql.h:
Removed some old types
Changed byte streams to use uchar* instead of char*
include/mysql_com.h:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
include/queues.h:
Removed some old types
include/sql_common.h:
Removed some old types
include/sslopt-longopts.h:
Removed some old types
include/violite.h:
Removed some old types
Changed some string lengths to use size_t
libmysql/client_settings.h:
Removed some old types
libmysql/libmysql.c:
Removed some old types
libmysql/manager.c:
Removed some old types
libmysqld/emb_qcache.cc:
Removed some old types
libmysqld/emb_qcache.h:
Removed some old types
libmysqld/lib_sql.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
true -> TRUE, false -> FALSE
mysys/array.c:
Removed some old types
mysys/charset.c:
Changed some string lengths to use size_t
mysys/checksum.c:
Include zlib to get definition for crc32
Removed some old types
mysys/default.c:
Removed some old types
Changed some string lengths to use size_t
mysys/default_modify.c:
Changed some string lengths to use size_t
Removed some not needed casts
mysys/hash.c:
Removed some old types
Changed some string lengths to use size_t
Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function.
hash_element now takes 'ulong' as the index type (cleanup)
mysys/list.c:
Removed some old types
mysys/mf_cache.c:
Changed some string lengths to use size_t
mysys/mf_dirname.c:
Removed some old types
Changed some string lengths to use size_t
Added argument to dirname_part() to avoid calculation of length for 'to'
mysys/mf_fn_ext.c:
Removed some old types
Updated parameters to dirname_part()
mysys/mf_format.c:
Removed some old types
Changed some string lengths to use size_t
mysys/mf_getdate.c:
Removed some old types
mysys/mf_iocache.c:
Removed some old types
Changed some string lengths to use size_t
Changed calculation of 'max_length' to be done the same way in all functions
mysys/mf_iocache2.c:
Removed some old types
Changed some string lengths to use size_t
Clean up comments
Removed not needed indentation
mysys/mf_keycache.c:
Removed some old types
mysys/mf_keycaches.c:
Removed some old types
mysys/mf_loadpath.c:
Removed some old types
mysys/mf_pack.c:
Removed some old types
Changed some string lengths to use size_t
Removed some not needed casts
Removed very old VMS code
Updated parameters to dirname_part()
Use result of dirnam_part() to remove call to strcat()
mysys/mf_path.c:
Removed some old types
mysys/mf_radix.c:
Removed some old types
mysys/mf_same.c:
Removed some old types
mysys/mf_sort.c:
Removed some old types
mysys/mf_soundex.c:
Removed some old types
mysys/mf_strip.c:
Removed some old types
mysys/mf_tempdir.c:
Removed some old types
mysys/mf_unixpath.c:
Removed some old types
mysys/mf_wfile.c:
Removed some old types
mysys/mulalloc.c:
Removed some old types
mysys/my_alloc.c:
Removed some old types
Changed some string lengths to use size_t
Use void* as type for allocated memory area
Removed some not needed casts
Changed argument 'Size' to 'length' according coding guidelines
mysys/my_chsize.c:
Changed some buffers to be uchar* to avoid casts
mysys/my_compress.c:
More comments
Removed some old types
Changed string lengths to use size_t
Changed arguments to my_uncompress() to make them easier to understand
Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix)
Changed type of 'pack_data' argument to packfrm() to avoid casts.
mysys/my_conio.c:
Changed some string lengths to use size_t
mysys/my_create.c:
Removed some old types
mysys/my_div.c:
Removed some old types
mysys/my_error.c:
Removed some old types
mysys/my_fopen.c:
Removed some old types
mysys/my_fstream.c:
Removed some old types
Changed some string lengths to use size_t
writen -> written
mysys/my_getopt.c:
Removed some old types
mysys/my_getwd.c:
Removed some old types
More comments
mysys/my_init.c:
Removed some old types
mysys/my_largepage.c:
Removed some old types
Changed some string lengths to use size_t
mysys/my_lib.c:
Removed some old types
mysys/my_lockmem.c:
Removed some old types
mysys/my_malloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/my_memmem.c:
Indentation cleanup
mysys/my_once.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
mysys/my_open.c:
Removed some old types
mysys/my_pread.c:
Removed some old types
Changed all functions to use size_t
Added comment for how my_pread() / my_pwrite() are supposed to work.
Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe.
(If we ever would really need this, it should be enabled only with a flag argument)
mysys/my_quick.c:
Removed some old types
Changed all functions to use size_t
mysys/my_read.c:
Removed some old types
Changed all functions to use size_t
mysys/my_realloc.c:
Removed some old types
Use void* as type for allocated memory area
Changed all functions to use size_t
mysys/my_static.c:
Removed some old types
mysys/my_static.h:
Removed some old types
mysys/my_vle.c:
Removed some old types
mysys/my_wincond.c:
Removed some old types
mysys/my_windac.c:
Removed some old types
mysys/my_write.c:
Removed some old types
Changed all functions to use size_t
mysys/ptr_cmp.c:
Removed some old types
Changed all functions to use size_t
mysys/queues.c:
Removed some old types
mysys/safemalloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/string.c:
Removed some old types
Changed all functions to use size_t
mysys/testhash.c:
Removed some old types
mysys/thr_alarm.c:
Removed some old types
mysys/thr_lock.c:
Removed some old types
mysys/tree.c:
Removed some old types
mysys/trie.c:
Removed some old types
mysys/typelib.c:
Removed some old types
plugin/daemon_example/daemon_example.cc:
Removed some old types
regex/reginit.c:
Removed some old types
server-tools/instance-manager/buffer.cc:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/buffer.h:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/commands.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_map.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_options.cc:
Changed buffer to be of type uchar*
Replaced alloc_root + strcpy() with strdup_root()
server-tools/instance-manager/mysql_connection.cc:
Changed buffer to be of type uchar*
server-tools/instance-manager/options.cc:
Removed some old types
server-tools/instance-manager/parse.cc:
Changed some string lengths to use size_t
server-tools/instance-manager/parse.h:
Removed some old types
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.cc:
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.h:
Changed some string lengths to use size_t
server-tools/instance-manager/user_map.cc:
Removed some old types
Changed some string lengths to use size_t
sql/derror.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/discover.cc:
Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
sql/event_data_objects.cc:
Removed some old types
Added missing casts for alloc() and sprintf()
sql/event_db_repository.cc:
Changed some buffers to be uchar* to avoid casts
Added missing casts for sprintf()
sql/event_queue.cc:
Removed some old types
sql/field.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/field.h:
Removed some old types
Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes).
Changed some string lengths to use size_t
Removed some not needed casts
Changed val_xxx(xxx, new_ptr) to take const pointers
sql/field_conv.cc:
Removed some old types
Added casts required because memory area pointers are now uchar*
sql/filesort.cc:
Initalize variable that was used unitialized in error conditions
sql/gen_lex_hash.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/gstream.h:
Added required cast
sql/ha_ndbcluster.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Added required casts
Removed some not needed casts
sql/ha_ndbcluster.h:
Removed some old types
sql/ha_ndbcluster_binlog.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake()
Changed some string lengths to use size_t
Added missing casts for alloc() and sprintf()
sql/ha_ndbcluster_binlog.h:
Removed some old types
sql/ha_ndbcluster_cond.cc:
Removed some old types
Removed some not needed casts
sql/ha_ndbcluster_cond.h:
Removed some old types
sql/ha_partition.cc:
Removed some old types
Changed prototype for change_partition() to avoid casts
sql/ha_partition.h:
Removed some old types
sql/handler.cc:
Removed some old types
Changed some string lengths to use size_t
sql/handler.h:
Removed some old types
Changed some string lengths to use size_t
Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts
sql/hash_filo.h:
Removed some old types
Changed all functions to use size_t
sql/hostname.cc:
Removed some old types
sql/item.cc:
Removed some old types
Changed some string lengths to use size_t
Use strmake() instead of memdup() to create a null terminated string.
Updated calls to new Field()
sql/item.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.h:
Removed some old types
sql/item_create.cc:
Removed some old types
sql/item_func.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added test for failing alloc() in init_result_field()
Remove old confusing comment
Fixed compiler warning
sql/item_func.h:
Removed some old types
sql/item_row.cc:
Removed some old types
sql/item_row.h:
Removed some old types
sql/item_strfunc.cc:
Include zlib (needed becasue we call crc32)
Removed some old types
sql/item_strfunc.h:
Removed some old types
Changed some types to match new function prototypes
sql/item_subselect.cc:
Removed some old types
sql/item_subselect.h:
Removed some old types
sql/item_sum.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/item_sum.h:
Removed some old types
sql/item_timefunc.cc:
Removed some old types
Changed some string lengths to use size_t
sql/item_timefunc.h:
Removed some old types
sql/item_xmlfunc.cc:
Changed some string lengths to use size_t
sql/item_xmlfunc.h:
Removed some old types
sql/key.cc:
Removed some old types
Removed some not needed casts
sql/lock.cc:
Removed some old types
Added some cast to my_multi_malloc() arguments for safety
sql/log.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Changed usage of pwrite() to not assume it holds the cursor position for the file
Made usage of my_read() safer
sql/log_event.cc:
Removed some old types
Added checking of return value of malloc() in pack_info()
Changed some buffers to be uchar* to avoid casts
Removed some 'const' to avoid casts
Added missing casts for alloc() and sprintf()
Added required casts
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
sql/log_event.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/log_event_old.cc:
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/log_event_old.h:
Changed some buffers to be uchar* to avoid casts
sql/mf_iocache.cc:
Removed some old types
sql/my_decimal.cc:
Changed memory area to use uchar*
sql/my_decimal.h:
Changed memory area to use uchar*
sql/mysql_priv.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some string lengths to use size_t
Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow
Changed some buffers to be uchar* to avoid casts
sql/mysqld.cc:
Removed some old types
sql/net_serv.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Ensure that vio_read()/vio_write() return values are stored in a size_t variable
Removed some not needed casts
sql/opt_range.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/opt_range.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/opt_sum.cc:
Removed some old types
Removed some not needed casts
sql/parse_file.cc:
Removed some old types
Changed some string lengths to use size_t
Changed alloc_root + memcpy + set end 0 -> strmake_root()
sql/parse_file.h:
Removed some old types
sql/partition_info.cc:
Removed some old types
Added missing casts for alloc()
Changed some buffers to be uchar* to avoid casts
sql/partition_info.h:
Changed some buffers to be uchar* to avoid casts
sql/protocol.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/protocol.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/records.cc:
Removed some old types
sql/repl_failsafe.cc:
Removed some old types
Changed some string lengths to use size_t
Added required casts
sql/rpl_filter.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some string lengths to use size_t
sql/rpl_filter.h:
Changed some string lengths to use size_t
sql/rpl_injector.h:
Removed some old types
sql/rpl_record.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
sql/rpl_record.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/rpl_record_old.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/rpl_record_old.h:
Removed some old types
Changed some buffers to be uchar* to avoid cast
sql/rpl_rli.cc:
Removed some old types
sql/rpl_tblmap.cc:
Removed some old types
sql/rpl_tblmap.h:
Removed some old types
sql/rpl_utility.cc:
Removed some old types
sql/rpl_utility.h:
Removed some old types
Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length
sql/set_var.cc:
Removed some old types
Updated parameters to dirname_part()
sql/set_var.h:
Removed some old types
sql/slave.cc:
Removed some old types
Changed some string lengths to use size_t
sql/slave.h:
Removed some old types
sql/sp.cc:
Removed some old types
Added missing casts for printf()
sql/sp.h:
Removed some old types
Updated hash-get-key function arguments
sql/sp_cache.cc:
Removed some old types
Added missing casts for printf()
Updated hash-get-key function arguments
sql/sp_head.cc:
Removed some old types
Added missing casts for alloc() and printf()
Added required casts
Updated hash-get-key function arguments
sql/sp_head.h:
Removed some old types
sql/sp_pcontext.cc:
Removed some old types
sql/sp_pcontext.h:
Removed some old types
sql/sql_acl.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added required casts
sql/sql_analyse.cc:
Changed some buffers to be uchar* to avoid casts
sql/sql_analyse.h:
Changed some buffers to be uchar* to avoid casts
sql/sql_array.h:
Removed some old types
sql/sql_base.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_binlog.cc:
Removed some old types
Added missing casts for printf()
sql/sql_cache.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
Changed some string lengths to use size_t
sql/sql_cache.h:
Removed some old types
Removed reference to not existing function cache_key()
Updated hash-get-key function arguments
sql/sql_class.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc()
Updated hash-get-key function arguments
Moved THD::max_row_length() to table.cc (as it's not depending on THD)
Removed some not needed casts
sql/sql_class.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Removed some not needed casts
Changed some string lengths to use size_t
Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD
sql/sql_connect.cc:
Removed some old types
Added required casts
sql/sql_db.cc:
Removed some old types
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
Added missing casts for alloc()
sql/sql_delete.cc:
Removed some old types
sql/sql_handler.cc:
Removed some old types
Updated hash-get-key function arguments
Added some cast to my_multi_malloc() arguments for safety
sql/sql_help.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_insert.cc:
Removed some old types
Added missing casts for alloc() and printf()
sql/sql_lex.cc:
Removed some old types
sql/sql_lex.h:
Removed some old types
Removed some not needed casts
sql/sql_list.h:
Removed some old types
Removed some not needed casts
sql/sql_load.cc:
Removed some old types
Removed compiler warning
sql/sql_manager.cc:
Removed some old types
sql/sql_map.cc:
Removed some old types
sql/sql_map.h:
Removed some old types
sql/sql_olap.cc:
Removed some old types
sql/sql_parse.cc:
Removed some old types
Trivial move of code lines to make things more readable
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/sql_partition.cc:
Removed some old types
Removed compiler warnings about not used functions
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_partition.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_plugin.cc:
Removed some old types
Added missing casts for alloc()
Updated hash-get-key function arguments
sql/sql_prepare.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Added missing casts for alloc() and printf()
sql-common/client.c:
Removed some old types
Changed some memory areas to use uchar*
sql-common/my_user.c:
Changed some string lengths to use size_t
sql-common/pack.c:
Changed some buffers to be uchar* to avoid casts
sql/sql_repl.cc:
Added required casts
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/sql_select.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some old types
sql/sql_select.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_servers.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_show.cc:
Removed some old types
Added missing casts for alloc()
Removed some not needed casts
sql/sql_string.cc:
Removed some old types
Added required casts
sql/sql_table.cc:
Removed some old types
Removed compiler warning about not used variable
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_test.cc:
Removed some old types
sql/sql_trigger.cc:
Removed some old types
Added missing casts for alloc()
sql/sql_udf.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_union.cc:
Removed some old types
sql/sql_update.cc:
Removed some old types
Removed some not needed casts
sql/sql_view.cc:
Removed some old types
sql/sql_yacc.yy:
Removed some old types
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/stacktrace.c:
Removed some old types
sql/stacktrace.h:
Removed some old types
sql/structs.h:
Removed some old types
sql/table.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Removed setting of LEX_STRING() arguments in declaration
Added required casts
More function comments
Moved max_row_length() here from sql_class.cc/sql_class.h
sql/table.h:
Removed some old types
Changed some string lengths to use size_t
sql/thr_malloc.cc:
Use void* as type for allocated memory area
Changed all functions to use size_t
sql/tzfile.h:
Changed some buffers to be uchar* to avoid casts
sql/tztime.cc:
Changed some buffers to be uchar* to avoid casts
Updated hash-get-key function arguments
Added missing casts for alloc()
Removed some not needed casts
sql/uniques.cc:
Removed some old types
Removed some not needed casts
sql/unireg.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added missing casts for alloc()
storage/archive/archive_reader.c:
Removed some old types
storage/archive/azio.c:
Removed some old types
Removed some not needed casts
storage/archive/ha_archive.cc:
Removed some old types
Changed type for 'frmblob' in archive_discover() to match handler
Updated hash-get-key function arguments
Removed some not needed casts
storage/archive/ha_archive.h:
Removed some old types
storage/blackhole/ha_blackhole.cc:
Removed some old types
storage/blackhole/ha_blackhole.h:
Removed some old types
storage/csv/ha_tina.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
storage/csv/ha_tina.h:
Removed some old types
Removed some not needed casts
storage/csv/transparent_file.cc:
Removed some old types
Changed type of 'bytes_read' to be able to detect read errors
Fixed indentation
storage/csv/transparent_file.h:
Removed some old types
storage/example/ha_example.cc:
Removed some old types
Updated hash-get-key function arguments
storage/example/ha_example.h:
Removed some old types
storage/federated/ha_federated.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
storage/federated/ha_federated.h:
Removed some old types
storage/heap/_check.c:
Changed some buffers to be uchar* to avoid casts
storage/heap/_rectest.c:
Removed some old types
storage/heap/ha_heap.cc:
Removed some old types
storage/heap/ha_heap.h:
Removed some old types
storage/heap/heapdef.h:
Removed some old types
storage/heap/hp_block.c:
Removed some old types
Changed some string lengths to use size_t
storage/heap/hp_clear.c:
Removed some old types
storage/heap/hp_close.c:
Removed some old types
storage/heap/hp_create.c:
Removed some old types
storage/heap/hp_delete.c:
Removed some old types
storage/heap/hp_hash.c:
Removed some old types
storage/heap/hp_info.c:
Removed some old types
storage/heap/hp_open.c:
Removed some old types
storage/heap/hp_rfirst.c:
Removed some old types
storage/heap/hp_rkey.c:
Removed some old types
storage/heap/hp_rlast.c:
Removed some old types
storage/heap/hp_rnext.c:
Removed some old types
storage/heap/hp_rprev.c:
Removed some old types
storage/heap/hp_rrnd.c:
Removed some old types
storage/heap/hp_rsame.c:
Removed some old types
storage/heap/hp_scan.c:
Removed some old types
storage/heap/hp_test1.c:
Removed some old types
storage/heap/hp_test2.c:
Removed some old types
storage/heap/hp_update.c:
Removed some old types
storage/heap/hp_write.c:
Removed some old types
Changed some string lengths to use size_t
storage/innobase/handler/ha_innodb.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc() and printf()
Removed some not needed casts
storage/innobase/handler/ha_innodb.h:
Removed some old types
storage/myisam/ft_boolean_search.c:
Removed some old types
storage/myisam/ft_nlq_search.c:
Removed some old types
storage/myisam/ft_parser.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ft_static.c:
Removed some old types
storage/myisam/ft_stopwords.c:
Removed some old types
storage/myisam/ft_update.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ftdefs.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/fulltext.h:
Removed some old types
storage/myisam/ha_myisam.cc:
Removed some old types
storage/myisam/ha_myisam.h:
Removed some old types
storage/myisam/mi_cache.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_check.c:
Removed some old types
storage/myisam/mi_checksum.c:
Removed some old types
storage/myisam/mi_close.c:
Removed some old types
storage/myisam/mi_create.c:
Removed some old types
storage/myisam/mi_delete.c:
Removed some old types
storage/myisam/mi_delete_all.c:
Removed some old types
storage/myisam/mi_dynrec.c:
Removed some old types
storage/myisam/mi_extra.c:
Removed some old types
storage/myisam/mi_key.c:
Removed some old types
storage/myisam/mi_locking.c:
Removed some old types
storage/myisam/mi_log.c:
Removed some old types
storage/myisam/mi_open.c:
Removed some old types
Removed some not needed casts
Check argument of my_write()/my_pwrite() in functions returning int
Added casting of string lengths to size_t
storage/myisam/mi_packrec.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_page.c:
Removed some old types
storage/myisam/mi_preload.c:
Removed some old types
storage/myisam/mi_range.c:
Removed some old types
storage/myisam/mi_rfirst.c:
Removed some old types
storage/myisam/mi_rkey.c:
Removed some old types
storage/myisam/mi_rlast.c:
Removed some old types
storage/myisam/mi_rnext.c:
Removed some old types
storage/myisam/mi_rnext_same.c:
Removed some old types
storage/myisam/mi_rprev.c:
Removed some old types
storage/myisam/mi_rrnd.c:
Removed some old types
storage/myisam/mi_rsame.c:
Removed some old types
storage/myisam/mi_rsamepos.c:
Removed some old types
storage/myisam/mi_scan.c:
Removed some old types
storage/myisam/mi_search.c:
Removed some old types
storage/myisam/mi_static.c:
Removed some old types
storage/myisam/mi_statrec.c:
Removed some old types
storage/myisam/mi_test1.c:
Removed some old types
storage/myisam/mi_test2.c:
Removed some old types
storage/myisam/mi_test3.c:
Removed some old types
storage/myisam/mi_unique.c:
Removed some old types
storage/myisam/mi_update.c:
Removed some old types
storage/myisam/mi_write.c:
Removed some old types
storage/myisam/myisam_ftdump.c:
Removed some old types
storage/myisam/myisamchk.c:
Removed some old types
storage/myisam/myisamdef.h:
Removed some old types
storage/myisam/myisamlog.c:
Removed some old types
Indentation fix
storage/myisam/myisampack.c:
Removed some old types
storage/myisam/rt_index.c:
Removed some old types
storage/myisam/rt_split.c:
Removed some old types
storage/myisam/sort.c:
Removed some old types
storage/myisam/sp_defs.h:
Removed some old types
storage/myisam/sp_key.c:
Removed some old types
storage/myisammrg/ha_myisammrg.cc:
Removed some old types
storage/myisammrg/ha_myisammrg.h:
Removed some old types
storage/myisammrg/myrg_close.c:
Removed some old types
storage/myisammrg/myrg_def.h:
Removed some old types
storage/myisammrg/myrg_delete.c:
Removed some old types
storage/myisammrg/myrg_open.c:
Removed some old types
Updated parameters to dirname_part()
storage/myisammrg/myrg_queue.c:
Removed some old types
storage/myisammrg/myrg_rfirst.c:
Removed some old types
storage/myisammrg/myrg_rkey.c:
Removed some old types
storage/myisammrg/myrg_rlast.c:
Removed some old types
storage/myisammrg/myrg_rnext.c:
Removed some old types
storage/myisammrg/myrg_rnext_same.c:
Removed some old types
storage/myisammrg/myrg_rprev.c:
Removed some old types
storage/myisammrg/myrg_rrnd.c:
Removed some old types
storage/myisammrg/myrg_rsame.c:
Removed some old types
storage/myisammrg/myrg_update.c:
Removed some old types
storage/myisammrg/myrg_write.c:
Removed some old types
storage/ndb/include/util/ndb_opts.h:
Removed some old types
storage/ndb/src/cw/cpcd/main.cpp:
Removed some old types
storage/ndb/src/kernel/vm/Configuration.cpp:
Removed some old types
storage/ndb/src/mgmclient/main.cpp:
Removed some old types
storage/ndb/src/mgmsrv/InitConfigFileParser.cpp:
Removed some old types
Removed old disabled code
storage/ndb/src/mgmsrv/main.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbBlob.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
Removed not used variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
Added required casts
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Added required casts
storage/ndb/tools/delete_all.cpp:
Removed some old types
storage/ndb/tools/desc.cpp:
Removed some old types
storage/ndb/tools/drop_index.cpp:
Removed some old types
storage/ndb/tools/drop_tab.cpp:
Removed some old types
storage/ndb/tools/listTables.cpp:
Removed some old types
storage/ndb/tools/ndb_config.cpp:
Removed some old types
storage/ndb/tools/restore/consumer_restore.cpp:
Changed some buffers to be uchar* to avoid casts with new defintion of packfrm()
storage/ndb/tools/restore/restore_main.cpp:
Removed some old types
storage/ndb/tools/select_all.cpp:
Removed some old types
storage/ndb/tools/select_count.cpp:
Removed some old types
storage/ndb/tools/waiter.cpp:
Removed some old types
strings/bchange.c:
Changed function to use uchar * and size_t
strings/bcmp.c:
Changed function to use uchar * and size_t
strings/bmove512.c:
Changed function to use uchar * and size_t
strings/bmove_upp.c:
Changed function to use uchar * and size_t
strings/ctype-big5.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-bin.c:
Changed functions to use size_t
strings/ctype-cp932.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-czech.c:
Fixed indentation
Changed functions to use size_t
strings/ctype-euc_kr.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-eucjpms.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-gb2312.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-gbk.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-latin1.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-mb.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-simple.c:
Changed functions to use size_t
Simpler loops for caseup/casedown
unsigned int -> uint
unsigned char -> uchar
strings/ctype-sjis.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-tis620.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-uca.c:
Changed functions to use size_t
unsigned char -> uchar
strings/ctype-ucs2.c:
Moved inclusion of stdarg.h to other includes
usigned char -> uchar
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-ujis.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-utf8.c:
Changed functions to use size_t
unsigned char -> uchar
Indentation fixes
strings/ctype-win1250ch.c:
Indentation fixes
Changed functions to use size_t
strings/ctype.c:
Changed functions to use size_t
strings/decimal.c:
Changed type for memory argument to uchar *
strings/do_ctype.c:
Indentation fixes
strings/my_strtoll10.c:
unsigned char -> uchar
strings/my_vsnprintf.c:
Changed functions to use size_t
strings/r_strinstr.c:
Removed some old types
Changed functions to use size_t
strings/str_test.c:
Removed some old types
strings/strappend.c:
Changed functions to use size_t
strings/strcont.c:
Removed some old types
strings/strfill.c:
Removed some old types
strings/strinstr.c:
Changed functions to use size_t
strings/strlen.c:
Changed functions to use size_t
strings/strmake.c:
Changed functions to use size_t
strings/strnlen.c:
Changed functions to use size_t
strings/strnmov.c:
Changed functions to use size_t
strings/strto.c:
unsigned char -> uchar
strings/strtod.c:
Changed functions to use size_t
strings/strxnmov.c:
Changed functions to use size_t
strings/xml.c:
Changed functions to use size_t
Indentation fixes
tests/mysql_client_test.c:
Removed some old types
tests/thread_test.c:
Removed some old types
vio/test-ssl.c:
Removed some old types
vio/test-sslclient.c:
Removed some old types
vio/test-sslserver.c:
Removed some old types
vio/vio.c:
Removed some old types
vio/vio_priv.h:
Removed some old types
Changed vio_read()/vio_write() to work with size_t
vio/viosocket.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viossl.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viosslfactories.c:
Removed some old types
vio/viotest-ssl.c:
Removed some old types
win/README:
More explanations
2007-05-10 11:59:39 +02:00
|
|
|
const uchar *header, ulong header_length,
|
|
|
|
const uchar *arg, ulong arg_length, my_bool skip_check,
|
2008-03-14 21:40:12 +01:00
|
|
|
MYSQL_STMT *stmt)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
NET *net= &mysql->net;
|
|
|
|
my_bool result= 1;
|
2008-03-14 21:40:12 +01:00
|
|
|
my_bool stmt_skip= stmt ? stmt->state != MYSQL_STMT_INIT_DONE : FALSE;
|
A fix and a test case for Bug#15752 "Lost connection to MySQL server
when calling a SP from C API"
The bug was caused by lack of checks for misuse in mysql_real_query.
A stored procedure always returns at least one result, which is the
status of execution of the procedure itself.
This result, or so-called OK packet, is similar to a result
returned by INSERT/UPDATE/CREATE operations: it contains the overall
status of execution, the number of affected rows and the number of
warnings. The client test program attached to the bug did not read this
result and ivnoked the next query. In turn, libmysql had no check for
such scenario and mysql_real_query was simply trying to send that query
without reading the pending response, thus messing up the communication
protocol.
The fix is to return an error from mysql_real_query when it's called
prior to retrieval of all pending results.
client/mysqlbinlog.cc:
net_safe_read -> cli_safe_read
include/mysql.h:
Remove a private function from the public header.
include/mysql_com.h:
Remove a define that is never used.
include/sql_common.h:
Add a declaration for cli_safe_read - a function that reads one packet
from the server.
libmysql/libmysql.c:
net_safe_read -> cli_safe_read
Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
using a connection which has pending result sets.
sql-common/client.c:
Actual fix for Bug#15752: if the server has pending result sets for
the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
another query. Similarly to the behaviour of mysql_use_result(),
multiple result sets block the connection and must be fetched
before it can be used for another query.
This uncovered an error in the protocol: the server doesn't drop
SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
a multi-query like SELECT 1; SELECT syntax_error; SELECT 2;
the client has no way to know that the server won't ever come to
execution of the third query and won't return any result sets for it.
For now, fix it in cli_safe_read, as a proper fix requires extension
of the client-server protocol.
sql/protocol.cc:
Remove a name that is never used.
sql/slave.cc:
net_safe_read -> cli_safe_read
tests/mysql_client_test.c:
Make 'query' a local variable to avoid name clash.
Add a test case for Bug#15752 "Lost connection to MySQL server when
calling an SP from C API"
2006-07-24 12:56:53 +02:00
|
|
|
DBUG_ENTER("cli_advanced_command");
|
2003-05-02 18:07:41 +02:00
|
|
|
|
|
|
|
if (mysql->net.vio == 0)
|
|
|
|
{ /* Do reconnect if possible */
|
2008-03-14 21:40:12 +01:00
|
|
|
if (mysql_reconnect(mysql) || stmt_skip)
|
2005-05-16 12:34:23 +02:00
|
|
|
DBUG_RETURN(1);
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
A fix and a test case for Bug#15752 "Lost connection to MySQL server
when calling a SP from C API"
The bug was caused by lack of checks for misuse in mysql_real_query.
A stored procedure always returns at least one result, which is the
status of execution of the procedure itself.
This result, or so-called OK packet, is similar to a result
returned by INSERT/UPDATE/CREATE operations: it contains the overall
status of execution, the number of affected rows and the number of
warnings. The client test program attached to the bug did not read this
result and ivnoked the next query. In turn, libmysql had no check for
such scenario and mysql_real_query was simply trying to send that query
without reading the pending response, thus messing up the communication
protocol.
The fix is to return an error from mysql_real_query when it's called
prior to retrieval of all pending results.
client/mysqlbinlog.cc:
net_safe_read -> cli_safe_read
include/mysql.h:
Remove a private function from the public header.
include/mysql_com.h:
Remove a define that is never used.
include/sql_common.h:
Add a declaration for cli_safe_read - a function that reads one packet
from the server.
libmysql/libmysql.c:
net_safe_read -> cli_safe_read
Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
using a connection which has pending result sets.
sql-common/client.c:
Actual fix for Bug#15752: if the server has pending result sets for
the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
another query. Similarly to the behaviour of mysql_use_result(),
multiple result sets block the connection and must be fetched
before it can be used for another query.
This uncovered an error in the protocol: the server doesn't drop
SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
a multi-query like SELECT 1; SELECT syntax_error; SELECT 2;
the client has no way to know that the server won't ever come to
execution of the third query and won't return any result sets for it.
For now, fix it in cli_safe_read, as a proper fix requires extension
of the client-server protocol.
sql/protocol.cc:
Remove a name that is never used.
sql/slave.cc:
net_safe_read -> cli_safe_read
tests/mysql_client_test.c:
Make 'query' a local variable to avoid name clash.
Add a test case for Bug#15752 "Lost connection to MySQL server when
calling an SP from C API"
2006-07-24 12:56:53 +02:00
|
|
|
if (mysql->status != MYSQL_STATUS_READY ||
|
|
|
|
mysql->server_status & SERVER_MORE_RESULTS_EXISTS)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2004-11-03 11:39:38 +01:00
|
|
|
DBUG_PRINT("error",("state: %d", mysql->status));
|
2004-03-12 13:21:48 +01:00
|
|
|
set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
|
2005-05-16 12:34:23 +02:00
|
|
|
DBUG_RETURN(1);
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
|
2007-10-31 15:16:53 +01:00
|
|
|
net_clear_error(net);
|
2003-05-02 18:07:41 +02:00
|
|
|
mysql->info=0;
|
|
|
|
mysql->affected_rows= ~(my_ulonglong) 0;
|
2006-11-29 21:51:09 +01:00
|
|
|
/*
|
2007-01-30 12:52:26 +01:00
|
|
|
We don't want to clear the protocol buffer on COM_QUIT, because if
|
2006-11-29 21:51:09 +01:00
|
|
|
the previous command was a shutdown command, we may have the
|
|
|
|
response for the COM_QUIT already in the communication buffer
|
|
|
|
*/
|
2006-11-30 02:40:42 +01:00
|
|
|
net_clear(&mysql->net, (command != COM_QUIT));
|
2003-05-02 18:07:41 +02:00
|
|
|
|
|
|
|
if (net_write_command(net,(uchar) command, header, header_length,
|
|
|
|
arg, arg_length))
|
|
|
|
{
|
|
|
|
DBUG_PRINT("error",("Can't send command to server. Error: %d",
|
|
|
|
socket_errno));
|
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
|
|
|
if (net->last_errno == ER_NET_PACKET_TOO_LARGE)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2007-10-31 15:16:53 +01:00
|
|
|
set_mysql_error(mysql, CR_NET_PACKET_TOO_LARGE, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
goto end;
|
|
|
|
}
|
2020-07-23 09:24:13 +02:00
|
|
|
if (net->last_errno == ER_NET_ERROR_ON_WRITE && command == COM_BINLOG_DUMP)
|
|
|
|
goto end;
|
2003-05-02 18:07:41 +02:00
|
|
|
end_server(mysql);
|
2008-03-14 21:40:12 +01:00
|
|
|
if (mysql_reconnect(mysql) || stmt_skip)
|
2003-05-02 18:07:41 +02:00
|
|
|
goto end;
|
|
|
|
if (net_write_command(net,(uchar) command, header, header_length,
|
|
|
|
arg, arg_length))
|
|
|
|
{
|
2007-10-31 15:16:53 +01:00
|
|
|
set_mysql_error(mysql, CR_SERVER_GONE_ERROR, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result=0;
|
|
|
|
if (!skip_check)
|
A fix and a test case for Bug#15752 "Lost connection to MySQL server
when calling a SP from C API"
The bug was caused by lack of checks for misuse in mysql_real_query.
A stored procedure always returns at least one result, which is the
status of execution of the procedure itself.
This result, or so-called OK packet, is similar to a result
returned by INSERT/UPDATE/CREATE operations: it contains the overall
status of execution, the number of affected rows and the number of
warnings. The client test program attached to the bug did not read this
result and ivnoked the next query. In turn, libmysql had no check for
such scenario and mysql_real_query was simply trying to send that query
without reading the pending response, thus messing up the communication
protocol.
The fix is to return an error from mysql_real_query when it's called
prior to retrieval of all pending results.
client/mysqlbinlog.cc:
net_safe_read -> cli_safe_read
include/mysql.h:
Remove a private function from the public header.
include/mysql_com.h:
Remove a define that is never used.
include/sql_common.h:
Add a declaration for cli_safe_read - a function that reads one packet
from the server.
libmysql/libmysql.c:
net_safe_read -> cli_safe_read
Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
using a connection which has pending result sets.
sql-common/client.c:
Actual fix for Bug#15752: if the server has pending result sets for
the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
another query. Similarly to the behaviour of mysql_use_result(),
multiple result sets block the connection and must be fetched
before it can be used for another query.
This uncovered an error in the protocol: the server doesn't drop
SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
a multi-query like SELECT 1; SELECT syntax_error; SELECT 2;
the client has no way to know that the server won't ever come to
execution of the third query and won't return any result sets for it.
For now, fix it in cli_safe_read, as a proper fix requires extension
of the client-server protocol.
sql/protocol.cc:
Remove a name that is never used.
sql/slave.cc:
net_safe_read -> cli_safe_read
tests/mysql_client_test.c:
Make 'query' a local variable to avoid name clash.
Add a test case for Bug#15752 "Lost connection to MySQL server when
calling an SP from C API"
2006-07-24 12:56:53 +02:00
|
|
|
result= ((mysql->packet_length=cli_safe_read(mysql)) == packet_error ?
|
2003-05-02 18:07:41 +02:00
|
|
|
1 : 0);
|
2003-06-05 22:19:56 +02:00
|
|
|
end:
|
2005-05-16 12:34:23 +02:00
|
|
|
DBUG_PRINT("exit",("result: %d", result));
|
|
|
|
DBUG_RETURN(result);
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
|
2003-05-31 12:15:46 +02:00
|
|
|
void free_old_query(MYSQL *mysql)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
DBUG_ENTER("free_old_query");
|
|
|
|
if (mysql->fields)
|
|
|
|
free_root(&mysql->field_alloc,MYF(0));
|
MDEV-4011 Added per thread memory counting and usage
Base code and idea from a patch from by plinux at Taobao.
The idea is that we mark all memory that are thread specific with MY_THREAD_SPECIFIC.
Memory counting is done per thread in the my_malloc_size_cb_func callback function from my_malloc().
There are plenty of new asserts to ensure that for a debug server the counting is correct.
Information_schema.processlist gets two new columns: MEMORY_USED and EXAMINED_ROWS.
- The later is there mainly to show how query is progressing.
The following changes in interfaces was needed to get this to work:
- init_alloc_root() amd init_sql_alloc() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- One now have to use alloc_root_set_min_malloc() to set min memory to be allocated by alloc_root()
- my_init_dynamic_array() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- my_net_init() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- Added flag for hash_init() so that one can mark hash table to be thread specific.
- Added flags to init_tree() so that one can mark tree to be thread specific.
- Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
- Added flag to Warning_info::Warning_info() if the structure should be fully initialized.
- String elements can now be marked as thread specific.
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Changed type of myf from int to ulong, as this is always a set of bit flags.
Other things:
- Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
- We now also show EXAMINED_ROWS in SHOW PROCESSLIST
- Added new variable 'memory_used'
- Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
- Removed calls to the obsoleted function init_dynamic_array()
- Use set_current_thd() instead of my_pthread_setspecific_ptr(THR_THD,...)
client/completion_hash.cc:
Updated call to init_alloc_root()
client/mysql.cc:
Updated call to init_alloc_root()
client/mysqlbinlog.cc:
init_dynamic_array() -> my_init_dynamic_array()
Updated call to init_alloc_root()
client/mysqlcheck.c:
Updated call to my_init_dynamic_array()
client/mysqldump.c:
Updated call to init_alloc_root()
client/mysqltest.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Fixed compiler warnings
extra/comp_err.c:
Updated call to my_init_dynamic_array()
extra/resolve_stack_dump.c:
Updated call to my_init_dynamic_array()
include/hash.h:
Added HASH_THREAD_SPECIFIC
include/heap.h:
Added flag is internal temporary table.
include/my_dir.h:
Safety fix: Ensure that MY_DONT_SORT and MY_WANT_STAT don't interfer with other mysys flags
include/my_global.h:
Changed type of myf from int to ulong, as this is always a set of bit flags.
include/my_sys.h:
Added MY_THREAD_SPECIFIC and MY_THREAD_MOVE
Added malloc_flags to DYNAMIC_ARRAY
Added extra mysys flag argument to my_init_dynamic_array()
Removed deprecated functions init_dynamic_array() and my_init_dynamic_array.._ci
Updated paramaters for init_alloc_root()
include/my_tree.h:
Added my_flags to allow one to use MY_THREAD_SPECIFIC with hash tables.
Removed with_delete. One should now instead use MY_TREE_WITH_DELETE_FLAG
Updated parameters to init_tree()
include/myisamchk.h:
Added malloc_flags to allow one to use MY_THREAD_SPECIFIC for checks.
include/mysql.h:
Added MYSQL_THREAD_SPECIFIC_MALLOC
Used 'unused1' to mark memory as thread specific.
include/mysql.h.pp:
Updated file
include/mysql_com.h:
Used 'unused1' to mark memory as thread specific.
Updated parameters for my_net_init()
libmysql/libmysql.c:
Updated call to init_alloc_root() to mark memory thread specific.
libmysqld/emb_qcache.cc:
Updated call to init_alloc_root()
libmysqld/lib_sql.cc:
Updated call to init_alloc_root()
mysql-test/r/create.result:
Updated results
mysql-test/r/user_var.result:
Updated results
mysql-test/suite/funcs_1/datadict/processlist_priv.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/datadict/processlist_val.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/is_columns_is.result:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result:
Updated results
mysql-test/suite/funcs_1/r/processlist_val_no_prot.result:
Updated results
mysql-test/t/show_explain.test:
Fixed usage of debug variable so that one can run test with --debug
mysql-test/t/user_var.test:
Added test of memory_usage variable.
mysys/array.c:
Added extra my_flags option to init_dynamic_array() and init_dynamic_array2() so that one can mark memory with MY_THREAD_SPECIFIC
All allocated memory is marked with the given my_flags.
Removed obsolete function init_dynamic_array()
mysys/default.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
mysys/hash.c:
Updated call to my_init_dynamic_array_ci().
Allocated memory is marked with MY_THREAD_SPECIFIC if HASH_THREAD_SPECIFIC is used.
mysys/ma_dyncol.c:
init_dynamic_array() -> my_init_dynamic_array()
Added #if to get rid of compiler warnings
mysys/mf_tempdir.c:
Updated call to my_init_dynamic_array()
mysys/my_alloc.c:
Added extra parameter to init_alloc_root() so that one can mark memory with MY_THREAD_SPECIFIC
Extend MEM_ROOT with a flag if memory is thread specific.
This is stored in block_size, to keep the size of the MEM_ROOT object identical as before.
Allocated memory is marked with MY_THREAD_SPECIFIC if used with init_alloc_root()
mysys/my_chmod.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_chsize.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_copy.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_create.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_delete.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_error.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fopen.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fstream.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_getwd.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_lib.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Updated DBUG_PRINT because of change of myf type
mysys/my_lock.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_malloc.c:
Store at start of each allocated memory block the size of the block and if the block is thread specific.
Call malloc_size_cb_func, if set, with the memory allocated/freed.
Updated DBUG_PRINT because of change of myf type
mysys/my_open.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_pread.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_read.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_redel.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_rename.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_seek.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_sync.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_thr_init.c:
Ensure that one can call my_thread_dbug_id() even if thread is not properly initialized.
mysys/my_write.c:
Updated DBUG_PRINT because of change of myf type
mysys/mysys_priv.h:
Updated parameters to sf_malloc and sf_realloc()
mysys/safemalloc.c:
Added checking that for memory marked with MY_THREAD_SPECIFIC that it's the same thread that is allocation and freeing the memory.
Added sf_malloc_dbug_id() to allow MariaDB to specify which THD is handling the memory.
Added my_flags arguments to sf_malloc() and sf_realloc() to be able to mark memory with MY_THREAD_SPECIFIC.
Added sf_report_leaked_memory() to get list of memory not freed by a thread.
mysys/tree.c:
Added flags to init_tree() so that one can mark tree to be thread specific.
Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
Updated call to init_alloc_root()
All allocated memory is marked with the given malloc flags
mysys/waiting_threads.c:
Updated call to my_init_dynamic_array()
sql-common/client.c:
Updated call to init_alloc_root() and my_net_init() to mark memory thread specific.
Updated call to my_init_dynamic_array().
Added MYSQL_THREAD_SPECIFIC_MALLOC so that client can mark memory as MY_THREAD_SPECIFIC.
sql-common/client_plugin.c:
Updated call to init_alloc_root()
sql/debug_sync.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/event_scheduler.cc:
Removed calls to net_end() as this is now done in ~THD()
Call set_current_thd() to ensure that memory is assigned to right thread.
sql/events.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/filesort.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/filesort_utils.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/ha_ndbcluster.cc:
Updated call to init_alloc_root()
Updated call to my_net_init()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_ndbcluster_binlog.cc:
Updated call to my_net_init()
Updated call to init_sql_alloc()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_partition.cc:
Updated call to init_alloc_root()
sql/handler.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
Added missing call to my_dir_end()
sql/item_func.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_subselect.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_sum.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/log.cc:
More DBUG
Updated call to init_alloc_root()
sql/mdl.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/mysqld.cc:
Added total_memory_used
Updated call to init_alloc_root()
Move mysql_cond_broadcast() before my_thread_end()
Added mariadb_dbug_id() to count memory per THD instead of per thread.
Added my_malloc_size_cb_func() callback function for my_malloc() to count memory.
Move initialization of mysqld_server_started and mysqld_server_initialized earlier.
Updated call to my_init_dynamic_array().
Updated call to my_net_init().
Call my_pthread_setspecific_ptr(THR_THD,...) to ensure that memory is assigned to right thread.
Added status variable 'memory_used'.
Updated call to init_alloc_root()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/mysqld.h:
Added set_current_thd()
sql/net_serv.cc:
Added new parameter to my_net_init() so that one can mark memory with MY_THREAD_SPECIFIC.
Store in net->thread_specific_malloc if memory is thread specific.
Mark memory to be thread specific if requested.
sql/opt_range.cc:
Updated call to my_init_dynamic_array()
Updated call to init_sql_alloc()
Added MY_THREAD_SPECIFIC to allocated memory.
sql/opt_subselect.cc:
Updated call to init_sql_alloc() to mark memory thread specific.
sql/protocol.cc:
Fixed compiler warning
sql/records.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/rpl_filter.cc:
Updated call to my_init_dynamic_array()
sql/rpl_handler.cc:
Updated call to my_init_dynamic_array2()
sql/rpl_handler.h:
Updated call to init_sql_alloc()
sql/rpl_mi.cc:
Updated call to my_init_dynamic_array()
sql/rpl_tblmap.cc:
Updated call to init_alloc_root()
sql/rpl_utility.cc:
Updated call to my_init_dynamic_array()
sql/slave.cc:
Initialize things properly before calling functions that allocate memory.
Removed calls to net_end() as this is now done in ~THD()
sql/sp_head.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
Added parameter to warning_info() that it should be fully initialized.
sql/sp_pcontext.cc:
Updated call to my_init_dynamic_array()
sql/sql_acl.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_admin.cc:
Added parameter to warning_info() that it should be fully initialized.
sql/sql_analyse.h:
Updated call to init_tree() to mark memory thread specific.
sql/sql_array.h:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_audit.cc:
Updated call to my_init_dynamic_array()
sql/sql_base.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_cache.cc:
Updated comment
sql/sql_class.cc:
Added parameter to warning_info() that not initialize it until THD is fully created.
Updated call to init_sql_alloc()
Mark THD::user_vars has to be thread specific.
Updated call to my_init_dynamic_array()
Ensure that memory allocated by THD is assigned to the THD.
More DBUG
Always acll net_end() in ~THD()
Assert that all memory signed to this THD is really deleted at ~THD.
Fixed set_status_var_init() to not reset memory_used.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_class.h:
Added MY_THREAD_SPECIFIC to allocated memory.
Added malloc_size to THD to record allocated memory per THD.
sql/sql_delete.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_error.cc:
Added 'initialize' parameter to Warning_info() to say if should allocate memory for it's structures.
This is used by THD::THD() to not allocate memory until THD is ready.
Added Warning_info::free_memory()
sql/sql_error.h:
Updated Warning_info() class.
sql/sql_handler.cc:
Updated call to init_alloc_root() to mark memory thread specific.
sql/sql_insert.cc:
More DBUG
sql/sql_join_cache.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_lex.cc:
Updated call to my_init_dynamic_array()
sql/sql_lex.h:
Updated call to my_init_dynamic_array()
sql/sql_load.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_parse.cc:
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
Ensure that examined_row_count() is reset before query.
Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Don't restore thd->status_var.memory_used when restoring thd->status_var
sql/sql_plugin.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Don't allocate THD on the stack, as this causes problems with valgrind when doing thd memory counting.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_prepare.cc:
Added parameter to warning_info() that it should be fully initialized.
Updated call to init_sql_alloc() to mark memory thread specific.
sql/sql_reload.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_select.cc:
Updated call to my_init_dynamic_array() and init_sql_alloc() to mark memory thread specific.
Added MY_THREAD_SPECIFIC to allocated memory.
More DBUG
sql/sql_servers.cc:
Updated call to init_sql_alloc() to mark memory some memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_show.cc:
Updated call to my_init_dynamic_array()
Mark my_dir() memory thread specific.
Use my_pthread_setspecific_ptr(THR_THD,...) to mark that allocated memory should be allocated to calling thread.
More DBUG.
Added malloc_size and examined_row_count to SHOW PROCESSLIST.
Added MY_THREAD_SPECIFIC to allocated memory.
Updated call to init_sql_alloc()
Added parameter to warning_info() that it should be fully initialized.
sql/sql_statistics.cc:
Fixed compiler warning
sql/sql_string.cc:
String elements can now be marked as thread specific.
sql/sql_string.h:
String elements can now be marked as thread specific.
sql/sql_table.cc:
Updated call to init_sql_alloc() and my_malloc() to mark memory thread specific
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Fixed compiler warning
sql/sql_test.cc:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_trigger.cc:
Updated call to init_sql_alloc()
sql/sql_udf.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_update.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/table.cc:
Updated call to init_sql_alloc().
Mark memory used by temporary tables, that are not for slave threads, as MY_THREAD_SPECIFIC
Updated call to init_sql_alloc()
sql/thr_malloc.cc:
Added my_flags argument to init_sql_alloc() to be able to mark memory as MY_THREAD_SPECIFIC.
sql/thr_malloc.h:
Updated prototype for init_sql_alloc()
sql/tztime.cc:
Updated call to init_sql_alloc()
Updated call to init_alloc_root() to mark memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/uniques.cc:
Updated calls to init_tree(), my_init_dynamic_array() and my_malloc() to mark memory thread specific.
sql/unireg.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/csv/ha_tina.cc:
Updated call to init_alloc_root()
storage/federated/ha_federated.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Ensure that memory allocated by fedarated is registered for the system, not for the thread.
storage/federatedx/federatedx_io_mysql.cc:
Updated call to my_init_dynamic_array()
storage/federatedx/ha_federatedx.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
storage/heap/ha_heap.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/heap/heapdef.h:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_block.c:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_create.c:
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Use MY_TREE_WITH_DELETE instead of removed option 'with_delete'.
storage/heap/hp_open.c:
Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
storage/heap/hp_write.c:
Added new parameter to hp_get_new_block()
storage/maria/ma_bitmap.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_blockrec.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_check.c:
Updated call to init_alloc_root()
storage/maria/ma_ft_boolean_search.c:
Updated calls to init_tree() and init_alloc_root()
storage/maria/ma_ft_nlq_search.c:
Updated call to init_tree()
storage/maria/ma_ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/maria/ma_loghandler.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_open.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_sort.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_write.c:
Updated calls to my_init_dynamic_array() and init_tree()
storage/maria/maria_pack.c:
Updated call to init_tree()
storage/maria/unittest/sequence_storage.c:
Updated call to my_init_dynamic_array()
storage/myisam/ft_boolean_search.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_nlq_search.c:
Updated call to init_tree()
storage/myisam/ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_stopwords.c:
Updated call to init_tree()
storage/myisam/mi_check.c:
Updated call to init_alloc_root()
storage/myisam/mi_write.c:
Updated call to my_init_dynamic_array()
Updated call to init_tree()
storage/myisam/myisamlog.c:
Updated call to init_tree()
storage/myisam/myisampack.c:
Updated call to init_tree()
storage/myisam/sort.c:
Updated call to my_init_dynamic_array()
storage/myisammrg/ha_myisammrg.cc:
Updated call to init_sql_alloc()
storage/perfschema/pfs_check.cc:
Rest current_thd
storage/perfschema/pfs_instr.cc:
Removed DBUG_ENTER/DBUG_VOID_RETURN as at this point my_thread_var is not allocated anymore, which can cause problems.
support-files/compiler_warnings.supp:
Disable compiler warning from offsetof macro.
2013-01-23 16:16:14 +01:00
|
|
|
/* Assume rowlength < 8192 */
|
2018-02-02 10:08:36 +01:00
|
|
|
init_alloc_root(&mysql->field_alloc, "fields", 8192, 0,
|
2013-04-17 22:37:06 +02:00
|
|
|
MYF(mysql->options.use_thread_specific_memory ?
|
|
|
|
MY_THREAD_SPECIFIC : 0));
|
2005-08-11 03:32:17 +02:00
|
|
|
mysql->fields= 0;
|
|
|
|
mysql->field_count= 0; /* For API */
|
2005-12-07 00:50:03 +01:00
|
|
|
mysql->warning_count= 0;
|
2005-08-11 03:32:17 +02:00
|
|
|
mysql->info= 0;
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Finish reading of a partial result set from the server.
|
|
|
|
Get the EOF packet, and update mysql->status
|
|
|
|
and mysql->warning_count.
|
|
|
|
|
|
|
|
@return TRUE if a communication or protocol error, an error
|
|
|
|
is set in this case, FALSE otherwise.
|
|
|
|
*/
|
|
|
|
|
|
|
|
my_bool flush_one_result(MYSQL *mysql)
|
|
|
|
{
|
|
|
|
ulong packet_length;
|
|
|
|
|
|
|
|
DBUG_ASSERT(mysql->status != MYSQL_STATUS_READY);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
packet_length= cli_safe_read(mysql);
|
|
|
|
/*
|
|
|
|
There is an error reading from the connection,
|
|
|
|
or (sic!) there were no error and no
|
|
|
|
data in the stream, i.e. no more data from the server.
|
|
|
|
Since we know our position in the stream (somewhere in
|
|
|
|
the middle of a result set), this latter case is an error too
|
|
|
|
-- each result set must end with a EOF packet.
|
|
|
|
cli_safe_read() has set an error for us, just return.
|
|
|
|
*/
|
|
|
|
if (packet_length == packet_error)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
while (packet_length > 8 || mysql->net.read_pos[0] != 254);
|
|
|
|
|
|
|
|
/* Analyze EOF packet of the result set. */
|
|
|
|
|
|
|
|
if (protocol_41(mysql))
|
|
|
|
{
|
|
|
|
char *pos= (char*) mysql->net.read_pos + 1;
|
|
|
|
mysql->warning_count=uint2korr(pos);
|
|
|
|
pos+=2;
|
|
|
|
mysql->server_status=uint2korr(pos);
|
|
|
|
pos+=2;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Read a packet from network. If it's an OK packet, flush it.
|
|
|
|
|
|
|
|
@return TRUE if error, FALSE otherwise. In case of
|
|
|
|
success, is_ok_packet is set to TRUE or FALSE,
|
|
|
|
based on what we got from network.
|
|
|
|
*/
|
|
|
|
|
|
|
|
my_bool opt_flush_ok_packet(MYSQL *mysql, my_bool *is_ok_packet)
|
|
|
|
{
|
|
|
|
ulong packet_length= cli_safe_read(mysql);
|
|
|
|
|
|
|
|
if (packet_length == packet_error)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* cli_safe_read always reads a non-empty packet. */
|
|
|
|
DBUG_ASSERT(packet_length);
|
|
|
|
|
|
|
|
*is_ok_packet= mysql->net.read_pos[0] == 0;
|
|
|
|
if (*is_ok_packet)
|
|
|
|
{
|
|
|
|
uchar *pos= mysql->net.read_pos + 1;
|
|
|
|
|
|
|
|
net_field_length_ll(&pos); /* affected rows */
|
|
|
|
net_field_length_ll(&pos); /* insert id */
|
|
|
|
|
|
|
|
mysql->server_status=uint2korr(pos);
|
|
|
|
pos+=2;
|
|
|
|
|
|
|
|
if (protocol_41(mysql))
|
|
|
|
{
|
|
|
|
mysql->warning_count=uint2korr(pos);
|
|
|
|
pos+=2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
/*
|
|
|
|
Flush result set sent from server
|
|
|
|
*/
|
|
|
|
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
static void cli_flush_use_result(MYSQL *mysql, my_bool flush_all_results)
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
{
|
|
|
|
/* Clear the current execution status */
|
2004-10-26 18:30:01 +02:00
|
|
|
DBUG_ENTER("cli_flush_use_result");
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
DBUG_PRINT("warning",("Not all packets read, clearing them"));
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
|
|
|
|
if (flush_one_result(mysql))
|
|
|
|
DBUG_VOID_RETURN; /* An error occurred */
|
|
|
|
|
|
|
|
if (! flush_all_results)
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
|
|
|
|
while (mysql->server_status & SERVER_MORE_RESULTS_EXISTS)
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
{
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
my_bool is_ok_packet;
|
|
|
|
if (opt_flush_ok_packet(mysql, &is_ok_packet))
|
|
|
|
DBUG_VOID_RETURN; /* An error occurred. */
|
|
|
|
if (is_ok_packet)
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
{
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
/*
|
|
|
|
Indeed what we got from network was an OK packet, and we
|
|
|
|
know that OK is the last one in a multi-result-set, so
|
|
|
|
just return.
|
|
|
|
*/
|
|
|
|
DBUG_VOID_RETURN;
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
}
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
/*
|
|
|
|
It's a result set, not an OK packet. A result set contains
|
|
|
|
of two result set subsequences: field metadata, terminated
|
|
|
|
with EOF packet, and result set data, again terminated with
|
|
|
|
EOF packet. Read and flush them.
|
|
|
|
*/
|
|
|
|
if (flush_one_result(mysql) || flush_one_result(mysql))
|
|
|
|
DBUG_VOID_RETURN; /* An error occurred. */
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
}
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
|
2004-10-26 18:30:01 +02:00
|
|
|
DBUG_VOID_RETURN;
|
2004-03-12 13:21:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-01 14:08:30 +02:00
|
|
|
/*
|
|
|
|
Report progress to the client
|
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
0 ok
|
|
|
|
1 error
|
|
|
|
*/
|
|
|
|
|
2012-10-01 13:15:29 +02:00
|
|
|
static int cli_report_progress(MYSQL *mysql, char *pkt, uint length)
|
2011-07-01 14:08:30 +02:00
|
|
|
{
|
|
|
|
uint stage, max_stage, proc_length;
|
|
|
|
double progress;
|
2012-10-01 13:15:29 +02:00
|
|
|
uchar *packet= (uchar*)pkt;
|
2011-07-01 14:08:30 +02:00
|
|
|
uchar *start= packet;
|
|
|
|
|
|
|
|
if (length < 5)
|
|
|
|
return 1; /* Wrong packet */
|
|
|
|
|
|
|
|
if (!(mysql->options.extension && mysql->options.extension->report_progress))
|
|
|
|
return 0; /* No callback, ignore packet */
|
|
|
|
|
|
|
|
packet++; /* Ignore number of strings */
|
|
|
|
stage= (uint) *packet++;
|
|
|
|
max_stage= (uint) *packet++;
|
|
|
|
progress= uint3korr(packet)/1000.0;
|
|
|
|
packet+= 3;
|
|
|
|
proc_length= net_field_length(&packet);
|
|
|
|
if (packet + proc_length > start + length)
|
|
|
|
return 1; /* Wrong packet */
|
|
|
|
(*mysql->options.extension->report_progress)(mysql, stage, max_stage,
|
|
|
|
progress, (char*) packet,
|
|
|
|
proc_length);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
Shut down connection
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
void end_server(MYSQL *mysql)
|
|
|
|
{
|
2006-11-23 15:41:21 +01:00
|
|
|
int save_errno= errno;
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_ENTER("end_server");
|
|
|
|
if (mysql->net.vio != 0)
|
|
|
|
{
|
|
|
|
DBUG_PRINT("info",("Net: %s", vio_description(mysql->net.vio)));
|
Bug#46013: rpl_extraColmaster_myisam fails on pb2
Bug#45243: crash on win in sql thread clear_tables_to_lock() -> free()
Bug#45242: crash on win in mysql_close() -> free()
Bug#45238: rpl_slave_skip, rpl_change_master failed (lost connection) for STOP SLAVE
Bug#46030: rpl_truncate_3innodb causes server crash on windows
Bug#46014: rpl_stm_reset_slave crashes the server sporadically in pb2
When killing a user session on the server, it's necessary to
interrupt (notify) the thread associated with the session that
the connection is being killed so that the thread is woken up
if waiting for I/O. On a few platforms (Mac, Windows and HP-UX)
where the SIGNAL_WITH_VIO_CLOSE flag is defined, this interruption
procedure is to asynchronously close the underlying socket of
the connection.
In order to enable this schema, each connection serving thread
registers its VIO (I/O interface) so that other threads can
access it and close the connection. But only the owner thread of
the VIO might delete it as to guarantee that other threads won't
see freed memory (the thread unregisters the VIO before deleting
it). A side note: closing the socket introduces a harmless race
that might cause a thread attempt to read from a closed socket,
but this is deemed acceptable.
The problem is that this infrastructure was meant to only be used
by server threads, but the slave I/O thread was registering the
VIO of a mysql handle (a client API structure that represents a
connection to another server instance) as a active connection of
the thread. But under some circumstances such as network failures,
the client API might destroy the VIO associated with a handle at
will, yet the VIO wouldn't be properly unregistered. This could
lead to accesses to freed data if a thread attempted to kill a
slave I/O thread whose connection was already broken.
There was a attempt to work around this by checking whether
the socket was being interrupted, but this hack didn't work as
intended due to the aforementioned race -- attempting to read
from the socket would yield a "bad file descriptor" error.
The solution is to add a hook to the client API that is called
from the client code before the VIO of a handle is deleted.
This hook allows the slave I/O thread to detach the active vio
so it does not point to freed memory.
server-tools/instance-manager/mysql_connection.cc:
Add stub method required for linking.
sql-common/client.c:
Invoke hook.
sql/client_settings.h:
Export hook.
sql/slave.cc:
Introduce hook that clears the active VIO before it is freed
by the client API.
2009-08-13 22:07:20 +02:00
|
|
|
#ifdef MYSQL_SERVER
|
|
|
|
slave_io_thread_detach_vio();
|
|
|
|
#endif
|
2003-05-02 18:07:41 +02:00
|
|
|
vio_delete(mysql->net.vio);
|
|
|
|
mysql->net.vio= 0; /* Marker */
|
2009-05-20 16:17:47 +02:00
|
|
|
mysql_prune_stmt_list(mysql);
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
net_end(&mysql->net);
|
|
|
|
free_old_query(mysql);
|
2006-11-23 15:41:21 +01:00
|
|
|
errno= save_errno;
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
void STDCALL
|
|
|
|
mysql_free_result(MYSQL_RES *result)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("mysql_free_result");
|
2017-09-19 19:45:17 +02:00
|
|
|
DBUG_PRINT("enter",("mysql_res: %p", result));
|
2003-05-02 18:07:41 +02:00
|
|
|
if (result)
|
|
|
|
{
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
MYSQL *mysql= result->handle;
|
|
|
|
if (mysql)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
if (mysql->unbuffered_fetch_owner == &result->unbuffered_fetch_cancelled)
|
|
|
|
mysql->unbuffered_fetch_owner= 0;
|
|
|
|
if (mysql->status == MYSQL_STATUS_USE_RESULT)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
Backport of revno 2630.28.10, 2630.28.31, 2630.28.26, 2630.33.1,
2630.39.1, 2630.28.29, 2630.34.3, 2630.34.2, 2630.34.1, 2630.29.29,
2630.29.28, 2630.31.1, 2630.28.13, 2630.28.10, 2617.23.14 and
some other minor revisions.
This patch implements:
WL#4264 "Backup: Stabilize Service Interface" -- all the
server prerequisites except si_objects.{h,cc} themselves (they can
be just copied over, when needed).
WL#4435: Support OUT-parameters in prepared statements.
(and all issues in the initial patches for these two
tasks, that were discovered in pushbuild and during testing).
Bug#39519: mysql_stmt_close() should flush all data
associated with the statement.
After execution of a prepared statement, send OUT parameters of the invoked
stored procedure, if any, to the client.
When using the binary protocol, send the parameters in an additional result
set over the wire. When using the text protocol, assign out parameters to
the user variables from the CALL(@var1, @var2, ...) specification.
The following refactoring has been made:
- Protocol::send_fields() was renamed to Protocol::send_result_set_metadata();
- A new Protocol::send_result_set_row() was introduced to incapsulate
common functionality for sending row data.
- Signature of Protocol::prepare_for_send() was changed: this operation
does not need a list of items, the number of items is fully sufficient.
The following backward incompatible changes have been made:
- CLIENT_MULTI_RESULTS is now enabled by default in the client;
- CLIENT_PS_MULTI_RESUTLS is now enabled by default in the client.
include/mysql.h:
Add a new flag to MYSQL_METHODS::flush_use_result
function pointer. This flag determines if all results
should be flushed or only the first one:
- if flush_all_results is TRUE, then cli_flush_use_result()
will read/flush all pending results. I.e. it will read
all packets while server status attribute indicates that
there are more results. This is a new semantic, required
to fix the bug.
- if flush_all_results is FALSE, the old sematic
is preserved -- i.e. cli_flush_use_result() reads data
until first EOF-packet.
include/mysql.h.pp:
Update the ABI with new calls (compatible changes).
include/mysql_com.h:
Add CLIENT_PS_OUT_PARAMS -- a client capability indicating that the client supportsю
libmysql/libmysql.c:
Add mysql_stmt_next_result() -- analogue of mysql_next_result() for binary protocol.
Fix a minor bug in alloc_fields() -- not all members were copied over,
and some only shallow-copied (catalog).
Flush all results in mysql_stmt_close() (Bug#39519).
libmysqld/lib_sql.cc:
Rename send_fields() -> send_result_set_metadata().
Refactoring: change prepare_for_send() so that it accepts only
what it really needs -- a number of elements in the list.
mysql-test/r/ps.result:
Update results: WL#4435.
mysql-test/t/ps.test:
WL#4435: A test case for an SQL-part of the problem.
sql-common/client.c:
Bug#39519.
Implement new functionality in cli_flush_use_result():
if flush_all_delete is TRUE, then it should read/flush
all pending results.
sql/Makefile.am:
Add a new header sql_prepare.h to the list
of build headers.
sql/events.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/mysql_priv.h:
Move sql_prepare.cc-specific declarations to a new
header - sql_prepare.h.
sql/procedure.h:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/protocol.cc:
Move the logic responsible for sending of one result
set row to the Protocol class. Define a template
for end-of-statement action.
Refactoring: change prepare_for_send() so that it accepts
only what it really needs -- a number of elements in the list.
Rename send_fields() to send_result_set_metadata().
sql/protocol.h:
Update with new declarations (WL#4435).
Rename send_fields() -> send_result_set_metadata().
prepare_for_send() only needs the number of columns to send,
and doesn't use the item list - update signature to require
only what's needed.
Add a new protocol type -- Protocol_local.
sql/repl_failsafe.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/slave.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_acl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_base.cc:
Include sql_prepare.h (for Reprepare_observer).
sql/sql_cache.cc:
Extend the query cache flags block to be able
to store a numeric id for the result format,
not just a flag binary/non-binary.
sql/sql_class.cc:
Update to use the rename of Protocol::send_fields()
to Protocol::send_result_set_metadata().
Use Protocol::send_one_result_set_row().
sql/sql_class.h:
Move the declaration of Reprepare_observer to the
new header - sql_prepare.h.
Update to the new signature of class Protocol::send_fields().
sql/sql_connect.cc:
Use a protocol template method instead of
raw NET layer API at the end of a statement.
sql/sql_cursor.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_error.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_handler.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
Use new method Protocol::send_one_result_set_row().
sql/sql_help.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_lex.cc:
Initialize multi_statements variable.
Add a handy constant for empty lex
string.
sql/sql_lex.h:
Add a separate member for a standalone
parsing option - multi-statements support.
sql/sql_list.cc:
sql_list.h is a standalone header now,
no need to include mysql_priv.h.
sql/sql_list.h:
Make sql_list.h a stand-alone header.
sql/sql_parse.cc:
Include sql_prepare.h for prepared
statements- related declarations.
Use a new Protocol template method to end
each statement (send OK, EOF or ERROR to
the client).
sql/sql_prepare.cc:
Implement Execute Direct API (WL#4264),
currently unused. It will be used by the service
interface (Backup).
Use a new header - sql_prepare.h.
Add support for OUT parameters in the
binary and text protocol (prepared statements
only).
sql/sql_prepare.h:
Add a new header to contain (for now)
all prepared statement- external
related declarations.
sql/sql_profile.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_repl.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_select.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_show.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_string.h:
Add a way to convert a String to LEX_STRING.
sql/sql_table.cc:
Rename: Protocol::send_fields() ->
Protocol::send_result_set_metadata().
sql/sql_update.cc:
Remove an extraneous my_error(). The error
is already reported in update_non_unique_table_error().
sql/sql_yacc.yy:
Support for multi-statements is an independent
property of parsing, not derived from
the protocol type.
tests/mysql_client_test.c:
Add tests for WL#4435 (binary protocol).
2009-10-21 22:02:06 +02:00
|
|
|
(*mysql->methods->flush_use_result)(mysql, FALSE);
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
mysql->status=MYSQL_STATUS_READY;
|
2005-05-12 09:16:12 +02:00
|
|
|
if (mysql->unbuffered_fetch_owner)
|
|
|
|
*mysql->unbuffered_fetch_owner= TRUE;
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
free_rows(result->data);
|
|
|
|
if (result->fields)
|
|
|
|
free_root(&result->field_alloc,MYF(0));
|
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(result->row);
|
|
|
|
my_free(result);
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
Get options from my.cnf
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static const char *default_options[]=
|
|
|
|
{
|
|
|
|
"port","socket","compress","password","pipe", "timeout", "user",
|
|
|
|
"init-command", "host", "database", "debug", "return-found-rows",
|
|
|
|
"ssl-key" ,"ssl-cert" ,"ssl-ca" ,"ssl-capath",
|
|
|
|
"character-sets-dir", "default-character-set", "interactive-timeout",
|
|
|
|
"connect-timeout", "local-infile", "disable-local-infile",
|
2018-08-20 14:06:33 +02:00
|
|
|
"ssl-cipher", "max-allowed-packet", "protocol",
|
2005-01-04 17:32:42 +01:00
|
|
|
"multi-results", "multi-statements", "multi-queries", "secure-auth",
|
2010-03-29 17:13:53 +02:00
|
|
|
"report-data-truncation", "plugin-dir", "default-auth",
|
2012-08-14 16:23:34 +02:00
|
|
|
"bind-address", "ssl-crl", "ssl-crlpath",
|
2013-06-11 11:11:05 +02:00
|
|
|
"enable-cleartext-plugin",
|
2003-05-02 18:07:41 +02:00
|
|
|
NullS
|
|
|
|
};
|
2010-03-29 17:13:53 +02:00
|
|
|
enum option_id {
|
|
|
|
OPT_port=1, OPT_socket, OPT_compress, OPT_password, OPT_pipe, OPT_timeout, OPT_user,
|
|
|
|
OPT_init_command, OPT_host, OPT_database, OPT_debug, OPT_return_found_rows,
|
|
|
|
OPT_ssl_key, OPT_ssl_cert, OPT_ssl_ca, OPT_ssl_capath,
|
|
|
|
OPT_character_sets_dir, OPT_default_character_set, OPT_interactive_timeout,
|
|
|
|
OPT_connect_timeout, OPT_local_infile, OPT_disable_local_infile,
|
2018-08-20 14:06:33 +02:00
|
|
|
OPT_ssl_cipher, OPT_max_allowed_packet, OPT_protocol,
|
2010-03-29 17:13:53 +02:00
|
|
|
OPT_multi_results, OPT_multi_statements, OPT_multi_queries, OPT_secure_auth,
|
|
|
|
OPT_report_data_truncation, OPT_plugin_dir, OPT_default_auth,
|
2012-08-14 16:23:34 +02:00
|
|
|
OPT_bind_address, OPT_ssl_crl, OPT_ssl_crlpath,
|
2013-06-11 11:11:05 +02:00
|
|
|
OPT_enable_cleartext_plugin,
|
Fix for BUG#59894
"set optimizer_switch to e or d causes invalid memory writes/valgrind warnings":
due to prefix support, the argument "e" was overwritten with its full value
"engine_condition_pushdown", which caused a buffer overrun.
This was wrong usage of find_type(); other wrong usages are fixed here too.
Please start reading with the comment of typelib.c.
client/mysqldump.c:
A bug: find_type() expects a bitmap as 3rd argument
(each bit is a flag controlling a behaviour of the function);
here it was instead passed the length of the string to search!
That could give random behaviour of find_type()
depending on the string.
We rather need to pass a correct flag to find_type().
The correct flag is FIND_TYPE_BASIC (0).
Flag 8 is not needed as buff cannot have a comma (see how buff is filled).
Flag 1 looks like a superfluous restriction.
Flag 4 is not user-friendly (why use
--compatible=2 rather than --compatible=mysql40 ?, and
we probably not commit to "2" always meaning "mysql40"
until the end of times).
include/mysql.h.pp:
This isn't a problematic API change as we go from char* to const char*:
existing code will run unchanged.
include/typelib.h:
named constants. Not an enum to not significantly change
the declaration of find_type() which would be an API change
(typelib.h is included in mysql.h).
mysql-test/r/mysqldump.result:
correct result (see the two requested modes in SQL_MODE)
mysql-test/suite/sys_vars/t/optimizer_switch_basic.test:
test for BUG#59894. The second SET used to crash.
mysql-test/t/mysqldump.test:
we had no test for multiple modes in --compatible, which is
supported according to --help
mysys/typelib.c:
Fix for BUG#59894. parse_name() is asked to match "e" with a row
of the TYPELIB (the TYPELIB lists permitted flags of optimizer_switch;
and comes from optimizer_switch_names[] of sys_vars.cc).
find_type() is capable of supporting prefixes, but if it is not
passed flag 2 in third argument, it will overwrite its first
argument (the string to search for) with the complete name,
here overwriting "e" with "engine_condition_pushdown". But
as this "e" was a buffer allocated in an Item, it was not big
enough to host the longer name, thus the crash.
We don't need to know the complete flag's name; the output used
from find_type() is just the flag's number (== function's return
code). So we can pass flag 2 to find_type() in parse_name().
After doing this fix and the other fixes in this patch, all usages
of find_type() were using flag 2; in most usages the string to search for,
is not guaranteed to be long enough to host the complete name
(it is either directly from argv, or from alloc_root/my_malloc
done in an earlier call).
Thus, flag 2 is here made implicit: callers need not pass it anymore,
it is always automatically turned on.
This allows to eliminate an oddity: parse_name() took a const char**,
and then removed "const" before calling find_type(), which could
theoretically modify the pointed data, thus lying on constness.
Last, constants for find_type() are now named.
sql-common/client.c:
Two bugs:
1) The enum was not in sync with the array (due to a bad porting of WL 1054;
the extra OPT_ values are about options present in 5.1 and deleted in 5.5);
added a compile_time_assert() to make sure this doesn't happen again
2) find_type() was writing past the end of opt_arg; as opt_arg was allocated
with alloc_root() with no extra space, this was an overrun; it could be seen
when
** building with -DWITH_VALGRIND -DHAVE_purify -DEXTRA_DEBUG
** making execution go through the faulty code; this faulty
code is executed only if the client asks to read a configuration
file like this:
mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "/tmp/cnf.cnf");
so by adding such line to the start of mysql_client_test.c::client_connect(),
we could see the valgrind warning:
==30548== Invalid write of size 1
==30548== at 0x4C2624C: strcpy (mc_replace_strmem.c:303)
==30548== by 0x48DC29: find_type (typelib.c:120)
==30548== by 0x465686: mysql_read_default_options (client.c:1344)
==30548== by 0x46830F: mysql_real_connect (client.c:2971)
==30548== by 0x409339: client_connect (mysql_client_test.c:331)
==30548== by 0x463A7F: main (mysql_client_test.c:19902)
==30548== Address 0x61875ad is 0 bytes after a block of size 29 alloc'd
==30548== at 0x4C25153: malloc (vg_replace_malloc.c:195)
==30548== by 0x49BFF1: my_malloc (my_malloc.c:38)
==30548== by 0x49C65C: alloc_root (my_alloc.c:166)
==30548== by 0x48EF97: handle_default_option (default.c:381)
==30548== by 0x49068C: search_default_file_with_ext (default.c:992)
==30548== by 0x48F929: search_default_file (default.c:670)
==30548== by 0x48EDC4: my_search_option_files (default.c:312)
==30548== by 0x48F4B1: my_load_defaults (default.c:576)
==30548== by 0x46517A: mysql_read_default_options (client.c:1207)
==30548== by 0x46830F: mysql_real_connect (client.c:2971)
==30548== by 0x409339: client_connect (mysql_client_test.c:331)
==30548== by 0x463A7F: main (mysql_client_test.c:19902)
This is fixed by having find_type() not overwrite anymore.
sql/sql_help.cc:
cast not needed anymore.
sql/table.cc:
cast not needed anymore.
2011-02-11 15:00:09 +01:00
|
|
|
OPT_keep_this_one_last
|
2010-03-29 17:13:53 +02:00
|
|
|
};
|
2003-05-02 18:07:41 +02:00
|
|
|
|
|
|
|
static TYPELIB option_types={array_elements(default_options)-1,
|
2004-10-26 18:59:33 +02:00
|
|
|
"options",default_options, NULL};
|
2003-05-02 18:07:41 +02:00
|
|
|
|
|
|
|
static int add_init_command(struct st_mysql_options *options, const char *cmd)
|
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
if (!options->init_commands)
|
|
|
|
{
|
|
|
|
options->init_commands= (DYNAMIC_ARRAY*)my_malloc(sizeof(DYNAMIC_ARRAY),
|
|
|
|
MYF(MY_WME));
|
2013-01-23 16:18:09 +01:00
|
|
|
my_init_dynamic_array(options->init_commands,sizeof(char*),5, 5, MYF(0));
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(tmp= my_strdup(cmd,MYF(MY_WME))) ||
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
insert_dynamic(options->init_commands, &tmp))
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
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(tmp);
|
2003-05-02 18:07:41 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-03 17:00:44 +02:00
|
|
|
|
|
|
|
#define ALLOCATE_EXTENSIONS(OPTS) \
|
2010-03-29 17:13:53 +02:00
|
|
|
(OPTS)->extension= (struct st_mysql_options_extention *) \
|
|
|
|
my_malloc(sizeof(struct st_mysql_options_extention), \
|
2013-10-03 17:00:44 +02:00
|
|
|
MYF(MY_WME | MY_ZEROFILL)) \
|
|
|
|
|
|
|
|
|
|
|
|
#define ENSURE_EXTENSIONS_PRESENT(OPTS) \
|
|
|
|
do { \
|
|
|
|
if (!(OPTS)->extension) \
|
|
|
|
ALLOCATE_EXTENSIONS(OPTS); \
|
|
|
|
} while (0)
|
|
|
|
|
2012-08-14 16:23:34 +02:00
|
|
|
|
2016-06-21 14:11:02 +02:00
|
|
|
#define EXTENSION_SET_STRING_X(OPTS, X, STR, dup) \
|
2013-10-03 17:00:44 +02:00
|
|
|
do { \
|
|
|
|
if ((OPTS)->extension) \
|
|
|
|
my_free((OPTS)->extension->X); \
|
|
|
|
else \
|
|
|
|
ALLOCATE_EXTENSIONS(OPTS); \
|
|
|
|
(OPTS)->extension->X= ((STR) != NULL) ? \
|
2016-06-21 14:11:02 +02:00
|
|
|
dup((STR), MYF(MY_WME)) : NULL; \
|
2013-10-03 17:00:44 +02:00
|
|
|
} while (0)
|
|
|
|
|
2016-06-21 14:11:02 +02:00
|
|
|
#define EXTENSION_SET_STRING(OPTS, X, STR) \
|
|
|
|
EXTENSION_SET_STRING_X(OPTS, X, STR, my_strdup)
|
2011-07-01 14:08:30 +02:00
|
|
|
|
2012-08-14 16:23:34 +02:00
|
|
|
|
|
|
|
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
|
2016-06-21 14:11:02 +02:00
|
|
|
#define SET_SSL_OPTION_X(OPTS, opt_var, arg, dup) \
|
|
|
|
my_free((OPTS)->opt_var); \
|
|
|
|
(OPTS)->opt_var= arg ? dup(arg, MYF(MY_WME)) : NULL;
|
|
|
|
#define EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, dup) \
|
|
|
|
EXTENSION_SET_STRING_X((OPTS), X, (STR), dup);
|
|
|
|
|
|
|
|
static char *set_ssl_option_unpack_path(const char *arg, myf flags)
|
2016-03-01 05:47:25 +01:00
|
|
|
{
|
2016-06-21 14:11:02 +02:00
|
|
|
char buff[FN_REFLEN + 1];
|
|
|
|
unpack_filename(buff, (char *)arg);
|
|
|
|
return my_strdup(buff, flags);
|
2016-03-01 05:47:25 +01:00
|
|
|
}
|
2016-06-21 14:11:02 +02:00
|
|
|
|
2012-08-14 16:23:34 +02:00
|
|
|
#else
|
2016-06-21 14:11:02 +02:00
|
|
|
#define SET_SSL_OPTION_X(OPTS, opt_var,arg, dup) do { } while(0)
|
|
|
|
#define EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, dup) do { } while(0)
|
2012-08-14 16:23:34 +02:00
|
|
|
#endif /* defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) */
|
2010-03-29 17:13:53 +02:00
|
|
|
|
2016-06-21 14:11:02 +02:00
|
|
|
#define SET_SSL_OPTION(OPTS, opt_var,arg) SET_SSL_OPTION_X(OPTS, opt_var, arg, my_strdup)
|
|
|
|
#define EXTENSION_SET_SSL_STRING(OPTS, X, STR) EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, my_strdup)
|
|
|
|
#define SET_SSL_PATH_OPTION(OPTS, opt_var,arg) SET_SSL_OPTION_X(OPTS, opt_var, arg, set_ssl_option_unpack_path)
|
|
|
|
#define EXTENSION_SET_SSL_PATH_STRING(OPTS, X, STR) EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, set_ssl_option_unpack_path)
|
2016-03-01 05:47:25 +01:00
|
|
|
|
2003-06-17 18:32:31 +02:00
|
|
|
void mysql_read_default_options(struct st_mysql_options *options,
|
|
|
|
const char *filename,const char *group)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
int argc;
|
|
|
|
char *argv_buff[1],**argv;
|
2011-03-18 16:03:43 +01:00
|
|
|
const char *groups[5];
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_ENTER("mysql_read_default_options");
|
|
|
|
DBUG_PRINT("enter",("file: %s group: %s",filename,group ? group :"NULL"));
|
|
|
|
|
Fix for BUG#59894
"set optimizer_switch to e or d causes invalid memory writes/valgrind warnings":
due to prefix support, the argument "e" was overwritten with its full value
"engine_condition_pushdown", which caused a buffer overrun.
This was wrong usage of find_type(); other wrong usages are fixed here too.
Please start reading with the comment of typelib.c.
client/mysqldump.c:
A bug: find_type() expects a bitmap as 3rd argument
(each bit is a flag controlling a behaviour of the function);
here it was instead passed the length of the string to search!
That could give random behaviour of find_type()
depending on the string.
We rather need to pass a correct flag to find_type().
The correct flag is FIND_TYPE_BASIC (0).
Flag 8 is not needed as buff cannot have a comma (see how buff is filled).
Flag 1 looks like a superfluous restriction.
Flag 4 is not user-friendly (why use
--compatible=2 rather than --compatible=mysql40 ?, and
we probably not commit to "2" always meaning "mysql40"
until the end of times).
include/mysql.h.pp:
This isn't a problematic API change as we go from char* to const char*:
existing code will run unchanged.
include/typelib.h:
named constants. Not an enum to not significantly change
the declaration of find_type() which would be an API change
(typelib.h is included in mysql.h).
mysql-test/r/mysqldump.result:
correct result (see the two requested modes in SQL_MODE)
mysql-test/suite/sys_vars/t/optimizer_switch_basic.test:
test for BUG#59894. The second SET used to crash.
mysql-test/t/mysqldump.test:
we had no test for multiple modes in --compatible, which is
supported according to --help
mysys/typelib.c:
Fix for BUG#59894. parse_name() is asked to match "e" with a row
of the TYPELIB (the TYPELIB lists permitted flags of optimizer_switch;
and comes from optimizer_switch_names[] of sys_vars.cc).
find_type() is capable of supporting prefixes, but if it is not
passed flag 2 in third argument, it will overwrite its first
argument (the string to search for) with the complete name,
here overwriting "e" with "engine_condition_pushdown". But
as this "e" was a buffer allocated in an Item, it was not big
enough to host the longer name, thus the crash.
We don't need to know the complete flag's name; the output used
from find_type() is just the flag's number (== function's return
code). So we can pass flag 2 to find_type() in parse_name().
After doing this fix and the other fixes in this patch, all usages
of find_type() were using flag 2; in most usages the string to search for,
is not guaranteed to be long enough to host the complete name
(it is either directly from argv, or from alloc_root/my_malloc
done in an earlier call).
Thus, flag 2 is here made implicit: callers need not pass it anymore,
it is always automatically turned on.
This allows to eliminate an oddity: parse_name() took a const char**,
and then removed "const" before calling find_type(), which could
theoretically modify the pointed data, thus lying on constness.
Last, constants for find_type() are now named.
sql-common/client.c:
Two bugs:
1) The enum was not in sync with the array (due to a bad porting of WL 1054;
the extra OPT_ values are about options present in 5.1 and deleted in 5.5);
added a compile_time_assert() to make sure this doesn't happen again
2) find_type() was writing past the end of opt_arg; as opt_arg was allocated
with alloc_root() with no extra space, this was an overrun; it could be seen
when
** building with -DWITH_VALGRIND -DHAVE_purify -DEXTRA_DEBUG
** making execution go through the faulty code; this faulty
code is executed only if the client asks to read a configuration
file like this:
mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "/tmp/cnf.cnf");
so by adding such line to the start of mysql_client_test.c::client_connect(),
we could see the valgrind warning:
==30548== Invalid write of size 1
==30548== at 0x4C2624C: strcpy (mc_replace_strmem.c:303)
==30548== by 0x48DC29: find_type (typelib.c:120)
==30548== by 0x465686: mysql_read_default_options (client.c:1344)
==30548== by 0x46830F: mysql_real_connect (client.c:2971)
==30548== by 0x409339: client_connect (mysql_client_test.c:331)
==30548== by 0x463A7F: main (mysql_client_test.c:19902)
==30548== Address 0x61875ad is 0 bytes after a block of size 29 alloc'd
==30548== at 0x4C25153: malloc (vg_replace_malloc.c:195)
==30548== by 0x49BFF1: my_malloc (my_malloc.c:38)
==30548== by 0x49C65C: alloc_root (my_alloc.c:166)
==30548== by 0x48EF97: handle_default_option (default.c:381)
==30548== by 0x49068C: search_default_file_with_ext (default.c:992)
==30548== by 0x48F929: search_default_file (default.c:670)
==30548== by 0x48EDC4: my_search_option_files (default.c:312)
==30548== by 0x48F4B1: my_load_defaults (default.c:576)
==30548== by 0x46517A: mysql_read_default_options (client.c:1207)
==30548== by 0x46830F: mysql_real_connect (client.c:2971)
==30548== by 0x409339: client_connect (mysql_client_test.c:331)
==30548== by 0x463A7F: main (mysql_client_test.c:19902)
This is fixed by having find_type() not overwrite anymore.
sql/sql_help.cc:
cast not needed anymore.
sql/table.cc:
cast not needed anymore.
2011-02-11 15:00:09 +01:00
|
|
|
compile_time_assert(OPT_keep_this_one_last ==
|
|
|
|
array_elements(default_options));
|
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
argc=1; argv=argv_buff; argv_buff[0]= (char*) "client";
|
2011-03-18 16:03:43 +01:00
|
|
|
groups[0]= (char*) "client";
|
|
|
|
groups[1]= (char*) "client-server";
|
|
|
|
groups[2]= (char*) "client-mariadb";
|
|
|
|
groups[3]= (char*) group;
|
|
|
|
groups[4]=0;
|
2003-05-02 18:07:41 +02:00
|
|
|
|
2009-02-27 10:26:06 +01:00
|
|
|
my_load_defaults(filename, groups, &argc, &argv, NULL);
|
2003-05-02 18:07:41 +02:00
|
|
|
if (argc != 1) /* If some default option */
|
|
|
|
{
|
|
|
|
char **option=argv;
|
|
|
|
while (*++option)
|
|
|
|
{
|
2011-01-17 08:44:37 +01:00
|
|
|
if (my_getopt_is_args_separator(option[0])) /* skip arguments separator */
|
2009-10-02 10:25:53 +02:00
|
|
|
continue;
|
2003-05-02 18:07:41 +02:00
|
|
|
/* DBUG_PRINT("info",("option: %s",option[0])); */
|
|
|
|
if (option[0][0] == '-' && option[0][1] == '-')
|
|
|
|
{
|
|
|
|
char *end=strcend(*option,'=');
|
|
|
|
char *opt_arg=0;
|
|
|
|
if (*end)
|
|
|
|
{
|
|
|
|
opt_arg=end+1;
|
|
|
|
*end=0; /* Remove '=' */
|
|
|
|
}
|
|
|
|
/* Change all '_' in variable name to '-' */
|
|
|
|
for (end= *option ; *(end= strcend(end,'_')) ; )
|
|
|
|
*end= '-';
|
Fix for BUG#59894
"set optimizer_switch to e or d causes invalid memory writes/valgrind warnings":
due to prefix support, the argument "e" was overwritten with its full value
"engine_condition_pushdown", which caused a buffer overrun.
This was wrong usage of find_type(); other wrong usages are fixed here too.
Please start reading with the comment of typelib.c.
client/mysqldump.c:
A bug: find_type() expects a bitmap as 3rd argument
(each bit is a flag controlling a behaviour of the function);
here it was instead passed the length of the string to search!
That could give random behaviour of find_type()
depending on the string.
We rather need to pass a correct flag to find_type().
The correct flag is FIND_TYPE_BASIC (0).
Flag 8 is not needed as buff cannot have a comma (see how buff is filled).
Flag 1 looks like a superfluous restriction.
Flag 4 is not user-friendly (why use
--compatible=2 rather than --compatible=mysql40 ?, and
we probably not commit to "2" always meaning "mysql40"
until the end of times).
include/mysql.h.pp:
This isn't a problematic API change as we go from char* to const char*:
existing code will run unchanged.
include/typelib.h:
named constants. Not an enum to not significantly change
the declaration of find_type() which would be an API change
(typelib.h is included in mysql.h).
mysql-test/r/mysqldump.result:
correct result (see the two requested modes in SQL_MODE)
mysql-test/suite/sys_vars/t/optimizer_switch_basic.test:
test for BUG#59894. The second SET used to crash.
mysql-test/t/mysqldump.test:
we had no test for multiple modes in --compatible, which is
supported according to --help
mysys/typelib.c:
Fix for BUG#59894. parse_name() is asked to match "e" with a row
of the TYPELIB (the TYPELIB lists permitted flags of optimizer_switch;
and comes from optimizer_switch_names[] of sys_vars.cc).
find_type() is capable of supporting prefixes, but if it is not
passed flag 2 in third argument, it will overwrite its first
argument (the string to search for) with the complete name,
here overwriting "e" with "engine_condition_pushdown". But
as this "e" was a buffer allocated in an Item, it was not big
enough to host the longer name, thus the crash.
We don't need to know the complete flag's name; the output used
from find_type() is just the flag's number (== function's return
code). So we can pass flag 2 to find_type() in parse_name().
After doing this fix and the other fixes in this patch, all usages
of find_type() were using flag 2; in most usages the string to search for,
is not guaranteed to be long enough to host the complete name
(it is either directly from argv, or from alloc_root/my_malloc
done in an earlier call).
Thus, flag 2 is here made implicit: callers need not pass it anymore,
it is always automatically turned on.
This allows to eliminate an oddity: parse_name() took a const char**,
and then removed "const" before calling find_type(), which could
theoretically modify the pointed data, thus lying on constness.
Last, constants for find_type() are now named.
sql-common/client.c:
Two bugs:
1) The enum was not in sync with the array (due to a bad porting of WL 1054;
the extra OPT_ values are about options present in 5.1 and deleted in 5.5);
added a compile_time_assert() to make sure this doesn't happen again
2) find_type() was writing past the end of opt_arg; as opt_arg was allocated
with alloc_root() with no extra space, this was an overrun; it could be seen
when
** building with -DWITH_VALGRIND -DHAVE_purify -DEXTRA_DEBUG
** making execution go through the faulty code; this faulty
code is executed only if the client asks to read a configuration
file like this:
mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "/tmp/cnf.cnf");
so by adding such line to the start of mysql_client_test.c::client_connect(),
we could see the valgrind warning:
==30548== Invalid write of size 1
==30548== at 0x4C2624C: strcpy (mc_replace_strmem.c:303)
==30548== by 0x48DC29: find_type (typelib.c:120)
==30548== by 0x465686: mysql_read_default_options (client.c:1344)
==30548== by 0x46830F: mysql_real_connect (client.c:2971)
==30548== by 0x409339: client_connect (mysql_client_test.c:331)
==30548== by 0x463A7F: main (mysql_client_test.c:19902)
==30548== Address 0x61875ad is 0 bytes after a block of size 29 alloc'd
==30548== at 0x4C25153: malloc (vg_replace_malloc.c:195)
==30548== by 0x49BFF1: my_malloc (my_malloc.c:38)
==30548== by 0x49C65C: alloc_root (my_alloc.c:166)
==30548== by 0x48EF97: handle_default_option (default.c:381)
==30548== by 0x49068C: search_default_file_with_ext (default.c:992)
==30548== by 0x48F929: search_default_file (default.c:670)
==30548== by 0x48EDC4: my_search_option_files (default.c:312)
==30548== by 0x48F4B1: my_load_defaults (default.c:576)
==30548== by 0x46517A: mysql_read_default_options (client.c:1207)
==30548== by 0x46830F: mysql_real_connect (client.c:2971)
==30548== by 0x409339: client_connect (mysql_client_test.c:331)
==30548== by 0x463A7F: main (mysql_client_test.c:19902)
This is fixed by having find_type() not overwrite anymore.
sql/sql_help.cc:
cast not needed anymore.
sql/table.cc:
cast not needed anymore.
2011-02-11 15:00:09 +01:00
|
|
|
switch (find_type(*option + 2, &option_types, FIND_TYPE_BASIC)) {
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_port:
|
2003-05-02 18:07:41 +02:00
|
|
|
if (opt_arg)
|
|
|
|
options->port=atoi(opt_arg);
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_socket:
|
2003-05-02 18:07:41 +02:00
|
|
|
if (opt_arg)
|
|
|
|
{
|
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(options->unix_socket);
|
2003-05-02 18:07:41 +02:00
|
|
|
options->unix_socket=my_strdup(opt_arg,MYF(MY_WME));
|
|
|
|
}
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_compress:
|
2003-05-02 18:07:41 +02:00
|
|
|
options->compress=1;
|
|
|
|
options->client_flag|= CLIENT_COMPRESS;
|
|
|
|
break;
|
2010-08-09 10:32:50 +02:00
|
|
|
case OPT_password:
|
2003-05-02 18:07:41 +02:00
|
|
|
if (opt_arg)
|
|
|
|
{
|
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(options->password);
|
2003-05-02 18:07:41 +02:00
|
|
|
options->password=my_strdup(opt_arg,MYF(MY_WME));
|
|
|
|
}
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_pipe:
|
2003-05-02 18:07:41 +02:00
|
|
|
options->protocol = MYSQL_PROTOCOL_PIPE;
|
2017-09-16 14:52:42 +02:00
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_connect_timeout:
|
|
|
|
case OPT_timeout:
|
2003-05-02 18:07:41 +02:00
|
|
|
if (opt_arg)
|
|
|
|
options->connect_timeout=atoi(opt_arg);
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_user:
|
2003-05-02 18:07:41 +02:00
|
|
|
if (opt_arg)
|
|
|
|
{
|
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(options->user);
|
2003-05-02 18:07:41 +02:00
|
|
|
options->user=my_strdup(opt_arg,MYF(MY_WME));
|
|
|
|
}
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_init_command:
|
2003-05-02 18:07:41 +02:00
|
|
|
add_init_command(options,opt_arg);
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_host:
|
2003-05-02 18:07:41 +02:00
|
|
|
if (opt_arg)
|
|
|
|
{
|
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(options->host);
|
2003-05-02 18:07:41 +02:00
|
|
|
options->host=my_strdup(opt_arg,MYF(MY_WME));
|
|
|
|
}
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_database:
|
2003-05-02 18:07:41 +02:00
|
|
|
if (opt_arg)
|
|
|
|
{
|
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(options->db);
|
2003-05-02 18:07:41 +02:00
|
|
|
options->db=my_strdup(opt_arg,MYF(MY_WME));
|
|
|
|
}
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_debug:
|
2003-06-14 10:37:42 +02:00
|
|
|
#ifdef MYSQL_CLIENT
|
2003-05-02 18:07:41 +02:00
|
|
|
mysql_debug(opt_arg ? opt_arg : "d:t:o,/tmp/client.trace");
|
|
|
|
break;
|
2003-05-31 12:15:46 +02:00
|
|
|
#endif
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_return_found_rows:
|
2003-05-02 18:07:41 +02:00
|
|
|
options->client_flag|=CLIENT_FOUND_ROWS;
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_ssl_key:
|
2012-08-14 16:23:34 +02:00
|
|
|
SET_SSL_OPTION(options, ssl_key, opt_arg);
|
2003-05-02 18:07:41 +02:00
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_ssl_cert:
|
2012-08-14 16:23:34 +02:00
|
|
|
SET_SSL_OPTION(options, ssl_cert, opt_arg);
|
2003-05-02 18:07:41 +02:00
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_ssl_ca:
|
2012-08-14 16:23:34 +02:00
|
|
|
SET_SSL_OPTION(options, ssl_ca, opt_arg);
|
2003-05-02 18:07:41 +02:00
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_ssl_capath:
|
2012-08-14 16:23:34 +02:00
|
|
|
SET_SSL_OPTION(options, ssl_capath, opt_arg);
|
2003-05-02 18:07:41 +02:00
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_ssl_cipher:
|
2012-08-14 16:23:34 +02:00
|
|
|
SET_SSL_OPTION(options, ssl_cipher, opt_arg);
|
|
|
|
break;
|
|
|
|
case OPT_ssl_crl:
|
|
|
|
EXTENSION_SET_SSL_STRING(options, ssl_crl, opt_arg);
|
|
|
|
break;
|
|
|
|
case OPT_ssl_crlpath:
|
|
|
|
EXTENSION_SET_SSL_STRING(options, ssl_crlpath, opt_arg);
|
2007-11-16 10:43:59 +01:00
|
|
|
break;
|
2010-08-09 10:32:50 +02:00
|
|
|
case OPT_character_sets_dir:
|
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(options->charset_dir);
|
2003-05-02 18:07:41 +02:00
|
|
|
options->charset_dir = my_strdup(opt_arg, MYF(MY_WME));
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_default_character_set:
|
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(options->charset_name);
|
2003-05-02 18:07:41 +02:00
|
|
|
options->charset_name = my_strdup(opt_arg, MYF(MY_WME));
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_interactive_timeout:
|
2003-05-02 18:07:41 +02:00
|
|
|
options->client_flag|= CLIENT_INTERACTIVE;
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_local_infile:
|
2003-05-02 18:07:41 +02:00
|
|
|
if (!opt_arg || atoi(opt_arg) != 0)
|
|
|
|
options->client_flag|= CLIENT_LOCAL_FILES;
|
|
|
|
else
|
|
|
|
options->client_flag&= ~CLIENT_LOCAL_FILES;
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_disable_local_infile:
|
2004-08-19 03:02:09 +02:00
|
|
|
options->client_flag&= ~CLIENT_LOCAL_FILES;
|
2003-05-02 18:07:41 +02:00
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_max_allowed_packet:
|
2003-12-19 15:25:50 +01:00
|
|
|
if (opt_arg)
|
|
|
|
options->max_allowed_packet= atoi(opt_arg);
|
2003-05-02 18:07:41 +02:00
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_protocol:
|
2017-12-18 14:15:48 +01:00
|
|
|
if (options->protocol != UINT_MAX32 &&
|
|
|
|
(options->protocol= find_type(opt_arg, &sql_protocol_typelib,
|
Fix for BUG#59894
"set optimizer_switch to e or d causes invalid memory writes/valgrind warnings":
due to prefix support, the argument "e" was overwritten with its full value
"engine_condition_pushdown", which caused a buffer overrun.
This was wrong usage of find_type(); other wrong usages are fixed here too.
Please start reading with the comment of typelib.c.
client/mysqldump.c:
A bug: find_type() expects a bitmap as 3rd argument
(each bit is a flag controlling a behaviour of the function);
here it was instead passed the length of the string to search!
That could give random behaviour of find_type()
depending on the string.
We rather need to pass a correct flag to find_type().
The correct flag is FIND_TYPE_BASIC (0).
Flag 8 is not needed as buff cannot have a comma (see how buff is filled).
Flag 1 looks like a superfluous restriction.
Flag 4 is not user-friendly (why use
--compatible=2 rather than --compatible=mysql40 ?, and
we probably not commit to "2" always meaning "mysql40"
until the end of times).
include/mysql.h.pp:
This isn't a problematic API change as we go from char* to const char*:
existing code will run unchanged.
include/typelib.h:
named constants. Not an enum to not significantly change
the declaration of find_type() which would be an API change
(typelib.h is included in mysql.h).
mysql-test/r/mysqldump.result:
correct result (see the two requested modes in SQL_MODE)
mysql-test/suite/sys_vars/t/optimizer_switch_basic.test:
test for BUG#59894. The second SET used to crash.
mysql-test/t/mysqldump.test:
we had no test for multiple modes in --compatible, which is
supported according to --help
mysys/typelib.c:
Fix for BUG#59894. parse_name() is asked to match "e" with a row
of the TYPELIB (the TYPELIB lists permitted flags of optimizer_switch;
and comes from optimizer_switch_names[] of sys_vars.cc).
find_type() is capable of supporting prefixes, but if it is not
passed flag 2 in third argument, it will overwrite its first
argument (the string to search for) with the complete name,
here overwriting "e" with "engine_condition_pushdown". But
as this "e" was a buffer allocated in an Item, it was not big
enough to host the longer name, thus the crash.
We don't need to know the complete flag's name; the output used
from find_type() is just the flag's number (== function's return
code). So we can pass flag 2 to find_type() in parse_name().
After doing this fix and the other fixes in this patch, all usages
of find_type() were using flag 2; in most usages the string to search for,
is not guaranteed to be long enough to host the complete name
(it is either directly from argv, or from alloc_root/my_malloc
done in an earlier call).
Thus, flag 2 is here made implicit: callers need not pass it anymore,
it is always automatically turned on.
This allows to eliminate an oddity: parse_name() took a const char**,
and then removed "const" before calling find_type(), which could
theoretically modify the pointed data, thus lying on constness.
Last, constants for find_type() are now named.
sql-common/client.c:
Two bugs:
1) The enum was not in sync with the array (due to a bad porting of WL 1054;
the extra OPT_ values are about options present in 5.1 and deleted in 5.5);
added a compile_time_assert() to make sure this doesn't happen again
2) find_type() was writing past the end of opt_arg; as opt_arg was allocated
with alloc_root() with no extra space, this was an overrun; it could be seen
when
** building with -DWITH_VALGRIND -DHAVE_purify -DEXTRA_DEBUG
** making execution go through the faulty code; this faulty
code is executed only if the client asks to read a configuration
file like this:
mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "/tmp/cnf.cnf");
so by adding such line to the start of mysql_client_test.c::client_connect(),
we could see the valgrind warning:
==30548== Invalid write of size 1
==30548== at 0x4C2624C: strcpy (mc_replace_strmem.c:303)
==30548== by 0x48DC29: find_type (typelib.c:120)
==30548== by 0x465686: mysql_read_default_options (client.c:1344)
==30548== by 0x46830F: mysql_real_connect (client.c:2971)
==30548== by 0x409339: client_connect (mysql_client_test.c:331)
==30548== by 0x463A7F: main (mysql_client_test.c:19902)
==30548== Address 0x61875ad is 0 bytes after a block of size 29 alloc'd
==30548== at 0x4C25153: malloc (vg_replace_malloc.c:195)
==30548== by 0x49BFF1: my_malloc (my_malloc.c:38)
==30548== by 0x49C65C: alloc_root (my_alloc.c:166)
==30548== by 0x48EF97: handle_default_option (default.c:381)
==30548== by 0x49068C: search_default_file_with_ext (default.c:992)
==30548== by 0x48F929: search_default_file (default.c:670)
==30548== by 0x48EDC4: my_search_option_files (default.c:312)
==30548== by 0x48F4B1: my_load_defaults (default.c:576)
==30548== by 0x46517A: mysql_read_default_options (client.c:1207)
==30548== by 0x46830F: mysql_real_connect (client.c:2971)
==30548== by 0x409339: client_connect (mysql_client_test.c:331)
==30548== by 0x463A7F: main (mysql_client_test.c:19902)
This is fixed by having find_type() not overwrite anymore.
sql/sql_help.cc:
cast not needed anymore.
sql/table.cc:
cast not needed anymore.
2011-02-11 15:00:09 +01:00
|
|
|
FIND_TYPE_BASIC)) <= 0)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Unknown option to protocol: %s\n", opt_arg);
|
2017-12-18 14:15:48 +01:00
|
|
|
options->protocol= UINT_MAX32;
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_multi_results:
|
2003-05-31 12:15:46 +02:00
|
|
|
options->client_flag|= CLIENT_MULTI_RESULTS;
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_multi_statements:
|
|
|
|
case OPT_multi_queries:
|
2003-11-18 12:47:27 +01:00
|
|
|
options->client_flag|= CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS;
|
2003-05-31 12:15:46 +02:00
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_secure_auth:
|
2003-11-28 11:11:44 +01:00
|
|
|
options->secure_auth= TRUE;
|
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_report_data_truncation:
|
2014-02-19 11:05:15 +01:00
|
|
|
options->report_data_truncation= opt_arg ? MY_TEST(atoi(opt_arg)) : 1;
|
2004-12-17 22:17:25 +01:00
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case OPT_plugin_dir:
|
2010-08-09 10:32:50 +02:00
|
|
|
{
|
2012-10-01 13:15:29 +02:00
|
|
|
char buff[FN_REFLEN], buff2[FN_REFLEN], *buff2_ptr= buff2;
|
2010-08-09 10:32:50 +02:00
|
|
|
if (strlen(opt_arg) >= FN_REFLEN)
|
|
|
|
opt_arg[FN_REFLEN]= '\0';
|
|
|
|
if (my_realpath(buff, opt_arg, 0))
|
|
|
|
{
|
|
|
|
DBUG_PRINT("warning",("failed to normalize the plugin path: %s",
|
|
|
|
opt_arg));
|
|
|
|
break;
|
|
|
|
}
|
2013-04-24 16:21:42 +02:00
|
|
|
convert_dirname(buff2, buff, NULL);
|
2012-10-01 13:15:29 +02:00
|
|
|
EXTENSION_SET_STRING(options, plugin_dir, buff2_ptr);
|
2010-08-09 10:32:50 +02:00
|
|
|
}
|
2010-03-29 17:13:53 +02:00
|
|
|
break;
|
|
|
|
case OPT_default_auth:
|
2010-08-09 10:32:50 +02:00
|
|
|
EXTENSION_SET_STRING(options, default_auth, opt_arg);
|
2010-03-29 17:13:53 +02:00
|
|
|
break;
|
2013-06-11 11:11:05 +02:00
|
|
|
case OPT_enable_cleartext_plugin:
|
|
|
|
break;
|
2003-05-02 18:07:41 +02:00
|
|
|
default:
|
|
|
|
DBUG_PRINT("warning",("unknown option: %s",option[0]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free_defaults(argv);
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
/**************************************************************************
|
|
|
|
Get column lengths of the current row
|
|
|
|
If one uses mysql_use_result, res->lengths contains the length information,
|
|
|
|
else the lengths are calculated from the offset between pointers.
|
|
|
|
**************************************************************************/
|
|
|
|
|
2005-02-23 09:29:57 +01:00
|
|
|
static void cli_fetch_lengths(ulong *to, MYSQL_ROW column,
|
2003-11-20 21:06:25 +01:00
|
|
|
unsigned int field_count)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2003-07-23 12:23:20 +02:00
|
|
|
ulong *prev_length;
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
BitKeeper/etc/ignore:
added libmysqld/ha_ndbcluster_cond.cc
---
added debian/defs.mk debian/control
client/completion_hash.cc:
Remove not needed casts
client/my_readline.h:
Remove some old types
client/mysql.cc:
Simplify types
client/mysql_upgrade.c:
Remove some old types
Update call to dirname_part
client/mysqladmin.cc:
Remove some old types
client/mysqlbinlog.cc:
Remove some old types
Change some buffers to be uchar to avoid casts
client/mysqlcheck.c:
Remove some old types
client/mysqldump.c:
Remove some old types
Remove some not needed casts
Change some string lengths to size_t
client/mysqlimport.c:
Remove some old types
client/mysqlshow.c:
Remove some old types
client/mysqlslap.c:
Remove some old types
Remove some not needed casts
client/mysqltest.c:
Removed some old types
Removed some not needed casts
Updated hash-get-key function arguments
Updated parameters to dirname_part()
client/readline.cc:
Removed some old types
Removed some not needed casts
Changed some string lengths to use size_t
client/sql_string.cc:
Removed some old types
dbug/dbug.c:
Removed some old types
Changed some string lengths to use size_t
Changed some prototypes to avoid casts
extra/comp_err.c:
Removed some old types
extra/innochecksum.c:
Removed some old types
extra/my_print_defaults.c:
Removed some old types
extra/mysql_waitpid.c:
Removed some old types
extra/perror.c:
Removed some old types
extra/replace.c:
Removed some old types
Updated parameters to dirname_part()
extra/resolve_stack_dump.c:
Removed some old types
extra/resolveip.c:
Removed some old types
include/config-win.h:
Removed some old types
include/decimal.h:
Changed binary strings to be uchar* instead of char*
include/ft_global.h:
Removed some old types
include/hash.h:
Removed some old types
include/heap.h:
Removed some old types
Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable
include/keycache.h:
Removed some old types
include/m_ctype.h:
Removed some old types
Changed some string lengths to use size_t
Changed character length functions to return uint
unsigned char -> uchar
include/m_string.h:
Removed some old types
Changed some string lengths to use size_t
include/my_alloc.h:
Changed some string lengths to use size_t
include/my_base.h:
Removed some old types
include/my_dbug.h:
Removed some old types
Changed some string lengths to use size_t
Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage
include/my_getopt.h:
Removed some old types
include/my_global.h:
Removed old types:
my_size_t -> size_t
byte -> uchar
gptr -> uchar *
include/my_list.h:
Removed some old types
include/my_nosys.h:
Removed some old types
include/my_pthread.h:
Removed some old types
include/my_sys.h:
Removed some old types
Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read()
Changed some string lengths to use size_t
my_malloc() / my_free() now uses void *
Updated parameters to dirname_part() & my_uncompress()
include/my_tree.h:
Removed some old types
include/my_trie.h:
Removed some old types
include/my_user.h:
Changed some string lengths to use size_t
include/my_vle.h:
Removed some old types
include/my_xml.h:
Removed some old types
Changed some string lengths to use size_t
include/myisam.h:
Removed some old types
include/myisammrg.h:
Removed some old types
include/mysql.h:
Removed some old types
Changed byte streams to use uchar* instead of char*
include/mysql_com.h:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
include/queues.h:
Removed some old types
include/sql_common.h:
Removed some old types
include/sslopt-longopts.h:
Removed some old types
include/violite.h:
Removed some old types
Changed some string lengths to use size_t
libmysql/client_settings.h:
Removed some old types
libmysql/libmysql.c:
Removed some old types
libmysql/manager.c:
Removed some old types
libmysqld/emb_qcache.cc:
Removed some old types
libmysqld/emb_qcache.h:
Removed some old types
libmysqld/lib_sql.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
true -> TRUE, false -> FALSE
mysys/array.c:
Removed some old types
mysys/charset.c:
Changed some string lengths to use size_t
mysys/checksum.c:
Include zlib to get definition for crc32
Removed some old types
mysys/default.c:
Removed some old types
Changed some string lengths to use size_t
mysys/default_modify.c:
Changed some string lengths to use size_t
Removed some not needed casts
mysys/hash.c:
Removed some old types
Changed some string lengths to use size_t
Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function.
hash_element now takes 'ulong' as the index type (cleanup)
mysys/list.c:
Removed some old types
mysys/mf_cache.c:
Changed some string lengths to use size_t
mysys/mf_dirname.c:
Removed some old types
Changed some string lengths to use size_t
Added argument to dirname_part() to avoid calculation of length for 'to'
mysys/mf_fn_ext.c:
Removed some old types
Updated parameters to dirname_part()
mysys/mf_format.c:
Removed some old types
Changed some string lengths to use size_t
mysys/mf_getdate.c:
Removed some old types
mysys/mf_iocache.c:
Removed some old types
Changed some string lengths to use size_t
Changed calculation of 'max_length' to be done the same way in all functions
mysys/mf_iocache2.c:
Removed some old types
Changed some string lengths to use size_t
Clean up comments
Removed not needed indentation
mysys/mf_keycache.c:
Removed some old types
mysys/mf_keycaches.c:
Removed some old types
mysys/mf_loadpath.c:
Removed some old types
mysys/mf_pack.c:
Removed some old types
Changed some string lengths to use size_t
Removed some not needed casts
Removed very old VMS code
Updated parameters to dirname_part()
Use result of dirnam_part() to remove call to strcat()
mysys/mf_path.c:
Removed some old types
mysys/mf_radix.c:
Removed some old types
mysys/mf_same.c:
Removed some old types
mysys/mf_sort.c:
Removed some old types
mysys/mf_soundex.c:
Removed some old types
mysys/mf_strip.c:
Removed some old types
mysys/mf_tempdir.c:
Removed some old types
mysys/mf_unixpath.c:
Removed some old types
mysys/mf_wfile.c:
Removed some old types
mysys/mulalloc.c:
Removed some old types
mysys/my_alloc.c:
Removed some old types
Changed some string lengths to use size_t
Use void* as type for allocated memory area
Removed some not needed casts
Changed argument 'Size' to 'length' according coding guidelines
mysys/my_chsize.c:
Changed some buffers to be uchar* to avoid casts
mysys/my_compress.c:
More comments
Removed some old types
Changed string lengths to use size_t
Changed arguments to my_uncompress() to make them easier to understand
Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix)
Changed type of 'pack_data' argument to packfrm() to avoid casts.
mysys/my_conio.c:
Changed some string lengths to use size_t
mysys/my_create.c:
Removed some old types
mysys/my_div.c:
Removed some old types
mysys/my_error.c:
Removed some old types
mysys/my_fopen.c:
Removed some old types
mysys/my_fstream.c:
Removed some old types
Changed some string lengths to use size_t
writen -> written
mysys/my_getopt.c:
Removed some old types
mysys/my_getwd.c:
Removed some old types
More comments
mysys/my_init.c:
Removed some old types
mysys/my_largepage.c:
Removed some old types
Changed some string lengths to use size_t
mysys/my_lib.c:
Removed some old types
mysys/my_lockmem.c:
Removed some old types
mysys/my_malloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/my_memmem.c:
Indentation cleanup
mysys/my_once.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
mysys/my_open.c:
Removed some old types
mysys/my_pread.c:
Removed some old types
Changed all functions to use size_t
Added comment for how my_pread() / my_pwrite() are supposed to work.
Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe.
(If we ever would really need this, it should be enabled only with a flag argument)
mysys/my_quick.c:
Removed some old types
Changed all functions to use size_t
mysys/my_read.c:
Removed some old types
Changed all functions to use size_t
mysys/my_realloc.c:
Removed some old types
Use void* as type for allocated memory area
Changed all functions to use size_t
mysys/my_static.c:
Removed some old types
mysys/my_static.h:
Removed some old types
mysys/my_vle.c:
Removed some old types
mysys/my_wincond.c:
Removed some old types
mysys/my_windac.c:
Removed some old types
mysys/my_write.c:
Removed some old types
Changed all functions to use size_t
mysys/ptr_cmp.c:
Removed some old types
Changed all functions to use size_t
mysys/queues.c:
Removed some old types
mysys/safemalloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/string.c:
Removed some old types
Changed all functions to use size_t
mysys/testhash.c:
Removed some old types
mysys/thr_alarm.c:
Removed some old types
mysys/thr_lock.c:
Removed some old types
mysys/tree.c:
Removed some old types
mysys/trie.c:
Removed some old types
mysys/typelib.c:
Removed some old types
plugin/daemon_example/daemon_example.cc:
Removed some old types
regex/reginit.c:
Removed some old types
server-tools/instance-manager/buffer.cc:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/buffer.h:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/commands.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_map.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_options.cc:
Changed buffer to be of type uchar*
Replaced alloc_root + strcpy() with strdup_root()
server-tools/instance-manager/mysql_connection.cc:
Changed buffer to be of type uchar*
server-tools/instance-manager/options.cc:
Removed some old types
server-tools/instance-manager/parse.cc:
Changed some string lengths to use size_t
server-tools/instance-manager/parse.h:
Removed some old types
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.cc:
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.h:
Changed some string lengths to use size_t
server-tools/instance-manager/user_map.cc:
Removed some old types
Changed some string lengths to use size_t
sql/derror.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/discover.cc:
Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
sql/event_data_objects.cc:
Removed some old types
Added missing casts for alloc() and sprintf()
sql/event_db_repository.cc:
Changed some buffers to be uchar* to avoid casts
Added missing casts for sprintf()
sql/event_queue.cc:
Removed some old types
sql/field.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/field.h:
Removed some old types
Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes).
Changed some string lengths to use size_t
Removed some not needed casts
Changed val_xxx(xxx, new_ptr) to take const pointers
sql/field_conv.cc:
Removed some old types
Added casts required because memory area pointers are now uchar*
sql/filesort.cc:
Initalize variable that was used unitialized in error conditions
sql/gen_lex_hash.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/gstream.h:
Added required cast
sql/ha_ndbcluster.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Added required casts
Removed some not needed casts
sql/ha_ndbcluster.h:
Removed some old types
sql/ha_ndbcluster_binlog.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake()
Changed some string lengths to use size_t
Added missing casts for alloc() and sprintf()
sql/ha_ndbcluster_binlog.h:
Removed some old types
sql/ha_ndbcluster_cond.cc:
Removed some old types
Removed some not needed casts
sql/ha_ndbcluster_cond.h:
Removed some old types
sql/ha_partition.cc:
Removed some old types
Changed prototype for change_partition() to avoid casts
sql/ha_partition.h:
Removed some old types
sql/handler.cc:
Removed some old types
Changed some string lengths to use size_t
sql/handler.h:
Removed some old types
Changed some string lengths to use size_t
Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts
sql/hash_filo.h:
Removed some old types
Changed all functions to use size_t
sql/hostname.cc:
Removed some old types
sql/item.cc:
Removed some old types
Changed some string lengths to use size_t
Use strmake() instead of memdup() to create a null terminated string.
Updated calls to new Field()
sql/item.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.h:
Removed some old types
sql/item_create.cc:
Removed some old types
sql/item_func.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added test for failing alloc() in init_result_field()
Remove old confusing comment
Fixed compiler warning
sql/item_func.h:
Removed some old types
sql/item_row.cc:
Removed some old types
sql/item_row.h:
Removed some old types
sql/item_strfunc.cc:
Include zlib (needed becasue we call crc32)
Removed some old types
sql/item_strfunc.h:
Removed some old types
Changed some types to match new function prototypes
sql/item_subselect.cc:
Removed some old types
sql/item_subselect.h:
Removed some old types
sql/item_sum.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/item_sum.h:
Removed some old types
sql/item_timefunc.cc:
Removed some old types
Changed some string lengths to use size_t
sql/item_timefunc.h:
Removed some old types
sql/item_xmlfunc.cc:
Changed some string lengths to use size_t
sql/item_xmlfunc.h:
Removed some old types
sql/key.cc:
Removed some old types
Removed some not needed casts
sql/lock.cc:
Removed some old types
Added some cast to my_multi_malloc() arguments for safety
sql/log.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Changed usage of pwrite() to not assume it holds the cursor position for the file
Made usage of my_read() safer
sql/log_event.cc:
Removed some old types
Added checking of return value of malloc() in pack_info()
Changed some buffers to be uchar* to avoid casts
Removed some 'const' to avoid casts
Added missing casts for alloc() and sprintf()
Added required casts
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
sql/log_event.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/log_event_old.cc:
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/log_event_old.h:
Changed some buffers to be uchar* to avoid casts
sql/mf_iocache.cc:
Removed some old types
sql/my_decimal.cc:
Changed memory area to use uchar*
sql/my_decimal.h:
Changed memory area to use uchar*
sql/mysql_priv.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some string lengths to use size_t
Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow
Changed some buffers to be uchar* to avoid casts
sql/mysqld.cc:
Removed some old types
sql/net_serv.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Ensure that vio_read()/vio_write() return values are stored in a size_t variable
Removed some not needed casts
sql/opt_range.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/opt_range.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/opt_sum.cc:
Removed some old types
Removed some not needed casts
sql/parse_file.cc:
Removed some old types
Changed some string lengths to use size_t
Changed alloc_root + memcpy + set end 0 -> strmake_root()
sql/parse_file.h:
Removed some old types
sql/partition_info.cc:
Removed some old types
Added missing casts for alloc()
Changed some buffers to be uchar* to avoid casts
sql/partition_info.h:
Changed some buffers to be uchar* to avoid casts
sql/protocol.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/protocol.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/records.cc:
Removed some old types
sql/repl_failsafe.cc:
Removed some old types
Changed some string lengths to use size_t
Added required casts
sql/rpl_filter.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some string lengths to use size_t
sql/rpl_filter.h:
Changed some string lengths to use size_t
sql/rpl_injector.h:
Removed some old types
sql/rpl_record.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
sql/rpl_record.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/rpl_record_old.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/rpl_record_old.h:
Removed some old types
Changed some buffers to be uchar* to avoid cast
sql/rpl_rli.cc:
Removed some old types
sql/rpl_tblmap.cc:
Removed some old types
sql/rpl_tblmap.h:
Removed some old types
sql/rpl_utility.cc:
Removed some old types
sql/rpl_utility.h:
Removed some old types
Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length
sql/set_var.cc:
Removed some old types
Updated parameters to dirname_part()
sql/set_var.h:
Removed some old types
sql/slave.cc:
Removed some old types
Changed some string lengths to use size_t
sql/slave.h:
Removed some old types
sql/sp.cc:
Removed some old types
Added missing casts for printf()
sql/sp.h:
Removed some old types
Updated hash-get-key function arguments
sql/sp_cache.cc:
Removed some old types
Added missing casts for printf()
Updated hash-get-key function arguments
sql/sp_head.cc:
Removed some old types
Added missing casts for alloc() and printf()
Added required casts
Updated hash-get-key function arguments
sql/sp_head.h:
Removed some old types
sql/sp_pcontext.cc:
Removed some old types
sql/sp_pcontext.h:
Removed some old types
sql/sql_acl.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added required casts
sql/sql_analyse.cc:
Changed some buffers to be uchar* to avoid casts
sql/sql_analyse.h:
Changed some buffers to be uchar* to avoid casts
sql/sql_array.h:
Removed some old types
sql/sql_base.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_binlog.cc:
Removed some old types
Added missing casts for printf()
sql/sql_cache.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
Changed some string lengths to use size_t
sql/sql_cache.h:
Removed some old types
Removed reference to not existing function cache_key()
Updated hash-get-key function arguments
sql/sql_class.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc()
Updated hash-get-key function arguments
Moved THD::max_row_length() to table.cc (as it's not depending on THD)
Removed some not needed casts
sql/sql_class.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Removed some not needed casts
Changed some string lengths to use size_t
Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD
sql/sql_connect.cc:
Removed some old types
Added required casts
sql/sql_db.cc:
Removed some old types
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
Added missing casts for alloc()
sql/sql_delete.cc:
Removed some old types
sql/sql_handler.cc:
Removed some old types
Updated hash-get-key function arguments
Added some cast to my_multi_malloc() arguments for safety
sql/sql_help.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_insert.cc:
Removed some old types
Added missing casts for alloc() and printf()
sql/sql_lex.cc:
Removed some old types
sql/sql_lex.h:
Removed some old types
Removed some not needed casts
sql/sql_list.h:
Removed some old types
Removed some not needed casts
sql/sql_load.cc:
Removed some old types
Removed compiler warning
sql/sql_manager.cc:
Removed some old types
sql/sql_map.cc:
Removed some old types
sql/sql_map.h:
Removed some old types
sql/sql_olap.cc:
Removed some old types
sql/sql_parse.cc:
Removed some old types
Trivial move of code lines to make things more readable
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/sql_partition.cc:
Removed some old types
Removed compiler warnings about not used functions
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_partition.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_plugin.cc:
Removed some old types
Added missing casts for alloc()
Updated hash-get-key function arguments
sql/sql_prepare.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Added missing casts for alloc() and printf()
sql-common/client.c:
Removed some old types
Changed some memory areas to use uchar*
sql-common/my_user.c:
Changed some string lengths to use size_t
sql-common/pack.c:
Changed some buffers to be uchar* to avoid casts
sql/sql_repl.cc:
Added required casts
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/sql_select.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some old types
sql/sql_select.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_servers.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_show.cc:
Removed some old types
Added missing casts for alloc()
Removed some not needed casts
sql/sql_string.cc:
Removed some old types
Added required casts
sql/sql_table.cc:
Removed some old types
Removed compiler warning about not used variable
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_test.cc:
Removed some old types
sql/sql_trigger.cc:
Removed some old types
Added missing casts for alloc()
sql/sql_udf.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_union.cc:
Removed some old types
sql/sql_update.cc:
Removed some old types
Removed some not needed casts
sql/sql_view.cc:
Removed some old types
sql/sql_yacc.yy:
Removed some old types
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/stacktrace.c:
Removed some old types
sql/stacktrace.h:
Removed some old types
sql/structs.h:
Removed some old types
sql/table.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Removed setting of LEX_STRING() arguments in declaration
Added required casts
More function comments
Moved max_row_length() here from sql_class.cc/sql_class.h
sql/table.h:
Removed some old types
Changed some string lengths to use size_t
sql/thr_malloc.cc:
Use void* as type for allocated memory area
Changed all functions to use size_t
sql/tzfile.h:
Changed some buffers to be uchar* to avoid casts
sql/tztime.cc:
Changed some buffers to be uchar* to avoid casts
Updated hash-get-key function arguments
Added missing casts for alloc()
Removed some not needed casts
sql/uniques.cc:
Removed some old types
Removed some not needed casts
sql/unireg.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added missing casts for alloc()
storage/archive/archive_reader.c:
Removed some old types
storage/archive/azio.c:
Removed some old types
Removed some not needed casts
storage/archive/ha_archive.cc:
Removed some old types
Changed type for 'frmblob' in archive_discover() to match handler
Updated hash-get-key function arguments
Removed some not needed casts
storage/archive/ha_archive.h:
Removed some old types
storage/blackhole/ha_blackhole.cc:
Removed some old types
storage/blackhole/ha_blackhole.h:
Removed some old types
storage/csv/ha_tina.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
storage/csv/ha_tina.h:
Removed some old types
Removed some not needed casts
storage/csv/transparent_file.cc:
Removed some old types
Changed type of 'bytes_read' to be able to detect read errors
Fixed indentation
storage/csv/transparent_file.h:
Removed some old types
storage/example/ha_example.cc:
Removed some old types
Updated hash-get-key function arguments
storage/example/ha_example.h:
Removed some old types
storage/federated/ha_federated.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
storage/federated/ha_federated.h:
Removed some old types
storage/heap/_check.c:
Changed some buffers to be uchar* to avoid casts
storage/heap/_rectest.c:
Removed some old types
storage/heap/ha_heap.cc:
Removed some old types
storage/heap/ha_heap.h:
Removed some old types
storage/heap/heapdef.h:
Removed some old types
storage/heap/hp_block.c:
Removed some old types
Changed some string lengths to use size_t
storage/heap/hp_clear.c:
Removed some old types
storage/heap/hp_close.c:
Removed some old types
storage/heap/hp_create.c:
Removed some old types
storage/heap/hp_delete.c:
Removed some old types
storage/heap/hp_hash.c:
Removed some old types
storage/heap/hp_info.c:
Removed some old types
storage/heap/hp_open.c:
Removed some old types
storage/heap/hp_rfirst.c:
Removed some old types
storage/heap/hp_rkey.c:
Removed some old types
storage/heap/hp_rlast.c:
Removed some old types
storage/heap/hp_rnext.c:
Removed some old types
storage/heap/hp_rprev.c:
Removed some old types
storage/heap/hp_rrnd.c:
Removed some old types
storage/heap/hp_rsame.c:
Removed some old types
storage/heap/hp_scan.c:
Removed some old types
storage/heap/hp_test1.c:
Removed some old types
storage/heap/hp_test2.c:
Removed some old types
storage/heap/hp_update.c:
Removed some old types
storage/heap/hp_write.c:
Removed some old types
Changed some string lengths to use size_t
storage/innobase/handler/ha_innodb.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc() and printf()
Removed some not needed casts
storage/innobase/handler/ha_innodb.h:
Removed some old types
storage/myisam/ft_boolean_search.c:
Removed some old types
storage/myisam/ft_nlq_search.c:
Removed some old types
storage/myisam/ft_parser.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ft_static.c:
Removed some old types
storage/myisam/ft_stopwords.c:
Removed some old types
storage/myisam/ft_update.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ftdefs.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/fulltext.h:
Removed some old types
storage/myisam/ha_myisam.cc:
Removed some old types
storage/myisam/ha_myisam.h:
Removed some old types
storage/myisam/mi_cache.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_check.c:
Removed some old types
storage/myisam/mi_checksum.c:
Removed some old types
storage/myisam/mi_close.c:
Removed some old types
storage/myisam/mi_create.c:
Removed some old types
storage/myisam/mi_delete.c:
Removed some old types
storage/myisam/mi_delete_all.c:
Removed some old types
storage/myisam/mi_dynrec.c:
Removed some old types
storage/myisam/mi_extra.c:
Removed some old types
storage/myisam/mi_key.c:
Removed some old types
storage/myisam/mi_locking.c:
Removed some old types
storage/myisam/mi_log.c:
Removed some old types
storage/myisam/mi_open.c:
Removed some old types
Removed some not needed casts
Check argument of my_write()/my_pwrite() in functions returning int
Added casting of string lengths to size_t
storage/myisam/mi_packrec.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_page.c:
Removed some old types
storage/myisam/mi_preload.c:
Removed some old types
storage/myisam/mi_range.c:
Removed some old types
storage/myisam/mi_rfirst.c:
Removed some old types
storage/myisam/mi_rkey.c:
Removed some old types
storage/myisam/mi_rlast.c:
Removed some old types
storage/myisam/mi_rnext.c:
Removed some old types
storage/myisam/mi_rnext_same.c:
Removed some old types
storage/myisam/mi_rprev.c:
Removed some old types
storage/myisam/mi_rrnd.c:
Removed some old types
storage/myisam/mi_rsame.c:
Removed some old types
storage/myisam/mi_rsamepos.c:
Removed some old types
storage/myisam/mi_scan.c:
Removed some old types
storage/myisam/mi_search.c:
Removed some old types
storage/myisam/mi_static.c:
Removed some old types
storage/myisam/mi_statrec.c:
Removed some old types
storage/myisam/mi_test1.c:
Removed some old types
storage/myisam/mi_test2.c:
Removed some old types
storage/myisam/mi_test3.c:
Removed some old types
storage/myisam/mi_unique.c:
Removed some old types
storage/myisam/mi_update.c:
Removed some old types
storage/myisam/mi_write.c:
Removed some old types
storage/myisam/myisam_ftdump.c:
Removed some old types
storage/myisam/myisamchk.c:
Removed some old types
storage/myisam/myisamdef.h:
Removed some old types
storage/myisam/myisamlog.c:
Removed some old types
Indentation fix
storage/myisam/myisampack.c:
Removed some old types
storage/myisam/rt_index.c:
Removed some old types
storage/myisam/rt_split.c:
Removed some old types
storage/myisam/sort.c:
Removed some old types
storage/myisam/sp_defs.h:
Removed some old types
storage/myisam/sp_key.c:
Removed some old types
storage/myisammrg/ha_myisammrg.cc:
Removed some old types
storage/myisammrg/ha_myisammrg.h:
Removed some old types
storage/myisammrg/myrg_close.c:
Removed some old types
storage/myisammrg/myrg_def.h:
Removed some old types
storage/myisammrg/myrg_delete.c:
Removed some old types
storage/myisammrg/myrg_open.c:
Removed some old types
Updated parameters to dirname_part()
storage/myisammrg/myrg_queue.c:
Removed some old types
storage/myisammrg/myrg_rfirst.c:
Removed some old types
storage/myisammrg/myrg_rkey.c:
Removed some old types
storage/myisammrg/myrg_rlast.c:
Removed some old types
storage/myisammrg/myrg_rnext.c:
Removed some old types
storage/myisammrg/myrg_rnext_same.c:
Removed some old types
storage/myisammrg/myrg_rprev.c:
Removed some old types
storage/myisammrg/myrg_rrnd.c:
Removed some old types
storage/myisammrg/myrg_rsame.c:
Removed some old types
storage/myisammrg/myrg_update.c:
Removed some old types
storage/myisammrg/myrg_write.c:
Removed some old types
storage/ndb/include/util/ndb_opts.h:
Removed some old types
storage/ndb/src/cw/cpcd/main.cpp:
Removed some old types
storage/ndb/src/kernel/vm/Configuration.cpp:
Removed some old types
storage/ndb/src/mgmclient/main.cpp:
Removed some old types
storage/ndb/src/mgmsrv/InitConfigFileParser.cpp:
Removed some old types
Removed old disabled code
storage/ndb/src/mgmsrv/main.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbBlob.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
Removed not used variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
Added required casts
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Added required casts
storage/ndb/tools/delete_all.cpp:
Removed some old types
storage/ndb/tools/desc.cpp:
Removed some old types
storage/ndb/tools/drop_index.cpp:
Removed some old types
storage/ndb/tools/drop_tab.cpp:
Removed some old types
storage/ndb/tools/listTables.cpp:
Removed some old types
storage/ndb/tools/ndb_config.cpp:
Removed some old types
storage/ndb/tools/restore/consumer_restore.cpp:
Changed some buffers to be uchar* to avoid casts with new defintion of packfrm()
storage/ndb/tools/restore/restore_main.cpp:
Removed some old types
storage/ndb/tools/select_all.cpp:
Removed some old types
storage/ndb/tools/select_count.cpp:
Removed some old types
storage/ndb/tools/waiter.cpp:
Removed some old types
strings/bchange.c:
Changed function to use uchar * and size_t
strings/bcmp.c:
Changed function to use uchar * and size_t
strings/bmove512.c:
Changed function to use uchar * and size_t
strings/bmove_upp.c:
Changed function to use uchar * and size_t
strings/ctype-big5.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-bin.c:
Changed functions to use size_t
strings/ctype-cp932.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-czech.c:
Fixed indentation
Changed functions to use size_t
strings/ctype-euc_kr.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-eucjpms.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-gb2312.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-gbk.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-latin1.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-mb.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-simple.c:
Changed functions to use size_t
Simpler loops for caseup/casedown
unsigned int -> uint
unsigned char -> uchar
strings/ctype-sjis.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-tis620.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-uca.c:
Changed functions to use size_t
unsigned char -> uchar
strings/ctype-ucs2.c:
Moved inclusion of stdarg.h to other includes
usigned char -> uchar
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-ujis.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-utf8.c:
Changed functions to use size_t
unsigned char -> uchar
Indentation fixes
strings/ctype-win1250ch.c:
Indentation fixes
Changed functions to use size_t
strings/ctype.c:
Changed functions to use size_t
strings/decimal.c:
Changed type for memory argument to uchar *
strings/do_ctype.c:
Indentation fixes
strings/my_strtoll10.c:
unsigned char -> uchar
strings/my_vsnprintf.c:
Changed functions to use size_t
strings/r_strinstr.c:
Removed some old types
Changed functions to use size_t
strings/str_test.c:
Removed some old types
strings/strappend.c:
Changed functions to use size_t
strings/strcont.c:
Removed some old types
strings/strfill.c:
Removed some old types
strings/strinstr.c:
Changed functions to use size_t
strings/strlen.c:
Changed functions to use size_t
strings/strmake.c:
Changed functions to use size_t
strings/strnlen.c:
Changed functions to use size_t
strings/strnmov.c:
Changed functions to use size_t
strings/strto.c:
unsigned char -> uchar
strings/strtod.c:
Changed functions to use size_t
strings/strxnmov.c:
Changed functions to use size_t
strings/xml.c:
Changed functions to use size_t
Indentation fixes
tests/mysql_client_test.c:
Removed some old types
tests/thread_test.c:
Removed some old types
vio/test-ssl.c:
Removed some old types
vio/test-sslclient.c:
Removed some old types
vio/test-sslserver.c:
Removed some old types
vio/vio.c:
Removed some old types
vio/vio_priv.h:
Removed some old types
Changed vio_read()/vio_write() to work with size_t
vio/viosocket.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viossl.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viosslfactories.c:
Removed some old types
vio/viotest-ssl.c:
Removed some old types
win/README:
More explanations
2007-05-10 11:59:39 +02:00
|
|
|
char *start=0;
|
2003-05-02 18:07:41 +02:00
|
|
|
MYSQL_ROW end;
|
2003-07-23 12:23:20 +02:00
|
|
|
|
|
|
|
prev_length=0; /* Keep gcc happy */
|
|
|
|
for (end=column + field_count + 1 ; column != end ; column++, to++)
|
|
|
|
{
|
|
|
|
if (!*column)
|
|
|
|
{
|
|
|
|
*to= 0; /* Null */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (start) /* Found end of prev string */
|
|
|
|
*prev_length= (ulong) (*column-start-1);
|
|
|
|
start= *column;
|
|
|
|
prev_length= to;
|
|
|
|
}
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
Change field rows to field structs
|
|
|
|
***************************************************************************/
|
|
|
|
|
2003-05-31 12:15:46 +02:00
|
|
|
MYSQL_FIELD *
|
2012-06-28 17:38:55 +02:00
|
|
|
unpack_fields(MYSQL *mysql, MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
|
2003-05-02 18:07:41 +02:00
|
|
|
my_bool default_value, uint server_capabilities)
|
|
|
|
{
|
|
|
|
MYSQL_ROWS *row;
|
|
|
|
MYSQL_FIELD *field,*result;
|
2003-05-31 12:15:46 +02:00
|
|
|
ulong lengths[9]; /* Max of fields */
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_ENTER("unpack_fields");
|
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
field= result= (MYSQL_FIELD*) alloc_root(alloc,
|
|
|
|
(uint) sizeof(*field)*fields);
|
2003-05-02 18:07:41 +02:00
|
|
|
if (!result)
|
|
|
|
{
|
|
|
|
free_rows(data); /* Free old data */
|
2012-06-28 17:38:55 +02:00
|
|
|
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
bzero((char*) field, (uint) sizeof(MYSQL_FIELD)*fields);
|
|
|
|
if (server_capabilities & CLIENT_PROTOCOL_41)
|
|
|
|
{
|
|
|
|
/* server is 4.1, and returns the new field result format */
|
|
|
|
for (row=data->data; row ; row = row->next,field++)
|
|
|
|
{
|
|
|
|
uchar *pos;
|
2006-11-13 11:28:55 +01:00
|
|
|
/* fields count may be wrong */
|
2018-05-10 13:01:42 +02:00
|
|
|
if (field >= result + fields)
|
2018-05-04 00:09:45 +02:00
|
|
|
goto err;
|
|
|
|
|
2003-07-23 12:23:20 +02:00
|
|
|
cli_fetch_lengths(&lengths[0], row->data, default_value ? 8 : 7);
|
2007-07-20 13:05:55 +02:00
|
|
|
field->catalog= strmake_root(alloc,(char*) row->data[0], lengths[0]);
|
|
|
|
field->db= strmake_root(alloc,(char*) row->data[1], lengths[1]);
|
|
|
|
field->table= strmake_root(alloc,(char*) row->data[2], lengths[2]);
|
|
|
|
field->org_table= strmake_root(alloc,(char*) row->data[3], lengths[3]);
|
|
|
|
field->name= strmake_root(alloc,(char*) row->data[4], lengths[4]);
|
|
|
|
field->org_name= strmake_root(alloc,(char*) row->data[5], lengths[5]);
|
2003-05-31 12:15:46 +02:00
|
|
|
|
|
|
|
field->catalog_length= lengths[0];
|
|
|
|
field->db_length= lengths[1];
|
|
|
|
field->table_length= lengths[2];
|
|
|
|
field->org_table_length= lengths[3];
|
|
|
|
field->name_length= lengths[4];
|
|
|
|
field->org_name_length= lengths[5];
|
2003-05-02 18:07:41 +02:00
|
|
|
|
|
|
|
/* Unpack fixed length parts */
|
2012-06-28 17:38:55 +02:00
|
|
|
if (lengths[6] != 12)
|
2018-05-04 00:09:45 +02:00
|
|
|
goto err;
|
2012-06-28 17:38:55 +02:00
|
|
|
|
2003-05-31 12:15:46 +02:00
|
|
|
pos= (uchar*) row->data[6];
|
2003-05-02 18:07:41 +02:00
|
|
|
field->charsetnr= uint2korr(pos);
|
2003-05-31 12:15:46 +02:00
|
|
|
field->length= (uint) uint4korr(pos+2);
|
|
|
|
field->type= (enum enum_field_types) pos[6];
|
|
|
|
field->flags= uint2korr(pos+7);
|
|
|
|
field->decimals= (uint) pos[9];
|
2003-05-02 18:07:41 +02:00
|
|
|
|
2009-09-30 12:25:50 +02:00
|
|
|
if (IS_NUM(field->type))
|
2003-05-02 18:07:41 +02:00
|
|
|
field->flags|= NUM_FLAG;
|
2003-05-31 12:15:46 +02:00
|
|
|
if (default_value && row->data[7])
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2007-07-20 13:05:55 +02:00
|
|
|
field->def=strmake_root(alloc,(char*) row->data[7], lengths[7]);
|
2003-05-31 12:15:46 +02:00
|
|
|
field->def_length= lengths[7];
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
field->def=0;
|
|
|
|
field->max_length= 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifndef DELETE_SUPPORT_OF_4_0_PROTOCOL
|
|
|
|
else
|
2003-06-14 10:37:42 +02:00
|
|
|
{
|
|
|
|
/* old protocol, for backward compatibility */
|
|
|
|
for (row=data->data; row ; row = row->next,field++)
|
|
|
|
{
|
2018-05-10 13:01:42 +02:00
|
|
|
if (field >= result + fields)
|
2018-05-04 00:09:45 +02:00
|
|
|
goto err;
|
2019-12-26 11:59:04 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
If any of the row->data[] below is NULL, it can result in a
|
|
|
|
crash. Error out early as it indicates a malformed packet.
|
|
|
|
For data[0], data[1] and data[5], strmake_root will handle
|
|
|
|
NULL values.
|
|
|
|
*/
|
|
|
|
if (!row->data[2] || !row->data[3] || !row->data[4])
|
|
|
|
{
|
|
|
|
free_rows(data);
|
|
|
|
set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate);
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
2003-07-23 12:23:20 +02:00
|
|
|
cli_fetch_lengths(&lengths[0], row->data, default_value ? 6 : 5);
|
2019-12-26 11:59:04 +01:00
|
|
|
field->org_table= field->table= strmake_root(alloc,(char*) row->data[0], lengths[0]);
|
|
|
|
field->name= strmake_root(alloc,(char*) row->data[1], lengths[1]);
|
2003-06-14 10:37:42 +02:00
|
|
|
field->length= (uint) uint3korr(row->data[2]);
|
|
|
|
field->type= (enum enum_field_types) (uchar) row->data[3][0];
|
|
|
|
|
|
|
|
field->catalog=(char*) "";
|
|
|
|
field->db= (char*) "";
|
|
|
|
field->catalog_length= 0;
|
|
|
|
field->db_length= 0;
|
|
|
|
field->org_table_length= field->table_length= lengths[0];
|
|
|
|
field->name_length= lengths[1];
|
|
|
|
|
|
|
|
if (server_capabilities & CLIENT_LONG_FLAG)
|
|
|
|
{
|
|
|
|
field->flags= uint2korr(row->data[4]);
|
|
|
|
field->decimals=(uint) (uchar) row->data[4][2];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
field->flags= (uint) (uchar) row->data[4][0];
|
|
|
|
field->decimals=(uint) (uchar) row->data[4][1];
|
|
|
|
}
|
2009-09-30 12:25:50 +02:00
|
|
|
if (IS_NUM(field->type))
|
2003-06-14 10:37:42 +02:00
|
|
|
field->flags|= NUM_FLAG;
|
|
|
|
if (default_value && row->data[5])
|
|
|
|
{
|
2019-12-26 11:59:04 +01:00
|
|
|
field->def= strmake_root(alloc,(char*) row->data[5], lengths[5]);
|
2003-06-14 10:37:42 +02:00
|
|
|
field->def_length= lengths[5];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
field->def=0;
|
|
|
|
field->max_length= 0;
|
|
|
|
}
|
|
|
|
}
|
2003-05-02 18:07:41 +02:00
|
|
|
#endif /* DELETE_SUPPORT_OF_4_0_PROTOCOL */
|
2018-05-10 13:01:42 +02:00
|
|
|
if (field < result + fields)
|
2018-05-04 00:09:45 +02:00
|
|
|
goto err;
|
2003-05-02 18:07:41 +02:00
|
|
|
free_rows(data); /* Free old data */
|
|
|
|
DBUG_RETURN(result);
|
2018-05-04 00:09:45 +02:00
|
|
|
|
|
|
|
err:
|
|
|
|
/* malformed packet. signal an error. */
|
|
|
|
free_rows(data);
|
|
|
|
free_root(alloc, MYF(0));
|
|
|
|
set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate);
|
|
|
|
DBUG_RETURN(0);
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read all rows (fields or data) from server */
|
|
|
|
|
2003-11-20 21:06:25 +01:00
|
|
|
MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
|
|
|
|
unsigned int fields)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
uint field;
|
|
|
|
ulong pkt_len;
|
|
|
|
ulong len;
|
|
|
|
uchar *cp;
|
|
|
|
char *to, *end_to;
|
|
|
|
MYSQL_DATA *result;
|
|
|
|
MYSQL_ROWS **prev_ptr,*cur;
|
|
|
|
NET *net = &mysql->net;
|
2003-09-16 13:06:25 +02:00
|
|
|
DBUG_ENTER("cli_read_rows");
|
2003-05-02 18:07:41 +02:00
|
|
|
|
A fix and a test case for Bug#15752 "Lost connection to MySQL server
when calling a SP from C API"
The bug was caused by lack of checks for misuse in mysql_real_query.
A stored procedure always returns at least one result, which is the
status of execution of the procedure itself.
This result, or so-called OK packet, is similar to a result
returned by INSERT/UPDATE/CREATE operations: it contains the overall
status of execution, the number of affected rows and the number of
warnings. The client test program attached to the bug did not read this
result and ivnoked the next query. In turn, libmysql had no check for
such scenario and mysql_real_query was simply trying to send that query
without reading the pending response, thus messing up the communication
protocol.
The fix is to return an error from mysql_real_query when it's called
prior to retrieval of all pending results.
client/mysqlbinlog.cc:
net_safe_read -> cli_safe_read
include/mysql.h:
Remove a private function from the public header.
include/mysql_com.h:
Remove a define that is never used.
include/sql_common.h:
Add a declaration for cli_safe_read - a function that reads one packet
from the server.
libmysql/libmysql.c:
net_safe_read -> cli_safe_read
Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
using a connection which has pending result sets.
sql-common/client.c:
Actual fix for Bug#15752: if the server has pending result sets for
the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
another query. Similarly to the behaviour of mysql_use_result(),
multiple result sets block the connection and must be fetched
before it can be used for another query.
This uncovered an error in the protocol: the server doesn't drop
SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
a multi-query like SELECT 1; SELECT syntax_error; SELECT 2;
the client has no way to know that the server won't ever come to
execution of the third query and won't return any result sets for it.
For now, fix it in cli_safe_read, as a proper fix requires extension
of the client-server protocol.
sql/protocol.cc:
Remove a name that is never used.
sql/slave.cc:
net_safe_read -> cli_safe_read
tests/mysql_client_test.c:
Make 'query' a local variable to avoid name clash.
Add a test case for Bug#15752 "Lost connection to MySQL server when
calling an SP from C API"
2006-07-24 12:56:53 +02:00
|
|
|
if ((pkt_len= cli_safe_read(mysql)) == packet_error)
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(0);
|
2018-06-14 16:27:54 +02:00
|
|
|
if (pkt_len == 0) DBUG_RETURN(0);
|
2003-05-02 18:07:41 +02:00
|
|
|
if (!(result=(MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
|
|
|
|
MYF(MY_WME | MY_ZEROFILL))))
|
|
|
|
{
|
2004-03-12 13:21:48 +01:00
|
|
|
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
MDEV-4011 Added per thread memory counting and usage
Base code and idea from a patch from by plinux at Taobao.
The idea is that we mark all memory that are thread specific with MY_THREAD_SPECIFIC.
Memory counting is done per thread in the my_malloc_size_cb_func callback function from my_malloc().
There are plenty of new asserts to ensure that for a debug server the counting is correct.
Information_schema.processlist gets two new columns: MEMORY_USED and EXAMINED_ROWS.
- The later is there mainly to show how query is progressing.
The following changes in interfaces was needed to get this to work:
- init_alloc_root() amd init_sql_alloc() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- One now have to use alloc_root_set_min_malloc() to set min memory to be allocated by alloc_root()
- my_init_dynamic_array() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- my_net_init() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
- Added flag for hash_init() so that one can mark hash table to be thread specific.
- Added flags to init_tree() so that one can mark tree to be thread specific.
- Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
- Added flag to Warning_info::Warning_info() if the structure should be fully initialized.
- String elements can now be marked as thread specific.
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Changed type of myf from int to ulong, as this is always a set of bit flags.
Other things:
- Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
- We now also show EXAMINED_ROWS in SHOW PROCESSLIST
- Added new variable 'memory_used'
- Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
- Removed calls to the obsoleted function init_dynamic_array()
- Use set_current_thd() instead of my_pthread_setspecific_ptr(THR_THD,...)
client/completion_hash.cc:
Updated call to init_alloc_root()
client/mysql.cc:
Updated call to init_alloc_root()
client/mysqlbinlog.cc:
init_dynamic_array() -> my_init_dynamic_array()
Updated call to init_alloc_root()
client/mysqlcheck.c:
Updated call to my_init_dynamic_array()
client/mysqldump.c:
Updated call to init_alloc_root()
client/mysqltest.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Fixed compiler warnings
extra/comp_err.c:
Updated call to my_init_dynamic_array()
extra/resolve_stack_dump.c:
Updated call to my_init_dynamic_array()
include/hash.h:
Added HASH_THREAD_SPECIFIC
include/heap.h:
Added flag is internal temporary table.
include/my_dir.h:
Safety fix: Ensure that MY_DONT_SORT and MY_WANT_STAT don't interfer with other mysys flags
include/my_global.h:
Changed type of myf from int to ulong, as this is always a set of bit flags.
include/my_sys.h:
Added MY_THREAD_SPECIFIC and MY_THREAD_MOVE
Added malloc_flags to DYNAMIC_ARRAY
Added extra mysys flag argument to my_init_dynamic_array()
Removed deprecated functions init_dynamic_array() and my_init_dynamic_array.._ci
Updated paramaters for init_alloc_root()
include/my_tree.h:
Added my_flags to allow one to use MY_THREAD_SPECIFIC with hash tables.
Removed with_delete. One should now instead use MY_TREE_WITH_DELETE_FLAG
Updated parameters to init_tree()
include/myisamchk.h:
Added malloc_flags to allow one to use MY_THREAD_SPECIFIC for checks.
include/mysql.h:
Added MYSQL_THREAD_SPECIFIC_MALLOC
Used 'unused1' to mark memory as thread specific.
include/mysql.h.pp:
Updated file
include/mysql_com.h:
Used 'unused1' to mark memory as thread specific.
Updated parameters for my_net_init()
libmysql/libmysql.c:
Updated call to init_alloc_root() to mark memory thread specific.
libmysqld/emb_qcache.cc:
Updated call to init_alloc_root()
libmysqld/lib_sql.cc:
Updated call to init_alloc_root()
mysql-test/r/create.result:
Updated results
mysql-test/r/user_var.result:
Updated results
mysql-test/suite/funcs_1/datadict/processlist_priv.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/datadict/processlist_val.inc:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/is_columns_is.result:
Update to handle new format of SHOW PROCESSLIST
mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result:
Updated results
mysql-test/suite/funcs_1/r/processlist_val_no_prot.result:
Updated results
mysql-test/t/show_explain.test:
Fixed usage of debug variable so that one can run test with --debug
mysql-test/t/user_var.test:
Added test of memory_usage variable.
mysys/array.c:
Added extra my_flags option to init_dynamic_array() and init_dynamic_array2() so that one can mark memory with MY_THREAD_SPECIFIC
All allocated memory is marked with the given my_flags.
Removed obsolete function init_dynamic_array()
mysys/default.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
mysys/hash.c:
Updated call to my_init_dynamic_array_ci().
Allocated memory is marked with MY_THREAD_SPECIFIC if HASH_THREAD_SPECIFIC is used.
mysys/ma_dyncol.c:
init_dynamic_array() -> my_init_dynamic_array()
Added #if to get rid of compiler warnings
mysys/mf_tempdir.c:
Updated call to my_init_dynamic_array()
mysys/my_alloc.c:
Added extra parameter to init_alloc_root() so that one can mark memory with MY_THREAD_SPECIFIC
Extend MEM_ROOT with a flag if memory is thread specific.
This is stored in block_size, to keep the size of the MEM_ROOT object identical as before.
Allocated memory is marked with MY_THREAD_SPECIFIC if used with init_alloc_root()
mysys/my_chmod.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_chsize.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_copy.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_create.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_delete.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_error.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fopen.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_fstream.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_getwd.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_lib.c:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Updated DBUG_PRINT because of change of myf type
mysys/my_lock.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_malloc.c:
Store at start of each allocated memory block the size of the block and if the block is thread specific.
Call malloc_size_cb_func, if set, with the memory allocated/freed.
Updated DBUG_PRINT because of change of myf type
mysys/my_open.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_pread.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_read.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_redel.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_rename.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_seek.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_sync.c:
Updated DBUG_PRINT because of change of myf type
mysys/my_thr_init.c:
Ensure that one can call my_thread_dbug_id() even if thread is not properly initialized.
mysys/my_write.c:
Updated DBUG_PRINT because of change of myf type
mysys/mysys_priv.h:
Updated parameters to sf_malloc and sf_realloc()
mysys/safemalloc.c:
Added checking that for memory marked with MY_THREAD_SPECIFIC that it's the same thread that is allocation and freeing the memory.
Added sf_malloc_dbug_id() to allow MariaDB to specify which THD is handling the memory.
Added my_flags arguments to sf_malloc() and sf_realloc() to be able to mark memory with MY_THREAD_SPECIFIC.
Added sf_report_leaked_memory() to get list of memory not freed by a thread.
mysys/tree.c:
Added flags to init_tree() so that one can mark tree to be thread specific.
Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
Updated call to init_alloc_root()
All allocated memory is marked with the given malloc flags
mysys/waiting_threads.c:
Updated call to my_init_dynamic_array()
sql-common/client.c:
Updated call to init_alloc_root() and my_net_init() to mark memory thread specific.
Updated call to my_init_dynamic_array().
Added MYSQL_THREAD_SPECIFIC_MALLOC so that client can mark memory as MY_THREAD_SPECIFIC.
sql-common/client_plugin.c:
Updated call to init_alloc_root()
sql/debug_sync.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/event_scheduler.cc:
Removed calls to net_end() as this is now done in ~THD()
Call set_current_thd() to ensure that memory is assigned to right thread.
sql/events.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/filesort.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/filesort_utils.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/ha_ndbcluster.cc:
Updated call to init_alloc_root()
Updated call to my_net_init()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_ndbcluster_binlog.cc:
Updated call to my_net_init()
Updated call to init_sql_alloc()
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
sql/ha_partition.cc:
Updated call to init_alloc_root()
sql/handler.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
Added missing call to my_dir_end()
sql/item_func.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_subselect.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/item_sum.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/log.cc:
More DBUG
Updated call to init_alloc_root()
sql/mdl.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/mysqld.cc:
Added total_memory_used
Updated call to init_alloc_root()
Move mysql_cond_broadcast() before my_thread_end()
Added mariadb_dbug_id() to count memory per THD instead of per thread.
Added my_malloc_size_cb_func() callback function for my_malloc() to count memory.
Move initialization of mysqld_server_started and mysqld_server_initialized earlier.
Updated call to my_init_dynamic_array().
Updated call to my_net_init().
Call my_pthread_setspecific_ptr(THR_THD,...) to ensure that memory is assigned to right thread.
Added status variable 'memory_used'.
Updated call to init_alloc_root()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/mysqld.h:
Added set_current_thd()
sql/net_serv.cc:
Added new parameter to my_net_init() so that one can mark memory with MY_THREAD_SPECIFIC.
Store in net->thread_specific_malloc if memory is thread specific.
Mark memory to be thread specific if requested.
sql/opt_range.cc:
Updated call to my_init_dynamic_array()
Updated call to init_sql_alloc()
Added MY_THREAD_SPECIFIC to allocated memory.
sql/opt_subselect.cc:
Updated call to init_sql_alloc() to mark memory thread specific.
sql/protocol.cc:
Fixed compiler warning
sql/records.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/rpl_filter.cc:
Updated call to my_init_dynamic_array()
sql/rpl_handler.cc:
Updated call to my_init_dynamic_array2()
sql/rpl_handler.h:
Updated call to init_sql_alloc()
sql/rpl_mi.cc:
Updated call to my_init_dynamic_array()
sql/rpl_tblmap.cc:
Updated call to init_alloc_root()
sql/rpl_utility.cc:
Updated call to my_init_dynamic_array()
sql/slave.cc:
Initialize things properly before calling functions that allocate memory.
Removed calls to net_end() as this is now done in ~THD()
sql/sp_head.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
Added parameter to warning_info() that it should be fully initialized.
sql/sp_pcontext.cc:
Updated call to my_init_dynamic_array()
sql/sql_acl.cc:
Updated call to init_sql_alloc()
Updated call to my_init_dynamic_array()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_admin.cc:
Added parameter to warning_info() that it should be fully initialized.
sql/sql_analyse.h:
Updated call to init_tree() to mark memory thread specific.
sql/sql_array.h:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_audit.cc:
Updated call to my_init_dynamic_array()
sql/sql_base.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_cache.cc:
Updated comment
sql/sql_class.cc:
Added parameter to warning_info() that not initialize it until THD is fully created.
Updated call to init_sql_alloc()
Mark THD::user_vars has to be thread specific.
Updated call to my_init_dynamic_array()
Ensure that memory allocated by THD is assigned to the THD.
More DBUG
Always acll net_end() in ~THD()
Assert that all memory signed to this THD is really deleted at ~THD.
Fixed set_status_var_init() to not reset memory_used.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_class.h:
Added MY_THREAD_SPECIFIC to allocated memory.
Added malloc_size to THD to record allocated memory per THD.
sql/sql_delete.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_error.cc:
Added 'initialize' parameter to Warning_info() to say if should allocate memory for it's structures.
This is used by THD::THD() to not allocate memory until THD is ready.
Added Warning_info::free_memory()
sql/sql_error.h:
Updated Warning_info() class.
sql/sql_handler.cc:
Updated call to init_alloc_root() to mark memory thread specific.
sql/sql_insert.cc:
More DBUG
sql/sql_join_cache.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_lex.cc:
Updated call to my_init_dynamic_array()
sql/sql_lex.h:
Updated call to my_init_dynamic_array()
sql/sql_load.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/sql_parse.cc:
Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
Ensure that examined_row_count() is reset before query.
Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Don't restore thd->status_var.memory_used when restoring thd->status_var
sql/sql_plugin.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Don't allocate THD on the stack, as this causes problems with valgrind when doing thd memory counting.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_prepare.cc:
Added parameter to warning_info() that it should be fully initialized.
Updated call to init_sql_alloc() to mark memory thread specific.
sql/sql_reload.cc:
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_select.cc:
Updated call to my_init_dynamic_array() and init_sql_alloc() to mark memory thread specific.
Added MY_THREAD_SPECIFIC to allocated memory.
More DBUG
sql/sql_servers.cc:
Updated call to init_sql_alloc() to mark memory some memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_show.cc:
Updated call to my_init_dynamic_array()
Mark my_dir() memory thread specific.
Use my_pthread_setspecific_ptr(THR_THD,...) to mark that allocated memory should be allocated to calling thread.
More DBUG.
Added malloc_size and examined_row_count to SHOW PROCESSLIST.
Added MY_THREAD_SPECIFIC to allocated memory.
Updated call to init_sql_alloc()
Added parameter to warning_info() that it should be fully initialized.
sql/sql_statistics.cc:
Fixed compiler warning
sql/sql_string.cc:
String elements can now be marked as thread specific.
sql/sql_string.h:
String elements can now be marked as thread specific.
sql/sql_table.cc:
Updated call to init_sql_alloc() and my_malloc() to mark memory thread specific
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
Fixed compiler warning
sql/sql_test.cc:
Updated call to my_init_dynamic_array() to mark memory thread specific.
sql/sql_trigger.cc:
Updated call to init_sql_alloc()
sql/sql_udf.cc:
Updated call to init_sql_alloc()
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/sql_update.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
sql/table.cc:
Updated call to init_sql_alloc().
Mark memory used by temporary tables, that are not for slave threads, as MY_THREAD_SPECIFIC
Updated call to init_sql_alloc()
sql/thr_malloc.cc:
Added my_flags argument to init_sql_alloc() to be able to mark memory as MY_THREAD_SPECIFIC.
sql/thr_malloc.h:
Updated prototype for init_sql_alloc()
sql/tztime.cc:
Updated call to init_sql_alloc()
Updated call to init_alloc_root() to mark memory thread specific.
my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
sql/uniques.cc:
Updated calls to init_tree(), my_init_dynamic_array() and my_malloc() to mark memory thread specific.
sql/unireg.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/csv/ha_tina.cc:
Updated call to init_alloc_root()
storage/federated/ha_federated.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
Ensure that memory allocated by fedarated is registered for the system, not for the thread.
storage/federatedx/federatedx_io_mysql.cc:
Updated call to my_init_dynamic_array()
storage/federatedx/ha_federatedx.cc:
Updated call to init_alloc_root()
Updated call to my_init_dynamic_array()
storage/heap/ha_heap.cc:
Added MY_THREAD_SPECIFIC to allocated memory.
storage/heap/heapdef.h:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_block.c:
Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
storage/heap/hp_create.c:
- Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
- Use MY_TREE_WITH_DELETE instead of removed option 'with_delete'.
storage/heap/hp_open.c:
Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
storage/heap/hp_write.c:
Added new parameter to hp_get_new_block()
storage/maria/ma_bitmap.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_blockrec.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_check.c:
Updated call to init_alloc_root()
storage/maria/ma_ft_boolean_search.c:
Updated calls to init_tree() and init_alloc_root()
storage/maria/ma_ft_nlq_search.c:
Updated call to init_tree()
storage/maria/ma_ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/maria/ma_loghandler.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_open.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_sort.c:
Updated call to my_init_dynamic_array()
storage/maria/ma_write.c:
Updated calls to my_init_dynamic_array() and init_tree()
storage/maria/maria_pack.c:
Updated call to init_tree()
storage/maria/unittest/sequence_storage.c:
Updated call to my_init_dynamic_array()
storage/myisam/ft_boolean_search.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_nlq_search.c:
Updated call to init_tree()
storage/myisam/ft_parser.c:
Updated call to init_tree()
Updated call to init_alloc_root()
storage/myisam/ft_stopwords.c:
Updated call to init_tree()
storage/myisam/mi_check.c:
Updated call to init_alloc_root()
storage/myisam/mi_write.c:
Updated call to my_init_dynamic_array()
Updated call to init_tree()
storage/myisam/myisamlog.c:
Updated call to init_tree()
storage/myisam/myisampack.c:
Updated call to init_tree()
storage/myisam/sort.c:
Updated call to my_init_dynamic_array()
storage/myisammrg/ha_myisammrg.cc:
Updated call to init_sql_alloc()
storage/perfschema/pfs_check.cc:
Rest current_thd
storage/perfschema/pfs_instr.cc:
Removed DBUG_ENTER/DBUG_VOID_RETURN as at this point my_thread_var is not allocated anymore, which can cause problems.
support-files/compiler_warnings.supp:
Disable compiler warning from offsetof macro.
2013-01-23 16:16:14 +01:00
|
|
|
/* Assume rowlength < 8192 */
|
2018-02-02 10:08:36 +01:00
|
|
|
init_alloc_root(&result->alloc, "result", 8192, 0,
|
2013-04-17 22:37:06 +02:00
|
|
|
MYF(mysql->options.use_thread_specific_memory ?
|
|
|
|
MY_THREAD_SPECIFIC : 0));
|
2003-05-02 18:07:41 +02:00
|
|
|
result->alloc.min_malloc=sizeof(MYSQL_ROWS);
|
|
|
|
prev_ptr= &result->data;
|
|
|
|
result->rows=0;
|
|
|
|
result->fields=fields;
|
|
|
|
|
|
|
|
/*
|
|
|
|
The last EOF packet is either a single 254 character or (in MySQL 4.1)
|
|
|
|
254 followed by 1-7 status bytes.
|
|
|
|
|
|
|
|
This doesn't conflict with normal usage of 254 which stands for a
|
|
|
|
string where the length of the string is 8 bytes. (see net_field_length())
|
|
|
|
*/
|
|
|
|
|
|
|
|
while (*(cp=net->read_pos) != 254 || pkt_len >= 8)
|
|
|
|
{
|
|
|
|
result->rows++;
|
|
|
|
if (!(cur= (MYSQL_ROWS*) alloc_root(&result->alloc,
|
|
|
|
sizeof(MYSQL_ROWS))) ||
|
|
|
|
!(cur->data= ((MYSQL_ROW)
|
|
|
|
alloc_root(&result->alloc,
|
|
|
|
(fields+1)*sizeof(char *)+pkt_len))))
|
|
|
|
{
|
|
|
|
free_rows(result);
|
2004-03-12 13:21:48 +01:00
|
|
|
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
*prev_ptr=cur;
|
|
|
|
prev_ptr= &cur->next;
|
|
|
|
to= (char*) (cur->data+fields+1);
|
|
|
|
end_to=to+pkt_len-1;
|
|
|
|
for (field=0 ; field < fields ; field++)
|
|
|
|
{
|
|
|
|
if ((len=(ulong) net_field_length(&cp)) == NULL_LENGTH)
|
|
|
|
{ /* null field */
|
|
|
|
cur->data[field] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cur->data[field] = to;
|
2018-04-30 13:50:59 +02:00
|
|
|
if (unlikely(len > (ulong)(end_to-to) || to > end_to))
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
free_rows(result);
|
2004-03-12 13:21:48 +01:00
|
|
|
set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
memcpy(to,(char*) cp,len); to[len]=0;
|
|
|
|
to+=len+1;
|
|
|
|
cp+=len;
|
|
|
|
if (mysql_fields)
|
|
|
|
{
|
|
|
|
if (mysql_fields[field].max_length < len)
|
|
|
|
mysql_fields[field].max_length=len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cur->data[field]=to; /* End of last field */
|
A fix and a test case for Bug#15752 "Lost connection to MySQL server
when calling a SP from C API"
The bug was caused by lack of checks for misuse in mysql_real_query.
A stored procedure always returns at least one result, which is the
status of execution of the procedure itself.
This result, or so-called OK packet, is similar to a result
returned by INSERT/UPDATE/CREATE operations: it contains the overall
status of execution, the number of affected rows and the number of
warnings. The client test program attached to the bug did not read this
result and ivnoked the next query. In turn, libmysql had no check for
such scenario and mysql_real_query was simply trying to send that query
without reading the pending response, thus messing up the communication
protocol.
The fix is to return an error from mysql_real_query when it's called
prior to retrieval of all pending results.
client/mysqlbinlog.cc:
net_safe_read -> cli_safe_read
include/mysql.h:
Remove a private function from the public header.
include/mysql_com.h:
Remove a define that is never used.
include/sql_common.h:
Add a declaration for cli_safe_read - a function that reads one packet
from the server.
libmysql/libmysql.c:
net_safe_read -> cli_safe_read
Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
using a connection which has pending result sets.
sql-common/client.c:
Actual fix for Bug#15752: if the server has pending result sets for
the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
another query. Similarly to the behaviour of mysql_use_result(),
multiple result sets block the connection and must be fetched
before it can be used for another query.
This uncovered an error in the protocol: the server doesn't drop
SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
a multi-query like SELECT 1; SELECT syntax_error; SELECT 2;
the client has no way to know that the server won't ever come to
execution of the third query and won't return any result sets for it.
For now, fix it in cli_safe_read, as a proper fix requires extension
of the client-server protocol.
sql/protocol.cc:
Remove a name that is never used.
sql/slave.cc:
net_safe_read -> cli_safe_read
tests/mysql_client_test.c:
Make 'query' a local variable to avoid name clash.
Add a test case for Bug#15752 "Lost connection to MySQL server when
calling an SP from C API"
2006-07-24 12:56:53 +02:00
|
|
|
if ((pkt_len=cli_safe_read(mysql)) == packet_error)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
free_rows(result);
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*prev_ptr=0; /* last pointer is null */
|
|
|
|
if (pkt_len > 1) /* MySQL 4.1 protocol */
|
|
|
|
{
|
|
|
|
mysql->warning_count= uint2korr(cp+1);
|
2003-11-18 12:47:27 +01:00
|
|
|
mysql->server_status= uint2korr(cp+3);
|
2003-11-28 11:18:13 +01:00
|
|
|
DBUG_PRINT("info",("status: %u warning_count: %u",
|
|
|
|
mysql->server_status, mysql->warning_count));
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
2006-11-20 21:42:06 +01:00
|
|
|
DBUG_PRINT("exit", ("Got %lu rows", (ulong) result->rows));
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Read one row. Uses packet buffer as storage for fields.
|
|
|
|
When next packet is read, the previous field values are destroyed
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths)
|
|
|
|
{
|
|
|
|
uint field;
|
|
|
|
ulong pkt_len,len;
|
2003-05-31 12:15:46 +02:00
|
|
|
uchar *pos, *prev_pos, *end_pos;
|
|
|
|
NET *net= &mysql->net;
|
2003-05-02 18:07:41 +02:00
|
|
|
|
A fix and a test case for Bug#15752 "Lost connection to MySQL server
when calling a SP from C API"
The bug was caused by lack of checks for misuse in mysql_real_query.
A stored procedure always returns at least one result, which is the
status of execution of the procedure itself.
This result, or so-called OK packet, is similar to a result
returned by INSERT/UPDATE/CREATE operations: it contains the overall
status of execution, the number of affected rows and the number of
warnings. The client test program attached to the bug did not read this
result and ivnoked the next query. In turn, libmysql had no check for
such scenario and mysql_real_query was simply trying to send that query
without reading the pending response, thus messing up the communication
protocol.
The fix is to return an error from mysql_real_query when it's called
prior to retrieval of all pending results.
client/mysqlbinlog.cc:
net_safe_read -> cli_safe_read
include/mysql.h:
Remove a private function from the public header.
include/mysql_com.h:
Remove a define that is never used.
include/sql_common.h:
Add a declaration for cli_safe_read - a function that reads one packet
from the server.
libmysql/libmysql.c:
net_safe_read -> cli_safe_read
Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
using a connection which has pending result sets.
sql-common/client.c:
Actual fix for Bug#15752: if the server has pending result sets for
the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
another query. Similarly to the behaviour of mysql_use_result(),
multiple result sets block the connection and must be fetched
before it can be used for another query.
This uncovered an error in the protocol: the server doesn't drop
SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
a multi-query like SELECT 1; SELECT syntax_error; SELECT 2;
the client has no way to know that the server won't ever come to
execution of the third query and won't return any result sets for it.
For now, fix it in cli_safe_read, as a proper fix requires extension
of the client-server protocol.
sql/protocol.cc:
Remove a name that is never used.
sql/slave.cc:
net_safe_read -> cli_safe_read
tests/mysql_client_test.c:
Make 'query' a local variable to avoid name clash.
Add a test case for Bug#15752 "Lost connection to MySQL server when
calling an SP from C API"
2006-07-24 12:56:53 +02:00
|
|
|
if ((pkt_len=cli_safe_read(mysql)) == packet_error)
|
2003-05-02 18:07:41 +02:00
|
|
|
return -1;
|
2003-05-31 12:15:46 +02:00
|
|
|
if (pkt_len <= 8 && net->read_pos[0] == 254)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
if (pkt_len > 1) /* MySQL 4.1 protocol */
|
2003-11-18 12:47:27 +01:00
|
|
|
{
|
2003-05-31 12:15:46 +02:00
|
|
|
mysql->warning_count= uint2korr(net->read_pos+1);
|
2003-11-18 12:47:27 +01:00
|
|
|
mysql->server_status= uint2korr(net->read_pos+3);
|
|
|
|
}
|
2003-05-02 18:07:41 +02:00
|
|
|
return 1; /* End of data */
|
|
|
|
}
|
|
|
|
prev_pos= 0; /* allowed to write at packet[-1] */
|
2003-05-31 12:15:46 +02:00
|
|
|
pos=net->read_pos;
|
2003-05-02 18:07:41 +02:00
|
|
|
end_pos=pos+pkt_len;
|
|
|
|
for (field=0 ; field < fields ; field++)
|
|
|
|
{
|
|
|
|
if ((len=(ulong) net_field_length(&pos)) == NULL_LENGTH)
|
|
|
|
{ /* null field */
|
|
|
|
row[field] = 0;
|
|
|
|
*lengths++=0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-30 13:50:59 +02:00
|
|
|
if (unlikely(len > (ulong)(end_pos - pos) || pos > end_pos))
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2004-03-12 13:21:48 +01:00
|
|
|
set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
row[field] = (char*) pos;
|
|
|
|
pos+=len;
|
|
|
|
*lengths++=len;
|
|
|
|
}
|
|
|
|
if (prev_pos)
|
|
|
|
*prev_pos=0; /* Terminate prev field */
|
|
|
|
prev_pos=pos;
|
|
|
|
}
|
|
|
|
row[field]=(char*) prev_pos+1; /* End of last field */
|
|
|
|
*prev_pos=0; /* Terminate last field */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
Init MySQL structure or allocate one
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
MYSQL * STDCALL
|
|
|
|
mysql_init(MYSQL *mysql)
|
|
|
|
{
|
2003-12-18 12:51:22 +01:00
|
|
|
if (mysql_server_init(0, NULL, NULL))
|
|
|
|
return 0;
|
2003-05-02 18:07:41 +02:00
|
|
|
if (!mysql)
|
|
|
|
{
|
|
|
|
if (!(mysql=(MYSQL*) my_malloc(sizeof(*mysql),MYF(MY_WME | MY_ZEROFILL))))
|
2008-02-27 09:42:43 +01:00
|
|
|
{
|
|
|
|
set_mysql_error(NULL, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
return 0;
|
2008-02-27 09:42:43 +01:00
|
|
|
}
|
2003-05-02 18:07:41 +02:00
|
|
|
mysql->free_me=1;
|
|
|
|
}
|
|
|
|
else
|
2006-03-22 23:37:40 +01:00
|
|
|
bzero((char*) (mysql), sizeof(*(mysql)));
|
2003-06-14 10:37:42 +02:00
|
|
|
mysql->options.connect_timeout= CONNECT_TIMEOUT;
|
2006-06-19 19:11:01 +02:00
|
|
|
mysql->charset=default_client_charset_info;
|
2004-09-06 16:23:51 +02:00
|
|
|
strmov(mysql->net.sqlstate, not_error_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
/*
|
|
|
|
Only enable LOAD DATA INFILE by default if configured with
|
|
|
|
--enable-local-infile
|
|
|
|
*/
|
2004-03-23 01:58:49 +01:00
|
|
|
|
2019-01-25 23:12:35 +01:00
|
|
|
#if ENABLED_LOCAL_INFILE && !defined(MYSQL_SERVER)
|
2003-05-02 18:07:41 +02:00
|
|
|
mysql->options.client_flag|= CLIENT_LOCAL_FILES;
|
2019-01-25 23:12:35 +01:00
|
|
|
mysql->auto_local_infile= ENABLED_LOCAL_INFILE == LOCAL_INFILE_MODE_AUTO
|
|
|
|
? WAIT_FOR_QUERY : ALWAYS_ACCEPT;
|
2003-05-02 18:07:41 +02:00
|
|
|
#endif
|
2004-03-23 01:58:49 +01:00
|
|
|
|
2003-06-18 12:58:57 +02:00
|
|
|
mysql->options.methods_to_use= MYSQL_OPT_GUESS_CONNECTION;
|
2004-12-17 22:17:25 +01:00
|
|
|
mysql->options.report_data_truncation= TRUE; /* default */
|
2006-01-26 11:20:59 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
By default we don't reconnect because it could silently corrupt data (after
|
|
|
|
reconnection you potentially lose table locks, user variables, session
|
|
|
|
variables (transactions but they are specifically dealt with in
|
|
|
|
mysql_reconnect()).
|
|
|
|
This is a change: < 5.0.3 mysql->reconnect was set to 1 by default.
|
|
|
|
How this change impacts existing apps:
|
|
|
|
- existing apps which relyed on the default will see a behaviour change;
|
|
|
|
they will have to set reconnect=1 after mysql_real_connect().
|
2016-06-08 13:14:42 +02:00
|
|
|
- existing apps which explicitly asked for reconnection (the only way they
|
2006-01-26 11:20:59 +01:00
|
|
|
could do it was by setting mysql.reconnect to 1 after mysql_real_connect())
|
|
|
|
will not see a behaviour change.
|
2016-06-08 13:14:42 +02:00
|
|
|
- existing apps which explicitly asked for no reconnection
|
2006-01-26 11:20:59 +01:00
|
|
|
(mysql.reconnect=0) will not see a behaviour change.
|
|
|
|
*/
|
|
|
|
mysql->reconnect= 0;
|
|
|
|
|
2017-09-19 19:45:17 +02:00
|
|
|
DBUG_PRINT("mysql",("mysql: %p", mysql));
|
2003-05-02 18:07:41 +02:00
|
|
|
return mysql;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-08-14 16:23:34 +02:00
|
|
|
Fill in SSL part of MYSQL structure.
|
2003-06-14 10:37:42 +02:00
|
|
|
NB! Errors are not reported until you do mysql_real_connect.
|
2012-08-14 16:23:34 +02:00
|
|
|
use_ssl is set in send_client_reply_packet if any ssl option is set.
|
2003-05-02 18:07:41 +02:00
|
|
|
*/
|
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
my_bool STDCALL
|
|
|
|
mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
|
|
|
|
const char *key __attribute__((unused)),
|
|
|
|
const char *cert __attribute__((unused)),
|
|
|
|
const char *ca __attribute__((unused)),
|
|
|
|
const char *capath __attribute__((unused)),
|
|
|
|
const char *cipher __attribute__((unused)))
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2012-08-14 16:23:34 +02:00
|
|
|
my_bool result= 0;
|
2005-10-04 15:43:55 +02:00
|
|
|
DBUG_ENTER("mysql_ssl_set");
|
2012-02-23 15:42:21 +01:00
|
|
|
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
|
2012-08-14 16:23:34 +02:00
|
|
|
result= (mysql_options(mysql, MYSQL_OPT_SSL_KEY, key) |
|
|
|
|
mysql_options(mysql, MYSQL_OPT_SSL_CERT, cert) |
|
|
|
|
mysql_options(mysql, MYSQL_OPT_SSL_CA, ca) |
|
|
|
|
mysql_options(mysql, MYSQL_OPT_SSL_CAPATH, capath) |
|
|
|
|
mysql_options(mysql, MYSQL_OPT_SSL_CIPHER, cipher) ?
|
|
|
|
1 : 0);
|
Backport of:
ChangeSet@1.2703, 2007-12-07 09:35:28-05:00, cmiller@zippy.cornsilk.net +40 -0
Bug#13174: SHA2 function
Patch contributed from Bill Karwin, paper unnumbered CLA in Seattle
Implement SHA2 functions.
Chad added code to make it work with YaSSL. Also, he removed the
(probable) bug of embedded server never using SSL-dependent
functions. (libmysqld/Makefile.am didn't read ANY autoconf defs.)
Function specification:
SHA2( string cleartext, integer hash_length )
-> string hash, or NULL
where hash_length is one of 224, 256, 384, or 512. If either is
NULL or a length is unsupported, then the result is NULL. The
resulting string is always the length of the hash_length parameter
or is NULL.
Include the canonical hash examples from the NIST in the test
results.
---
Polish and address concerns of reviewers.
.bzrignore:
Added libmysqld/sha2.cc to the ignore list.
client/mysql.cc:
Add condition to remove code for embedded server.
client/mysqltest.cc:
Add condition to remove code for embedded server.
include/Makefile.am:
New header file to header list.
include/mysql_embed.h:
Embedded servers can use SSL-library functions too!
include/sha2.h:
Compatibility layer to make YaSSL behave like OpenSSL.
include/sslopt-case.h:
Remove SSL-communication parameters from command lines.
include/sslopt-longopts.h:
Remove SSL-communication parameters from command lines.
include/sslopt-vars.h:
Don't declare variables that are only used in SSL communication, if
we are compiling the embedded server.
include/violite.h:
Don't even compile the SSL-communication function if we're in the
embedded server.
---
Remove CPP condition indentation.
libmysqld/CMakeLists.txt:
Add new file to source list.
libmysqld/Makefile.am:
Include standard DEFS in embedded compilation. It's an undiscovered
but that it's not there.
Add new file to source list.
libmysqld/examples/Makefile.am:
Include autoconf DEFS.
libmysqld/lib_sql.cc:
Initialize SSL-related variables in embedded server.
mysql-test/include/have_ssl_crypto_functs.inc:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/r/func_digest.result:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
mysql-test/r/func_encrypt_nossl.result:
Update results to the new error message text.
mysql-test/r/have_ssl_is_yes_or_disabled_only.require:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/suite/rpl/t/rpl_ssl.test:
Distinguish between communication and crypto.
mysql-test/suite/rpl/t/rpl_ssl1.test:
Distinguish between communication and crypto.
mysql-test/t/func_des_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/func_digest.test:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
Also, test that various parameters (legal and illegal)
do what we expect.
---
Distinguish between communication and crypto.
mysql-test/t/func_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/openssl_1.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl-big.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_8k_key.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_compress.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_connect.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
sql-common/client.c:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/CMakeLists.txt:
Add new source file to source list so that we have access to SHA2
functions.
sql/Makefile.am:
Add new source file to source list so that we have access to SHA2
functions.
sql/item_create.cc:
Bootstrap the SHA2 function into the server.
sql/item_strfunc.cc:
Add new SHA2 Item class methods.
Clean up two minor problems.
---
Remove extraneous debugging.
---
We must check nullness of a parameter only /after/ computing its
value.
sql/item_strfunc.h:
Declare new SHA2 Item class.
sql/mysqld.cc:
For embedded server, don't refer to SSL-communications variables
or values.
---
Remove CPP condition indentation.
sql/sha2.cc:
Compatibility layer to make YaSSL behave like OpenSSL.
---
Add comment for generated functions.
sql/sql_acl.cc:
For embedded server, don't refer to SSL-communications variables
or values.
sql/sql_connect.cc:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/sys_vars.cc:
For embedded server, don't refer to SSL-communications variables
or values.
2010-04-13 17:04:45 +02:00
|
|
|
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
|
2017-04-19 20:31:05 +02:00
|
|
|
mysql->options.use_ssl= TRUE;
|
2012-08-14 16:23:34 +02:00
|
|
|
DBUG_RETURN(result);
|
2003-06-14 10:37:42 +02:00
|
|
|
}
|
2003-05-02 18:07:41 +02:00
|
|
|
|
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
/*
|
|
|
|
Free strings in the SSL structure and clear 'use_ssl' flag.
|
|
|
|
NB! Errors are not reported until you do mysql_real_connect.
|
|
|
|
*/
|
|
|
|
|
Backport of:
ChangeSet@1.2703, 2007-12-07 09:35:28-05:00, cmiller@zippy.cornsilk.net +40 -0
Bug#13174: SHA2 function
Patch contributed from Bill Karwin, paper unnumbered CLA in Seattle
Implement SHA2 functions.
Chad added code to make it work with YaSSL. Also, he removed the
(probable) bug of embedded server never using SSL-dependent
functions. (libmysqld/Makefile.am didn't read ANY autoconf defs.)
Function specification:
SHA2( string cleartext, integer hash_length )
-> string hash, or NULL
where hash_length is one of 224, 256, 384, or 512. If either is
NULL or a length is unsupported, then the result is NULL. The
resulting string is always the length of the hash_length parameter
or is NULL.
Include the canonical hash examples from the NIST in the test
results.
---
Polish and address concerns of reviewers.
.bzrignore:
Added libmysqld/sha2.cc to the ignore list.
client/mysql.cc:
Add condition to remove code for embedded server.
client/mysqltest.cc:
Add condition to remove code for embedded server.
include/Makefile.am:
New header file to header list.
include/mysql_embed.h:
Embedded servers can use SSL-library functions too!
include/sha2.h:
Compatibility layer to make YaSSL behave like OpenSSL.
include/sslopt-case.h:
Remove SSL-communication parameters from command lines.
include/sslopt-longopts.h:
Remove SSL-communication parameters from command lines.
include/sslopt-vars.h:
Don't declare variables that are only used in SSL communication, if
we are compiling the embedded server.
include/violite.h:
Don't even compile the SSL-communication function if we're in the
embedded server.
---
Remove CPP condition indentation.
libmysqld/CMakeLists.txt:
Add new file to source list.
libmysqld/Makefile.am:
Include standard DEFS in embedded compilation. It's an undiscovered
but that it's not there.
Add new file to source list.
libmysqld/examples/Makefile.am:
Include autoconf DEFS.
libmysqld/lib_sql.cc:
Initialize SSL-related variables in embedded server.
mysql-test/include/have_ssl_crypto_functs.inc:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/r/func_digest.result:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
mysql-test/r/func_encrypt_nossl.result:
Update results to the new error message text.
mysql-test/r/have_ssl_is_yes_or_disabled_only.require:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/suite/rpl/t/rpl_ssl.test:
Distinguish between communication and crypto.
mysql-test/suite/rpl/t/rpl_ssl1.test:
Distinguish between communication and crypto.
mysql-test/t/func_des_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/func_digest.test:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
Also, test that various parameters (legal and illegal)
do what we expect.
---
Distinguish between communication and crypto.
mysql-test/t/func_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/openssl_1.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl-big.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_8k_key.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_compress.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_connect.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
sql-common/client.c:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/CMakeLists.txt:
Add new source file to source list so that we have access to SHA2
functions.
sql/Makefile.am:
Add new source file to source list so that we have access to SHA2
functions.
sql/item_create.cc:
Bootstrap the SHA2 function into the server.
sql/item_strfunc.cc:
Add new SHA2 Item class methods.
Clean up two minor problems.
---
Remove extraneous debugging.
---
We must check nullness of a parameter only /after/ computing its
value.
sql/item_strfunc.h:
Declare new SHA2 Item class.
sql/mysqld.cc:
For embedded server, don't refer to SSL-communications variables
or values.
---
Remove CPP condition indentation.
sql/sha2.cc:
Compatibility layer to make YaSSL behave like OpenSSL.
---
Add comment for generated functions.
sql/sql_acl.cc:
For embedded server, don't refer to SSL-communications variables
or values.
sql/sql_connect.cc:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/sys_vars.cc:
For embedded server, don't refer to SSL-communications variables
or values.
2010-04-13 17:04:45 +02:00
|
|
|
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
|
2006-07-03 20:08:38 +02:00
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
static void
|
|
|
|
mysql_ssl_free(MYSQL *mysql __attribute__((unused)))
|
|
|
|
{
|
2006-03-10 16:41:14 +01:00
|
|
|
struct st_VioSSLFd *ssl_fd= (struct st_VioSSLFd*) mysql->connector_fd;
|
2005-10-04 15:43:55 +02:00
|
|
|
DBUG_ENTER("mysql_ssl_free");
|
2005-11-25 11:57:13 +01:00
|
|
|
|
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.ssl_key);
|
|
|
|
my_free(mysql->options.ssl_cert);
|
|
|
|
my_free(mysql->options.ssl_ca);
|
|
|
|
my_free(mysql->options.ssl_capath);
|
|
|
|
my_free(mysql->options.ssl_cipher);
|
2012-08-14 16:23:34 +02:00
|
|
|
if (mysql->options.extension)
|
|
|
|
{
|
|
|
|
my_free(mysql->options.extension->ssl_crl);
|
|
|
|
my_free(mysql->options.extension->ssl_crlpath);
|
|
|
|
}
|
2006-03-10 16:41:14 +01:00
|
|
|
if (ssl_fd)
|
|
|
|
SSL_CTX_free(ssl_fd->ssl_context);
|
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->connector_fd);
|
2003-06-14 10:37:42 +02:00
|
|
|
mysql->options.ssl_key = 0;
|
|
|
|
mysql->options.ssl_cert = 0;
|
|
|
|
mysql->options.ssl_ca = 0;
|
|
|
|
mysql->options.ssl_capath = 0;
|
|
|
|
mysql->options.ssl_cipher= 0;
|
2012-08-14 16:23:34 +02:00
|
|
|
if (mysql->options.extension)
|
|
|
|
{
|
|
|
|
mysql->options.extension->ssl_crl = 0;
|
|
|
|
mysql->options.extension->ssl_crlpath = 0;
|
|
|
|
}
|
2003-06-14 10:37:42 +02:00
|
|
|
mysql->options.use_ssl = FALSE;
|
|
|
|
mysql->connector_fd = 0;
|
2005-10-04 15:43:55 +02:00
|
|
|
DBUG_VOID_RETURN;
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
2006-04-07 11:26:21 +02:00
|
|
|
|
Backport of:
ChangeSet@1.2703, 2007-12-07 09:35:28-05:00, cmiller@zippy.cornsilk.net +40 -0
Bug#13174: SHA2 function
Patch contributed from Bill Karwin, paper unnumbered CLA in Seattle
Implement SHA2 functions.
Chad added code to make it work with YaSSL. Also, he removed the
(probable) bug of embedded server never using SSL-dependent
functions. (libmysqld/Makefile.am didn't read ANY autoconf defs.)
Function specification:
SHA2( string cleartext, integer hash_length )
-> string hash, or NULL
where hash_length is one of 224, 256, 384, or 512. If either is
NULL or a length is unsupported, then the result is NULL. The
resulting string is always the length of the hash_length parameter
or is NULL.
Include the canonical hash examples from the NIST in the test
results.
---
Polish and address concerns of reviewers.
.bzrignore:
Added libmysqld/sha2.cc to the ignore list.
client/mysql.cc:
Add condition to remove code for embedded server.
client/mysqltest.cc:
Add condition to remove code for embedded server.
include/Makefile.am:
New header file to header list.
include/mysql_embed.h:
Embedded servers can use SSL-library functions too!
include/sha2.h:
Compatibility layer to make YaSSL behave like OpenSSL.
include/sslopt-case.h:
Remove SSL-communication parameters from command lines.
include/sslopt-longopts.h:
Remove SSL-communication parameters from command lines.
include/sslopt-vars.h:
Don't declare variables that are only used in SSL communication, if
we are compiling the embedded server.
include/violite.h:
Don't even compile the SSL-communication function if we're in the
embedded server.
---
Remove CPP condition indentation.
libmysqld/CMakeLists.txt:
Add new file to source list.
libmysqld/Makefile.am:
Include standard DEFS in embedded compilation. It's an undiscovered
but that it's not there.
Add new file to source list.
libmysqld/examples/Makefile.am:
Include autoconf DEFS.
libmysqld/lib_sql.cc:
Initialize SSL-related variables in embedded server.
mysql-test/include/have_ssl_crypto_functs.inc:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/r/func_digest.result:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
mysql-test/r/func_encrypt_nossl.result:
Update results to the new error message text.
mysql-test/r/have_ssl_is_yes_or_disabled_only.require:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/suite/rpl/t/rpl_ssl.test:
Distinguish between communication and crypto.
mysql-test/suite/rpl/t/rpl_ssl1.test:
Distinguish between communication and crypto.
mysql-test/t/func_des_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/func_digest.test:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
Also, test that various parameters (legal and illegal)
do what we expect.
---
Distinguish between communication and crypto.
mysql-test/t/func_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/openssl_1.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl-big.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_8k_key.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_compress.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_connect.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
sql-common/client.c:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/CMakeLists.txt:
Add new source file to source list so that we have access to SHA2
functions.
sql/Makefile.am:
Add new source file to source list so that we have access to SHA2
functions.
sql/item_create.cc:
Bootstrap the SHA2 function into the server.
sql/item_strfunc.cc:
Add new SHA2 Item class methods.
Clean up two minor problems.
---
Remove extraneous debugging.
---
We must check nullness of a parameter only /after/ computing its
value.
sql/item_strfunc.h:
Declare new SHA2 Item class.
sql/mysqld.cc:
For embedded server, don't refer to SSL-communications variables
or values.
---
Remove CPP condition indentation.
sql/sha2.cc:
Compatibility layer to make YaSSL behave like OpenSSL.
---
Add comment for generated functions.
sql/sql_acl.cc:
For embedded server, don't refer to SSL-communications variables
or values.
sql/sql_connect.cc:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/sys_vars.cc:
For embedded server, don't refer to SSL-communications variables
or values.
2010-04-13 17:04:45 +02:00
|
|
|
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
|
2006-04-07 11:26:21 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Return the SSL cipher (if any) used for current
|
|
|
|
connection to the server.
|
|
|
|
|
|
|
|
SYNOPSYS
|
|
|
|
mysql_get_ssl_cipher()
|
|
|
|
mysql pointer to the mysql connection
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
const char * STDCALL
|
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
BitKeeper/etc/ignore:
added libmysqld/ha_ndbcluster_cond.cc
---
added debian/defs.mk debian/control
client/completion_hash.cc:
Remove not needed casts
client/my_readline.h:
Remove some old types
client/mysql.cc:
Simplify types
client/mysql_upgrade.c:
Remove some old types
Update call to dirname_part
client/mysqladmin.cc:
Remove some old types
client/mysqlbinlog.cc:
Remove some old types
Change some buffers to be uchar to avoid casts
client/mysqlcheck.c:
Remove some old types
client/mysqldump.c:
Remove some old types
Remove some not needed casts
Change some string lengths to size_t
client/mysqlimport.c:
Remove some old types
client/mysqlshow.c:
Remove some old types
client/mysqlslap.c:
Remove some old types
Remove some not needed casts
client/mysqltest.c:
Removed some old types
Removed some not needed casts
Updated hash-get-key function arguments
Updated parameters to dirname_part()
client/readline.cc:
Removed some old types
Removed some not needed casts
Changed some string lengths to use size_t
client/sql_string.cc:
Removed some old types
dbug/dbug.c:
Removed some old types
Changed some string lengths to use size_t
Changed some prototypes to avoid casts
extra/comp_err.c:
Removed some old types
extra/innochecksum.c:
Removed some old types
extra/my_print_defaults.c:
Removed some old types
extra/mysql_waitpid.c:
Removed some old types
extra/perror.c:
Removed some old types
extra/replace.c:
Removed some old types
Updated parameters to dirname_part()
extra/resolve_stack_dump.c:
Removed some old types
extra/resolveip.c:
Removed some old types
include/config-win.h:
Removed some old types
include/decimal.h:
Changed binary strings to be uchar* instead of char*
include/ft_global.h:
Removed some old types
include/hash.h:
Removed some old types
include/heap.h:
Removed some old types
Changed records_under_level to be 'ulong' instead of 'uint' to clarify usage of variable
include/keycache.h:
Removed some old types
include/m_ctype.h:
Removed some old types
Changed some string lengths to use size_t
Changed character length functions to return uint
unsigned char -> uchar
include/m_string.h:
Removed some old types
Changed some string lengths to use size_t
include/my_alloc.h:
Changed some string lengths to use size_t
include/my_base.h:
Removed some old types
include/my_dbug.h:
Removed some old types
Changed some string lengths to use size_t
Changed db_dump() to take uchar * as argument for memory to reduce number of casts in usage
include/my_getopt.h:
Removed some old types
include/my_global.h:
Removed old types:
my_size_t -> size_t
byte -> uchar
gptr -> uchar *
include/my_list.h:
Removed some old types
include/my_nosys.h:
Removed some old types
include/my_pthread.h:
Removed some old types
include/my_sys.h:
Removed some old types
Changed MY_FILE_ERROR to be in line with new definitions of my_write()/my_read()
Changed some string lengths to use size_t
my_malloc() / my_free() now uses void *
Updated parameters to dirname_part() & my_uncompress()
include/my_tree.h:
Removed some old types
include/my_trie.h:
Removed some old types
include/my_user.h:
Changed some string lengths to use size_t
include/my_vle.h:
Removed some old types
include/my_xml.h:
Removed some old types
Changed some string lengths to use size_t
include/myisam.h:
Removed some old types
include/myisammrg.h:
Removed some old types
include/mysql.h:
Removed some old types
Changed byte streams to use uchar* instead of char*
include/mysql_com.h:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
include/queues.h:
Removed some old types
include/sql_common.h:
Removed some old types
include/sslopt-longopts.h:
Removed some old types
include/violite.h:
Removed some old types
Changed some string lengths to use size_t
libmysql/client_settings.h:
Removed some old types
libmysql/libmysql.c:
Removed some old types
libmysql/manager.c:
Removed some old types
libmysqld/emb_qcache.cc:
Removed some old types
libmysqld/emb_qcache.h:
Removed some old types
libmysqld/lib_sql.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
true -> TRUE, false -> FALSE
mysys/array.c:
Removed some old types
mysys/charset.c:
Changed some string lengths to use size_t
mysys/checksum.c:
Include zlib to get definition for crc32
Removed some old types
mysys/default.c:
Removed some old types
Changed some string lengths to use size_t
mysys/default_modify.c:
Changed some string lengths to use size_t
Removed some not needed casts
mysys/hash.c:
Removed some old types
Changed some string lengths to use size_t
Note: Prototype of hash_key() has changed which may cause problems if client uses hash_init() with a cast for the hash-get-key function.
hash_element now takes 'ulong' as the index type (cleanup)
mysys/list.c:
Removed some old types
mysys/mf_cache.c:
Changed some string lengths to use size_t
mysys/mf_dirname.c:
Removed some old types
Changed some string lengths to use size_t
Added argument to dirname_part() to avoid calculation of length for 'to'
mysys/mf_fn_ext.c:
Removed some old types
Updated parameters to dirname_part()
mysys/mf_format.c:
Removed some old types
Changed some string lengths to use size_t
mysys/mf_getdate.c:
Removed some old types
mysys/mf_iocache.c:
Removed some old types
Changed some string lengths to use size_t
Changed calculation of 'max_length' to be done the same way in all functions
mysys/mf_iocache2.c:
Removed some old types
Changed some string lengths to use size_t
Clean up comments
Removed not needed indentation
mysys/mf_keycache.c:
Removed some old types
mysys/mf_keycaches.c:
Removed some old types
mysys/mf_loadpath.c:
Removed some old types
mysys/mf_pack.c:
Removed some old types
Changed some string lengths to use size_t
Removed some not needed casts
Removed very old VMS code
Updated parameters to dirname_part()
Use result of dirnam_part() to remove call to strcat()
mysys/mf_path.c:
Removed some old types
mysys/mf_radix.c:
Removed some old types
mysys/mf_same.c:
Removed some old types
mysys/mf_sort.c:
Removed some old types
mysys/mf_soundex.c:
Removed some old types
mysys/mf_strip.c:
Removed some old types
mysys/mf_tempdir.c:
Removed some old types
mysys/mf_unixpath.c:
Removed some old types
mysys/mf_wfile.c:
Removed some old types
mysys/mulalloc.c:
Removed some old types
mysys/my_alloc.c:
Removed some old types
Changed some string lengths to use size_t
Use void* as type for allocated memory area
Removed some not needed casts
Changed argument 'Size' to 'length' according coding guidelines
mysys/my_chsize.c:
Changed some buffers to be uchar* to avoid casts
mysys/my_compress.c:
More comments
Removed some old types
Changed string lengths to use size_t
Changed arguments to my_uncompress() to make them easier to understand
Changed packfrm()/unpackfrm() to not be depending on uint size (portability fix)
Changed type of 'pack_data' argument to packfrm() to avoid casts.
mysys/my_conio.c:
Changed some string lengths to use size_t
mysys/my_create.c:
Removed some old types
mysys/my_div.c:
Removed some old types
mysys/my_error.c:
Removed some old types
mysys/my_fopen.c:
Removed some old types
mysys/my_fstream.c:
Removed some old types
Changed some string lengths to use size_t
writen -> written
mysys/my_getopt.c:
Removed some old types
mysys/my_getwd.c:
Removed some old types
More comments
mysys/my_init.c:
Removed some old types
mysys/my_largepage.c:
Removed some old types
Changed some string lengths to use size_t
mysys/my_lib.c:
Removed some old types
mysys/my_lockmem.c:
Removed some old types
mysys/my_malloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/my_memmem.c:
Indentation cleanup
mysys/my_once.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
mysys/my_open.c:
Removed some old types
mysys/my_pread.c:
Removed some old types
Changed all functions to use size_t
Added comment for how my_pread() / my_pwrite() are supposed to work.
Removed windows specific code to restore cursor position as this causes slowdown on windows and we should not mix read() and pread() calls anyway as this is not thread safe.
(If we ever would really need this, it should be enabled only with a flag argument)
mysys/my_quick.c:
Removed some old types
Changed all functions to use size_t
mysys/my_read.c:
Removed some old types
Changed all functions to use size_t
mysys/my_realloc.c:
Removed some old types
Use void* as type for allocated memory area
Changed all functions to use size_t
mysys/my_static.c:
Removed some old types
mysys/my_static.h:
Removed some old types
mysys/my_vle.c:
Removed some old types
mysys/my_wincond.c:
Removed some old types
mysys/my_windac.c:
Removed some old types
mysys/my_write.c:
Removed some old types
Changed all functions to use size_t
mysys/ptr_cmp.c:
Removed some old types
Changed all functions to use size_t
mysys/queues.c:
Removed some old types
mysys/safemalloc.c:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed all functions to use size_t
mysys/string.c:
Removed some old types
Changed all functions to use size_t
mysys/testhash.c:
Removed some old types
mysys/thr_alarm.c:
Removed some old types
mysys/thr_lock.c:
Removed some old types
mysys/tree.c:
Removed some old types
mysys/trie.c:
Removed some old types
mysys/typelib.c:
Removed some old types
plugin/daemon_example/daemon_example.cc:
Removed some old types
regex/reginit.c:
Removed some old types
server-tools/instance-manager/buffer.cc:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/buffer.h:
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/commands.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_map.cc:
Removed some old types
Changed some string lengths to use size_t
Changed buffer to be of type uchar*
server-tools/instance-manager/instance_options.cc:
Changed buffer to be of type uchar*
Replaced alloc_root + strcpy() with strdup_root()
server-tools/instance-manager/mysql_connection.cc:
Changed buffer to be of type uchar*
server-tools/instance-manager/options.cc:
Removed some old types
server-tools/instance-manager/parse.cc:
Changed some string lengths to use size_t
server-tools/instance-manager/parse.h:
Removed some old types
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.cc:
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
server-tools/instance-manager/protocol.h:
Changed some string lengths to use size_t
server-tools/instance-manager/user_map.cc:
Removed some old types
Changed some string lengths to use size_t
sql/derror.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/discover.cc:
Changed in readfrm() and writefrom() the type for argument 'frmdata' to uchar** to avoid casts
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
sql/event_data_objects.cc:
Removed some old types
Added missing casts for alloc() and sprintf()
sql/event_db_repository.cc:
Changed some buffers to be uchar* to avoid casts
Added missing casts for sprintf()
sql/event_queue.cc:
Removed some old types
sql/field.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/field.h:
Removed some old types
Changed memory buffers to be uchar* (except of store() as this would have caused too many other changes).
Changed some string lengths to use size_t
Removed some not needed casts
Changed val_xxx(xxx, new_ptr) to take const pointers
sql/field_conv.cc:
Removed some old types
Added casts required because memory area pointers are now uchar*
sql/filesort.cc:
Initalize variable that was used unitialized in error conditions
sql/gen_lex_hash.cc:
Removed some old types
Changed memory buffers to be uchar*
Changed some string lengths to use size_t
Removed a lot of casts
Safety fix in Field_blob::val_decimal() to not access zero pointer
sql/gstream.h:
Added required cast
sql/ha_ndbcluster.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Added required casts
Removed some not needed casts
sql/ha_ndbcluster.h:
Removed some old types
sql/ha_ndbcluster_binlog.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Replaced sql_alloc() + memcpy() + set end 0 with sql_strmake()
Changed some string lengths to use size_t
Added missing casts for alloc() and sprintf()
sql/ha_ndbcluster_binlog.h:
Removed some old types
sql/ha_ndbcluster_cond.cc:
Removed some old types
Removed some not needed casts
sql/ha_ndbcluster_cond.h:
Removed some old types
sql/ha_partition.cc:
Removed some old types
Changed prototype for change_partition() to avoid casts
sql/ha_partition.h:
Removed some old types
sql/handler.cc:
Removed some old types
Changed some string lengths to use size_t
sql/handler.h:
Removed some old types
Changed some string lengths to use size_t
Changed type for 'frmblob' parameter for discover() and ha_discover() to get fewer casts
sql/hash_filo.h:
Removed some old types
Changed all functions to use size_t
sql/hostname.cc:
Removed some old types
sql/item.cc:
Removed some old types
Changed some string lengths to use size_t
Use strmake() instead of memdup() to create a null terminated string.
Updated calls to new Field()
sql/item.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/item_cmpfunc.h:
Removed some old types
sql/item_create.cc:
Removed some old types
sql/item_func.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added test for failing alloc() in init_result_field()
Remove old confusing comment
Fixed compiler warning
sql/item_func.h:
Removed some old types
sql/item_row.cc:
Removed some old types
sql/item_row.h:
Removed some old types
sql/item_strfunc.cc:
Include zlib (needed becasue we call crc32)
Removed some old types
sql/item_strfunc.h:
Removed some old types
Changed some types to match new function prototypes
sql/item_subselect.cc:
Removed some old types
sql/item_subselect.h:
Removed some old types
sql/item_sum.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/item_sum.h:
Removed some old types
sql/item_timefunc.cc:
Removed some old types
Changed some string lengths to use size_t
sql/item_timefunc.h:
Removed some old types
sql/item_xmlfunc.cc:
Changed some string lengths to use size_t
sql/item_xmlfunc.h:
Removed some old types
sql/key.cc:
Removed some old types
Removed some not needed casts
sql/lock.cc:
Removed some old types
Added some cast to my_multi_malloc() arguments for safety
sql/log.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Changed usage of pwrite() to not assume it holds the cursor position for the file
Made usage of my_read() safer
sql/log_event.cc:
Removed some old types
Added checking of return value of malloc() in pack_info()
Changed some buffers to be uchar* to avoid casts
Removed some 'const' to avoid casts
Added missing casts for alloc() and sprintf()
Added required casts
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
sql/log_event.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/log_event_old.cc:
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/log_event_old.h:
Changed some buffers to be uchar* to avoid casts
sql/mf_iocache.cc:
Removed some old types
sql/my_decimal.cc:
Changed memory area to use uchar*
sql/my_decimal.h:
Changed memory area to use uchar*
sql/mysql_priv.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Changed some string lengths to use size_t
Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid long overflow
Changed some buffers to be uchar* to avoid casts
sql/mysqld.cc:
Removed some old types
sql/net_serv.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Ensure that vio_read()/vio_write() return values are stored in a size_t variable
Removed some not needed casts
sql/opt_range.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/opt_range.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/opt_sum.cc:
Removed some old types
Removed some not needed casts
sql/parse_file.cc:
Removed some old types
Changed some string lengths to use size_t
Changed alloc_root + memcpy + set end 0 -> strmake_root()
sql/parse_file.h:
Removed some old types
sql/partition_info.cc:
Removed some old types
Added missing casts for alloc()
Changed some buffers to be uchar* to avoid casts
sql/partition_info.h:
Changed some buffers to be uchar* to avoid casts
sql/protocol.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/protocol.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/records.cc:
Removed some old types
sql/repl_failsafe.cc:
Removed some old types
Changed some string lengths to use size_t
Added required casts
sql/rpl_filter.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some string lengths to use size_t
sql/rpl_filter.h:
Changed some string lengths to use size_t
sql/rpl_injector.h:
Removed some old types
sql/rpl_record.cc:
Removed some old types
Removed some not needed casts
Changed some buffers to be uchar* to avoid casts
sql/rpl_record.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/rpl_record_old.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/rpl_record_old.h:
Removed some old types
Changed some buffers to be uchar* to avoid cast
sql/rpl_rli.cc:
Removed some old types
sql/rpl_tblmap.cc:
Removed some old types
sql/rpl_tblmap.h:
Removed some old types
sql/rpl_utility.cc:
Removed some old types
sql/rpl_utility.h:
Removed some old types
Changed type of m_size from my_size_t to ulong to reflect that m_size is the number of elements in the array, not a string/memory length
sql/set_var.cc:
Removed some old types
Updated parameters to dirname_part()
sql/set_var.h:
Removed some old types
sql/slave.cc:
Removed some old types
Changed some string lengths to use size_t
sql/slave.h:
Removed some old types
sql/sp.cc:
Removed some old types
Added missing casts for printf()
sql/sp.h:
Removed some old types
Updated hash-get-key function arguments
sql/sp_cache.cc:
Removed some old types
Added missing casts for printf()
Updated hash-get-key function arguments
sql/sp_head.cc:
Removed some old types
Added missing casts for alloc() and printf()
Added required casts
Updated hash-get-key function arguments
sql/sp_head.h:
Removed some old types
sql/sp_pcontext.cc:
Removed some old types
sql/sp_pcontext.h:
Removed some old types
sql/sql_acl.cc:
Removed some old types
Changed some string lengths to use size_t
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added required casts
sql/sql_analyse.cc:
Changed some buffers to be uchar* to avoid casts
sql/sql_analyse.h:
Changed some buffers to be uchar* to avoid casts
sql/sql_array.h:
Removed some old types
sql/sql_base.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_binlog.cc:
Removed some old types
Added missing casts for printf()
sql/sql_cache.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
Changed some string lengths to use size_t
sql/sql_cache.h:
Removed some old types
Removed reference to not existing function cache_key()
Updated hash-get-key function arguments
sql/sql_class.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc()
Updated hash-get-key function arguments
Moved THD::max_row_length() to table.cc (as it's not depending on THD)
Removed some not needed casts
sql/sql_class.h:
Removed some old types
Changed malloc(), free() and related functions to use void *
Removed some not needed casts
Changed some string lengths to use size_t
Moved max_row_length and max_row_length_blob() to table.cc, as they are not depending on THD
sql/sql_connect.cc:
Removed some old types
Added required casts
sql/sql_db.cc:
Removed some old types
Removed some not needed casts
Added some cast to my_multi_malloc() arguments for safety
Added missing casts for alloc()
sql/sql_delete.cc:
Removed some old types
sql/sql_handler.cc:
Removed some old types
Updated hash-get-key function arguments
Added some cast to my_multi_malloc() arguments for safety
sql/sql_help.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_insert.cc:
Removed some old types
Added missing casts for alloc() and printf()
sql/sql_lex.cc:
Removed some old types
sql/sql_lex.h:
Removed some old types
Removed some not needed casts
sql/sql_list.h:
Removed some old types
Removed some not needed casts
sql/sql_load.cc:
Removed some old types
Removed compiler warning
sql/sql_manager.cc:
Removed some old types
sql/sql_map.cc:
Removed some old types
sql/sql_map.h:
Removed some old types
sql/sql_olap.cc:
Removed some old types
sql/sql_parse.cc:
Removed some old types
Trivial move of code lines to make things more readable
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/sql_partition.cc:
Removed some old types
Removed compiler warnings about not used functions
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_partition.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_plugin.cc:
Removed some old types
Added missing casts for alloc()
Updated hash-get-key function arguments
sql/sql_prepare.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Added missing casts for alloc() and printf()
sql-common/client.c:
Removed some old types
Changed some memory areas to use uchar*
sql-common/my_user.c:
Changed some string lengths to use size_t
sql-common/pack.c:
Changed some buffers to be uchar* to avoid casts
sql/sql_repl.cc:
Added required casts
Changed some buffers to be uchar* to avoid casts
Changed some string lengths to use size_t
sql/sql_select.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some old types
sql/sql_select.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
sql/sql_servers.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_show.cc:
Removed some old types
Added missing casts for alloc()
Removed some not needed casts
sql/sql_string.cc:
Removed some old types
Added required casts
sql/sql_table.cc:
Removed some old types
Removed compiler warning about not used variable
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
sql/sql_test.cc:
Removed some old types
sql/sql_trigger.cc:
Removed some old types
Added missing casts for alloc()
sql/sql_udf.cc:
Removed some old types
Updated hash-get-key function arguments
sql/sql_union.cc:
Removed some old types
sql/sql_update.cc:
Removed some old types
Removed some not needed casts
sql/sql_view.cc:
Removed some old types
sql/sql_yacc.yy:
Removed some old types
Changed some string lengths to use size_t
Added missing casts for alloc()
sql/stacktrace.c:
Removed some old types
sql/stacktrace.h:
Removed some old types
sql/structs.h:
Removed some old types
sql/table.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
Removed setting of LEX_STRING() arguments in declaration
Added required casts
More function comments
Moved max_row_length() here from sql_class.cc/sql_class.h
sql/table.h:
Removed some old types
Changed some string lengths to use size_t
sql/thr_malloc.cc:
Use void* as type for allocated memory area
Changed all functions to use size_t
sql/tzfile.h:
Changed some buffers to be uchar* to avoid casts
sql/tztime.cc:
Changed some buffers to be uchar* to avoid casts
Updated hash-get-key function arguments
Added missing casts for alloc()
Removed some not needed casts
sql/uniques.cc:
Removed some old types
Removed some not needed casts
sql/unireg.cc:
Removed some old types
Changed some buffers to be uchar* to avoid casts
Removed some not needed casts
Added missing casts for alloc()
storage/archive/archive_reader.c:
Removed some old types
storage/archive/azio.c:
Removed some old types
Removed some not needed casts
storage/archive/ha_archive.cc:
Removed some old types
Changed type for 'frmblob' in archive_discover() to match handler
Updated hash-get-key function arguments
Removed some not needed casts
storage/archive/ha_archive.h:
Removed some old types
storage/blackhole/ha_blackhole.cc:
Removed some old types
storage/blackhole/ha_blackhole.h:
Removed some old types
storage/csv/ha_tina.cc:
Removed some old types
Updated hash-get-key function arguments
Changed some buffers to be uchar* to avoid casts
storage/csv/ha_tina.h:
Removed some old types
Removed some not needed casts
storage/csv/transparent_file.cc:
Removed some old types
Changed type of 'bytes_read' to be able to detect read errors
Fixed indentation
storage/csv/transparent_file.h:
Removed some old types
storage/example/ha_example.cc:
Removed some old types
Updated hash-get-key function arguments
storage/example/ha_example.h:
Removed some old types
storage/federated/ha_federated.cc:
Removed some old types
Updated hash-get-key function arguments
Removed some not needed casts
storage/federated/ha_federated.h:
Removed some old types
storage/heap/_check.c:
Changed some buffers to be uchar* to avoid casts
storage/heap/_rectest.c:
Removed some old types
storage/heap/ha_heap.cc:
Removed some old types
storage/heap/ha_heap.h:
Removed some old types
storage/heap/heapdef.h:
Removed some old types
storage/heap/hp_block.c:
Removed some old types
Changed some string lengths to use size_t
storage/heap/hp_clear.c:
Removed some old types
storage/heap/hp_close.c:
Removed some old types
storage/heap/hp_create.c:
Removed some old types
storage/heap/hp_delete.c:
Removed some old types
storage/heap/hp_hash.c:
Removed some old types
storage/heap/hp_info.c:
Removed some old types
storage/heap/hp_open.c:
Removed some old types
storage/heap/hp_rfirst.c:
Removed some old types
storage/heap/hp_rkey.c:
Removed some old types
storage/heap/hp_rlast.c:
Removed some old types
storage/heap/hp_rnext.c:
Removed some old types
storage/heap/hp_rprev.c:
Removed some old types
storage/heap/hp_rrnd.c:
Removed some old types
storage/heap/hp_rsame.c:
Removed some old types
storage/heap/hp_scan.c:
Removed some old types
storage/heap/hp_test1.c:
Removed some old types
storage/heap/hp_test2.c:
Removed some old types
storage/heap/hp_update.c:
Removed some old types
storage/heap/hp_write.c:
Removed some old types
Changed some string lengths to use size_t
storage/innobase/handler/ha_innodb.cc:
Removed some old types
Updated hash-get-key function arguments
Added missing casts for alloc() and printf()
Removed some not needed casts
storage/innobase/handler/ha_innodb.h:
Removed some old types
storage/myisam/ft_boolean_search.c:
Removed some old types
storage/myisam/ft_nlq_search.c:
Removed some old types
storage/myisam/ft_parser.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ft_static.c:
Removed some old types
storage/myisam/ft_stopwords.c:
Removed some old types
storage/myisam/ft_update.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/ftdefs.h:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/fulltext.h:
Removed some old types
storage/myisam/ha_myisam.cc:
Removed some old types
storage/myisam/ha_myisam.h:
Removed some old types
storage/myisam/mi_cache.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_check.c:
Removed some old types
storage/myisam/mi_checksum.c:
Removed some old types
storage/myisam/mi_close.c:
Removed some old types
storage/myisam/mi_create.c:
Removed some old types
storage/myisam/mi_delete.c:
Removed some old types
storage/myisam/mi_delete_all.c:
Removed some old types
storage/myisam/mi_dynrec.c:
Removed some old types
storage/myisam/mi_extra.c:
Removed some old types
storage/myisam/mi_key.c:
Removed some old types
storage/myisam/mi_locking.c:
Removed some old types
storage/myisam/mi_log.c:
Removed some old types
storage/myisam/mi_open.c:
Removed some old types
Removed some not needed casts
Check argument of my_write()/my_pwrite() in functions returning int
Added casting of string lengths to size_t
storage/myisam/mi_packrec.c:
Removed some old types
Changed some buffers to be uchar* to avoid casts
storage/myisam/mi_page.c:
Removed some old types
storage/myisam/mi_preload.c:
Removed some old types
storage/myisam/mi_range.c:
Removed some old types
storage/myisam/mi_rfirst.c:
Removed some old types
storage/myisam/mi_rkey.c:
Removed some old types
storage/myisam/mi_rlast.c:
Removed some old types
storage/myisam/mi_rnext.c:
Removed some old types
storage/myisam/mi_rnext_same.c:
Removed some old types
storage/myisam/mi_rprev.c:
Removed some old types
storage/myisam/mi_rrnd.c:
Removed some old types
storage/myisam/mi_rsame.c:
Removed some old types
storage/myisam/mi_rsamepos.c:
Removed some old types
storage/myisam/mi_scan.c:
Removed some old types
storage/myisam/mi_search.c:
Removed some old types
storage/myisam/mi_static.c:
Removed some old types
storage/myisam/mi_statrec.c:
Removed some old types
storage/myisam/mi_test1.c:
Removed some old types
storage/myisam/mi_test2.c:
Removed some old types
storage/myisam/mi_test3.c:
Removed some old types
storage/myisam/mi_unique.c:
Removed some old types
storage/myisam/mi_update.c:
Removed some old types
storage/myisam/mi_write.c:
Removed some old types
storage/myisam/myisam_ftdump.c:
Removed some old types
storage/myisam/myisamchk.c:
Removed some old types
storage/myisam/myisamdef.h:
Removed some old types
storage/myisam/myisamlog.c:
Removed some old types
Indentation fix
storage/myisam/myisampack.c:
Removed some old types
storage/myisam/rt_index.c:
Removed some old types
storage/myisam/rt_split.c:
Removed some old types
storage/myisam/sort.c:
Removed some old types
storage/myisam/sp_defs.h:
Removed some old types
storage/myisam/sp_key.c:
Removed some old types
storage/myisammrg/ha_myisammrg.cc:
Removed some old types
storage/myisammrg/ha_myisammrg.h:
Removed some old types
storage/myisammrg/myrg_close.c:
Removed some old types
storage/myisammrg/myrg_def.h:
Removed some old types
storage/myisammrg/myrg_delete.c:
Removed some old types
storage/myisammrg/myrg_open.c:
Removed some old types
Updated parameters to dirname_part()
storage/myisammrg/myrg_queue.c:
Removed some old types
storage/myisammrg/myrg_rfirst.c:
Removed some old types
storage/myisammrg/myrg_rkey.c:
Removed some old types
storage/myisammrg/myrg_rlast.c:
Removed some old types
storage/myisammrg/myrg_rnext.c:
Removed some old types
storage/myisammrg/myrg_rnext_same.c:
Removed some old types
storage/myisammrg/myrg_rprev.c:
Removed some old types
storage/myisammrg/myrg_rrnd.c:
Removed some old types
storage/myisammrg/myrg_rsame.c:
Removed some old types
storage/myisammrg/myrg_update.c:
Removed some old types
storage/myisammrg/myrg_write.c:
Removed some old types
storage/ndb/include/util/ndb_opts.h:
Removed some old types
storage/ndb/src/cw/cpcd/main.cpp:
Removed some old types
storage/ndb/src/kernel/vm/Configuration.cpp:
Removed some old types
storage/ndb/src/mgmclient/main.cpp:
Removed some old types
storage/ndb/src/mgmsrv/InitConfigFileParser.cpp:
Removed some old types
Removed old disabled code
storage/ndb/src/mgmsrv/main.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbBlob.cpp:
Removed some old types
storage/ndb/src/ndbapi/NdbOperationDefine.cpp:
Removed not used variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
Added required casts
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
Added required casts
storage/ndb/tools/delete_all.cpp:
Removed some old types
storage/ndb/tools/desc.cpp:
Removed some old types
storage/ndb/tools/drop_index.cpp:
Removed some old types
storage/ndb/tools/drop_tab.cpp:
Removed some old types
storage/ndb/tools/listTables.cpp:
Removed some old types
storage/ndb/tools/ndb_config.cpp:
Removed some old types
storage/ndb/tools/restore/consumer_restore.cpp:
Changed some buffers to be uchar* to avoid casts with new defintion of packfrm()
storage/ndb/tools/restore/restore_main.cpp:
Removed some old types
storage/ndb/tools/select_all.cpp:
Removed some old types
storage/ndb/tools/select_count.cpp:
Removed some old types
storage/ndb/tools/waiter.cpp:
Removed some old types
strings/bchange.c:
Changed function to use uchar * and size_t
strings/bcmp.c:
Changed function to use uchar * and size_t
strings/bmove512.c:
Changed function to use uchar * and size_t
strings/bmove_upp.c:
Changed function to use uchar * and size_t
strings/ctype-big5.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-bin.c:
Changed functions to use size_t
strings/ctype-cp932.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-czech.c:
Fixed indentation
Changed functions to use size_t
strings/ctype-euc_kr.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-eucjpms.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-gb2312.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-gbk.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-latin1.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-mb.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-simple.c:
Changed functions to use size_t
Simpler loops for caseup/casedown
unsigned int -> uint
unsigned char -> uchar
strings/ctype-sjis.c:
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-tis620.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-uca.c:
Changed functions to use size_t
unsigned char -> uchar
strings/ctype-ucs2.c:
Moved inclusion of stdarg.h to other includes
usigned char -> uchar
Changed functions to use size_t
Changed character length functions to return uint
strings/ctype-ujis.c:
Changed functions to use size_t
Changed character length functions to return uint
unsigned char -> uchar
strings/ctype-utf8.c:
Changed functions to use size_t
unsigned char -> uchar
Indentation fixes
strings/ctype-win1250ch.c:
Indentation fixes
Changed functions to use size_t
strings/ctype.c:
Changed functions to use size_t
strings/decimal.c:
Changed type for memory argument to uchar *
strings/do_ctype.c:
Indentation fixes
strings/my_strtoll10.c:
unsigned char -> uchar
strings/my_vsnprintf.c:
Changed functions to use size_t
strings/r_strinstr.c:
Removed some old types
Changed functions to use size_t
strings/str_test.c:
Removed some old types
strings/strappend.c:
Changed functions to use size_t
strings/strcont.c:
Removed some old types
strings/strfill.c:
Removed some old types
strings/strinstr.c:
Changed functions to use size_t
strings/strlen.c:
Changed functions to use size_t
strings/strmake.c:
Changed functions to use size_t
strings/strnlen.c:
Changed functions to use size_t
strings/strnmov.c:
Changed functions to use size_t
strings/strto.c:
unsigned char -> uchar
strings/strtod.c:
Changed functions to use size_t
strings/strxnmov.c:
Changed functions to use size_t
strings/xml.c:
Changed functions to use size_t
Indentation fixes
tests/mysql_client_test.c:
Removed some old types
tests/thread_test.c:
Removed some old types
vio/test-ssl.c:
Removed some old types
vio/test-sslclient.c:
Removed some old types
vio/test-sslserver.c:
Removed some old types
vio/vio.c:
Removed some old types
vio/vio_priv.h:
Removed some old types
Changed vio_read()/vio_write() to work with size_t
vio/viosocket.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viossl.c:
Changed vio_read()/vio_write() to work with size_t
Indentation fixes
vio/viosslfactories.c:
Removed some old types
vio/viotest-ssl.c:
Removed some old types
win/README:
More explanations
2007-05-10 11:59:39 +02:00
|
|
|
mysql_get_ssl_cipher(MYSQL *mysql __attribute__((unused)))
|
2006-04-07 11:26:21 +02:00
|
|
|
{
|
|
|
|
DBUG_ENTER("mysql_get_ssl_cipher");
|
Backport of:
ChangeSet@1.2703, 2007-12-07 09:35:28-05:00, cmiller@zippy.cornsilk.net +40 -0
Bug#13174: SHA2 function
Patch contributed from Bill Karwin, paper unnumbered CLA in Seattle
Implement SHA2 functions.
Chad added code to make it work with YaSSL. Also, he removed the
(probable) bug of embedded server never using SSL-dependent
functions. (libmysqld/Makefile.am didn't read ANY autoconf defs.)
Function specification:
SHA2( string cleartext, integer hash_length )
-> string hash, or NULL
where hash_length is one of 224, 256, 384, or 512. If either is
NULL or a length is unsupported, then the result is NULL. The
resulting string is always the length of the hash_length parameter
or is NULL.
Include the canonical hash examples from the NIST in the test
results.
---
Polish and address concerns of reviewers.
.bzrignore:
Added libmysqld/sha2.cc to the ignore list.
client/mysql.cc:
Add condition to remove code for embedded server.
client/mysqltest.cc:
Add condition to remove code for embedded server.
include/Makefile.am:
New header file to header list.
include/mysql_embed.h:
Embedded servers can use SSL-library functions too!
include/sha2.h:
Compatibility layer to make YaSSL behave like OpenSSL.
include/sslopt-case.h:
Remove SSL-communication parameters from command lines.
include/sslopt-longopts.h:
Remove SSL-communication parameters from command lines.
include/sslopt-vars.h:
Don't declare variables that are only used in SSL communication, if
we are compiling the embedded server.
include/violite.h:
Don't even compile the SSL-communication function if we're in the
embedded server.
---
Remove CPP condition indentation.
libmysqld/CMakeLists.txt:
Add new file to source list.
libmysqld/Makefile.am:
Include standard DEFS in embedded compilation. It's an undiscovered
but that it's not there.
Add new file to source list.
libmysqld/examples/Makefile.am:
Include autoconf DEFS.
libmysqld/lib_sql.cc:
Initialize SSL-related variables in embedded server.
mysql-test/include/have_ssl_crypto_functs.inc:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/r/func_digest.result:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
mysql-test/r/func_encrypt_nossl.result:
Update results to the new error message text.
mysql-test/r/have_ssl_is_yes_or_disabled_only.require:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/suite/rpl/t/rpl_ssl.test:
Distinguish between communication and crypto.
mysql-test/suite/rpl/t/rpl_ssl1.test:
Distinguish between communication and crypto.
mysql-test/t/func_des_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/func_digest.test:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
Also, test that various parameters (legal and illegal)
do what we expect.
---
Distinguish between communication and crypto.
mysql-test/t/func_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/openssl_1.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl-big.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_8k_key.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_compress.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_connect.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
sql-common/client.c:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/CMakeLists.txt:
Add new source file to source list so that we have access to SHA2
functions.
sql/Makefile.am:
Add new source file to source list so that we have access to SHA2
functions.
sql/item_create.cc:
Bootstrap the SHA2 function into the server.
sql/item_strfunc.cc:
Add new SHA2 Item class methods.
Clean up two minor problems.
---
Remove extraneous debugging.
---
We must check nullness of a parameter only /after/ computing its
value.
sql/item_strfunc.h:
Declare new SHA2 Item class.
sql/mysqld.cc:
For embedded server, don't refer to SSL-communications variables
or values.
---
Remove CPP condition indentation.
sql/sha2.cc:
Compatibility layer to make YaSSL behave like OpenSSL.
---
Add comment for generated functions.
sql/sql_acl.cc:
For embedded server, don't refer to SSL-communications variables
or values.
sql/sql_connect.cc:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/sys_vars.cc:
For embedded server, don't refer to SSL-communications variables
or values.
2010-04-13 17:04:45 +02:00
|
|
|
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
|
2006-04-07 11:26:21 +02:00
|
|
|
if (mysql->net.vio && mysql->net.vio->ssl_arg)
|
2006-04-10 12:23:20 +02:00
|
|
|
DBUG_RETURN(SSL_get_cipher_name((SSL*)mysql->net.vio->ssl_arg));
|
Backport of:
ChangeSet@1.2703, 2007-12-07 09:35:28-05:00, cmiller@zippy.cornsilk.net +40 -0
Bug#13174: SHA2 function
Patch contributed from Bill Karwin, paper unnumbered CLA in Seattle
Implement SHA2 functions.
Chad added code to make it work with YaSSL. Also, he removed the
(probable) bug of embedded server never using SSL-dependent
functions. (libmysqld/Makefile.am didn't read ANY autoconf defs.)
Function specification:
SHA2( string cleartext, integer hash_length )
-> string hash, or NULL
where hash_length is one of 224, 256, 384, or 512. If either is
NULL or a length is unsupported, then the result is NULL. The
resulting string is always the length of the hash_length parameter
or is NULL.
Include the canonical hash examples from the NIST in the test
results.
---
Polish and address concerns of reviewers.
.bzrignore:
Added libmysqld/sha2.cc to the ignore list.
client/mysql.cc:
Add condition to remove code for embedded server.
client/mysqltest.cc:
Add condition to remove code for embedded server.
include/Makefile.am:
New header file to header list.
include/mysql_embed.h:
Embedded servers can use SSL-library functions too!
include/sha2.h:
Compatibility layer to make YaSSL behave like OpenSSL.
include/sslopt-case.h:
Remove SSL-communication parameters from command lines.
include/sslopt-longopts.h:
Remove SSL-communication parameters from command lines.
include/sslopt-vars.h:
Don't declare variables that are only used in SSL communication, if
we are compiling the embedded server.
include/violite.h:
Don't even compile the SSL-communication function if we're in the
embedded server.
---
Remove CPP condition indentation.
libmysqld/CMakeLists.txt:
Add new file to source list.
libmysqld/Makefile.am:
Include standard DEFS in embedded compilation. It's an undiscovered
but that it's not there.
Add new file to source list.
libmysqld/examples/Makefile.am:
Include autoconf DEFS.
libmysqld/lib_sql.cc:
Initialize SSL-related variables in embedded server.
mysql-test/include/have_ssl_crypto_functs.inc:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/r/func_digest.result:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
mysql-test/r/func_encrypt_nossl.result:
Update results to the new error message text.
mysql-test/r/have_ssl_is_yes_or_disabled_only.require:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/suite/rpl/t/rpl_ssl.test:
Distinguish between communication and crypto.
mysql-test/suite/rpl/t/rpl_ssl1.test:
Distinguish between communication and crypto.
mysql-test/t/func_des_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/func_digest.test:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
Also, test that various parameters (legal and illegal)
do what we expect.
---
Distinguish between communication and crypto.
mysql-test/t/func_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/openssl_1.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl-big.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_8k_key.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_compress.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_connect.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
sql-common/client.c:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/CMakeLists.txt:
Add new source file to source list so that we have access to SHA2
functions.
sql/Makefile.am:
Add new source file to source list so that we have access to SHA2
functions.
sql/item_create.cc:
Bootstrap the SHA2 function into the server.
sql/item_strfunc.cc:
Add new SHA2 Item class methods.
Clean up two minor problems.
---
Remove extraneous debugging.
---
We must check nullness of a parameter only /after/ computing its
value.
sql/item_strfunc.h:
Declare new SHA2 Item class.
sql/mysqld.cc:
For embedded server, don't refer to SSL-communications variables
or values.
---
Remove CPP condition indentation.
sql/sha2.cc:
Compatibility layer to make YaSSL behave like OpenSSL.
---
Add comment for generated functions.
sql/sql_acl.cc:
For embedded server, don't refer to SSL-communications variables
or values.
sql/sql_connect.cc:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/sys_vars.cc:
For embedded server, don't refer to SSL-communications variables
or values.
2010-04-13 17:04:45 +02:00
|
|
|
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
|
2006-04-07 11:26:21 +02:00
|
|
|
DBUG_RETURN(NULL);
|
|
|
|
}
|
|
|
|
|
2006-04-26 22:24:25 +02:00
|
|
|
|
2006-04-18 17:58:27 +02:00
|
|
|
/*
|
|
|
|
Check the server's (subject) Common Name against the
|
|
|
|
hostname we connected to
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
ssl_verify_server_cert()
|
|
|
|
vio pointer to a SSL connected vio
|
|
|
|
server_hostname name of the server that we connected to
|
2011-05-19 11:47:43 +02:00
|
|
|
errptr if we fail, we'll return (a pointer to a string
|
|
|
|
describing) the reason here
|
2006-04-18 17:58:27 +02:00
|
|
|
|
|
|
|
RETURN VALUES
|
|
|
|
0 Success
|
|
|
|
1 Failed to validate server
|
|
|
|
|
|
|
|
*/
|
2006-07-03 20:08:38 +02:00
|
|
|
|
2012-02-22 11:44:53 +01:00
|
|
|
#if defined(HAVE_OPENSSL)
|
2006-07-03 20:08:38 +02:00
|
|
|
|
2017-05-03 21:22:59 +02:00
|
|
|
#ifdef HAVE_X509_check_host
|
2017-04-25 23:00:58 +02:00
|
|
|
#include <openssl/x509v3.h>
|
|
|
|
#endif
|
|
|
|
|
2011-05-19 11:47:43 +02:00
|
|
|
static int ssl_verify_server_cert(Vio *vio, const char* server_hostname, const char **errptr)
|
2006-04-18 17:58:27 +02:00
|
|
|
{
|
|
|
|
SSL *ssl;
|
2016-01-11 02:39:13 +01:00
|
|
|
X509 *server_cert= NULL;
|
2017-04-25 23:00:58 +02:00
|
|
|
#ifndef HAVE_X509_check_host
|
2016-01-11 02:39:13 +01:00
|
|
|
char *cn= NULL;
|
|
|
|
int cn_loc= -1;
|
|
|
|
ASN1_STRING *cn_asn1= NULL;
|
|
|
|
X509_NAME_ENTRY *cn_entry= NULL;
|
|
|
|
X509_NAME *subject= NULL;
|
2017-04-25 23:00:58 +02:00
|
|
|
#endif
|
2016-01-11 02:39:13 +01:00
|
|
|
int ret_validation= 1;
|
|
|
|
|
2006-04-18 17:58:27 +02:00
|
|
|
DBUG_ENTER("ssl_verify_server_cert");
|
|
|
|
DBUG_PRINT("enter", ("server_hostname: %s", server_hostname));
|
|
|
|
|
|
|
|
if (!(ssl= (SSL*)vio->ssl_arg))
|
|
|
|
{
|
2011-05-19 11:47:43 +02:00
|
|
|
*errptr= "No SSL pointer found";
|
2016-01-11 02:39:13 +01:00
|
|
|
goto error;
|
2006-04-18 17:58:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!server_hostname)
|
|
|
|
{
|
2011-05-19 11:47:43 +02:00
|
|
|
*errptr= "No server hostname supplied";
|
2016-01-11 02:39:13 +01:00
|
|
|
goto error;
|
2006-04-18 17:58:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(server_cert= SSL_get_peer_certificate(ssl)))
|
|
|
|
{
|
2011-05-19 11:47:43 +02:00
|
|
|
*errptr= "Could not get server certificate";
|
2016-01-11 02:39:13 +01:00
|
|
|
goto error;
|
2006-04-18 17:58:27 +02:00
|
|
|
}
|
|
|
|
|
2014-07-31 11:52:49 +02:00
|
|
|
if (X509_V_OK != SSL_get_verify_result(ssl))
|
|
|
|
{
|
|
|
|
*errptr= "Failed to verify the server certificate";
|
2016-01-11 02:39:13 +01:00
|
|
|
goto error;
|
2014-07-31 11:52:49 +02:00
|
|
|
}
|
2006-04-18 17:58:27 +02:00
|
|
|
/*
|
|
|
|
We already know that the certificate exchanged was valid; the SSL library
|
|
|
|
handled that. Now we need to verify that the contents of the certificate
|
|
|
|
are what we expect.
|
|
|
|
*/
|
|
|
|
|
2017-04-25 23:00:58 +02:00
|
|
|
#ifdef HAVE_X509_check_host
|
2019-04-24 11:15:08 +02:00
|
|
|
ret_validation=
|
2019-02-13 09:08:06 +01:00
|
|
|
X509_check_host(server_cert, server_hostname,
|
|
|
|
strlen(server_hostname), 0, 0) != 1;
|
|
|
|
#ifndef HAVE_WOLFSSL
|
|
|
|
if (ret_validation)
|
|
|
|
{
|
|
|
|
ret_validation=
|
|
|
|
X509_check_ip_asc(server_cert, server_hostname, 0) != 1;
|
|
|
|
}
|
|
|
|
#endif
|
2017-04-25 23:00:58 +02:00
|
|
|
#else
|
2016-02-09 11:27:40 +01:00
|
|
|
subject= X509_get_subject_name(server_cert);
|
2016-01-11 02:39:13 +01:00
|
|
|
cn_loc= X509_NAME_get_index_by_NID(subject, NID_commonName, -1);
|
|
|
|
if (cn_loc < 0)
|
2006-04-18 17:58:27 +02:00
|
|
|
{
|
2016-01-11 02:39:13 +01:00
|
|
|
*errptr= "Failed to get CN location in the certificate subject";
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
cn_entry= X509_NAME_get_entry(subject, cn_loc);
|
|
|
|
if (cn_entry == NULL)
|
|
|
|
{
|
|
|
|
*errptr= "Failed to get CN entry using CN location";
|
|
|
|
goto error;
|
2006-04-18 17:58:27 +02:00
|
|
|
}
|
2015-12-07 20:06:54 +01:00
|
|
|
|
2016-01-11 02:39:13 +01:00
|
|
|
cn_asn1 = X509_NAME_ENTRY_get_data(cn_entry);
|
|
|
|
if (cn_asn1 == NULL)
|
|
|
|
{
|
|
|
|
*errptr= "Failed to get CN from CN entry";
|
|
|
|
goto error;
|
|
|
|
}
|
2015-12-07 20:06:54 +01:00
|
|
|
|
2017-03-08 17:39:47 +01:00
|
|
|
cn= (char *) ASN1_STRING_get0_data(cn_asn1);
|
2015-12-07 20:06:54 +01:00
|
|
|
|
2016-01-11 02:39:13 +01:00
|
|
|
if ((size_t)ASN1_STRING_length(cn_asn1) != strlen(cn))
|
|
|
|
{
|
|
|
|
*errptr= "NULL embedded in the certificate CN";
|
|
|
|
goto error;
|
|
|
|
}
|
2015-12-07 20:06:54 +01:00
|
|
|
|
2016-01-11 02:39:13 +01:00
|
|
|
DBUG_PRINT("info", ("Server hostname in cert: %s", cn));
|
|
|
|
if (!strcmp(cn, server_hostname))
|
|
|
|
{
|
|
|
|
/* Success */
|
|
|
|
ret_validation= 0;
|
|
|
|
}
|
2017-04-25 23:00:58 +02:00
|
|
|
#endif
|
2011-05-19 11:47:43 +02:00
|
|
|
*errptr= "SSL certificate validation failure";
|
2016-01-11 02:39:13 +01:00
|
|
|
|
|
|
|
error:
|
|
|
|
if (server_cert != NULL)
|
|
|
|
X509_free (server_cert);
|
|
|
|
DBUG_RETURN(ret_validation);
|
2006-04-18 17:58:27 +02:00
|
|
|
}
|
|
|
|
|
2012-02-22 11:44:53 +01:00
|
|
|
#endif /* HAVE_OPENSSL */
|
2003-05-02 18:07:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Note that the mysql argument must be initialized with mysql_init()
|
|
|
|
before calling mysql_real_connect !
|
|
|
|
*/
|
|
|
|
|
2003-12-22 13:57:34 +01:00
|
|
|
static my_bool cli_read_query_result(MYSQL *mysql);
|
|
|
|
static MYSQL_RES *cli_use_result(MYSQL *mysql);
|
2003-06-17 18:32:31 +02:00
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
int cli_read_change_user_result(MYSQL *mysql)
|
|
|
|
{
|
|
|
|
return cli_safe_read(mysql);
|
|
|
|
}
|
|
|
|
|
2003-06-17 18:32:31 +02:00
|
|
|
static MYSQL_METHODS client_methods=
|
|
|
|
{
|
A fix and a test case for Bug#15752 "Lost connection to MySQL server
when calling a SP from C API"
The bug was caused by lack of checks for misuse in mysql_real_query.
A stored procedure always returns at least one result, which is the
status of execution of the procedure itself.
This result, or so-called OK packet, is similar to a result
returned by INSERT/UPDATE/CREATE operations: it contains the overall
status of execution, the number of affected rows and the number of
warnings. The client test program attached to the bug did not read this
result and ivnoked the next query. In turn, libmysql had no check for
such scenario and mysql_real_query was simply trying to send that query
without reading the pending response, thus messing up the communication
protocol.
The fix is to return an error from mysql_real_query when it's called
prior to retrieval of all pending results.
client/mysqlbinlog.cc:
net_safe_read -> cli_safe_read
include/mysql.h:
Remove a private function from the public header.
include/mysql_com.h:
Remove a define that is never used.
include/sql_common.h:
Add a declaration for cli_safe_read - a function that reads one packet
from the server.
libmysql/libmysql.c:
net_safe_read -> cli_safe_read
Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
using a connection which has pending result sets.
sql-common/client.c:
Actual fix for Bug#15752: if the server has pending result sets for
the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
another query. Similarly to the behaviour of mysql_use_result(),
multiple result sets block the connection and must be fetched
before it can be used for another query.
This uncovered an error in the protocol: the server doesn't drop
SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
a multi-query like SELECT 1; SELECT syntax_error; SELECT 2;
the client has no way to know that the server won't ever come to
execution of the third query and won't return any result sets for it.
For now, fix it in cli_safe_read, as a proper fix requires extension
of the client-server protocol.
sql/protocol.cc:
Remove a name that is never used.
sql/slave.cc:
net_safe_read -> cli_safe_read
tests/mysql_client_test.c:
Make 'query' a local variable to avoid name clash.
Add a test case for Bug#15752 "Lost connection to MySQL server when
calling an SP from C API"
2006-07-24 12:56:53 +02:00
|
|
|
cli_read_query_result, /* read_query_result */
|
|
|
|
cli_advanced_command, /* advanced_command */
|
|
|
|
cli_read_rows, /* read_rows */
|
|
|
|
cli_use_result, /* use_result */
|
|
|
|
cli_fetch_lengths, /* fetch_lengths */
|
2010-03-29 17:13:53 +02:00
|
|
|
cli_flush_use_result, /* flush_use_result */
|
|
|
|
cli_read_change_user_result /* read_change_user_result */
|
2003-09-19 11:05:28 +02:00
|
|
|
#ifndef MYSQL_SERVER
|
A fix and a test case for Bug#15752 "Lost connection to MySQL server
when calling a SP from C API"
The bug was caused by lack of checks for misuse in mysql_real_query.
A stored procedure always returns at least one result, which is the
status of execution of the procedure itself.
This result, or so-called OK packet, is similar to a result
returned by INSERT/UPDATE/CREATE operations: it contains the overall
status of execution, the number of affected rows and the number of
warnings. The client test program attached to the bug did not read this
result and ivnoked the next query. In turn, libmysql had no check for
such scenario and mysql_real_query was simply trying to send that query
without reading the pending response, thus messing up the communication
protocol.
The fix is to return an error from mysql_real_query when it's called
prior to retrieval of all pending results.
client/mysqlbinlog.cc:
net_safe_read -> cli_safe_read
include/mysql.h:
Remove a private function from the public header.
include/mysql_com.h:
Remove a define that is never used.
include/sql_common.h:
Add a declaration for cli_safe_read - a function that reads one packet
from the server.
libmysql/libmysql.c:
net_safe_read -> cli_safe_read
Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
using a connection which has pending result sets.
sql-common/client.c:
Actual fix for Bug#15752: if the server has pending result sets for
the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
another query. Similarly to the behaviour of mysql_use_result(),
multiple result sets block the connection and must be fetched
before it can be used for another query.
This uncovered an error in the protocol: the server doesn't drop
SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
a multi-query like SELECT 1; SELECT syntax_error; SELECT 2;
the client has no way to know that the server won't ever come to
execution of the third query and won't return any result sets for it.
For now, fix it in cli_safe_read, as a proper fix requires extension
of the client-server protocol.
sql/protocol.cc:
Remove a name that is never used.
sql/slave.cc:
net_safe_read -> cli_safe_read
tests/mysql_client_test.c:
Make 'query' a local variable to avoid name clash.
Add a test case for Bug#15752 "Lost connection to MySQL server when
calling an SP from C API"
2006-07-24 12:56:53 +02:00
|
|
|
,cli_list_fields, /* list_fields */
|
|
|
|
cli_read_prepare_result, /* read_prepare_result */
|
|
|
|
cli_stmt_execute, /* stmt_execute */
|
|
|
|
cli_read_binary_rows, /* read_binary_rows */
|
|
|
|
cli_unbuffered_fetch, /* unbuffered_fetch */
|
|
|
|
NULL, /* free_embedded_thd */
|
|
|
|
cli_read_statistics, /* read_statistics */
|
|
|
|
cli_read_query_result, /* next_result */
|
|
|
|
cli_read_binary_rows /* read_rows_from_cursor */
|
2003-09-19 11:05:28 +02:00
|
|
|
#endif
|
2003-06-17 18:32:31 +02:00
|
|
|
};
|
|
|
|
|
2009-10-21 14:59:47 +02:00
|
|
|
|
2019-06-17 10:56:00 +02:00
|
|
|
#include <my_sys.h>
|
2009-10-21 14:59:47 +02:00
|
|
|
static int
|
|
|
|
mysql_autodetect_character_set(MYSQL *mysql)
|
|
|
|
{
|
2013-03-18 08:16:06 +01:00
|
|
|
if (mysql->options.charset_name)
|
|
|
|
my_free(mysql->options.charset_name);
|
2019-06-17 10:56:00 +02:00
|
|
|
if (!(mysql->options.charset_name= my_strdup(my_default_csname(),MYF(MY_WME))))
|
2009-10-21 14:59:47 +02:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
mysql_set_character_set_with_default_collation(MYSQL *mysql)
|
|
|
|
{
|
|
|
|
const char *save= charsets_dir;
|
|
|
|
if (mysql->options.charset_dir)
|
|
|
|
charsets_dir=mysql->options.charset_dir;
|
|
|
|
|
|
|
|
if ((mysql->charset= get_charset_by_csname(mysql->options.charset_name,
|
|
|
|
MY_CS_PRIMARY, MYF(MY_WME))))
|
|
|
|
{
|
|
|
|
/* Try to set compiled default collation when it's possible. */
|
|
|
|
CHARSET_INFO *collation;
|
|
|
|
if ((collation=
|
|
|
|
get_charset_by_name(MYSQL_DEFAULT_COLLATION_NAME, MYF(MY_WME))) &&
|
|
|
|
my_charset_same(mysql->charset, collation))
|
|
|
|
{
|
|
|
|
mysql->charset= collation;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Default compiled collation not found, or is not applicable
|
|
|
|
to the requested character set.
|
|
|
|
Continue with the default collation of the character set.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
charsets_dir= save;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-19 19:11:01 +02:00
|
|
|
C_MODE_START
|
|
|
|
int mysql_init_character_set(MYSQL *mysql)
|
|
|
|
{
|
|
|
|
/* Set character set */
|
2019-06-17 10:56:00 +02:00
|
|
|
if (!mysql->options.charset_name ||
|
|
|
|
!strcmp(mysql->options.charset_name,
|
|
|
|
MYSQL_AUTODETECT_CHARSET_NAME))
|
2006-06-30 13:48:18 +02:00
|
|
|
{
|
2019-06-17 10:56:00 +02:00
|
|
|
if (mysql_autodetect_character_set(mysql))
|
2009-10-21 14:59:47 +02:00
|
|
|
return 1;
|
2006-06-19 19:11:01 +02:00
|
|
|
}
|
2009-10-21 14:59:47 +02:00
|
|
|
|
|
|
|
mysql_set_character_set_with_default_collation(mysql);
|
2007-10-31 15:16:53 +01:00
|
|
|
|
2006-06-19 19:11:01 +02:00
|
|
|
if (!mysql->charset)
|
|
|
|
{
|
|
|
|
if (mysql->options.charset_dir)
|
2007-10-31 15:16:53 +01:00
|
|
|
set_mysql_extended_error(mysql, CR_CANT_READ_CHARSET, unknown_sqlstate,
|
|
|
|
ER(CR_CANT_READ_CHARSET),
|
|
|
|
mysql->options.charset_name,
|
|
|
|
mysql->options.charset_dir);
|
2006-06-19 19:11:01 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
char cs_dir_name[FN_REFLEN];
|
|
|
|
get_charsets_dir(cs_dir_name);
|
2007-10-31 15:16:53 +01:00
|
|
|
set_mysql_extended_error(mysql, CR_CANT_READ_CHARSET, unknown_sqlstate,
|
|
|
|
ER(CR_CANT_READ_CHARSET),
|
|
|
|
mysql->options.charset_name,
|
|
|
|
cs_dir_name);
|
2006-06-19 19:11:01 +02:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
C_MODE_END
|
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
/*********** client side authentication support **************************/
|
|
|
|
|
|
|
|
typedef struct st_mysql_client_plugin_AUTHENTICATION auth_plugin_t;
|
|
|
|
static int client_mpvio_write_packet(struct st_plugin_vio*, const uchar*, int);
|
|
|
|
static int native_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql);
|
|
|
|
static int old_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql);
|
|
|
|
|
|
|
|
static auth_plugin_t native_password_client_plugin=
|
|
|
|
{
|
|
|
|
MYSQL_CLIENT_AUTHENTICATION_PLUGIN,
|
|
|
|
MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION,
|
|
|
|
native_password_plugin_name,
|
|
|
|
"R.J.Silk, Sergei Golubchik",
|
|
|
|
"Native MySQL authentication",
|
|
|
|
{1, 0, 0},
|
2010-10-04 14:54:41 +02:00
|
|
|
"GPL",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2010-03-29 17:13:53 +02:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
native_password_auth_client
|
|
|
|
};
|
|
|
|
|
|
|
|
static auth_plugin_t old_password_client_plugin=
|
|
|
|
{
|
|
|
|
MYSQL_CLIENT_AUTHENTICATION_PLUGIN,
|
|
|
|
MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION,
|
|
|
|
old_password_plugin_name,
|
|
|
|
"R.J.Silk, Sergei Golubchik",
|
|
|
|
"Old MySQL-3.23 authentication",
|
|
|
|
{1, 0, 0},
|
2010-10-04 14:54:41 +02:00
|
|
|
"GPL",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2010-03-29 17:13:53 +02:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
old_password_auth_client
|
|
|
|
};
|
|
|
|
|
2013-10-03 17:00:44 +02:00
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
struct st_mysql_client_plugin *mysql_client_builtins[]=
|
|
|
|
{
|
|
|
|
(struct st_mysql_client_plugin *)&native_password_client_plugin,
|
|
|
|
(struct st_mysql_client_plugin *)&old_password_client_plugin,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2013-10-03 17:00:44 +02:00
|
|
|
|
|
|
|
static uchar *
|
|
|
|
write_length_encoded_string3(uchar *buf, char *string, size_t length)
|
|
|
|
{
|
|
|
|
buf= net_store_length(buf, length);
|
|
|
|
memcpy(buf, string, length);
|
|
|
|
buf+= length;
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uchar *
|
|
|
|
send_client_connect_attrs(MYSQL *mysql, uchar *buf)
|
|
|
|
{
|
|
|
|
/* check if the server supports connection attributes */
|
|
|
|
if (mysql->server_capabilities & CLIENT_CONNECT_ATTRS)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Always store the length if the client supports it */
|
|
|
|
buf= net_store_length(buf,
|
|
|
|
mysql->options.extension ?
|
|
|
|
mysql->options.extension->connection_attributes_length :
|
|
|
|
0);
|
|
|
|
|
|
|
|
/* check if we have connection attributes */
|
|
|
|
if (mysql->options.extension &&
|
|
|
|
my_hash_inited(&mysql->options.extension->connection_attributes))
|
|
|
|
{
|
|
|
|
HASH *attrs= &mysql->options.extension->connection_attributes;
|
|
|
|
ulong idx;
|
|
|
|
|
|
|
|
/* loop over and dump the connection attributes */
|
|
|
|
for (idx= 0; idx < attrs->records; idx++)
|
|
|
|
{
|
|
|
|
LEX_STRING *attr= (LEX_STRING *) my_hash_element(attrs, idx);
|
|
|
|
LEX_STRING *key= attr, *value= attr + 1;
|
|
|
|
|
|
|
|
/* we can't have zero length keys */
|
|
|
|
DBUG_ASSERT(key->length);
|
|
|
|
|
|
|
|
buf= write_length_encoded_string3(buf, key->str, key->length);
|
|
|
|
buf= write_length_encoded_string3(buf, value->str, value->length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static size_t get_length_store_length(size_t length)
|
|
|
|
{
|
|
|
|
/* as defined in net_store_length */
|
|
|
|
#define MAX_VARIABLE_STRING_LENGTH 9
|
|
|
|
uchar length_buffer[MAX_VARIABLE_STRING_LENGTH], *ptr;
|
|
|
|
|
|
|
|
ptr= net_store_length(length_buffer, length);
|
|
|
|
|
|
|
|
return ptr - &length_buffer[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
/* this is a "superset" of MYSQL_PLUGIN_VIO, in C++ I use inheritance */
|
|
|
|
typedef struct {
|
|
|
|
int (*read_packet)(struct st_plugin_vio *vio, uchar **buf);
|
|
|
|
int (*write_packet)(struct st_plugin_vio *vio, const uchar *pkt, int pkt_len);
|
|
|
|
void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info);
|
|
|
|
/* -= end of MYSQL_PLUGIN_VIO =- */
|
|
|
|
MYSQL *mysql;
|
2010-08-09 10:32:50 +02:00
|
|
|
auth_plugin_t *plugin; /**< what plugin we're under */
|
2010-03-29 17:13:53 +02:00
|
|
|
const char *db;
|
|
|
|
struct {
|
2010-08-09 10:32:50 +02:00
|
|
|
uchar *pkt; /**< pointer into NET::buff */
|
2010-03-29 17:13:53 +02:00
|
|
|
uint pkt_len;
|
|
|
|
} cached_server_reply;
|
2010-08-09 10:32:50 +02:00
|
|
|
int packets_read, packets_written; /**< counters for send/received packets */
|
|
|
|
int mysql_change_user; /**< if it's mysql_change_user() */
|
|
|
|
int last_read_packet_len; /**< the length of the last *read* packet */
|
2010-03-29 17:13:53 +02:00
|
|
|
} MCPVIO_EXT;
|
|
|
|
|
2013-12-09 12:38:02 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
Write 1-8 bytes of string length header infromation to dest depending on
|
|
|
|
value of src_len, then copy src_len bytes from src to dest.
|
|
|
|
|
|
|
|
@param dest Destination buffer of size src_len+8
|
|
|
|
@param dest_end One byte past the end of the dest buffer
|
|
|
|
@param src Source buff of size src_len
|
|
|
|
@param src_end One byte past the end of the src buffer
|
|
|
|
|
|
|
|
@return pointer dest+src_len+header size or NULL if
|
|
|
|
*/
|
|
|
|
|
|
|
|
static uchar *write_length_encoded_string4(uchar *dst, size_t dst_len,
|
|
|
|
const uchar *src, size_t src_len)
|
|
|
|
{
|
|
|
|
uchar *to= safe_net_store_length(dst, dst_len, src_len);
|
|
|
|
if (to == NULL)
|
|
|
|
return NULL;
|
|
|
|
memcpy(to, src, src_len);
|
|
|
|
return to + src_len;
|
|
|
|
}
|
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
/**
|
|
|
|
sends a COM_CHANGE_USER command with a caller provided payload
|
|
|
|
|
|
|
|
Packet format:
|
|
|
|
|
|
|
|
Bytes Content
|
|
|
|
----- ----
|
|
|
|
n user name - \0-terminated string
|
|
|
|
n password
|
|
|
|
3.23 scramble - \0-terminated string (9 bytes)
|
|
|
|
otherwise - length (1 byte) coded
|
|
|
|
n database name - \0-terminated string
|
|
|
|
2 character set number (if the server >= 4.1.x)
|
|
|
|
n client auth plugin name - \0-terminated string,
|
|
|
|
(if the server supports plugin auth)
|
|
|
|
|
|
|
|
@retval 0 ok
|
|
|
|
@retval 1 error
|
|
|
|
*/
|
|
|
|
static int send_change_user_packet(MCPVIO_EXT *mpvio,
|
|
|
|
const uchar *data, int data_len)
|
|
|
|
{
|
|
|
|
MYSQL *mysql= mpvio->mysql;
|
|
|
|
char *buff, *end;
|
|
|
|
int res= 1;
|
2013-10-03 17:00:44 +02:00
|
|
|
size_t connect_attrs_len=
|
|
|
|
(mysql->server_capabilities & CLIENT_CONNECT_ATTRS &&
|
|
|
|
mysql->options.extension) ?
|
|
|
|
mysql->options.extension->connection_attributes_length : 0;
|
2010-03-29 17:13:53 +02:00
|
|
|
|
2013-10-03 17:00:44 +02:00
|
|
|
buff= my_alloca(USERNAME_LENGTH + data_len + 1 + NAME_LEN + 2 + NAME_LEN +
|
|
|
|
connect_attrs_len + 9 /* for the length of the attrs */);
|
2010-03-29 17:13:53 +02:00
|
|
|
|
|
|
|
end= strmake(buff, mysql->user, USERNAME_LENGTH) + 1;
|
|
|
|
|
|
|
|
if (!data_len)
|
|
|
|
*end++= 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (mysql->client_flag & CLIENT_SECURE_CONNECTION)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(data_len <= 255);
|
|
|
|
if (data_len > 255)
|
|
|
|
{
|
|
|
|
set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
*end++= data_len;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(data_len == SCRAMBLE_LENGTH_323 + 1);
|
|
|
|
DBUG_ASSERT(data[SCRAMBLE_LENGTH_323] == 0);
|
|
|
|
}
|
|
|
|
memcpy(end, data, data_len);
|
|
|
|
end+= data_len;
|
|
|
|
}
|
|
|
|
end= strmake(end, mpvio->db ? mpvio->db : "", NAME_LEN) + 1;
|
|
|
|
|
|
|
|
if (mysql->server_capabilities & CLIENT_PROTOCOL_41)
|
|
|
|
{
|
|
|
|
int2store(end, (ushort) mysql->charset->number);
|
|
|
|
end+= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mysql->server_capabilities & CLIENT_PLUGIN_AUTH)
|
|
|
|
end= strmake(end, mpvio->plugin->name, NAME_LEN) + 1;
|
|
|
|
|
2013-10-03 17:00:44 +02:00
|
|
|
end= (char *) send_client_connect_attrs(mysql, (uchar *) end);
|
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
res= simple_command(mysql, COM_CHANGE_USER,
|
|
|
|
(uchar*)buff, (ulong)(end-buff), 1);
|
|
|
|
|
|
|
|
error:
|
|
|
|
my_afree(buff);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-10-03 17:00:44 +02:00
|
|
|
#define MAX_CONNECTION_ATTR_STORAGE_LENGTH 65536
|
2010-03-29 17:13:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
sends a client authentication packet (second packet in the 3-way handshake)
|
|
|
|
|
|
|
|
Packet format (when the server is 4.0 or earlier):
|
|
|
|
|
|
|
|
Bytes Content
|
|
|
|
----- ----
|
|
|
|
2 client capabilities
|
|
|
|
3 max packet size
|
|
|
|
n user name, \0-terminated
|
|
|
|
9 scramble_323, \0-terminated
|
|
|
|
|
|
|
|
Packet format (when the server is 4.1 or newer):
|
|
|
|
|
|
|
|
Bytes Content
|
|
|
|
----- ----
|
|
|
|
4 client capabilities
|
|
|
|
4 max packet size
|
|
|
|
1 charset number
|
|
|
|
23 reserved (always 0)
|
|
|
|
n user name, \0-terminated
|
2013-12-09 12:38:02 +01:00
|
|
|
n plugin auth data (e.g. scramble), length encoded
|
2010-03-29 17:13:53 +02:00
|
|
|
n database name, \0-terminated
|
|
|
|
(if CLIENT_CONNECT_WITH_DB is set in the capabilities)
|
|
|
|
n client auth plugin name - \0-terminated string,
|
|
|
|
(if CLIENT_PLUGIN_AUTH is set in the capabilities)
|
|
|
|
|
|
|
|
@retval 0 ok
|
|
|
|
@retval 1 error
|
|
|
|
*/
|
|
|
|
static int send_client_reply_packet(MCPVIO_EXT *mpvio,
|
|
|
|
const uchar *data, int data_len)
|
|
|
|
{
|
|
|
|
MYSQL *mysql= mpvio->mysql;
|
|
|
|
NET *net= &mysql->net;
|
|
|
|
char *buff, *end;
|
2013-10-03 17:00:44 +02:00
|
|
|
size_t buff_size;
|
|
|
|
size_t connect_attrs_len=
|
|
|
|
(mysql->server_capabilities & CLIENT_CONNECT_ATTRS &&
|
|
|
|
mysql->options.extension) ?
|
|
|
|
mysql->options.extension->connection_attributes_length : 0;
|
|
|
|
|
|
|
|
DBUG_ASSERT(connect_attrs_len < MAX_CONNECTION_ATTR_STORAGE_LENGTH);
|
|
|
|
|
|
|
|
/*
|
|
|
|
see end= buff+32 below, fixed size of the packet is 32 bytes.
|
|
|
|
+9 because data is a length encoded binary where meta data size is max 9.
|
|
|
|
*/
|
|
|
|
buff_size= 33 + USERNAME_LENGTH + data_len + 9 + NAME_LEN + NAME_LEN + connect_attrs_len + 9;
|
|
|
|
buff= my_alloca(buff_size);
|
2010-03-29 17:13:53 +02:00
|
|
|
|
|
|
|
mysql->client_flag|= mysql->options.client_flag;
|
|
|
|
mysql->client_flag|= CLIENT_CAPABILITIES;
|
|
|
|
|
|
|
|
if (mysql->client_flag & CLIENT_MULTI_STATEMENTS)
|
|
|
|
mysql->client_flag|= CLIENT_MULTI_RESULTS;
|
|
|
|
|
2018-03-29 15:25:08 +02:00
|
|
|
#ifdef HAVE_OPENSSL
|
2018-06-05 23:13:19 +02:00
|
|
|
if (mysql->options.ssl_key || mysql->options.ssl_cert ||
|
|
|
|
mysql->options.ssl_ca || mysql->options.ssl_capath ||
|
|
|
|
mysql->options.ssl_cipher)
|
|
|
|
mysql->options.use_ssl = 1;
|
2010-03-29 17:13:53 +02:00
|
|
|
if (mysql->options.use_ssl)
|
|
|
|
mysql->client_flag|= CLIENT_SSL;
|
2018-03-29 15:25:08 +02:00
|
|
|
#endif /* HAVE_OPENSSL */
|
2015-06-09 13:08:44 +02:00
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
if (mpvio->db)
|
|
|
|
mysql->client_flag|= CLIENT_CONNECT_WITH_DB;
|
|
|
|
|
|
|
|
/* Remove options that server doesn't support */
|
|
|
|
mysql->client_flag= mysql->client_flag &
|
|
|
|
(~(CLIENT_COMPRESS | CLIENT_SSL | CLIENT_PROTOCOL_41)
|
|
|
|
| mysql->server_capabilities);
|
|
|
|
|
|
|
|
#ifndef HAVE_COMPRESS
|
|
|
|
mysql->client_flag&= ~CLIENT_COMPRESS;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (mysql->client_flag & CLIENT_PROTOCOL_41)
|
|
|
|
{
|
|
|
|
/* 4.1 server and 4.1 client has a 32 byte option flag */
|
|
|
|
int4store(buff,mysql->client_flag);
|
|
|
|
int4store(buff+4, net->max_packet_size);
|
|
|
|
buff[8]= (char) mysql->charset->number;
|
|
|
|
bzero(buff+9, 32-9);
|
|
|
|
end= buff+32;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int2store(buff, mysql->client_flag);
|
|
|
|
int3store(buff+2, net->max_packet_size);
|
|
|
|
end= buff+5;
|
|
|
|
}
|
2015-06-09 13:08:44 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
If client uses ssl and client also has to verify the server
|
|
|
|
certificate, a ssl connection is required.
|
|
|
|
If the server does not support ssl, we abort the connection.
|
|
|
|
*/
|
|
|
|
if (mysql->options.use_ssl &&
|
|
|
|
(mysql->client_flag & CLIENT_SSL_VERIFY_SERVER_CERT) &&
|
|
|
|
!(mysql->server_capabilities & CLIENT_SSL))
|
|
|
|
{
|
|
|
|
set_mysql_extended_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate,
|
|
|
|
ER(CR_SSL_CONNECTION_ERROR),
|
|
|
|
"SSL is required, but the server does not "
|
|
|
|
"support it");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2017-04-19 20:31:05 +02:00
|
|
|
#ifdef HAVE_OPENSSL
|
2010-03-29 17:13:53 +02:00
|
|
|
if (mysql->client_flag & CLIENT_SSL)
|
|
|
|
{
|
|
|
|
/* Do the SSL layering. */
|
|
|
|
struct st_mysql_options *options= &mysql->options;
|
|
|
|
struct st_VioSSLFd *ssl_fd;
|
2011-05-19 11:47:43 +02:00
|
|
|
enum enum_ssl_init_error ssl_init_error;
|
|
|
|
const char *cert_error;
|
|
|
|
unsigned long ssl_error;
|
2018-07-29 13:10:29 +02:00
|
|
|
#ifdef EMBEDDED_LIBRARY
|
|
|
|
DBUG_ASSERT(0); // embedded should not do SSL connect
|
|
|
|
#endif
|
2010-03-29 17:13:53 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Send mysql->client_flag, max_packet_size - unencrypted otherwise
|
|
|
|
the server does not know we want to do SSL
|
|
|
|
*/
|
|
|
|
if (my_net_write(net, (uchar*)buff, (size_t) (end-buff)) || net_flush(net))
|
|
|
|
{
|
|
|
|
set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
|
|
|
|
ER(CR_SERVER_LOST_EXTENDED),
|
|
|
|
"sending connection information to server",
|
|
|
|
errno);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the VioSSLConnectorFd - init SSL and load certs */
|
|
|
|
if (!(ssl_fd= new_VioSSLConnectorFd(options->ssl_key,
|
|
|
|
options->ssl_cert,
|
|
|
|
options->ssl_ca,
|
|
|
|
options->ssl_capath,
|
2011-05-19 11:47:43 +02:00
|
|
|
options->ssl_cipher,
|
2012-08-14 16:23:34 +02:00
|
|
|
&ssl_init_error,
|
|
|
|
options->extension ?
|
|
|
|
options->extension->ssl_crl : NULL,
|
|
|
|
options->extension ?
|
|
|
|
options->extension->ssl_crlpath : NULL)))
|
2010-03-29 17:13:53 +02:00
|
|
|
{
|
2011-05-19 11:47:43 +02:00
|
|
|
set_mysql_extended_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate,
|
|
|
|
ER(CR_SSL_CONNECTION_ERROR), sslGetErrString(ssl_init_error));
|
2010-03-29 17:13:53 +02:00
|
|
|
goto error;
|
|
|
|
}
|
2010-08-09 10:32:50 +02:00
|
|
|
mysql->connector_fd= (unsigned char *) ssl_fd;
|
2010-03-29 17:13:53 +02:00
|
|
|
|
|
|
|
/* Connect to the server */
|
|
|
|
DBUG_PRINT("info", ("IO layer change in progress..."));
|
|
|
|
if (sslconnect(ssl_fd, net->vio,
|
2011-05-19 11:47:43 +02:00
|
|
|
(long) (mysql->options.connect_timeout), &ssl_error))
|
2010-08-09 10:32:50 +02:00
|
|
|
{
|
2011-05-19 11:47:43 +02:00
|
|
|
char buf[512];
|
|
|
|
ERR_error_string_n(ssl_error, buf, 512);
|
|
|
|
buf[511]= 0;
|
|
|
|
set_mysql_extended_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate,
|
|
|
|
ER(CR_SSL_CONNECTION_ERROR),
|
|
|
|
buf);
|
2010-03-29 17:13:53 +02:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
DBUG_PRINT("info", ("IO layer change done!"));
|
|
|
|
|
|
|
|
/* Verify server cert */
|
|
|
|
if ((mysql->client_flag & CLIENT_SSL_VERIFY_SERVER_CERT) &&
|
2011-05-19 11:47:43 +02:00
|
|
|
ssl_verify_server_cert(net->vio, mysql->host, &cert_error))
|
2010-03-29 17:13:53 +02:00
|
|
|
{
|
2011-05-19 11:47:43 +02:00
|
|
|
set_mysql_extended_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate,
|
|
|
|
ER(CR_SSL_CONNECTION_ERROR), cert_error);
|
2010-03-29 17:13:53 +02:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* HAVE_OPENSSL */
|
|
|
|
|
|
|
|
DBUG_PRINT("info",("Server version = '%s' capabilites: %lu status: %u client_flag: %lu",
|
|
|
|
mysql->server_version, mysql->server_capabilities,
|
|
|
|
mysql->server_status, mysql->client_flag));
|
|
|
|
|
|
|
|
/* This needs to be changed as it's not useful with big packets */
|
|
|
|
if (mysql->user[0])
|
|
|
|
strmake(end, mysql->user, USERNAME_LENGTH);
|
|
|
|
else
|
|
|
|
read_user_name(end);
|
|
|
|
|
|
|
|
/* We have to handle different version of handshake here */
|
|
|
|
DBUG_PRINT("info",("user: %s",end));
|
|
|
|
end= strend(end) + 1;
|
|
|
|
if (data_len)
|
|
|
|
{
|
|
|
|
if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION)
|
|
|
|
{
|
2013-12-09 12:38:02 +01:00
|
|
|
if (mysql->server_capabilities & CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA)
|
|
|
|
end= (char*)write_length_encoded_string4((uchar*)end,
|
|
|
|
buff_size, data, data_len);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (data_len > 255)
|
|
|
|
goto error;
|
|
|
|
*end++= data_len;
|
|
|
|
memcpy(end, data, data_len);
|
|
|
|
end+= data_len;
|
|
|
|
}
|
|
|
|
if (end == NULL)
|
|
|
|
goto error;
|
2010-03-29 17:13:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(data_len == SCRAMBLE_LENGTH_323 + 1); /* incl. \0 at the end */
|
|
|
|
memcpy(end, data, data_len);
|
|
|
|
end+= data_len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*end++= 0;
|
|
|
|
|
|
|
|
/* Add database if needed */
|
|
|
|
if (mpvio->db && (mysql->server_capabilities & CLIENT_CONNECT_WITH_DB))
|
|
|
|
{
|
|
|
|
end= strmake(end, mpvio->db, NAME_LEN) + 1;
|
|
|
|
mysql->db= my_strdup(mpvio->db, MYF(MY_WME));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mysql->server_capabilities & CLIENT_PLUGIN_AUTH)
|
|
|
|
end= strmake(end, mpvio->plugin->name, NAME_LEN) + 1;
|
|
|
|
|
2013-10-03 17:00:44 +02:00
|
|
|
end= (char *) send_client_connect_attrs(mysql, (uchar *) end);
|
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
/* Write authentication package */
|
|
|
|
if (my_net_write(net, (uchar*) buff, (size_t) (end-buff)) || net_flush(net))
|
|
|
|
{
|
|
|
|
set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
|
|
|
|
ER(CR_SERVER_LOST_EXTENDED),
|
|
|
|
"sending authentication information",
|
|
|
|
errno);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
my_afree(buff);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
|
|
|
my_afree(buff);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
vio->read_packet() callback method for client authentication plugins
|
|
|
|
|
|
|
|
This function is called by a client authentication plugin, when it wants
|
|
|
|
to read data from the server.
|
|
|
|
*/
|
|
|
|
static int client_mpvio_read_packet(struct st_plugin_vio *mpv, uchar **buf)
|
|
|
|
{
|
|
|
|
MCPVIO_EXT *mpvio= (MCPVIO_EXT*)mpv;
|
|
|
|
MYSQL *mysql= mpvio->mysql;
|
|
|
|
ulong pkt_len;
|
|
|
|
|
|
|
|
/* there are cached data left, feed it to a plugin */
|
|
|
|
if (mpvio->cached_server_reply.pkt)
|
|
|
|
{
|
|
|
|
*buf= mpvio->cached_server_reply.pkt;
|
|
|
|
mpvio->cached_server_reply.pkt= 0;
|
|
|
|
mpvio->packets_read++;
|
|
|
|
return mpvio->cached_server_reply.pkt_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mpvio->packets_read == 0)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
the server handshake packet came from the wrong plugin,
|
|
|
|
or it's mysql_change_user(). Either way, there is no data
|
|
|
|
for a plugin to read. send a dummy packet to the server
|
|
|
|
to initiate a dialog.
|
|
|
|
*/
|
|
|
|
if (client_mpvio_write_packet(mpv, 0, 0))
|
|
|
|
return (int)packet_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* otherwise read the data */
|
|
|
|
pkt_len= (*mysql->methods->read_change_user_result)(mysql);
|
|
|
|
mpvio->last_read_packet_len= pkt_len;
|
|
|
|
*buf= mysql->net.read_pos;
|
|
|
|
|
|
|
|
/* was it a request to change plugins ? */
|
2018-04-30 23:06:09 +02:00
|
|
|
if (pkt_len == packet_error || **buf == 254)
|
2010-03-29 17:13:53 +02:00
|
|
|
return (int)packet_error; /* if yes, this plugin shan't continue */
|
|
|
|
|
|
|
|
/*
|
|
|
|
the server sends \1\255 or \1\254 instead of just \255 or \254 -
|
|
|
|
for us to not confuse it with an error or "change plugin" packets.
|
|
|
|
We remove this escaping \1 here.
|
|
|
|
|
|
|
|
See also server_mpvio_write_packet() where the escaping is done.
|
|
|
|
*/
|
|
|
|
if (pkt_len && **buf == 1)
|
|
|
|
{
|
|
|
|
(*buf)++;
|
|
|
|
pkt_len--;
|
|
|
|
}
|
|
|
|
mpvio->packets_read++;
|
|
|
|
return pkt_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
vio->write_packet() callback method for client authentication plugins
|
|
|
|
|
|
|
|
This function is called by a client authentication plugin, when it wants
|
|
|
|
to send data to the server.
|
|
|
|
|
|
|
|
It transparently wraps the data into a change user or authentication
|
|
|
|
handshake packet, if neccessary.
|
|
|
|
*/
|
|
|
|
static int client_mpvio_write_packet(struct st_plugin_vio *mpv,
|
|
|
|
const uchar *pkt, int pkt_len)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
MCPVIO_EXT *mpvio= (MCPVIO_EXT*)mpv;
|
|
|
|
|
|
|
|
if (mpvio->packets_written == 0)
|
|
|
|
{
|
|
|
|
if (mpvio->mysql_change_user)
|
|
|
|
res= send_change_user_packet(mpvio, pkt, pkt_len);
|
|
|
|
else
|
|
|
|
res= send_client_reply_packet(mpvio, pkt, pkt_len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NET *net= &mpvio->mysql->net;
|
|
|
|
if (mpvio->mysql->thd)
|
|
|
|
res= 1; /* no chit-chat in embedded */
|
|
|
|
else
|
|
|
|
res= my_net_write(net, pkt, pkt_len) || net_flush(net);
|
|
|
|
if (res)
|
|
|
|
set_mysql_extended_error(mpvio->mysql, CR_SERVER_LOST, unknown_sqlstate,
|
|
|
|
ER(CR_SERVER_LOST_EXTENDED),
|
|
|
|
"sending authentication information",
|
|
|
|
errno);
|
|
|
|
}
|
|
|
|
mpvio->packets_written++;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
fills MYSQL_PLUGIN_VIO_INFO structure with the information about the
|
|
|
|
connection
|
|
|
|
*/
|
|
|
|
void mpvio_info(Vio *vio, MYSQL_PLUGIN_VIO_INFO *info)
|
|
|
|
{
|
|
|
|
bzero(info, sizeof(*info));
|
|
|
|
switch (vio->type) {
|
|
|
|
case VIO_TYPE_TCPIP:
|
|
|
|
info->protocol= MYSQL_VIO_TCP;
|
2017-09-28 12:38:02 +02:00
|
|
|
info->socket= (int)vio_fd(vio);
|
2010-03-29 17:13:53 +02:00
|
|
|
return;
|
|
|
|
case VIO_TYPE_SOCKET:
|
|
|
|
info->protocol= MYSQL_VIO_SOCKET;
|
2017-09-28 12:38:02 +02:00
|
|
|
info->socket= (int)vio_fd(vio);
|
2010-03-29 17:13:53 +02:00
|
|
|
return;
|
|
|
|
case VIO_TYPE_SSL:
|
|
|
|
{
|
|
|
|
struct sockaddr addr;
|
2010-04-02 11:20:09 +02:00
|
|
|
SOCKET_SIZE_TYPE addrlen= sizeof(addr);
|
2012-08-14 16:23:34 +02:00
|
|
|
if (getsockname(vio_fd(vio), &addr, &addrlen))
|
2010-03-29 17:13:53 +02:00
|
|
|
return;
|
|
|
|
info->protocol= addr.sa_family == AF_UNIX ?
|
|
|
|
MYSQL_VIO_SOCKET : MYSQL_VIO_TCP;
|
2017-09-28 12:38:02 +02:00
|
|
|
info->socket= (int)vio_fd(vio);
|
2010-03-29 17:13:53 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#ifdef _WIN32
|
|
|
|
case VIO_TYPE_NAMEDPIPE:
|
|
|
|
info->protocol= MYSQL_VIO_PIPE;
|
|
|
|
info->handle= vio->hPipe;
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
default: DBUG_ASSERT(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void client_mpvio_info(MYSQL_PLUGIN_VIO *vio,
|
|
|
|
MYSQL_PLUGIN_VIO_INFO *info)
|
|
|
|
{
|
|
|
|
MCPVIO_EXT *mpvio= (MCPVIO_EXT*)vio;
|
|
|
|
mpvio_info(mpvio->mysql->net.vio, info);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Client side of the plugin driver authentication.
|
|
|
|
|
|
|
|
@note this is used by both the mysql_real_connect and mysql_change_user
|
|
|
|
|
|
|
|
@param mysql mysql
|
|
|
|
@param data pointer to the plugin auth data (scramble) in the
|
|
|
|
handshake packet
|
|
|
|
@param data_len the length of the data
|
|
|
|
@param data_plugin a plugin that data were prepared for
|
|
|
|
or 0 if it's mysql_change_user()
|
|
|
|
@param db initial db to use, can be 0
|
|
|
|
|
|
|
|
@retval 0 ok
|
|
|
|
@retval 1 error
|
|
|
|
*/
|
|
|
|
int run_plugin_auth(MYSQL *mysql, char *data, uint data_len,
|
2010-04-01 11:04:26 +02:00
|
|
|
const char *data_plugin, const char *db)
|
2010-03-29 17:13:53 +02:00
|
|
|
{
|
|
|
|
const char *auth_plugin_name;
|
|
|
|
auth_plugin_t *auth_plugin;
|
|
|
|
MCPVIO_EXT mpvio;
|
|
|
|
ulong pkt_length;
|
|
|
|
int res;
|
|
|
|
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_ENTER ("run_plugin_auth");
|
2010-03-29 17:13:53 +02:00
|
|
|
/* determine the default/initial plugin to use */
|
|
|
|
if (mysql->options.extension && mysql->options.extension->default_auth &&
|
|
|
|
mysql->server_capabilities & CLIENT_PLUGIN_AUTH)
|
|
|
|
{
|
|
|
|
auth_plugin_name= mysql->options.extension->default_auth;
|
|
|
|
if (!(auth_plugin= (auth_plugin_t*) mysql_client_find_plugin(mysql,
|
|
|
|
auth_plugin_name, MYSQL_CLIENT_AUTHENTICATION_PLUGIN)))
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_RETURN (1); /* oops, not found */
|
2010-03-29 17:13:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auth_plugin= mysql->server_capabilities & CLIENT_PROTOCOL_41 ?
|
|
|
|
&native_password_client_plugin : &old_password_client_plugin;
|
|
|
|
auth_plugin_name= auth_plugin->name;
|
|
|
|
}
|
|
|
|
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_PRINT ("info", ("using plugin %s", auth_plugin_name));
|
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
mysql->net.last_errno= 0; /* just in case */
|
|
|
|
|
|
|
|
if (data_plugin && strcmp(data_plugin, auth_plugin_name))
|
|
|
|
{
|
|
|
|
/* data was prepared for a different plugin, don't show it to this one */
|
|
|
|
data= 0;
|
|
|
|
data_len= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
mpvio.mysql_change_user= data_plugin == 0;
|
|
|
|
mpvio.cached_server_reply.pkt= (uchar*)data;
|
|
|
|
mpvio.cached_server_reply.pkt_len= data_len;
|
|
|
|
mpvio.read_packet= client_mpvio_read_packet;
|
|
|
|
mpvio.write_packet= client_mpvio_write_packet;
|
|
|
|
mpvio.info= client_mpvio_info;
|
|
|
|
mpvio.mysql= mysql;
|
|
|
|
mpvio.packets_read= mpvio.packets_written= 0;
|
|
|
|
mpvio.db= db;
|
|
|
|
mpvio.plugin= auth_plugin;
|
|
|
|
|
2021-10-21 04:13:45 +02:00
|
|
|
DBUG_EXECUTE_IF("client_delay_run_plugin_auth", my_sleep(400000););
|
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
res= auth_plugin->authenticate_user((struct st_plugin_vio *)&mpvio, mysql);
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_PRINT ("info", ("authenticate_user returned %s",
|
|
|
|
res == CR_OK ? "CR_OK" :
|
|
|
|
res == CR_ERROR ? "CR_ERROR" :
|
|
|
|
res == CR_OK_HANDSHAKE_COMPLETE ?
|
|
|
|
"CR_OK_HANDSHAKE_COMPLETE" : "error"));
|
2010-03-29 17:13:53 +02:00
|
|
|
|
|
|
|
compile_time_assert(CR_OK == -1);
|
|
|
|
compile_time_assert(CR_ERROR == 0);
|
2018-04-30 23:06:09 +02:00
|
|
|
if (res > CR_OK && (mysql->net.last_errno || mysql->net.read_pos[0] != 254))
|
2010-03-29 17:13:53 +02:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
the plugin returned an error. write it down in mysql,
|
|
|
|
unless the error code is CR_ERROR and mysql->net.last_errno
|
|
|
|
is already set (the plugin has done it)
|
|
|
|
*/
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_PRINT ("info", ("res=%d", res));
|
2010-03-29 17:13:53 +02:00
|
|
|
if (res > CR_ERROR)
|
|
|
|
set_mysql_error(mysql, res, unknown_sqlstate);
|
|
|
|
else
|
|
|
|
if (!mysql->net.last_errno)
|
|
|
|
set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_RETURN (1);
|
2010-03-29 17:13:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* read the OK packet (or use the cached value in mysql->net.read_pos */
|
|
|
|
if (res == CR_OK)
|
|
|
|
pkt_length= (*mysql->methods->read_change_user_result)(mysql);
|
|
|
|
else /* res == CR_OK_HANDSHAKE_COMPLETE */
|
|
|
|
pkt_length= mpvio.last_read_packet_len;
|
|
|
|
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_PRINT ("info", ("OK packet length=%lu", pkt_length));
|
2010-03-29 17:13:53 +02:00
|
|
|
if (pkt_length == packet_error)
|
|
|
|
{
|
|
|
|
if (mysql->net.last_errno == CR_SERVER_LOST)
|
|
|
|
set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
|
|
|
|
ER(CR_SERVER_LOST_EXTENDED),
|
|
|
|
"reading authorization packet",
|
|
|
|
errno);
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_RETURN (1);
|
2010-03-29 17:13:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mysql->net.read_pos[0] == 254)
|
|
|
|
{
|
|
|
|
/* The server asked to use a different authentication plugin */
|
|
|
|
if (pkt_length == 1)
|
|
|
|
{
|
|
|
|
/* old "use short scramble" packet */
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_PRINT ("info", ("old use short scramble packet from server"));
|
2010-03-29 17:13:53 +02:00
|
|
|
auth_plugin_name= old_password_plugin_name;
|
|
|
|
mpvio.cached_server_reply.pkt= (uchar*)mysql->scramble;
|
|
|
|
mpvio.cached_server_reply.pkt_len= SCRAMBLE_LENGTH + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* new "use different plugin" packet */
|
|
|
|
uint len;
|
|
|
|
auth_plugin_name= (char*)mysql->net.read_pos + 1;
|
2018-02-06 13:55:58 +01:00
|
|
|
len= (uint)strlen(auth_plugin_name); /* safe as my_net_read always appends \0 */
|
2010-03-29 17:13:53 +02:00
|
|
|
mpvio.cached_server_reply.pkt_len= pkt_length - len - 2;
|
|
|
|
mpvio.cached_server_reply.pkt= mysql->net.read_pos + len + 2;
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_PRINT ("info", ("change plugin packet from server for plugin %s",
|
|
|
|
auth_plugin_name));
|
2010-03-29 17:13:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(auth_plugin= (auth_plugin_t *) mysql_client_find_plugin(mysql,
|
|
|
|
auth_plugin_name, MYSQL_CLIENT_AUTHENTICATION_PLUGIN)))
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_RETURN (1);
|
2010-03-29 17:13:53 +02:00
|
|
|
|
|
|
|
mpvio.plugin= auth_plugin;
|
|
|
|
res= auth_plugin->authenticate_user((struct st_plugin_vio *)&mpvio, mysql);
|
|
|
|
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_PRINT ("info", ("second authenticate_user returned %s",
|
|
|
|
res == CR_OK ? "CR_OK" :
|
|
|
|
res == CR_ERROR ? "CR_ERROR" :
|
|
|
|
res == CR_OK_HANDSHAKE_COMPLETE ?
|
|
|
|
"CR_OK_HANDSHAKE_COMPLETE" : "error"));
|
2010-03-29 17:13:53 +02:00
|
|
|
if (res > CR_OK)
|
|
|
|
{
|
|
|
|
if (res > CR_ERROR)
|
|
|
|
set_mysql_error(mysql, res, unknown_sqlstate);
|
|
|
|
else
|
|
|
|
if (!mysql->net.last_errno)
|
|
|
|
set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_RETURN (1);
|
2010-03-29 17:13:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (res != CR_OK_HANDSHAKE_COMPLETE)
|
|
|
|
{
|
|
|
|
/* Read what server thinks about out new auth message report */
|
|
|
|
if (cli_safe_read(mysql) == packet_error)
|
|
|
|
{
|
|
|
|
if (mysql->net.last_errno == CR_SERVER_LOST)
|
|
|
|
set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
|
|
|
|
ER(CR_SERVER_LOST_EXTENDED),
|
|
|
|
"reading final connect information",
|
|
|
|
errno);
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_RETURN (1);
|
2010-03-29 17:13:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
net->read_pos[0] should always be 0 here if the server implements
|
|
|
|
the protocol correctly
|
|
|
|
*/
|
2010-08-09 10:32:50 +02:00
|
|
|
DBUG_RETURN (mysql->net.read_pos[0] != 0);
|
2010-03-29 17:13:53 +02:00
|
|
|
}
|
|
|
|
|
2006-06-19 19:11:01 +02:00
|
|
|
|
2011-09-20 12:49:25 +02:00
|
|
|
static int
|
|
|
|
connect_sync_or_async(MYSQL *mysql, NET *net, my_socket fd,
|
2015-11-03 18:14:13 +01:00
|
|
|
struct sockaddr *name, uint namelen)
|
2011-09-20 12:49:25 +02:00
|
|
|
{
|
2015-11-03 18:14:13 +01:00
|
|
|
int vio_timeout = get_vio_connect_timeout(mysql);
|
|
|
|
|
2012-01-06 12:43:18 +01:00
|
|
|
if (mysql->options.extension && mysql->options.extension->async_context &&
|
|
|
|
mysql->options.extension->async_context->active)
|
2011-09-20 12:49:25 +02:00
|
|
|
{
|
|
|
|
my_bool old_mode;
|
|
|
|
vio_blocking(net->vio, FALSE, &old_mode);
|
2012-01-06 12:43:18 +01:00
|
|
|
return my_connect_async(mysql->options.extension->async_context, fd,
|
2012-10-12 11:00:01 +02:00
|
|
|
name, namelen, vio_timeout);
|
2011-09-20 12:49:25 +02:00
|
|
|
}
|
2012-01-06 12:43:18 +01:00
|
|
|
|
2015-11-03 18:14:13 +01:00
|
|
|
return vio_socket_connect(net->vio, name, namelen, vio_timeout);
|
2011-09-20 12:49:25 +02:00
|
|
|
}
|
|
|
|
|
2013-10-03 17:00:44 +02:00
|
|
|
|
|
|
|
/** set some default attributes */
|
|
|
|
static int
|
|
|
|
set_connect_attributes(MYSQL *mysql, char *buff, size_t buf_len)
|
|
|
|
{
|
|
|
|
int rc= 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
Clean up any values set by the client code. We want these options as
|
|
|
|
consistent as possible
|
|
|
|
*/
|
|
|
|
rc+= mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "_client_name");
|
|
|
|
rc+= mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "_os");
|
|
|
|
rc+= mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "_platform");
|
2018-05-11 04:11:48 +02:00
|
|
|
rc+= mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "_server_host");
|
2013-10-03 17:00:44 +02:00
|
|
|
rc+= mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "_pid");
|
|
|
|
rc+= mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "_thread");
|
|
|
|
rc+= mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "_client_version");
|
|
|
|
|
|
|
|
/*
|
|
|
|
Now let's set up some values
|
|
|
|
*/
|
|
|
|
rc+= mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
|
|
|
|
"_client_name", "libmysql");
|
|
|
|
rc+= mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
|
|
|
|
"_client_version", PACKAGE_VERSION);
|
|
|
|
rc+= mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
|
|
|
|
"_os", SYSTEM_TYPE);
|
|
|
|
rc+= mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
|
|
|
|
"_platform", MACHINE_TYPE);
|
2018-05-10 05:53:29 +02:00
|
|
|
rc+= mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
|
2018-05-11 04:11:48 +02:00
|
|
|
"_server_host", mysql->host);
|
2013-10-03 17:00:44 +02:00
|
|
|
#ifdef __WIN__
|
|
|
|
snprintf(buff, buf_len, "%lu", (ulong) GetCurrentProcessId());
|
|
|
|
#else
|
|
|
|
snprintf(buff, buf_len, "%lu", (ulong) getpid());
|
|
|
|
#endif
|
|
|
|
rc+= mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "_pid", buff);
|
|
|
|
|
|
|
|
#ifdef __WIN__
|
|
|
|
snprintf(buff, buf_len, "%lu", (ulong) GetCurrentThreadId());
|
|
|
|
rc+= mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "_thread", buff);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return rc > 0 ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-17 18:32:31 +02:00
|
|
|
MYSQL * STDCALL
|
|
|
|
CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
|
|
|
|
const char *passwd, const char *db,
|
|
|
|
uint port, const char *unix_socket,ulong client_flag)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2006-09-27 14:49:16 +02:00
|
|
|
char buff[NAME_LEN+USERNAME_LENGTH+100];
|
2015-02-10 11:05:49 +01:00
|
|
|
int scramble_data_len, UNINIT_VAR(pkt_scramble_len);
|
2010-08-09 10:32:50 +02:00
|
|
|
char *end,*host_info= 0, *server_version_end, *pkt_end;
|
2010-04-01 11:04:26 +02:00
|
|
|
char *scramble_data;
|
|
|
|
const char *scramble_plugin;
|
2003-05-02 18:07:41 +02:00
|
|
|
ulong pkt_length;
|
|
|
|
NET *net= &mysql->net;
|
|
|
|
#ifdef __WIN__
|
|
|
|
HANDLE hPipe=INVALID_HANDLE_VALUE;
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_UN_H
|
|
|
|
struct sockaddr_un UNIXaddr;
|
|
|
|
#endif
|
|
|
|
DBUG_ENTER("mysql_real_connect");
|
|
|
|
|
2009-09-30 12:28:15 +02:00
|
|
|
DBUG_PRINT("enter",("host: %s db: %s user: %s (client)",
|
2003-05-02 18:07:41 +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 (net->vio)
|
|
|
|
{
|
|
|
|
set_mysql_error(mysql, CR_ALREADY_CONNECTED, unknown_sqlstate);
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
2003-11-28 15:28:04 +01:00
|
|
|
mysql->methods= &client_methods;
|
2003-05-31 12:15:46 +02:00
|
|
|
mysql->client_flag=0; /* For handshake */
|
2003-05-02 18:07:41 +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);
|
2003-05-02 18:07:41 +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;
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Some empty-string-tests are done because of ODBC */
|
|
|
|
if (!host || !host[0])
|
|
|
|
host=mysql->options.host;
|
|
|
|
if (!user || !user[0])
|
2003-11-28 11:11:44 +01:00
|
|
|
{
|
2003-05-02 18:07:41 +02:00
|
|
|
user=mysql->options.user;
|
2003-11-28 11:11:44 +01:00
|
|
|
if (!user)
|
|
|
|
user= "";
|
|
|
|
}
|
2003-05-02 18:07:41 +02:00
|
|
|
if (!passwd)
|
|
|
|
{
|
|
|
|
passwd=mysql->options.password;
|
2003-06-14 10:37:42 +02:00
|
|
|
#if !defined(DONT_USE_MYSQL_PWD) && !defined(MYSQL_SERVER)
|
2003-05-02 18:07:41 +02:00
|
|
|
if (!passwd)
|
|
|
|
passwd=getenv("MYSQL_PWD"); /* get it from environment */
|
|
|
|
#endif
|
2003-11-28 11:11:44 +01:00
|
|
|
if (!passwd)
|
|
|
|
passwd= "";
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
if (!db || !db[0])
|
|
|
|
db=mysql->options.db;
|
|
|
|
if (!port)
|
|
|
|
port=mysql->options.port;
|
|
|
|
if (!unix_socket)
|
|
|
|
unix_socket=mysql->options.unix_socket;
|
|
|
|
|
|
|
|
mysql->server_status=SERVER_STATUS_AUTOCOMMIT;
|
2009-09-30 12:28:15 +02:00
|
|
|
DBUG_PRINT("info", ("Connecting"));
|
2003-05-02 18:07:41 +02:00
|
|
|
|
|
|
|
/*
|
2003-07-01 21:40:59 +02:00
|
|
|
Part 0: Grab a socket and connect it to the server
|
2003-05-02 18:07:41 +02:00
|
|
|
*/
|
A fix for Bug#35289: Too many connections -- wrong SQL state
in some case.
ER_CON_COUNT_ERROR is defined with SQL state 08004. However, this SQL state is not always
returned.
This error can be thrown in two cases:
1. when an ordinary user (a user w/o SUPER privilege) is connecting,
and the number of active user connections is equal or greater than
max_connections.
2. when a user is connecting and the number of active user connections is
already (max_connections + 1) -- that means that no more connections will
be accepted regardless of the user credentials.
In the 1-st case, SQL state is correct.
The bug happens in the 2-nd case -- on UNIX the client gets 00000 SQL state, which is
absolutely wrong (00000 means "not error SQL state); on Windows
the client accidentally gets HY000 (which means "unknown SQL state).
The cause of the problem is that the server rejects extra connection
prior to read a packet with client capabilities. Thus, the server
does not know if the client supports SQL states or not (if the client
supports 4.1 protocol or not). So, the server supposes the worst and
does not send SQL state at all.
The difference in behavior on UNIX and Windows occurs because on Windows
CLI_MYSQL_REAL_CONNECT() invokes create_shared_memory(), which returns
an error (in default configuration, where shared memory is not configured).
Then, the client does not reset this error, so when the connection is
rejected, SQL state is HY000 (from the error from create_shared_memory()).
The bug appeared after test case for Bug#33507 -- before that, this behavior
just had not been tested.
The fix is to 1) reset the error after create_shared_memory();
2) set SQL state to 'unknown error' if it was not received from
the server.
A separate test case is not required, since the behavior is already
tested in connect.test.
Note for doc-team: the manual should be updated to say that under
some circumstances, 'Too many connections' has HY000 SQL state.
mysql-test/r/connect.result:
Update result file.
sql-common/client.c:
1. Reset an error from create_shared_memory();
2. Set SQL state to 'unknown error' if it was not received from
the server.
2008-03-14 13:58:27 +01:00
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
#if defined(HAVE_SYS_UN_H)
|
2003-06-14 10:37:42 +02:00
|
|
|
if (!net->vio &&
|
|
|
|
(!mysql->options.protocol ||
|
|
|
|
mysql->options.protocol == MYSQL_PROTOCOL_SOCKET) &&
|
|
|
|
(unix_socket || mysql_unix_port) &&
|
|
|
|
(!host || !strcmp(host,LOCAL_HOST)))
|
|
|
|
{
|
2009-11-25 11:53:23 +01:00
|
|
|
my_socket sock= socket(AF_UNIX, SOCK_STREAM, 0);
|
2010-03-16 20:10:45 +01:00
|
|
|
DBUG_PRINT("info", ("Using socket"));
|
2018-02-20 22:17:36 +01:00
|
|
|
if (sock == INVALID_SOCKET)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2007-10-31 15:16:53 +01:00
|
|
|
set_mysql_extended_error(mysql, CR_SOCKET_CREATE_ERROR,
|
|
|
|
unknown_sqlstate,
|
|
|
|
ER(CR_SOCKET_CREATE_ERROR),
|
|
|
|
socket_errno);
|
2003-06-14 10:37:42 +02:00
|
|
|
goto error;
|
|
|
|
}
|
2009-11-25 11:53:23 +01:00
|
|
|
|
2005-03-05 22:10:08 +01:00
|
|
|
net->vio= vio_new(sock, VIO_TYPE_SOCKET,
|
|
|
|
VIO_LOCALHOST | VIO_BUFFERED_READ);
|
2009-11-25 11:53:23 +01:00
|
|
|
if (!net->vio)
|
|
|
|
{
|
|
|
|
DBUG_PRINT("error",("Unknow protocol %d ", mysql->options.protocol));
|
|
|
|
set_mysql_error(mysql, CR_CONN_UNKNOW_PROTOCOL, unknown_sqlstate);
|
|
|
|
closesocket(sock);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
host= LOCAL_HOST;
|
|
|
|
if (!unix_socket)
|
|
|
|
unix_socket= mysql_unix_port;
|
|
|
|
host_info= (char*) ER(CR_LOCALHOST_CONNECTION);
|
|
|
|
DBUG_PRINT("info", ("Using UNIX sock '%s'", unix_socket));
|
|
|
|
|
|
|
|
bzero((char*) &UNIXaddr, sizeof(UNIXaddr));
|
|
|
|
UNIXaddr.sun_family= AF_UNIX;
|
2013-04-17 19:42:34 +02:00
|
|
|
strmake_buf(UNIXaddr.sun_path, unix_socket);
|
2011-09-20 12:49:25 +02:00
|
|
|
if (connect_sync_or_async(mysql, net, sock,
|
|
|
|
(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr)))
|
2003-06-14 10:37:42 +02:00
|
|
|
{
|
|
|
|
DBUG_PRINT("error",("Got error %d on connect to local server",
|
|
|
|
socket_errno));
|
2007-10-31 15:16:53 +01:00
|
|
|
set_mysql_extended_error(mysql, CR_CONNECTION_ERROR,
|
|
|
|
unknown_sqlstate,
|
|
|
|
ER(CR_CONNECTION_ERROR),
|
|
|
|
unix_socket, socket_errno);
|
2009-11-25 11:53:23 +01:00
|
|
|
vio_delete(net->vio);
|
|
|
|
net->vio= 0;
|
2003-06-14 10:37:42 +02:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
mysql->options.protocol=MYSQL_PROTOCOL_SOCKET;
|
|
|
|
}
|
|
|
|
#elif defined(__WIN__)
|
|
|
|
if (!net->vio &&
|
|
|
|
(mysql->options.protocol == MYSQL_PROTOCOL_PIPE ||
|
|
|
|
(host && !strcmp(host,LOCAL_HOST_NAMEDPIPE)) ||
|
2018-02-20 22:17:36 +01:00
|
|
|
(! have_tcpip && (unix_socket || !host ))))
|
2003-06-14 10:37:42 +02:00
|
|
|
{
|
2007-10-31 22:55:25 +01:00
|
|
|
if ((hPipe= create_named_pipe(mysql, mysql->options.connect_timeout,
|
|
|
|
(char**) &host, (char**) &unix_socket)) ==
|
2003-06-14 10:37:42 +02:00
|
|
|
INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
DBUG_PRINT("error",
|
|
|
|
("host: '%s' socket: '%s' have_tcpip: %d",
|
|
|
|
host ? host : "<null>",
|
|
|
|
unix_socket ? unix_socket : "<null>",
|
|
|
|
(int) have_tcpip));
|
|
|
|
if (mysql->options.protocol == MYSQL_PROTOCOL_PIPE ||
|
|
|
|
(host && !strcmp(host,LOCAL_HOST_NAMEDPIPE)) ||
|
|
|
|
(unix_socket && !strcmp(unix_socket,MYSQL_NAMEDPIPE)))
|
2003-05-02 18:07:41 +02:00
|
|
|
goto error;
|
2003-06-14 10:37:42 +02:00
|
|
|
/* Try also with TCP/IP */
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-02 23:19:58 +01:00
|
|
|
net->vio= vio_new_win32pipe(hPipe);
|
2005-01-09 02:19:42 +01:00
|
|
|
my_snprintf(host_info=buff, sizeof(buff)-1,
|
|
|
|
ER(CR_NAMEDPIPE_CONNECTION), unix_socket);
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
2003-06-14 10:37:42 +02:00
|
|
|
}
|
2003-05-02 18:07:41 +02:00
|
|
|
#endif
|
2009-09-30 12:28:15 +02:00
|
|
|
DBUG_PRINT("info", ("net->vio: %p protocol: %d",
|
|
|
|
net->vio, mysql->options.protocol));
|
2003-06-14 10:37:42 +02:00
|
|
|
if (!net->vio &&
|
|
|
|
(!mysql->options.protocol ||
|
|
|
|
mysql->options.protocol == MYSQL_PROTOCOL_TCP))
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2009-11-25 11:53:23 +01:00
|
|
|
struct addrinfo *res_lst, hints, *t_res;
|
|
|
|
int gai_errno;
|
|
|
|
char port_buf[NI_MAXSERV];
|
2018-02-20 22:17:36 +01:00
|
|
|
my_socket sock= INVALID_SOCKET;
|
2010-03-26 09:09:14 +01:00
|
|
|
int saved_error= 0, status= -1;
|
2009-11-25 11:53:23 +01:00
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
unix_socket=0; /* This is not used */
|
2009-11-25 11:53:23 +01:00
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
if (!port)
|
2009-11-25 11:53:23 +01:00
|
|
|
port= mysql_port;
|
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
if (!host)
|
2009-11-25 11:53:23 +01:00
|
|
|
host= LOCAL_HOST;
|
|
|
|
|
|
|
|
my_snprintf(host_info=buff, sizeof(buff)-1, ER(CR_TCP_CONNECTION), host);
|
|
|
|
DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host, port));
|
|
|
|
DBUG_PRINT("info",("IP '%s'", "client"));
|
|
|
|
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
hints.ai_socktype= SOCK_STREAM;
|
|
|
|
hints.ai_protocol= IPPROTO_TCP;
|
|
|
|
hints.ai_family= AF_UNSPEC;
|
|
|
|
|
|
|
|
DBUG_PRINT("info",("IPV6 getaddrinfo %s", host));
|
|
|
|
my_snprintf(port_buf, NI_MAXSERV, "%d", port);
|
|
|
|
gai_errno= getaddrinfo(host, port_buf, &hints, &res_lst);
|
|
|
|
|
|
|
|
if (gai_errno != 0)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
For DBUG we are keeping the right message but for client we default to
|
|
|
|
historical error message.
|
|
|
|
*/
|
|
|
|
DBUG_PRINT("info",("IPV6 getaddrinfo error %d", gai_errno));
|
|
|
|
set_mysql_extended_error(mysql, CR_UNKNOWN_HOST, unknown_sqlstate,
|
2012-05-29 23:37:55 +02:00
|
|
|
ER(CR_UNKNOWN_HOST), host, gai_errno);
|
2009-11-25 11:53:23 +01:00
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-11-25 11:53:23 +01:00
|
|
|
A hostname might map to multiple IP addresses (IPv4/IPv6). Go over the
|
|
|
|
list of IP addresses until a successful connection can be established.
|
2003-05-02 18:07:41 +02:00
|
|
|
*/
|
2009-11-25 11:53:23 +01:00
|
|
|
DBUG_PRINT("info", ("Try connect on all addresses for host."));
|
|
|
|
for (t_res= res_lst; t_res; t_res= t_res->ai_next)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2009-11-25 11:53:23 +01:00
|
|
|
DBUG_PRINT("info", ("Create socket, family: %d type: %d proto: %d",
|
|
|
|
t_res->ai_family, t_res->ai_socktype,
|
|
|
|
t_res->ai_protocol));
|
|
|
|
sock= socket(t_res->ai_family, t_res->ai_socktype, t_res->ai_protocol);
|
2018-02-20 22:17:36 +01:00
|
|
|
if (sock == INVALID_SOCKET)
|
2009-11-25 11:53:23 +01:00
|
|
|
{
|
|
|
|
saved_error= socket_errno;
|
|
|
|
continue;
|
|
|
|
}
|
2009-07-31 02:28:43 +02:00
|
|
|
|
2012-02-21 22:15:44 +01:00
|
|
|
net->vio= vio_new(sock, VIO_TYPE_TCPIP, VIO_BUFFERED_READ);
|
|
|
|
if (!net->vio)
|
2009-07-31 02:28:43 +02:00
|
|
|
{
|
2012-02-21 22:15:44 +01:00
|
|
|
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
|
|
|
closesocket(sock);
|
|
|
|
freeaddrinfo(res_lst);
|
|
|
|
goto error;
|
2009-07-31 02:28:43 +02:00
|
|
|
}
|
|
|
|
|
2009-11-25 11:53:23 +01:00
|
|
|
DBUG_PRINT("info", ("Connect socket"));
|
2012-02-21 22:15:44 +01:00
|
|
|
status= connect_sync_or_async(mysql, net, sock,
|
2018-02-06 13:55:58 +01:00
|
|
|
t_res->ai_addr, (uint)t_res->ai_addrlen);
|
2009-07-31 02:28:43 +02:00
|
|
|
/*
|
2009-11-25 11:53:23 +01:00
|
|
|
Here we rely on my_connect() to return success only if the
|
|
|
|
connect attempt was really successful. Otherwise we would stop
|
|
|
|
trying another address, believing we were successful.
|
2009-07-31 02:28:43 +02:00
|
|
|
*/
|
2009-11-25 11:53:23 +01:00
|
|
|
if (!status)
|
|
|
|
break;
|
2009-07-31 02:28:43 +02:00
|
|
|
|
2009-11-25 11:53:23 +01:00
|
|
|
/*
|
|
|
|
Save value as socket errno might be overwritten due to
|
|
|
|
calling a socket function below.
|
|
|
|
*/
|
|
|
|
saved_error= socket_errno;
|
2009-07-31 02:28:43 +02:00
|
|
|
|
2009-11-25 11:53:23 +01:00
|
|
|
DBUG_PRINT("info", ("No success, close socket, try next address."));
|
2012-02-21 22:15:44 +01:00
|
|
|
vio_delete(mysql->net.vio);
|
|
|
|
mysql->net.vio= 0;
|
2009-11-25 11:53:23 +01:00
|
|
|
}
|
|
|
|
DBUG_PRINT("info",
|
|
|
|
("End of connect attempts, sock: %d status: %d error: %d",
|
2017-09-19 19:45:17 +02:00
|
|
|
(int)sock, status, saved_error));
|
2009-11-25 11:53:23 +01:00
|
|
|
|
|
|
|
freeaddrinfo(res_lst);
|
|
|
|
|
2018-02-20 22:17:36 +01:00
|
|
|
if (sock == INVALID_SOCKET)
|
2009-11-25 11:53:23 +01:00
|
|
|
{
|
|
|
|
set_mysql_extended_error(mysql, CR_IPSOCK_ERROR, unknown_sqlstate,
|
|
|
|
ER(CR_IPSOCK_ERROR), saved_error);
|
|
|
|
goto error;
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
2009-07-31 02:28:43 +02:00
|
|
|
|
|
|
|
if (status)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2009-11-25 11:53:23 +01:00
|
|
|
DBUG_PRINT("error",("Got error %d on connect to '%s'", saved_error, host));
|
2007-10-31 15:16:53 +01:00
|
|
|
set_mysql_extended_error(mysql, CR_CONN_HOST_ERROR, unknown_sqlstate,
|
2009-11-25 11:53:23 +01:00
|
|
|
ER(CR_CONN_HOST_ERROR), host, saved_error);
|
|
|
|
goto error;
|
|
|
|
}
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
2009-11-25 11:53:23 +01:00
|
|
|
|
|
|
|
DBUG_PRINT("info", ("net->vio: %p", net->vio));
|
2003-06-14 10:37:42 +02:00
|
|
|
if (!net->vio)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
DBUG_PRINT("error",("Unknow protocol %d ",mysql->options.protocol));
|
2004-03-12 13:21:48 +01:00
|
|
|
set_mysql_error(mysql, CR_CONN_UNKNOW_PROTOCOL, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
goto error;
|
|
|
|
}
|
2003-06-14 10:37:42 +02:00
|
|
|
|
2012-01-30 13:45:58 +01:00
|
|
|
if (mysql->options.extension && mysql->options.extension->async_context)
|
2012-01-06 12:43:18 +01:00
|
|
|
net->vio->async_context= mysql->options.extension->async_context;
|
2011-09-20 12:49:25 +02:00
|
|
|
|
2017-04-24 15:39:47 +02:00
|
|
|
if (my_net_init(net, net->vio, _current_thd(), MYF(0)))
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
vio_delete(net->vio);
|
|
|
|
net->vio = 0;
|
2004-03-12 13:21:48 +01:00
|
|
|
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
vio_keepalive(net->vio,TRUE);
|
2007-01-29 14:31:48 +01:00
|
|
|
|
|
|
|
/* If user set read_timeout, let it override the default */
|
2003-06-14 10:37:42 +02:00
|
|
|
if (mysql->options.read_timeout)
|
2007-05-24 11:21:27 +02:00
|
|
|
my_net_set_read_timeout(net, mysql->options.read_timeout);
|
2007-01-29 14:31:48 +01:00
|
|
|
|
|
|
|
/* If user set write_timeout, let it override the default */
|
2003-06-14 10:37:42 +02:00
|
|
|
if (mysql->options.write_timeout)
|
2007-05-24 11:21:27 +02:00
|
|
|
my_net_set_write_timeout(net, mysql->options.write_timeout);
|
2007-01-29 14:31:48 +01:00
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
if (mysql->options.max_allowed_packet)
|
|
|
|
net->max_packet_size= mysql->options.max_allowed_packet;
|
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
/* Get version info */
|
|
|
|
mysql->protocol_version= PROTOCOL_VERSION; /* Assume this */
|
|
|
|
if (mysql->options.connect_timeout &&
|
2012-08-14 16:23:34 +02:00
|
|
|
(vio_io_wait(net->vio, VIO_IO_EVENT_READ,
|
|
|
|
get_vio_connect_timeout(mysql)) < 1))
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2006-11-23 15:41:21 +01:00
|
|
|
set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
|
|
|
|
ER(CR_SERVER_LOST_EXTENDED),
|
|
|
|
"waiting for initial communication packet",
|
|
|
|
errno);
|
2003-05-02 18:07:41 +02:00
|
|
|
goto error;
|
|
|
|
}
|
2003-07-01 21:40:59 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Part 1: Connection established, read and parse first packet
|
|
|
|
*/
|
2009-09-30 12:28:15 +02:00
|
|
|
DBUG_PRINT("info", ("Read first packet."));
|
2003-07-01 21:40:59 +02:00
|
|
|
|
A fix and a test case for Bug#15752 "Lost connection to MySQL server
when calling a SP from C API"
The bug was caused by lack of checks for misuse in mysql_real_query.
A stored procedure always returns at least one result, which is the
status of execution of the procedure itself.
This result, or so-called OK packet, is similar to a result
returned by INSERT/UPDATE/CREATE operations: it contains the overall
status of execution, the number of affected rows and the number of
warnings. The client test program attached to the bug did not read this
result and ivnoked the next query. In turn, libmysql had no check for
such scenario and mysql_real_query was simply trying to send that query
without reading the pending response, thus messing up the communication
protocol.
The fix is to return an error from mysql_real_query when it's called
prior to retrieval of all pending results.
client/mysqlbinlog.cc:
net_safe_read -> cli_safe_read
include/mysql.h:
Remove a private function from the public header.
include/mysql_com.h:
Remove a define that is never used.
include/sql_common.h:
Add a declaration for cli_safe_read - a function that reads one packet
from the server.
libmysql/libmysql.c:
net_safe_read -> cli_safe_read
Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
using a connection which has pending result sets.
sql-common/client.c:
Actual fix for Bug#15752: if the server has pending result sets for
the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
another query. Similarly to the behaviour of mysql_use_result(),
multiple result sets block the connection and must be fetched
before it can be used for another query.
This uncovered an error in the protocol: the server doesn't drop
SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
a multi-query like SELECT 1; SELECT syntax_error; SELECT 2;
the client has no way to know that the server won't ever come to
execution of the third query and won't return any result sets for it.
For now, fix it in cli_safe_read, as a proper fix requires extension
of the client-server protocol.
sql/protocol.cc:
Remove a name that is never used.
sql/slave.cc:
net_safe_read -> cli_safe_read
tests/mysql_client_test.c:
Make 'query' a local variable to avoid name clash.
Add a test case for Bug#15752 "Lost connection to MySQL server when
calling an SP from C API"
2006-07-24 12:56:53 +02:00
|
|
|
if ((pkt_length=cli_safe_read(mysql)) == packet_error)
|
2006-11-23 15:41:21 +01:00
|
|
|
{
|
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
|
|
|
if (mysql->net.last_errno == CR_SERVER_LOST)
|
2006-11-23 15:41:21 +01:00
|
|
|
set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
|
|
|
|
ER(CR_SERVER_LOST_EXTENDED),
|
|
|
|
"reading initial communication packet",
|
|
|
|
errno);
|
2003-05-02 18:07:41 +02:00
|
|
|
goto error;
|
2006-11-23 15:41:21 +01:00
|
|
|
}
|
2010-03-29 17:13:53 +02:00
|
|
|
pkt_end= (char*)net->read_pos + pkt_length;
|
2003-05-02 18:07:41 +02:00
|
|
|
/* Check if version of protocol matches current one */
|
|
|
|
mysql->protocol_version= net->read_pos[0];
|
2008-01-30 16:03:00 +01:00
|
|
|
DBUG_DUMP("packet",(uchar*) net->read_pos,10);
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_PRINT("info",("mysql protocol version %d, server=%d",
|
|
|
|
PROTOCOL_VERSION, mysql->protocol_version));
|
2003-06-14 10:37:42 +02:00
|
|
|
if (mysql->protocol_version != PROTOCOL_VERSION)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2007-10-31 15:16:53 +01:00
|
|
|
set_mysql_extended_error(mysql, CR_VERSION_ERROR, unknown_sqlstate,
|
|
|
|
ER(CR_VERSION_ERROR), mysql->protocol_version,
|
|
|
|
PROTOCOL_VERSION);
|
2003-05-02 18:07:41 +02:00
|
|
|
goto error;
|
|
|
|
}
|
2010-03-29 17:13:53 +02:00
|
|
|
server_version_end= end= strend((char*) net->read_pos+1);
|
2003-05-02 18:07:41 +02:00
|
|
|
mysql->thread_id=uint4korr(end+1);
|
|
|
|
end+=5;
|
2003-07-01 21:40:59 +02:00
|
|
|
/*
|
2010-03-29 17:13:53 +02:00
|
|
|
Scramble is split into two parts because old clients do not understand
|
2003-07-01 21:40:59 +02:00
|
|
|
long scrambles; here goes the first part.
|
|
|
|
*/
|
2010-03-29 17:13:53 +02:00
|
|
|
scramble_data= end;
|
|
|
|
scramble_data_len= SCRAMBLE_LENGTH_323 + 1;
|
|
|
|
scramble_plugin= old_password_plugin_name;
|
|
|
|
end+= scramble_data_len;
|
2003-07-01 21:40:59 +02:00
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
if (pkt_end >= end + 1)
|
2003-05-02 18:07:41 +02:00
|
|
|
mysql->server_capabilities=uint2korr(end);
|
2010-03-29 17:13:53 +02:00
|
|
|
if (pkt_end >= end + 18)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
/* New protocol with 16 bytes to describe server characteristics */
|
|
|
|
mysql->server_language=end[2];
|
|
|
|
mysql->server_status=uint2korr(end+3);
|
2020-09-23 11:42:30 +02:00
|
|
|
mysql->server_capabilities|= ((unsigned) uint2korr(end+5)) << 16;
|
2010-03-29 17:13:53 +02:00
|
|
|
pkt_scramble_len= end[7];
|
2012-06-29 13:04:24 +02:00
|
|
|
if (pkt_scramble_len < 0)
|
|
|
|
{
|
|
|
|
set_mysql_error(mysql, CR_MALFORMED_PACKET,
|
|
|
|
unknown_sqlstate); /* purecov: inspected */
|
|
|
|
goto error;
|
|
|
|
}
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
2003-07-01 21:40:59 +02:00
|
|
|
end+= 18;
|
2003-05-02 18:07:41 +02:00
|
|
|
|
2003-11-28 11:11:44 +01:00
|
|
|
if (mysql->options.secure_auth && passwd[0] &&
|
|
|
|
!(mysql->server_capabilities & CLIENT_SECURE_CONNECTION))
|
|
|
|
{
|
2004-03-12 13:21:48 +01:00
|
|
|
set_mysql_error(mysql, CR_SECURE_AUTH, unknown_sqlstate);
|
2003-11-28 11:11:44 +01:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2006-06-19 19:11:01 +02:00
|
|
|
if (mysql_init_character_set(mysql))
|
2004-06-07 14:28:31 +02:00
|
|
|
goto error;
|
2003-05-02 18:07:41 +02:00
|
|
|
|
|
|
|
/* Save connection information */
|
|
|
|
if (!my_multi_malloc(MYF(0),
|
|
|
|
&mysql->host_info, (uint) strlen(host_info)+1,
|
|
|
|
&mysql->host, (uint) strlen(host)+1,
|
|
|
|
&mysql->unix_socket,unix_socket ?
|
|
|
|
(uint) strlen(unix_socket)+1 : (uint) 1,
|
|
|
|
&mysql->server_version,
|
2010-03-29 17:13:53 +02:00
|
|
|
(uint) (server_version_end - (char*) net->read_pos + 1),
|
2003-05-02 18:07:41 +02:00
|
|
|
NullS) ||
|
|
|
|
!(mysql->user=my_strdup(user,MYF(0))) ||
|
|
|
|
!(mysql->passwd=my_strdup(passwd,MYF(0))))
|
|
|
|
{
|
2004-03-12 13:21:48 +01:00
|
|
|
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
strmov(mysql->host_info,host_info);
|
|
|
|
strmov(mysql->host,host);
|
|
|
|
if (unix_socket)
|
|
|
|
strmov(mysql->unix_socket,unix_socket);
|
|
|
|
else
|
|
|
|
mysql->unix_socket=0;
|
|
|
|
strmov(mysql->server_version,(char*) net->read_pos+1);
|
|
|
|
mysql->port=port;
|
|
|
|
|
2013-05-05 20:39:31 +02:00
|
|
|
/*
|
2013-06-06 14:14:23 +02:00
|
|
|
remove the rpl hack from the version string,
|
|
|
|
see RPL_VERSION_HACK comment
|
2013-05-05 20:39:31 +02:00
|
|
|
*/
|
|
|
|
if ((mysql->server_capabilities & CLIENT_PLUGIN_AUTH) &&
|
2013-04-09 23:27:52 +02:00
|
|
|
strncmp(mysql->server_version, RPL_VERSION_HACK,
|
|
|
|
sizeof(RPL_VERSION_HACK) - 1) == 0)
|
|
|
|
mysql->server_version+= sizeof(RPL_VERSION_HACK) - 1;
|
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
if (pkt_end >= end + SCRAMBLE_LENGTH - SCRAMBLE_LENGTH_323 + 1)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2006-03-10 16:41:14 +01:00
|
|
|
/*
|
2010-03-29 17:13:53 +02:00
|
|
|
move the first scramble part - directly in the NET buffer -
|
|
|
|
to get a full continuous scramble. We've read all the header,
|
|
|
|
and can overwrite it now.
|
2006-03-10 16:41:14 +01:00
|
|
|
*/
|
2010-03-29 17:13:53 +02:00
|
|
|
memmove(end - SCRAMBLE_LENGTH_323, scramble_data,
|
|
|
|
SCRAMBLE_LENGTH_323);
|
|
|
|
scramble_data= end - SCRAMBLE_LENGTH_323;
|
|
|
|
if (mysql->server_capabilities & CLIENT_PLUGIN_AUTH)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2010-03-29 17:13:53 +02:00
|
|
|
scramble_data_len= pkt_scramble_len;
|
|
|
|
scramble_plugin= scramble_data + scramble_data_len;
|
|
|
|
if (scramble_data + scramble_data_len > pkt_end)
|
2020-01-17 15:08:11 +01:00
|
|
|
{
|
|
|
|
set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate);
|
|
|
|
goto error;
|
|
|
|
}
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
2003-07-04 18:52:04 +02:00
|
|
|
else
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2017-09-28 12:38:02 +02:00
|
|
|
scramble_data_len= (int)(pkt_end - scramble_data);
|
2010-03-29 17:13:53 +02:00
|
|
|
scramble_plugin= native_password_plugin_name;
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2010-03-29 17:13:53 +02:00
|
|
|
mysql->server_capabilities&= ~CLIENT_SECURE_CONNECTION;
|
|
|
|
|
|
|
|
mysql->client_flag= client_flag;
|
2003-07-01 21:40:59 +02:00
|
|
|
|
2018-06-02 22:27:59 +02:00
|
|
|
set_connect_attributes(mysql, buff, sizeof(buff));
|
|
|
|
|
2003-07-01 21:40:59 +02:00
|
|
|
/*
|
2010-03-29 17:13:53 +02:00
|
|
|
Part 2: invoke the plugin to send the authentication data to the server
|
2003-07-01 21:40:59 +02:00
|
|
|
*/
|
2003-05-02 18:07:41 +02:00
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
if (run_plugin_auth(mysql, scramble_data, scramble_data_len,
|
|
|
|
scramble_plugin, db))
|
2003-05-02 18:07:41 +02:00
|
|
|
goto error;
|
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
/*
|
|
|
|
Part 3: authenticated, finish the initialization of the connection
|
|
|
|
*/
|
2003-07-01 21:40:59 +02:00
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
if (mysql->client_flag & CLIENT_COMPRESS) /* We will use compression */
|
2003-05-02 18:07:41 +02:00
|
|
|
net->compress=1;
|
|
|
|
|
2010-03-29 17:13:53 +02:00
|
|
|
if (db && !mysql->db && mysql_select_db(mysql, db))
|
2006-11-23 15:41:21 +01:00
|
|
|
{
|
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
|
|
|
if (mysql->net.last_errno == CR_SERVER_LOST)
|
2006-11-23 15:41:21 +01:00
|
|
|
set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
|
|
|
|
ER(CR_SERVER_LOST_EXTENDED),
|
|
|
|
"Setting intital database",
|
|
|
|
errno);
|
2003-05-02 18:07:41 +02:00
|
|
|
goto error;
|
2006-11-23 15:41:21 +01:00
|
|
|
}
|
2003-05-02 18:07:41 +02:00
|
|
|
|
2010-05-10 05:02:05 +02:00
|
|
|
/*
|
|
|
|
Using init_commands is not supported when connecting from within the
|
|
|
|
server.
|
|
|
|
*/
|
|
|
|
#ifndef MYSQL_SERVER
|
2003-05-02 18:07:41 +02:00
|
|
|
if (mysql->options.init_commands)
|
|
|
|
{
|
|
|
|
DYNAMIC_ARRAY *init_commands= mysql->options.init_commands;
|
|
|
|
char **ptr= (char**)init_commands->buffer;
|
2006-12-14 23:51:37 +01:00
|
|
|
char **end_command= ptr + init_commands->elements;
|
2003-05-02 18:07:41 +02:00
|
|
|
|
|
|
|
my_bool reconnect=mysql->reconnect;
|
|
|
|
mysql->reconnect=0;
|
|
|
|
|
2006-12-14 23:51:37 +01:00
|
|
|
for (; ptr < end_command; ptr++)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2010-05-10 05:02:05 +02:00
|
|
|
int status;
|
|
|
|
|
2005-06-13 12:41:15 +02:00
|
|
|
if (mysql_real_query(mysql,*ptr, (ulong) strlen(*ptr)))
|
2003-05-02 18:07:41 +02:00
|
|
|
goto error;
|
2010-05-10 05:02:05 +02:00
|
|
|
|
|
|
|
do {
|
|
|
|
if (mysql->fields)
|
|
|
|
{
|
|
|
|
MYSQL_RES *res;
|
|
|
|
if (!(res= cli_use_result(mysql)))
|
|
|
|
goto error;
|
|
|
|
mysql_free_result(res);
|
|
|
|
}
|
|
|
|
if ((status= mysql_next_result(mysql)) > 0)
|
|
|
|
goto error;
|
|
|
|
} while (status == 0);
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
mysql->reconnect=reconnect;
|
|
|
|
}
|
2010-05-10 05:02:05 +02:00
|
|
|
#endif
|
2003-05-02 18:07:41 +02:00
|
|
|
|
2017-09-19 19:45:17 +02:00
|
|
|
DBUG_PRINT("exit", ("Mysql handler: %p",mysql));
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(mysql);
|
|
|
|
|
|
|
|
error:
|
2003-05-31 12:15:46 +02:00
|
|
|
DBUG_PRINT("error",("message: %u/%s (%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
|
|
|
net->last_errno,
|
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
|
|
|
net->sqlstate,
|
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
|
|
|
net->last_error));
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
/* Free alloced memory */
|
|
|
|
end_server(mysql);
|
2003-06-14 10:37:42 +02:00
|
|
|
mysql_close_free(mysql);
|
2016-08-16 21:23:57 +02:00
|
|
|
if (!(client_flag & CLIENT_REMEMBER_OPTIONS) &&
|
2018-07-24 17:01:30 +02:00
|
|
|
!(mysql->options.extension && mysql->options.extension->async_context))
|
2016-08-11 17:50:21 +02:00
|
|
|
mysql_close_free_options(mysql);
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
|
2011-09-20 12:49:25 +02:00
|
|
|
struct my_hook_data {
|
|
|
|
MYSQL *orig_mysql;
|
|
|
|
MYSQL *new_mysql;
|
|
|
|
/* This is always NULL currently, but restoring does not hurt just in case. */
|
|
|
|
Vio *orig_vio;
|
|
|
|
};
|
|
|
|
/*
|
|
|
|
Callback hook to make the new VIO accessible via the old MYSQL to calling
|
|
|
|
application when suspending a non-blocking call during automatic reconnect.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
my_suspend_hook(my_bool suspend, void *data)
|
|
|
|
{
|
|
|
|
struct my_hook_data *hook_data= (struct my_hook_data *)data;
|
|
|
|
if (suspend)
|
|
|
|
{
|
|
|
|
hook_data->orig_vio= hook_data->orig_mysql->net.vio;
|
|
|
|
hook_data->orig_mysql->net.vio= hook_data->new_mysql->net.vio;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hook_data->orig_mysql->net.vio= hook_data->orig_vio;
|
|
|
|
}
|
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
my_bool mysql_reconnect(MYSQL *mysql)
|
|
|
|
{
|
|
|
|
MYSQL tmp_mysql;
|
2011-09-20 12:49:25 +02:00
|
|
|
struct my_hook_data hook_data;
|
|
|
|
struct mysql_async_context *ctxt= NULL;
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_ENTER("mysql_reconnect");
|
2006-10-12 10:27:44 +02:00
|
|
|
DBUG_ASSERT(mysql);
|
|
|
|
DBUG_PRINT("enter", ("mysql->reconnect: %d", mysql->reconnect));
|
2003-05-02 18:07:41 +02:00
|
|
|
|
2003-06-05 22:19:56 +02:00
|
|
|
if (!mysql->reconnect ||
|
|
|
|
(mysql->server_status & SERVER_STATUS_IN_TRANS) || !mysql->host_info)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2003-06-05 22:19:56 +02:00
|
|
|
/* Allow reconnect next time */
|
2003-05-02 18:07:41 +02:00
|
|
|
mysql->server_status&= ~SERVER_STATUS_IN_TRANS;
|
2004-03-12 13:21:48 +01:00
|
|
|
set_mysql_error(mysql, CR_SERVER_GONE_ERROR, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
|
|
|
mysql_init(&tmp_mysql);
|
Added option --valgrind-mysqltest to mysql-test-run
Added flag to Field::store(longlong) to specify if value is unsigned.
This fixes bug #12750: Incorrect storage of 9999999999999999999 in DECIMAL(19, 0)
Fixed warning from valgrind in CREATE ... SELECT
Fixed double free of mysql.options if reconnect failed
mysql-test/mysql-test-run.sh:
Added option --valgrind-mysqltest to allow one to run mysqltest with valgrind
mysql-test/r/bigint.result:
Update results after fix for Field::store(longlong)
mysql-test/r/range.result:
Update results after fix for Field::store(longlong)
mysql-test/r/strict.result:
Update results after fix for Field::store(longlong)
(This fixes some wrong results when storing things into bigint columns)
mysql-test/r/type_ranges.result:
Update results after fix for Field::store(longlong)
mysql-test/t/bigint.test:
Added testing for #12750: Incorrect storage of 9999999999999999999 in DECIMAL(19, 0)
mysql-test/t/innodb.test:
Removed comments affected by this bug fix
mysql-test/t/mysqldump.test:
Fixed result to not depend on existing config files
mysql-test/t/range.test:
0xff numbers are now unsigned
mysql-test/t/strict.test:
Added errors for things that previously (wrongly) succeeded
sql-common/client.c:
Fixed double free of mysql.options if reconnect failed
sql/field.cc:
Added flag to Field::store(longlong) to specify if value is unsigned
sql/field.h:
Added flag to Field::store(longlong) to specify if value is unsigned
sql/field_conv.cc:
Fixed calls to Field::store(longlong,flag)
sql/ha_ndbcluster.cc:
Fixed calls to Field::store(longlong,flag)
sql/handler.cc:
Fixed calls to Field::store(longlong,flag)
sql/item.cc:
Fixed calls to Field::store(longlong,flag)
sql/item_sum.cc:
Fixed calls to Field::store(longlong,flag)
sql/sp.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_acl.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_help.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_show.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_table.cc:
Fixed varning from valgrind
sql/sql_udf.cc:
Fixed calls to Field::store(longlong,flag)
sql/tztime.cc:
Fixed calls to Field::store(longlong,flag)
sql/unireg.cc:
Fixed calls to Field::store(longlong,flag)
2005-09-14 00:41:44 +02:00
|
|
|
tmp_mysql.options= mysql->options;
|
2007-06-25 13:40:29 +02:00
|
|
|
tmp_mysql.options.my_cnf_file= tmp_mysql.options.my_cnf_group= 0;
|
2009-10-15 22:56:17 +02:00
|
|
|
|
2011-09-20 12:49:25 +02:00
|
|
|
/*
|
|
|
|
If we are automatically re-connecting inside a non-blocking API call, we
|
|
|
|
may need to suspend and yield to the user application during the reconnect.
|
|
|
|
If so, the user application will need access to the new VIO already then
|
|
|
|
so that it can correctly wait for I/O to become ready.
|
|
|
|
To achieve this, we temporarily install a hook that will temporarily put in
|
|
|
|
the VIO while we are suspended.
|
|
|
|
(The vio will be put in the original MYSQL permanently once we successfully
|
|
|
|
reconnect, or be discarded if we fail to reconnect.)
|
|
|
|
*/
|
2012-01-06 12:43:18 +01:00
|
|
|
if (mysql->options.extension &&
|
|
|
|
(ctxt= mysql->options.extension->async_context) &&
|
|
|
|
mysql->options.extension->async_context->active)
|
2011-09-20 12:49:25 +02:00
|
|
|
{
|
|
|
|
hook_data.orig_mysql= mysql;
|
|
|
|
hook_data.new_mysql= &tmp_mysql;
|
|
|
|
hook_data.orig_vio= mysql->net.vio;
|
|
|
|
my_context_install_suspend_resume_hook(ctxt, my_suspend_hook, &hook_data);
|
|
|
|
}
|
2003-05-02 18:07:41 +02:00
|
|
|
if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
|
|
|
|
mysql->db, mysql->port, mysql->unix_socket,
|
2016-08-11 17:50:21 +02:00
|
|
|
mysql->client_flag | CLIENT_REMEMBER_OPTIONS))
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2011-09-20 12:49:25 +02:00
|
|
|
if (ctxt)
|
|
|
|
my_context_install_suspend_resume_hook(ctxt, NULL, NULL);
|
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= tmp_mysql.net.last_errno;
|
|
|
|
strmov(mysql->net.last_error, tmp_mysql.net.last_error);
|
2003-06-14 10:37:42 +02:00
|
|
|
strmov(mysql->net.sqlstate, tmp_mysql.net.sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
2005-07-28 15:10:14 +02:00
|
|
|
if (mysql_set_character_set(&tmp_mysql, mysql->charset->csname))
|
|
|
|
{
|
Added option --valgrind-mysqltest to mysql-test-run
Added flag to Field::store(longlong) to specify if value is unsigned.
This fixes bug #12750: Incorrect storage of 9999999999999999999 in DECIMAL(19, 0)
Fixed warning from valgrind in CREATE ... SELECT
Fixed double free of mysql.options if reconnect failed
mysql-test/mysql-test-run.sh:
Added option --valgrind-mysqltest to allow one to run mysqltest with valgrind
mysql-test/r/bigint.result:
Update results after fix for Field::store(longlong)
mysql-test/r/range.result:
Update results after fix for Field::store(longlong)
mysql-test/r/strict.result:
Update results after fix for Field::store(longlong)
(This fixes some wrong results when storing things into bigint columns)
mysql-test/r/type_ranges.result:
Update results after fix for Field::store(longlong)
mysql-test/t/bigint.test:
Added testing for #12750: Incorrect storage of 9999999999999999999 in DECIMAL(19, 0)
mysql-test/t/innodb.test:
Removed comments affected by this bug fix
mysql-test/t/mysqldump.test:
Fixed result to not depend on existing config files
mysql-test/t/range.test:
0xff numbers are now unsigned
mysql-test/t/strict.test:
Added errors for things that previously (wrongly) succeeded
sql-common/client.c:
Fixed double free of mysql.options if reconnect failed
sql/field.cc:
Added flag to Field::store(longlong) to specify if value is unsigned
sql/field.h:
Added flag to Field::store(longlong) to specify if value is unsigned
sql/field_conv.cc:
Fixed calls to Field::store(longlong,flag)
sql/ha_ndbcluster.cc:
Fixed calls to Field::store(longlong,flag)
sql/handler.cc:
Fixed calls to Field::store(longlong,flag)
sql/item.cc:
Fixed calls to Field::store(longlong,flag)
sql/item_sum.cc:
Fixed calls to Field::store(longlong,flag)
sql/sp.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_acl.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_help.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_show.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_table.cc:
Fixed varning from valgrind
sql/sql_udf.cc:
Fixed calls to Field::store(longlong,flag)
sql/tztime.cc:
Fixed calls to Field::store(longlong,flag)
sql/unireg.cc:
Fixed calls to Field::store(longlong,flag)
2005-09-14 00:41:44 +02:00
|
|
|
DBUG_PRINT("error", ("mysql_set_character_set() failed"));
|
|
|
|
bzero((char*) &tmp_mysql.options,sizeof(tmp_mysql.options));
|
2005-07-28 15:10:14 +02:00
|
|
|
mysql_close(&tmp_mysql);
|
2011-09-20 12:49:25 +02:00
|
|
|
if (ctxt)
|
|
|
|
my_context_install_suspend_resume_hook(ctxt, NULL, NULL);
|
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= tmp_mysql.net.last_errno;
|
|
|
|
strmov(mysql->net.last_error, tmp_mysql.net.last_error);
|
2005-07-28 15:10:14 +02:00
|
|
|
strmov(mysql->net.sqlstate, tmp_mysql.net.sqlstate);
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
2011-09-20 12:49:25 +02:00
|
|
|
if (ctxt)
|
|
|
|
my_context_install_suspend_resume_hook(ctxt, NULL, NULL);
|
2005-07-28 15:10:14 +02:00
|
|
|
|
2018-12-21 21:06:08 +01:00
|
|
|
DBUG_PRINT("info", ("reconnect succeeded"));
|
2004-12-09 14:44:10 +01:00
|
|
|
tmp_mysql.reconnect= 1;
|
2003-06-24 11:10:35 +02:00
|
|
|
tmp_mysql.free_me= mysql->free_me;
|
2005-03-28 19:59:41 +02:00
|
|
|
|
2009-05-20 16:17:47 +02:00
|
|
|
/* Move prepared statements (if any) over to the new mysql object */
|
|
|
|
tmp_mysql.stmts= mysql->stmts;
|
|
|
|
mysql->stmts= 0;
|
2005-03-28 19:59:41 +02:00
|
|
|
|
2003-06-24 11:10:35 +02:00
|
|
|
/* Don't free options as these are now used in tmp_mysql */
|
|
|
|
bzero((char*) &mysql->options,sizeof(mysql->options));
|
2003-05-02 18:07:41 +02:00
|
|
|
mysql->free_me=0;
|
|
|
|
mysql_close(mysql);
|
|
|
|
*mysql=tmp_mysql;
|
2006-11-30 02:40:42 +01:00
|
|
|
net_clear(&mysql->net, 1);
|
2003-05-02 18:07:41 +02:00
|
|
|
mysql->affected_rows= ~(my_ulonglong) 0;
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
/**************************************************************************
|
|
|
|
Set current database
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
int STDCALL
|
|
|
|
mysql_select_db(MYSQL *mysql, const char *db)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
DBUG_ENTER("mysql_select_db");
|
|
|
|
DBUG_PRINT("enter",("db: '%s'",db));
|
|
|
|
|
2007-08-13 15:11:25 +02:00
|
|
|
if ((error=simple_command(mysql,COM_INIT_DB, (const uchar*) db,
|
|
|
|
(ulong) strlen(db),0)))
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(error);
|
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->db);
|
2003-05-02 18:07:41 +02:00
|
|
|
mysql->db=my_strdup(db,MYF(MY_WME));
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Send a QUIT to the server and close the connection
|
|
|
|
If handle is alloced by mysql connect free it.
|
|
|
|
*************************************************************************/
|
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
static void mysql_close_free_options(MYSQL *mysql)
|
|
|
|
{
|
Added option --valgrind-mysqltest to mysql-test-run
Added flag to Field::store(longlong) to specify if value is unsigned.
This fixes bug #12750: Incorrect storage of 9999999999999999999 in DECIMAL(19, 0)
Fixed warning from valgrind in CREATE ... SELECT
Fixed double free of mysql.options if reconnect failed
mysql-test/mysql-test-run.sh:
Added option --valgrind-mysqltest to allow one to run mysqltest with valgrind
mysql-test/r/bigint.result:
Update results after fix for Field::store(longlong)
mysql-test/r/range.result:
Update results after fix for Field::store(longlong)
mysql-test/r/strict.result:
Update results after fix for Field::store(longlong)
(This fixes some wrong results when storing things into bigint columns)
mysql-test/r/type_ranges.result:
Update results after fix for Field::store(longlong)
mysql-test/t/bigint.test:
Added testing for #12750: Incorrect storage of 9999999999999999999 in DECIMAL(19, 0)
mysql-test/t/innodb.test:
Removed comments affected by this bug fix
mysql-test/t/mysqldump.test:
Fixed result to not depend on existing config files
mysql-test/t/range.test:
0xff numbers are now unsigned
mysql-test/t/strict.test:
Added errors for things that previously (wrongly) succeeded
sql-common/client.c:
Fixed double free of mysql.options if reconnect failed
sql/field.cc:
Added flag to Field::store(longlong) to specify if value is unsigned
sql/field.h:
Added flag to Field::store(longlong) to specify if value is unsigned
sql/field_conv.cc:
Fixed calls to Field::store(longlong,flag)
sql/ha_ndbcluster.cc:
Fixed calls to Field::store(longlong,flag)
sql/handler.cc:
Fixed calls to Field::store(longlong,flag)
sql/item.cc:
Fixed calls to Field::store(longlong,flag)
sql/item_sum.cc:
Fixed calls to Field::store(longlong,flag)
sql/sp.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_acl.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_help.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_show.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_table.cc:
Fixed varning from valgrind
sql/sql_udf.cc:
Fixed calls to Field::store(longlong,flag)
sql/tztime.cc:
Fixed calls to Field::store(longlong,flag)
sql/unireg.cc:
Fixed calls to Field::store(longlong,flag)
2005-09-14 00:41:44 +02:00
|
|
|
DBUG_ENTER("mysql_close_free_options");
|
|
|
|
|
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.user);
|
|
|
|
my_free(mysql->options.host);
|
|
|
|
my_free(mysql->options.password);
|
|
|
|
my_free(mysql->options.unix_socket);
|
|
|
|
my_free(mysql->options.db);
|
|
|
|
my_free(mysql->options.my_cnf_file);
|
|
|
|
my_free(mysql->options.my_cnf_group);
|
|
|
|
my_free(mysql->options.charset_dir);
|
|
|
|
my_free(mysql->options.charset_name);
|
|
|
|
my_free(mysql->options.client_ip);
|
2003-06-14 10:37:42 +02:00
|
|
|
if (mysql->options.init_commands)
|
|
|
|
{
|
|
|
|
DYNAMIC_ARRAY *init_commands= mysql->options.init_commands;
|
|
|
|
char **ptr= (char**)init_commands->buffer;
|
|
|
|
char **end= ptr + init_commands->elements;
|
|
|
|
for (; ptr<end; ptr++)
|
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(*ptr);
|
2003-06-14 10:37:42 +02:00
|
|
|
delete_dynamic(init_commands);
|
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(init_commands);
|
2003-06-14 10:37:42 +02:00
|
|
|
}
|
Backport of:
ChangeSet@1.2703, 2007-12-07 09:35:28-05:00, cmiller@zippy.cornsilk.net +40 -0
Bug#13174: SHA2 function
Patch contributed from Bill Karwin, paper unnumbered CLA in Seattle
Implement SHA2 functions.
Chad added code to make it work with YaSSL. Also, he removed the
(probable) bug of embedded server never using SSL-dependent
functions. (libmysqld/Makefile.am didn't read ANY autoconf defs.)
Function specification:
SHA2( string cleartext, integer hash_length )
-> string hash, or NULL
where hash_length is one of 224, 256, 384, or 512. If either is
NULL or a length is unsupported, then the result is NULL. The
resulting string is always the length of the hash_length parameter
or is NULL.
Include the canonical hash examples from the NIST in the test
results.
---
Polish and address concerns of reviewers.
.bzrignore:
Added libmysqld/sha2.cc to the ignore list.
client/mysql.cc:
Add condition to remove code for embedded server.
client/mysqltest.cc:
Add condition to remove code for embedded server.
include/Makefile.am:
New header file to header list.
include/mysql_embed.h:
Embedded servers can use SSL-library functions too!
include/sha2.h:
Compatibility layer to make YaSSL behave like OpenSSL.
include/sslopt-case.h:
Remove SSL-communication parameters from command lines.
include/sslopt-longopts.h:
Remove SSL-communication parameters from command lines.
include/sslopt-vars.h:
Don't declare variables that are only used in SSL communication, if
we are compiling the embedded server.
include/violite.h:
Don't even compile the SSL-communication function if we're in the
embedded server.
---
Remove CPP condition indentation.
libmysqld/CMakeLists.txt:
Add new file to source list.
libmysqld/Makefile.am:
Include standard DEFS in embedded compilation. It's an undiscovered
but that it's not there.
Add new file to source list.
libmysqld/examples/Makefile.am:
Include autoconf DEFS.
libmysqld/lib_sql.cc:
Initialize SSL-related variables in embedded server.
mysql-test/include/have_ssl_crypto_functs.inc:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/r/func_digest.result:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
mysql-test/r/func_encrypt_nossl.result:
Update results to the new error message text.
mysql-test/r/have_ssl_is_yes_or_disabled_only.require:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/suite/rpl/t/rpl_ssl.test:
Distinguish between communication and crypto.
mysql-test/suite/rpl/t/rpl_ssl1.test:
Distinguish between communication and crypto.
mysql-test/t/func_des_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/func_digest.test:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
Also, test that various parameters (legal and illegal)
do what we expect.
---
Distinguish between communication and crypto.
mysql-test/t/func_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/openssl_1.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl-big.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_8k_key.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_compress.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_connect.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
sql-common/client.c:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/CMakeLists.txt:
Add new source file to source list so that we have access to SHA2
functions.
sql/Makefile.am:
Add new source file to source list so that we have access to SHA2
functions.
sql/item_create.cc:
Bootstrap the SHA2 function into the server.
sql/item_strfunc.cc:
Add new SHA2 Item class methods.
Clean up two minor problems.
---
Remove extraneous debugging.
---
We must check nullness of a parameter only /after/ computing its
value.
sql/item_strfunc.h:
Declare new SHA2 Item class.
sql/mysqld.cc:
For embedded server, don't refer to SSL-communications variables
or values.
---
Remove CPP condition indentation.
sql/sha2.cc:
Compatibility layer to make YaSSL behave like OpenSSL.
---
Add comment for generated functions.
sql/sql_acl.cc:
For embedded server, don't refer to SSL-communications variables
or values.
sql/sql_connect.cc:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/sys_vars.cc:
For embedded server, don't refer to SSL-communications variables
or values.
2010-04-13 17:04:45 +02:00
|
|
|
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
|
2003-06-14 10:37:42 +02:00
|
|
|
mysql_ssl_free(mysql);
|
Backport of:
ChangeSet@1.2703, 2007-12-07 09:35:28-05:00, cmiller@zippy.cornsilk.net +40 -0
Bug#13174: SHA2 function
Patch contributed from Bill Karwin, paper unnumbered CLA in Seattle
Implement SHA2 functions.
Chad added code to make it work with YaSSL. Also, he removed the
(probable) bug of embedded server never using SSL-dependent
functions. (libmysqld/Makefile.am didn't read ANY autoconf defs.)
Function specification:
SHA2( string cleartext, integer hash_length )
-> string hash, or NULL
where hash_length is one of 224, 256, 384, or 512. If either is
NULL or a length is unsupported, then the result is NULL. The
resulting string is always the length of the hash_length parameter
or is NULL.
Include the canonical hash examples from the NIST in the test
results.
---
Polish and address concerns of reviewers.
.bzrignore:
Added libmysqld/sha2.cc to the ignore list.
client/mysql.cc:
Add condition to remove code for embedded server.
client/mysqltest.cc:
Add condition to remove code for embedded server.
include/Makefile.am:
New header file to header list.
include/mysql_embed.h:
Embedded servers can use SSL-library functions too!
include/sha2.h:
Compatibility layer to make YaSSL behave like OpenSSL.
include/sslopt-case.h:
Remove SSL-communication parameters from command lines.
include/sslopt-longopts.h:
Remove SSL-communication parameters from command lines.
include/sslopt-vars.h:
Don't declare variables that are only used in SSL communication, if
we are compiling the embedded server.
include/violite.h:
Don't even compile the SSL-communication function if we're in the
embedded server.
---
Remove CPP condition indentation.
libmysqld/CMakeLists.txt:
Add new file to source list.
libmysqld/Makefile.am:
Include standard DEFS in embedded compilation. It's an undiscovered
but that it's not there.
Add new file to source list.
libmysqld/examples/Makefile.am:
Include autoconf DEFS.
libmysqld/lib_sql.cc:
Initialize SSL-related variables in embedded server.
mysql-test/include/have_ssl_crypto_functs.inc:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/r/func_digest.result:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
mysql-test/r/func_encrypt_nossl.result:
Update results to the new error message text.
mysql-test/r/have_ssl_is_yes_or_disabled_only.require:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/suite/rpl/t/rpl_ssl.test:
Distinguish between communication and crypto.
mysql-test/suite/rpl/t/rpl_ssl1.test:
Distinguish between communication and crypto.
mysql-test/t/func_des_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/func_digest.test:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
Also, test that various parameters (legal and illegal)
do what we expect.
---
Distinguish between communication and crypto.
mysql-test/t/func_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/openssl_1.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl-big.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_8k_key.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_compress.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_connect.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
sql-common/client.c:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/CMakeLists.txt:
Add new source file to source list so that we have access to SHA2
functions.
sql/Makefile.am:
Add new source file to source list so that we have access to SHA2
functions.
sql/item_create.cc:
Bootstrap the SHA2 function into the server.
sql/item_strfunc.cc:
Add new SHA2 Item class methods.
Clean up two minor problems.
---
Remove extraneous debugging.
---
We must check nullness of a parameter only /after/ computing its
value.
sql/item_strfunc.h:
Declare new SHA2 Item class.
sql/mysqld.cc:
For embedded server, don't refer to SSL-communications variables
or values.
---
Remove CPP condition indentation.
sql/sha2.cc:
Compatibility layer to make YaSSL behave like OpenSSL.
---
Add comment for generated functions.
sql/sql_acl.cc:
For embedded server, don't refer to SSL-communications variables
or values.
sql/sql_connect.cc:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/sys_vars.cc:
For embedded server, don't refer to SSL-communications variables
or values.
2010-04-13 17:04:45 +02:00
|
|
|
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
|
2010-03-29 17:13:53 +02:00
|
|
|
if (mysql->options.extension)
|
|
|
|
{
|
2012-01-06 12:43:18 +01:00
|
|
|
struct mysql_async_context *ctxt= mysql->options.extension->async_context;
|
2011-04-25 17:22:25 +02:00
|
|
|
my_free(mysql->options.extension->plugin_dir);
|
|
|
|
my_free(mysql->options.extension->default_auth);
|
2013-10-03 17:00:44 +02:00
|
|
|
my_hash_free(&mysql->options.extension->connection_attributes);
|
2012-01-06 12:43:18 +01:00
|
|
|
if (ctxt)
|
|
|
|
{
|
|
|
|
my_context_destroy(&ctxt->async_context);
|
2012-02-21 22:15:44 +01:00
|
|
|
my_free(ctxt);
|
2012-01-06 12:43:18 +01:00
|
|
|
}
|
2011-04-25 17:22:25 +02:00
|
|
|
my_free(mysql->options.extension);
|
2010-03-29 17:13:53 +02:00
|
|
|
}
|
2003-06-24 11:10:35 +02:00
|
|
|
bzero((char*) &mysql->options,sizeof(mysql->options));
|
Added option --valgrind-mysqltest to mysql-test-run
Added flag to Field::store(longlong) to specify if value is unsigned.
This fixes bug #12750: Incorrect storage of 9999999999999999999 in DECIMAL(19, 0)
Fixed warning from valgrind in CREATE ... SELECT
Fixed double free of mysql.options if reconnect failed
mysql-test/mysql-test-run.sh:
Added option --valgrind-mysqltest to allow one to run mysqltest with valgrind
mysql-test/r/bigint.result:
Update results after fix for Field::store(longlong)
mysql-test/r/range.result:
Update results after fix for Field::store(longlong)
mysql-test/r/strict.result:
Update results after fix for Field::store(longlong)
(This fixes some wrong results when storing things into bigint columns)
mysql-test/r/type_ranges.result:
Update results after fix for Field::store(longlong)
mysql-test/t/bigint.test:
Added testing for #12750: Incorrect storage of 9999999999999999999 in DECIMAL(19, 0)
mysql-test/t/innodb.test:
Removed comments affected by this bug fix
mysql-test/t/mysqldump.test:
Fixed result to not depend on existing config files
mysql-test/t/range.test:
0xff numbers are now unsigned
mysql-test/t/strict.test:
Added errors for things that previously (wrongly) succeeded
sql-common/client.c:
Fixed double free of mysql.options if reconnect failed
sql/field.cc:
Added flag to Field::store(longlong) to specify if value is unsigned
sql/field.h:
Added flag to Field::store(longlong) to specify if value is unsigned
sql/field_conv.cc:
Fixed calls to Field::store(longlong,flag)
sql/ha_ndbcluster.cc:
Fixed calls to Field::store(longlong,flag)
sql/handler.cc:
Fixed calls to Field::store(longlong,flag)
sql/item.cc:
Fixed calls to Field::store(longlong,flag)
sql/item_sum.cc:
Fixed calls to Field::store(longlong,flag)
sql/sp.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_acl.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_help.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_show.cc:
Fixed calls to Field::store(longlong,flag)
sql/sql_table.cc:
Fixed varning from valgrind
sql/sql_udf.cc:
Fixed calls to Field::store(longlong,flag)
sql/tztime.cc:
Fixed calls to Field::store(longlong,flag)
sql/unireg.cc:
Fixed calls to Field::store(longlong,flag)
2005-09-14 00:41:44 +02:00
|
|
|
DBUG_VOID_RETURN;
|
2003-06-14 10:37:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void mysql_close_free(MYSQL *mysql)
|
|
|
|
{
|
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->host_info);
|
|
|
|
my_free(mysql->user);
|
|
|
|
my_free(mysql->passwd);
|
|
|
|
my_free(mysql->db);
|
2006-03-22 23:37:40 +01:00
|
|
|
#if defined(EMBEDDED_LIBRARY) || MYSQL_VERSION_ID >= 50100
|
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->info_buffer);
|
2006-03-22 23:37:40 +01:00
|
|
|
mysql->info_buffer= 0;
|
|
|
|
#endif
|
2003-06-24 11:10:35 +02:00
|
|
|
/* Clear pointers for better safety */
|
2006-03-22 23:37:40 +01:00
|
|
|
mysql->host_info= mysql->user= mysql->passwd= mysql->db= 0;
|
2003-06-14 10:37:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-20 16:17:47 +02:00
|
|
|
/**
|
|
|
|
For use when the connection to the server has been lost (in which case
|
|
|
|
the server has discarded all information about prepared statements
|
|
|
|
associated with the connection).
|
|
|
|
|
|
|
|
Mark all statements in mysql->stmts by setting stmt->mysql= 0 if the
|
|
|
|
statement has transitioned beyond the MYSQL_STMT_INIT_DONE state, and
|
|
|
|
unlink the statement from the mysql->stmts list.
|
|
|
|
|
|
|
|
The remaining pruned list of statements (if any) is kept in mysql->stmts.
|
|
|
|
|
|
|
|
@param mysql pointer to the MYSQL object
|
|
|
|
|
|
|
|
@return none
|
|
|
|
*/
|
2009-05-20 19:34:37 +02:00
|
|
|
static void mysql_prune_stmt_list(MYSQL *mysql)
|
2009-05-20 16:17:47 +02:00
|
|
|
{
|
|
|
|
LIST *element= mysql->stmts;
|
|
|
|
for (; element; element= element->next)
|
|
|
|
{
|
|
|
|
MYSQL_STMT *stmt= (MYSQL_STMT *) element->data;
|
|
|
|
if (stmt->state != MYSQL_STMT_INIT_DONE)
|
|
|
|
{
|
|
|
|
stmt->mysql= 0;
|
|
|
|
stmt->last_errno= CR_SERVER_LOST;
|
|
|
|
strmov(stmt->last_error, ER(CR_SERVER_LOST));
|
|
|
|
strmov(stmt->sqlstate, unknown_sqlstate);
|
2017-02-16 11:32:47 +01:00
|
|
|
mysql->stmts= list_delete(mysql->stmts, element);
|
2009-05-20 16:17:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-22 13:50:07 +02:00
|
|
|
/*
|
|
|
|
Clear connection pointer of every statement: this is necessary
|
|
|
|
to give error on attempt to use a prepared statement of closed
|
|
|
|
connection.
|
|
|
|
|
|
|
|
SYNOPSYS
|
|
|
|
mysql_detach_stmt_list()
|
|
|
|
stmt_list pointer to mysql->stmts
|
2007-04-13 00:56:22 +02:00
|
|
|
func_name name of calling function
|
2005-03-28 19:59:41 +02:00
|
|
|
|
|
|
|
NOTE
|
|
|
|
There is similar code in mysql_reconnect(), so changes here
|
|
|
|
should also be reflected there.
|
2004-09-22 13:50:07 +02:00
|
|
|
*/
|
|
|
|
|
2007-04-13 00:56:22 +02:00
|
|
|
void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused)),
|
2007-04-16 16:08:29 +02:00
|
|
|
const char *func_name __attribute__((unused)))
|
2004-09-22 13:50:07 +02:00
|
|
|
{
|
|
|
|
#ifdef MYSQL_CLIENT
|
|
|
|
/* Reset connection handle in all prepared statements. */
|
|
|
|
LIST *element= *stmt_list;
|
2007-04-13 00:56:22 +02:00
|
|
|
char buff[MYSQL_ERRMSG_SIZE];
|
|
|
|
DBUG_ENTER("mysql_detach_stmt_list");
|
|
|
|
|
|
|
|
my_snprintf(buff, sizeof(buff)-1, ER(CR_STMT_CLOSED), func_name);
|
2004-09-22 13:50:07 +02:00
|
|
|
for (; element; element= element->next)
|
|
|
|
{
|
|
|
|
MYSQL_STMT *stmt= (MYSQL_STMT *) element->data;
|
2007-10-31 15:16:53 +01:00
|
|
|
set_stmt_error(stmt, CR_STMT_CLOSED, unknown_sqlstate, buff);
|
2004-09-22 13:50:07 +02:00
|
|
|
stmt->mysql= 0;
|
|
|
|
/* No need to call list_delete for statement here */
|
|
|
|
}
|
|
|
|
*stmt_list= 0;
|
2007-04-13 00:56:22 +02:00
|
|
|
DBUG_VOID_RETURN;
|
2004-09-22 13:50:07 +02:00
|
|
|
#endif /* MYSQL_CLIENT */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-29 19:42:22 +01:00
|
|
|
/*
|
|
|
|
Close a MySQL connection and free all resources attached to it.
|
|
|
|
|
|
|
|
This function is coded in such that it can be called multiple times
|
|
|
|
(As some clients call this after mysql_real_connect() fails)
|
|
|
|
*/
|
|
|
|
|
2011-09-20 12:49:25 +02:00
|
|
|
/*
|
|
|
|
mysql_close() can actually block, at least in theory, if the socket buffer
|
|
|
|
is full when sending the COM_QUIT command.
|
|
|
|
|
|
|
|
On the other hand, the latter part of mysql_close() needs to free the stack
|
|
|
|
used for non-blocking operation of blocking stuff, so that later part can
|
|
|
|
_not_ be done non-blocking.
|
|
|
|
|
2012-01-06 12:43:18 +01:00
|
|
|
Therefore, mysql_close_slow_part() is used to run the parts of mysql_close()
|
|
|
|
that may block. It can be called before mysql_close(), and in that case
|
|
|
|
mysql_close() is guaranteed not to need to block. */
|
|
|
|
void STDCALL mysql_close_slow_part(MYSQL *mysql)
|
2011-09-20 12:49:25 +02:00
|
|
|
{
|
|
|
|
/* If connection is still up, send a QUIT message */
|
|
|
|
if (mysql->net.vio != 0)
|
|
|
|
{
|
|
|
|
free_old_query(mysql);
|
|
|
|
mysql->status=MYSQL_STATUS_READY; /* Force command */
|
|
|
|
mysql->reconnect=0;
|
|
|
|
simple_command(mysql,COM_QUIT,(uchar*) 0,0,1);
|
|
|
|
end_server(mysql); /* Sets mysql->net.vio= 0 */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-26 12:33:13 +02:00
|
|
|
void STDCALL mysql_close(MYSQL *mysql)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
DBUG_ENTER("mysql_close");
|
2017-09-19 19:45:17 +02:00
|
|
|
DBUG_PRINT("enter", ("mysql: %p", mysql));
|
2011-02-24 01:36:32 +01:00
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
if (mysql) /* Some simple safety */
|
|
|
|
{
|
2012-01-06 12:43:18 +01:00
|
|
|
mysql_close_slow_part(mysql);
|
2003-06-14 10:37:42 +02:00
|
|
|
mysql_close_free_options(mysql);
|
|
|
|
mysql_close_free(mysql);
|
2007-04-13 00:56:22 +02:00
|
|
|
mysql_detach_stmt_list(&mysql->stmts, "mysql_close");
|
2003-09-29 11:09:51 +02:00
|
|
|
#ifndef MYSQL_SERVER
|
|
|
|
if (mysql->thd)
|
2010-01-29 19:42:22 +01:00
|
|
|
{
|
2003-09-29 11:09:51 +02:00
|
|
|
(*mysql->methods->free_embedded_thd)(mysql);
|
2010-01-29 19:42:22 +01:00
|
|
|
mysql->thd= 0;
|
|
|
|
}
|
2003-09-29 11:09:51 +02:00
|
|
|
#endif
|
2003-05-02 18:07:41 +02:00
|
|
|
if (mysql->free_me)
|
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);
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
}
|
|
|
|
|
2004-03-18 13:53:38 +01:00
|
|
|
|
2003-12-22 13:57:34 +01:00
|
|
|
static my_bool cli_read_query_result(MYSQL *mysql)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
uchar *pos;
|
|
|
|
ulong field_count;
|
|
|
|
MYSQL_DATA *fields;
|
|
|
|
ulong length;
|
2019-01-25 23:12:35 +01:00
|
|
|
#ifdef MYSQL_CLIENT
|
|
|
|
my_bool can_local_infile= mysql->auto_local_infile != WAIT_FOR_QUERY;
|
|
|
|
#endif
|
2003-12-22 13:57:34 +01:00
|
|
|
DBUG_ENTER("cli_read_query_result");
|
2003-05-02 18:07:41 +02:00
|
|
|
|
2019-01-25 23:12:35 +01:00
|
|
|
if (mysql->auto_local_infile == ACCEPT_FILE_REQUEST)
|
|
|
|
mysql->auto_local_infile= WAIT_FOR_QUERY;
|
|
|
|
|
A fix and a test case for Bug#15752 "Lost connection to MySQL server
when calling a SP from C API"
The bug was caused by lack of checks for misuse in mysql_real_query.
A stored procedure always returns at least one result, which is the
status of execution of the procedure itself.
This result, or so-called OK packet, is similar to a result
returned by INSERT/UPDATE/CREATE operations: it contains the overall
status of execution, the number of affected rows and the number of
warnings. The client test program attached to the bug did not read this
result and ivnoked the next query. In turn, libmysql had no check for
such scenario and mysql_real_query was simply trying to send that query
without reading the pending response, thus messing up the communication
protocol.
The fix is to return an error from mysql_real_query when it's called
prior to retrieval of all pending results.
client/mysqlbinlog.cc:
net_safe_read -> cli_safe_read
include/mysql.h:
Remove a private function from the public header.
include/mysql_com.h:
Remove a define that is never used.
include/sql_common.h:
Add a declaration for cli_safe_read - a function that reads one packet
from the server.
libmysql/libmysql.c:
net_safe_read -> cli_safe_read
Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
using a connection which has pending result sets.
sql-common/client.c:
Actual fix for Bug#15752: if the server has pending result sets for
the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
another query. Similarly to the behaviour of mysql_use_result(),
multiple result sets block the connection and must be fetched
before it can be used for another query.
This uncovered an error in the protocol: the server doesn't drop
SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
a multi-query like SELECT 1; SELECT syntax_error; SELECT 2;
the client has no way to know that the server won't ever come to
execution of the third query and won't return any result sets for it.
For now, fix it in cli_safe_read, as a proper fix requires extension
of the client-server protocol.
sql/protocol.cc:
Remove a name that is never used.
sql/slave.cc:
net_safe_read -> cli_safe_read
tests/mysql_client_test.c:
Make 'query' a local variable to avoid name clash.
Add a test case for Bug#15752 "Lost connection to MySQL server when
calling an SP from C API"
2006-07-24 12:56:53 +02:00
|
|
|
if ((length = cli_safe_read(mysql)) == packet_error)
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(1);
|
2003-06-14 10:37:42 +02:00
|
|
|
free_old_query(mysql); /* Free old result */
|
|
|
|
#ifdef MYSQL_CLIENT /* Avoid warn of unused labels*/
|
2003-05-02 18:07:41 +02:00
|
|
|
get_info:
|
2003-05-31 12:15:46 +02:00
|
|
|
#endif
|
2003-05-02 18:07:41 +02:00
|
|
|
pos=(uchar*) mysql->net.read_pos;
|
|
|
|
if ((field_count= net_field_length(&pos)) == 0)
|
|
|
|
{
|
|
|
|
mysql->affected_rows= net_field_length_ll(&pos);
|
|
|
|
mysql->insert_id= net_field_length_ll(&pos);
|
2003-11-28 11:18:13 +01:00
|
|
|
DBUG_PRINT("info",("affected_rows: %lu insert_id: %lu",
|
|
|
|
(ulong) mysql->affected_rows,
|
|
|
|
(ulong) mysql->insert_id));
|
2003-05-02 18:07:41 +02:00
|
|
|
if (protocol_41(mysql))
|
|
|
|
{
|
|
|
|
mysql->server_status=uint2korr(pos); pos+=2;
|
|
|
|
mysql->warning_count=uint2korr(pos); pos+=2;
|
|
|
|
}
|
2003-05-31 12:15:46 +02:00
|
|
|
else if (mysql->server_capabilities & CLIENT_TRANSACTIONS)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
2003-11-28 11:18:13 +01:00
|
|
|
/* MySQL 4.0 protocol */
|
2003-05-02 18:07:41 +02:00
|
|
|
mysql->server_status=uint2korr(pos); pos+=2;
|
|
|
|
mysql->warning_count= 0;
|
|
|
|
}
|
2003-11-28 11:18:13 +01:00
|
|
|
DBUG_PRINT("info",("status: %u warning_count: %u",
|
2003-05-02 18:07:41 +02:00
|
|
|
mysql->server_status, mysql->warning_count));
|
|
|
|
if (pos < mysql->net.read_pos+length && net_field_length(&pos))
|
|
|
|
mysql->info=(char*) pos;
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
2003-05-31 12:15:46 +02:00
|
|
|
#ifdef MYSQL_CLIENT
|
2003-05-02 18:07:41 +02:00
|
|
|
if (field_count == NULL_LENGTH) /* LOAD DATA LOCAL INFILE */
|
|
|
|
{
|
2008-02-22 18:45:45 +01:00
|
|
|
int error;
|
|
|
|
|
2019-01-25 23:12:35 +01:00
|
|
|
if (!(mysql->options.client_flag & CLIENT_LOCAL_FILES) ||
|
|
|
|
!can_local_infile)
|
2008-02-22 18:45:45 +01:00
|
|
|
{
|
|
|
|
set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate);
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
error= handle_local_infile(mysql,(char*) pos);
|
A fix and a test case for Bug#15752 "Lost connection to MySQL server
when calling a SP from C API"
The bug was caused by lack of checks for misuse in mysql_real_query.
A stored procedure always returns at least one result, which is the
status of execution of the procedure itself.
This result, or so-called OK packet, is similar to a result
returned by INSERT/UPDATE/CREATE operations: it contains the overall
status of execution, the number of affected rows and the number of
warnings. The client test program attached to the bug did not read this
result and ivnoked the next query. In turn, libmysql had no check for
such scenario and mysql_real_query was simply trying to send that query
without reading the pending response, thus messing up the communication
protocol.
The fix is to return an error from mysql_real_query when it's called
prior to retrieval of all pending results.
client/mysqlbinlog.cc:
net_safe_read -> cli_safe_read
include/mysql.h:
Remove a private function from the public header.
include/mysql_com.h:
Remove a define that is never used.
include/sql_common.h:
Add a declaration for cli_safe_read - a function that reads one packet
from the server.
libmysql/libmysql.c:
net_safe_read -> cli_safe_read
Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
using a connection which has pending result sets.
sql-common/client.c:
Actual fix for Bug#15752: if the server has pending result sets for
the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
another query. Similarly to the behaviour of mysql_use_result(),
multiple result sets block the connection and must be fetched
before it can be used for another query.
This uncovered an error in the protocol: the server doesn't drop
SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
a multi-query like SELECT 1; SELECT syntax_error; SELECT 2;
the client has no way to know that the server won't ever come to
execution of the third query and won't return any result sets for it.
For now, fix it in cli_safe_read, as a proper fix requires extension
of the client-server protocol.
sql/protocol.cc:
Remove a name that is never used.
sql/slave.cc:
net_safe_read -> cli_safe_read
tests/mysql_client_test.c:
Make 'query' a local variable to avoid name clash.
Add a test case for Bug#15752 "Lost connection to MySQL server when
calling an SP from C API"
2006-07-24 12:56:53 +02:00
|
|
|
if ((length= cli_safe_read(mysql)) == packet_error || error)
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(1);
|
|
|
|
goto get_info; /* Get info packet */
|
|
|
|
}
|
2003-05-31 12:15:46 +02:00
|
|
|
#endif
|
2003-05-02 18:07:41 +02:00
|
|
|
if (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT))
|
|
|
|
mysql->server_status|= SERVER_STATUS_IN_TRANS;
|
|
|
|
|
2006-02-24 17:34:15 +01:00
|
|
|
if (!(fields=cli_read_rows(mysql,(MYSQL_FIELD*)0, protocol_41(mysql) ? 7:5)))
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(1);
|
2012-06-28 17:38:55 +02:00
|
|
|
if (!(mysql->fields=unpack_fields(mysql, fields,&mysql->field_alloc,
|
2003-05-02 18:07:41 +02:00
|
|
|
(uint) field_count,0,
|
|
|
|
mysql->server_capabilities)))
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
mysql->status= MYSQL_STATUS_GET_RESULT;
|
|
|
|
mysql->field_count= (uint) field_count;
|
2005-05-16 12:34:23 +02:00
|
|
|
DBUG_PRINT("exit",("ok"));
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Send the query and return so we can do something else.
|
|
|
|
Needs to be followed by mysql_read_query_result() when we want to
|
|
|
|
finish processing it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int STDCALL
|
|
|
|
mysql_send_query(MYSQL* mysql, const char* query, ulong length)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("mysql_send_query");
|
2019-01-25 23:12:35 +01:00
|
|
|
if (mysql->options.client_flag & CLIENT_LOCAL_FILES &&
|
|
|
|
mysql->auto_local_infile == WAIT_FOR_QUERY &&
|
|
|
|
(*query == 'l' || *query == 'L'))
|
|
|
|
{
|
|
|
|
if (strncasecmp(query, STRING_WITH_LEN("load")) == 0)
|
|
|
|
mysql->auto_local_infile= ACCEPT_FILE_REQUEST;
|
|
|
|
}
|
2007-08-13 15:11:25 +02:00
|
|
|
DBUG_RETURN(simple_command(mysql, COM_QUERY, (uchar*) query, length, 1));
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int STDCALL
|
|
|
|
mysql_real_query(MYSQL *mysql, const char *query, ulong length)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("mysql_real_query");
|
2017-09-19 19:45:17 +02:00
|
|
|
DBUG_PRINT("enter",("handle: %p", mysql));
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_PRINT("query",("Query = '%-.4096s'",query));
|
|
|
|
|
|
|
|
if (mysql_send_query(mysql,query,length))
|
|
|
|
DBUG_RETURN(1);
|
2003-09-18 15:28:42 +02:00
|
|
|
DBUG_RETURN((int) (*mysql->methods->read_query_result)(mysql));
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
/**************************************************************************
|
|
|
|
Alloc result struct for buffered results. All rows are read to buffer.
|
|
|
|
mysql_data_seek may be used.
|
|
|
|
**************************************************************************/
|
|
|
|
|
2003-09-16 13:06:25 +02:00
|
|
|
MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
|
|
|
MYSQL_RES *result;
|
|
|
|
DBUG_ENTER("mysql_store_result");
|
2009-10-15 22:56:17 +02:00
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
if (!mysql->fields)
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
if (mysql->status != MYSQL_STATUS_GET_RESULT)
|
|
|
|
{
|
2004-03-12 13:21:48 +01:00
|
|
|
set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
mysql->status=MYSQL_STATUS_READY; /* server is ready */
|
|
|
|
if (!(result=(MYSQL_RES*) my_malloc((uint) (sizeof(MYSQL_RES)+
|
|
|
|
sizeof(ulong) *
|
|
|
|
mysql->field_count),
|
|
|
|
MYF(MY_WME | MY_ZEROFILL))))
|
|
|
|
{
|
2004-03-12 13:21:48 +01:00
|
|
|
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
2003-07-23 12:23:20 +02:00
|
|
|
result->methods= mysql->methods;
|
2003-05-02 18:07:41 +02:00
|
|
|
result->eof=1; /* Marker for buffered */
|
|
|
|
result->lengths=(ulong*) (result+1);
|
2003-09-16 13:06:25 +02:00
|
|
|
if (!(result->data=
|
|
|
|
(*mysql->methods->read_rows)(mysql,mysql->fields,mysql->field_count)))
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
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(result);
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
mysql->affected_rows= result->row_count= result->data->rows;
|
|
|
|
result->data_cursor= result->data->data;
|
|
|
|
result->fields= mysql->fields;
|
|
|
|
result->field_alloc= mysql->field_alloc;
|
|
|
|
result->field_count= mysql->field_count;
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
/* The rest of result members is bzeroed in malloc */
|
2003-05-02 18:07:41 +02:00
|
|
|
mysql->fields=0; /* fields is now in result */
|
2007-04-16 16:08:29 +02:00
|
|
|
clear_alloc_root(&mysql->field_alloc);
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
/* just in case this was mistakenly called after mysql_stmt_execute() */
|
|
|
|
mysql->unbuffered_fetch_owner= 0;
|
2003-05-02 18:07:41 +02:00
|
|
|
DBUG_RETURN(result); /* Data fetched */
|
|
|
|
}
|
|
|
|
|
2003-06-14 10:37:42 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
Alloc struct for use with unbuffered reads. Data is fetched by domand
|
|
|
|
when calling to mysql_fetch_row.
|
|
|
|
mysql_data_seek is a noop.
|
|
|
|
|
|
|
|
No other queries may be specified with the same MYSQL handle.
|
|
|
|
There shouldn't be much processing per row because mysql server shouldn't
|
|
|
|
have to wait for the client (and will not wait more than 30 sec/packet).
|
|
|
|
**************************************************************************/
|
|
|
|
|
2003-12-22 13:57:34 +01:00
|
|
|
static MYSQL_RES * cli_use_result(MYSQL *mysql)
|
2003-06-14 10:37:42 +02:00
|
|
|
{
|
|
|
|
MYSQL_RES *result;
|
2003-12-22 13:57:34 +01:00
|
|
|
DBUG_ENTER("cli_use_result");
|
2003-06-14 10:37:42 +02:00
|
|
|
|
|
|
|
if (!mysql->fields)
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
if (mysql->status != MYSQL_STATUS_GET_RESULT)
|
|
|
|
{
|
2004-03-12 13:21:48 +01:00
|
|
|
set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
|
2003-06-14 10:37:42 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
if (!(result=(MYSQL_RES*) my_malloc(sizeof(*result)+
|
|
|
|
sizeof(ulong)*mysql->field_count,
|
|
|
|
MYF(MY_WME | MY_ZEROFILL))))
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
result->lengths=(ulong*) (result+1);
|
2003-07-23 12:23:20 +02:00
|
|
|
result->methods= mysql->methods;
|
2003-06-14 10:37:42 +02:00
|
|
|
if (!(result->row=(MYSQL_ROW)
|
|
|
|
my_malloc(sizeof(result->row[0])*(mysql->field_count+1), MYF(MY_WME))))
|
|
|
|
{ /* Ptrs: to one row */
|
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(result);
|
2003-06-14 10:37:42 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
result->fields= mysql->fields;
|
|
|
|
result->field_alloc= mysql->field_alloc;
|
|
|
|
result->field_count= mysql->field_count;
|
|
|
|
result->current_field=0;
|
|
|
|
result->handle= mysql;
|
|
|
|
result->current_row= 0;
|
|
|
|
mysql->fields=0; /* fields is now in result */
|
2007-04-16 16:08:29 +02:00
|
|
|
clear_alloc_root(&mysql->field_alloc);
|
2003-06-14 10:37:42 +02:00
|
|
|
mysql->status=MYSQL_STATUS_USE_RESULT;
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
mysql->unbuffered_fetch_owner= &result->unbuffered_fetch_cancelled;
|
2003-06-14 10:37:42 +02:00
|
|
|
DBUG_RETURN(result); /* Data is read to be fetched */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
/**************************************************************************
|
2003-06-14 10:37:42 +02:00
|
|
|
Return next row of the query results
|
2003-05-02 18:07:41 +02:00
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
MYSQL_ROW STDCALL
|
|
|
|
mysql_fetch_row(MYSQL_RES *res)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("mysql_fetch_row");
|
|
|
|
if (!res->data)
|
|
|
|
{ /* Unbufferred fetch */
|
|
|
|
if (!res->eof)
|
|
|
|
{
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
MYSQL *mysql= res->handle;
|
|
|
|
if (mysql->status != MYSQL_STATUS_USE_RESULT)
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
set_mysql_error(mysql,
|
|
|
|
res->unbuffered_fetch_cancelled ?
|
2004-07-01 05:18:41 +02:00
|
|
|
CR_FETCH_CANCELED : CR_COMMANDS_OUT_OF_SYNC,
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
unknown_sqlstate);
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
else if (!(read_one_row(mysql, res->field_count, res->row, res->lengths)))
|
2003-05-02 18:07:41 +02:00
|
|
|
{
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
res->row_count++;
|
|
|
|
DBUG_RETURN(res->current_row=res->row);
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
Intermediate commit of client library (cleanups + fixes of 3 items from
flaws list)
TODO:
* verify that no sequence of API calls produces SIGSEGV.
That is, verify that mysql_stmt_init -> mysql_stmt_fetch is OK,
or mysql_stmt_prepare -> mysql_stmt_fetch_column is OK and sets
meaningful error.
* remove alloc_stmt_fields call
* revise stmt->state codes and statement states.
* there are other items in prepared statements 'to fix' document.
Done:
- cleanups and comments
- revision of prepared statement error codes.
- mysql_stmt_prepare is now can always be called (that is, you can reprepare
a statement)
- new implementation of mysql_stmt_close and fetch cancellation
include/errmsg.h:
- CR_NOT_ALL_PARAMS_BOUND - this error code wasn't used until now.
Apparently it was added in advance, but then interface of
mysql_stmt_bind_param changed. Now it's not possible to bind only some
parameters - either all or none of parameters are bound.
This error code is renamed to CR_PARAMS_NOT_BOUND
- CR_FETCH_CANCELLED - error code set on server side when fetch from
MYSQL_RES or MYSQL_STMT (in blocking mode) was cancelled because of
intercepting call to mysql_stmt_close
- CR_NO_DATA - this is proposed error code to return from
mysql_stmt_fetch_column if no row was fetched (by any type of fetch).
We always can fall back to CR_COMMANDS_OUT_OF_SYNC though.
Need reviewer's opinion on this one.
include/mysql.h:
- added unbuffered_fetch_owner member to MYSQL to point to MYSQL_RES
or MYSQL_STMT which is used to fetch result at the moment.
This is to be able to set CR_FETCH_CANCELLED error without fantoms.
- added unbuffered_fetch_cancelled boolean variable to MYSQL_STMT and
MYSQL_RES structures
- rename PREP_STMT_STATE -> enum enum_mysql_stmt_state
- members of MYSQL_STMT ordered by size.
- removed members of MYSQL_STMT: current_row, result_buffered,
last_fetched_column, last_fetched_buffer, query
- renamed members of MYSQL_STMT: param_buffers -> bind_param_done,
res_buffers -> bind_result_done
- now mysql_stmt_fetch calls stmt->read_row_func to read row either from
buffer or from network.
include/sql_common.h:
declaration for flush_use_result
libmysql/client_settings.h:
stmt_close declaration removed
libmysql/errmsg.c:
Error messages for changed and added error codes.
libmysql/libmysql.c:
Many changes:
- some unused variables removed
- cleanups
- better error reporting
- some function calls commented
- alloc_stmt_fields is now called right after execute, to not read
mysql->fields of some other statement
- new implementation of mysql_stmt_fetch - this is also with cursor
fetch in mind (to implement cursor fetch I'll just need to write
special read_row function for it, so this change will be local)
- implementation of fetch cancellation, including complete rewrite of
mysql_stmt_close
- now mysql_stmt_free_result doesn't free results of other statements.
sql-common/client.c:
- implementation of flush_use_result
- implementation of fetch cancellation
- changed behaviour of mysql_close in regard to mysql_stmt_close - now
mysql_close just set stmt->mysql to 0
2004-03-15 23:04:04 +01:00
|
|
|
DBUG_PRINT("info",("end of data"));
|
|
|
|
res->eof=1;
|
|
|
|
mysql->status=MYSQL_STATUS_READY;
|
|
|
|
/*
|
|
|
|
Reset only if owner points to us: there is a chance that somebody
|
|
|
|
started new query after mysql_stmt_close():
|
|
|
|
*/
|
|
|
|
if (mysql->unbuffered_fetch_owner == &res->unbuffered_fetch_cancelled)
|
|
|
|
mysql->unbuffered_fetch_owner= 0;
|
|
|
|
/* Don't clear handle in mysql_free_result */
|
|
|
|
res->handle=0;
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
DBUG_RETURN((MYSQL_ROW) NULL);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
MYSQL_ROW tmp;
|
|
|
|
if (!res->data_cursor)
|
|
|
|
{
|
|
|
|
DBUG_PRINT("info",("end of data"));
|
|
|
|
DBUG_RETURN(res->current_row=(MYSQL_ROW) NULL);
|
|
|
|
}
|
|
|
|
tmp = res->data_cursor->data;
|
|
|
|
res->data_cursor = res->data_cursor->next;
|
|
|
|
DBUG_RETURN(res->current_row=tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-23 09:29:57 +01:00
|
|
|
/**************************************************************************
|
|
|
|
Get column lengths of the current row
|
|
|
|
If one uses mysql_use_result, res->lengths contains the length information,
|
|
|
|
else the lengths are calculated from the offset between pointers.
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
ulong * STDCALL
|
|
|
|
mysql_fetch_lengths(MYSQL_RES *res)
|
|
|
|
{
|
|
|
|
MYSQL_ROW column;
|
|
|
|
|
|
|
|
if (!(column=res->current_row))
|
|
|
|
return 0; /* Something is wrong */
|
|
|
|
if (res->data)
|
|
|
|
(*res->methods->fetch_lengths)(res->lengths, column, res->field_count);
|
|
|
|
return res->lengths;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-06 12:43:18 +01:00
|
|
|
#define ASYNC_CONTEXT_DEFAULT_STACK_SIZE (4096*15)
|
|
|
|
|
2003-05-31 12:15:46 +02:00
|
|
|
int STDCALL
|
2007-03-27 21:04:05 +02:00
|
|
|
mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg)
|
2003-05-31 12:15:46 +02:00
|
|
|
{
|
2012-01-06 12:43:18 +01:00
|
|
|
struct mysql_async_context *ctxt;
|
|
|
|
size_t stacksize;
|
|
|
|
|
2011-07-10 20:21:18 +02:00
|
|
|
DBUG_ENTER("mysql_options");
|
2003-05-31 12:15:46 +02:00
|
|
|
DBUG_PRINT("enter",("option: %d",(int) option));
|
|
|
|
switch (option) {
|
|
|
|
case MYSQL_OPT_CONNECT_TIMEOUT:
|
|
|
|
mysql->options.connect_timeout= *(uint*) arg;
|
|
|
|
break;
|
2003-06-14 10:37:42 +02:00
|
|
|
case MYSQL_OPT_READ_TIMEOUT:
|
|
|
|
mysql->options.read_timeout= *(uint*) arg;
|
|
|
|
break;
|
|
|
|
case MYSQL_OPT_WRITE_TIMEOUT:
|
|
|
|
mysql->options.write_timeout= *(uint*) arg;
|
|
|
|
break;
|
2003-05-31 12:15:46 +02:00
|
|
|
case MYSQL_OPT_COMPRESS:
|
|
|
|
mysql->options.compress= 1; /* Remember for connect */
|
|
|
|
mysql->options.client_flag|= CLIENT_COMPRESS;
|
|
|
|
break;
|
2003-06-14 10:37:42 +02:00
|
|
|
case MYSQL_OPT_NAMED_PIPE: /* This option is depricated */
|
2003-05-31 12:15:46 +02:00
|
|
|
mysql->options.protocol=MYSQL_PROTOCOL_PIPE; /* Force named pipe */
|
|
|
|
break;
|
|
|
|
case MYSQL_OPT_LOCAL_INFILE: /* Allow LOAD DATA LOCAL ?*/
|
2019-01-25 23:12:35 +01:00
|
|
|
if (!arg || *(uint*) arg)
|
2003-05-31 12:15:46 +02:00
|
|
|
mysql->options.client_flag|= CLIENT_LOCAL_FILES;
|
|
|
|
else
|
|
|
|
mysql->options.client_flag&= ~CLIENT_LOCAL_FILES;
|
2019-01-25 23:12:35 +01:00
|
|
|
mysql->auto_local_infile= arg && *(uint*)arg == LOCAL_INFILE_MODE_AUTO
|
|
|
|
? WAIT_FOR_QUERY : ALWAYS_ACCEPT;
|
2003-05-31 12:15:46 +02:00
|
|
|
break;
|
|
|
|
case MYSQL_INIT_COMMAND:
|
|
|
|
add_init_command(&mysql->options,arg);
|
|
|
|
break;
|
|
|
|
case MYSQL_READ_DEFAULT_FILE:
|
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);
|
2003-05-31 12:15:46 +02:00
|
|
|
mysql->options.my_cnf_file=my_strdup(arg,MYF(MY_WME));
|
|
|
|
break;
|
|
|
|
case MYSQL_READ_DEFAULT_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_group);
|
2003-05-31 12:15:46 +02:00
|
|
|
mysql->options.my_cnf_group=my_strdup(arg,MYF(MY_WME));
|
|
|
|
break;
|
|
|
|
case MYSQL_SET_CHARSET_DIR:
|
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.charset_dir);
|
2003-05-31 12:15:46 +02:00
|
|
|
mysql->options.charset_dir=my_strdup(arg,MYF(MY_WME));
|
|
|
|
break;
|
|
|
|
case MYSQL_SET_CHARSET_NAME:
|
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.charset_name);
|
2003-05-31 12:15:46 +02:00
|
|
|
mysql->options.charset_name=my_strdup(arg,MYF(MY_WME));
|
|
|
|
break;
|
|
|
|
case MYSQL_OPT_PROTOCOL:
|
|
|
|
mysql->options.protocol= *(uint*) arg;
|
|
|
|
break;
|
2003-06-18 12:58:57 +02:00
|
|
|
case MYSQL_OPT_USE_REMOTE_CONNECTION:
|
|
|
|
case MYSQL_OPT_USE_EMBEDDED_CONNECTION:
|
|
|
|
case MYSQL_OPT_GUESS_CONNECTION:
|
|
|
|
mysql->options.methods_to_use= option;
|
2003-05-31 12:15:46 +02:00
|
|
|
break;
|
2003-09-26 12:33:13 +02:00
|
|
|
case MYSQL_SET_CLIENT_IP:
|
2012-08-14 16:23:34 +02:00
|
|
|
my_free(mysql->options.client_ip);
|
2003-09-26 12:33:13 +02:00
|
|
|
mysql->options.client_ip= my_strdup(arg, MYF(MY_WME));
|
2003-11-28 11:14:10 +01:00
|
|
|
break;
|
2003-11-28 11:11:44 +01:00
|
|
|
case MYSQL_SECURE_AUTH:
|
|
|
|
mysql->options.secure_auth= *(my_bool *) arg;
|
2003-11-28 00:50:58 +01:00
|
|
|
break;
|
2004-12-17 22:17:25 +01:00
|
|
|
case MYSQL_REPORT_DATA_TRUNCATION:
|
2014-02-19 11:05:15 +01:00
|
|
|
mysql->options.report_data_truncation= MY_TEST(*(my_bool*) arg);
|
2004-12-17 22:17:25 +01:00
|
|
|
break;
|
2005-07-07 01:29:31 +02:00
|
|
|
case MYSQL_OPT_RECONNECT:
|
|
|
|
mysql->reconnect= *(my_bool *) arg;
|
|
|
|
break;
|
2013-04-17 22:37:06 +02:00
|
|
|
case MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY:
|
|
|
|
mysql->options.use_thread_specific_memory= *(my_bool *) arg;
|
|
|
|
break;
|
2006-04-18 17:58:27 +02:00
|
|
|
case MYSQL_OPT_SSL_VERIFY_SERVER_CERT:
|
2007-03-27 19:26:01 +02:00
|
|
|
if (*(my_bool*) arg)
|
2006-08-25 17:54:33 +02:00
|
|
|
mysql->options.client_flag|= CLIENT_SSL_VERIFY_SERVER_CERT;
|
|
|
|
else
|
|
|
|
mysql->options.client_flag&= ~CLIENT_SSL_VERIFY_SERVER_CERT;
|
2006-04-18 17:58:27 +02:00
|
|
|
break;
|
2010-03-29 17:13:53 +02:00
|
|
|
case MYSQL_PLUGIN_DIR:
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
EXTENSION_SET_STRING(&mysql->options, plugin_dir, arg);
|
2010-03-29 17:13:53 +02:00
|
|
|
break;
|
|
|
|
case MYSQL_DEFAULT_AUTH:
|
fixes for test failures
and small collateral changes
mysql-test/lib/My/Test.pm:
somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
this differs, because we don't rewrite general log queries, and multi-statement
packets are logged as a one entry. this result file is identical to what mysql-5.6.5
produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
|
|
|
EXTENSION_SET_STRING(&mysql->options, default_auth, arg);
|
2010-03-29 17:13:53 +02:00
|
|
|
break;
|
2013-06-11 11:11:05 +02:00
|
|
|
case MYSQL_ENABLE_CLEARTEXT_PLUGIN:
|
|
|
|
break;
|
2011-07-01 14:08:30 +02:00
|
|
|
case MYSQL_PROGRESS_CALLBACK:
|
|
|
|
if (!mysql->options.extension)
|
|
|
|
mysql->options.extension= (struct st_mysql_options_extention *)
|
|
|
|
my_malloc(sizeof(struct st_mysql_options_extention),
|
|
|
|
MYF(MY_WME | MY_ZEROFILL));
|
|
|
|
if (mysql->options.extension)
|
|
|
|
mysql->options.extension->report_progress=
|
|
|
|
(void (*)(const MYSQL *, uint, uint, double, const char *, uint)) arg;
|
|
|
|
break;
|
2012-01-06 12:43:18 +01:00
|
|
|
case MYSQL_OPT_NONBLOCK:
|
|
|
|
if (mysql->options.extension &&
|
|
|
|
(ctxt = mysql->options.extension->async_context) != 0)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
We must not allow changing the stack size while a non-blocking call is
|
|
|
|
suspended (as the stack is then in use).
|
|
|
|
*/
|
|
|
|
if (ctxt->suspended)
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
my_context_destroy(&ctxt->async_context);
|
2012-02-21 22:15:44 +01:00
|
|
|
my_free(ctxt);
|
2012-01-06 12:43:18 +01:00
|
|
|
}
|
|
|
|
if (!(ctxt= (struct mysql_async_context *)
|
|
|
|
my_malloc(sizeof(*ctxt), MYF(MY_ZEROFILL))))
|
|
|
|
{
|
|
|
|
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
|
|
|
stacksize= 0;
|
|
|
|
if (arg)
|
|
|
|
stacksize= *(const size_t *)arg;
|
|
|
|
if (!stacksize)
|
|
|
|
stacksize= ASYNC_CONTEXT_DEFAULT_STACK_SIZE;
|
|
|
|
if (my_context_init(&ctxt->async_context, stacksize))
|
|
|
|
{
|
2016-02-01 16:10:49 +01:00
|
|
|
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
2012-02-21 22:15:44 +01:00
|
|
|
my_free(ctxt);
|
2012-01-06 12:43:18 +01:00
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
2013-10-03 17:00:44 +02:00
|
|
|
ENSURE_EXTENSIONS_PRESENT(&(mysql->options));
|
|
|
|
mysql->options.extension->async_context= ctxt;
|
2012-01-06 12:43:18 +01:00
|
|
|
if (mysql->net.vio)
|
|
|
|
mysql->net.vio->async_context= ctxt;
|
|
|
|
break;
|
2012-08-14 16:23:34 +02:00
|
|
|
case MYSQL_OPT_SSL_KEY:
|
2016-06-21 14:11:02 +02:00
|
|
|
SET_SSL_PATH_OPTION(&mysql->options,ssl_key, arg);
|
2012-08-14 16:23:34 +02:00
|
|
|
break;
|
|
|
|
case MYSQL_OPT_SSL_CERT:
|
2016-06-21 14:11:02 +02:00
|
|
|
SET_SSL_PATH_OPTION(&mysql->options, ssl_cert, arg);
|
2012-08-14 16:23:34 +02:00
|
|
|
break;
|
|
|
|
case MYSQL_OPT_SSL_CA:
|
2016-06-21 14:11:02 +02:00
|
|
|
SET_SSL_PATH_OPTION(&mysql->options,ssl_ca, arg);
|
2012-08-14 16:23:34 +02:00
|
|
|
break;
|
|
|
|
case MYSQL_OPT_SSL_CAPATH:
|
2016-06-21 14:11:02 +02:00
|
|
|
SET_SSL_PATH_OPTION(&mysql->options,ssl_capath, arg);
|
2012-08-14 16:23:34 +02:00
|
|
|
break;
|
|
|
|
case MYSQL_OPT_SSL_CIPHER:
|
|
|
|
SET_SSL_OPTION(&mysql->options,ssl_cipher, arg);
|
|
|
|
break;
|
|
|
|
case MYSQL_OPT_SSL_CRL:
|
2016-06-21 14:11:02 +02:00
|
|
|
EXTENSION_SET_SSL_PATH_STRING(&mysql->options, ssl_crl, arg);
|
2012-08-14 16:23:34 +02:00
|
|
|
break;
|
|
|
|
case MYSQL_OPT_SSL_CRLPATH:
|
2016-06-21 14:11:02 +02:00
|
|
|
EXTENSION_SET_SSL_PATH_STRING(&mysql->options, ssl_crlpath, arg);
|
2012-08-14 16:23:34 +02:00
|
|
|
break;
|
2013-10-03 17:00:44 +02:00
|
|
|
case MYSQL_OPT_CONNECT_ATTR_RESET:
|
|
|
|
ENSURE_EXTENSIONS_PRESENT(&mysql->options);
|
|
|
|
if (my_hash_inited(&mysql->options.extension->connection_attributes))
|
|
|
|
{
|
|
|
|
my_hash_free(&mysql->options.extension->connection_attributes);
|
|
|
|
mysql->options.extension->connection_attributes_length= 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MYSQL_OPT_CONNECT_ATTR_DELETE:
|
|
|
|
ENSURE_EXTENSIONS_PRESENT(&mysql->options);
|
|
|
|
if (my_hash_inited(&mysql->options.extension->connection_attributes))
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
uchar *elt;
|
|
|
|
|
|
|
|
len= arg ? strlen(arg) : 0;
|
|
|
|
|
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
elt= my_hash_search(&mysql->options.extension->connection_attributes,
|
|
|
|
arg, len);
|
|
|
|
if (elt)
|
|
|
|
{
|
|
|
|
LEX_STRING *attr= (LEX_STRING *) elt;
|
|
|
|
LEX_STRING *key= attr, *value= attr + 1;
|
|
|
|
|
|
|
|
mysql->options.extension->connection_attributes_length-=
|
|
|
|
get_length_store_length(key->length) + key->length +
|
|
|
|
get_length_store_length(value->length) + value->length;
|
|
|
|
|
|
|
|
my_hash_delete(&mysql->options.extension->connection_attributes,
|
|
|
|
elt);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2018-08-20 14:06:33 +02:00
|
|
|
case MYSQL_SHARED_MEMORY_BASE_NAME:
|
2013-10-03 17:00:44 +02:00
|
|
|
default:
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
A function to return the key from a connection attribute
|
|
|
|
*/
|
|
|
|
uchar *
|
|
|
|
get_attr_key(LEX_STRING *part, size_t *length,
|
|
|
|
my_bool not_used __attribute__((unused)))
|
|
|
|
{
|
|
|
|
*length= part[0].length;
|
|
|
|
return (uchar *) part[0].str;
|
|
|
|
}
|
|
|
|
|
|
|
|
int STDCALL
|
|
|
|
mysql_options4(MYSQL *mysql,enum mysql_option option,
|
|
|
|
const void *arg1, const void *arg2)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("mysql_option");
|
|
|
|
DBUG_PRINT("enter",("option: %d",(int) option));
|
|
|
|
|
|
|
|
switch (option)
|
|
|
|
{
|
|
|
|
case MYSQL_OPT_CONNECT_ATTR_ADD:
|
|
|
|
{
|
|
|
|
LEX_STRING *elt;
|
|
|
|
char *key, *value;
|
|
|
|
size_t key_len= arg1 ? strlen(arg1) : 0,
|
|
|
|
value_len= arg2 ? strlen(arg2) : 0;
|
|
|
|
size_t attr_storage_length= key_len + value_len;
|
|
|
|
|
|
|
|
/* we can't have a zero length key */
|
|
|
|
if (!key_len)
|
|
|
|
{
|
|
|
|
set_mysql_error(mysql, CR_INVALID_PARAMETER_NO, unknown_sqlstate);
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* calculate the total storage length of the attribute */
|
|
|
|
attr_storage_length+= get_length_store_length(key_len);
|
|
|
|
attr_storage_length+= get_length_store_length(value_len);
|
|
|
|
|
|
|
|
ENSURE_EXTENSIONS_PRESENT(&mysql->options);
|
|
|
|
|
|
|
|
/*
|
|
|
|
Throw and error if the maximum combined length of the attribute value
|
|
|
|
will be greater than the maximum that we can safely transmit.
|
|
|
|
*/
|
|
|
|
if (attr_storage_length +
|
|
|
|
mysql->options.extension->connection_attributes_length >
|
|
|
|
MAX_CONNECTION_ATTR_STORAGE_LENGTH)
|
|
|
|
{
|
|
|
|
set_mysql_error(mysql, CR_INVALID_PARAMETER_NO, unknown_sqlstate);
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!my_hash_inited(&mysql->options.extension->connection_attributes))
|
|
|
|
{
|
|
|
|
if (my_hash_init(&mysql->options.extension->connection_attributes,
|
|
|
|
&my_charset_bin, 0, 0, 0, (my_hash_get_key) get_attr_key,
|
|
|
|
my_free, HASH_UNIQUE))
|
|
|
|
{
|
|
|
|
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!my_multi_malloc(MY_WME,
|
|
|
|
&elt, 2 * sizeof(LEX_STRING),
|
|
|
|
&key, key_len + 1,
|
|
|
|
&value, value_len + 1,
|
|
|
|
NULL))
|
|
|
|
{
|
|
|
|
set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
|
|
|
elt[0].str= key; elt[0].length= key_len;
|
|
|
|
elt[1].str= value; elt[1].length= value_len;
|
|
|
|
if (key_len)
|
|
|
|
memcpy(key, arg1, key_len);
|
|
|
|
key[key_len]= 0;
|
|
|
|
if (value_len)
|
|
|
|
memcpy(value, arg2, value_len);
|
|
|
|
value[value_len]= 0;
|
|
|
|
if (my_hash_insert(&mysql->options.extension->connection_attributes,
|
|
|
|
(uchar *) elt))
|
|
|
|
{
|
|
|
|
/* can't insert the value */
|
|
|
|
my_free(elt);
|
|
|
|
set_mysql_error(mysql, CR_DUPLICATE_CONNECTION_ATTR,
|
|
|
|
unknown_sqlstate);
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
mysql->options.extension->connection_attributes_length+=
|
|
|
|
attr_storage_length;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-05-31 12:15:46 +02:00
|
|
|
default:
|
|
|
|
DBUG_RETURN(1);
|
|
|
|
}
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
/****************************************************************************
|
|
|
|
Functions to get information from the MySQL structure
|
|
|
|
These are functions to make shared libraries more usable.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* MYSQL_RES */
|
|
|
|
my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res)
|
|
|
|
{
|
|
|
|
return res->row_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int STDCALL mysql_num_fields(MYSQL_RES *res)
|
|
|
|
{
|
|
|
|
return res->field_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint STDCALL mysql_errno(MYSQL *mysql)
|
|
|
|
{
|
2008-03-12 09:19:46 +01:00
|
|
|
return mysql ? mysql->net.last_errno : mysql_server_last_errno;
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
|
|
|
|
2005-07-16 07:13:40 +02:00
|
|
|
|
2003-05-02 18:07:41 +02:00
|
|
|
const char * STDCALL mysql_error(MYSQL *mysql)
|
|
|
|
{
|
2008-03-12 09:19:46 +01:00
|
|
|
return mysql ? mysql->net.last_error : mysql_server_last_error;
|
2003-05-02 18:07:41 +02:00
|
|
|
}
|
2004-03-12 13:21:48 +01:00
|
|
|
|
2006-04-06 10:03:22 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Get version number for server in a form easy to test on
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
mysql_get_server_version()
|
|
|
|
mysql Connection
|
|
|
|
|
|
|
|
EXAMPLE
|
2009-12-03 16:26:54 +01:00
|
|
|
MariaDB-4.1.0-alfa -> 40100
|
2006-04-06 10:03:22 +02:00
|
|
|
|
|
|
|
NOTES
|
|
|
|
We will ensure that a newer server always has a bigger number.
|
|
|
|
|
|
|
|
RETURN
|
|
|
|
Signed number > 323000
|
2014-04-17 15:33:55 +02:00
|
|
|
Zero if there is no connection
|
2006-04-06 10:03:22 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
ulong STDCALL
|
|
|
|
mysql_get_server_version(MYSQL *mysql)
|
|
|
|
{
|
2014-04-17 15:33:55 +02:00
|
|
|
ulong major= 0, minor= 0, version= 0;
|
|
|
|
|
|
|
|
if (mysql->server_version)
|
|
|
|
{
|
2014-06-03 09:55:08 +02:00
|
|
|
const char *pos= mysql->server_version;
|
|
|
|
char *end_pos;
|
|
|
|
/* Skip possible prefix */
|
|
|
|
while (*pos && !my_isdigit(&my_charset_latin1, *pos))
|
|
|
|
pos++;
|
2014-04-17 15:33:55 +02:00
|
|
|
major= strtoul(pos, &end_pos, 10); pos=end_pos+1;
|
|
|
|
minor= strtoul(pos, &end_pos, 10); pos=end_pos+1;
|
|
|
|
version= strtoul(pos, &end_pos, 10);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
|
|
|
|
}
|
|
|
|
|
|
|
|
return major*10000 + minor*100 + version;
|
2006-04-06 10:03:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-16 07:13:40 +02:00
|
|
|
/*
|
|
|
|
mysql_set_character_set function sends SET NAMES cs_name to
|
|
|
|
the server (which changes character_set_client, character_set_result
|
|
|
|
and character_set_connection) and updates mysql->charset so other
|
|
|
|
functions like mysql_real_escape will work correctly.
|
|
|
|
*/
|
|
|
|
int STDCALL mysql_set_character_set(MYSQL *mysql, const char *cs_name)
|
|
|
|
{
|
2010-01-06 20:20:16 +01:00
|
|
|
CHARSET_INFO *cs;
|
2005-07-16 07:13:40 +02:00
|
|
|
const char *save_csdir= charsets_dir;
|
|
|
|
|
|
|
|
if (mysql->options.charset_dir)
|
|
|
|
charsets_dir= mysql->options.charset_dir;
|
|
|
|
|
|
|
|
if (strlen(cs_name) < MY_CS_NAME_SIZE &&
|
|
|
|
(cs= get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0))))
|
|
|
|
{
|
|
|
|
char buff[MY_CS_NAME_SIZE + 10];
|
|
|
|
charsets_dir= save_csdir;
|
2006-04-06 09:43:13 +02:00
|
|
|
/* Skip execution of "SET NAMES" for pre-4.1 servers */
|
|
|
|
if (mysql_get_server_version(mysql) < 40100)
|
|
|
|
return 0;
|
2023-02-23 23:43:14 +01:00
|
|
|
snprintf(buff, sizeof(buff), "SET NAMES %s", cs_name);
|
2009-02-10 23:47:54 +01:00
|
|
|
if (!mysql_real_query(mysql, buff, (uint) strlen(buff)))
|
2005-07-16 07:13:40 +02:00
|
|
|
{
|
|
|
|
mysql->charset= cs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char cs_dir_name[FN_REFLEN];
|
|
|
|
get_charsets_dir(cs_dir_name);
|
2007-10-31 15:16:53 +01:00
|
|
|
set_mysql_extended_error(mysql, CR_CANT_READ_CHARSET, unknown_sqlstate,
|
|
|
|
ER(CR_CANT_READ_CHARSET), cs_name, cs_dir_name);
|
2005-07-16 07:13:40 +02:00
|
|
|
}
|
|
|
|
charsets_dir= save_csdir;
|
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
|
|
|
return mysql->net.last_errno;
|
2005-07-16 07:13:40 +02:00
|
|
|
}
|
|
|
|
|
2010-08-09 10:32:50 +02:00
|
|
|
/**
|
|
|
|
client authentication plugin that does native MySQL authentication
|
|
|
|
using a 20-byte (4.1+) scramble
|
|
|
|
*/
|
|
|
|
static int native_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
|
|
|
|
{
|
|
|
|
int pkt_len;
|
|
|
|
uchar *pkt;
|
|
|
|
|
2010-11-10 16:21:51 +01:00
|
|
|
DBUG_ENTER("native_password_auth_client");
|
2010-08-09 10:32:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
if (((MCPVIO_EXT *)vio)->mysql_change_user)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
in mysql_change_user() the client sends the first packet.
|
|
|
|
we use the old scramble.
|
|
|
|
*/
|
|
|
|
pkt= (uchar*)mysql->scramble;
|
|
|
|
pkt_len= SCRAMBLE_LENGTH + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* read the scramble */
|
|
|
|
if ((pkt_len= vio->read_packet(vio, &pkt)) < 0)
|
2010-11-10 16:21:51 +01:00
|
|
|
DBUG_RETURN(CR_ERROR);
|
2010-08-09 10:32:50 +02:00
|
|
|
|
|
|
|
if (pkt_len != SCRAMBLE_LENGTH + 1)
|
2010-11-10 16:21:51 +01:00
|
|
|
DBUG_RETURN(CR_SERVER_HANDSHAKE_ERR);
|
2010-08-09 10:32:50 +02:00
|
|
|
|
|
|
|
/* save it in MYSQL */
|
|
|
|
memcpy(mysql->scramble, pkt, SCRAMBLE_LENGTH);
|
|
|
|
mysql->scramble[SCRAMBLE_LENGTH] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mysql->passwd[0])
|
|
|
|
{
|
|
|
|
char scrambled[SCRAMBLE_LENGTH + 1];
|
2010-11-10 16:21:51 +01:00
|
|
|
DBUG_PRINT("info", ("sending scramble"));
|
2010-08-09 10:32:50 +02:00
|
|
|
scramble(scrambled, (char*)pkt, mysql->passwd);
|
|
|
|
if (vio->write_packet(vio, (uchar*)scrambled, SCRAMBLE_LENGTH))
|
2010-11-10 16:21:51 +01:00
|
|
|
DBUG_RETURN(CR_ERROR);
|
2010-08-09 10:32:50 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-10 16:21:51 +01:00
|
|
|
DBUG_PRINT("info", ("no password"));
|
2010-08-09 10:32:50 +02:00
|
|
|
if (vio->write_packet(vio, 0, 0)) /* no password */
|
2010-11-10 16:21:51 +01:00
|
|
|
DBUG_RETURN(CR_ERROR);
|
2010-08-09 10:32:50 +02:00
|
|
|
}
|
|
|
|
|
2010-11-10 16:21:51 +01:00
|
|
|
DBUG_RETURN(CR_OK);
|
2010-08-09 10:32:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
client authentication plugin that does old MySQL authentication
|
|
|
|
using an 8-byte (4.0-) scramble
|
|
|
|
*/
|
|
|
|
static int old_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
|
|
|
|
{
|
|
|
|
uchar *pkt;
|
|
|
|
int pkt_len;
|
|
|
|
|
2010-11-10 16:21:51 +01:00
|
|
|
DBUG_ENTER("old_password_auth_client");
|
2010-08-09 10:32:50 +02:00
|
|
|
|
|
|
|
if (((MCPVIO_EXT *)vio)->mysql_change_user)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
in mysql_change_user() the client sends the first packet.
|
|
|
|
we use the old scramble.
|
|
|
|
*/
|
|
|
|
pkt= (uchar*)mysql->scramble;
|
|
|
|
pkt_len= SCRAMBLE_LENGTH_323 + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* read the scramble */
|
|
|
|
if ((pkt_len= vio->read_packet(vio, &pkt)) < 0)
|
2010-11-10 16:21:51 +01:00
|
|
|
DBUG_RETURN(CR_ERROR);
|
2010-08-09 10:32:50 +02:00
|
|
|
|
|
|
|
if (pkt_len != SCRAMBLE_LENGTH_323 + 1 &&
|
|
|
|
pkt_len != SCRAMBLE_LENGTH + 1)
|
2010-11-10 16:21:51 +01:00
|
|
|
DBUG_RETURN(CR_SERVER_HANDSHAKE_ERR);
|
2005-07-16 07:13:40 +02:00
|
|
|
|
2010-08-09 10:32:50 +02:00
|
|
|
/* save it in MYSQL */
|
2013-01-15 19:07:46 +01:00
|
|
|
memmove(mysql->scramble, pkt, pkt_len - 1);
|
2012-12-11 09:50:48 +01:00
|
|
|
mysql->scramble[pkt_len - 1] = 0;
|
2010-08-09 10:32:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mysql->passwd[0])
|
|
|
|
{
|
|
|
|
char scrambled[SCRAMBLE_LENGTH_323 + 1];
|
|
|
|
scramble_323(scrambled, (char*)pkt, mysql->passwd);
|
|
|
|
if (vio->write_packet(vio, (uchar*)scrambled, SCRAMBLE_LENGTH_323 + 1))
|
2010-11-10 16:21:51 +01:00
|
|
|
DBUG_RETURN(CR_ERROR);
|
2010-08-09 10:32:50 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if (vio->write_packet(vio, 0, 0)) /* no password */
|
2010-11-10 16:21:51 +01:00
|
|
|
DBUG_RETURN(CR_ERROR);
|
2010-08-09 10:32:50 +02:00
|
|
|
|
2010-11-10 16:21:51 +01:00
|
|
|
DBUG_RETURN(CR_OK);
|
2010-08-09 10:32:50 +02:00
|
|
|
}
|
2011-01-31 16:32:57 +01:00
|
|
|
|
2011-09-20 12:49:25 +02:00
|
|
|
|
|
|
|
my_socket STDCALL
|
|
|
|
mysql_get_socket(const MYSQL *mysql)
|
|
|
|
{
|
|
|
|
if (mysql->net.vio)
|
2012-08-14 16:23:34 +02:00
|
|
|
return vio_fd(mysql->net.vio);
|
2012-01-06 12:43:18 +01:00
|
|
|
return INVALID_SOCKET;
|
2011-09-20 12:49:25 +02:00
|
|
|
}
|
2016-08-19 22:03:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
int STDCALL mysql_cancel(MYSQL *mysql)
|
|
|
|
{
|
|
|
|
if (mysql->net.vio)
|
|
|
|
return vio_shutdown(mysql->net.vio, SHUT_RDWR);
|
|
|
|
return -1;
|
|
|
|
}
|