Commit eac128ef authored by guilhem@mysql.com's avatar guilhem@mysql.com

Merge gbichot@bk-internal.mysql.com:/home/bk/mysql-5.0

into mysql.com:/home/mysql_src/mysql-5.0-clean
parents dafb2969 1cbc904c
......@@ -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 ) ;
......
......@@ -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 ;
......
......@@ -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));
......
......@@ -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;
}
}
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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 */
......
......@@ -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))
......
......@@ -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)
{
......
......@@ -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;
}
......
......@@ -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);
}
}
......
......@@ -109,6 +109,7 @@ bool __fastcall TForm1::connect_server()
ret_value = true;
is_server_started = true;
}
MySQL->reconnect= 1;
return ret_value;
}
//---------------------------------------------------------------------------
......
......@@ -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;
......
......@@ -80,6 +80,7 @@ BackupRestore::init()
ndbout_c("Connect failed: %s", mysql_error(&mysql));
returnValue = false;
}
mysql.reconnect= 1;
ndbout << "Connected to MySQL!!!" <<endl;
}
......
......@@ -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));
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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");
......@@ -1057,6 +1058,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));
......@@ -4481,6 +4483,7 @@ static void test_stmt_close()
myerror("connection failed");
exit(1);
}
lmysql->reconnect= 1;
if (!opt_silent)
fprintf(stdout, " OK");
......@@ -5372,6 +5375,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);
......@@ -5480,6 +5484,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);
......@@ -7012,6 +7017,7 @@ static void test_prepare_grant()
mysql_close(lmysql);
exit(1);
}
lmysql->reconnect= 1;
if (!opt_silent)
fprintf(stdout, " OK");
......@@ -7457,6 +7463,7 @@ static void test_drop_temp()
mysql_close(lmysql);
exit(1);
}
lmysql->reconnect= 1;
if (!opt_silent)
fprintf(stdout, " OK");
......
......@@ -46,6 +46,7 @@ int main(int argc, char **argv)
perror("");
exit(1);
}
sock->reconnect= 1;
if (mysql_select_db(sock,"test"))
{
......
......@@ -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);
......
......@@ -40,6 +40,7 @@ int main(int argc, char **argv)
perror("");
exit(1);
}
mysql.reconnect= 1;
num = atoi(argv[2]);
count = 0;
......
......@@ -43,6 +43,7 @@ int main(int argc, char **argv)
perror("");
exit(1);
}
mysql.reconnect= 1;
if (mysql_select_db(sock,argv[1]) < 0)
{
......
......@@ -44,6 +44,7 @@ int main(int argc, char **argv)
perror("");
exit(1);
}
mysql.reconnect= 1;
count = 0;
num = atoi(argv[2]);
......
......@@ -45,6 +45,7 @@ int main(int argc, char **argv)
perror("");
exit(1);
}
mysql.reconnect= 1;
count = 0;
num = atoi(argv[2]);
......
......@@ -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)
......
......@@ -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++)
{
......
......@@ -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";
......
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