From 1d17fd7d51f7100038eaa5fb4cb372c785a44010 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 12 Oct 2003 17:56:05 +0300 Subject: fixed printability of Items (all items except subselects) (SCRUM) (WL#1274) sql/item.cc: fixed printability of Items sql/item.h: fixed printability of Items sql/item_cmpfunc.cc: fixed printability of Items sql/item_cmpfunc.h: fixed printability of Items sql/item_func.cc: fixed printability of Items sql/item_func.h: fixed printability of Items sql/item_geofunc.h: added DBUG_ASSERT to catch error in debuging timw sql/item_row.cc: fixed printability of Items sql/item_row.h: fixed printability of Items sql/item_strfunc.cc: fixed printability of Items sql/item_strfunc.h: fixed printability of Items sql/item_sum.cc: fixed printability of Items sql/item_sum.h: fixed printability of Items sql/item_timefunc.cc: fixed printability of Items sql/item_timefunc.h: layout fixed fixed printability of Items sql/item_uniq.h: fixed printability of Items sql/sql_yacc.yy: layout fixed correct convertion to String --- sql/item_timefunc.cc | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 3 deletions(-) (limited to 'sql/item_timefunc.cc') diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 31ce2ad9cdc..511e372e40a 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1359,6 +1359,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 @@ -1467,10 +1496,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(')'); } @@ -1740,6 +1790,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. -- cgit v1.2.1