summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc42
1 files changed, 26 insertions, 16 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 07f521abf3e..df6c2a80424 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -2412,8 +2412,7 @@ String *Field_timestamp::val_str(String *val_buffer,
return val_buffer;
}
-bool Field_timestamp::get_date(TIME *ltime,
- bool fuzzydate __attribute__((unused)))
+bool Field_timestamp::get_date(TIME *ltime, bool fuzzydate)
{
long temp;
#ifdef WORDS_BIGENDIAN
@@ -2424,6 +2423,8 @@ bool Field_timestamp::get_date(TIME *ltime,
longget(temp,ptr);
if (temp == 0L)
{ /* Zero time is "000000" */
+ if (!fuzzydate)
+ return 1;
bzero((char*) ltime,sizeof(*ltime));
}
else
@@ -2447,8 +2448,7 @@ bool Field_timestamp::get_date(TIME *ltime,
bool Field_timestamp::get_time(TIME *ltime)
{
- Field_timestamp::get_date(ltime,0);
- return 0;
+ return Field_timestamp::get_date(ltime,0);
}
int Field_timestamp::cmp(const char *a_ptr, const char *b_ptr)
@@ -3029,13 +3029,12 @@ bool Field_newdate::get_date(TIME *ltime,bool fuzzydate)
ltime->month= (tmp >> 5) & 15;
ltime->year= (tmp >> 9);
ltime->time_type=TIMESTAMP_DATE;
- return (!fuzzydate && (!ltime->month || !ltime->day) && ltime->year) ? 1 : 0;
+ return (!fuzzydate && (!ltime->month || !ltime->day)) ? 1 : 0;
}
bool Field_newdate::get_time(TIME *ltime)
{
- Field_newdate::get_date(ltime,0);
- return 0;
+ return Field_newdate::get_date(ltime,0);
}
int Field_newdate::cmp(const char *a_ptr, const char *b_ptr)
@@ -3214,13 +3213,12 @@ bool Field_datetime::get_date(TIME *ltime,bool fuzzydate)
ltime->day= part1%100;
ltime->month= part1/100%100;
ltime->year= part1/10000;
- return (!fuzzydate && (!ltime->month || !ltime->day) && ltime->year) ? 1 : 0;
+ return (!fuzzydate && (!ltime->month || !ltime->day)) ? 1 : 0;
}
bool Field_datetime::get_time(TIME *ltime)
{
- Field_datetime::get_date(ltime,0);
- return 0;
+ return Field_datetime::get_date(ltime,0);
}
int Field_datetime::cmp(const char *a_ptr, const char *b_ptr)
@@ -3468,9 +3466,9 @@ int Field_string::pack_cmp(const char *b, uint length)
}
-uint Field_string::packed_col_length(const char *ptr)
+uint Field_string::packed_col_length(const char *ptr, uint length)
{
- if (field_length > 255)
+ if (length > 255)
return uint2korr(ptr)+2;
else
return (uint) ((uchar) *ptr)+1;
@@ -3478,7 +3476,7 @@ uint Field_string::packed_col_length(const char *ptr)
uint Field_string::max_packed_col_length(uint max_length)
{
- return (field_length > 255 ? 2 : 1)+max_length;
+ return (max_length > 255 ? 2 : 1)+max_length;
}
@@ -3687,9 +3685,9 @@ int Field_varstring::pack_cmp(const char *b, uint key_length)
return my_sortncmp(a,a_length, b,b_length);
}
-uint Field_varstring::packed_col_length(const char *ptr)
+uint Field_varstring::packed_col_length(const char *ptr, uint length)
{
- if (field_length > 255)
+ if (length > 255)
return uint2korr(ptr)+2;
else
return (uint) ((uchar) *ptr)+1;
@@ -3697,7 +3695,7 @@ uint Field_varstring::packed_col_length(const char *ptr)
uint Field_varstring::max_packed_col_length(uint max_length)
{
- return (field_length > 255 ? 2 : 1)+max_length;
+ return (max_length > 255 ? 2 : 1)+max_length;
}
/****************************************************************************
@@ -4173,6 +4171,18 @@ char *Field_blob::pack_key_from_key_image(char *to, const char *from,
return to+length;
}
+uint Field_blob::packed_col_length(const char *ptr, uint length)
+{
+ if (length > 255)
+ return uint2korr(ptr)+2;
+ else
+ return (uint) ((uchar) *ptr)+1;
+}
+
+uint Field_blob::max_packed_col_length(uint max_length)
+{
+ return (max_length > 255 ? 2 : 1)+max_length;
+}
/****************************************************************************
** enum type.