summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2003-10-22 20:52:47 +0300
committerunknown <bell@sanja.is.com.ua>2003-10-22 20:52:47 +0300
commit47f3a4fd4aa4ac7f2944c85aa20333fa0259ac77 (patch)
tree094f3d63a932eeaa346520cc5605255beab9debe /sql/item_timefunc.cc
parent9a4aa99769b29cb4084b3b16d2bfb7067d817d2c (diff)
parentb7aac7df29e716ab0bfd95e2c7349287912dcbf6 (diff)
downloadmariadb-git-47f3a4fd4aa4ac7f2944c85aa20333fa0259ac77.tar.gz
Merge
mysql-test/t/subselect.test: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_func.cc: Auto merged sql/item_strfunc.cc: Auto merged sql/item_sum.cc: Auto merged sql/item_sum.h: Auto merged sql/item_timefunc.cc: Auto merged sql/item_timefunc.h: Auto merged sql/mysql_priv.h: Auto merged sql/sql_derived.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_yacc.yy: Auto merged mysql-test/r/subselect.result: SCCS merged
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r--sql/item_timefunc.cc78
1 files changed, 75 insertions, 3 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 4009256ee17..a8c8f9bcf7f 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -1644,6 +1644,35 @@ longlong Item_date_add_interval::val_int()
((date*100L + ltime.hour)*100L+ ltime.minute)*100L + ltime.second;
}
+static const char *interval_names[]=
+{
+ "year", "month", "day", "hour", "minute",
+ "second", "microsecond", "year_month",
+ "day_hour", "day_minute", "day_second",
+ "hour_minute", "hour_second", "minute_second",
+ "day_microsecond", "hour_microsecond",
+ "minute_microsecond", "second_microsecond"
+};
+
+void Item_date_add_interval::print(String *str)
+{
+ str->append('(');
+ args[0]->print(str);
+ str->append(date_sub_interval?" - interval ":" + interval ");
+ args[1]->print(str);
+ str->append(interval_names[int_type]);
+ str->append(')');
+}
+
+void Item_extract::print(String *str)
+{
+ str->append("extract(");
+ str->append(interval_names[int_type]);
+ str->append(' ');
+ args[0]->print(str);
+ str->append(')');
+}
+
void Item_extract::fix_length_and_dec()
{
value.alloc(32); // alloc buffer
@@ -1751,10 +1780,31 @@ bool Item_extract::eq(const Item *item, bool binary_cmp) const
void Item_typecast::print(String *str)
{
- str->append("CAST(");
+ str->append("cast(");
args[0]->print(str);
- str->append(" AS ");
- str->append(func_name());
+ str->append(" as ");
+ str->append(cast_type());
+ str->append(')');
+}
+
+void Item_char_typecast::print(String *str)
+{
+ str->append("cast(");
+ args[0]->print(str);
+ str->append(" as char");
+ if (cast_length >= 0)
+ {
+ str->append('(');
+ char buff[10];
+ snprintf(buff, 10, "%d", cast_length);
+ str->append(buff);
+ str->append(')');
+ }
+ if (cast_cs)
+ {
+ str->append(" charset ");
+ str->append(cast_cs->name);
+ }
str->append(')');
}
@@ -2039,6 +2089,28 @@ null_date:
return 0;
}
+
+void Item_func_add_time::print(String *str)
+{
+ if (is_date)
+ {
+ DBUG_ASSERT(sign > 0);
+ str->append("timestamp(");
+ }
+ else
+ {
+ if (sign > 0)
+ str->append("addtime(");
+ else
+ str->append("subtime(");
+ }
+ args[0]->print(str);
+ str->append(',');
+ args[0]->print(str);
+ str->append(')');
+}
+
+
/*
TIMEDIFF(t,s) is a time function that calculates the
time value between a start and end time.