Commit graph

38 commits

Author SHA1 Message Date
unknown
17fb7f96a2 fix for bug #16411 Events: Microsecond intervals are allowed
WL#1034


mysql-test/r/events.result:
  output fix
sql/event.cc:
  - handle also INTERVAL_MICROSECOND, was missing.
  - use renamed ER_ code which is generic
sql/event.h:
  add new error code
sql/event_executor.cc:
  - use new ER_ code name
  - handle EVEX_MICROSECOND_UNSUP error code
sql/event_timed.cc:
  forbid MICROSECOND intervals for events
sql/share/errmsg.txt:
  rename error code, it's generic
sql/sql_show.cc:
  use new error code name
sql/sql_yacc.yy:
  bail out if any MICROSECOND interval is specified
2006-02-20 16:06:05 +01:00
unknown
74b2989dc4 merge
mysql-test/r/events.result:
  Auto merged
mysql-test/t/events.test:
  Auto merged
sql/event_priv.h:
  Auto merged
sql/sql_db.cc:
  Auto merged
sql/event.cc:
  manual merge
sql/event.h:
  manual merge
sql/event_executor.cc:
  manual merge
sql/event_timed.cc:
  manual merge
2006-02-16 01:27:36 +01:00
unknown
fea4742db5 fix for bug#16406 (Events: DROP DATABASE doesn't automatically drop events)
WL#1034
- This changeset also changes the executor so its quite more stable now.
  Stressing test case added that executes ~800 events per second and dropping
  hundreds of events at once using DROP DATABASE.
(with fixes after review of JimW)
(with fixes after review of Serg)


mysql-test/r/events.result:
  update results after TRIGGER_ACL was added
mysql-test/t/events.test:
  -redundant line
sql/event.cc:
  Implemented evex_db_drop_events() which drops all events
  from a specific database. Needed for SQLCOM_DROP_DATABASE
sql/event.h:
  - protect the event better (see the changes to event_executor.cc
    and event.cc). An event object could be used in a spawned thread
    before it's executed but till now the object is marked as being
    executed when the anonymous sp_head is executed. However, there are
    timeframes before and after that during which the event is not marked
    as executed and other thread may delete the object -> so we end with
    a nirvana pointer.
sql/event_executor.cc:
  - extract some of the code executed in the main thread to a function. Too long
    functions are bad for the overview.
  - prepend all information/error messages to the console with "SCHEDULER:" for
    better overview, and easied searching in the log tables.
sql/event_priv.h:
  - change the name, of evex_db_find_event_by_name() and don't
    used C++ features like function overloading
  - define consts for result returned from event_timed::spawn_now()
sql/event_timed.cc:
  - add few methods related to event execution.
    now the event spawns the worker thread and
    passes itself as parameter. This way it locks itself for exectution
    first and then spawning -> no race condition. When the worker thread
    has finished working with the reference it calls back
    event_timed::spawn_thread_finish() to unlock itself.
sql/sql_db.cc:
  - call evex_drop_db_events() on DROP DATABASE
2006-02-16 00:43:11 +01:00
unknown
c6e5c2bcfb cosmetic post-review changes
mysql-test/r/events.result:
  result fixed
sql/event_executor.cc:
  cosmetic changes to show the definer of the event
2006-02-15 21:40:38 +01:00
unknown
ea717647f5 cosmetic changes of the fix for bug#17289 (no privileges checks in EVENTS), before push
sql/event_executor.cc:
  cosmetic changes of the fix for bug#17289, before push
2006-02-15 12:14:23 +01:00
unknown
a280f0c8bd Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into lmy004.:/work/mysql-5.1-bug17289


sql/event_executor.cc:
  Auto merged
2006-02-14 23:35:13 +01:00
unknown
60ea0bfaf6 make it explicitly extern. this should fix build failure on FC4 2006-02-14 20:58:19 +01:00
unknown
1161b5213d Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into lmy004.:/work/mysql-5.1-bug17289


mysql-test/r/events.result:
  Auto merged
mysql-test/t/events.test:
  Auto merged
sql/event.h:
  Auto merged
sql/event_executor.cc:
  Auto merged
sql/event_timed.cc:
  Auto merged
2006-02-14 19:44:10 +01:00
unknown
77970a98d1 post-merge fixes
sql/event_executor.cc:
  fix for bug#17289 (Events: missing privilege check for drop database)
  WL#1034
  post-merge fixes
2006-02-14 17:51:22 +01:00
unknown
752cadd453 manual merge
mysql-test/r/events.result:
  Auto merged
mysql-test/t/events.test:
  Auto merged
sql/event.h:
  Auto merged
sql/event_executor.cc:
  Auto merged
sql/event_timed.cc:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_acl.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/table.cc:
  Auto merged
sql/table.h:
  Auto merged
2006-02-14 17:05:36 +01:00
unknown
8d4f74be2d - final fixes for bug#16431 (Events: An event which alters itself disappears)
- fix for bug#16423 (Events: SHOW CREATE EVENT doesn't work)
- this Changeset commits makes CREATE/UPDATE/DELETE EVENT real DDL statements
  by committing the currently open transaction before they are executed.
- this Changeset also fixes a trailing space problem since the very early days
  of the internal cron
- adds sophisticated checking of whether mysql.event was tampered accidentally
  or with purpose by an user.
- adds a lot of inline function documentation - documents everything left
  uncodumented
- INTERVAL_XXXX to XXX in I_S.EVENTS.INTERVAL_FIELD

WL#1034 (Internal CRON)


mysql-test/r/events.result:
  update result
mysql-test/t/events.test:
  add test cases for SHOW CREATE EVENT
  add test cases where the structure of mysql.event is changed and error reporting in this case
sql/event.cc:
  - do a lot more checking on mysql.event whether it's valid
    introduced generic function table_check_intact() which can be used also
    for checking whether a system table (mysql.*) has been tampered by user
    and report an error in this case. The checking is quite strict, thus
    maybe some mechanism can be added later that loosens this like some
    session variable, for instance, i_am_aware_that_i_can_damage_my_data
    so the table will be opened nevertheless we think that it's not valid.
  - add evex_show_create_event(THD *thd, sp_name *spn, LEX_STRING definer)
  - document a loooot. not a single function left undocumented.
sql/event.h:
  - add evex_show_create_event(THD *thd, sp_name *spn, LEX_STRING definer)
  - change get_show_create_event() to get_create_event()
  - add TABLE_FIELD_W_TYPE used by table_check_intact()
  - add event_timed::sql_mode so it can be used by show create event. currently
    always 0, will be fixed by a patch for another bug. At least makes the code
    of show create event complete.
sql/event_executor.cc:
  - add evex_check_system_tables() that checks on boot and event
    main thread startup that mysql.db and mysql.user tables are correct.
  - document everything!
sql/event_priv.h:
  remove a line
sql/event_timed.cc:
  - implement SHOW CREATE EVENT
  - document undocumented functions!
sql/share/errmsg.txt:
  - fix an error message and add two new
sql/sql_acl.cc:
  - add mysql.db table definition to use by table_check_intact()
  - exchange some of the positions by numbers from mysql.db to enum names (see sql_acl.h)
sql/sql_acl.h:
  - define the structure of mysql.db table
sql/sql_parse.cc:
  - handle SQLCOM_SHOW_CREATE_EVENT
  - end the current transaction becase CREATE/UPDATE/DELETE EVENT is a DDL
    statement
sql/sql_show.cc:
  - remove interval_type_to_name
  - use common function event_reconstruct_interval_expression()
    that reconstructs the expression given at create/alter, to some
    extent - interval of 2:62 MINUTE_SECOND will be reconstructed as
    interval of 3:02 MINUTE_SECOND!
sql/sql_yacc.yy:
  init the definer of event_timed also when doing SHOW CREATE EVENT
  because it's needed for checking into mysql.event
sql/table.cc:
  - remove stale code. only mysql.event should be a 'system_table'
  - add table_check_intact() to check the consistency of a table.
    mostly usable with mysql.xxx tables.
sql/table.h:
  - export TABLE_FIELD_W_TYPE and table_check_intact() which are used for 
    checking the structure of a table. mostly usable for mysql.xxx tables.
2006-02-14 16:20:48 +01:00
unknown
5b497b163a fix for bug #17289 Events: missing privilege check for drop database
Events were executed with all privileges possible on planet Earth :(
WL#1034


mysql-test/r/events.result:
  update test results
mysql-test/t/events.test:
  test for bug#17289 Events: missing privilege check for drop database
sql/event.h:
  -add two new methods to event_timed to change and restore
   the security context
sql/event_executor.cc:
  - move code regarding privilieges checking to event_timed::execute()
  - add a new function evex_print_warnings() which prints the notes/warnings/errors
    to the console (easily capturable with logs-into-tables) so one can see what
    has happened if there was an error of some sort!
sql/event_timed.cc:
  - fix documentation
  - add a new error code -99, EVENT was revoked from the user on the DB
  - set_sec_ctx, execute, restore_sex_ctx
sql/sql_error.cc:
  - make warning_level_names public to be used in event_executor.cc
  - change from 2 arrays to a LEX_STRING array
2006-02-10 15:02:57 +01:00
unknown
c9111fc6c3 - use the connection_attib used to spawn threads
in the server. this fixes the problem with the limited number of
  threads because of them being non-detached. pthread_detach_this_tread()
  expands to empty on most platforms including SuSE but pthread_detach(pthread_self())
  is not portable on Windows so the first macro should be used and the thread
  to be detached we have to create it as such.
fix for bug#16984 (Events: running out of threads)
WL#1034 (Internal CRON)


sql/event_executor.cc:
  - use the connection_attib used to spawn threads
    in the server. this fixes the problem with the limited number of
    threads because of them being non-detached. pthread_detach_this_tread()
    expands to empty on most platforms including SuSE but pthread_detach(pthread_self())
    is not portable on Windows so the first macro should be used and the thread
    to be detached we have to create it as such.
2006-01-31 23:41:21 +01:00
unknown
c4f91d17b7 Merge mysql.com:/usr/local/mysql/mysql-5.1-win-fixes
into  mysql.com:/usr/local/mysql/x/mysql-5.1-new


VC++Files/sql/mysqld.vcproj:
  Auto merged
sql/event.h:
  Auto merged
sql/event_executor.cc:
  Auto merged
sql/event_timed.cc:
  Auto merged
sql/handler.h:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/sql_partition.cc:
  Auto merged
VC++Files/client/mysqldump.vcproj:
  Manual merge.
2006-01-30 17:57:20 +01:00
unknown
2272e140fd post-commit merge
mysql-test/lib/init_db.sql:
  Auto merged
scripts/mysql_create_system_tables.sh:
  Auto merged
scripts/mysql_fix_privilege_tables.sql:
  Auto merged
sql/event.cc:
  Auto merged
sql/event.h:
  Auto merged
sql/event_executor.cc:
  Auto merged
sql/event_priv.h:
  Auto merged
sql/event_timed.cc:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/events.result:
  manual merge
mysql-test/r/system_mysql_db.result:
  manual merge
mysql-test/t/events.test:
  manual merge
2006-01-30 14:28:48 +01:00
unknown
c3542cebf9 fix for bug#16642 (Events: No INFORMATION_SCHEMA.EVENTS table)
post-review change - use pointer instead of copy on the stack.
WL#1034 (Internal CRON)
 This patch adds INFORMATION_SCHEMA.EVENTS table with the following format:
  EVENT_CATALOG  - MYSQL_TYPE_STRING  (Always NULL)
  EVENT_SCHEMA   - MYSQL_TYPE_STRING  (the database)
  EVENT_NAME     - MYSQL_TYPE_STRING  (the name)
  DEFINER        - MYSQL_TYPE_STRING  (user@host)
  EVENT_BODY     - MYSQL_TYPE_STRING  (the body from mysql.event)
  EVENT_TYPE     - MYSQL_TYPE_STRING  ("ONE TIME" | "RECURRING")
  EXECUTE_AT     - MYSQL_TYPE_TIMESTAMP (set for "ONE TIME" otherwise NULL)
  INTERVAL_VALUE - MYSQL_TYPE_LONG    (set for RECURRING otherwise NULL)
  INTERVAL_FIELD - MYSQL_TYPE_STRING  (set for RECURRING otherwise NULL)
  SQL_MODE       - MYSQL_TYPE_STRING  (for now NULL)
  STARTS         - MYSQL_TYPE_TIMESTAMP (starts from mysql.event)
  ENDS           - MYSQL_TYPE_TIMESTAMP (ends from mysql.event)
  STATUS         - MYSQL_TYPE_STRING  (ENABLED | DISABLED)
  ON_COMPLETION  - MYSQL_TYPE_STRING  (NOT PRESERVE | PRESERVE)
  CREATED        - MYSQL_TYPE_TIMESTAMP
  LAST_ALTERED   - MYSQL_TYPE_TIMESTAMP
  LAST_EXECUTED  - MYSQL_TYPE_TIMESTAMP
  EVENT_COMMENT  - MYSQL_TYPE_STRING

  SQL_MODE is NULL for now, because the value is still not stored in mysql.event .
Support will be added as a fix for another bug.

 This patch also adds SHOW [FULL] EVENTS [FROM db] [LIKE pattern]
1. SHOW EVENTS shows always only the events on the same user,
   because the PK of mysql.event is (definer, db, name) several 
   users may have event with the same name -> no information disclosure.
2. SHOW FULL EVENTS - shows the events (in the current db as SHOW EVENTS)
   of all users. The user has to have PROCESS privilege, if not then
   SHOW FULL EVENTS behave like SHOW EVENTS.
3. If [FROM db] is specified then this db is considered.
4. Event names can be filtered with LIKE pattern.
  SHOW EVENTS returns table with the following columns, which are subset of
  the data which is returned by SELECT * FROM I_S.EVENTS
   Db
   Name
   Definer 
   Type
   Execute at
   Interval value
   Interval field 
   Starts 
   Ends
   Status


mysql-test/lib/init_db.sql:
  change the PK - (definer, db, name)
  quicker searches when SHOW EVENTS;
  allow also different users to have events with the same name -> 
  no information disclosure
mysql-test/r/events.result:
  result of new tests
mysql-test/r/information_schema.result:
  result of new tests
mysql-test/r/information_schema_db.result:
  result of new tests
mysql-test/r/system_mysql_db.result:
  result of new tests
mysql-test/t/events.test:
  new tests for information_schema.events
scripts/mysql_create_system_tables.sh:
  change the PK of mysql.event to (definer, db, name)
scripts/mysql_fix_privilege_tables.sql:
  change the PK of mysql.event to (definer, db, name)
sql/event.cc:
  pass around the definer of the event because of the new PK
  which is (definer, db, name). It's needed for index searching.
sql/event.h:
  - make enum evex_table_field again public so it can be used
  in sql_show.cc
  - make created and modified ulonglong, because they should be such
  - make public evex_open_event_table so it can be used in sql_show.cc
sql/event_executor.cc:
  - cosmetics
sql/event_priv.h:
  - moved enum evex_table_field and evex_open_event_table()
    to event.h (made them therefore public)
sql/event_timed.cc:
  - in event_timed::init_definer() always fill this.definer with
    the concatenated value of definer_user@definer_host. Makes
    later the work easier.
  - pass around the definer wherever is needed for searching 
    (new prototype of evex_db_find_evex_aux)
sql/mysqld.cc:
  - add counter for SHOW EVENTS
sql/sql_lex.h:
  - register SHOW EVENTS as command
sql/sql_parse.cc:
  - handle SCH_EVENTS (I_S.EVENTS like SCH_TRIGGERS)
  - make additional check in case of SHOW EVENTS (check for EVENT on
    the current database. if it is null check_access() gives appropriate
    message back.
sql/sql_show.cc:
  - add INFORMATION_SCHEMA.EVENTS and SHOW EVENTS
  - I_S.EVENTS.SQL_MODE is NULL for now -> not implemented. Trudy
    asked to be added so bug #16642 can be completely closed. There
    is another bug report which will fix the lack of storage of
    SQL_MODE during event creation.
sql/sql_yacc.yy:
  - always call event_timed::init_definer() when CREATE/ALTER/DROP
    EVENT but not when just compiling the body of the event because
    in this case this operation is not needed, it takes memory and
    CPU time and at the end the result is not used. event_timed::definer
    is used only on SQLCOM_CREATE/ALTER/DROP_EVENT execution not on
    statement compilation.
  - add SHOW [FULL] EVENTS [FROM db] [LIKE pattern]
    in case of FULL and the user has PROCESS privilege then he will see
    also others' events in the current database, otherwise the output
    is the same as of SHOW EVENTS. Because the events are per DB only
    the events from the current database are shown. pattern is applied
    against event name. FROM db is self explanatory.
sql/table.h:
  add SCH_EVENTS as part of INFORMATION_SCHEMA
2006-01-30 13:15:23 +01:00
unknown
ab88a598ca Windows compile fixes in preparation for 5.1.6 beta.
VC++Files/client/mysqldump.vcproj:
  Add missing source file.
VC++Files/mysql.sln:
  Fix configuration mismatch.
VC++Files/sql/mysqld.vcproj:
  Enable row-based replication.
  Add missing source files.
scripts/make_win_src_distribution.sh:
  Add copying of missing directory.
sql/event.h:
  Fix type conflict only visible on Windows.
sql/event_executor.cc:
  Fix non-portable thread stuff.
sql/event_timed.cc:
  Fix type conflict only visible on Windows.
sql/ha_archive.cc:
  Add cast needed for Windows.
sql/handler.h:
  Fix Windows byte * <-> char * mismatch.
sql/opt_range.cc:
  Fix Windows byte * <-> char * mismatch.
sql/set_var.cc:
  BUG#16811
  Fix Windows compilation by making the cast-away of volatile implicit
  (Windows linker does not like volatile <-> non-volatile mismatch, in
  contrast to Unix)
sql/sql_partition.cc:
  Fix Windows byte * <-> char * mismatch.
2006-01-30 13:09:08 +01:00
unknown
ea09d626a5 Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into lmy004.:/work/mysql-5.1-tt-copy-works


sql/event.cc:
  Auto merged
sql/event_executor.cc:
  Auto merged
sql/event_timed.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2006-01-23 16:13:46 +01:00
unknown
3a8e50e082 fix for bug#16431 (Events: An event which alters itself disappears)
WL#1034 (Internal CRON)


mysql-test/r/events.result:
  add a test for to test bug #16431
mysql-test/t/events.test:
  results of new tests
sql/event.cc:
  - more debug info
  - pass info to evex_remove_from_cache() whether the operation 
    was drop or alter. this fixes possible bug that may lead to dropping
    of an event when it's altered. also fix for bug#16431
sql/event_executor.cc:
  be more verbose and throw more errors
sql/event_timed.cc:
  - add ` around the names of the db and the event_name and not
  their concatenation. remove ; from the end - unneeded. this fixes bug #16431,
  which was failing because after some recursion the query was ending on ;;
  which is normally an error in the parser because that's the delimiter
  
  - more debug info
  - don't execute lex_end() two times when there's a parse error or thd->is_fatal_error
2006-01-20 22:24:58 +01:00
unknown
6bd58a2a3c - fix bug #16435 (Weekly events execute every second) (WL#1034 Internal CRON)
Before the interval expression was considered to be in seconds, now it is
just a number and the type of interval is considered.

- this changeset introduces also fix for bug#16432 (Events: error re interval
  misrepresents the facts)
  the code of event_timed::set_interval() was refactored anyway so it is meaningful to
  fix the bug in the same changeset.


include/my_time.h:
  - move enum interval_type to include/my_time.h so it can be used by functions
    in the whole server
sql/event.cc:
  - don't use second_part
  - fix small problem with create event xyz, when xyz exists -> make it error
    instead of warning if create_if_not is false.
sql/event.h:
  pass thd to mark_last_executed() to be able to call thd->end_time()
sql/event_executor.cc:
  - pass thd to event_timed::compute_next_execution_time()
  - a bit more DBUG info in the server log
  - handle error returned by event_timed::compute_next_execution_time()
sql/event_priv.h:
  - define the maximal possible value for interval_value
sql/event_timed.cc:
  - more docs
  - add static get_next_time() which sums a TIME with an interval
  - fix bug #16435 (Weekly events execute every second)
  Before the interval expression was considered to be in seconds, now it is
  just a number and the type of interval is considered.
  - fix for bug#16432 (Events: error re interval misrepresents the facts)
    (return an error if a value is too big or is negative - errmsg changed)
sql/item_timefunc.cc:
  - export get_interval_date()
  - refactor Item_date_add_interval::get_date() and extract the core
    to date_add_interval() in time.cc so it can be reused by the
    scheduler code in event_timed.cc
sql/item_timefunc.h:
  - export get_interval_value() so it can be reused in event_timed.cc in
    function static get_next_time()
  - move enum interval_type to include/my_time.h so it can be used by functions
    in the whole server
sql/mysql_priv.h:
  export the new function date_add_interval() added to time.cc
sql/share/errmsg.txt:
  - change error message to be appropriate as fix for bug#16432
    (Events: error re interval misrepresents the facts)
sql/sql_yacc.yy:
  - change error message to be appropriate as fix for bug#16432
    (Events: error re interval misrepresents the facts)
sql/time.cc:
  extract the core of Item_date_add_interval::get_date()
  to a function per Serg's request. The code can be reused
  to add und substract interval from a date.
2006-01-18 20:41:22 +01:00
unknown
eb2012034c WL #1034 (Internal CRON) post-push update
- fix compile failure on QNX and FreeBSD


sql/event_executor.cc:
  time_t and my_time_t seem have the same length so cast
  in tztime.cc it's already done this way.
  Precautionary check at runtime about the sizes of my_time_t and time_t
sql/event_timed.cc:
  do time_t* cast to satisfy compilers on various platforms
  (QNX, FreeBSD)
2006-01-12 16:51:45 +01:00
unknown
af6d402627 WL #1034
- add a bit more debug messages
- disable events.test for now due to a bug


mysql-test/r/events.result:
  fix result
mysql-test/t/disabled.def:
  make it disabled
mysql-test/t/events.test:
  disable show processlist
sql/event_executor.cc:
  a bit more debug messages
2006-01-11 19:31:21 +01:00
unknown
2fc956fae9 WL #1034 (Internal CRON) pre-push updates
- various fixes of test cases
(hopefully the last pre-push update before the push)


mysql-test/include/system_db_struct.inc:
  extend test case to include testing for event system table
mysql-test/r/events.result:
  results of events test
mysql-test/r/system_mysql_db.result:
  more testing - add structure of event system table
mysql-test/t/events.test:
  test case for events (internal CRON)
mysql-test/t/system_mysql_db_fix.test:
  drop event table and leave the test database empty
scripts/mysql_create_system_tables.sh:
  add missing create table statement
scripts/mysql_fix_privilege_tables.sql:
  don't specify the database. this fixes a failing test case which creates the
  tables not on mysql but on a test database and then tests again mysql.
sql/event_executor.cc:
  if asked to stop -> stop.
2006-01-11 18:09:05 +01:00
unknown
f133a92312 WL 1034 update
(pre-push cleanups removing debugging code)


sql/event.cc:
  - comment
  - fix 80 cols
  - fix a crash when dropping a running event (after it has finished
    its work because the memory got freed in remove_from_cache but the event
    was still running)
sql/event.h:
  - add new method
sql/event_executor.cc:
  - remove printf-s
  - fix 80cols
  - fix message
2006-01-10 11:31:45 +01:00
unknown
3a12408a70 WL #1034 (update)
- improve the stability of the executor
- make create event if not exists work as before


sql/event.cc:
  refactoring:
  - have only 1 routine for comparing TIME structures 
  fix:
  - after previous refactoring IF NOT EXISTS of CREATE EVENT did not work 
    anymore. Now it will work.
sql/event.h:
  update definitions
sql/event_executor.cc:
  - don't load DISABLED events
  - if an event is being disabled because of time restrictions - drop it from the 
    prio queue
  - move dropping to the worker process
sql/event_priv.h:
  - remove unneeded func
sql/share/errmsg.txt:
  fix error message
sql/sql_parse.cc:
  - support 0 rows affected when CREATE EVENT IF NOT EXISTS
2005-12-28 12:07:57 +02:00
unknown
9b323387b8 WL #1034 update
- fix one bug found by PeterG, namely bug #51

#there is a major problem currently after removing the specialised DYNAMIC_ARRAY as 
  storage for the events. I have to reintroduce similar storage, this time probably some
  linked list or maybe some API on top of DYNAMIC_ARRAY.


sql/event.cc:
  close the table
sql/event.h:
  change definition
sql/event_executor.cc:
  don't start the thread in advance
sql/event_timed.cc:
  - don't call evex_drop_event
  - quote the name during compilation to make create event `the rain in spain goes into the drain` not fail.
2005-12-20 14:21:02 +02:00
unknown
7634f7d60c WL #1034 update
- handle crashes where the table definition has been changed
  (different number of fields)


sql/event.cc:
  change the way table is opened
  check whether the number of fields is exact, otherwise report damaged table
sql/event_executor.cc:
  - move around some code
  - use the new way of table opening
sql/event_priv.h:
  - new declaration
sql/event_timed.cc:
  - now 0 is ok
2005-12-16 12:42:39 +01:00
unknown
48405ec751 WL#1034 update
- fix EVENT_ACL problem that GRANT ALL on some_db.* to someone@somewhere did not get to mysql.db
- fix crash when the following is executed :
  CREATE EVENT P() CREATE EVENT E ON SCHEDULER 1 SECOND DO ROLLBACK;
  (creation works as well as calling P() which creates the event).


mysql-test/lib/init_db.sql:
  - fix init_db.sql so add Event_priv to the database privs, many tests failed because of that
    ommision
  - remove the quotes from the column names
mysql-test/t/events.test:
  - fix the small test, don't create own db
scripts/mysql_fix_privilege_tables.sql:
  - fix that
sql/event.cc:
  - be defensive and don't crash if outside has already has opened some table
sql/event_executor.cc:
  - show in SHOW PROCESSLIST - "event_scheduler" as name of the user of the main thread
  - use "localhost" as the host where event_scheduler comes from
  - comment out some debug info, fix other debug info
sql/event_timed.cc:
  - enable EVENT creation inside SP. sphead from lex->sphead goes to et->sphead. it's there only
    if we compile the event. OTOH when doing 
    CREATE PROCEDURE PROC() CREATE EVENT SOME_EV ON SCHEDULE EVERY 1 SECOND DO ROLLBACK;
    I have only to get the body of the event which is anonymous SP. Before it being "compiled"
    but then freed without being used because a bit later it is compiled one more time before
    being put in the events cache. So it was good that the memory structures weren't reused but
    scrapped out. Now lex->sphead is not needed during event creation but only where the event's
    body starts and where it ends so to be able at later stage to compile this anonymous SP (the
    body of the event).
sql/sp_head.cc:
  - copy over a fix to a crash
sql/sql_acl.h:
  - fix privileges.
    There was _NO_ documentation about that. Another CHUNK had to be created to so EVENT_ACL gets shifted to
    it's place in the db table. So how this is calculated? EVENT_ACL is 1 << 26. Remember 26, see which poistion
    in the db table is EVENT_ACL, it's 17, counted from 0. 26 - 17 = 9, then shift it with 9.
    CHUNKS are created because in some cases some privileges are in chunks and they are shifted at once. There are
    few chunks of such privileges which has to be shifted to get to exactly the structure of mysql.db table.
sql/sql_parse.cc:
  - ok, we don't care anymore about lex->sphead because our sphead is lex->et->sphead
sql/sql_yacc.yy:
  - bail out if new event_timed returns 0x0
  - enable creation of an event inside a SP
    CREATE PROCEDURE P() CREATE EVENT E ON SCHEDULE EVERY 1 SECOND DO SELECT 1;
2005-12-15 14:12:28 +01:00
unknown
d22bb45cce WL#1034 (update)
- fixed silly bug, the main thread restarted but did not execute events,
  Quite currious why many calls to pthread_mutex_init() do not lead to abort()


sql/event.cc:
  - remove mysql_event_table_exists
  - fix possible crash when table is 0x0
sql/event_executor.cc:
  - make event_executor_running_global_var volatile
  - fix erroneous reinitilization of a mutex, why did it not crash in debug mode?
    why pthread_mutex_init() does not abort() in case the mutex was not deinitted
    beforehand?
  - first initialization of event_executor_running_global_var inside init_mutexes()
  - remove debug if()
sql/event_priv.h:
  - remove unneeded definitions
sql/event_timed.cc:
  make backup and then restore the open table state of thd
2005-12-13 23:10:29 +01:00
unknown
f92086d074 WL#1034 update
(cleanups, leaks fixed)


sql/event.cc:
  - update comments
  - remove dead code
  - event_timed is no more copied after allocation on a DYNAMIC_ARRAY
    because there is a problem when the array is reallocated - we get
    dangling pointers from the scheduling queue. anyway it makes little
    sense to keep them there except that cleaning is quite efficient but
    iterating over all events and cleaning them one by one is not that bad
    considering that happens only when the main scheduler thread is killed
    or during server shutdown.
sql/event_executor.cc:
  - DYNAMIC_ARRAY is no more
sql/event_priv.h:
  - remove unneeded code/defines. the scheduler's queue is of 
    type QUEUE and cannot run anymore on top of DYNAMIC_ARRAY
sql/event_timed.cc:
  - after parsing (in ::compile() ) destruct the event_timed object
sql/sql_parse.cc:
  in case of syntax error clean up lex->et because there could be an object
  created. as in the code the same is done for SPs.
2005-12-13 19:16:00 +01:00
unknown
112d408fe7 WL#1034 update
cleanup before throwin away DYNAMIC_ARRAY for event storage,
once reallocated I get dangling pointers so that's not good.
solution will be found however ;)


sql/event.cc:
  - remove unneeded variables
  - remove commented out code
  - remove non-cs compliant comment
  - fix a bug when removing from memory cache
  - better close the tables than relying on sql_parse.cc::do_command()
    to do that
sql/event_executor.cc:
  - cleanup
sql/event_priv.h:
  -cleanup
sql/event_timed.cc:
  cleanup
2005-12-13 13:21:11 +01:00
unknown
81eadfcac1 WL#1034 update
QUEUE implementation working now. this should be ready more or less
for testing once the debug output is being cleaned and some things
around DYNAMIC_ARRAY are cleaned
- fix handling in case of errors that lead to crashes, now no more crashes
  in case of table corruption and such.


include/queues.h:
  introduce a safe version of queue_insert that will extend the queue if
  necessary. the auto_extent is passed to the _ex version of init_queue()
mysys/queues.c:
  add init_queue_ex() implementation
  add queue_insert_safe() implementation
sql/event.cc:
  - move mysql_priv.h inclusion to event_priv.h
  - use a priority queue instead of DYNAMIC_ARRAY which is sorted
sql/event.h:
  reorder
sql/event_executor.cc:
  reorder
sql/event_priv.h:
  - reorder a bit
  - add macroses and functions for queue manipulation which stay on top
   of QUEUE (partly implemented for DYNAMIC_ARRAY but will be cleared to be
   only for QUEUE).
sql/event_timed.cc:
  allocate one more byte and zeroterminate, really
2005-12-12 21:19:19 +01:00
unknown
1c5573a47c WL #1034 update
- handle better non-latin1 identifiers


sql/event.cc:
  - introduce a wrapper to compare easily and correctly
  LEX_STRINGs
  - remove few unneeded variables
  - remove need_second_pass by restructuring the code. this brings
    performance boost because the code bails out from the loop once
    it hits what it looks for
  - handle ALTER EVENT name RENAME TO name  (throw an error message).
sql/event_executor.cc:
  - comment about DBUG_FAULTY_THR
  - indent fix
sql/event_timed.cc:
  - fix a problem when event name is not latin1. a cyrillic event name
    was crashing the parser so the I emulate SET NAMES utf8. The data is
    already in utf8, being loaded from the disk.
sql/share/errmsg.txt:
  add new error message
2005-12-08 20:37:54 +01:00
unknown
faa8995e7a WL #1034 updates after review
(strip m_ as prefix from member variables' names)


sql/event.cc:
  - change copyright years
  - remove m_ prefix from member variables (I liked m_)
  - reorder parameter in evex_update_event()
sql/event.h:
  - change copyright years
  - remove m_ prefix from member variables
  - declare some member variables as private (were public)
  - delete 0 is valid in C++ therefore don't embrace with if()
sql/event_executor.cc:
  - executor => scheduler in messages
  - fix a bug introduced in last commit -> typo in a mutex name
  - remove m_ prefix from member variables
sql/event_priv.h:
  - change copyright years
sql/event_timed.cc:
  - change copyright years
  - strip m_ as prefix from member variables' names
sql/sql_parse.cc:
  - strip m_ as prefix from member variables' names
sql/sql_yacc.yy:
  - strip m_ as prefix from member variables names
2005-12-08 00:17:05 +01:00
unknown
a4bcbd51d9 WL #1034 updates after review
sql/event.cc:
  - fix TODO (remove things already done)
  - check the length of the event's name and body during creation
    and report an error if longer than what can be fit into 
    mysql.event (nothing like non-strict mode here)
  - report to sql_parse.cc and error when open table failed, otherwise send_ok()
    was being called and the error have become an warning.
  - update function documentation a bit
  - evex_db_find_routine_aux returns 0 and not EVEX_OK
sql/event_executor.cc:
  - CS changes to definitions of the main and worker thread routines
  - reorder code a bit to prevent crashes because of reading of
    already freed data -> first wait all events to finish their work,
    namely all worker threads to finish, and then destroy in-memory
    structures
  - more error checking and error reporting at the place of failure.
sql/event_priv.h:
  code simplifying macro
sql/event_timed.cc:
  CS cosmetics
2005-12-07 22:29:00 +01:00
unknown
bc3708a5b9 WL#1034 ongoing updates after review
sql/event.cc:
  -my_error() as close as possible to the place where the error
   occurs.
  -a thought how to replicate events
  -use close_thread_tables() in some cases and for others rely on
   this call being done in sql_parse.cc::do_command()
sql/event.h:
  remove redundant defines
sql/event_executor.cc:
  - reenable the compilation again
  - don't backup the open_tables_state, it's not needed
sql/event_timed.cc:
  - inline a bit
  - comment added
sql/mysqld.cc:
  - start mysqld with --event-scheduler=0 by default
sql/share/errmsg.txt:
  3 new messages
sql/sql_parse.cc:
  remove now obsolete error checking - the errors are reported
  as closer as possible to the place where they are detected
sql/sql_yacc.yy:
  add WARNING message. fix a bug that was corrupting 
  thd->client_capabilites ->
  select count(*) from mysql.event
  was reporting : "Unknown table test.event"!!!
  Using temporal variable is nice but IMO quite error-prone.
2005-12-07 19:26:44 +01:00
unknown
70856a0d54 WL#1034
updated sources


sql/event.cc:
  update
  put some error calls to the places they occur
sql/event.h:
  - change the default (does not work in STRICT mode)
sql/event_executor.cc:
  move mutex initialization to evex_init_mutexes so init_events() can be reused when the
  main thread does not work and set global event_scheduler=1; (this will start the thread)
  The main thread is now visible with show processlist and can be killed.
sql/event_priv.h:
  don't use anymore SP for opening table
sql/event_timed.cc:
  don't use anymore SP routines for opening mysql.event
sql/mysqld.cc:
  shutdown_events() should be maximal at the end of the server because
  it destroys mutexes of EVEX. The call should not be in the main thread.
sql/set_var.cc:
  make sys_var_event_executor subclass sys_var_bool_ptr
  to overload ::update() method - needed to start a
  killed (non-running) evex main thread
sql/set_var.h:
  declare class sys_var_event_executor
sql/share/errmsg.txt:
  2 new messages
2005-12-06 16:15:29 +01:00
unknown
7ff7977105 WL#1034 updated
- split into several files
- forbid parallel execution (before analyse is done how to make it possible)
  because the same sp_head instance cannot be executed in parallel
- added GPL headers
- changed EVENT_ACL to be per DB variable
- fixed minor problems


mysql-test/lib/init_db.sql:
  WL#1034 updated
  - add Event_priv to mysql.user (update test)
  - add updated mysql.event table struct
scripts/mysql_fix_privilege_tables.sql:
  WL#1034 updated
  add updated mysql.event structure
sql/Makefile.am:
  split event.cc into
  - event.cc (create/alter/drop)
  - event_executor.cc (main and worker threads)
  - event_timed.cc (class event_timed)
  - event_priv.h (some definitions used internally by the module)
sql/event.cc:
  - added GPL header
  - split into few files
  - fixed some issues after code review
  - now using SP routines for opening/traversing/closing tables
    (will be reverted)
sql/event.h:
  - add GPL header
  - remove two methods - inline them in sql_yacc.yy 
  - don't use absolute values for EVEX_ defines but the SP_ equivalents (have to move 100% to SP_
    defines and as later step to not transfer messages upwards in the stack but
    report them at the place they occur)
  - updated reference table definition
  - move default mem_root param from event.cc to the header
sql/mysqld.cc:
  WL#1034
  rename --event-executor to --event-scheduler
  executor sounds a bit scary :)
sql/set_var.cc:
  rename internal variable name from event_executor to event_scheduler
  (ppl won't be scarried anymore :)
sql/share/errmsg.txt:
  omit one %s - not needed
sql/sp_head.cc:
  disable this DBUG_PRINT for a bit. m_next_cached_sp is 0x0 and I get crash here...
sql/sp_head.h:
  remove m_old_cmq, a temporal variable is used in sql_yacc.yy (Serg's idea)
  to keep the previous state.
  $<ulong_val>$ =  ....
  
  YYTHD->client_capabilites != $<ulong_val>4;
  
  (the same is done also for class event_timed)
sql/sql_acl.cc:
  handle pre-5.1.4 table and give the user EVENT_ACL if he had CREATE_ACL
sql/sql_acl.h:
  fix the bitmask
sql/sql_parse.cc:
  - move from EVENT_ACL being global to EVENT_ACL being per DB like
    CREATE_PROC_ACL
  - lex->m_qname dropped, because not needed, fix code therefore
  - add comment that SHOW CREATE EVENT has to be implemented
sql/sql_yacc.yy:
  - use temporal variable of Bison to store a short lived value
  - fix indentation
  - inline 2 class event_timed methods in the parser
sql/tztime.h:
  be more expressive - it's already extern
2005-12-05 11:45:04 +01:00