X-Git-Url: https://git.sven.stormbind.net/?p=sven%2Fmysqltcl.git;a=blobdiff_plain;f=generic%2Fmysqltcl.c;h=53195b9a4d942acae134e5f7d07ebc1833ec9767;hp=cd79a07c3d9638c00dd09539d151da022c61156f;hb=ef0160440ef423857ed8496d6384f24e5130822f;hpb=8b83892bf9d924349d5e09c88f16790a8086a950 diff --git a/generic/mysqltcl.c b/generic/mysqltcl.c index cd79a07..53195b9 100755 --- a/generic/mysqltcl.c +++ b/generic/mysqltcl.c @@ -36,7 +36,7 @@ #ifdef _WINDOWS #include #define PACKAGE "mysqltcl" - #define PACKAGE_VERSION "3.04" + #define PACKAGE_VERSION "3.052" #endif #include @@ -728,13 +728,14 @@ static CONST char* MysqlConnectOpt[] = "-multistatement","-multiresult", #endif "-localfiles","-ignorespace","-foundrows","-interactive","-sslkey","-sslcert", - "-sslca","-sslcapath","-sslciphers",NULL + "-sslca","-sslcapath","-sslciphers","-reconnect", NULL }; static int Mysqltcl_Connect(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { MysqltclState *statePtr = (MysqltclState *)clientData; int i, idx; + int mysql_options_reconnect = 0; char *hostname = NULL; char *user = NULL; char *password = NULL; @@ -765,12 +766,12 @@ static int Mysqltcl_Connect(ClientData clientData, Tcl_Interp *interp, int objc, #endif MYSQL_LOCALFILES_OPT,MYSQL_IGNORESPACE_OPT, MYSQL_FOUNDROWS_OPT,MYSQL_INTERACTIVE_OPT,MYSQL_SSLKEY_OPT,MYSQL_SSLCERT_OPT, - MYSQL_SSLCA_OPT,MYSQL_SSLCAPATH_OPT,MYSQL_SSLCIPHERS_OPT + MYSQL_SSLCA_OPT,MYSQL_SSLCAPATH_OPT,MYSQL_SSLCIPHERS_OPT, MYSQL_RECONNECT_OPT }; if (!(objc & 1) || objc>(sizeof(MysqlConnectOpt)/sizeof(MysqlConnectOpt[0]-1)*2+1)) { - Tcl_WrongNumArgs(interp, 1, objv, "[-user xxx] [-db mysql] [-port 3306] [-host localhost] [-socket sock] [-password pass] [-encoding encoding] [-ssl boolean] [-compress boolean] [-odbc boolean] [-noschema boolean]" + Tcl_WrongNumArgs(interp, 1, objv, "[-user xxx] [-db mysql] [-port 3306] [-host localhost] [-socket sock] [-password pass] [-encoding encoding] [-ssl boolean] [-compress boolean] [-odbc boolean] [-noschema boolean] [-reconnect boolean]" ); return TCL_ERROR; } @@ -885,6 +886,12 @@ static int Mysqltcl_Connect(ClientData clientData, Tcl_Interp *interp, int objc, case MYSQL_SSLCIPHERS_OPT: sslcipher = Tcl_GetStringFromObj(objv[++i],NULL); break; + case MYSQL_RECONNECT_OPT: + if (Tcl_GetBooleanFromObj(interp,objv[++i],&booleanflag) != TCL_OK ) + return TCL_ERROR; + if (booleanflag) + mysql_options_reconnect = 1; + break; default: return mysql_prim_confl(interp,objc,objv,"Weirdness in options"); } @@ -902,6 +909,11 @@ static int Mysqltcl_Connect(ClientData clientData, Tcl_Interp *interp, int objc, /* the function below caused in version pre 3.23.50 segmentation fault */ #if (MYSQL_VERSION_ID>=32350) + if(mysql_options_reconnect) + { + my_bool reconnect = 1; + mysql_options(handle->connection, MYSQL_OPT_RECONNECT, &reconnect); + } mysql_options(handle->connection,MYSQL_READ_DEFAULT_GROUP,groupname); #endif #if (MYSQL_VERSION_ID >= 40107) @@ -2151,6 +2163,7 @@ static int Mysqltcl_NextResult(ClientData clientData, Tcl_Interp *interp, int ob return mysql_server_confl(interp,objc,objv,handle->connection); } handle->result = mysql_store_result(handle->connection); + handle->col_count = mysql_num_fields(handle->result); if (handle->result == NULL) { Tcl_SetObjResult(interp, Tcl_NewIntObj(-1)); } else { @@ -2245,7 +2258,7 @@ static int Mysqltcl_NewNull(ClientData clientData, Tcl_Interp *interp, int objc, #if (MYSQL_VERSION_ID >= 40107) static CONST char* MysqlServerOpt[] = { - "-multi_statment_on", "-multi_statment_off",NULL + "-multi_statment_on", "-multi_statment_off", "-auto_reconnect_on", "-auto_reconnect_off", NULL }; #endif @@ -2755,3 +2768,4 @@ int Mysqltcl_SafeInit(interp) { return Mysqltcl_Init(interp); } +