diff options
author | Mikael Ronstrom <mikael@mysql.com> | 2009-09-28 09:39:50 +0200 |
---|---|---|
committer | Mikael Ronstrom <mikael@mysql.com> | 2009-09-28 09:39:50 +0200 |
commit | ccae404afaddf98c16889fdd21c613b551ee5e5e (patch) | |
tree | f7dc27f11e200c4a174df0a91afb7bbd83e5dcc5 /sql-common | |
parent | ec5b25954376265d187c57984d0416c50d0a1694 (diff) | |
parent | a8edd0aabb5059935b99076fbcc92403079535df (diff) | |
download | mariadb-git-ccae404afaddf98c16889fdd21c613b551ee5e5e.tar.gz |
Merge to mysql-next-mr
Diffstat (limited to 'sql-common')
-rw-r--r-- | sql-common/client.c | 12 | ||||
-rw-r--r-- | sql-common/my_time.c | 12 |
2 files changed, 15 insertions, 9 deletions
diff --git a/sql-common/client.c b/sql-common/client.c index 5a9ea84b498..84029b449af 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -482,6 +482,15 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout) int i; /* + If this is NULL, somebody freed the MYSQL* options. mysql_close() + is a good candidate. We don't just silently (re)set it to + def_shared_memory_base_name as that would create really confusing/buggy + behavior if the user passed in a different name on the command-line or + in a my.cnf. + */ + DBUG_ASSERT(shared_memory_base_name != NULL); + + /* get enough space base-name + '_' + longest suffix we might ever send */ if (!(tmp= (char *)my_malloc(strlen(shared_memory_base_name) + 32L, MYF(MY_FAE)))) @@ -1849,7 +1858,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, uint port, const char *unix_socket,ulong client_flag) { char buff[NAME_LEN+USERNAME_LENGTH+100]; - char *end,*host_info; + char *end,*host_info= NULL; my_socket sock; in_addr_t ip_addr; struct sockaddr_in sock_addr; @@ -1867,7 +1876,6 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, #endif init_sigpipe_variables DBUG_ENTER("mysql_real_connect"); - LINT_INIT(host_info); DBUG_PRINT("enter",("host: %s db: %s user: %s", host ? host : "(Null)", diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 747c5797ed4..2ec1fc253a7 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -160,7 +160,7 @@ enum enum_mysql_timestamp_type str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, uint flags, int *was_cut) { - uint field_length, year_length, digits, i, number_of_fields; + uint field_length, UNINIT_VAR(year_length), digits, i, number_of_fields; uint date[MAX_DATE_PARTS], date_len[MAX_DATE_PARTS]; uint add_hours= 0, start_loop; ulong not_zero_date, allow_space; @@ -174,7 +174,6 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, DBUG_PRINT("ENTER",("str: %.*s",length,str)); LINT_INIT(field_length); - LINT_INIT(year_length); LINT_INIT(last_field_pos); *was_cut= 0; @@ -450,9 +449,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, } } - DBUG_RETURN(l_time->time_type= - (number_of_fields <= 3 ? MYSQL_TIMESTAMP_DATE : - MYSQL_TIMESTAMP_DATETIME)); + DBUG_RETURN(l_time->time_type); err: bzero((char*) l_time, sizeof(*l_time)); @@ -778,11 +775,12 @@ long calc_daynr(uint year,uint month,uint day) if (y == 0 && month == 0 && day == 0) DBUG_RETURN(0); /* Skip errors */ - delsum= (long) (365L * y+ 31*(month-1) +day); + /* Cast to int to be able to handle month == 0 */ + delsum= (long) (365 * y + 31 *((int) month - 1) + (int) day); if (month <= 2) y--; else - delsum-= (long) (month*4+23)/10; + delsum-= (long) ((int) month * 4 + 23) / 10; temp=(int) ((y/100+1)*3)/4; DBUG_PRINT("exit",("year: %d month: %d day: %d -> daynr: %ld", y+(month <= 2),month,day,delsum+y/4-temp)); |