mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Galera4
This commit is contained in:
committed by
Sergey Vojtovich
parent
382115b992
commit
36a2a185fe
@@ -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 */
|
||||
|
Reference in New Issue
Block a user