1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Fix for Bug#4030 "Client side conversion string -> date type doesn't

work (prepared statements)" and after-review fixes:
- str_to_TIME renamed to str_to_datetime to pair with str_to_time
- functions str_to_time and str_to_TIME moved to sql-common
- send_data_str now supports MYSQL_TYPE_TIME, MYSQL_TIME_DATE,
  MYSQL_TIME_DATETIME types of user input buffers.
- few more comments in the client library
- a test case added.
This commit is contained in:
konstantin@mysql.com
2004-06-24 19:08:36 +04:00
parent 3bcbdcb406
commit a30fcdc690
25 changed files with 386 additions and 770 deletions

View File

@ -361,7 +361,7 @@ static void set_param_time(Item_param *param, uchar **pos, ulong len)
}
tm.day= tm.year= tm.month= 0;
param->set_time(&tm, TIMESTAMP_TIME,
param->set_time(&tm, MYSQL_TIMESTAMP_TIME,
MAX_TIME_WIDTH * MY_CHARSET_BIN_MB_MAXLEN);
}
*pos+= length;
@ -396,7 +396,7 @@ static void set_param_datetime(Item_param *param, uchar **pos, ulong len)
tm.second_part= (length > 7) ? (ulong) sint4korr(to+7) : 0;
param->set_time(&tm, TIMESTAMP_DATETIME,
param->set_time(&tm, MYSQL_TIMESTAMP_DATETIME,
MAX_DATETIME_WIDTH * MY_CHARSET_BIN_MB_MAXLEN);
}
*pos+= length;
@ -423,7 +423,7 @@ static void set_param_date(Item_param *param, uchar **pos, ulong len)
tm.second_part= 0;
tm.neg= 0;
param->set_time(&tm, TIMESTAMP_DATE,
param->set_time(&tm, MYSQL_TIMESTAMP_DATE,
MAX_DATE_WIDTH * MY_CHARSET_BIN_MB_MAXLEN);
}
*pos+= length;
@ -432,58 +432,25 @@ static void set_param_date(Item_param *param, uchar **pos, ulong len)
#else/*!EMBEDDED_LIBRARY*/
void set_param_time(Item_param *param, uchar **pos, ulong len)
{
TIME tm;
MYSQL_TIME *to= (MYSQL_TIME*)*pos;
tm.second_part= to->second_part;
tm.day= to->day;
tm.hour= to->hour;
tm.minute= to->minute;
tm.second= to->second;
tm.year= tm.month= 0;
tm.neg= to->neg;
param->set_time(&tm, TIMESTAMP_TIME,
param->set_time(to, MYSQL_TIMESTAMP_TIME,
MAX_TIME_WIDTH * MY_CHARSET_BIN_MB_MAXLEN);
}
void set_param_datetime(Item_param *param, uchar **pos, ulong len)
{
TIME tm;
MYSQL_TIME *to= (MYSQL_TIME*)*pos;
tm.second_part= to->second_part;
tm.day= to->day;
tm.hour= to->hour;
tm.minute= to->minute;
tm.second= to->second;
tm.year= to->year;
tm.month= to->month;
tm.neg= 0;
param->set_time(&tm, TIMESTAMP_DATETIME,
param->set_time(to, MYSQL_TIMESTAMP_DATETIME,
MAX_DATETIME_WIDTH * MY_CHARSET_BIN_MB_MAXLEN);
}
void set_param_date(Item_param *param, uchar **pos, ulong len)
{
TIME tm;
MYSQL_TIME *to= (MYSQL_TIME*)*pos;
tm.second_part= to->second_part;
tm.day= to->day;
tm.year= to->year;
tm.month= to->month;
tm.neg= 0;
tm.hour= tm.minute= tm.second= 0;
tm.second_part= 0;
tm.neg= 0;
param->set_time(&tm, TIMESTAMP_DATE,
param->set_time(to, MYSQL_TIMESTAMP_DATE,
MAX_DATE_WIDTH * MY_CHARSET_BIN_MB_MAXLEN);
}
#endif /*!EMBEDDED_LIBRARY*/