diff options
Diffstat (limited to 'sql-common/client.c')
-rw-r--r-- | sql-common/client.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/sql-common/client.c b/sql-common/client.c index 87a781e0a0d..0ff98102da9 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -57,7 +57,7 @@ my_bool net_flush(NET *net); #else /*EMBEDDED_LIBRARY*/ -#define CLI_MYSQL_REAL_CONNECT mysql_real_connect +#define CLI_MYSQL_REAL_CONNECT STDCALL mysql_real_connect #endif /*EMBEDDED_LIBRARY*/ #include <my_sys.h> #include <mysys_err.h> @@ -98,9 +98,6 @@ my_bool net_flush(NET *net); # include <sys/un.h> #endif -#ifndef INADDR_NONE -#define INADDR_NONE -1 -#endif #if defined(MSDOS) || defined(__WIN__) #define perror(A) #else @@ -657,6 +654,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command, } if (mysql->status != MYSQL_STATUS_READY) { + DBUG_PRINT("error",("state: %d", mysql->status)); set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); return 1; } @@ -883,6 +881,7 @@ static const char *default_options[]= "replication-probe", "enable-reads-from-master", "repl-parse-query", "ssl-cipher", "max-allowed-packet", "protocol", "shared-memory-base-name", "multi-results", "multi-queries", "secure-auth", + "report-data-truncation", NullS }; @@ -1093,6 +1092,9 @@ void mysql_read_default_options(struct st_mysql_options *options, case 32: /* secure-auth */ options->secure_auth= TRUE; break; + case 33: /* report-data-truncation */ + options->report_data_truncation= opt_arg ? test(atoi(opt_arg)) : 1; + break; default: DBUG_PRINT("warning",("unknown option: %s",option[0])); } @@ -1436,6 +1438,7 @@ mysql_init(MYSQL *mysql) #endif mysql->options.methods_to_use= MYSQL_OPT_GUESS_CONNECTION; + mysql->options.report_data_truncation= TRUE; /* default */ return mysql; } @@ -1521,7 +1524,8 @@ static MYSQL_METHODS client_methods= #endif }; -MYSQL * STDCALL + +MYSQL * CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, const char *passwd, const char *db, uint port, const char *unix_socket,ulong client_flag) @@ -1543,7 +1547,6 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, #ifdef HAVE_SYS_UN_H struct sockaddr_un UNIXaddr; #endif - init_sigpipe_variables DBUG_ENTER("mysql_real_connect"); LINT_INIT(host_info); @@ -1596,8 +1599,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; /* @@ -2170,6 +2189,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)); @@ -2658,6 +2678,9 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) case MYSQL_SECURE_AUTH: mysql->options.secure_auth= *(my_bool *) arg; break; + case MYSQL_REPORT_DATA_TRUNCATION: + mysql->options.report_data_truncation= test(*(my_bool *) arg); + break; default: DBUG_RETURN(1); } |