From 4e6606acad4ad0ea75dec114ad316e0325efaf02 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Feb 2014 19:15:28 +0100 Subject: 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). --- sql/item_func.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'sql/item_func.cc') diff --git a/sql/item_func.cc b/sql/item_func.cc index 5d9abbb0d8c..b2af80e6d96 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3989,6 +3989,34 @@ err: } +longlong Item_master_gtid_wait::val_int() +{ + DBUG_ASSERT(fixed == 1); + longlong result= 0; + + if (args[0]->null_value) + { + null_value= 1; + return 0; + } + + null_value=0; +#ifdef HAVE_REPLICATION + THD* thd= current_thd; + longlong timeout_us; + String *gtid_pos = args[0]->val_str(&value); + + if (arg_count==2 && !args[1]->null_value) + timeout_us= (longlong)(1e6*args[1]->val_real()); + else + timeout_us= (longlong)-1; + + result= rpl_global_gtid_waiting.wait_for_pos(thd, gtid_pos, timeout_us); +#endif + return result; +} + + /** Enables a session to wait on a condition until a timeout or a network disconnect occurs. -- cgit v1.2.1 From d12c7adf715677b118104d4e5adf6f978c27b4ee Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Wed, 19 Feb 2014 14:05:15 +0400 Subject: MDEV-5314 - Compiling fails on OSX using clang This is port of fix for MySQL BUG#17647863. revno: 5572 revision-id: jon.hauglid@oracle.com-20131030232243-b0pw98oy72uka2sj committer: Jon Olav Hauglid timestamp: Thu 2013-10-31 00:22:43 +0100 message: Bug#17647863: MYSQL DOES NOT COMPILE ON OSX 10.9 GM Rename test() macro to MY_TEST() to avoid conflict with libc++. --- sql/item_func.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sql/item_func.cc') diff --git a/sql/item_func.cc b/sql/item_func.cc index 9918b7c40f6..2fe47406b9e 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2615,7 +2615,8 @@ void Item_func_round::fix_length_and_dec() case INT_RESULT: if ((!decimals_to_set && truncate) || (args[0]->decimal_precision() < DECIMAL_LONGLONG_DIGITS)) { - int length_can_increase= test(!truncate && (val1 < 0) && !val1_unsigned); + int length_can_increase= MY_TEST(!truncate && (val1 < 0) && + !val1_unsigned); max_length= args[0]->max_length + length_can_increase; /* Here we can keep INT_RESULT */ cached_result_type= INT_RESULT; @@ -4617,7 +4618,7 @@ longlong Item_func_sleep::val_int() mysql_cond_destroy(&cond); - return test(!error); // Return 1 killed + return MY_TEST(!error); // Return 1 killed } @@ -6684,7 +6685,7 @@ void Item_func_sp::fix_length_and_dec() max_length= sp_result_field->field_length; collation.set(sp_result_field->charset()); maybe_null= 1; - unsigned_flag= test(sp_result_field->flags & UNSIGNED_FLAG); + unsigned_flag= MY_TEST(sp_result_field->flags & UNSIGNED_FLAG); DBUG_VOID_RETURN; } -- cgit v1.2.1 From ce3c457e6d6f282967154cd7a56d1382c652cb2b Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Sun, 23 Mar 2014 19:43:01 +0400 Subject: MDEV-5781 Item_sum_std::val_real(): Assertion `nr >= 0.0' fails on query with STDDEV_POP, ROUND and variable --- sql/item_func.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sql/item_func.cc') diff --git a/sql/item_func.cc b/sql/item_func.cc index 2fe47406b9e..c659d7964b9 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2666,6 +2666,9 @@ double my_double_round(double value, longlong dec, bool dec_unsigned, volatile double value_div_tmp= value / tmp; volatile double value_mul_tmp= value * tmp; + if (!dec_negative && my_isinf(tmp)) // "dec" is too large positive number + return value; + if (dec_negative && my_isinf(tmp)) tmp2= 0.0; else if (!dec_negative && my_isinf(value_mul_tmp)) -- cgit v1.2.1 From 7b1b744f53aca6ca77f06cb1980c40da666387d1 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 20 Mar 2014 23:26:41 +0100 Subject: MDEV-5849 MySQL bug#12602983 - User without privilege on routine can discover its existence by executing "select non_existing_func();" or by "call non_existing_proc()" add or move privilege checks before existence checks --- sql/item_func.cc | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'sql/item_func.cc') diff --git a/sql/item_func.cc b/sql/item_func.cc index c659d7964b9..eb176d7e490 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -6741,22 +6741,18 @@ Item_func_sp::execute_impl(THD *thd) { bool err_status= TRUE; Sub_statement_state statement_state; -#ifndef NO_EMBEDDED_ACCESS_CHECKS Security_context *save_security_ctx= thd->security_ctx; -#endif enum enum_sp_data_access access= (m_sp->m_chistics->daccess == SP_DEFAULT_ACCESS) ? SP_DEFAULT_ACCESS_MAPPING : m_sp->m_chistics->daccess; DBUG_ENTER("Item_func_sp::execute_impl"); -#ifndef NO_EMBEDDED_ACCESS_CHECKS if (context->security_ctx) { /* Set view definer security context */ thd->security_ctx= context->security_ctx; } -#endif if (sp_check_access(thd)) goto error; @@ -6784,9 +6780,7 @@ Item_func_sp::execute_impl(THD *thd) thd->restore_sub_statement_state(&statement_state); error: -#ifndef NO_EMBEDDED_ACCESS_CHECKS thd->security_ctx= save_security_ctx; -#endif DBUG_RETURN(err_status); } @@ -6857,11 +6851,9 @@ Item_func_sp::sp_check_access(THD *thd) { DBUG_ENTER("Item_func_sp::sp_check_access"); DBUG_ASSERT(m_sp); -#ifndef NO_EMBEDDED_ACCESS_CHECKS if (check_routine_access(thd, EXECUTE_ACL, m_sp->m_db.str, m_sp->m_name.str, 0, FALSE)) DBUG_RETURN(TRUE); -#endif DBUG_RETURN(FALSE); } @@ -6873,7 +6865,29 @@ Item_func_sp::fix_fields(THD *thd, Item **ref) bool res; DBUG_ENTER("Item_func_sp::fix_fields"); DBUG_ASSERT(fixed == 0); - + + /* + Checking privileges to execute the function while creating view and + executing the function of select. + */ + if (!(thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW) || + (thd->lex->sql_command == SQLCOM_CREATE_VIEW)) + { + Security_context *save_security_ctx= thd->security_ctx; + if (context->security_ctx) + thd->security_ctx= context->security_ctx; + + res= check_routine_access(thd, EXECUTE_ACL, m_name->m_db.str, + m_name->m_name.str, 0, FALSE); + thd->security_ctx= save_security_ctx; + + if (res) + { + context->process_error(thd); + DBUG_RETURN(res); + } + } + /* We must call init_result_field before Item_func::fix_fields() to make m_sp and result_field members available to fix_length_and_dec(), -- cgit v1.2.1