Commit graph

41 commits

Author SHA1 Message Date
Monty
5a759d31f7 Changing field::field_name and Item::name to LEX_CSTRING
Benefits of this patch:
- Removed a lot of calls to strlen(), especially for field_string
- Strings generated by parser are now const strings, less chance of
  accidently changing a string
- Removed a lot of calls with LEX_STRING as parameter (changed to pointer)
- More uniform code
- Item::name_length was not kept up to date. Now fixed
- Several bugs found and fixed (Access to null pointers,
  access of freed memory, wrong arguments to printf like functions)
- Removed a lot of casts from (const char*) to (char*)

Changes:
- This caused some ABI changes
  - lex_string_set now uses LEX_CSTRING
  - Some fucntions are now taking const char* instead of char*
- Create_field::change and after changed to LEX_CSTRING
- handler::connect_string, comment and engine_name() changed to LEX_CSTRING
- Checked printf() related calls to find bugs. Found and fixed several
  errors in old code.
- A lot of changes from LEX_STRING to LEX_CSTRING, especially related to
  parsing and events.
- Some changes from LEX_STRING and LEX_STRING & to LEX_CSTRING*
- Some changes for char* to const char*
- Added printf argument checking for my_snprintf()
- Introduced null_clex_str, star_clex_string, temp_lex_str to simplify
  code
- Added item_empty_name and item_used_name to be able to distingush between
  items that was given an empty name and items that was not given a name
  This is used in sql_yacc.yy to know when to give an item a name.
- select table_name."*' is not anymore same as table_name.*
- removed not used function Item::rename()
- Added comparision of item->name_length before some calls to
  my_strcasecmp() to speed up comparison
- Moved Item_sp_variable::make_field() from item.h to item.cc
- Some minimal code changes to avoid copying to const char *
- Fixed wrong error message in wsrep_mysql_parse()
- Fixed wrong code in find_field_in_natural_join() where real_item() was
  set when it shouldn't
- ER_ERROR_ON_RENAME was used with extra arguments.
- Removed some (wrong) ER_OUTOFMEMORY, as alloc_root will already
  give the error.

TODO:
- Check possible unsafe casts in plugin/auth_examples/qa_auth_interface.c
- Change code to not modify LEX_CSTRING for database name
  (as part of lower_case_table_names)
2017-04-23 22:35:46 +03:00
Monty
7b96416f3c Use sql_mode_t for sql_mode.
This fixed several cases where we where using just ulong for sql_mode
2016-10-05 01:11:08 +03:00
Sergei Golubchik
fe0ff58000 compiler warnings 2014-10-01 23:38:26 +02:00
Sergei Golubchik
0e007344ea mysql-5.5.18 merge 2011-11-03 19:17:05 +01:00
Sergei Golubchik
9809f05199 5.5-merge 2011-07-02 22:08:51 +02:00
Kent Boortz
02e07e3b51 Updated/added copyright headers 2011-06-30 17:46:53 +02:00
Sergei Golubchik
65ca700def merge.
checkpoint.
does not compile.
2010-11-25 18:17:28 +01:00
Dmitry Lenev
6bf6272fda Patch that refactors global read lock implementation and fixes
bug #57006 "Deadlock between HANDLER and FLUSH TABLES WITH READ
LOCK" and bug #54673 "It takes too long to get readlock for
'FLUSH TABLES WITH READ LOCK'".

The first bug manifested itself as a deadlock which occurred
when a connection, which had some table open through HANDLER
statement, tried to update some data through DML statement
while another connection tried to execute FLUSH TABLES WITH
READ LOCK concurrently.

What happened was that FTWRL in the second connection managed
to perform first step of GRL acquisition and thus blocked all
upcoming DML. After that it started to wait for table open
through HANDLER statement to be flushed. When the first connection
tried to execute DML it has started to wait for GRL/the second
connection creating deadlock.

The second bug manifested itself as starvation of FLUSH TABLES
WITH READ LOCK statements in cases when there was a constant
stream of concurrent DML statements (in two or more
connections).

This has happened because requests for protection against GRL
which were acquired by DML statements were ignoring presence of
pending GRL and thus the latter was starved.

This patch solves both these problems by re-implementing GRL
using metadata locks.

Similar to the old implementation acquisition of GRL in new
implementation is two-step. During the first step we block
all concurrent DML and DDL statements by acquiring global S
metadata lock (each DML and DDL statement acquires global IX
lock for its duration). During the second step we block commits
by acquiring global S lock in COMMIT namespace (commit code
acquires global IX lock in this namespace).

Note that unlike in old implementation acquisition of
protection against GRL in DML and DDL is semi-automatic.
We assume that any statement which should be blocked by GRL
will either open and acquires write-lock on tables or acquires
metadata locks on objects it is going to modify. For any such
statement global IX metadata lock is automatically acquired
for its duration.

The first problem is solved because waits for GRL become
visible to deadlock detector in metadata locking subsystem
and thus deadlocks like one in the first bug become impossible.

The second problem is solved because global S locks which
are used for GRL implementation are given preference over
IX locks which are acquired by concurrent DML (and we can
switch to fair scheduling in future if needed).

Important change:
FTWRL/GRL no longer blocks DML and DDL on temporary tables.
Before this patch behavior was not consistent in this respect:
in some cases DML/DDL statements on temporary tables were
blocked while in others they were not. Since the main use cases
for FTWRL are various forms of backups and temporary tables are
not preserved during backups we have opted for consistently
allowing DML/DDL on temporary tables during FTWRL/GRL.

Important change:
This patch changes thread state names which are used when
DML/DDL of FTWRL is waiting for global read lock. It is now
either "Waiting for global read lock" or "Waiting for commit
lock" depending on the stage on which FTWRL is.

Incompatible change:
To solve deadlock in events code which was exposed by this
patch we have to replace LOCK_event_metadata mutex with
metadata locks on events. As result we have to prohibit
DDL on events under LOCK TABLES.

This patch also adds extensive test coverage for interaction
of DML/DDL and FTWRL.

Performance of new and old global read lock implementations
in sysbench tests were compared. There were no significant
difference between new and old implementations.

mysql-test/include/check_ftwrl_compatible.inc:
  Added helper script which allows to check that a statement is
  compatible with FLUSH TABLES WITH READ LOCK.
mysql-test/include/check_ftwrl_incompatible.inc:
  Added helper script which allows to check that a statement is
  incompatible with FLUSH TABLES WITH READ LOCK.
mysql-test/include/handler.inc:
  Adjusted test case to the fact that now DROP TABLE closes
  open HANDLERs for the table to be dropped before checking
  if there active FTWRL in this connection.
mysql-test/include/wait_show_condition.inc:
  Fixed small error in the timeout message. The correct name
  of variable used as parameter for this script is "$condition"
  and not "$wait_condition".
mysql-test/r/delayed.result:
  Added test coverage for scenario which triggered assert in
  metadata locking subsystem.
mysql-test/r/events_2.result:
  Updated test results after prohibiting event DDL operations
  under LOCK TABLES.
mysql-test/r/flush.result:
  Added test coverage for bug #57006 "Deadlock between HANDLER
  and FLUSH TABLES WITH READ LOCK".
mysql-test/r/flush_read_lock.result:
  Added test coverage for various aspects of FLUSH TABLES WITH
  READ LOCK functionality.
mysql-test/r/flush_read_lock_kill.result:
  Adjusted test case after replacing custom global read lock
  implementation with one based on metadata locks. Use new
  debug_sync point. Do not disable concurrent inserts as now
  InnoDB we always use InnoDB table.
mysql-test/r/handler_innodb.result:
  Adjusted test case to the fact that now DROP TABLE closes
  open HANDLERs for the table to be dropped before checking
  if there active FTWRL in this connection.
mysql-test/r/handler_myisam.result:
  Adjusted test case to the fact that now DROP TABLE closes
  open HANDLERs for the table to be dropped before checking
  if there active FTWRL in this connection.
mysql-test/r/mdl_sync.result:
  Adjusted test case after replacing custom global read lock
  implementation with one based on metadata locks. Replaced
  usage of GRL-specific debug_sync's with appropriate sync
  points in MDL subsystem.
mysql-test/suite/perfschema/r/dml_setup_instruments.result:
  Updated test results after removing global
  COND_global_read_lock condition variable.
mysql-test/suite/perfschema/r/func_file_io.result:
  Ensure that this test doesn't affect subsequent tests.
  At the end of its execution enable back P_S instrumentation
  which this test disables at some point.
mysql-test/suite/perfschema/r/func_mutex.result:
  Ensure that this test doesn't affect subsequent tests.
  At the end of its execution enable back P_S instrumentation
  which this test disables at some point.
mysql-test/suite/perfschema/r/global_read_lock.result:
  Adjusted test case to take into account that new GRL
  implementation is based on MDL.
mysql-test/suite/perfschema/r/server_init.result:
  Adjusted test case after replacing custom global read
  lock implementation with one based on MDL and replacing
  LOCK_event_metadata mutex with metadata lock.
mysql-test/suite/perfschema/t/func_file_io.test:
  Ensure that this test doesn't affect subsequent tests.
  At the end of its execution enable back P_S instrumentation
  which this test disables at some point.
mysql-test/suite/perfschema/t/func_mutex.test:
  Ensure that this test doesn't affect subsequent tests.
  At the end of its execution enable back P_S instrumentation
  which this test disables at some point.
mysql-test/suite/perfschema/t/global_read_lock.test:
  Adjusted test case to take into account that new GRL
  implementation is based on MDL.
mysql-test/suite/perfschema/t/server_init.test:
  Adjusted test case after replacing custom global read
  lock implementation with one based on MDL and replacing
  LOCK_event_metadata mutex with metadata lock.
mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL.result:
  Updated test results after prohibiting event DDL under
  LOCK TABLES.
mysql-test/t/delayed.test:
  Added test coverage for scenario which triggered assert in
  metadata locking subsystem.
mysql-test/t/events_2.test:
  Updated test case after prohibiting event DDL operations
  under LOCK TABLES.
mysql-test/t/flush.test:
  Added test coverage for bug #57006 "Deadlock between HANDLER
  and FLUSH TABLES WITH READ LOCK".
mysql-test/t/flush_block_commit.test:
  Adjusted test case after changing thread state name which
  is used when COMMIT waits for FLUSH TABLES WITH READ LOCK
  from "Waiting for release of readlock" to "Waiting for commit
  lock".
mysql-test/t/flush_block_commit_notembedded.test:
  Adjusted test case after changing thread state name which is
  used when DML waits for FLUSH TABLES WITH READ LOCK. Now we
  use "Waiting for global read lock" in this case.
mysql-test/t/flush_read_lock.test:
  Added test coverage for various aspects of FLUSH TABLES WITH
  READ LOCK functionality.
mysql-test/t/flush_read_lock_kill-master.opt:
  We no longer need to use make_global_read_lock_block_commit_loop
  debug tag in this test. Instead we rely on an appropriate
  debug_sync point in MDL code.
mysql-test/t/flush_read_lock_kill.test:
  Adjusted test case after replacing custom global read lock
  implementation with one based on metadata locks. Use new
  debug_sync point. Do not disable concurrent inserts as now
  InnoDB we always use InnoDB table.
mysql-test/t/lock_multi.test:
  Adjusted test case after changing thread state names which
  are used when DML or DDL waits for FLUSH TABLES WITH READ
  LOCK to "Waiting for global read lock".
mysql-test/t/mdl_sync.test:
  Adjusted test case after replacing custom global read lock
  implementation with one based on metadata locks. Replaced
  usage of GRL-specific debug_sync's with appropriate sync
  points in MDL subsystem. Updated thread state names which
  are used when DDL waits for FTWRL.
mysql-test/t/trigger_notembedded.test:
  Adjusted test case after changing thread state names which
  are used when DML or DDL waits for FLUSH TABLES WITH READ
  LOCK to "Waiting for global read lock".
sql/event_data_objects.cc:
  Removed Event_queue_element::status/last_executed_changed
  members and Event_queue_element::update_timing_fields()
  method. We no longer use this class for updating mysql.events
  once event is chosen for execution. Accesses to instances of
  this class in scheduler thread require protection by
  Event_queue::LOCK_event_queue mutex and we try to avoid
  updating table while holding this lock.
sql/event_data_objects.h:
  Removed Event_queue_element::status/last_executed_changed
  members and Event_queue_element::update_timing_fields()
  method. We no longer use this class for updating mysql.events
  once event is chosen for execution. Accesses to instances of
  this class in scheduler thread require protection by
  Event_queue::LOCK_event_queue mutex and we try to avoid
  updating table while holding this lock.
sql/event_db_repository.cc:
  - Changed Event_db_repository methods to not release all
    metadata locks once they are done updating mysql.events
    table. This allows to keep metadata lock protecting
    against GRL and lock protecting particular event around
    until corresponding DDL statement is written to the binary
    log.
  - Removed logic for conditional update of "status" and
    "last_executed" fields from update_timing_fields_for_event()
    method. In the only case when this method is called now
    "last_executed" is always modified and tracking change
    of "status" is too much hassle.
sql/event_db_repository.h:
  Removed logic for conditional update of "status" and
  "last_executed" fields from Event_db_repository::
  update_timing_fields_for_event() method.
  In the only case when this method is called now "last_executed"
  is always modified and tracking change of "status" field is
  too much hassle.
sql/event_queue.cc:
  Changed event scheduler code not to update mysql.events
  table while holding Event_queue::LOCK_event_queue mutex.
  Doing so led to a deadlock with a new GRL implementation.
  This deadlock didn't occur with old implementation due to
  fact that code acquiring protection against GRL ignored
  pending GRL requests (which lead to GRL starvation).
  One of goals of new implementation is to disallow GRL
  starvation and so we have to solve problem with this
  deadlock in a different way.
sql/events.cc:
  Changed methods of Events class to acquire protection
  against GRL while perfoming DDL statement and keep it
  until statement is written to the binary log.
  Unfortunately this step together with new GRL implementation
  exposed deadlock involving Events::LOCK_event_metadata
  and GRL. To solve it Events::LOCK_event_metadata mutex was
  replaced with a metadata lock on event. As a side-effect
  events DDL has to be prohibited under LOCK TABLES even in
  cases when mysql.events table was explicitly locked for
  write.
sql/events.h:
  Replaced Events::LOCK_event_metadata mutex with a metadata
  lock on event.
sql/ha_ndbcluster.cc:
  Updated code after replacing custom global read lock
  implementation with one based on MDL. Since MDL subsystem
  should now be able to detect deadlocks involving metadata
  locks and GRL there is no need for special handling of
  active GRL.
sql/handler.cc:
  Replaced custom implementation of global read lock with
  one based on metadata locks. Consequently when doing
  commit instead of calling method of Global_read_lock
  class to acquire protection against GRL we simply acquire
  IX in COMMIT namespace.
sql/lock.cc:
  Replaced custom implementation of global read lock with
  one based on metadata locks. This step allows to expose
  wait for GRL to deadlock detector of MDL subsystem and
  thus succesfully resolve deadlocks similar to one behind
  bug #57006 "Deadlock between HANDLER and FLUSH TABLES
  WITH READ LOCK". It also solves problem with GRL starvation
  described in bug #54673 "It takes too long to get readlock
  for 'FLUSH TABLES WITH READ LOCK'" since metadata locks used
  by GRL give preference to FTWRL statement instead of DML
  statements (if needed in future this can be changed to
  fair scheduling).
  
  Similar to old implementation of acquisition of GRL is
  two-step. During the first step we block all concurrent
  DML and DDL statements by acquiring global S metadata lock
  (each DML and DDL statement acquires global IX lock for
  its duration). During the second step we block commits by
  acquiring global S lock in COMMIT namespace (commit code
  acquires global IX lock in this namespace).
  
  Note that unlike in old implementation acquisition of
  protection against GRL in DML and DDL is semi-automatic.
  We assume that any statement which should be blocked by GRL
  will either open and acquires write-lock on tables or acquires
  metadata locks on objects it is going to modify. For any such
  statement global IX metadata lock is automatically acquired
  for its duration.
  
  To support this change:
  - Global_read_lock::lock/unlock_global_read_lock and
    make_global_read_lock_block_commit methods were changed
    accordingly.
  - Global_read_lock::wait_if_global_read_lock() and
    start_waiting_global_read_lock() methods were dropped.
    It is now responsibility of code acquiring metadata locks
    opening tables to acquire protection against GRL by
    explicitly taking global IX lock with statement duration.
  - Global variables, mutex and condition variable used by
    old implementation was removed.
  - lock_routine_name() was changed to use statement duration for
    its global IX lock. It was also renamed to lock_object_name()
    as it now also used to take metadata locks on events.
  - Global_read_lock::set_explicit_lock_duration() was added which
    allows not to release locks used for GRL when leaving prelocked
    mode.
sql/lock.h:
  - Renamed lock_routine_name() to lock_object_name() and changed
    its signature to allow its usage for events.
  - Removed broadcast_refresh() function. It is no longer needed
    with new GRL implementation.
sql/log_event.cc:
  Release metadata locks with statement duration at the end
  of processing legacy event for LOAD DATA. This ensures that
  replication thread processing such event properly releases
  its protection against global read lock.
sql/mdl.cc:
  Changed MDL subsystem to support new MDL-based implementation
  of global read lock.
  
  Added COMMIT and EVENTS namespaces for metadata locks. Changed
  thread state name for GLOBAL namespace to "Waiting for global
  read lock".
  
  Optimized MDL_map::find_or_insert() method to avoid taking
  m_mutex mutex when looking up MDL_lock objects for GLOBAL
  or COMMIT namespaces. We keep pre-created MDL_lock objects
  for these namespaces around and simply return pointers to
  these global objects when needed.
  
  Changed MDL_lock/MDL_scoped_lock to properly handle
  notification of insert delayed handler threads when FTWRL
  takes global S lock.
  
  Introduced concept of lock duration. In addition to locks with
  transaction duration which work in the way which is similar to
  how locks worked before (i.e. they are released at the end of
  transaction), locks with statement and explicit duration were
  introduced.
  Locks with statement duration are automatically released at the
  end of statement. Locks with explicit duration require explicit
  release and obsolete concept of transactional sentinel.
  
  * Changed MDL_request and MDL_ticket classes to support notion
    of duration.
  * Changed MDL_context to keep locks with different duration in
    different lists. Changed code handling ticket list to take
    this into account.
  * Changed methods responsible for releasing locks to take into
    account duration of tickets. Particularly public
    MDL_context::release_lock() method now only can release
    tickets with explicit duration (there is still internal
    method which allows to specify duration). To release locks
    with statement or transaction duration one have to use
    release_statement/transactional_locks() methods.
  * Concept of savepoint for MDL subsystem now has to take into
    account locks with statement duration. Consequently
    MDL_savepoint class was introduced and methods working with
    savepoints were updated accordingly.
  * Added methods which allow to set duration for one or all
    locks in the context.
sql/mdl.h:
  Changed MDL subsystem to support new MDL-based implementation
  of global read lock.
  
  Added COMMIT and EVENTS namespaces for metadata locks.
  
  Introduced concept of lock duration. In addition to locks with
  transaction duration which work in the way which is similar to
  how locks worked before (i.e. they are released at the end of
  transaction), locks with statement and explicit duration were
  introduced.
  Locks with statement duration are automatically released at the
  end of statement. Locks with explicit duration require explicit
  release and obsolete concept of transactional sentinel.
  
  * Changed MDL_request and MDL_ticket classes to support notion
    of duration.
  * Changed MDL_context to keep locks with different duration in
    different lists. Changed code handling ticket list to take
    this into account.
  * Changed methods responsible for releasing locks to take into
    account duration of tickets. Particularly public
    MDL_context::release_lock() method now only can release
    tickets with explicit duration (there is still internal
    method which allows to specify duration). To release locks
    with statement or transaction duration one have to use
    release_statement/transactional_locks() methods.
  * Concept of savepoint for MDL subsystem now has to take into
    account locks with statement duration. Consequently
    MDL_savepoint class was introduced and methods working with
    savepoints were updated accordingly.
  * Added methods which allow to set duration for one or all
    locks in the context.
sql/mysqld.cc:
  Removed global mutex and condition variables which were used
  by old implementation of GRL.
  Also we no longer need to initialize Events::LOCK_event_metadata
  mutex as it was replaced with metadata locks on events.
sql/mysqld.h:
  Removed global variable, mutex and condition variables which
  were used by old implementation of GRL.
sql/rpl_rli.cc:
  When slave thread closes tables which were open for handling
  of RBR events ensure that it releases global IX lock which
  was acquired as protection against GRL.
sql/sp.cc:
  Adjusted code to the new signature of lock_object/routine_name(),
  to the fact that one now needs specify duration of lock when
  initializing MDL_request and to the fact that savepoints for MDL
  subsystem are now represented by MDL_savepoint class.
sql/sp_head.cc:
  Ensure that statements in stored procedures release statement
  metadata locks and thus release their protectiong against GRL
  in proper moment in time.
  Adjusted code to the fact that one now needs specify duration
  of lock when initializing MDL_request.
sql/sql_admin.cc:
  Adjusted code to the fact that one now needs specify duration
  of lock when initializing MDL_request.
sql/sql_base.cc:
  - Implemented support for new approach to acquiring protection
    against global read lock. We no longer acquire such protection
    explicitly on the basis of statement flags. Instead we always
    rely on code which is responsible for acquiring metadata locks
    on object to be changed acquiring this protection. This is
    achieved by acquiring global IX metadata lock with statement
    duration. Code doing this also responsible for checking that
    current connection has no active GRL by calling an
    Global_read_lock::can_acquire_protection() method.
    Changed code in open_table() and lock_table_names()
    accordingly.
    Note that as result of this change DDL and DML on temporary
    tables is always compatible with GRL (before it was
    incompatible in some cases and compatible in other cases).
  - To speed-up code acquiring protection against GRL introduced
    m_has_protection_against_grl member in Open_table_context
    class. It indicates that protection was already acquired
    sometime during open_tables() execution and new attempts
    can be skipped.
  - Thanks to new GRL implementation calls to broadcast_refresh()
    became unnecessary and were removed.
  - Adjusted code to the fact that one now needs specify duration
    of lock when initializing MDL_request and to the fact that
    savepoints for MDL subsystem are now represented by
    MDL_savepoint class.
sql/sql_base.h:
  Adjusted code to the fact that savepoints for MDL subsystem are
  now represented by MDL_savepoint class.
  Also introduced Open_table_context::m_has_protection_against_grl
  member which allows to avoid acquiring protection against GRL
  while opening tables if such protection was already acquired.
sql/sql_class.cc:
  Changed THD::leave_locked_tables_mode() after transactional
  sentinel for metadata locks was obsoleted by introduction of
  locks with explicit duration.
sql/sql_class.h:
  - Adjusted code to the fact that savepoints for MDL subsystem
    are now represented by MDL_savepoint class.
  - Changed Global_read_lock class according to changes in
    global read lock implementation:
    * wait_if_global_read_lock and start_waiting_global_read_lock
      are now gone. Instead code needing protection against GRL
      has to acquire global IX metadata lock with statement
      duration itself. To help it new can_acquire_protection()
      was introduced. Also as result of the above change
      m_protection_count member is gone too.
    * Added m_mdl_blocks_commits_lock member to store metadata
      lock blocking commits.
    * Adjusted code to the fact that concept of transactional
      sentinel was obsoleted by concept of lock duration.
  - Removed CF_PROTECT_AGAINST_GRL flag as it is no longer
    necessary. New GRL implementation acquires protection
    against global read lock automagically when statement
    acquires metadata locks on tables or other objects it
    is going to change.
sql/sql_db.cc:
  Adjusted code to the fact that one now needs specify duration
  of lock when initializing MDL_request.
sql/sql_handler.cc:
  Removed call to broadcast_refresh() function. It is no longer
  needed with new GRL implementation.
  Adjusted code after introducing duration concept for metadata
  locks. Particularly to the fact transactional sentinel was
  replaced with explicit duration.
sql/sql_handler.h:
  Renamed mysql_ha_move_tickets_after_trans_sentinel() to
  mysql_ha_set_explicit_lock_duration() after transactional
  sentinel was obsoleted by locks with explicit duration.
sql/sql_insert.cc:
  Adjusted code handling delaying inserts after switching to
  new GRL implementation. Now connection thread initiating
  delayed insert has to acquire global IX lock in addition
  to metadata lock on table being inserted into. This IX lock
  protects against GRL and similarly to SW lock on table being
  inserted into has to be passed to handler thread in order to
  avoid deadlocks.
sql/sql_lex.cc:
  LEX::protect_against_global_read_lock member is no longer
  necessary since protection against GRL is automatically
  taken by code acquiring metadata locks/opening tables.
sql/sql_lex.h:
  LEX::protect_against_global_read_lock member is no longer
  necessary since protection against GRL is automatically
  taken by code acquiring metadata locks/opening tables.
sql/sql_parse.cc:
  - Implemented support for new approach to acquiring protection
    against global read lock. We no longer acquire such protection
    explicitly on the basis of statement flags. Instead we always
    rely on code which is responsible for acquiring metadata locks
    on object to be changed acquiring this protection. This is
    achieved by acquiring global IX metadata lock with statement
    duration. This lock is automatically released at the end of
    statement execution.
  - Changed implementation of CREATE/DROP PROCEDURE/FUNCTION not
    to release metadata locks and thus protection against of GRL
    in the middle of statement execution.
  - Adjusted code to the fact that one now needs specify duration
    of lock when initializing MDL_request and to the fact that
    savepoints for MDL subsystem are now represented by
    MDL_savepoint class.
sql/sql_prepare.cc:
  Adjusted code to the to the fact that savepoints for MDL
  subsystem are now represented by MDL_savepoint class.
sql/sql_rename.cc:
  With new GRL implementation there is no need to explicitly
  acquire protection against GRL before renaming tables.
  This happens automatically in code which acquires metadata
  locks on tables being renamed.
sql/sql_show.cc:
  Adjusted code to the fact that one now needs specify duration
  of lock when initializing MDL_request and to the fact that
  savepoints for MDL subsystem are now represented by
  MDL_savepoint class.
sql/sql_table.cc:
  - With new GRL implementation there is no need to explicitly
    acquire protection against GRL before dropping tables.
    This happens automatically in code which acquires metadata
    locks on tables being dropped.
  - Changed mysql_alter_table() not to release lock on new table
    name explicitly and to rely on automatic release of locks
    at the end of statement instead. This was necessary since
    now MDL_context::release_lock() is supported only for locks
    for explicit duration.
sql/sql_trigger.cc:
  With new GRL implementation there is no need to explicitly
  acquire protection against GRL before changing table triggers.
  This happens automatically in code which acquires metadata
  locks on tables which triggers are to be changed.
sql/sql_update.cc:
  Fix bug exposed by GRL testing. During prepare phase acquire
  only S metadata locks instead of SW locks to keep prepare of
  multi-UPDATE compatible with concurrent LOCK TABLES WRITE
  and global read lock.
sql/sql_view.cc:
  With new GRL implementation there is no need to explicitly
  acquire protection against GRL before creating view.
  This happens automatically in code which acquires metadata
  lock on view to be created.
sql/sql_yacc.yy:
  LEX::protect_against_global_read_lock member is no longer
  necessary since protection against GRL is automatically
  taken by code acquiring metadata locks/opening tables.
sql/table.cc:
  Adjusted code to the fact that one now needs specify duration
  of lock when initializing MDL_request.
sql/table.h:
  Adjusted code to the fact that one now needs specify duration
  of lock when initializing MDL_request.
sql/transaction.cc:
  Replaced custom implementation of global read lock with
  one based on metadata locks. Consequently when doing
  commit instead of calling method of Global_read_lock
  class to acquire protection against GRL we simply acquire
  IX in COMMIT namespace.
  Also adjusted code to the fact that MDL savepoint is now
  represented by MDL_savepoint class.
2010-11-11 20:11:05 +03:00
Michael Widenius
bdba1d11c4 Change some my_bool in C++ classes and a few functions to bool to detect wrong usage of bool/my_bool.
Fix some bugs where we stored values other than 0 or 1 in my_bool
Fixed some compiler warnings


client/mysql.cc:
  Changed interrupted_query from my_bool to int, as we stored 2 in it.
client/mysqladmin.cc:
  Changed return variable type to same type as function value type
client/mysqltest.cc:
  Changed 'found' to int as we store other values than 0 or 1 into it
  Changed type for parameter of set_reconnect() to match usage.
extra/libevent/evbuffer.c:
  Added __attribute__((unused))
extra/libevent/event.c:
  Added __attribute__((unused))
extra/libevent/signal.c:
  Added __attribute__((unused))
sql/event_data_objects.h:
  my_bool -> bool
sql/event_db_repository.cc:
  my_bool -> bool
sql/event_db_repository.h:
  my_bool -> bool
sql/event_parse_data.h:
  my_bool -> bool
sql/events.cc:
  my_bool -> bool
sql/events.h:
  my_bool -> bool
sql/field.cc:
  my_bool -> bool
sql/field.h:
  my_bool -> bool
sql/hash_filo.h:
  my_bool -> bool
sql/item.cc:
  my_bool -> bool
sql/item.h:
  my_bool -> bool
sql/item_cmpfunc.h:
  my_bool -> bool
  Changed result_for_null_param from my_bool to int as we stored -1 in it.
sql/item_func.cc:
  my_bool -> bool
  Modified udf wrapper functions so that the UDF functions would continue to use my_bool. (To keep compatibility with UDF:s)
sql/item_func.h:
  my_bool -> bool
sql/item_subselect.h:
  my_bool -> bool
sql/item_sum.cc:
  Modified udf wrapper functions so that the UDF functions would continue to use my_bool. (To keep compatibility with UDF:s)
sql/parse_file.h:
  my_bool -> bool
sql/rpl_mi.h:
  my_bool -> bool
sql/sp_rcontext.h:
  my_bool -> bool
sql/sql_analyse.h:
  my_bool -> bool
sql/sql_base.cc:
  Change some assignments so that we don't initialize bool variables with int's.
sql/sql_bitmap.h:
  my_bool -> bool
sql/sql_cache.cc:
  my_bool -> bool
sql/sql_cache.h:
  my_bool -> bool
sql/sql_class.h:
  my_bool -> bool
sql/sql_insert.cc:
  Change some assignments so that we don't initialize bool variables with int's.
sql/sql_prepare.cc:
  my_bool -> bool
sql/table.h:
  my_bool -> bool
storage/maria/ma_check.c:
  Removed duplicate assignment
strings/decimal.c:
  Fixed wrong variable usage.
  Don't do complex arithmetic on bool when simple works.
2010-09-24 01:00:32 +03:00
Mats Kindahl
23d8586dbf WL#5030: Split and remove mysql_priv.h
This patch:

- Moves all definitions from the mysql_priv.h file into
  header files for the component where the variable is
  defined
- Creates header files if the component lacks one
- Eliminates all include directives from mysql_priv.h
- Eliminates all circular include cycles
- Rename time.cc to sql_time.cc
- Rename mysql_priv.h to sql_priv.h
2010-03-31 16:05:33 +02:00
unknown
3cf9e6eb6b Bug#35997 Event scheduler seems to let the server crash, if it is embedded.
The event scheduler was not designed to work in embedded mode. This
patch disables and excludes the event scheduler when the server is
compiled for embedded build.


libmysqld/Makefile.am:
  Reduce the amount of event code in an embedded build.
mysql-test/t/events_trans.test:
  Disable test if run in embedded mode.
sql/Makefile.am:
  Introduce definition HAVE_EVENT_SCHEDULER and one new source file.
sql/event_data_objects.cc:
  Refactor Event_parse_data to new file.
sql/event_data_objects.h:
  Refactor Event_parse_data to new file.
  Move global definitions to new file.
sql/event_queue.cc:
  Move all parsed items to Event_parse_data for easier modularization.
sql/events.cc:
  Move all parsed items to Event_parse_data for easier modularization.
sql/mysqld.cc:
  Disable the event schedular subsystem if the server is compiled in
  embedded mode.
sql/set_var.cc:
  Disable the event schedular subsystem if the server is compiled in
  embedded mode.
sql/set_var.h:
  Disable the event schedular subsystem if the server is compiled in
  embedded mode.
sql/sql_db.cc:
  Disable the event schedular subsystem if the server is compiled in
  embedded mode.
sql/sql_parse.cc:
  Disable the event schedular subsystem if the server is compiled in
  embedded mode.
sql/sql_show.cc:
  Disable the event schedular subsystem if the server is compiled in
  embedded mode.
sql/sql_test.cc:
  Disable the event schedular subsystem if the server is compiled in
  embedded mode.
sql/sql_yacc.yy:
  Only include event-code needed for parsing to reduce impact on embedded
  build.
  Move all constants to Event_parse_data class.
mysql-test/r/events_embedded.result:
  Add test case to make sure the 'event_scheduler' can't be activated
  in embedded mode.
mysql-test/r/is_embedded.require:
  Add test case to make sure the 'event_scheduler' can't be activated
  in embedded mode.
mysql-test/t/events_embedded.test:
  Add test case to make sure the 'event_scheduler' can't be activated
  in embedded mode.
sql/event_parse_data.cc:
  New file. Extracted Event_parse data into a new file.
sql/event_parse_data.h:
  New file. Extracted Event_parse data into a new file.
2008-05-09 09:43:02 +02:00
unknown
7691bbbfe3 Provide initial module structure to Doxygen.
sql/event_data_objects.cc:
  Add module comments.
sql/event_data_objects.h:
  Add module comments.
sql/event_db_repository.cc:
  Add module comments.
sql/event_db_repository.h:
  Add module comments.
sql/event_queue.cc:
  Add module comments.
sql/event_queue.h:
  Add module comments.
sql/event_scheduler.cc:
  Add module comments.
sql/event_scheduler.h:
  Add module comments.
sql/events.cc:
  Add module comments.
sql/events.h:
  Add module comments.
sql/lock.cc:
  Add module comments.
sql/sp_head.h:
  Add module comments.
sql/sql_base.cc:
  Add module comments.
sql/sql_lex.h:
  Add module comments.
sql/sql_parse.cc:
  Add module comments.
sql/sql_select.cc:
  Add module comments.
sql/sql_yacc.yy:
  Add module comments.
2007-08-15 19:08:44 +04:00
unknown
405f82d390 Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
    has a non-ascii symbol
  - BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
  - BUG#19443: INFORMATION_SCHEMA does not support charsets properly
  - BUG#21249: Character set of SP-var can be ignored
  - BUG#25212: Character set of string constant is ignored (stored routines)
  - BUG#25221: Character set of string constant is ignored (triggers)

There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
   triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
   inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
   definition;

1. No query-definition-character set.

In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.

The context contains the following data:
  - client character set;
  - connection collation (character set and collation);
  - collation of the owner database;

The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).

2. Wrong mysqldump-output.

The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.

Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).

The solution is
  - to store definition queries in the original character set;
  - to change SHOW CREATE statement to output definition query in the
    binary character set (i.e. without any conversion);
  - introduce SHOW CREATE TRIGGER statement;
  - to dump special statements to switch the context to the original one
    before dumping and restore it afterwards.

Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.

3. INFORMATION_SCHEMA showed non-UTF8 strings

The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.

Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.

This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object.  Specialized SHOW CREATE statements should be
used for this.

The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).

Example:

  - original query:
    CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;

  - UTF8 query (for INFORMATION_SCHEMA):
    CREATE VIEW v1 AS SELECT 'Hello' AS c1;


client/mysqldump.c:
  Set original character set and collation before dumping definition query.
include/my_sys.h:
  Move out-parameter to the end of list.
mysql-test/lib/mtr_report.pl:
  Ignore server-warnings during the test case.
mysql-test/r/create.result:
  Update result file.
mysql-test/r/ctype_cp932_binlog_stm.result:
  Update result file.
mysql-test/r/events.result:
  Update result file.
mysql-test/r/events_bugs.result:
  Update result file.
mysql-test/r/events_grant.result:
  Update result file.
mysql-test/r/func_in.result:
  Update result file.
mysql-test/r/gis.result:
  Update result file.
mysql-test/r/grant.result:
  Update result file.
mysql-test/r/information_schema.result:
  Update result file.
mysql-test/r/information_schema_db.result:
  Update result file.
mysql-test/r/lowercase_view.result:
  Update result file.
mysql-test/r/mysqldump.result:
  Update result file.
mysql-test/r/ndb_sp.result:
  Update result file.
mysql-test/r/ps.result:
  Update result file.
mysql-test/r/rpl_replicate_do.result:
  Update result file.
mysql-test/r/rpl_sp.result:
  Update result file.
mysql-test/r/rpl_trigger.result:
  Update result file.
mysql-test/r/rpl_view.result:
  Update result file.
mysql-test/r/show_check.result:
  Update result file.
mysql-test/r/skip_grants.result:
  Update result file.
mysql-test/r/sp-destruct.result:
  Update result file.
mysql-test/r/sp-error.result:
  Update result file.
mysql-test/r/sp-security.result:
  Update result file.
mysql-test/r/sp.result:
  Update result file.
mysql-test/r/sql_mode.result:
  Update result file.
mysql-test/r/system_mysql_db.result:
  Update result file.
mysql-test/r/temp_table.result:
  Update result file.
mysql-test/r/trigger-compat.result:
  Update result file.
mysql-test/r/trigger-grant.result:
  Update result file.
mysql-test/r/trigger.result:
  Update result file.
mysql-test/r/view.result:
  Update result file.
mysql-test/r/view_grant.result:
  Update result file.
mysql-test/t/events.test:
  Update test case (new columns added).
mysql-test/t/information_schema.test:
  Update test case (new columns added).
mysql-test/t/show_check.test:
  Test case for SHOW CREATE TRIGGER in prepared statements and
  stored routines.
mysql-test/t/sp-destruct.test:
  Update test case (new columns added).
mysql-test/t/sp.test:
  Update test case (new columns added).
mysql-test/t/view.test:
  Update test.
mysys/charset.c:
  Move out-parameter to the end of list.
scripts/mysql_system_tables.sql:
  Add new columns to mysql.proc and mysql.event.
scripts/mysql_system_tables_fix.sql:
  Add new columns to mysql.proc and mysql.event.
sql/event_data_objects.cc:
  Support new attributes for events.
sql/event_data_objects.h:
  Support new attributes for events.
sql/event_db_repository.cc:
  Support new attributes for events.
sql/event_db_repository.h:
  Support new attributes for events.
sql/events.cc:
  Add new columns to SHOW CREATE event resultset.
sql/mysql_priv.h:
  1. Introduce Object_creation_ctx;
  2. Introduce SHOW CREATE TRIGGER;
  3. Introduce auxilary functions.
sql/sp.cc:
  Add support for new store routines attributes.
sql/sp_head.cc:
  Add support for new store routines attributes.
sql/sp_head.h:
  Add support for new store routines attributes.
sql/sql_lex.cc:
  Generate UTF8-body on parsing/lexing.
sql/sql_lex.h:
  1. Generate UTF8-body on parsing/lexing.
  2. Introduce SHOW CREATE TRIGGER.
sql/sql_parse.cc:
  Introduce SHOW CREATE TRIGGER.
sql/sql_partition.cc:
  Update parse_sql().
sql/sql_prepare.cc:
  Update parse_sql().
sql/sql_show.cc:
  Support new attributes for views
sql/sql_trigger.cc:
  Support new attributes for views
sql/sql_trigger.h:
  Support new attributes for views
sql/sql_view.cc:
  Support new attributes for views
sql/sql_yacc.yy:
  1. Add SHOW CREATE TRIGGER statement.
  2. Generate UTF8-body for views, stored routines, triggers and events.
sql/table.cc:
  Introduce Object_creation_ctx.
sql/table.h:
  Introduce Object_creation_ctx.
sql/share/errmsg.txt:
  Add new errors.
mysql-test/include/ddl_i18n.check_events.inc:
  Aux file for test suite.
mysql-test/include/ddl_i18n.check_sp.inc:
  Aux file for test suite.
mysql-test/include/ddl_i18n.check_triggers.inc:
  Aux file for test suite.
mysql-test/include/ddl_i18n.check_views.inc:
  Aux file for test suite.
mysql-test/include/have_cp1251.inc:
  Aux file for test suite.
mysql-test/include/have_cp866.inc:
  Aux file for test suite.
mysql-test/include/have_koi8r.inc:
  Aux file for test suite.
mysql-test/include/have_utf8.inc:
  Aux file for test suite.
mysql-test/r/ddl_i18n_koi8r.result:
  Result file.
mysql-test/r/ddl_i18n_utf8.result:
  Result file.
mysql-test/r/have_cp1251.require:
  Aux file for test suite.
mysql-test/r/have_cp866.require:
  Aux file for test suite.
mysql-test/r/have_koi8r.require:
  Aux file for test suite.
mysql-test/r/have_utf8.require:
  Aux file for test suite.
mysql-test/t/ddl_i18n_koi8r.test:
  Complete koi8r test case for the CS patch.
mysql-test/t/ddl_i18n_utf8.test:
  Complete utf8 test case for the CS patch.
2007-06-28 21:34:54 +04:00
unknown
c7aeb8f37b This is the 3-rd part of patch for BUG#11986:
remove redundant "body" from Event_parse_data (use sp_head::m_body).


sql/event_data_objects.cc:
  Use sp_head::m_body to store SQL-statement.
  Polishing.
sql/event_data_objects.h:
  Use sp_head::m_body to store SQL-statement.
  Polishing.
sql/event_db_repository.cc:
  Use sp_head::m_body to store SQL-statement.
sql/sql_yacc.yy:
  Use sp_head::m_body to store SQL-statement.
2007-06-14 18:49:17 +04:00
unknown
ab59263b24 Fix rpl_events test failure in the runtime tree.
mysql-test/r/rpl_events.result:
  Now ON COMPLETION NOT PRESERVE events are also dropped on the
  slave, since DROP EVENT command that is invoked for all such commands
  gets invoked on the slave.
sql/event_data_objects.cc:
  Fix the failing rpl_events test after the patch for Bug#27733.
  At the time Events::drop_event got invoked inside
  Event_job_data::execute() thd->query pointed to CREATE PROCEDURE
  statement. This statement was written to the binary log
  from inside Events::drop_event (under assumption that this is a
  DROP EVENT statement that needs to be replicated), and caused
  creation of this procedure on the slave (and a subsequent failure
  when a procedure with the same name already exist).
  
  The patch ensures that thd->query points at the right query text
  for DROP EVENT executed when dropping ON COMPLETION NOT PRESERVE 
  events.
sql/event_data_objects.h:
  Update a  declaration.
sql/events.cc:
  Change if () to an assert: thd->query now always points at a valid
  query.
2007-04-13 23:53:05 -04:00
unknown
c1b6e128cc An attempt to fix a sporadic valgrind memory leak in Event Scheduler:
streamline the event worker thread work flow and try to eliminate
possibilities for memory corruptions that might have been
lurking in previous (complicated) code.
This patch: 
 * removes Event_job_data::compile that was never used
 * cleans up Event_job_data::execute to minimize juggling with
   thread context and eliminate unneded code paths
 * Implements Security_context::change/restore_security_context
   to be able to re-use these methods in all stored programs
This is to maybe fix Bug#27733 "Valgrind failures in 
remove_table_from_cache".
Review comments applied.


sql/event_data_objects.cc:
  Remove Event_job_data::compile, which was never used without
  Event_job_data::execute().
  Merge the implementation of compile() with Event_job_data::execute().
  Reuse existing functions to prepare the event worker thread
  for execution instead of some previously copy-pasted code.
  Do not change and restore the current database inside 
  Event_job_data::execute(), just set the current database in the 
  thread, that is enough to parse and execute an event.
sql/event_data_objects.h:
  Update declarations.
sql/event_scheduler.cc:
  Allocate Event_job_data on stack.
sql/item_func.cc:
  Update to match the new declaration of restore_security_context()
sql/sp_head.cc:
  Update to match the new declaration of 
  change/restore_security_context()
sql/sql_class.cc:
  Move change/restore_security_context to class Security_context.
  Add more comments.
sql/sql_class.h:
  Make change/restore_security_context methods of Security_context.
  That allows us to reuse them in Event Scheduler (instead of a
  copy-paste presently used there).
sql/sql_trigger.cc:
  Update to match the new declaration of 
  change/restore_security_context()
2007-04-13 16:35:56 -04:00
unknown
ff452d050a Post-merge and post-review fixes for the patch for
Bug#23631 "Events: SHOW VARIABLES doesn't work when mysql.event 
is damaged:


mysql-test/r/events.result:
  Update results (a post-merge fix)
mysql-test/r/events_bugs.result:
  Update results (a post-merge fix)
mysql-test/r/events_scheduling.result:
  Update results (a post-merge fix)
mysql-test/t/events_scheduling.test:
  Make sure this test has no races.
sql/event_data_objects.cc:
  Manual post-merge fix for the events replication patch.
sql/event_data_objects.h:
  A post-merge fix.
sql/event_db_repository.cc:
  A post-merge fix.
sql/event_scheduler.cc:
  We should drop the event inside ::execute since there we have
  the right credentials to do so (otherwise Events::drop_event
  returns "access denied" error).
sql/events.cc:
  A post-review fix for: rename start_or_stop_event_scheduler
  to switch_event_scheduler_state.
sql/events.h:
  A post-review fix for: rename start_or_stop_event_scheduler
  to switch_event_scheduler_state.
sql/set_var.cc:
  A post-review fix for: rename start_or_stop_event_scheduler
  to switch_event_scheduler_state.
sql/sql_yacc.yy:
  Remove unused declaratoins.
2007-04-05 20:47:22 +04:00
unknown
a36054f420 Merge bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
into  vajra.(none):/opt/local/work/mysql-5.1-c1


mysql-test/r/events_bugs.result:
  Auto merged
mysql-test/r/events_scheduling.result:
  Auto merged
mysql-test/t/events.test:
  Auto merged
mysql-test/t/events_scheduling.test:
  Auto merged
sql/event_data_objects.h:
  Auto merged
sql/event_db_repository.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/table.h:
  Auto merged
sql/share/errmsg.txt:
  Auto merged
mysql-test/r/events.result:
  e
  Use local.
mysql-test/r/events_restart_phase1.result:
  Use local
mysql-test/r/events_time_zone.result:
  SCCS merged
mysql-test/t/events_restart_phase1.test:
  Use local
sql/event_data_objects.cc:
  Use local
sql/event_db_repository.cc:
  Manual merge.
sql/event_queue.cc:
  Manual merge.
sql/events.cc:
  Manual merge.
2007-04-05 15:49:46 +04:00
unknown
fa1d637e89 A set of changes aiming to make the Event Scheduler more user-friendly
when there are no up-to-date system tables to support it:
 - initialize the scheduler before reporting "Ready for connections".
   This ensures that warnings, if any, are printed before "Ready for
   connections", and this message is not mangled.
 - do not abort the scheduler if there are no system tables
 - check the tables once at start up, remember the status and disable
   the scheduler if the tables are not up to date.
   If one attempts to use the scheduler with bad tables,
   issue an error message.
 - clean up the behaviour of the module under LOCK TABLES and pre-locking
   mode
 - make sure implicit commit of Events DDL works as expected.
 - add more tests


Collateral clean ups in the events code.

This patch fixes Bug#23631 Events: SHOW VARIABLES doesn't work 
when mysql.event is damaged


mysql-test/r/events.result:
  Update results.
mysql-test/r/events_bugs.result:
  Update results.
mysql-test/r/events_restart_phase1.result:
  Update results.
mysql-test/r/events_restart_phase2.result:
  Update results.
mysql-test/r/events_restart_phase3.result:
  Update results.
mysql-test/r/events_scheduling.result:
  Update results.
mysql-test/r/events_time_zone.result:
  Update results.
mysql-test/t/events.test:
  Add new tests for tampering with mysql.event and some more
  tests for sub-statements, LOCK TABLES mode and pre-locking.
mysql-test/t/events_bugs.test:
  Move the non-concurrent part of test for Bug 16420 to this file.
mysql-test/t/events_restart_phase1.test:
  Rewrite events_restart_* tests to take into account that now
  we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase2.test:
  Rewrite events_restart_* tests to take into account that now
  we check mysql.event table only once, at server startup.
mysql-test/t/events_restart_phase3.test:
  Rewrite events_restart_* tests to take into account that now
  we check mysql.event table only once, at server startup.
mysql-test/t/events_scheduling.test:
  Add more coverage for event_scheduler global variable.
mysql-test/t/events_time_zone.test:
  Move the non-concurrent part of the tests for Bug 16420 to 
  events_bugs.test
sql/event_data_objects.cc:
  Move update_timing_fields functionality to Event_db_repository.
  Make loading of events from a table record more robust to tampering
  with the table - now we do not check mysql.event on every table open.
sql/event_data_objects.h:
  Cleanup.
sql/event_db_repository.cc:
  Now Event_db_repository is responsible for table I/O only.
  All the logic of events DDL is handled outside, in Events class please
  refer to the added test coverage to see how this change affected
  the behavior of Event Scheduler.
  Dependency on sp_head.h and sp.h removed.
  Make this module robust to tweaks with mysql.event table.
  Move check_system_tables from events.cc to this file
sql/event_db_repository.h:
  Cleanup declarations (remove unused ones, change return type to bool
  from int).
sql/event_queue.cc:
  Update to adapt to the new start up scheme of the Event Scheduler.
sql/event_queue.h:
  Cleanup declarations.
sql/event_scheduler.cc:
  Make all the error messages uniform:
  [SEVERITY] Event Scheduler: [user][schema.event] message
  Using append_identifier for error logging was an overkill - we may 
  need it only if the system character set may have NUL (null character)
  as part of a valid identifier, this is currently never the case, 
  whereas additional quoting did not look nice in the log.
sql/event_scheduler.h:
  Cleanup the headers.
sql/events.cc:
  Use a different start up procedure of Event Scheduler:
  - at start up, try to check the system tables first.
  If they are not up-to-date, disable the scheduler.
  - try to load all the active events. In case of a load error, abort
  start up.
  - do not parse an event on start up. Parsing only gives some information
  about event validity, but far not all.
  Consolidate the business logic of Events DDL in this module.
  Now opt_event_scheduler may change after start up and thus is protected
  by LOCK_event_metadata mutex.
sql/events.h:
  Use all-static-data-members approach to implement Singleton pattern.
sql/mysqld.cc:
  New invocation scheme of Events. Move some logic to events.cc.
  Initialize the scheduler before reporting "Ready for connections".
sql/set_var.cc:
  Clean up sys_var_thd_sql_mode::symbolic_mode_representation
  to work with a LEX_STRING.
  Move more logic related to @@events_scheduler global variable to Events
  module.
sql/set_var.h:
  Update declarations.
sql/share/errmsg.txt:
  If someone tampered with mysql.event table after the server has
  started we no longer give him/her a complete report what was actually 
  broken. Do not send the user to look at the error log in such case,
  as there is nothing there (check_table_intact is not executed).
sql/sp_head.cc:
  Update to a new declaration of 
  sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_db.cc:
  New invocation scheme of Events module.
sql/sql_parse.cc:
  Move more logic to Events module. Make sure that we are consistent
  in the way access rights are checked for Events DDL: always
  after committing the current transaction and checking the system tables.
sql/sql_show.cc:
  Update to the new declarations of 
  sys_var_thd_sql_mode::symbolic_mode_representation
sql/sql_test.cc:
  New invocation scheme of events.
sql/table.cc:
  mysql.event is a system table.
  Update check_table_intact to be concurrent, more verbose, and less smart.
sql/table.h:
  Add a helper method.
mysql-test/r/events_trans.result:
  New BitKeeper file ``mysql-test/r/events_trans.result''
mysql-test/t/events_trans.test:
  New BitKeeper file ``mysql-test/t/events_trans.test'':
  test cases for Event Scheduler that require a transactional
  storage engine.
2007-04-05 15:24:34 +04:00
unknown
7b1bfbb77a Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  bodhi.local:/opt/local/work/mysql-5.1-runtime


mysql-test/r/events_bugs.result:
  Auto merged
mysql-test/r/ps.result:
  Auto merged
mysql-test/t/events.test:
  Auto merged
sql/event_data_objects.cc:
  Auto merged
sql/event_data_objects.h:
  Auto merged
sql/event_db_repository.h:
  Auto merged
sql/event_queue.cc:
  Auto merged
sql/events.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sql_servers.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/table.h:
  Auto merged
sql/share/errmsg.txt:
  Auto merged
mysql-test/r/events.result:
  Manual merge.
sql/event_db_repository.cc:
  Manual merge.
sql/sql_parse.cc:
  Manual merge.
2007-04-03 14:34:37 +04:00
unknown
092c052280 WL#3629 - Replication of Invocation and Invoked Features
This patch corrects an error in the header file concerning a method declaration
in the header file. Compiles ok on Windows, but not on Linux. 


sql/event_data_objects.h:
  WL#3629 - Replication of Invocation and Invoked Features
  
  This patch corrects an error in the header file concerning a method declaration
  in the header file.
2007-03-29 13:21:59 -04:00
unknown
4a0f5887b7 Merge cbell@bk-internal.mysql.com:/home/bk/mysql-5.1-new-rpl
into  mysql_cab_desk.:C:/source/c++/mysql-5.1-new-rpl


mysql-test/t/events.test:
  Auto merged
sql/event_queue.cc:
  Auto merged
sql/events.cc:
  Auto merged
sql/lex.h:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
BitKeeper/deleted/.del-init_db.sql~a77d572c39d5a1f8:
  WL#3629 : Replication of Invocation and Invoked Features
  
  Manual merge prior to pushing patches.
BitKeeper/deleted/.del-mysql_create_system_tables.sh:
  WL#3629 : Replication of Invocation and Invoked Features
  
  Manual merge prior to pushing patches.
mysql-test/r/events.result:
  WL#3629 : Replication of Invocation and Invoked Features
  
  Manual merge prior to pushing patches.
mysql-test/r/events_grant.result:
  WL#3629 : Replication of Invocation and Invoked Features
  
  Manual merge prior to pushing patches.
mysql-test/r/events_restart_phase1.result:
  WL#3629 : Replication of Invocation and Invoked Features
  
  Manual merge prior to pushing patches.
mysql-test/r/system_mysql_db.result:
  WL#3629 : Replication of Invocation and Invoked Features
  
  Manual merge prior to pushing patches.
mysql-test/t/events_restart_phase1.test:
  WL#3629 : Replication of Invocation and Invoked Features
  
  Manual merge prior to pushing patches.
scripts/mysql_system_tables.sql:
  WL#3629 : Replication of Invocation and Invoked Features
  
  Manual merge prior to pushing patches.
scripts/mysql_system_tables_fix.sql:
  WL#3629 : Replication of Invocation and Invoked Features
  
  Manual merge prior to pushing patches.
sql/event_data_objects.cc:
  WL#3629 : Replication of Invocation and Invoked Features
  
  Manual merge prior to pushing patches.
sql/event_data_objects.h:
  WL#3629 : Replication of Invocation and Invoked Features
  
  Manual merge prior to pushing patches.
sql/event_db_repository.cc:
  WL#3629 : Replication of Invocation and Invoked Features
  
  Manual merge prior to pushing patches.
sql/event_db_repository.h:
  WL#3629 : Replication of Invocation and Invoked Features
  
  Manual merge prior to pushing patches.
sql/sql_udf.cc:
  WL#3629 : Replication of Invocation and Invoked Features
  
  Manual merge prior to pushing patches.
2007-03-29 09:54:59 -04:00
unknown
f5940fe904 Remove unnecessary casts to uchar. The casts are stemming from
the lexer API which internally uses  unsigned char variables to
address its state map. The implementation of the lexer should be
internal to the lexer, and not influence the rest of the code.


sql/event_data_objects.cc:
  Clean up unnecessary type casts.
sql/event_data_objects.h:
  Clean up unnecessary type casts.
sql/ha_ndbcluster.cc:
  Clean up unnecessary type casts.
sql/mysql_priv.h:
  Clean up unnecessary type casts.
sql/partition_info.h:
  Clean up unnecessary type casts.
sql/sp.cc:
  Clean up unnecessary type casts.
sql/sp_head.cc:
  Clean up unnecessary type casts.
sql/sp_head.h:
  Clean up unnecessary type casts.
sql/sql_lex.cc:
  Clean up unnecessary type casts.
sql/sql_lex.h:
  Clean up unnecessary type casts.
sql/sql_parse.cc:
  Clean up unnecessary type casts.
sql/sql_partition.cc:
  Clean up unnecessary type casts.
sql/sql_partition.h:
  Clean up unnecessary type casts.
sql/sql_prepare.cc:
  Clean up unnecessary type casts.
sql/sql_trigger.cc:
  Clean up unnecessary type casts.
sql/sql_view.cc:
  Clean up unnecessary type casts.
sql/sql_yacc.yy:
  Clean up unnecessary type casts.
sql/table.cc:
  Clean up unnecessary type casts.
sql/table.h:
  Clean up unnecessary type casts.
2007-03-27 21:09:56 +04:00
unknown
ff1d6b2252 Merge mysql_cab_desk.:C:/source/c++/mysql-5.1-new-rpl
into  mysql_cab_desk.:C:/source/c++/mysql-5.1_WL_3629


BitKeeper/deleted/.del-init_db.sql~a77d572c39d5a1f8:
  Auto merged
BitKeeper/deleted/.del-mysql_create_system_tables.sh:
  Auto merged
scripts/mysql_system_tables_fix.sql:
  Auto merged
sql/event_data_objects.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/event_data_objects.h:
  Manual merge.
sql/event_queue.cc:
  Manual merge.
sql/events.cc:
  Manual merge.
2007-03-26 09:57:16 -04:00
unknown
57dc12563f Trivial cleanups and whitespace change in Event Scheduler code.
A larger patch is to come, this is to exclude rudimentary changes
from it.


sql/event_data_objects.cc:
  Whitespace change.
sql/event_data_objects.h:
  Remove debug allocators - we have safemalloc.
sql/event_db_repository.cc:
  Whitespace change.
sql/event_db_repository.h:
  Whitespace change.
sql/event_queue.cc:
  Remove an unused structure. Whitespace change.
sql/event_queue.h:
  Whitespace.
sql/event_scheduler.cc:
  Whitespace change.
sql/event_scheduler.h:
  Add comments. Whitespace change.
sql/events.cc:
  Whitespace change.
sql/events.h:
  Trivial cleanups.
2007-03-23 18:14:03 +03:00
unknown
086fba7627 BUG#16420: Events: timestamps become UTC
BUG#26429: SHOW CREATE EVENT is incorrect for an event that
           STARTS NOW()
BUG#26431: Impossible to re-create an event from backup if its
           STARTS clause is in the past
WL#3698: Events: execution in local time zone

The problem was that local times specified by the user in AT, STARTS
and ENDS of CREATE EVENT/ALTER EVENT statement were converted to UTC,
and the original time zone was forgotten.  This way, event scheduler
couldn't honor Daylight Saving Time shifts, and times shown to the
user were also in UTC.  Additionally, CREATE EVENT didn't allow times
in the past, thus preventing straightforward event restoration from
old backups.

This patch reworks event scheduler time computations, performing them
in the time zone associated with the event.  Also it allows times to
be in the past.

The patch adds time_zone column to mysql.event table.

NOTE: The patch is almost final, but the bug#9953 should be pushed
first.


client/mysqldump.c:
  Before every CREATE EVENT, output its time zone.
mysql-test/include/wait_condition.inc:
  Add optional $wait_timeout parameter.
mysql-test/lib/init_db.sql:
  Add time_zone column.
mysql-test/r/events.result:
  Update result.
mysql-test/r/events_bugs.result:
  Update result.
mysql-test/r/events_grant.result:
  Update result.
mysql-test/r/events_restart_phase1.result:
  Update result.
mysql-test/r/events_scheduling.result:
  Update result.
mysql-test/r/mysqldump.result:
  Update result.
mysql-test/r/ps.result:
  Update result.
mysql-test/r/system_mysql_db.result:
  Update result.
mysql-test/t/events.test:
  Remove STARTS from the result, as it depends on current time.
mysql-test/t/events_bugs.test:
  Time in the past is no longer an error.
mysql-test/t/events_restart_phase1.test:
  Fill new column 'time_zone' in mysql.event.
mysql-test/t/events_scheduling.test:
  Cleanup: disable event scheduler.
scripts/mysql_create_system_tables.sh:
  Add new column 'time_zone' to mysql.event.
scripts/mysql_fix_privilege_tables.sql:
  Add new column 'time_zone' to mysql.event.
sql/event_data_objects.cc:
  The essence of the change is the following:
   - for internal times use my_time_t instead of TIME.  Assignment and
     comparison is done now on plain numbers.
   - in init_execute_at(), init_starts(), init_ends() convert given time
     to number of seconds since Epoch (aka Unix time, in UTC).
   - handle time_zone field loading and storing.
   - in get_next_time(), Unix time is converted back to event time zone,
     interval is added, and the result is converted to UTC again.
   - fix Event_timed::get_create_event() to report STARTS and ENDS.
   - before executing the event body we set thread time zone to the
     event time zone.
sql/event_data_objects.h:
  Add time_zone member to Event_basic class.
  
  Store internal times in my_time_t (number of seconds since Epoch),
  rather than in broken down TIME structure.
sql/event_db_repository.cc:
  Add time_zone column handling.
  
  Give a warning and do not create an event if its execution time is in
  the past, and ON COMPLETION NOT PRESERVE is set, because such an event
  should be dropped by that time.  Also, do not allow ALTER EVENT to
  set execution time in the past when ON COMPLETION NOT PRESERVE is set.
sql/event_db_repository.h:
  Add enum member for new time zone column.
sql/event_queue.cc:
  Replace handling of broken down times with simple handling of
  my_time_t.
sql/event_queue.h:
  Store internal times in my_time_t (number of seconds since Epoch),
  rather than in broken down TIME structure.
sql/event_scheduler.cc:
  Add TODO comment.
sql/events.cc:
  Send time_zone column for SHOW CREATE EVENT.
sql/share/errmsg.txt:
  Update error message, and add two more errors.
sql/sql_show.cc:
  Add TIME_ZONE column to the output of SHOW EVENTS.
mysql-test/r/events_time_zone.result:
  BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/r/events_time_zone.result
mysql-test/t/events_time_zone.test:
  BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/t/events_time_zone.test
2007-03-16 17:31:07 +03:00
unknown
62b41b5fbc WL#3629 - Replication of Invocation and Invoked Features
This changeset adds replication of events and user-defined functions. 
There are several bug reports involved in this change:

BUG#16421, BUG#17857, BUG#20384:
This patch modifies the mysql.events table to permit the addition of
another enum value for the status column. The column now has values
of ('DISABLED','SLAVESIDE_DISABLED','ENABLED'). A status of
SLAVESIDE_DISABLED is set on the slave during replication of events.
This enables users to determine which events werereplicated from the 
master and to later enable them if they promote the slave to a master.
The CREATE, ALTER, and DROP statements are binlogged.
A new test was added for replication of events (rpl_events).

BUG#17671:
This patch modifies the code to permit logging of user-defined functions.
Note: this is the CREATE FUNCTION ... SONAME variety. A more friendly error 
message to be displayed should a replicated user-defined function not be
found in the loadable library or if the library is missing from the
slave.The CREATE andDROP statements are binlogged. A new test was added 
for replication of user-defined functions (rpl_udf). 

The patch also adds a new column to the mysql.event table named
'originator' that is used to store the server_id of the server that
the event originated on. This enables users to promote a slave to a 
master and later return the promoted slave to a slave and disable the
replicated events.


mysql-test/lib/init_db.sql:
  WL#3629 - Replication of Invocation and Invoked Feature
  This patch adds the SLAVESIDE_DISABLED to the list of enumerated 
  values for the mysql.event table.
  
  This patch adds the column 'originator' to the mysql.event table.
mysql-test/r/events.result:
  WL#3629 - Replication of Invocation and Invoked Feature
  This patch adds the 'originator' column to the events test results.
  This was necessary to ensure the manual insert into mysql.event table 
  succeeds because the originator column is set to NOT NULL.
mysql-test/r/events_grant.result:
  WL#3629 - Replication of Invocation and Invoked Feature
  This patch adds the 'originator' column to the events_grant test results.
  This was necessary to ensure the manual insert into mysql.event table 
  succeeds because the originator column is set to NOT NULL.
mysql-test/r/events_restart_phase1.result:
  WL#3629 - Replication of Invocation and Invoked Feature
  This patch adds the 'originator' column to the events_restart_phase1
  test results. This was necessary to ensure the manual insert into 
  mysql.event table succeeds because the originator column is set to 
  NOT NULL.
mysql-test/r/system_mysql_db.result:
  WL#3629 - Replication of Invocation and Invoked Feature
  This patch adds the SLAVESIDE_DISABLED to the list of enumerated 
  values for the mysql.event table.
  
  This patch adds the column 'originator' to the mysql.event table.
  
  These changes to the result file were necessary to ensure correct test
  results.
mysql-test/t/events.test:
  WL#3629 - Replication of Invocation and Invoked Feature
  This patch adds the 'originator' column to the events
  test. This was necessary to ensure the manual insert into 
  mysql.event table succeeds because the originator column is set to 
  NOT NULL.
mysql-test/t/events_restart_phase1.test:
  WL#3629 - Replication of Invocation and Invoked Feature
  This patch adds the 'originator' column to the events_restart_phase1
  test. This was necessary to ensure the manual insert into 
  mysql.event table succeeds because the originator column is set to 
  NOT NULL.
scripts/mysql_create_system_tables.sh:
  WL#3629 - Replication of Invocation and Invoked Feature
  This patch adds the SLAVESIDE_DISABLED to the list of enumerated 
  values for the mysql.event table.
  
  This patch adds the column 'originator' to the mysql.event table.
scripts/mysql_fix_privilege_tables.sql:
  WL#3629 - Replication of Invocation and Invoked Feature
  This patch adds the SLAVESIDE_DISABLED to the list of enumerated 
  values for the mysql.event table.
  
  This patch adds the column 'originator' to the mysql.event table.
sql/event_data_objects.cc:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch modifies the code to permit processing of the new enum
  SLAVESIDE_DISABLED which is set on the slave during replication
  of events. 
  
  This patch uses the new Event_basic:: enumerated values.
sql/event_data_objects.h:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch moves the duplicated enumeration values for ENABLED, 
  SLAVESIDE_DISABLED, and DISABLED to the Event_basic class removing
  them from the other Event_* classes.
sql/event_db_repository.cc:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch modifies the code to permit processing of the new enum
  SLAVESIDE_DISABLED which is set on the slave during replication
  of events. 
  
  The patch also adds a new column to the mysql.event table named
  'originator' that is used to store the server_id of the server that
  the event originated on. This enables users to promote a slave to a 
  master and later return the promoted slave to a slave and disable the
  replicated events.
sql/event_db_repository.h:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch modifies the code to add a new field named 'originator' 
  to the enum_event_table_field and associated structure.
sql/event_queue.cc:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch modifies the code to permit processing of the new enum
  SLAVESIDE_DISABLED which is set on the slave during replication
  of events.
sql/events.cc:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch modifies the code to permit processing of the new enum
  SLAVESIDE_DISABLED which is set on the slave during replication
  of events.
sql/lex.h:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch modifies the code to add the new SLAVESIDE_DISABLE symbol
  to the lexical parser.
sql/slave.cc:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch modifies the code to permit the capture of the error on
  the slave when a UDF from a loadable library is not loaded on the server
  when replicated from the master.
sql/sql_parse.cc:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch removes the comment because drop functions commands 
  are replicated.
sql/sql_show.cc:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch modifies the code to permit processing of the new enum
  SLAVESIDE_DISABLED which is set on the slave during replication
  of events. The code also adds changes the display width of the status
  column for the schema table for the show events command and also adds
  the new column 'originator' to the events_field_info structure.
sql/sql_udf.cc:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch modifies the code to add the binlogging of the create and
  drop function events.
sql/sql_yacc.yy:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch modifies the code to change the enumeration of the status
  column for the events in the parser. The code uses the Event_basic::
  enumerations allowing the enums to be defined in one place.
mysql-test/t/rpl_events.test:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch adds a new test for testing replication of events. The test
  uses include files so that the test can test under both RBR and SBR.
mysql-test/r/rpl_events.result:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch adds a new result file for testing replication of events.
mysql-test/r/rpl_udf.result:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch adds a new result file for testing replication of UDFs.
mysql-test/t/rpl_udf.test:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch adds a new test for testing replication of UDFs. The test
  uses include files so that the test can test under both RBR and SBR.
mysql-test/include/rpl_events.inc:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch adds a new include file for testing replication of events.
  This file contains the core test procedures.
mysql-test/include/rpl_udf.inc:
  WL#3629 - Replication of Invocation and Invoked Features
  This patch adds a new include file for testing replication of UDFs.
  This file contains the core test procedures.
2007-03-16 09:56:57 -04:00
unknown
3c39b0d831 Fix for bug#22740 Events: Decouple Event_queue from Event_db_repository
This patch implements the idea of the bug report by making Event_queue
unaware of Event_db_repository by making a higher level class - Events,
which is aware of most of all classes, responsible for passing all data
needed for adding/updating/deleting an event to/from the queue.

Introduces few new classes :
 - Event_worker_thread
 - Event_queue_element_for_exec


sql/event_data_objects.cc:
  Introduced a new class Event_queue_element_for_exec
  According to Konstantin it should be named Event_name and hold
  only two LEX_STRINGs but `dropped` is not saved on disk and will
  require additional logic in Event_worker_thread class, after loading
  to compute whether the event should be dropped or not. It's easier
  just to pass this flag around.
  
  Removed Event_queue_element::drop(). This method was a source of a
  race condition. At the place where the event should be dropped we
  call Events::drop_event() which is the only code-flow for dropping.
  In addition, because ::drop_event() holds Events::LOCK_metadata there is
  no source of race conditions. Before this patch dropping from ::drop()
  wasn't under LOCK_metadata and races were possible.
  
  Because Events::open_event_table was removed as a method, provisionally
  events_event_db_repository was exported from events.cc till a solution is
  build where Event_queue_element does not access directly mysql.event.
sql/event_data_objects.h:
  New class Event_queue_element_for_exec added which is returned
  from Event_queue::get_top_if_time() and passed through Event_scheduler
  to Event_worker_thread. There by using the (db)name Event_job_data is
  instanciated and executed.
  
  Dropped Event_queue_element::drop()
  
  thd was moved out of Event_job_data as it is now part of
  Event_queue_element_for_exec
sql/event_queue.cc:
  Removed dependency of Event_queue on Event_db_repository.
  The instantiation of Event_job_data was moved to class Event_worker_thread
  In place is a return of an object of Event_queue_element_for_exec is used
  later for instantiating Event_job_data.
  
  The `dropped` flag of Event_queue_element is passed over
  Event_queue_element_for_exec to the code in Event_worker_thread.
sql/event_queue.h:
  Removed dependency of Event_queue on Event_db_repository
  Removed dependency on Event_scheduler
sql/event_scheduler.cc:
  Added class Event_worker_thread, which is used during
  the execution of an event. It has a static init() method
  to get a pointer to Event_db_repository to be used for
  instantiation of Event_job_data object. This object it then
  executed.
sql/event_scheduler.h:
  Added class Event_worker_thread, which is used during
  the execution of an event.
sql/events.cc:
  Removed Events::open_event_table() because it was a product of
  a bad architecture.
sql/events.h:
  Removed friend definition, unneeded.
  
  Fixed Events::drop_event() to have the previous signature without
  bool only_from_disk
sql/sql_parse.cc:
  Fix call
2007-01-29 20:46:29 +03:00
unknown
92e68d49d7 Many files:
Changed header to GPL version 2 only


client/mysqlslap.c:
  Changed header to GPL version 2 only
include/atomic/nolock.h:
  Changed header to GPL version 2 only
include/atomic/rwlock.h:
  Changed header to GPL version 2 only
include/atomic/x86-gcc.h:
  Changed header to GPL version 2 only
include/atomic/x86-msvc.h:
  Changed header to GPL version 2 only
include/my_atomic.h:
  Changed header to GPL version 2 only
include/my_trie.h:
  Changed header to GPL version 2 only
include/my_vle.h:
  Changed header to GPL version 2 only
include/mysql/plugin.h:
  Changed header to GPL version 2 only
mysys/my_atomic.c:
  Changed header to GPL version 2 only
mysys/my_getncpus.c:
  Changed header to GPL version 2 only
mysys/my_memmem.c:
  Changed header to GPL version 2 only
mysys/my_vle.c:
  Changed header to GPL version 2 only
mysys/trie.c:
  Changed header to GPL version 2 only
plugin/Makefile.am:
  Changed header to GPL version 2 only
server-tools/instance-manager/IMService.h:
  Changed header to GPL version 2 only
server-tools/instance-manager/WindowsService.h:
  Changed header to GPL version 2 only
server-tools/instance-manager/exit_codes.h:
  Changed header to GPL version 2 only
server-tools/instance-manager/user_management_commands.h:
  Changed header to GPL version 2 only
sql/authors.h:
  Changed header to GPL version 2 only
sql/contributors.h:
  Changed header to GPL version 2 only
sql/event_data_objects.cc:
  Changed header to GPL version 2 only
sql/event_data_objects.h:
  Changed header to GPL version 2 only
sql/event_db_repository.cc:
  Changed header to GPL version 2 only
sql/event_db_repository.h:
  Changed header to GPL version 2 only
sql/event_queue.cc:
  Changed header to GPL version 2 only
sql/event_queue.h:
  Changed header to GPL version 2 only
sql/event_scheduler.cc:
  Changed header to GPL version 2 only
sql/event_scheduler.h:
  Changed header to GPL version 2 only
sql/events.cc:
  Changed header to GPL version 2 only
sql/events.h:
  Changed header to GPL version 2 only
sql/ha_ndbcluster_binlog.cc:
  Changed header to GPL version 2 only
sql/ha_ndbcluster_binlog.h:
  Changed header to GPL version 2 only
sql/ha_ndbcluster_tables.h:
  Changed header to GPL version 2 only
sql/ha_partition.cc:
  Changed header to GPL version 2 only
sql/ha_partition.h:
  Changed header to GPL version 2 only
sql/item_xmlfunc.cc:
  Changed header to GPL version 2 only
sql/item_xmlfunc.h:
  Changed header to GPL version 2 only
sql/log.h:
  Changed header to GPL version 2 only
sql/partition_element.h:
  Changed header to GPL version 2 only
sql/partition_info.cc:
  Changed header to GPL version 2 only
sql/partition_info.h:
  Changed header to GPL version 2 only
sql/rpl_filter.cc:
  Changed header to GPL version 2 only
sql/rpl_filter.h:
  Changed header to GPL version 2 only
sql/rpl_injector.cc:
  Changed header to GPL version 2 only
sql/rpl_injector.h:
  Changed header to GPL version 2 only
sql/rpl_mi.cc:
  Changed header to GPL version 2 only
sql/rpl_mi.h:
  Changed header to GPL version 2 only
sql/rpl_rli.cc:
  Changed header to GPL version 2 only
sql/rpl_rli.h:
  Changed header to GPL version 2 only
sql/rpl_tblmap.cc:
  Changed header to GPL version 2 only
sql/rpl_tblmap.h:
  Changed header to GPL version 2 only
sql/rpl_utility.cc:
  Changed header to GPL version 2 only
sql/rpl_utility.h:
  Changed header to GPL version 2 only
sql/sql_binlog.cc:
  Changed header to GPL version 2 only
sql/sql_partition.cc:
  Changed header to GPL version 2 only
sql/sql_partition.h:
  Changed header to GPL version 2 only
sql/sql_plugin.cc:
  Changed header to GPL version 2 only
sql/sql_plugin.h:
  Changed header to GPL version 2 only
sql/sql_servers.cc:
  Changed header to GPL version 2 only
sql/sql_servers.h:
  Changed header to GPL version 2 only
sql/sql_tablespace.cc:
  Changed header to GPL version 2 only
sql/sql_yacc.yy.bak:
  Changed header to GPL version 2 only
storage/Makefile.am:
  Changed header to GPL version 2 only
storage/archive/Makefile.am:
  Changed header to GPL version 2 only
storage/blackhole/Makefile.am:
  Changed header to GPL version 2 only
storage/csv/Makefile.am:
  Changed header to GPL version 2 only
storage/example/Makefile.am:
  Changed header to GPL version 2 only
storage/federated/Makefile.am:
  Changed header to GPL version 2 only
storage/innobase/handler/Makefile.am:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/AllocNodeId.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/CreateObj.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/DictObjOp.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/DihFragCount.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/DropFilegroup.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/DropFilegroupImpl.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/DropObj.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/Extent.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/LgmanContinueB.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/PgmanContinueB.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/RestoreContinueB.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/RestoreImpl.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/RouteOrd.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/kernel/signaldata/TsmanContinueB.hpp:
  Changed header to GPL version 2 only
storage/ndb/include/ndbapi/NdbIndexStat.hpp:
  Changed header to GPL version 2 only
storage/ndb/ndbapi-examples/mgmapi_logevent/mgmapi_logevent.cpp:
  Changed header to GPL version 2 only
storage/ndb/ndbapi-examples/mgmapi_logevent_dual/mgmapi_logevent_dual.cpp:
  Changed header to GPL version 2 only
storage/ndb/ndbapi-examples/ndbapi_async/ndbapi_async.cpp:
  Changed header to GPL version 2 only
storage/ndb/ndbapi-examples/ndbapi_async1/ndbapi_async1.cpp:
  Changed header to GPL version 2 only
storage/ndb/ndbapi-examples/ndbapi_event/ndbapi_event.cpp:
  Changed header to GPL version 2 only
storage/ndb/ndbapi-examples/ndbapi_retries/ndbapi_retries.cpp:
  Changed header to GPL version 2 only
storage/ndb/ndbapi-examples/ndbapi_scan/ndbapi_scan.cpp:
  Changed header to GPL version 2 only
storage/ndb/ndbapi-examples/ndbapi_simple/ndbapi_simple.cpp:
  Changed header to GPL version 2 only
storage/ndb/ndbapi-examples/ndbapi_simple_dual/ndbapi_simple_dual.cpp:
  Changed header to GPL version 2 only
storage/ndb/ndbapi-examples/ndbapi_simple_index/ndbapi_simple_index.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/dbdih/printSysfile.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/dbtup/tuppage.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/dbtux/DbtuxStat.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/diskpage.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/lgman.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/lgman.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/pgman.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/pgman.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/print_file.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/record_types.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/restore.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/restore.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/tsman.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/blocks/tsman.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/DLCFifoList.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/DLCHashTable.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/DynArr256.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/DynArr256.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/KeyTable2Ref.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/LinearPool.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/NdbdSuperPool.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/NdbdSuperPool.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/Pool.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/Pool.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/RWPool.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/RWPool.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/Rope.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/SLFifoList.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/WOPool.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/WOPool.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/bench_pool.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/kernel/vm/ndbd_malloc_impl.hpp:
  Changed header to GPL version 2 only
storage/ndb/src/mgmsrv/ParamInfo.cpp:
  Changed header to GPL version 2 only
storage/ndb/src/ndbapi/NdbIndexStat.cpp:
  Changed header to GPL version 2 only
storage/ndb/test/ndbapi/testIndexStat.cpp:
  Changed header to GPL version 2 only
storage/ndb/test/tools/listen.cpp:
  Changed header to GPL version 2 only
storage/ndb/tools/restore/ndb_nodegroup_map.h:
  Changed header to GPL version 2 only
strings/my_strchr.c:
  Changed header to GPL version 2 only
unittest/mysys/base64-t.c:
  Changed header to GPL version 2 only
unittest/mysys/bitmap-t.c:
  Changed header to GPL version 2 only
unittest/mysys/my_atomic-t.c:
  Changed header to GPL version 2 only
unittest/mytap/tap.c:
  Changed header to GPL version 2 only
unittest/mytap/tap.h:
  Changed header to GPL version 2 only
win/Makefile.am:
  Changed header to GPL version 2 only
2006-12-27 02:23:51 +01:00
unknown
788ad30f08 Fixed a LOT of compiler warnings
Added missing DBUG_RETURN statements (in mysqldump.c)
Added missing enums
Fixed a lot of wrong DBUG_PRINT() statements, some of which could cause crashes
Removed usage of %lld and %p in printf strings as these are not portable or produces different results on different systems.


client/mysqldump.c:
  Fixed some compiler warnings
  Added some missing DBUG_RETURN
  Remove copying of 'cluster' database
client/mysqlslap.c:
  Fixed compiler warnings
client/mysqltest.c:
  After merge fix
extra/yassl/taocrypt/include/algebra.hpp:
  Removed compiler warning
mysql-test/include/im_check_env.inc:
  Fixed race condition (mysqld1 could report 'starting' or 'online'
mysql-test/mysql-test-run.pl:
  After merge fixes
  Added missing directory to LD_LIBRARY_PATH
mysql-test/r/ctype_cp1250_ch.result:
  After merge fix
mysql-test/r/im_cmd_line.result:
  Fixed race condition
mysql-test/r/im_daemon_life_cycle.result:
  Fixed race condition
mysql-test/r/im_instance_conf.result:
  Fixed race condition
mysql-test/r/im_life_cycle.result:
  Fixed race condition
mysql-test/r/im_utils.result:
  Fixed race condition
mysql-test/r/log_tables.result:
  Fixed wrong result
mysql-test/t/disabled.def:
  Disabled ndb_restore_partion, as ndb_restore_compate caused it to fail, becasue of table 'cluster/def/schema' which is stored in ndb_backup50
mysys/my_compress.c:
  Removed compiler warnings
mysys/my_getopt.c:
  Ensure we always have at least one space between option name and value
plugin/fulltext/plugin_example.c:
  Removed compiler warnings
server-tools/instance-manager/mysql_connection.cc:
  After merge fix
sql/event_data_objects.cc:
  Fixed compiler warnings
  Fixed platform compatibility issues (%lld is not portable)
sql/event_data_objects.h:
  Fixed compiler warnings
sql/event_db_repository.cc:
  Fixed compiler warnings
sql/event_queue.cc:
  Fixed compiler warnings
sql/event_scheduler.cc:
  Fixed compiler warnings
sql/events.cc:
  Fixed compiler warnings
sql/field.cc:
  Fixed compiler warnings
sql/ha_ndbcluster.cc:
  Fixed compiler warnings
sql/ha_ndbcluster_binlog.cc:
  Fixed compiler warnings
sql/ha_partition.cc:
  Fixed compiler warnings
sql/handler.cc:
  Fixed compiler warnings
sql/item_cmpfunc.cc:
  Fixed DBUG_PRINT style
sql/item_func.cc:
  Fixed compiler warnings
sql/log.cc:
  Fixed compiler warnings
sql/log_event.cc:
  Fixed compiler warnings
sql/mysqld.cc:
  Fixed compiler warnings
sql/opt_range.cc:
  Fixed compiler warnings
sql/repl_failsafe.cc:
  Indentation fixes
sql/rpl_rli.cc:
  Fixed compiler warnings
sql/rpl_tblmap.cc:
  Fixed compiler warnings
sql/set_var.cc:
  Fixed compiler warnings
sql/slave.cc:
  Fixed compiler warnings
sql/sp_head.cc:
  Fixed compiler warnings
sql/sql_base.cc:
  Fixed compiler warnings
  Fixed indentation
sql/sql_binlog.cc:
  Fixed compiler warnings
sql/sql_cache.cc:
  Fixed compiler warnings
sql/sql_class.cc:
  Fixed compiler warnings
sql/sql_handler.cc:
  Fixed compiler warnings
sql/sql_lex.cc:
  Fixed compiler warnings
sql/sql_parse.cc:
  Fixed compiler warnings
sql/sql_partition.cc:
  Fixed compiler warnings
sql/sql_prepare.cc:
  Fixed compiler warnings
sql/sql_table.cc:
  Fixed compiler warnings
sql/sql_test.cc:
  Fixed DBUG_PRINT style
sql/sql_trigger.cc:
  Fixed DBUG_PRINT style
sql/table.cc:
  Fixed compiler warnings
storage/federated/ha_federated.cc:
  Fixed compiler warnings
storage/myisam/mi_rsamepos.c:
  Fixed compiler warnings
storage/ndb/include/ndb_global.h.in:
  After merge fix
storage/ndb/include/util/NdbOut.hpp:
  Inform gcc that ndbout_c takes a printf() string as argument
storage/ndb/include/util/SimpleProperties.hpp:
  After merge fixes
storage/ndb/src/kernel/blocks/backup/Backup.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
  Fixed compiler warnings
  Fixed usage of uninitialized value (Got help from Jonas with patch)
storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/blocks/lgman.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/blocks/pgman.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/blocks/restore.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/blocks/dbtup/DbtupFixAlloc.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/blocks/suma/Suma.cpp:
  Fixed compiler warnings
  Added missing enum's to switch
storage/ndb/src/kernel/vm/Configuration.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/vm/DLHashTable.hpp:
  Fixed compiler warnings
storage/ndb/src/kernel/vm/RWPool.hpp:
  Fixed compiler warnings
storage/ndb/src/kernel/vm/SimulatedBlock.cpp:
  Fixed compiler warnings
storage/ndb/src/kernel/vm/WOPool.hpp:
  Fixed compiler warnings
storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp:
  Fixed compiler warnings
storage/ndb/src/mgmclient/CommandInterpreter.cpp:
  Fixed compiler warnings
storage/ndb/src/mgmsrv/MgmtSrvr.cpp:
  Fixed compiler warnings
storage/ndb/src/ndbapi/DictCache.cpp:
  Fixed compiler warnings
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  Fixed compiler warnings
storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp:
  Fixed compiler warnings
storage/ndb/src/ndbapi/NdbIndexOperation.cpp:
  Fixed compiler warnings
storage/ndb/src/ndbapi/NdbIndexStat.cpp:
  Initialize possible uninitialized variable
storage/ndb/src/ndbapi/NdbOperationInt.cpp:
  Fixed compiler warnings
storage/ndb/src/ndbapi/NdbRecAttr.cpp:
  Added missing enum's (To avoid compiler warnings)
storage/ndb/src/ndbapi/NdbScanOperation.cpp:
  Fixed compiler warnings
storage/ndb/src/ndbapi/ObjectMap.hpp:
  Fixed compiler warnings
storage/ndb/tools/desc.cpp:
  Fixed compiler warnings
storage/ndb/tools/restore/Restore.cpp:
  Fixed compiler warnings
storage/ndb/tools/restore/consumer_restore.cpp:
  Fixed compiler warnings
unittest/mytap/t/basic-t.c:
  Fixed compiler warnings
unittest/mytap/tap.c:
  Fixed compiler warnings
2006-11-27 01:47:38 +02:00
unknown
99adbd131a WL#3337 (Event scheduler new architecture)
Post-review fixes. Mostly whitespace, int-to-bool return value, fixed comments


sql/Makefile.am:
  compile all submodules of Events before compiling the facade
sql/event_data_objects.cc:
  - Use initialization list
  - Clean whitespaces
  - Shorten comments
  - Fix comments
sql/event_data_objects.h:
  - Fix whitespace
sql/event_db_repository.cc:
  - Change return type from int to bool where only one error code is
    returned.
  - Don't use macros but get the maximal number of characters in a column
    from the column
  - Fix  comments
  - Make functions which has return value but it's not used - void.
sql/event_db_repository.h:
  - Methods with only one error code int -> bool return value
  - Remove declaration of fill_schema_events, a function that does not exist
sql/event_queue.cc:
  - Use initialization lists
  - Let find_n_remove_event delete the object thus making the code more robust.
    The caller could forget to destruct the object. In addition, find_n_remove_element()
    does not return a value.
  - Move check_system_tables() to class Events
  - Fix comments
sql/event_queue.h:
  - Whitespace changes
  - init_queue() should allow passing of THD
  - check_system_tables moved to class Events
  - find_n_remove_event() is now void
sql/event_scheduler.cc:
  - Initialize res before use
  - Remove end stop from message
sql/event_scheduler.h:
  Add uninitialized state. The scheduler is in it before init_scheduler()
  is called. The rationale is that otherwise state has no value before
  the call. If the system tables were damaged the scheduler won't be initialized
  but in Events::deinit() Event_scheduler::stop() will be called and this will
  touch state, generating valgrind warning at minimum.
sql/events.cc:
  - Whitespace changes
  - Fix comments
  - Make methods which have only one error code be bool instead of int
  - Create temporarily a THD to be used for the initialization of Event_queue
  - Event_queue::check_system_tables() moved to Events::check_system_tables
  - is_started() is renamed to is_execution_of_events_started()
sql/events.h:
  - Whitespace changes
  - When a method returns only one error code it should be bool, not int
  - is_started() renamed to is_execution_of_events_started()
sql/set_var.cc:
  is_started() is renamed to is_execution_of_events_started()
sql/sql_db.cc:
  The return code is not used, thus don't return anything and drop_schema_events()
  is now void.
sql/sql_yacc.yy:
  - Fix comments
  - Remove unneeded initialization which is performed in lex_init()
sql/share/errmsg.txt:
  New error message
sql/table.cc:
  - Fix comments
  - make table_check_intact() accespt const *table_def
sql/table.h:
  Make table_check_intact() accespt const *table_def
2006-08-17 14:22:59 +02:00
unknown
e69e640f2e WL#3337 (Events new architecture)
Small updates before patch submit.


client/mysqltest.c:
  allow --valgrind option to mysqltest so one can be able to detect
  whether the test is running under valgrind by having $VALGRIND_TEST,
  similar to BIG_TEST, in the test file.
mysql-test/mysql-test-run.pl:
  If the test suite is running under valgrind start mysqltest with --valgrind
  to inform that we run valgrind. mysqltest will provide $VALGRIND_TEST for the
  test cases.
mysql-test/r/events_bugs.result:
  update result
mysql-test/r/events_scheduling.result:
  update result
mysql-test/t/events.test:
  Increase times or the test will fail under valgrind
mysql-test/t/events_bugs.test:
  Increase times or the test will fail under valgrind
mysql-test/t/events_scheduling.test:
  Remove faulty test
  Disable the test case for valgrind
sql/event_data_objects.cc:
  count the number of executions
sql/event_data_objects.h:
  flags is not used at all
  add execution_count to count the number of executions
sql/event_db_repository.cc:
  Initialize wherever needed.
  Add a comment regarding valgrind warning.
sql/event_queue.cc:
  more debug info in the trace log
sql/event_scheduler.cc:
  Use macro COND_STATE_WAIT() in all cases we need waiting
  on condition. Hence, we can trace locking, attemption to lock
  and more with SHOW SCHEDULER STATUS
sql/event_scheduler.h:
  Change the declaration of cond_wait to accept THD
sql/events.cc:
  fix memory leak. Destroy event_queue
mysql-test/include/not_valgrind.inc:
  New BitKeeper file ``mysql-test/include/not_valgrind.inc''
mysql-test/r/not_valgrind.require:
  New BitKeeper file ``mysql-test/r/not_valgrind.require''
2006-07-17 16:52:45 +02:00
unknown
31caa8c433 WL #3337 (Events new architecture)
Final stroke, events should be loaded from disk on server startup.
Also check the validity of their bodies if possible during loading.


sql/event_data_objects.cc:
  Remove Event_job_data::free_sp(), move the code to the destructor
  Change the way we change the security context
  Steal some code from sql_parse.cc
sql/event_data_objects.h:
  Remove free_sp()
  Make compile() public, to be used when booting for verifying the integrity of mysql.event
sql/event_queue.cc:
  Make the queue load events from disk on server boot.
  Compile and thus check for integrity the events.
sql/event_queue.h:
  shift methods around. add queue_loaded boolean.
sql/event_scheduler.cc:
  Rename init_event_thread() to pre_init_event_thread()
  and make it more generic.
  Add post_init_event_thread()
  Export these two as well as deinit_event_thread().
  Now it is quite easy to write code to spawn a new event thread
  whenever needed.
sql/event_scheduler.h:
  export pre_init_event_thread(), post_init_event_thread() and deinit_event_thread()
  to simplify writing of thread functions.
sql/events.cc:
  Events::init() returns only one error code, then make it bool
sql/events.h:
  Events::init() returns only one error code, then make it bool
sql/mysqld.cc:
  Check the return code of Events::init()
sql/sp_head.cc:
  Add trace info
sql/sql_class.cc:
  Reorganize thd::change_security_context() to load main_security_ctx
sql/sql_class.h:
  Reorganize thd::change_security_context() to load main_security_ctx
sql/sql_lex.cc:
  Initialize lex->spname
sql/sql_yacc.yy:
  Add a comment
2006-07-13 10:59:58 +02:00
unknown
42a8e2c942 WL#3337 (Event scheduler new architecture)
More small fixes to the API : use LEX_STRING instead of LEX_STRING* and if error
then return bool(true) instead of error code.
Merged functions. Reduced usage of sp_name.
Fixed a lot of function documentation errors.
Added function documentation wherever needed.
Removed some unused defines and error codes.

Next to come is batch rename of Event_scheduler_ng to Event_scheduler.


mysql-test/r/events.result:
  update result
mysql-test/r/events_logs_tests.result:
  update result
mysql-test/t/events.test:
  more test coverage
mysql-test/t/events_logs_tests.test:
  fix test
sql/event_data_objects.cc:
  Cosmetics.
  Fix function documentation whenever needed.
  Move Event_job_data::compile() next to Event_job_data::execute()
sql/event_data_objects.h:
  Remove unneeded error codes and defines
  Move function declarations at the end of the header
sql/event_db_repository.cc:
  Fix function documentation.
  Event_db_repository::update_event() now uses LEX_STRING *-s instead of
  sp_name . Lower coupling.
sql/event_db_repository.h:
  Event_db_repository::update_event() now uses LEX_STRING *-s instead of
  sp_name . Lower coupling.
  find_event -> find_named_event
  find_event_by_name is not used externally, merge with load_named_event()
sql/event_queue.cc:
  LEX_STRING* to LEX_STRING
  Fix comments.
  Fix and add function documentation.
  Remove Event_queue::events_count() as it is unused
  Change get_top_for_execution_if_time() to return status code as return value
  and the object is in out parameter.
sql/event_queue.h:
  LEX_STRING* to LEX_STRING
  Fix comments.
  Fix and add function documentation.
  Remove Event_queue::events_count() as it is unused
  Change get_top_for_execution_if_time() to return status code as return value
  and the object is in out parameter.
  Try to detect also lock attemptions for deadlocks.
sql/event_scheduler_ng.cc:
  Always execute on thd->mem_root
  Fix according to changed API of Event_queue::get_top_for_execution_if_time()
sql/events.cc:
  Fix function documentation.
  Fix code after API changes of internal Event module classes.
sql/events.h:
  sp_name -> LEX_STRINGs
sql/sql_parse.cc:
  Fix according to changed API of Events::show_create_event()
sql/sql_yacc.yy:
  Don't pass NULL as third parameter to sp_head::init_strings()
2006-07-11 18:28:15 +02:00
unknown
974eecc246 WL#3337 (Event scheduler new architecture)
This patch introduces specialized Event data objects
Event_basic as parent.
Event_queue_element used for queue storage
Event_timed used for SHOW EVENTS/ I_S.EVENTS / SHOW CREATE EVENT
Event_job_data using during execution.
Methods were moved out of Event_timed to other classes.

This patch also introduces Events::LOCK_event_metadata.
This patch gives new implementation of Events::dump_internal_status().
Now both the Event_scheduler and Event_queue return information during
their ::dump_internal_status().

Shortened a bit the runtime for executing events test cases.


mysql-test/r/events.result:
  update results
mysql-test/r/events_bugs.result:
  update results
mysql-test/r/events_logs_tests.result:
  update results
mysql-test/r/events_scheduling.result:
  update results
mysql-test/t/events.test:
  update test
  make --sleep more appropriate . saving some time could mean failure on loaded boxes though :(
  add tests for previously uncovered branches.
mysql-test/t/events_bugs.test:
  update test
  make --sleep more appropriate . saving some time could mean failure on loaded boxes though :(
  add tests for previously uncovered branches.
mysql-test/t/events_logs_tests.test:
  make the test shorter by time
mysql-test/t/events_scheduling.test:
  when selecting always use ORDER BY
mysql-test/t/events_stress.test:
  sleep 2.5secs for shorter stress test
sql/event_data_objects.cc:
  Event_timed is no more used during execution.
  Event_timed is no more used during in the memory queue.
  Event_timed is only used for SHOW CREATE EVENT/ I_S.EVENTS/ SHOW EVENTS
  Event_basic is the parent of almost all Event data objects.
  Event_basic -> Event_queue_element (used for the memory queue) -> Event_timed
  Event_basic -> Event_job_data (the object used for execution)
  Sql_alloc -> Event_parse_data (used during parsing)
sql/event_data_objects.h:
  Event_timed is no more used during execution.
  Event_timed is no more used during in the memory queue.
  Event_timed is only used for SHOW CREATE EVENT/ I_S.EVENTS/ SHOW EVENTS
  Event_basic is the parent of almost all Event data objects.
  Event_basic -> Event_queue_element (used for the memory queue) -> Event_timed
  Event_basic -> Event_job_data (the object used for execution)
  Sql_alloc -> Event_parse_data (used during parsing)
sql/event_db_repository.cc:
  Cosmetics.
  load_named_event now uses Event_basic, for polymorphism
  find_event uses Event_basic, to be polymorphic.
  use Field **fields= table->field and then index fields[...]
  Add documentation.
  Fix documentation.
sql/event_db_repository.h:
  Event_db_repository depends only on Event_basic's interface
sql/event_queue.cc:
  Cosmetics.
  Don't use Event_timed for the queue and giving back object for execution.
  Event_queue_element is for the queue, Event_job_data is for execution.
  Add Event_queue::dump_internal_status() for SHOW SCHEDULER STATUS command
sql/event_queue.h:
  Cosmetics.
  Don't use Event_timed for the queue and giving back object for execution.
  Event_queue_element is for the queue, Event_job_data is for execution.
  Add Event_queue::dump_internal_status() for SHOW SCHEDULER STATUS command
sql/event_scheduler_ng.cc:
  Add back Event_scheduler::cond_wait()
  Add back Event_scheduler::dump_internal_status()
  Using Event_job_data for execution. Make the scheduler thread unkillable (thd->command= COM_DAEMON).
  Add a lot of documentation.
sql/event_scheduler_ng.h:
  Add back Event_scheduler::cond_wait()
  Add back Event_scheduler::dump_internal_status()
  Using Event_job_data for execution.
sql/events.cc:
  Documentation
  Add LOCK_event_metadata
sql/events.h:
  Change the signature of Events::drop_event() not to use sp_name but LEX_STRING
sql/share/errmsg.txt:
  Fix error message
sql/sql_parse.cc:
  Events::drop_event() has new signature
2006-07-10 13:44:43 +02:00
unknown
b9a7fe2757 WL#3337 (Event scheduler new architecture)
Cleaned up the code a bit. Fixed few leaks.
This code still does not load events on server startup
from disk. The problem is that there is a need for a THD instance, which
does not exist during server boot. This will be solved soon.
Still Event_timed is used both for the memory queue and for exectution.
This will be changed according to WL#3337 probably in the next commit.


sql/event_data_objects.cc:
  Strip unneeded stuff from class Event_timed
  Event_timed is still used for the queue and execution.
  That will be changed in the next commit.
sql/event_data_objects.h:
  Strip unneeded stuff from class Event_timed
  Event_timed is still used for the queue and execution.
  That will be changed in the next commit.
sql/event_db_repository.cc:
  Cosmetics.
  Add a new method load_named_event_job, to be made complete in the 
  next commit. It will load from disk an instance of Event_job_data to
  be used during execution.
sql/event_db_repository.h:
  find_event does not need MEM_ROOT anymore
  because the memory is allocated on Event's own root.
sql/event_queue.cc:
  Remove dead code.
  Move dumping of the queue to separate method.
  Make critical sections in create_event & update_event
  as small as possible - load the new event outside of the section
  and free the object also outside of it.
sql/event_queue.h:
  init -> init_queue -> easier for ctags
  deinit -> deinit_queue -> easier for ctags
sql/event_scheduler.cc:
  empty this file
sql/event_scheduler.h:
  empty this file
sql/event_scheduler_ng.cc:
  add back DBUG_RETURN(0) in thread handlers.
  We don't stop running events when stopping the scheduler. Therefore
  remove this method now. If it is needed later it can be added back.
sql/event_scheduler_ng.h:
  Remove stop_all_running_threads()
  init -> init_scheduler
  deinit -> deinit_scheduler
  easier for ctags
sql/events.cc:
  Cosmetics
sql/events.h:
  Cosmetics
sql/set_var.cc:
  Remove references to dead code
sql/sql_parse.cc:
  Reorganize a bit.
2006-07-05 17:12:50 +02:00
unknown
a5dfeb02e9 WL #3337 (Event scheduler new architecture)
Cut Nr. 8.

All tests pass.

Separated Event_scheduler into Event_queue and Event_scheduler.
Added new Event_scheduler_ng which is the new scheduler and is used
system-wide. Will be moved to the event_scheduler.cc in the future.
Using Event_timed in Event_queue as well as cloned during execution.
Next step is to have Event_worker_data which will be used during execution
and will take ::compile()/::execute() out of Event_timed.


mysql-test/r/events.result:
  update result
mysql-test/r/events_bugs.result:
  update result
mysql-test/r/ps_1general.result:
  update result
mysql-test/r/skip_name_resolve.result:
  update result
mysql-test/r/sp-threads.result:
  update result
mysql-test/r/sp_notembedded.result:
  update result
mysql-test/r/status.result:
  update result
mysql-test/t/events_stress.test:
  Make event_stress a bit longer
sql/Makefile.am:
  Add new event_scheduler_ng.h/cc . These are only to be in the experimental
  clone. Later their content will be moved to event_scheduler.h/cc
sql/event_data_objects.cc:
  Allocate strings memory on own memory root, instead
  on the schedulers. Thus don't "leak" memory. This should
  fix bug#18683 memory leak in event scheduler
sql/event_data_objects.h:
  add mem_root
  add THD - this is only temporal, will be moved to class Event_job_data
  once Event_job_data is responsible for the execution.
sql/event_db_repository.cc:
  Remove unused code.
  Cosmetic changes
sql/event_queue.cc:
  Now use the Event_scheduler_ng (NextGen)
sql/event_queue.h:
  Now use the Event_scheduler_ng (NextGen)
sql/event_scheduler.cc:
  This file is no more used, but will be soon.
sql/event_scheduler.h:
  This file is no more used but will be soon
sql/events.cc:
  Now use the Event_scheduler_ng (NextGen)
sql/events.h:
  Now use the Event_scheduler_ng (NextGen)
sql/mysqld.cc:
  Make it again possible to kill the scheduler thread
sql/set_var.cc:
  Now use the Event_scheduler_ng (NextGen)
sql/share/errmsg.txt:
  Shorten the message.
sql/sql_show.cc:
  Loading is on a own root, then don't use thd->mem_root
2006-07-04 18:44:35 +02:00
unknown
9fa9378b2e WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
  a mutex. Event_parse_data class is used during parsing. It is suited only
  for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
  the problems of nested events in SP or other events (for the situation 
  of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
  SP was compiled, and not executed, the actual init_xxx methods of Event_timed
  were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
  now 25% quicker.

Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.


mysql-test/r/events.result:
  update result
mysql-test/t/events.test:
  disabled is actually wrong, should be disable, but because of the early
  checking it was never parsed.
sql/event_data_objects.cc:
  move add init_xxx methods from Event_timed to Event_parse_data
  Event_parse data does not need definer_user and definer_host
  in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
  move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
  No more Event_timed comes from parsing but Event_parse_data
  The initialization of Item*-s from parsing is done late, and not
  during the actual parsing. This is the right way to go because
  if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
  executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
  No more Event_timed comes from parsing but Event_parse_data
  The initialization of Item*-s from parsing is done late, and not
  during the actual parsing. This is the right way to go because
  if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
  executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
  No more Event_timed comes from parsing but Event_parse_data
  The initialization of Item*-s from parsing is done late, and not
  during the actual parsing. This is the right way to go because
  if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
  executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
  No more Event_timed comes from parsing but Event_parse_data
  The initialization of Item*-s from parsing is done late, and not
  during the actual parsing. This is the right way to go because
  if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
  executed (initialized) during parsing, as it was done.
sql/events.cc:
  No more Event_timed comes from parsing but Event_parse_data
  The initialization of Item*-s from parsing is done late, and not
  during the actual parsing. This is the right way to go because
  if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
  executed (initialized) during parsing, as it was done.
sql/events.h:
  No more Event_timed comes from parsing but Event_parse_data
  The initialization of Item*-s from parsing is done late, and not
  during the actual parsing. This is the right way to go because
  if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
  executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
  lex->et_compile_phase and lex->et are no more.
  Use lex->event_parse_data
sql/sql_lex.h:
  lex->et_compile_phase and lex->et are no more.
  Use lex->event_parse_data
sql/sql_parse.cc:
  lex->et_compile_phase and lex->et are no more.
  Use lex->event_parse_data
  ACL checks were moved inside the Events subsystem.
  Also ending of the transaction is performed only just
  before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
  lex->et and lex->et_parse_phase are no more
  Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
unknown
acefb78bc3 WL#3337 (Events new architecture)
5th cut, moved DB related code to Event_db_repository and
updated accordingly the remanining code.
Moved change/restore_security_context() to class THD
Removed events_priv.h
Next step is to reorganize create/update_event() and parsing for them.
But probably some other refactoring could be done in the meanwhile.
The changes so far pass the test suite.


BitKeeper/deleted/.del-events_priv.h~2e8bce2cf35997df:
  Delete: sql/events_priv.h
sql/Makefile.am:
  events_priv.h is no more
sql/event_data_objects.cc:
  reorganize events code
sql/event_data_objects.h:
  reorganize events code
sql/event_db_repository.cc:
  reorganize events code
sql/event_db_repository.h:
  reorganize events code
sql/event_scheduler.cc:
  reorganize events code
sql/event_scheduler.h:
  reorganize events code
sql/events.cc:
  reorganize events code
sql/events.h:
  reorganize events code
sql/mysqld.cc:
  reorganize events code
sql/set_var.cc:
  reorganize events code
sql/sql_class.cc:
  add ::change_security_context() and restore_security_context()
sql/sql_class.h:
  add ::change_security_context() and restore_security_context()
sql/sql_db.cc:
  reorganize Events code
sql/sql_parse.cc:
  reorganize Events code
sql/sql_show.cc:
  reorganize Events code
2006-06-28 01:28:03 +02:00
unknown
d2db48c69b WL#3337 (Events new infrasctructure)
Second cut of separating parsing phase from execution phase
Separate Event_timed from parsing phase and introducing Event_parse_data.


sql/event_data_objects.cc:
  second cut,
  copy Event_timed::init_body() to Event_parse_data::init_body()
  Init the body during parsing, everything else keep as a pointer to
  Item or some other pointer to use for later initialization.
sql/event_data_objects.h:
  get the identifier as sp_name*, later will initialize our structures
sql/events.cc:
  for easy transition add temporarily parse_data, later Event_timed *et will be removed.
  Do slow transition because Event_timed is so tightly integrated that a front-attack
  by removing things from this class was unsuccessful. Do things step by step by eliminating
  dependencies. Hence, the code could be checked with the current test suite too
  (early testing)
sql/events.h:
  for easy transition add temporarily parse_data, later Event_timed *et will be removed.
  Do slow transition because Event_timed is so tightly integrated that a front-attack
  by removing things from this class was unsuccessful. Do things step by step by eliminating
  dependencies. Hence, the code could be checked with the current test suite too
  (early testing)
BitKeeper/etc/ignore:
  Added libmysql/viosocket.o.6WmSJk libmysqld/event_data_objects.cc libmysqld/event_db_repository.cc libmysqld/event_queue.cc server-tools/instance-manager/net_serv.cc to the ignore list
sql/share/errmsg.txt:
  remove this message, not used and needed for now
sql/sql_lex.h:
  for easy transition add temporarily parse_data, later Event_timed *et will be removed.
  Do slow transition because Event_timed is so tightly integrated that a front-attack
  by removing things from this class was unsuccessful. Do things step by step by eliminating
  dependencies. Hence, the code could be checked with the current test suite too
  (early testing)
sql/sql_parse.cc:
  for easy transition add temporarily parse_data, later Event_timed *et will be removed.
  Do slow transition because Event_timed is so tightly integrated that a front-attack
  by removing things from this class was unsuccessful. Do things step by step by eliminating
  dependencies. Hence, the code could be checked with the current test suite too
  (early testing)
sql/sql_yacc.yy:
  for easy transition add temporarily parse_data, later Event_timed *et will be removed.
  Do slow transition because Event_timed is so tightly integrated that a front-attack
  by removing things from this class was unsuccessful. Do things step by step by eliminating
  dependencies. Hence, the code could be checked with the current test suite too
  (early testing)
2006-06-27 10:53:26 +02:00
unknown
e5f8163b88 first cut of WL#3337 (New event scheduler locking infrastructure).
Infrastructure built. Added the  foreseen files and change Makefile.am/CMakeLists.txt
accordingly.


libmysqld/Makefile.am:
  add new files. this is first cut of WL3337u
sql/CMakeLists.txt:
  add more files to build
sql/Makefile.am:
  add new files. this is first cut of WL3337
sql/event_scheduler.cc:
  event_timed.h -> event_data_objects.h (WL#3337)
sql/events.cc:
  event_timed.h -> event_data_objects.h (WL#3337)
sql/share/errmsg.txt:
  new error message
sql/event_data_objects.cc:
  event_timed.h -> event_data_objects.h (WL#3337)
sql/event_data_objects.h:
  event_timed.h -> event_data_objects.h (WL#3337)
sql/sql_parse.cc:
  event_timed.h -> event_data_objects.h (WL#3337)
sql/sql_show.cc:
  event_timed.h -> event_data_objects.h (WL#3337)
sql/sql_yacc.yy:
  event_timed.h -> event_data_objects.h (WL#3337)
2006-06-27 08:48:50 +02:00
Renamed from sql/event_timed.h (Browse further)