The world's most popular open source database
#include "mysql_priv.h"#include "events_priv.h"#include "events.h"#include "event_timed.h"#include "sp_head.h"Include dependency graph for event_timed.cc:

Go to the source code of this file.
Defines | |
| #define | MYSQL_LEX 1 |
Functions | |
| static bool | get_next_time (TIME *next, TIME *start, TIME *time_now, TIME *last_exec, int i_value, interval_type i_type) |
| bool | event_timed_name_equal (Event_timed *et, LEX_STRING *name) |
| bool | event_timed_db_equal (Event_timed *et, LEX_STRING *db) |
| bool | event_timed_definer_equal (Event_timed *et, LEX_STRING *definer) |
| bool | event_timed_identifier_equal (Event_timed *a, Event_timed *b) |
| bool | change_security_context (THD *thd, LEX_STRING user, LEX_STRING host, LEX_STRING db, Security_context *s_ctx, Security_context **backup) |
| void | restore_security_context (THD *thd, Security_context *backup) |
Variables | |
| pthread_attr_t | connection_attrib |
| #define MYSQL_LEX 1 |
Definition at line 17 of file event_timed.cc.
| bool change_security_context | ( | THD * | thd, | |
| LEX_STRING | user, | |||
| LEX_STRING | host, | |||
| LEX_STRING | db, | |||
| Security_context * | s_ctx, | |||
| Security_context ** | backup | |||
| ) |
Definition at line 1828 of file event_timed.cc.
References acl_getroot_no_password(), db, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, ER_NO_SUCH_USER, FALSE, host, my_error(), MYF, TRUE, and user.
Referenced by Event_timed::compile(), and event_worker_thread().
01831 { 01832 DBUG_ENTER("change_security_context"); 01833 DBUG_PRINT("info",("%s@%s@%s", user.str, host.str, db.str)); 01834 #ifndef NO_EMBEDDED_ACCESS_CHECKS 01835 s_ctx->init(); 01836 *backup= 0; 01837 if (acl_getroot_no_password(s_ctx, user.str, host.str, host.str, db.str)) 01838 { 01839 my_error(ER_NO_SUCH_USER, MYF(0), user.str, host.str); 01840 DBUG_RETURN(TRUE); 01841 } 01842 *backup= thd->security_ctx; 01843 thd->security_ctx= s_ctx; 01844 #endif 01845 DBUG_RETURN(FALSE); 01846 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool event_timed_db_equal | ( | Event_timed * | et, | |
| LEX_STRING * | db | |||
| ) |
Definition at line 1767 of file event_timed.cc.
References db, Event_timed::dbname, sortcmp_lex_string(), and system_charset_info.
Referenced by Event_scheduler::drop_schema_events(), and event_timed_identifier_equal().
01768 { 01769 return !sortcmp_lex_string(et->dbname, *db, system_charset_info); 01770 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool event_timed_definer_equal | ( | Event_timed * | et, | |
| LEX_STRING * | definer | |||
| ) |
Definition at line 1785 of file event_timed.cc.
References Event_timed::definer, sortcmp_lex_string(), and system_charset_info.
Referenced by event_timed_identifier_equal().
01786 { 01787 return !sortcmp_lex_string(et->definer, *definer, system_charset_info); 01788 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool event_timed_identifier_equal | ( | Event_timed * | a, | |
| Event_timed * | b | |||
| ) |
Definition at line 1803 of file event_timed.cc.
References Event_timed::dbname, Event_timed::definer, event_timed_db_equal(), event_timed_definer_equal(), event_timed_name_equal(), and Event_timed::name.
Referenced by Event_scheduler::find_event().
01804 { 01805 return event_timed_name_equal(a, &b->name) && 01806 event_timed_db_equal(a, &b->dbname) && 01807 event_timed_definer_equal(a, &b->definer); 01808 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool event_timed_name_equal | ( | Event_timed * | et, | |
| LEX_STRING * | name | |||
| ) |
Definition at line 1749 of file event_timed.cc.
References Event_timed::name, name, sortcmp_lex_string(), and system_charset_info.
Referenced by event_timed_identifier_equal().
01750 { 01751 return !sortcmp_lex_string(et->name, *name, system_charset_info); 01752 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static bool get_next_time | ( | TIME * | next, | |
| TIME * | start, | |||
| TIME * | time_now, | |||
| TIME * | last_exec, | |||
| int | i_value, | |||
| interval_type | i_type | |||
| ) | [static] |
Definition at line 776 of file event_timed.cc.
References bzero, calc_time_diff(), date_add_interval(), DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, interval, INTERVAL_DAY, INTERVAL_DAY_HOUR, INTERVAL_DAY_MICROSECOND, INTERVAL_DAY_MINUTE, INTERVAL_DAY_SECOND, INTERVAL_HOUR, INTERVAL_HOUR_MICROSECOND, INTERVAL_HOUR_MINUTE, INTERVAL_HOUR_SECOND, INTERVAL_LAST, INTERVAL_MICROSECOND, INTERVAL_MINUTE, INTERVAL_MINUTE_MICROSECOND, INTERVAL_MINUTE_SECOND, INTERVAL_MONTH, INTERVAL_QUARTER, INTERVAL_SECOND, INTERVAL_SECOND_MICROSECOND, INTERVAL_WEEK, INTERVAL_YEAR, INTERVAL_YEAR_MONTH, st_mysql_time::month, my_time_compare(), start(), TIME_to_ulonglong_datetime(), and st_mysql_time::year.
Referenced by Event_timed::compute_next_execution_time().
00778 { 00779 bool ret; 00780 INTERVAL interval; 00781 TIME tmp; 00782 longlong months=0, seconds=0; 00783 DBUG_ENTER("get_next_time"); 00784 DBUG_PRINT("enter", ("start=%llu now=%llu", TIME_to_ulonglong_datetime(start), 00785 TIME_to_ulonglong_datetime(time_now))); 00786 00787 bzero(&interval, sizeof(interval)); 00788 00789 switch (i_type) { 00790 case INTERVAL_YEAR: 00791 months= i_value*12; 00792 break; 00793 case INTERVAL_QUARTER: 00794 /* Has already been converted to months */ 00795 case INTERVAL_YEAR_MONTH: 00796 case INTERVAL_MONTH: 00797 months= i_value; 00798 break; 00799 case INTERVAL_WEEK: 00800 /* WEEK has already been converted to days */ 00801 case INTERVAL_DAY: 00802 seconds= i_value*24*3600; 00803 break; 00804 case INTERVAL_DAY_HOUR: 00805 case INTERVAL_HOUR: 00806 seconds= i_value*3600; 00807 break; 00808 case INTERVAL_DAY_MINUTE: 00809 case INTERVAL_HOUR_MINUTE: 00810 case INTERVAL_MINUTE: 00811 seconds= i_value*60; 00812 break; 00813 case INTERVAL_DAY_SECOND: 00814 case INTERVAL_HOUR_SECOND: 00815 case INTERVAL_MINUTE_SECOND: 00816 case INTERVAL_SECOND: 00817 seconds= i_value; 00818 break; 00819 case INTERVAL_DAY_MICROSECOND: 00820 case INTERVAL_HOUR_MICROSECOND: 00821 case INTERVAL_MINUTE_MICROSECOND: 00822 case INTERVAL_SECOND_MICROSECOND: 00823 case INTERVAL_MICROSECOND: 00824 /* 00825 We should return an error here so SHOW EVENTS/ SELECT FROM I_S.EVENTS 00826 would give an error then. 00827 */ 00828 DBUG_RETURN(1); 00829 break; 00830 case INTERVAL_LAST: 00831 DBUG_ASSERT(0); 00832 } 00833 DBUG_PRINT("info", ("seconds=%ld months=%ld", seconds, months)); 00834 if (seconds) 00835 { 00836 longlong seconds_diff; 00837 long microsec_diff; 00838 00839 if (calc_time_diff(time_now, start, 1, &seconds_diff, µsec_diff)) 00840 { 00841 DBUG_PRINT("error", ("negative difference")); 00842 DBUG_ASSERT(0); 00843 } 00844 uint multiplier= seconds_diff / seconds; 00845 /* 00846 Increase the multiplier is the modulus is not zero to make round up. 00847 Or if time_now==start then we should not execute the same 00848 event two times for the same time 00849 get the next exec if the modulus is not 00850 */ 00851 DBUG_PRINT("info", ("multiplier=%d", multiplier)); 00852 if (seconds_diff % seconds || (!seconds_diff && last_exec->year) || 00853 TIME_to_ulonglong_datetime(time_now) == 00854 TIME_to_ulonglong_datetime(last_exec)) 00855 ++multiplier; 00856 interval.second= seconds * multiplier; 00857 DBUG_PRINT("info", ("multiplier=%u interval.second=%u", multiplier, 00858 interval.second)); 00859 tmp= *start; 00860 if (!(ret= date_add_interval(&tmp, INTERVAL_SECOND, interval))) 00861 *next= tmp; 00862 } 00863 else 00864 { 00865 /* PRESUMED is that at least one execution took already place */ 00866 int diff_months= (time_now->year - start->year)*12 + 00867 (time_now->month - start->month); 00868 /* 00869 Note: If diff_months is 0 that means we are in the same month as the 00870 last execution which is also the first execution. 00871 */ 00872 /* 00873 First we try with the smaller if not then + 1, because if we try with 00874 directly with +1 we will be after the current date but it could be that 00875 we will be 1 month ahead, so 2 steps are necessary. 00876 */ 00877 interval.month= (diff_months / months)*months; 00878 /* 00879 Check if the same month as last_exec (always set - prerequisite) 00880 An event happens at most once per month so there is no way to schedule 00881 it two times for the current month. This saves us from two calls to 00882 date_add_interval() if the event was just executed. But if the scheduler 00883 is started and there was at least 1 scheduled date skipped this one does 00884 not help and two calls to date_add_interval() will be done, which is a 00885 bit more expensive but compared to the rareness of the case is neglectable. 00886 */ 00887 if (time_now->year==last_exec->year && time_now->month==last_exec->month) 00888 interval.month+= months; 00889 00890 tmp= *start; 00891 if ((ret= date_add_interval(&tmp, INTERVAL_MONTH, interval))) 00892 goto done; 00893 00894 /* If `tmp` is still before time_now just add one more time the interval */ 00895 if (my_time_compare(&tmp, time_now) == -1) 00896 { 00897 interval.month+= months; 00898 tmp= *start; 00899 if ((ret= date_add_interval(&tmp, INTERVAL_MONTH, interval))) 00900 goto done; 00901 } 00902 *next= tmp; 00903 /* assert on that the next is after now */ 00904 DBUG_ASSERT(1==my_time_compare(next, time_now)); 00905 } 00906 00907 done: 00908 DBUG_PRINT("info", ("next=%llu", TIME_to_ulonglong_datetime(next))); 00909 DBUG_RETURN(ret); 00910 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void restore_security_context | ( | THD * | thd, | |
| Security_context * | backup | |||
| ) |
Definition at line 1858 of file event_timed.cc.
References DBUG_ENTER, and DBUG_VOID_RETURN.
Referenced by Event_timed::compile().
01859 { 01860 DBUG_ENTER("restore_security_context"); 01861 #ifndef NO_EMBEDDED_ACCESS_CHECKS 01862 if (backup) 01863 thd->security_ctx= backup; 01864 #endif 01865 DBUG_VOID_RETURN; 01866 }
Here is the caller graph for this function:

| pthread_attr_t connection_attrib |
1.4.7

