diff options
author | mronstrom@mysql.com <> | 2004-09-02 19:29:11 +0200 |
---|---|---|
committer | mronstrom@mysql.com <> | 2004-09-02 19:29:11 +0200 |
commit | 5bd4d59508909facecda6cdb160264a4aca51d37 (patch) | |
tree | ca210db1e140029732f55128efd8685635c249d9 /sql | |
parent | 99f9ff912f425216372fa9eb5217c67d97f9297b (diff) | |
parent | 290443298a969cbd28ba1b26cd8f7927e634ab0b (diff) | |
download | mariadb-git-5bd4d59508909facecda6cdb160264a4aca51d37.tar.gz |
Merge mronstrom@bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/Users/mikron/mysql-4.1
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_prepare.cc | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 708ca3a516f..25b6434c184 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -329,15 +329,22 @@ static void set_param_double(Item_param *param, uchar **pos, ulong len) } #ifndef EMBEDDED_LIBRARY + +/* + Read date/time/datetime parameter values from network (binary + protocol). See writing counterparts of these functions in + libmysql.c (store_param_{time,date,datetime}). +*/ + static void set_param_time(Item_param *param, uchar **pos, ulong len) { - ulong length; - uint day; + MYSQL_TIME tm; + ulong length= get_param_length(pos, len); - if ((length= get_param_length(pos, len)) >= 8) + if (length >= 8) { uchar *to= *pos; - TIME tm; + uint day; tm.neg= (bool) to[0]; day= (uint) sint4korr(to+1); @@ -359,21 +366,22 @@ static void set_param_time(Item_param *param, uchar **pos, ulong len) tm.second= 59; } tm.day= tm.year= tm.month= 0; - - param->set_time(&tm, MYSQL_TIMESTAMP_TIME, - MAX_TIME_WIDTH * MY_CHARSET_BIN_MB_MAXLEN); } + else + set_zero_time(&tm); + param->set_time(&tm, MYSQL_TIMESTAMP_TIME, + MAX_TIME_WIDTH * MY_CHARSET_BIN_MB_MAXLEN); *pos+= length; } static void set_param_datetime(Item_param *param, uchar **pos, ulong len) { - uint length; + MYSQL_TIME tm; + ulong length= get_param_length(pos, len); - if ((length= get_param_length(pos, len)) >= 4) + if (length >= 4) { uchar *to= *pos; - TIME tm; tm.neg= 0; tm.year= (uint) sint2korr(to); @@ -394,21 +402,22 @@ static void set_param_datetime(Item_param *param, uchar **pos, ulong len) tm.hour= tm.minute= tm.second= 0; tm.second_part= (length > 7) ? (ulong) sint4korr(to+7) : 0; - - param->set_time(&tm, MYSQL_TIMESTAMP_DATETIME, - MAX_DATETIME_WIDTH * MY_CHARSET_BIN_MB_MAXLEN); } + else + set_zero_time(&tm); + param->set_time(&tm, MYSQL_TIMESTAMP_DATETIME, + MAX_DATETIME_WIDTH * MY_CHARSET_BIN_MB_MAXLEN); *pos+= length; } static void set_param_date(Item_param *param, uchar **pos, ulong len) { - ulong length; - - if ((length= get_param_length(pos, len)) >= 4) + MYSQL_TIME tm; + ulong length= get_param_length(pos, len); + + if (length >= 4) { uchar *to= *pos; - TIME tm; /* Note, that though ranges of hour, minute and second are not checked here we rely on them being < 256: otherwise @@ -421,10 +430,11 @@ static void set_param_date(Item_param *param, uchar **pos, ulong len) tm.hour= tm.minute= tm.second= 0; tm.second_part= 0; tm.neg= 0; - - param->set_time(&tm, MYSQL_TIMESTAMP_DATE, - MAX_DATE_WIDTH * MY_CHARSET_BIN_MB_MAXLEN); } + else + set_zero_time(&tm); + param->set_time(&tm, MYSQL_TIMESTAMP_DATE, + MAX_DATE_WIDTH * MY_CHARSET_BIN_MB_MAXLEN); *pos+= length; } |