diff options
author | venu@myvenu.com <> | 2003-01-23 22:32:39 -0800 |
---|---|---|
committer | venu@myvenu.com <> | 2003-01-23 22:32:39 -0800 |
commit | 04f16d9f6fe2d15d449711b643911425fc770362 (patch) | |
tree | 3770332cd8ad21a18d63fc12c201a57de514def2 /sql/sql_prepare.cc | |
parent | d62ef3a0d91f3f5ae66a0fce08a5209b5c3bcdb3 (diff) | |
download | mariadb-git-04f16d9f6fe2d15d449711b643911425fc770362.tar.gz |
MYSQL_TIME handling(Direct DATE,TIME and TS th' structure) - server
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r-- | sql/sql_prepare.cc | 93 |
1 files changed, 91 insertions, 2 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index e8ba7e91c7b..758054a6e48 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -256,11 +256,87 @@ static void setup_param_double(Item_param *param, uchar **pos) *pos+= 8; } +static void setup_param_time(Item_param *param, uchar **pos) +{ + ulong length; + + if ((length= get_param_length(pos))) + { + uchar *to= *pos; + TIME tm; + + tm.second_part= (length > 8 ) ? (ulong) sint4korr(to+7): 0; + + tm.day= (ulong) sint4korr(to+1); + tm.hour= (uint) to[5]; + tm.minute= (uint) to[6]; + tm.second= (uint) to[7]; + + tm.year= tm.month= 0; + tm.neg= (bool)to[0]; + + param->set_time(&tm, TIMESTAMP_TIME); + } + *pos+= length; +} + +static void setup_param_datetime(Item_param *param, uchar **pos) +{ + uint length= get_param_length(pos); + + if (length) + { + uchar *to= *pos; + TIME tm; + + tm.second_part= (length > 7 ) ? (ulong) sint4korr(to+7): 0; + + if (length > 4) + { + tm.hour= (uint) to[4]; + tm.minute= (uint) to[5]; + tm.second= (uint) to[6]; + } + else + tm.hour= tm.minute= tm.second= 0; + + tm.year= (uint) sint2korr(to); + tm.month= (uint) to[2]; + tm.day= (uint) to[3]; + tm.neg= 0; + + param->set_time(&tm, TIMESTAMP_FULL); + } + *pos+= length; +} + +static void setup_param_date(Item_param *param, uchar **pos) +{ + ulong length; + + if ((length= get_param_length(pos))) + { + uchar *to= *pos; + TIME tm; + + tm.year = (uint) sint2korr(to); + tm.month= (uint) to[2]; + tm.day= (uint) to[3]; + + tm.hour= tm.minute= tm.second= 0; + tm.second_part= 0; + tm.neg= 0; + + param->set_time(&tm, TIMESTAMP_DATE); + } + *pos+= length; +} + static void setup_param_str(Item_param *param, uchar **pos) { - ulong len=get_param_length(pos); + ulong len= get_param_length(pos); param->set_value((const char *)*pos, len); - *pos+=len; + *pos+= len; } static void setup_param_functions(Item_param *param, uchar param_type) @@ -290,6 +366,19 @@ static void setup_param_functions(Item_param *param, uchar param_type) param->setup_param_func= setup_param_double; param->item_result_type = REAL_RESULT; break; + case FIELD_TYPE_TIME: + param->setup_param_func= setup_param_time; + param->item_result_type = STRING_RESULT; + break; + case FIELD_TYPE_DATE: + param->setup_param_func= setup_param_date; + param->item_result_type = STRING_RESULT; + break; + case FIELD_TYPE_DATETIME: + case FIELD_TYPE_TIMESTAMP: + param->setup_param_func= setup_param_datetime; + param->item_result_type = STRING_RESULT; + break; default: param->setup_param_func= setup_param_str; param->item_result_type = STRING_RESULT; |