diff options
Diffstat (limited to 'sql-common')
-rw-r--r-- | sql-common/client.c | 38 | ||||
-rw-r--r-- | sql-common/my_time.c | 27 |
2 files changed, 35 insertions, 30 deletions
diff --git a/sql-common/client.c b/sql-common/client.c index 3342db4bcfe..2c09498d8f4 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -70,11 +70,6 @@ my_bool net_flush(NET *net); #include <my_pthread.h> /* because of signal() */ #endif /* defined(THREAD) && !defined(__WIN__) */ -#if defined(OS2) && defined(MYSQL_SERVER) -#undef ER -#define ER CER -#endif /* defined( OS2) && defined(MYSQL_SERVER) */ - #include <sys/stat.h> #include <signal.h> #include <time.h> @@ -125,7 +120,7 @@ const char *def_shared_memory_base_name= default_shared_memory_base_name; static void mysql_close_free_options(MYSQL *mysql); static void mysql_close_free(MYSQL *mysql); -#if !(defined(__WIN__) || defined(OS2) || defined(__NETWARE__)) +#if !(defined(__WIN__) || defined(__NETWARE__)) static int wait_for_data(my_socket fd, uint timeout); #endif @@ -144,7 +139,7 @@ CHARSET_INFO *default_client_charset_info = &my_charset_latin1; int my_connect(my_socket fd, const struct sockaddr *name, uint namelen, uint timeout) { -#if defined(__WIN__) || defined(OS2) || defined(__NETWARE__) +#if defined(__WIN__) || defined(__NETWARE__) return connect(fd, (struct sockaddr*) name, namelen); #else int flags, res, s_err; @@ -184,7 +179,7 @@ int my_connect(my_socket fd, const struct sockaddr *name, uint namelen, If not, we will use select() */ -#if !(defined(__WIN__) || defined(OS2) || defined(__NETWARE__)) +#if !(defined(__WIN__) || defined(__NETWARE__)) static int wait_for_data(my_socket fd, uint timeout) { @@ -275,7 +270,7 @@ static int wait_for_data(my_socket fd, uint timeout) return (0); /* ok */ #endif /* HAVE_POLL */ } -#endif /* defined(__WIN__) || defined(OS2) || defined(__NETWARE__) */ +#endif /* defined(__WIN__) || defined(__NETWARE__) */ /* @@ -686,7 +681,12 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command, mysql->net.report_error=0; mysql->info=0; mysql->affected_rows= ~(my_ulonglong) 0; - net_clear(&mysql->net); /* Clear receive buffer */ + /* + We don't want to clear the protocol buffer on COM_QUIT, because if + the previous command was a shutdown command, we may have the + response for the COM_QUIT already in the communication buffer + */ + net_clear(&mysql->net, (command != COM_QUIT)); if (net_write_command(net,(uchar) command, header, header_length, arg, arg_length)) @@ -2507,7 +2507,7 @@ my_bool mysql_reconnect(MYSQL *mysql) mysql_close(mysql); *mysql=tmp_mysql; mysql_fix_pointers(mysql, &tmp_mysql); /* adjust connection pointers */ - net_clear(&mysql->net); + net_clear(&mysql->net, 1); mysql->affected_rows= ~(my_ulonglong) 0; DBUG_RETURN(0); } @@ -2596,24 +2596,32 @@ static void mysql_close_free(MYSQL *mysql) SYNOPSYS mysql_detach_stmt_list() stmt_list pointer to mysql->stmts + func_name name of calling function NOTE There is similar code in mysql_reconnect(), so changes here should also be reflected there. */ -void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused))) +void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused)), + const char *func_name __attribute__((unused))) { #ifdef MYSQL_CLIENT /* Reset connection handle in all prepared statements. */ LIST *element= *stmt_list; + char buff[MYSQL_ERRMSG_SIZE]; + DBUG_ENTER("mysql_detach_stmt_list"); + + my_snprintf(buff, sizeof(buff)-1, ER(CR_STMT_CLOSED), func_name); for (; element; element= element->next) { MYSQL_STMT *stmt= (MYSQL_STMT *) element->data; + set_stmt_errmsg(stmt, buff, CR_STMT_CLOSED, unknown_sqlstate); stmt->mysql= 0; /* No need to call list_delete for statement here */ } *stmt_list= 0; + DBUG_VOID_RETURN; #endif /* MYSQL_CLIENT */ } @@ -2634,7 +2642,7 @@ void STDCALL mysql_close(MYSQL *mysql) } mysql_close_free_options(mysql); mysql_close_free(mysql); - mysql_detach_stmt_list(&mysql->stmts); + mysql_detach_stmt_list(&mysql->stmts, "mysql_close"); #ifndef TO_BE_DELETED /* free/close slave list */ if (mysql->rpl_pivot) @@ -2820,6 +2828,7 @@ MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql) result->field_count= mysql->field_count; /* The rest of result members is bzeroed in malloc */ mysql->fields=0; /* fields is now in result */ + clear_alloc_root(&mysql->field_alloc); /* just in case this was mistakenly called after mysql_stmt_execute() */ mysql->unbuffered_fetch_owner= 0; DBUG_RETURN(result); /* Data fetched */ @@ -2869,6 +2878,7 @@ static MYSQL_RES * cli_use_result(MYSQL *mysql) result->handle= mysql; result->current_row= 0; mysql->fields=0; /* fields is now in result */ + clear_alloc_root(&mysql->field_alloc); mysql->status=MYSQL_STATUS_USE_RESULT; mysql->unbuffered_fetch_owner= &result->unbuffered_fetch_cancelled; DBUG_RETURN(result); /* Data is read to be fetched */ @@ -2948,7 +2958,7 @@ mysql_fetch_lengths(MYSQL_RES *res) int STDCALL -mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) +mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg) { DBUG_ENTER("mysql_option"); DBUG_PRINT("enter",("option: %d",(int) option)); diff --git a/sql-common/my_time.c b/sql-common/my_time.c index f5d5828e024..7c8719bc9e0 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -453,7 +453,7 @@ err: /* - Convert a time string to a TIME struct. + Convert a time string to a MYSQL_TIME struct. SYNOPSIS str_to_time() @@ -639,11 +639,11 @@ fractional: l_time->second_part= date[4]; l_time->time_type= MYSQL_TIMESTAMP_TIME; - /* Check if the value is valid and fits into TIME range */ + /* Check if the value is valid and fits into MYSQL_TIME range */ if (check_time_range(l_time, warning)) return 1; - /* Check if there is garbage at end of the TIME specification */ + /* Check if there is garbage at end of the MYSQL_TIME specification */ if (str != end) { do @@ -660,11 +660,11 @@ fractional: /* - Check 'time' value to lie in the TIME range + Check 'time' value to lie in the MYSQL_TIME range SYNOPSIS: check_time_range() - time pointer to TIME value + time pointer to MYSQL_TIME value warning set MYSQL_TIME_WARN_OUT_OF_RANGE flag if the value is out of range DESCRIPTION @@ -769,11 +769,6 @@ long calc_daynr(uint year,uint month,uint day) if (year == 0 && month == 0 && day == 0) DBUG_RETURN(0); /* Skip errors */ - if (year < 200) - { - if ((year=year+1900) < 1900+YY_PART_YEAR) - year+=100; - } delsum= (long) (365L * year+ 31*(month-1) +day); if (month <= 2) year--; @@ -1010,7 +1005,7 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type) /* Functions to convert time/date/datetime value to a string, using default format. - This functions don't check that given TIME structure members are + This functions don't check that given MYSQL_TIME structure members are in valid range. If they are not, return value won't reflect any valid date either. Additionally, make_time doesn't take into account time->day member: it's assumed that days have been converted @@ -1096,7 +1091,7 @@ int my_TIME_to_str(const MYSQL_TIME *l_time, char *to) DESCRIPTION Convert a datetime value of formats YYMMDD, YYYYMMDD, YYMMDDHHMSS, - YYYYMMDDHHMMSS to broken-down TIME representation. Return value in + YYYYMMDDHHMMSS to broken-down MYSQL_TIME representation. Return value in YYYYMMDDHHMMSS format as side-effect. This function also checks if datetime value fits in DATETIME range. @@ -1189,7 +1184,7 @@ ulonglong TIME_to_ulonglong_datetime(const MYSQL_TIME *my_time) } -/* Convert TIME value to integer in YYYYMMDD format */ +/* Convert MYSQL_TIME value to integer in YYYYMMDD format */ ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *my_time) { @@ -1199,7 +1194,7 @@ ulonglong TIME_to_ulonglong_date(const MYSQL_TIME *my_time) /* - Convert TIME value to integer in HHMMSS format. + Convert MYSQL_TIME value to integer in HHMMSS format. This function doesn't take into account time->day member: it's assumed that days have been converted to hours already. */ @@ -1213,7 +1208,7 @@ ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *my_time) /* - Convert struct TIME (date and time split into year/month/day/hour/... + Convert struct MYSQL_TIME (date and time split into year/month/day/hour/... to a number in format YYYYMMDDHHMMSS (DATETIME), YYYYMMDD (DATE) or HHMMSS (TIME). @@ -1227,7 +1222,7 @@ ulonglong TIME_to_ulonglong_time(const MYSQL_TIME *my_time) SELECT ?+1; NOTE - This function doesn't check that given TIME structure members are + This function doesn't check that given MYSQL_TIME structure members are in valid range. If they are not, return value won't reflect any valid date either. */ |