summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <malff/marcsql@weblab.(none)>2007-06-11 10:49:26 -0600
committerunknown <malff/marcsql@weblab.(none)>2007-06-11 10:49:26 -0600
commit62c807a72d6a412bce2fa353ae4605854660e3ff (patch)
tree91e32b38a5e2fe7ebe5e09f88884ed02d7c1c231
parent97cf2694a133eb9b3fc8e81eea66964b2446b864 (diff)
parent0e958122e197f4d02cf07040e4cb24af460ab15e (diff)
downloadmariadb-git-62c807a72d6a412bce2fa353ae4605854660e3ff.tar.gz
Merge weblab.(none):/home/marcsql/TREE/mysql-5.0-runtime
into weblab.(none):/home/marcsql/TREE/mysql-5.1-rt-merge50 sql/item_timefunc.cc: Auto merged sql/unireg.h: Auto merged
-rw-r--r--sql/item_timefunc.cc32
-rw-r--r--sql/unireg.h1
2 files changed, 22 insertions, 11 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 3bc63eaf5f9..f6583fb3031 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -51,7 +51,7 @@ static bool make_datetime(date_time_format_types format, MYSQL_TIME *ltime,
{
char *buff;
CHARSET_INFO *cs= &my_charset_bin;
- uint length= 30;
+ uint length= MAX_DATE_STRING_REP_LENGTH;
if (str->alloc(length))
return 1;
@@ -1379,7 +1379,7 @@ String *Item_date::val_str(String *str)
MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE))
return (String *) 0;
- if (str->alloc(11))
+ if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
{
null_value= 1;
return (String *) 0;
@@ -1428,7 +1428,7 @@ void Item_func_curdate::fix_length_and_dec()
String *Item_func_curdate::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
- if (str->alloc(11))
+ if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
{
null_value= 1;
return (String *) 0;
@@ -1657,7 +1657,8 @@ String *Item_func_sec_to_time::val_str(String *str)
MYSQL_TIME ltime;
longlong arg_val= args[0]->val_int();
- if ((null_value=args[0]->null_value) || str->alloc(19))
+ if ((null_value=args[0]->null_value) ||
+ str->alloc(MAX_DATE_STRING_REP_LENGTH))
{
null_value= 1;
return (String*) 0;
@@ -1842,6 +1843,10 @@ String *Item_func_date_format::val_str(String *str)
size=max_length;
else
size=format_length(format);
+
+ if (size < MAX_DATE_STRING_REP_LENGTH)
+ size= MAX_DATE_STRING_REP_LENGTH;
+
if (format == str)
str= &value; // Save result here
if (str->alloc(size))
@@ -1885,13 +1890,14 @@ String *Item_func_from_unixtime::val_str(String *str)
if (get_date(&time_tmp, 0))
return 0;
- if (str->alloc(20*MY_CHARSET_BIN_MB_MAXLEN))
+ if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
{
null_value= 1;
return 0;
}
make_datetime((DATE_TIME_FORMAT *) 0, &time_tmp, str);
+
return str;
}
@@ -1940,14 +1946,15 @@ String *Item_func_convert_tz::val_str(String *str)
if (get_date(&time_tmp, 0))
return 0;
-
- if (str->alloc(20*MY_CHARSET_BIN_MB_MAXLEN))
+
+ if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
{
null_value= 1;
return 0;
}
-
+
make_datetime((DATE_TIME_FORMAT *) 0, &time_tmp, str);
+
return str;
}
@@ -2454,6 +2461,7 @@ String *Item_datetime_typecast::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
+
if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) &&
!make_datetime(ltime.second_part ? DATE_TIME_MICROSECOND : DATE_TIME,
&ltime, str))
@@ -2532,7 +2540,8 @@ String *Item_date_typecast::val_str(String *str)
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
- if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) && !str->alloc(11))
+ if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) &&
+ !str->alloc(MAX_DATE_STRING_REP_LENGTH))
{
make_date((DATE_TIME_FORMAT *) 0, &ltime, str);
return str;
@@ -2585,7 +2594,7 @@ String *Item_func_makedate::val_str(String *str)
{
null_value=0;
get_date_from_daynr(days,&l_time.year,&l_time.month,&l_time.day);
- if (str->alloc(11))
+ if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
goto err;
make_date((DATE_TIME_FORMAT *) 0, &l_time, str);
return str;
@@ -2721,6 +2730,7 @@ String *Item_func_add_time::val_str(String *str)
days= (long)(seconds/86400L);
calc_time_from_sec(&l_time3, (long)(seconds%86400L), microseconds);
+
if (!is_time)
{
get_date_from_daynr(days,&l_time3.year,&l_time3.month,&l_time3.day);
@@ -2836,7 +2846,7 @@ String *Item_func_maketime::val_str(String *str)
args[2]->null_value ||
minute < 0 || minute > 59 ||
second < 0 || second > 59 ||
- str->alloc(19))))
+ str->alloc(MAX_DATE_STRING_REP_LENGTH))))
return 0;
bzero((char *)&ltime, sizeof(ltime));
diff --git a/sql/unireg.h b/sql/unireg.h
index d67fa372083..5b73c6e9caa 100644
--- a/sql/unireg.h
+++ b/sql/unireg.h
@@ -74,6 +74,7 @@
#define MAX_TIME_WIDTH 23 /* -DDDDDD HH:MM:SS.###### */
#define MAX_DATETIME_FULL_WIDTH 29 /* YYYY-MM-DD HH:MM:SS.###### AM */
#define MAX_DATETIME_WIDTH 19 /* YYYY-MM-DD HH:MM:SS */
+#define MAX_DATETIME_COMPRESSED_WIDTH 14 /* YYYYMMDDHHMMSS */
#define MAX_TABLES (sizeof(table_map)*8-3) /* Max tables in join */
#define PARAM_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-3))