summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VC++Files/libmysqltest/mytest.c1
-rw-r--r--VC++Files/mysqlmanager/mysqlmanagerview.cpp5
-rw-r--r--VC++Files/test1/mysql_thr.c1
-rw-r--r--VC++Files/winmysqladmin/main.cpp2
-rw-r--r--client/mysql.cc2
-rw-r--r--client/mysqladmin.cc1
-rw-r--r--client/mysqlbinlog.cc1
-rw-r--r--client/mysqlcheck.c1
-rw-r--r--client/mysqlimport.c1
-rw-r--r--client/mysqlshow.c1
-rw-r--r--client/mysqltest.c1
-rw-r--r--libmysql/libmysql.c4
-rw-r--r--libmysqld/examples/builder-sample/emb_samples.cpp1
-rw-r--r--ndb/test/ndbapi/flex_bench_mysql.cpp2
-rw-r--r--ndb/tools/restore/consumer_restorem.cpp1
-rw-r--r--sql-common/client.c19
-rw-r--r--sql/repl_failsafe.cc1
-rw-r--r--sql/slave.cc1
-rw-r--r--tests/client_test.c7
-rw-r--r--tests/connect_test.c1
-rw-r--r--tests/deadlock_test.c1
-rw-r--r--tests/insert_test.c1
-rw-r--r--tests/list_test.c1
-rw-r--r--tests/select_test.c1
-rw-r--r--tests/showdb_test.c1
-rw-r--r--tests/ssl_test.c1
-rw-r--r--tests/thread_test.c1
-rw-r--r--tools/mysqlmanager.c3
28 files changed, 63 insertions, 1 deletions
diff --git a/VC++Files/libmysqltest/mytest.c b/VC++Files/libmysqltest/mytest.c
index 9af8c486e40..a1dc13db39f 100644
--- a/VC++Files/libmysqltest/mytest.c
+++ b/VC++Files/libmysqltest/mytest.c
@@ -91,6 +91,7 @@ main( int argc, char * argv[] )
mysql_real_connect( myData, NULL, NULL, NULL, NULL, MYSQL_PORT,
NULL, 0 ) )
{
+ myData->reconnect= 1;
if ( mysql_select_db( myData, szDB ) < 0 ) {
printf( "Can't select the %s database !\n", szDB ) ;
mysql_close( myData ) ;
diff --git a/VC++Files/mysqlmanager/mysqlmanagerview.cpp b/VC++Files/mysqlmanager/mysqlmanagerview.cpp
index 1d4756e7d7a..f39e0a9963e 100644
--- a/VC++Files/mysqlmanager/mysqlmanagerview.cpp
+++ b/VC++Files/mysqlmanager/mysqlmanagerview.cpp
@@ -551,6 +551,7 @@ void CMySqlManagerView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
PostMessage(WM_COMMAND,IDM_TOOLS_SERVER_PROPERTIES);
return;
}
+ mysql.reconnect= 1;
if (!(result=mysql_list_processes(&mysql)))
{
return;
@@ -576,6 +577,7 @@ void CMySqlManagerView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
);
return;
}
+ mysql.reconnect= 1;
if (!(result=mysql_list_dbs(&mysql,0)))
{
}
@@ -603,6 +605,7 @@ void CMySqlManagerView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
);
return;
}
+ mysql.reconnect= 1;
CResourceDatabase* pRes = (CResourceDatabase*) pResource;
CString strDB = pResource->GetDisplayName();
strDB.TrimRight();
@@ -641,6 +644,7 @@ void CMySqlManagerView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
);
return;
}
+ mysql.reconnect= 1;
HTREEITEM hParent = m_pTree->GetParentItem(hItem);
memset( &item, 0, sizeof(TV_ITEM) );
item.hItem = hParent;
@@ -714,6 +718,7 @@ void CMySqlManagerView::OnRefresh()
{
return;
}
+ mysql.reconnect= 1;
memset( &item, 0, sizeof(TV_ITEM) );
item.hItem = hParent;
item.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_CHILDREN | TVIF_PARAM ;
diff --git a/VC++Files/test1/mysql_thr.c b/VC++Files/test1/mysql_thr.c
index fac5c37a9af..c2743cb8e4c 100644
--- a/VC++Files/test1/mysql_thr.c
+++ b/VC++Files/test1/mysql_thr.c
@@ -167,6 +167,7 @@ pthread_handler_decl(test_thread,arg)
perror("");
goto end;
}
+ mysql.reconnect= 1;
if (mysql_query(&mysql,"select 1") < 0)
{
fprintf(stderr,"Query failed (%s)\n",mysql_error(&mysql));
diff --git a/VC++Files/winmysqladmin/main.cpp b/VC++Files/winmysqladmin/main.cpp
index dfb2004a780..150bc669c74 100644
--- a/VC++Files/winmysqladmin/main.cpp
+++ b/VC++Files/winmysqladmin/main.cpp
@@ -1337,6 +1337,7 @@ void __fastcall TForm1::IsMySQLInit(void)
}
}
+ MySQL->reconnect= 1;
}
@@ -1348,6 +1349,7 @@ void __fastcall TForm1::IsMySQLInit(void)
MySQL = mysql_init(MySQL);
if(mysql_real_connect(MySQL,host,user,password , 0, 0, NULL, 0))
IsConnect = true;
+ MySQL->reconnect= 1;
}
}
}
diff --git a/client/mysql.cc b/client/mysql.cc
index 8e9dd84c8f0..cb3a56972fa 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -2792,6 +2792,8 @@ sql_real_connect(char *host,char *database,char *user,char *password,
connected=1;
#ifndef EMBEDDED_LIBRARY
mysql.reconnect=info_flag ? 1 : 0; // We want to know if this happens
+#else
+ mysql.reconnect= 1;
#endif
#ifdef HAVE_READLINE
build_completion_hash(rehash, 1);
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 924af3a9977..21e8f6ab3e4 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -425,6 +425,7 @@ static my_bool sql_connect(MYSQL *mysql, uint wait)
if (mysql_real_connect(mysql,host,user,opt_password,NullS,tcp_port,
unix_port, 0))
{
+ mysql->reconnect= 1;
if (info)
{
fputs("\n",stderr);
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 1c10ece92dd..7036deab2fe 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -753,6 +753,7 @@ static MYSQL* safe_connect()
mysql_options(local_mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol);
if (!mysql_real_connect(local_mysql, host, user, pass, 0, port, sock, 0))
die("failed on connect: %s", mysql_error(local_mysql));
+ local_mysql->reconnect= 1;
return local_mysql;
}
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index c670b84db44..980046fe6e6 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -628,6 +628,7 @@ static int dbConnect(char *host, char *user, char *passwd)
DBerror(&mysql_connection, "when trying to connect");
return 1;
}
+ mysql_connection.reconnect= 1;
return 0;
} /* dbConnect */
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index fae84be610a..3552f03fb27 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -388,6 +388,7 @@ static MYSQL *db_connect(char *host, char *database, char *user, char *passwd)
ignore_errors=0; /* NO RETURN FROM db_error */
db_error(&mysql_connection);
}
+ mysql_connection.reconnect= 0;
if (verbose)
fprintf(stdout, "Selecting database %s\n", database);
if (mysql_select_db(sock, database))
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index ee478058cdc..8171cb95268 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -125,6 +125,7 @@ int main(int argc, char **argv)
fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql));
exit(1);
}
+ mysql.reconnect= 1;
switch (argc)
{
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 4f55320e4f3..27ba5bad6c7 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -1627,6 +1627,7 @@ int safe_connect(MYSQL* con, const char* host, const char* user,
}
sleep(CON_RETRY_SLEEP);
}
+ con->reconnect= 1; /* TODO: change this to 0 in future versions */
return con_error;
}
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 3e98d8399ff..2355f9f6617 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -317,6 +317,7 @@ my_bool STDCALL mysql_master_send_query(MYSQL *mysql, const char *q,
DBUG_ENTER("mysql_master_send_query");
if (!master->net.vio && !mysql_real_connect(master,0,0,0,0,0,0,0))
DBUG_RETURN(1);
+ master->reconnect= 1;
mysql->last_used_con = master;
DBUG_RETURN(simple_command(master, COM_QUERY, q, length, 1));
}
@@ -351,6 +352,7 @@ my_bool STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
if (!slave_to_use->net.vio && !mysql_real_connect(slave_to_use, 0,0,0,
0,0,0,0))
DBUG_RETURN(1);
+ slave_to_use->reconnect= 1;
DBUG_RETURN(simple_command(slave_to_use, COM_QUERY, q, length, 1));
}
@@ -448,6 +450,7 @@ static my_bool get_slaves_from_master(MYSQL* mysql)
expand_error(mysql, CR_PROBE_MASTER_CONNECT);
DBUG_RETURN(1);
}
+ mysql->reconnect= 1;
if (mysql_query(mysql, "SHOW SLAVE HOSTS") ||
!(res = mysql_store_result(mysql)))
@@ -615,6 +618,7 @@ mysql_connect(MYSQL *mysql,const char *host,
if (mysql->free_me)
my_free((gptr) mysql,MYF(0));
}
+ mysql->reconnect= 1;
DBUG_RETURN(res);
}
}
diff --git a/libmysqld/examples/builder-sample/emb_samples.cpp b/libmysqld/examples/builder-sample/emb_samples.cpp
index 4dfde111f84..411de26149b 100644
--- a/libmysqld/examples/builder-sample/emb_samples.cpp
+++ b/libmysqld/examples/builder-sample/emb_samples.cpp
@@ -109,6 +109,7 @@ bool __fastcall TForm1::connect_server()
ret_value = true;
is_server_started = true;
}
+ MySQL->reconnect= 1;
return ret_value;
}
//---------------------------------------------------------------------------
diff --git a/ndb/test/ndbapi/flex_bench_mysql.cpp b/ndb/test/ndbapi/flex_bench_mysql.cpp
index c8d4d85bedf..ad84390a9e5 100644
--- a/ndb/test/ndbapi/flex_bench_mysql.cpp
+++ b/ndb/test/ndbapi/flex_bench_mysql.cpp
@@ -397,6 +397,7 @@ NDB_COMMAND(flexBench, "flexBench", "flexBench", "flexbench", 65535)
ndbout << "Connect failed" <<endl;
returnValue = NDBT_FAILED;
}
+ mysql.reconnect= 1;
}
if(returnValue == NDBT_OK){
mysql_set_server_option(&mysql, MYSQL_OPTION_MULTI_STATEMENTS_ON);
@@ -712,6 +713,7 @@ static void* flexBenchThread(void* pArg)
ndbout << "failed" << endl;
NdbThread_Exit(0) ;
}
+ mysql.reconnect= 1;
ndbout << "ok" << endl;
int r;
diff --git a/ndb/tools/restore/consumer_restorem.cpp b/ndb/tools/restore/consumer_restorem.cpp
index 6a9ec07148a..ce1738ea686 100644
--- a/ndb/tools/restore/consumer_restorem.cpp
+++ b/ndb/tools/restore/consumer_restorem.cpp
@@ -80,6 +80,7 @@ BackupRestore::init()
ndbout_c("Connect failed: %s", mysql_error(&mysql));
returnValue = false;
}
+ mysql.reconnect= 1;
ndbout << "Connected to MySQL!!!" <<endl;
}
diff --git a/sql-common/client.c b/sql-common/client.c
index aa50b9fe27b..fd65ed01462 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1587,8 +1587,24 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
port=mysql->options.port;
if (!unix_socket)
unix_socket=mysql->options.unix_socket;
+
+ /*
+ 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().
+ - existing apps which explicitely asked for reconnection (the only way they
+ could do it was by setting mysql.reconnect to 1 after mysql_real_connect())
+ will not see a behaviour change.
+ - existing apps which explicitely asked for no reconnection
+ (mysql.reconnect=0) will not see a behaviour change.
+ */
+ mysql->reconnect= 0;
- mysql->reconnect=1; /* Reconnect as default */
mysql->server_status=SERVER_STATUS_AUTOCOMMIT;
/*
@@ -2161,6 +2177,7 @@ my_bool mysql_reconnect(MYSQL *mysql)
strmov(mysql->net.sqlstate, tmp_mysql.net.sqlstate);
DBUG_RETURN(1);
}
+ tmp_mysql.reconnect= 1;
tmp_mysql.free_me= mysql->free_me;
/* Don't free options as these are now used in tmp_mysql */
bzero((char*) &mysql->options,sizeof(mysql->options));
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index f759be59ffb..b7575f3a44e 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -709,6 +709,7 @@ int connect_to_master(THD *thd, MYSQL* mysql, MASTER_INFO* mi)
if (!mysql_real_connect(mysql, mi->host, mi->user, mi->password, 0,
mi->port, 0, 0))
DBUG_RETURN(1);
+ mysql->reconnect= 1;
DBUG_RETURN(0);
}
diff --git a/sql/slave.cc b/sql/slave.cc
index 1e38d92ebc5..9ddbe7d05de 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -4394,6 +4394,7 @@ replication resumed in log '%s' at position %s", mi->user,
thd->set_active_vio(mysql->net.vio);
#endif
}
+ mysql->reconnect= 1;
DBUG_PRINT("exit",("slave_was_killed: %d", slave_was_killed));
DBUG_RETURN(slave_was_killed);
}
diff --git a/tests/client_test.c b/tests/client_test.c
index aac0a92df65..7392f05d820 100644
--- a/tests/client_test.c
+++ b/tests/client_test.c
@@ -243,6 +243,7 @@ static void client_connect()
fprintf(stdout, "\n Check the connection options using --help or -?\n");
exit(1);
}
+ mysql->reconnect= 1;
if (!opt_silent)
fprintf(stdout, " OK");
@@ -1050,6 +1051,7 @@ static my_bool thread_query(char *query)
error= 1;
goto end;
}
+ l_mysql->reconnect= 1;
if (mysql_query(l_mysql, (char *)query))
{
fprintf(stderr, "Query failed (%s)\n", mysql_error(l_mysql));
@@ -4474,6 +4476,7 @@ static void test_stmt_close()
myerror("connection failed");
exit(1);
}
+ lmysql->reconnect= 1;
if (!opt_silent)
fprintf(stdout, " OK");
@@ -5365,6 +5368,7 @@ DROP TABLE IF EXISTS test_multi_tab";
fprintf(stdout, "\n connection failed(%s)", mysql_error(mysql_local));
exit(1);
}
+ mysql_local->reconnect= 1;
rc= mysql_query(mysql_local, query);
myquery(rc);
@@ -5473,6 +5477,7 @@ static void test_prepare_multi_statements()
fprintf(stderr, "\n connection failed(%s)", mysql_error(mysql_local));
exit(1);
}
+ mysql_local->reconnect= 1;
strmov(query, "select 1; select 'another value'");
stmt= mysql_simple_prepare(mysql_local, query);
check_stmt_r(stmt);
@@ -7004,6 +7009,7 @@ static void test_prepare_grant()
mysql_close(lmysql);
exit(1);
}
+ lmysql->reconnect= 1;
if (!opt_silent)
fprintf(stdout, " OK");
@@ -7439,6 +7445,7 @@ static void test_drop_temp()
mysql_close(lmysql);
exit(1);
}
+ lmysql->reconnect= 1;
if (!opt_silent)
fprintf(stdout, " OK");
diff --git a/tests/connect_test.c b/tests/connect_test.c
index fd81ad635ad..c68ade9f78f 100644
--- a/tests/connect_test.c
+++ b/tests/connect_test.c
@@ -46,6 +46,7 @@ int main(int argc, char **argv)
perror("");
exit(1);
}
+ sock->reconnect= 1;
if (mysql_select_db(sock,"test"))
{
diff --git a/tests/deadlock_test.c b/tests/deadlock_test.c
index 65a0df5c215..ab8158e0cd8 100644
--- a/tests/deadlock_test.c
+++ b/tests/deadlock_test.c
@@ -227,6 +227,7 @@ int main()
!mysql_real_connect(&sel, host, user, pass, db, 0,0,0 ) ||
!mysql_real_connect(&del_ins, host, user, pass, db, 0,0,0 ))
die("Error in mysql_real_connect(): %s", mysql_error(&lock));
+ lock.reconnect= sel.reconnect= del_ins.reconnect= 1;
permute(order, num_queries);
printf("count = %d\n", count);
diff --git a/tests/insert_test.c b/tests/insert_test.c
index 052c12bfdf0..2b659e9eecb 100644
--- a/tests/insert_test.c
+++ b/tests/insert_test.c
@@ -40,6 +40,7 @@ int main(int argc, char **argv)
perror("");
exit(1);
}
+ mysql.reconnect= 1;
num = atoi(argv[2]);
count = 0;
diff --git a/tests/list_test.c b/tests/list_test.c
index 06bf16d2751..1d50e703133 100644
--- a/tests/list_test.c
+++ b/tests/list_test.c
@@ -43,6 +43,7 @@ int main(int argc, char **argv)
perror("");
exit(1);
}
+ mysql.reconnect= 1;
if (mysql_select_db(sock,argv[1]) < 0)
{
diff --git a/tests/select_test.c b/tests/select_test.c
index ee2a9192865..64c4fec5167 100644
--- a/tests/select_test.c
+++ b/tests/select_test.c
@@ -44,6 +44,7 @@ int main(int argc, char **argv)
perror("");
exit(1);
}
+ mysql.reconnect= 1;
count = 0;
num = atoi(argv[2]);
diff --git a/tests/showdb_test.c b/tests/showdb_test.c
index df2b3037c00..08229fc51ee 100644
--- a/tests/showdb_test.c
+++ b/tests/showdb_test.c
@@ -45,6 +45,7 @@ int main(int argc, char **argv)
perror("");
exit(1);
}
+ mysql.reconnect= 1;
count = 0;
num = atoi(argv[2]);
diff --git a/tests/ssl_test.c b/tests/ssl_test.c
index b18e493c267..85f490cb02e 100644
--- a/tests/ssl_test.c
+++ b/tests/ssl_test.c
@@ -51,6 +51,7 @@ int main(int argc, char **argv)
perror("");
exit(1);
}
+ mysql.reconnect= 1;
count = 0;
num = atoi(argv[2]);
while (count < num)
diff --git a/tests/thread_test.c b/tests/thread_test.c
index 06f335fe1a6..f8577857d0a 100644
--- a/tests/thread_test.c
+++ b/tests/thread_test.c
@@ -55,6 +55,7 @@ unsigned __stdcall test_thread(void *arg __attribute__((unused)))
perror("");
goto end;
}
+ mysql.reconnect= 1;
if (verbose) { putchar('*'); fflush(stdout); }
for (count=0 ; count < number_of_tests ; count++)
{
diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c
index bb0a76d6c49..1be0242c505 100644
--- a/tools/mysqlmanager.c
+++ b/tools/mysqlmanager.c
@@ -877,7 +877,10 @@ static void manager_exec_connect(struct manager_exec* e)
{
if (mysql_real_connect(&e->mysql,e->con_host,e->con_user,e->con_pass,0,
e->con_port,e->con_sock,0))
+ {
+ e->mysql.reconnect= 1;
return;
+ }
sleep(1);
}
e->error="Could not connect to MySQL server withing the number of tries";