summaryrefslogtreecommitdiff
path: root/sql/item_create.cc
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2014-02-07 19:15:28 +0100
committerunknown <knielsen@knielsen-hq.org>2014-02-07 19:15:28 +0100
commit4e6606acad4ad0ea75dec114ad316e0325efaf02 (patch)
treeabb53cd21ab57261299ec9c96fef4089f7025d1d /sql/item_create.cc
parentce02738d7f2f2688eeec7004dd6a30293d36044f (diff)
downloadmariadb-git-4e6606acad4ad0ea75dec114ad316e0325efaf02.tar.gz
MDEV-4984: Implement MASTER_GTID_WAIT() and @@LAST_GTID.
MASTER_GTID_WAIT() is similar to MASTER_POS_WAIT(), but works with a GTID position rather than an old-style filename/offset. @@LAST_GTID gives the GTID assigned to the last transaction written into the binlog. Together, the two can be used by applications to obtain the GTID of an update on the master, and then do a MASTER_GTID_WAIT() for that position on any read slave where it is important to get results that are caught up with the master at least to the point of the update. The implementation of MASTER_GTID_WAIT() is implemented in a way that tries to minimise the performance impact on the SQL threads, even in the presense of many waiters on single GTID positions (as from @@LAST_GTID).
Diffstat (limited to 'sql/item_create.cc')
-rw-r--r--sql/item_create.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 60eabe67c83..c158816bf32 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -1783,6 +1783,19 @@ protected:
};
+class Create_func_master_gtid_wait : public Create_native_func
+{
+public:
+ virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+
+ static Create_func_master_gtid_wait s_singleton;
+
+protected:
+ Create_func_master_gtid_wait() {}
+ virtual ~Create_func_master_gtid_wait() {}
+};
+
+
class Create_func_md5 : public Create_func_arg1
{
public:
@@ -4590,6 +4603,47 @@ Create_func_master_pos_wait::create_native(THD *thd, LEX_STRING name,
}
+Create_func_master_gtid_wait Create_func_master_gtid_wait::s_singleton;
+
+Item*
+Create_func_master_gtid_wait::create_native(THD *thd, LEX_STRING name,
+ List<Item> *item_list)
+{
+ Item *func= NULL;
+ int arg_count= 0;
+
+ thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
+
+ if (item_list != NULL)
+ arg_count= item_list->elements;
+
+ if (arg_count < 1 || arg_count > 2)
+ {
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ return func;
+ }
+
+ thd->lex->safe_to_cache_query= 0;
+
+ Item *param_1= item_list->pop();
+ switch (arg_count) {
+ case 1:
+ {
+ func= new (thd->mem_root) Item_master_gtid_wait(param_1);
+ break;
+ }
+ case 2:
+ {
+ Item *param_2= item_list->pop();
+ func= new (thd->mem_root) Item_master_gtid_wait(param_1, param_2);
+ break;
+ }
+ }
+
+ return func;
+}
+
+
Create_func_md5 Create_func_md5::s_singleton;
Item*
@@ -5536,6 +5590,7 @@ static Native_func_registry func_array[] =
{ { C_STRING_WITH_LEN("MAKEDATE") }, BUILDER(Create_func_makedate)},
{ { C_STRING_WITH_LEN("MAKETIME") }, BUILDER(Create_func_maketime)},
{ { C_STRING_WITH_LEN("MAKE_SET") }, BUILDER(Create_func_make_set)},
+ { { C_STRING_WITH_LEN("MASTER_GTID_WAIT") }, BUILDER(Create_func_master_gtid_wait)},
{ { C_STRING_WITH_LEN("MASTER_POS_WAIT") }, BUILDER(Create_func_master_pos_wait)},
{ { C_STRING_WITH_LEN("MBRCONTAINS") }, GEOM_BUILDER(Create_func_mbr_contains)},
{ { C_STRING_WITH_LEN("MBRDISJOINT") }, GEOM_BUILDER(Create_func_mbr_disjoint)},