Commit bfdf7986 authored by unknown's avatar unknown

Merge work:/home/bk/mysql-4.0 into hundin.mysql.fi:/my/bk/mysql-4.0


sql/sql_yacc.yy:
  Auto merged
parents 4b0ce2a1 6974c3d0
...@@ -391,13 +391,6 @@ int main(int argc,char *argv[]) ...@@ -391,13 +391,6 @@ int main(int argc,char *argv[])
sig_handler mysql_end(int sig) sig_handler mysql_end(int sig)
{ {
mysql_close(&mysql); mysql_close(&mysql);
#ifdef HAVE_OPENSSL
my_free(opt_ssl_key,MYF(MY_ALLOW_ZERO_PTR));
my_free(opt_ssl_cert,MYF(MY_ALLOW_ZERO_PTR));
my_free(opt_ssl_ca,MYF(MY_ALLOW_ZERO_PTR));
my_free(opt_ssl_capath,MYF(MY_ALLOW_ZERO_PTR));
my_free(opt_ssl_cipher,MYF(MY_ALLOW_ZERO_PTR));
#endif
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
if (!status.batch && !quick && !opt_html && !opt_xml) if (!status.batch && !quick && !opt_html && !opt_xml)
{ {
...@@ -709,7 +702,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -709,7 +702,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case '?': case '?':
usage(0); usage(0);
exit(0); exit(0);
#include "sslopt-case.h"
} }
return 0; return 0;
} }
...@@ -2209,6 +2201,9 @@ sql_real_connect(char *host,char *database,char *user,char *password, ...@@ -2209,6 +2201,9 @@ sql_real_connect(char *host,char *database,char *user,char *password,
if (using_opt_local_infile) if (using_opt_local_infile)
mysql_options(&mysql,MYSQL_OPT_LOCAL_INFILE, (char*) &opt_local_infile); mysql_options(&mysql,MYSQL_OPT_LOCAL_INFILE, (char*) &opt_local_infile);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (opt_ssl_key || opt_ssl_cert || opt_ssl_ca || opt_ssl_capath ||
opt_ssl_cipher)
opt_use_ssl= 1;
if (opt_use_ssl) if (opt_use_ssl)
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath, opt_ssl_cipher); opt_ssl_capath, opt_ssl_cipher);
......
...@@ -222,7 +222,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -222,7 +222,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
else else
option_wait= ~0; option_wait= ~0;
break; break;
#include "sslopt-case.h"
case '?': case '?':
case 'I': /* Info */ case 'I': /* Info */
error++; error++;
...@@ -275,10 +274,13 @@ int main(int argc,char *argv[]) ...@@ -275,10 +274,13 @@ int main(int argc,char *argv[])
mysql_options(&mysql,MYSQL_OPT_CONNECT_TIMEOUT, (char*) &tmp); mysql_options(&mysql,MYSQL_OPT_CONNECT_TIMEOUT, (char*) &tmp);
} }
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (opt_ssl_key || opt_ssl_cert || opt_ssl_ca || opt_ssl_capath ||
opt_ssl_cipher)
opt_use_ssl= 1;
if (opt_use_ssl) if (opt_use_ssl)
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath, opt_ssl_cipher); opt_ssl_capath, opt_ssl_cipher);
#endif /* HAVE_OPENSSL */ #endif
if (sql_connect(&mysql, option_wait)) if (sql_connect(&mysql, option_wait))
error = 1; error = 1;
else else
......
...@@ -246,7 +246,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -246,7 +246,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
verbose++; verbose++;
break; break;
case 'V': print_version(); exit(0); case 'V': print_version(); exit(0);
#include "sslopt-case.h"
} }
return 0; return 0;
} }
...@@ -530,6 +529,9 @@ static int dbConnect(char *host, char *user, char *passwd) ...@@ -530,6 +529,9 @@ static int dbConnect(char *host, char *user, char *passwd)
if (opt_compress) if (opt_compress)
mysql_options(&mysql_connection, MYSQL_OPT_COMPRESS, NullS); mysql_options(&mysql_connection, MYSQL_OPT_COMPRESS, NullS);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (opt_ssl_key || opt_ssl_cert || opt_ssl_ca || opt_ssl_capath ||
opt_ssl_cipher)
opt_use_ssl= 1;
if (opt_use_ssl) if (opt_use_ssl)
mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath, opt_ssl_cipher); opt_ssl_capath, opt_ssl_cipher);
......
...@@ -352,7 +352,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -352,7 +352,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case (int) OPT_TABLES: case (int) OPT_TABLES:
opt_databases=0; opt_databases=0;
break; break;
#include "sslopt-case.h"
} }
return 0; return 0;
} }
...@@ -458,6 +457,9 @@ static int dbConnect(char *host, char *user,char *passwd) ...@@ -458,6 +457,9 @@ static int dbConnect(char *host, char *user,char *passwd)
if (opt_compress) if (opt_compress)
mysql_options(&mysql_connection,MYSQL_OPT_COMPRESS,NullS); mysql_options(&mysql_connection,MYSQL_OPT_COMPRESS,NullS);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (opt_ssl_key || opt_ssl_cert || opt_ssl_ca || opt_ssl_capath ||
opt_ssl_cipher)
opt_use_ssl= 1;
if (opt_use_ssl) if (opt_use_ssl)
mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath, opt_ssl_cipher); opt_ssl_capath, opt_ssl_cipher);
......
...@@ -193,7 +193,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -193,7 +193,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case '?': case '?':
usage(); usage();
exit(0); exit(0);
#include "sslopt-case.h"
} }
return 0; return 0;
} }
...@@ -348,6 +347,9 @@ static MYSQL *db_connect(char *host, char *database, char *user, char *passwd) ...@@ -348,6 +347,9 @@ static MYSQL *db_connect(char *host, char *database, char *user, char *passwd)
mysql_options(&mysql_connection,MYSQL_OPT_LOCAL_INFILE, mysql_options(&mysql_connection,MYSQL_OPT_LOCAL_INFILE,
(char*) &opt_local_file); (char*) &opt_local_file);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (opt_ssl_key || opt_ssl_cert || opt_ssl_ca || opt_ssl_capath ||
opt_ssl_cipher)
opt_use_ssl= 1;
if (opt_use_ssl) if (opt_use_ssl)
mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath, opt_ssl_cipher); opt_ssl_capath, opt_ssl_cipher);
......
...@@ -85,6 +85,9 @@ int main(int argc, char **argv) ...@@ -85,6 +85,9 @@ int main(int argc, char **argv)
if (opt_compress) if (opt_compress)
mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS); mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (opt_ssl_key || opt_ssl_cert || opt_ssl_ca || opt_ssl_capath ||
opt_ssl_cipher)
opt_use_ssl= 1;
if (opt_use_ssl) if (opt_use_ssl)
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath, opt_ssl_cipher); opt_ssl_capath, opt_ssl_cipher);
...@@ -218,7 +221,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -218,7 +221,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_mysql_unix_port=MYSQL_NAMEDPIPE; opt_mysql_unix_port=MYSQL_NAMEDPIPE;
#endif #endif
break; break;
#include "sslopt-case.h"
case '#': case '#':
DBUG_PUSH(argument ? argument : "d:t:o"); DBUG_PUSH(argument ? argument : "d:t:o");
break; break;
......
...@@ -20,7 +20,7 @@ pkginclude_HEADERS = dbug.h m_string.h my_sys.h my_list.h \ ...@@ -20,7 +20,7 @@ pkginclude_HEADERS = dbug.h m_string.h my_sys.h my_list.h \
mysql.h mysql_com.h mysqld_error.h mysql_embed.h \ mysql.h mysql_com.h mysqld_error.h mysql_embed.h \
my_semaphore.h my_pthread.h my_no_pthread.h raid.h \ my_semaphore.h my_pthread.h my_no_pthread.h raid.h \
errmsg.h my_global.h my_net.h my_alloc.h\ errmsg.h my_global.h my_net.h my_alloc.h\
sslopt-case.h sslopt-longopts.h sslopt-usage.h \ sslopt-longopts.h sslopt-usage.h \
sslopt-vars.h $(BUILT_SOURCES) sslopt-vars.h $(BUILT_SOURCES)
noinst_HEADERS = config-win.h config-os2.h \ noinst_HEADERS = config-win.h config-os2.h \
nisam.h heap.h merge.h my_bitmap.h\ nisam.h heap.h merge.h my_bitmap.h\
......
/* Copyright (C) 2000 MySQL AB
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
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
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef HAVE_OPENSSL
case OPT_SSL_SSL:
opt_use_ssl = 1; /* true */
break;
case OPT_SSL_KEY:
opt_use_ssl = 1; /* true */
/* QQ to be removed??? my_free(opt_ssl_key, MYF(MY_ALLOW_ZERO_PTR)); */
/* QQ to be removed??? opt_ssl_key = my_strdup(optarg, MYF(0)); */
my_free(opt_ssl_key, MYF(MY_ALLOW_ZERO_PTR));
opt_ssl_key = my_strdup(argument, MYF(0));
break;
case OPT_SSL_CERT:
opt_use_ssl = 1; /* true */
my_free(opt_ssl_cert, MYF(MY_ALLOW_ZERO_PTR));
opt_ssl_cert = my_strdup(argument, MYF(0));
break;
case OPT_SSL_CA:
opt_use_ssl = 1; /* true */
my_free(opt_ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
opt_ssl_ca = my_strdup(argument, MYF(0));
break;
case OPT_SSL_CAPATH:
opt_use_ssl = 1; /* true */
my_free(opt_ssl_capath, MYF(MY_ALLOW_ZERO_PTR));
opt_ssl_capath = my_strdup(argument, MYF(0));
break;
case OPT_SSL_CIPHER:
opt_use_ssl = 1; /* true */
my_free(opt_ssl_cipher, MYF(MY_ALLOW_ZERO_PTR));
opt_ssl_cipher = my_strdup(argument, MYF(0));
break;
#endif
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
"CA directory (check OpenSSL docs, implies --ssl)", "CA directory (check OpenSSL docs, implies --ssl)",
(gptr*) &opt_ssl_capath, (gptr*) &opt_ssl_capath, 0, GET_STR, REQUIRED_ARG, (gptr*) &opt_ssl_capath, (gptr*) &opt_ssl_capath, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"ssl-cipher", OPT_SSL_CAPATH, "SSL cipher to use (implies --ssl)", {"ssl-cipher", OPT_SSL_CIPHER, "SSL cipher to use (implies --ssl)",
(gptr*) &opt_ssl_cipher, (gptr*) &opt_ssl_cipher, 0, GET_STR, REQUIRED_ARG, (gptr*) &opt_ssl_cipher, (gptr*) &opt_ssl_cipher, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
......
...@@ -1436,7 +1436,6 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) , ...@@ -1436,7 +1436,6 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
mysql->options.ssl_ca= strdup_if_not_null(ca); mysql->options.ssl_ca= strdup_if_not_null(ca);
mysql->options.ssl_capath= strdup_if_not_null(capath); mysql->options.ssl_capath= strdup_if_not_null(capath);
mysql->options.ssl_cipher= strdup_if_not_null(cipher); mysql->options.ssl_cipher= strdup_if_not_null(cipher);
mysql->options.use_ssl= TRUE;
mysql->connector_fd = (gptr) new_VioSSLConnectorFd(key, cert, ca, capath, mysql->connector_fd = (gptr) new_VioSSLConnectorFd(key, cert, ca, capath,
cipher); cipher);
DBUG_PRINT("info",("mysql_ssl_set, context: %p", DBUG_PRINT("info",("mysql_ssl_set, context: %p",
...@@ -1808,6 +1807,10 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -1808,6 +1807,10 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
client_flag|=CLIENT_CAPABILITIES; client_flag|=CLIENT_CAPABILITIES;
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
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;
if (mysql->options.use_ssl) if (mysql->options.use_ssl)
client_flag|=CLIENT_SSL; client_flag|=CLIENT_SSL;
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
......
...@@ -989,3 +989,41 @@ select * from t2; ...@@ -989,3 +989,41 @@ select * from t2;
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
333 tubs 99 2 20020109113453 501 20020109113453 500 3 10 0 333 tubs 99 2 20020109113453 501 20020109113453 500 3 10 0
drop table t1,t2; drop table t1,t2;
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) type=innodb;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SELECT @@tx_isolation,@@global.tx_isolation;
@@tx_isolation @@tx_isolation
SERIALIZABLE READ-COMMITTED
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David');
select id, code, name from t1 order by id;
id code name
1 1 Tim
2 1 Monty
3 2 David
COMMIT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha');
select id, code, name from t1 order by id;
id code name
1 1 Tim
2 1 Monty
3 2 David
4 2 Erik
5 3 Sasha
COMMIT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt');
select id, code, name from t1 order by id;
id code name
1 1 Tim
2 1 Monty
3 2 David
4 2 Erik
5 3 Sasha
6 3 Jeremy
7 4 Matt
COMMIT;
DROP TABLE t1;
...@@ -638,3 +638,31 @@ select * from t1; ...@@ -638,3 +638,31 @@ select * from t1;
select * from t2; select * from t2;
select * from t2; select * from t2;
drop table t1,t2; drop table t1,t2;
#
# A simple test with some isolation levels
# TODO: Make this into a test using replication to really test how
# this works.
#
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) type=innodb;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SELECT @@tx_isolation,@@global.tx_isolation;
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David');
select id, code, name from t1 order by id;
COMMIT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha');
select id, code, name from t1 order by id;
COMMIT;
BEGIN;
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt');
select id, code, name from t1 order by id;
COMMIT;
DROP TABLE t1;
...@@ -492,7 +492,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -492,7 +492,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
uint port, const char *unix_socket,uint client_flag, uint port, const char *unix_socket,uint client_flag,
uint net_read_timeout) uint net_read_timeout)
{ {
char buff[100],*end,*host_info; char buff[NAME_LEN+USERNAME_LENGTH+100],*end,*host_info;
my_socket sock; my_socket sock;
ulong ip_addr; ulong ip_addr;
struct sockaddr_in sock_addr; struct sockaddr_in sock_addr;
...@@ -518,7 +518,6 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -518,7 +518,6 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
thr_alarm_init(&alarmed); thr_alarm_init(&alarmed);
thr_alarm(&alarmed, net_read_timeout, &alarm_buff); thr_alarm(&alarmed, net_read_timeout, &alarm_buff);
bzero((char*) &mysql->options,sizeof(mysql->options));
net->vio = 0; /* If something goes wrong */ net->vio = 0; /* If something goes wrong */
mysql->charset=default_charset_info; /* Set character set */ mysql->charset=default_charset_info; /* Set character set */
if (!port) if (!port)
...@@ -527,13 +526,14 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -527,13 +526,14 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
unix_socket=MYSQL_UNIX_ADDR; unix_socket=MYSQL_UNIX_ADDR;
mysql->reconnect=1; /* Reconnect as default */ mysql->reconnect=1; /* Reconnect as default */
mysql->server_status=SERVER_STATUS_AUTOCOMMIT;
/* /*
** Grab a socket and connect it to the server ** Grab a socket and connect it to the server
*/ */
#if defined(HAVE_SYS_UN_H) #if defined(HAVE_SYS_UN_H)
if (!host || !strcmp(host,LOCAL_HOST)) if ((!host || !strcmp(host,LOCAL_HOST)) && unix_socket)
{ {
host=LOCAL_HOST; host=LOCAL_HOST;
host_info=(char*) ER(CR_LOCALHOST_CONNECTION); host_info=(char*) ER(CR_LOCALHOST_CONNECTION);
...@@ -598,7 +598,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -598,7 +598,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
host=LOCAL_HOST; host=LOCAL_HOST;
sprintf(host_info=buff,ER(CR_TCP_CONNECTION),host); sprintf(host_info=buff,ER(CR_TCP_CONNECTION),host);
DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host,port)); DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host,port));
if ((sock = socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR) if ((sock = (my_socket) socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR)
{ {
net->last_errno=CR_IPSOCK_ERROR; net->last_errno=CR_IPSOCK_ERROR;
sprintf(net->last_error,ER(net->last_errno),socket_errno); sprintf(net->last_error,ER(net->last_errno),socket_errno);
...@@ -652,7 +652,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -652,7 +652,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
if (!net->vio || my_net_init(net, net->vio)) if (!net->vio || my_net_init(net, net->vio))
{ {
vio_delete(net->vio); vio_delete(net->vio);
net->vio = 0; // safety net->vio = 0;
net->last_errno=CR_OUT_OF_MEMORY; net->last_errno=CR_OUT_OF_MEMORY;
strmov(net->last_error,ER(net->last_errno)); strmov(net->last_error,ER(net->last_errno));
goto error; goto error;
...@@ -661,6 +661,13 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -661,6 +661,13 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
net->read_timeout=slave_net_timeout; net->read_timeout=slave_net_timeout;
/* Get version info */ /* Get version info */
mysql->protocol_version= PROTOCOL_VERSION; /* Assume this */ mysql->protocol_version= PROTOCOL_VERSION; /* Assume this */
if (mysql->options.connect_timeout &&
vio_poll_read(net->vio, mysql->options.connect_timeout))
{
net->last_errno= CR_SERVER_LOST;
strmov(net->last_error,ER(net->last_errno));
goto error;
}
if ((pkt_length=mc_net_safe_read(mysql)) == packet_error) if ((pkt_length=mc_net_safe_read(mysql)) == packet_error)
goto error; goto error;
...@@ -682,8 +689,15 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -682,8 +689,15 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
mysql->thread_id=uint4korr(end+1); mysql->thread_id=uint4korr(end+1);
end+=5; end+=5;
strmake(mysql->scramble_buff,end,8); strmake(mysql->scramble_buff,end,8);
if (pkt_length > (uint) (end+9 - (char*) net->read_pos)) end+=9;
mysql->server_capabilities=uint2korr(end+9); if (pkt_length >= (uint) (end+1 - (char*) net->read_pos))
mysql->server_capabilities=uint2korr(end);
if (pkt_length >= (uint) (end+18 - (char*) net->read_pos))
{
/* New protocol with 16 bytes to describe server characteristics */
mysql->server_language=end[2];
mysql->server_status=uint2korr(end+3);
}
/* Save connection information */ /* Save connection information */
if (!user) user=""; if (!user) user="";
...@@ -710,7 +724,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -710,7 +724,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
mysql->unix_socket=0; mysql->unix_socket=0;
strmov(mysql->server_version,(char*) net->read_pos+1); strmov(mysql->server_version,(char*) net->read_pos+1);
mysql->port=port; mysql->port=port;
mysql->client_flag=client_flag | mysql->options.client_flag; client_flag|=mysql->options.client_flag;
DBUG_PRINT("info",("Server version = '%s' capabilites: %ld", DBUG_PRINT("info",("Server version = '%s' capabilites: %ld",
mysql->server_version,mysql->server_capabilities)); mysql->server_version,mysql->server_capabilities));
...@@ -718,6 +732,10 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -718,6 +732,10 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
client_flag|=CLIENT_CAPABILITIES; client_flag|=CLIENT_CAPABILITIES;
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
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;
if (mysql->options.use_ssl) if (mysql->options.use_ssl)
client_flag|=CLIENT_SSL; client_flag|=CLIENT_SSL;
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
...@@ -725,8 +743,8 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -725,8 +743,8 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
if (db) if (db)
client_flag|=CLIENT_CONNECT_WITH_DB; client_flag|=CLIENT_CONNECT_WITH_DB;
#ifdef HAVE_COMPRESS #ifdef HAVE_COMPRESS
if (mysql->server_capabilities & CLIENT_COMPRESS && if ((mysql->server_capabilities & CLIENT_COMPRESS) &&
(mysql->options.compress || client_flag & CLIENT_COMPRESS)) (mysql->options.compress || (client_flag & CLIENT_COMPRESS)))
client_flag|=CLIENT_COMPRESS; /* We will use compression */ client_flag|=CLIENT_COMPRESS; /* We will use compression */
else else
#endif #endif
...@@ -753,22 +771,10 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -753,22 +771,10 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
mysql->client_flag=client_flag; mysql->client_flag=client_flag;
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if ((mysql->server_capabilities & CLIENT_SSL) && /*
(mysql->options.use_ssl || (client_flag & CLIENT_SSL))) Oops.. are we careful enough to not send ANY information without
{ encryption?
DBUG_PRINT("info", ("Changing IO layer to SSL")); */
client_flag |= CLIENT_SSL;
}
else
{
if (client_flag & CLIENT_SSL)
{
DBUG_PRINT("info", ("Leaving IO layer intact because server doesn't support SSL"));
}
client_flag &= ~CLIENT_SSL;
}
/* Oops.. are we careful enough to not send ANY information */
/* without encryption? */
if (client_flag & CLIENT_SSL) if (client_flag & CLIENT_SSL)
{ {
if (my_net_write(net,buff,(uint) (2)) || net_flush(net)) if (my_net_write(net,buff,(uint) (2)) || net_flush(net))
...@@ -776,11 +782,11 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -776,11 +782,11 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
/* Do the SSL layering. */ /* Do the SSL layering. */
DBUG_PRINT("info", ("IO layer change in progress...")); DBUG_PRINT("info", ("IO layer change in progress..."));
DBUG_PRINT("info", ("IO context %p",((struct st_VioSSLConnectorFd*)mysql->connector_fd)->ssl_context_)); DBUG_PRINT("info", ("IO context %p",((struct st_VioSSLConnectorFd*)mysql->connector_fd)->ssl_context_));
sslconnect((struct st_VioSSLConnectorFd*)(mysql->connector_fd),mysql->net.vio,60L); sslconnect((struct st_VioSSLConnectorFd*)(mysql->connector_fd),mysql->net.vio, (long)(mysql->options.connect_timeout));
DBUG_PRINT("info", ("IO layer change done!")); DBUG_PRINT("info", ("IO layer change done!"));
} }
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
max_allowed_packet=mysql->net.max_packet; max_allowed_packet=mysql->net.max_packet_size;
int3store(buff+2,max_allowed_packet); int3store(buff+2,max_allowed_packet);
...@@ -798,10 +804,11 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -798,10 +804,11 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
(my_bool) (mysql->protocol_version == 9)); (my_bool) (mysql->protocol_version == 9));
if (db) if (db)
{ {
end=strmov(end+1,db); end=strmake(end+1,db,NAME_LEN);
mysql->db=my_strdup(db,MYF(MY_WME)); mysql->db=my_strdup(db,MYF(MY_WME));
db=0;
} }
if (my_net_write(net,buff,(uint) (end-buff)) || net_flush(net) || if (my_net_write(net,buff,(ulong) (end-buff)) || net_flush(net) ||
mc_net_safe_read(mysql) == packet_error) mc_net_safe_read(mysql) == packet_error)
goto error; goto error;
if (client_flag & CLIENT_COMPRESS) /* We will use compression */ if (client_flag & CLIENT_COMPRESS) /* We will use compression */
...@@ -837,10 +844,12 @@ mysql_ssl_clear(MYSQL *mysql) ...@@ -837,10 +844,12 @@ mysql_ssl_clear(MYSQL *mysql)
my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.ssl_capath, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.ssl_capath, MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.ssl_cipher, MYF(MY_ALLOW_ZERO_PTR));
mysql->options.ssl_key = 0; mysql->options.ssl_key = 0;
mysql->options.ssl_cert = 0; mysql->options.ssl_cert = 0;
mysql->options.ssl_ca = 0; mysql->options.ssl_ca = 0;
mysql->options.ssl_capath = 0; mysql->options.ssl_capath = 0;
mysql->options.ssl_cipher= 0;
mysql->options.use_ssl = FALSE; mysql->options.use_ssl = FALSE;
my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR));
mysql->connector_fd = 0; mysql->connector_fd = 0;
......
...@@ -828,16 +828,6 @@ void clean_up(bool print_message) ...@@ -828,16 +828,6 @@ void clean_up(bool print_message)
#ifdef USE_RAID #ifdef USE_RAID
end_raid(); end_raid();
#endif #endif
#ifdef HAVE_OPENSSL
my_free(opt_ssl_key,MYF(MY_ALLOW_ZERO_PTR));
my_free(opt_ssl_cert,MYF(MY_ALLOW_ZERO_PTR));
my_free(opt_ssl_ca,MYF(MY_ALLOW_ZERO_PTR));
my_free(opt_ssl_capath,MYF(MY_ALLOW_ZERO_PTR));
my_free(opt_ssl_cipher,MYF(MY_ALLOW_ZERO_PTR));
my_free((gptr) ssl_acceptor_fd, MYF(MY_ALLOW_ZERO_PTR));
opt_ssl_key=opt_ssl_cert=opt_ssl_ca=opt_ssl_capath=0;
#endif /* HAVE_OPENSSL */
if (defaults_argv) if (defaults_argv)
free_defaults(defaults_argv); free_defaults(defaults_argv);
my_free(charsets_list, MYF(MY_ALLOW_ZERO_PTR)); my_free(charsets_list, MYF(MY_ALLOW_ZERO_PTR));
...@@ -1868,13 +1858,16 @@ int main(int argc, char **argv) ...@@ -1868,13 +1858,16 @@ int main(int argc, char **argv)
charsets_list = list_charsets(MYF(MY_COMPILED_SETS|MY_CONFIG_SETS)); charsets_list = list_charsets(MYF(MY_COMPILED_SETS|MY_CONFIG_SETS));
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (opt_ssl_key || opt_ssl_cert || opt_ssl_ca || opt_ssl_capath ||
opt_ssl_cipher)
opt_use_ssl= 1;
if (opt_use_ssl) if (opt_use_ssl)
{ {
/* having ssl_acceptor_fd != 0 signals the use of SSL */ /* having ssl_acceptor_fd != 0 signals the use of SSL */
ssl_acceptor_fd= new_VioSSLAcceptorFd(opt_ssl_key, opt_ssl_cert, ssl_acceptor_fd= new_VioSSLAcceptorFd(opt_ssl_key, opt_ssl_cert,
opt_ssl_ca, opt_ssl_capath, opt_ssl_ca, opt_ssl_capath,
opt_ssl_cipher); opt_ssl_cipher);
DBUG_PRINT("info",("ssl_acceptor_fd: %p", ssl_acceptor_fd)); DBUG_PRINT("info",("ssl_acceptor_fd: %lx", (long) ssl_acceptor_fd));
if (!ssl_acceptor_fd) if (!ssl_acceptor_fd)
opt_use_ssl = 0; opt_use_ssl = 0;
} }
...@@ -4237,14 +4230,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -4237,14 +4230,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
strmake(mysql_charsets_dir, argument, sizeof(mysql_charsets_dir)-1); strmake(mysql_charsets_dir, argument, sizeof(mysql_charsets_dir)-1);
charsets_dir = mysql_charsets_dir; charsets_dir = mysql_charsets_dir;
break; break;
#ifdef HAVE_OPENSSL
#include "sslopt-case.h"
#endif
case OPT_DES_KEY_FILE:
#ifdef HAVE_OPENSSL
des_key_file=argument;
#endif
break;
case OPT_TX_ISOLATION: case OPT_TX_ISOLATION:
{ {
int type; int type;
...@@ -4361,7 +4346,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -4361,7 +4346,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
static void get_options(int argc,char **argv) static void get_options(int argc,char **argv)
{ {
int ho_error; int ho_error;
THD *thd= current_thd;
myisam_delay_key_write=1; // Allow use of this myisam_delay_key_write=1; // Allow use of this
#ifndef HAVE_purify #ifndef HAVE_purify
......
...@@ -3286,7 +3286,7 @@ option_value: ...@@ -3286,7 +3286,7 @@ option_value:
{ {
LEX *lex=Lex; LEX *lex=Lex;
lex->var_list.push_back(new set_var(lex->option_type, lex->var_list.push_back(new set_var(lex->option_type,
find_sys_var("transaction_isolation_num"), find_sys_var("tx_isolation"),
new Item_int((int) $4))); new Item_int((int) $4)));
} }
| CHAR_SYM SET opt_equal set_expr_or_default | CHAR_SYM SET opt_equal set_expr_or_default
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment