diff options
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r-- | sql/item_strfunc.cc | 107 |
1 files changed, 103 insertions, 4 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 6c82c580858..77e870b297d 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -4544,7 +4544,7 @@ bool Item_func_dyncol_create::prepare_arguments(THD *thd, bool force_names_arg) case DYN_COL_DATETIME: case DYN_COL_DATE: args[valpos]->get_date(thd, &vals[i].x.time_value, - sql_mode_for_dates(thd)); + Datetime::Options(thd)); break; case DYN_COL_TIME: args[valpos]->get_time(thd, &vals[i].x.time_value); @@ -5135,7 +5135,7 @@ bool Item_dyncol_get::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydat { longlong llval = (longlong)val.x.ulong_value; if (int_to_datetime_with_warn(thd, Longlong_hybrid(llval, !signed_value), - ltime, fuzzydate, 0 /* TODO */)) + ltime, fuzzydate, 0, 0 /* TODO */)) goto null; return 0; } @@ -5144,12 +5144,12 @@ bool Item_dyncol_get::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydat /* fall through */ case DYN_COL_DOUBLE: if (double_to_datetime_with_warn(thd, val.x.double_value, ltime, fuzzydate, - 0 /* TODO */)) + 0, 0 /* TODO */)) goto null; return 0; case DYN_COL_DECIMAL: if (decimal_to_datetime_with_warn(thd, (my_decimal*)&val.x.decimal.value, - ltime, fuzzydate, 0 /* TODO */)) + ltime, fuzzydate, 0, 0 /* TODO */)) goto null; return 0; case DYN_COL_STRING: @@ -5264,3 +5264,102 @@ String *Item_temptable_rowid::val_str(String *str) str_value.set((char*)(table->file->ref), max_length, &my_charset_bin); return &str_value; } +#ifdef WITH_WSREP + +#include "wsrep_mysqld.h" + +String *Item_func_wsrep_last_written_gtid::val_str_ascii(String *str) +{ + wsrep::gtid gtid= current_thd->wsrep_cs().last_written_gtid(); + if (gtid_str.alloc(wsrep::gtid_c_str_len())) + { + my_error(ER_OUTOFMEMORY, wsrep::gtid_c_str_len()); + null_value= true; + return NULL; + } + + ssize_t gtid_len= gtid_print_to_c_str(gtid, (char*) gtid_str.ptr(), + wsrep::gtid_c_str_len()); + if (gtid_len < 0) + { + my_error(ER_ERROR_WHEN_EXECUTING_COMMAND, MYF(0), func_name(), + "wsrep_gtid_print failed"); + null_value= true; + return NULL; + } + gtid_str.length(gtid_len); + return >id_str; +} + +String *Item_func_wsrep_last_seen_gtid::val_str_ascii(String *str) +{ + /* TODO: Should call Wsrep_server_state.instance().last_committed_gtid() + instead. */ + wsrep::gtid gtid= Wsrep_server_state::instance().provider().last_committed_gtid(); + if (gtid_str.alloc(wsrep::gtid_c_str_len())) + { + my_error(ER_OUTOFMEMORY, wsrep::gtid_c_str_len()); + null_value= true; + return NULL; + } + ssize_t gtid_len= wsrep::gtid_print_to_c_str(gtid, (char*) gtid_str.ptr(), + wsrep::gtid_c_str_len()); + if (gtid_len < 0) + { + my_error(ER_ERROR_WHEN_EXECUTING_COMMAND, MYF(0), func_name(), + "wsrep_gtid_print failed"); + null_value= true; + return NULL; + } + gtid_str.length(gtid_len); + return >id_str; +} + +longlong Item_func_wsrep_sync_wait_upto::val_int() +{ + int timeout= -1; + String* gtid_str= args[0]->val_str(&value); + if (gtid_str == NULL) + { + my_error(ER_WRONG_ARGUMENTS, MYF(0), func_name()); + return 0LL; + } + + if (arg_count == 2) + { + timeout= args[1]->val_int(); + } + + wsrep_gtid_t gtid; + int gtid_len= wsrep_gtid_scan(gtid_str->ptr(), gtid_str->length(), >id); + if (gtid_len < 0) + { + my_error(ER_WRONG_ARGUMENTS, MYF(0), func_name()); + return 0LL; + } + + if (gtid.seqno == WSREP_SEQNO_UNDEFINED && + wsrep_uuid_compare(>id.uuid, &WSREP_UUID_UNDEFINED) == 0) + { + return 1LL; + } + + enum wsrep::provider::status status= + wsrep_sync_wait_upto(current_thd, >id, timeout); + + if (status) + { + int err; + switch (status) { + case wsrep::provider::error_transaction_missing: + err= ER_WRONG_ARGUMENTS; + break; + default: + err= ER_LOCK_WAIT_TIMEOUT; + } + my_error(err, MYF(0), func_name()); + return 0LL; + } + return 1LL; +} +#endif /* WITH_WSREP */ |