mysql_init卡住_mysql_init调用卡住原因分析

/****************************************************************************

Init MySQL structure or allocate one

****************************************************************************/

MYSQL * STDCALL

mysql_init(MYSQL *mysql)

{

if (mysql_server_init(0, NULL, NULL))

return 0;

if (!mysql)

{

if (!(mysql=(MYSQL*) my_malloc(sizeof(*mysql),MYF(MY_WME | MY_ZEROFILL))))

{

set_mysql_error(NULL, CR_OUT_OF_MEMORY, unknown_sqlstate);

return 0;

}

mysql->free_me=1;

}

else

memset(mysql, 0, sizeof(*(mysql)));

mysql->charset=default_client_charset_info;

strmov(mysql->net.sqlstate, not_error_sqlstate);

/*

Only enable LOAD DATA INFILE by default if configured with

--enable-local-infile

*/

#if defined(ENABLED_LOCAL_INFILE) && !defined(MYSQL_SERVER)

mysql->options.client_flag|= CLIENT_LOCAL_FILES;

#endif

#ifdef HAVE_SMEM

mysql->options.shared_memory_base_name= (char*) def_shared_memory_base_name;

#endif

mysql->options.methods_to_use= MYSQL_OPT_GUESS_CONNECTION;

mysql->options.report_data_truncation= TRUE;  /* default */

/*

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: 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->options.secure_auth= TRUE;

return mysql;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值