Commit graph

23107 commits

Author SHA1 Message Date
unknown
d0e99dfa26 Merge adventure.(none):/home/thek/Development/cpp/bug27440/my51-bug27440
into  adventure.(none):/home/thek/Development/cpp/mysql-5.1-runtime


sql/sql_parse.cc:
  Auto merged
2007-12-10 12:14:52 +01:00
unknown
c84a285035 Merge adventure.(none):/home/thek/Development/cpp/bug27440/my50-bug27440
into  adventure.(none):/home/thek/Development/cpp/bug27440/my51-bug27440


mysql-test/r/read_only.result:
  Manual merge
mysql-test/t/read_only.test:
  Manual merge
sql/sql_parse.cc:
  Manual merge
2007-12-10 10:32:07 +01:00
unknown
5826a5c490 Bug #27440 read_only allows create and drop database
When read_only option was enabled, a user without SUPER privilege could
perform CREATE DATABASE and DROP DATABASE operations.

This patch adds a check to make sure this isn't possible. It also attempts to 
simplify the logic used to determine if relevant tables are updated,
making it more human readable.


mysql-test/r/read_only.result:
  Updated result file
mysql-test/t/read_only.test:
  A test case is added which shows that it is not possible to drop or create a
  database in read-only mode despite having the GRANT permissions to do so,
  SUPER user excepted.
sql/sql_parse.cc:
  - Simplified complex predicate by grouping it in a read friendly way.
  - Added predicate to fail on database updates while running in read-only
    mode.
2007-12-07 15:39:41 +01:00
unknown
6923c36a09 Merge bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
into  mysql.com:/Users/davi/mysql/mysql-5.1-runtime
2007-11-30 14:07:36 -02:00
unknown
4b954cc094 A patch for BUG#32148: killing a query may be ineffective.
The problem was that THD::killed was reset after a command was
read from the socket, but before it was actually handled. That lead
to a race: if another KILL statement was issued for this connection
in the middle of reading from the socket and processing a command,
THD::killed state would be cleaned.

The fix is to move this cleanup into net_send_error() function.

A sample test case exists in binlog_killed.test:
  - connection 1: start a new transaction on table t1;
  - connection 2: send query to the server (w/o waiting for the
    result) to update data in table t1 -- this query will be blocked
    since there is unfinished transaction;
  - connection 1: kill query in connection 2 and finish the transaction;
  - connection 2: get result of the previous query -- it should be
    the "query-killed" error.

This test however contains race condition, which can not be fixed
with the current protocol: there is no way to guarantee, that the
server will receive and start processing the query in connection 2
(which is intended to get blocked) before the KILL command (sent in
the connection 1) will arrive. In other words, there is no way to
ensure that the following sequence will not happen:

  - connection 1: start a new transaction on table t1;
  - connection 1: kill query in connection 2 and finish the transaction;
  - connection 2: send query to the server (w/o waiting for the
    result) to update data in table t1 -- this query will be blocked
    since there is unfinished transaction;
  - connection 2: get result of the previous query -- the query will
    succeed.

So, there is no test case for this bug, since it's impossible
to write a reliable test case under the current circumstances.


sql/protocol.cc:
  Move thd->killed cleanup from dispatch_command() to net_send_error().
sql/sql_parse.cc:
  Move thd->killed cleanup from dispatch_command() to net_send_error().
2007-11-30 16:12:20 +03:00
unknown
cdc382e7fd Bug#22312 Syntax error in expression with INTERVAL()
Parser rejects valid INTERVAL() expressions when associated with
arithmetic operators. The problem is the way in which the expression
and interval grammar rules were organized caused shift/reduce conflicts.

The solution is to tweak the interval rules to avoid shift/reduce
conflicts by removing the broken interval_expr rule and explicitly
specify it's content where necessary.

Original fix by Davi Arnaut, revised and improved rules by Marc Alff


mysql-test/r/parser.result:
  Add test case result for Bug#22312
mysql-test/t/parser.test:
  Add test case for Bug#22312
sql/sql_yacc.yy:
  Resolve shift/reduce conflicts by reorganizing the interval
  expression rules.
2007-11-30 09:34:25 -02:00
unknown
87143063d3 Bug#23713 LOCK TABLES + CREATE TRIGGER + FLUSH TABLES WITH READ LOCK = deadlock
This bug is actually two bugs in one, one of which is CREATE TRIGGER under
LOCK TABLES and the other is CREATE TRIGGER under LOCK TABLES simultaneous
to a FLUSH TABLES WITH READ LOCK (global read lock). Both situations could
lead to a server crash or deadlock.

The first problem arises from the fact that when under LOCK TABLES, if the
table is in the set of locked tables, the table is already open and it doesn't
need to be reopened (not a placeholder). Also in this case, if the table is
not write locked, a exclusive lock can't be acquired because of a possible
deadlock with another thread also holding a (read) lock on the table. The
second issue arises from the fact that one should never wait for a global
read lock if it's holding any locked tables, because the global read lock
is waiting for these tables and this leads to a circular wait deadlock.

The solution for the first case is to check if the table is write locked
and upgraded the write lock to a exclusive lock and fail otherwise for non
write locked tables. Grabbin the exclusive lock in this case also means
to ensure that the table is opened only by the calling thread. The second
issue is partly fixed by not waiting for the global read lock if the thread
is holding any locked tables.

The second issue is only partly addressed in this patch because it turned
out to be much wider and also affects other DDL statements. Reported as
Bug#32395


mysql-test/r/trigger.result:
  Add test case result for Bug#23713
mysql-test/r/trigger_notembedded.result:
  Add test case result for Bug#23713
mysql-test/t/trigger.test:
  Add test case for Bug#23713
mysql-test/t/trigger_notembedded.test:
  Add test case for Bug#23713
sql/mysql_priv.h:
  Locally export wait_while_table_is_used and name_lock_locked_table
  and add flag to mysql_ha_rm_tables to signal that LOCK_open is locked.
sql/sql_base.cc:
  Introduce name_lock_locked_table function and match
  close_old_data_files function declaration and definition.
sql/sql_handler.cc:
  Add flag to mysql_ha_rm_tables to signal that LOCK_open is locked.
sql/sql_rename.cc:
  Fix mysql_ha_rm_tables caller.
sql/sql_table.cc:
  Export wait_while_table_is_used and assert that LOCK_open is locked
  and fix mysql_ha_rm_tables caller.
sql/sql_trigger.cc:
  Upgrade write locked tables to a exclusive lock and fail if
  the table is not write locked. Also, don't wait for the global
  read lock if under LOCK TABLES.
2007-11-29 09:42:26 -02:00
unknown
b512270e54 Manual merge 2007-11-28 08:41:45 -07:00
unknown
f927182efe Merge lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.1-base
into  lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.1-rt-merge


sql/events.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/sql_table.cc:
  manual merge
2007-11-28 07:42:36 -07:00
unknown
30aee30b0d Merge stella.local:/home2/mydev/mysql-5.1-amain
into  stella.local:/home2/mydev/mysql-5.1-axmrg


include/my_base.h:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/suite/ndb/t/disabled.def:
  Auto merged
mysql-test/t/partition.test:
  Auto merged
sql/handler.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
client/mysql.cc:
  Manual merge
mysql-test/suite/rpl/t/disabled.def:
  Manual merge
2007-11-27 19:29:10 +01:00
unknown
8bfcdce04d Merge lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.1-base
into  lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.1-rt-merge


sql/mysqld.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-11-27 09:03:04 -07:00
unknown
7eb5a83de6 Merge mysql.com:/home/ram/work/b30495/b30495.5.0
into  mysql.com:/home/ram/work/b30495/b30495.5.1


mysql-test/r/analyze.result:
  Auto merged
mysql-test/t/analyze.test:
  Auto merged
sql/sql_yacc.yy:
  5.0 -> 5.1 manual merging (see bug #30495: optimize table t1,t2,t3 extended errors):
  CHECK options disabled for ANALYZE/OPTIMIZE PARTITION.
2007-11-27 10:14:46 +04:00
unknown
f1ad502ae1 Merge adventure.(none):/home/thek/Development/cpp/bug16470/my51-bug16470
into  adventure.(none):/home/thek/Development/cpp/mysql-5.1-runtime


mysql-test/r/grant.result:
  Auto merged
mysql-test/t/grant.test:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_parse.cc:
  manual merge
2007-11-26 19:31:41 +01:00
unknown
1ddb4722f4 Bug#16470 crash on grant if old grant tables
Loading 4.1 into 5.0 or 5.1 failed silently because procs_priv table missing.
This caused the server to crash on any attempt to store new grants because
of uninitialized structures.

This patch breaks up the grant loading function into two phases to allow
for procs_priv table to fail with an warning instead of crashing the server.


mysql-test/r/grant.result:
  Test case
mysql-test/t/grant.test:
  Test case making sure that FLUSH PRIVILEGES doesn't crash the server if
  procs_priv is removed.
sql/sql_acl.cc:
  - Refactored grant_reload into two phases: 1. open and lock tables_priv and 
    columns_priv tables, read the data, close tables. 2. open and lock
    procs_priv, read data, close table. Since the tables are independant of
    each other there will be no race conditions and it will be possible to
    handle situations where the procs_priv table isn't present.
  - Refactored the helper function grant_load into new grant_load (without
    procs_priv table) and grant_load_procs_priv.
sql/sql_parse.cc:
  - Changed comment style to doxygen style.
2007-11-26 19:09:40 +01:00
unknown
1522ef3f21 Merge adventure.(none):/home/thek/Development/cpp/bug32436/my51-bug32436
into  adventure.(none):/home/thek/Development/cpp/mysql-5.1-runtime


sql/item_func.cc:
  Auto merged
2007-11-26 15:59:09 +01:00
unknown
0b65a2e710 Merge adventure.(none):/home/thek/Development/cpp/bug32436/my50-bug32436
into  adventure.(none):/home/thek/Development/cpp/bug32436/my51-bug32436


sql/item_func.cc:
  Auto merged
2007-11-26 15:45:13 +01:00
unknown
fea1524dbf Bug #32436 KILL QUERY completely deadlocks mysqld
Sending several "KILL QUERY" statements to target a connection running
"SELECT SLEEP" could freeze the server.

The locking order in Item_func_sleep was wrong and this could lead to a
dead lock.

This patch solves the issue by resolving the locking order properly.


sql/item_func.cc:
  - Moved LOCK_user_locks critical region so that it doesn't share space with
    mysys_var->mutex region; this can lead to deadlock.
2007-11-26 15:44:05 +01:00
unknown
a41eb64590 Merge mysql.com:/home/ram/work/b32560/b32560.5.0
into  mysql.com:/home/ram/work/b32560/b32560.5.1


mysql-test/r/func_set.result:
  Auto merged
sql/item_cmpfunc.cc:
  SCCS merged
2007-11-23 16:43:49 +04:00
unknown
1f57bfb8d1 Fix for bug #32560: crash with interval function and count(*)
Problem: INTERVAL function implementation doesn't handle NULL range values.

Fix: skip NULL ranges looking for a proper one.


mysql-test/r/func_set.result:
  Fix for bug #32560: crash with interval function and count(*)
    - test result.
mysql-test/t/func_set.test:
  Fix for bug #32560: crash with interval function and count(*)
    - test case.
sql/item_cmpfunc.cc:
  Fix for bug #32560: crash with interval function and count(*)
    - skip NULL ranges calculating INTERVAL(...).
2007-11-23 16:30:06 +04:00
unknown
6cc8a820d3 Merge mysql.com:/home/ram/work/b32558/b32558.5.0
into  mysql.com:/home/ram/work/b32558/b32558.5.1


mysql-test/r/olap.result:
  Auto merged
sql/item_func.h:
  Auto merged
2007-11-23 12:35:02 +04:00
unknown
ed4edda18f Merge endora.local:/Users/davi/mysql/bugs/32528-5.0
into  endora.local:/Users/davi/mysql/mysql-5.1-runtime


sql/sql_parse.cc:
  Auto merged
mysql-test/r/flush.result:
  SCCS merged
mysql-test/t/flush.test:
  SCCS merged
2007-11-22 10:32:34 -02:00
unknown
a8b4bc8165 Merge endora.local:/Users/davi/mysql/bugs/32528-5.0
into  endora.local:/Users/davi/mysql/mysql-5.0-runtime
2007-11-22 10:20:12 -02:00
unknown
719e64e4a5 Bug#32528 Global read lock with a low priority write lock causes a server crash
FLUSH TABLES WITH READ LOCK fails to properly detect write locked
tables when running under low priority updates.

The problem is that when trying to aspire a global read lock, the
reload_acl_and_cache() function fails to properly check if the thread
has a low priority write lock, which later my cause a server crash or
deadlock.

The solution is to simple check if the thread has any type of the
possible exclusive write locks.


mysql-test/r/flush.result:
  Add test case result for Bug#32528
mysql-test/t/flush.test:
  Add test case for Bug#32528
sql/sql_parse.cc:
  Although it should not matter under LOCK TABLES, use TL_WRITE_ALLOW_WRITE
  to emphasize that it should fail in case of any write lock.
2007-11-22 10:18:19 -02:00
unknown
0190008095 Merge lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.1-base
into  lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.1-rt-merge


mysql-test/r/events_bugs.result:
  Auto merged
mysql-test/t/information_schema.test:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-11-21 18:42:15 -07:00
unknown
a11256f49a Merge lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.0-base
into  lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.0-rt-merge


sql/mysqld.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-11-21 18:35:02 -07:00
unknown
692f0e4f67 Merge dl145h.mysql.com:/data0/mkindahl/mysql-5.1
into  dl145h.mysql.com:/data0/mkindahl/mysql-5.1-rpl-merge


client/mysql.cc:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/r/ctype_ucs.result:
  Auto merged
mysql-test/r/mysql.result:
  Auto merged
mysql-test/suite/ndb/r/ndb_dd_basic.result:
  Auto merged
mysql-test/suite/rpl/r/rpl_extraCol_innodb.result:
  Auto merged
mysql-test/suite/rpl/r/rpl_extraCol_myisam.result:
  Auto merged
mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result:
  Auto merged
mysql-test/t/ctype_uca.test:
  Auto merged
mysql-test/t/ctype_ucs.test:
  Auto merged
mysql-test/t/innodb.test:
  Auto merged
mysql-test/t/mysql.test:
  Auto merged
mysql-test/t/partition.test:
  Auto merged
mysql-test/t/subselect.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/innodb.result:
  Manual merge.
2007-11-21 21:15:33 +01:00
unknown
569c2dcd12 Merge adventure.(none):/home/thek/Development/cpp/bug31153/my51-bug31153
into  adventure.(none):/home/thek/Development/cpp/mysql-5.1-runtime


sql/mysqld.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-11-21 20:57:28 +01:00
unknown
0c2dac2a8b Fix for bug #32558: group by null-returning expression with rollup causes crash
Problem: setting Item_func_rollup_const::null_value property to argument's null_value
before (without) the argument evaluation may result in a crash due to wrong null_value.

Fix: use is_null() to set Item_func_rollup_const::null_value instead as it evaluates
the argument if necessary and returns a proper value.


mysql-test/r/olap.result:
  Fix for bug #32558: group by null-returning expression with rollup causes crash
    - test result.
mysql-test/t/olap.test:
  Fix for bug #32558: group by null-returning expression with rollup causes crash
    - test case.
sql/item_func.h:
  Fix for bug #32558: group by null-returning expression with rollup causes crash
    - use args[0]->is_null() to obtain Item_func_rollup_const::null_value 
      instead of args[0]->null_value as it's not set in advance in case of 
      constant functions.
2007-11-21 20:53:44 +04:00
unknown
961cc887bf Fix for bug #32557: order by updatexml causes assertion in filesort
Problem: even if an Item_xml_str_func successor returns NULL, it doesn't have 
a corresponding property (maybe_null) set, that leads to a failed assertion.

Fix: set nullability property of Item_xml_str_func.


mysql-test/r/xml.result:
  Fix for bug #32557: order by updatexml causes assertion in filesort
    - test result.
mysql-test/t/xml.test:
  Fix for bug #32557: order by updatexml causes assertion in filesort
    - test case.
sql/item_xmlfunc.h:
  Fix for bug #32557: order by updatexml causes assertion in filesort
    - set Item_xml_str_func::maybe_null.
2007-11-21 16:00:09 +04:00
unknown
bc54a3736f Merge adventure.(none):/home/thek/Development/cpp/bug31153/my50-bug31153
into  adventure.(none):/home/thek/Development/cpp/bug31153/my51-bug31153


sql/mysqld.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_yacc.yy:
  Null merge.
sql/sql_base.cc:
  Manual merge
sql/sql_lex.h:
  Manual merge
2007-11-21 11:25:17 +01:00
unknown
1ae0237f24 Merge adventure.(none):/home/thek/Development/cpp/bug31153/my50-bug31153
into  adventure.(none):/home/thek/Development/cpp/mysql-5.0-runtime


sql/mysqld.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_yacc.yy:
  Manual merge.
2007-11-21 10:02:44 +01:00
unknown
18851d9ea7 Fix for bug #30495: optimize table t1,t2,t3 extended errors
Problem: we have CHECK TABLE options allowed (by accident?) for
ANALYZE/OPTIMIZE TABLE.

Fix: disable them.

Note: it might require additional fixes in 5.1/6.0


mysql-test/r/analyze.result:
  Fix for bug #30495: optimize table t1,t2,t3 extended errors
    - test result.
mysql-test/t/analyze.test:
  Fix for bug #30495: optimize table t1,t2,t3 extended errors
    - test case.
sql/sql_yacc.yy:
  Fix for bug #30495: optimize table t1,t2,t3 extended errors
    - opt_mi_check_type (CHECK TABLE options) removed from analyze: and optimize:
2007-11-21 11:11:22 +04:00
unknown
f2a631f0dc Fix for bug #32021: Using Date 000-00-01 in WHERE causes wrong result
Problem: caching 00000000-00000099 dates as integer values we're 
improperly shifting them up twice in the get_datetime_value().
  
Fix: don't shift cached DATETIME values up for the second time.


mysql-test/r/type_date.result:
  Fix for bug #32021: Using Date 000-00-01 in WHERE causes wrong result
    - test result.
mysql-test/t/type_date.test:
  Fix for bug #32021: Using Date 000-00-01 in WHERE causes wrong result
    - test case.
sql/item.h:
  Fix for bug #32021: Using Date 000-00-01 in WHERE causes wrong result
    - Item_cache::field_type() method added.
    - new Item_cache(enum_field_types) and Item_cache_int(enum_field_types) 
      constructors added.
sql/item_cmpfunc.cc:
  Fix for bug #32021: Using Date 000-00-01 in WHERE causes wrong result
    - don't shift cached DATETIME values for the second time in the
      get_datetime_value():
        creating new Item_cache_int set DATETIME filed type,
        check the type before shifting.
2007-11-21 08:01:00 +04:00
unknown
a3dc40e24a Applied InnoDB snapshot innodb-5.0-ss2095
Fixes the following bugs:

- Bug #29560: InnoDB >= 5.0.30 hangs on adaptive hash rw-lock 'waiting for an X-lock'

  Fixed a race condition in the rw_lock where an os_event_reset()
  can overwrite an earlier os_event_set() triggering an indefinite
  wait.
  NOTE: This fix for windows is different from that for other platforms.
  NOTE2: This bug is introduced in the scalability fix to the
  sync0arr which was applied to 5.0 only. Therefore, it need not be
  applied to the 5.1 tree. If we decide to port the scalability fix
  to 5.1 then this fix should be ported as well.

- Bug #32125: Database crash due to ha_innodb.cc:3896: ulint convert_search_mode_to_innobase

  When unknown find_flag is encountered in convert_search_mode_to_innobase()
  do not call assert(0); instead queue a MySQL error using my_error() and
  return the error code PAGE_CUR_UNSUPP. Change the functions that call
  convert_search_mode_to_innobase() to handle that error code by "canceling"
  execution and returning appropriate error code further upstream.


innobase/include/db0err.h:
  Applied InnoDB snapshot innodb-5.0-ss2095
  
  Revision r2091:
  branches/5.0:
   
  Merge r2088 from trunk:
   
  log for r2088:
  
  Fix Bug#32125 (http://bugs.mysql.com/32125)
  "Database crash due to ha_innodb.cc:3896: ulint convert_search_mode_to_innobase":
  
  When unknown find_flag is encountered in convert_search_mode_to_innobase()
  do not call assert(0); instead queue a MySQL error using my_error() and
  return the error code PAGE_CUR_UNSUPP. Change the functions that call
  convert_search_mode_to_innobase() to handle that error code by "canceling"
  execution and returning appropriate error code further upstream.
  
  Approved by:	Heikki
innobase/include/os0sync.h:
  Applied InnoDB snapshot innodb-5.0-ss2095
  
  Revision r2082:
  branches/5.0:  bug#29560
  
  Fixed a race condition in the rw_lock where an os_event_reset()
  can overwrite an earlier os_event_set() triggering an indefinite
  wait.
  NOTE: This fix for windows is different from that for other platforms.
  NOTE2: This bug is introduced in the scalability fix to the
  sync0arr which was applied to 5.0 only. Therefore, it need not be
  applied to the 5.1 tree. If we decide to port the scalability fix
  to 5.1 then this fix should be ported as well.
  
  Reviewed by: Heikki
innobase/include/page0cur.h:
  Applied InnoDB snapshot innodb-5.0-ss2095
  
  Revision r2091:
  branches/5.0:
   
  Merge r2088 from trunk:
   
  log for r2088:
  
  Fix Bug#32125 (http://bugs.mysql.com/32125)
  "Database crash due to ha_innodb.cc:3896: ulint convert_search_mode_to_innobase":
  
  When unknown find_flag is encountered in convert_search_mode_to_innobase()
  do not call assert(0); instead queue a MySQL error using my_error() and
  return the error code PAGE_CUR_UNSUPP. Change the functions that call
  convert_search_mode_to_innobase() to handle that error code by "canceling"
  execution and returning appropriate error code further upstream.
  
  Approved by:	Heikki
innobase/include/sync0rw.h:
  Applied InnoDB snapshot innodb-5.0-ss2095
  
  Revision r2082:
  branches/5.0:  bug#29560
  
  Fixed a race condition in the rw_lock where an os_event_reset()
  can overwrite an earlier os_event_set() triggering an indefinite
  wait.
  NOTE: This fix for windows is different from that for other platforms.
  NOTE2: This bug is introduced in the scalability fix to the
  sync0arr which was applied to 5.0 only. Therefore, it need not be
  applied to the 5.1 tree. If we decide to port the scalability fix
  to 5.1 then this fix should be ported as well.
  
  Reviewed by: Heikki
innobase/include/sync0rw.ic:
  Applied InnoDB snapshot innodb-5.0-ss2095
  
  Revision r2082:
  branches/5.0:  bug#29560
  
  Fixed a race condition in the rw_lock where an os_event_reset()
  can overwrite an earlier os_event_set() triggering an indefinite
  wait.
  NOTE: This fix for windows is different from that for other platforms.
  NOTE2: This bug is introduced in the scalability fix to the
  sync0arr which was applied to 5.0 only. Therefore, it need not be
  applied to the 5.1 tree. If we decide to port the scalability fix
  to 5.1 then this fix should be ported as well.
  
  Reviewed by: Heikki
innobase/include/sync0sync.ic:
  Applied InnoDB snapshot innodb-5.0-ss2095
  
  Revision r2082:
  branches/5.0:  bug#29560
  
  Fixed a race condition in the rw_lock where an os_event_reset()
  can overwrite an earlier os_event_set() triggering an indefinite
  wait.
  NOTE: This fix for windows is different from that for other platforms.
  NOTE2: This bug is introduced in the scalability fix to the
  sync0arr which was applied to 5.0 only. Therefore, it need not be
  applied to the 5.1 tree. If we decide to port the scalability fix
  to 5.1 then this fix should be ported as well.
  
  Reviewed by: Heikki
innobase/os/os0sync.c:
  Applied InnoDB snapshot innodb-5.0-ss2095
  
  Revision r2082:
  branches/5.0:  bug#29560
  
  Fixed a race condition in the rw_lock where an os_event_reset()
  can overwrite an earlier os_event_set() triggering an indefinite
  wait.
  NOTE: This fix for windows is different from that for other platforms.
  NOTE2: This bug is introduced in the scalability fix to the
  sync0arr which was applied to 5.0 only. Therefore, it need not be
  applied to the 5.1 tree. If we decide to port the scalability fix
  to 5.1 then this fix should be ported as well.
  
  Reviewed by: Heikki
innobase/srv/srv0srv.c:
  Applied InnoDB snapshot innodb-5.0-ss2095
  
  Revision r2082:
  branches/5.0:  bug#29560
  
  Fixed a race condition in the rw_lock where an os_event_reset()
  can overwrite an earlier os_event_set() triggering an indefinite
  wait.
  NOTE: This fix for windows is different from that for other platforms.
  NOTE2: This bug is introduced in the scalability fix to the
  sync0arr which was applied to 5.0 only. Therefore, it need not be
  applied to the 5.1 tree. If we decide to port the scalability fix
  to 5.1 then this fix should be ported as well.
  
  Reviewed by: Heikki
innobase/sync/sync0arr.c:
  Applied InnoDB snapshot innodb-5.0-ss2095
  
  Revision r2082:
  branches/5.0:  bug#29560
  
  Fixed a race condition in the rw_lock where an os_event_reset()
  can overwrite an earlier os_event_set() triggering an indefinite
  wait.
  NOTE: This fix for windows is different from that for other platforms.
  NOTE2: This bug is introduced in the scalability fix to the
  sync0arr which was applied to 5.0 only. Therefore, it need not be
  applied to the 5.1 tree. If we decide to port the scalability fix
  to 5.1 then this fix should be ported as well.
  
  Reviewed by: Heikki
innobase/sync/sync0rw.c:
  Applied InnoDB snapshot innodb-5.0-ss2095
  
  Revision r2082:
  branches/5.0:  bug#29560
  
  Fixed a race condition in the rw_lock where an os_event_reset()
  can overwrite an earlier os_event_set() triggering an indefinite
  wait.
  NOTE: This fix for windows is different from that for other platforms.
  NOTE2: This bug is introduced in the scalability fix to the
  sync0arr which was applied to 5.0 only. Therefore, it need not be
  applied to the 5.1 tree. If we decide to port the scalability fix
  to 5.1 then this fix should be ported as well.
  
  Reviewed by: Heikki
innobase/sync/sync0sync.c:
  Applied InnoDB snapshot innodb-5.0-ss2095
  
  Revision r2082:
  branches/5.0:  bug#29560
  
  Fixed a race condition in the rw_lock where an os_event_reset()
  can overwrite an earlier os_event_set() triggering an indefinite
  wait.
  NOTE: This fix for windows is different from that for other platforms.
  NOTE2: This bug is introduced in the scalability fix to the
  sync0arr which was applied to 5.0 only. Therefore, it need not be
  applied to the 5.1 tree. If we decide to port the scalability fix
  to 5.1 then this fix should be ported as well.
  
  Reviewed by: Heikki
sql/ha_innodb.cc:
  Applied InnoDB snapshot innodb-5.0-ss2095
  
  Revision r2091:
  branches/5.0:
   
  Merge r2088 from trunk:
   
  log for r2088:
  
  Fix Bug#32125 (http://bugs.mysql.com/32125)
  "Database crash due to ha_innodb.cc:3896: ulint convert_search_mode_to_innobase":
  
  When unknown find_flag is encountered in convert_search_mode_to_innobase()
  do not call assert(0); instead queue a MySQL error using my_error() and
  return the error code PAGE_CUR_UNSUPP. Change the functions that call
  convert_search_mode_to_innobase() to handle that error code by "canceling"
  execution and returning appropriate error code further upstream.
  
  Approved by:	Heikki
  
  
  Revision r2095:
  branches/5.0: Merge r2093 from trunk:
  
  convert_search_mode_to_innobase(): Add the missing case label
  HA_READ_MBR_EQUAL that was forgotten in r2088.
2007-11-20 10:53:19 -07:00
unknown
7cf04ced45 Merge endora.local:/Users/davi/mysql/bugs/31397-5.1
into  endora.local:/Users/davi/mysql/mysql-5.1-runtime


sql/sql_class.cc:
  Auto merged
2007-11-20 15:18:57 -02:00
unknown
4d6543a6f0 Bug#31397 Inconsistent drop table behavior of handler tables.
The problem is that DROP TABLE and other DDL statements failed to
automatically close handlers associated with tables that were marked
for reopen (FLUSH TABLES).

The current implementation fails to properly discard handlers of
dropped tables (that were marked for reopen) because it searches
on the open handler tables list and using the current alias of the
table being dropped. The problem is that it must not use the open
handler tables list to search because the table might have been
closed (marked for reopen) by a flush tables command and also it
must not use the current table alias at all since multiple different
aliases may be associated with a single table. This is specially
visible when a user has two open handlers (using alias) of a same
table and a flush tables command is issued before the table is
dropped (see test case). Scanning the handler table list is also
useless for dropping handlers associated with temporary tables,
because temporary tables are not kept in the THD::handler_tables
list.

The solution is to simple scan the handlers hash table searching
for, and deleting all handlers with matching table names if the
reopen flag is not passed to the flush function, indicating that
the handlers should be deleted. All matching handlers are deleted
even if the associated the table is not open.


mysql-test/include/handler.inc:
  Add test case for Bug#31397
mysql-test/r/handler_innodb.result:
  Add test case result for Bug#31397
mysql-test/r/handler_myisam.result:
  Add test case result for Bug#31397
sql/mysql_priv.h:
  Rename flush functions to better match the intent of the caller and
  update functions prototypes and remove unused flags.
sql/sql_base.cc:
  Rename flush functions to better match the intent of the caller.
sql/sql_class.cc:
  Rename the flush functions to better match the intent of the caller.
  The hash_free function is moved to the cleanup.
sql/sql_handler.cc:
  When dropping tables for a final close, scan the handler's hash table since
  the table might not be in the handlers open table list because the table was
  marked for reopen or because it's a temporary table.
sql/sql_rename.cc:
  Drop handlers associated with tables that are being renamed.
sql/sql_table.cc:
  Now that temporary tables are properly removed even when opened
  by a SQL HANDLER, enable the assert since this branch can't be taken
  outside of SF/trigger/prelocked mode.
2007-11-20 15:17:53 -02:00
unknown
bb681dbc88 Bug #31153 calling stored procedure crashes server if available memory is low
When the server was out of memory it crashed because of invalid memory access.

This patch adds detection for failed memory allocations and make the server
output a proper error message.


sql/mysqld.cc:
  Don't try to push_warning from within push_warning. It will cause a recursion
  until the stack is consumed.
  
  If my_net_init fails (for example: because of OOM) the temporary vio object 
  might have been attached to the thd object already. This will cause a double
  free on the vio object when the thd object is deleted later on and the server
  will crash.
sql/sp_head.cc:
  Added check for out-of-memory on a 'new' operation.
  Refactored reset_lex method to return a error state code instead of void.
  Initialize the mem-root with init_sql_alloc to get a basic error handler for
  memory allocation problems. This alone won't prevent the server from crashing,
  NULL pointers have to be accounted for as well.
sql/sp_head.h:
  Use the throw() clause in operator new, to indicate to the compiler that
  memory allocation can fail and return NULL, so that the compiler should
  generate code to check for NULL before invoking C++ constructors, to be
  crash safe.
sql/sql_base.cc:
  Use init_sql_alloc to get basic out-of-memory error handling.
sql/sql_lex.h:
  Use the throw() clause in operator new, to indicate to the compiler that
  memory allocation can fail and return NULL, so that the compiler should
  generate code to check for NULL before invoking C++ constructors, to be
  crash safe.
sql/sql_prepare.cc:
  Use init_sql_alloc to get basic out-of-memory error handling.
sql/sql_yacc.yy:
  Check for memory allocation failures where it matters.
2007-11-19 17:59:44 +01:00
unknown
caa031e0f7 Merge stella.local:/home2/mydev/mysql-5.1-ateam
into  stella.local:/home2/mydev/mysql-5.1-axmrg
2007-11-19 11:08:02 +01:00
unknown
864216747d Merge bk-internal.mysql.com:/home/bk/mysql-5.1-engines
into  stella.local:/home2/mydev/mysql-5.1-bug26379-8
2007-11-18 23:17:54 +01:00
unknown
5f4bb8429e Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
corrupts a MERGE table

Post-pushbuild fix for a Valgrind warning.


mysql-test/r/merge.result:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Fixed test result.
mysql-test/t/merge.test:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Removed unnecessary statements from test.
sql/sql_trigger.cc:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Fixed usage of db and table_name for
  close_data_files_and_morph_locks().
2007-11-18 20:28:37 +01:00
unknown
1e94ef77f9 Merge stella.local:/home2/mydev/mysql-5.1-ateam
into  stella.local:/home2/mydev/mysql-5.1-axmrg


sql/item_func.cc:
  Auto merged
2007-11-17 09:21:09 +01:00
unknown
011eb3dffe Fix for bug #32260: User variables in query cause server crash
Problem: there's no guarantee that the user variable item's result_field
is assigned when we're adjusting its table read map.
  
Fix: check the result_field before using it.


mysql-test/r/user_var.result:
  Fix for bug #32260: User variables in query cause server crash
    - test result.
mysql-test/t/user_var.test:
  Fix for bug #32260: User variables in query cause server crash
    - test case.
sql/item_func.cc:
  Fix for bug #32260: User variables in query cause server crash
    - using the result_field ensure it is set.
2007-11-17 11:20:50 +04:00
unknown
47d30b190d Merge dl145h.mysql.com:/data0/mkindahl/mysql-5.1-new-rpl
into  dl145h.mysql.com:/data0/mkindahl/mysql-5.1-rpl-merge
2007-11-16 15:56:24 +01:00
unknown
211383388e Bug#32435:
DROP DATABASE statement writes changes to mysql.proc table under RBR

When replicating a DROP DATABASE statement with a database holding
stored procedures, the changes to the mysql.proc table was recorded
in the binary log under row-based replication.

With this patch, the thread uses statement-logging format for the
duration of the DROP DATABASE statement. The logging format is
(already) reset at the end of the statement, so no additional code
for resetting the logging format is necessary.


sql/sql_db.cc:
  Clearing the row-based statement flag for the DROP DATABASE statement
  since it should always be replicated as a statement.
mysql-test/extra/binlog_tests/database.test:
  New BitKeeper file ``mysql-test/extra/binlog_tests/database.test''
mysql-test/suite/binlog/r/binlog_database.result:
  New BitKeeper file ``mysql-test/suite/binlog/r/binlog_database.result''
mysql-test/suite/binlog/t/binlog_database.test:
  New BitKeeper file ``mysql-test/suite/binlog/t/binlog_database.test''
2007-11-16 15:55:22 +01:00
unknown
9e63a99d9b Merge stella.local:/home2/mydev/mysql-5.1-amain
into  stella.local:/home2/mydev/mysql-5.1-axmrg


include/mysql_com.h:
  Auto merged
mysql-test/r/partition.result:
  Auto merged
mysql-test/t/partition.test:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_partition.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-11-16 14:07:59 +01:00
unknown
d87ae86bc6 Merge lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.1-base
into  lambda.hsd1.co.comcast.net.:/home/malff/TREE/mysql-5.1-rt-merge


sql/events.cc:
  Auto merged
2007-11-15 14:17:04 -07:00
unknown
c8450b278d Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
corrupts a MERGE table
Bug 26867 - LOCK TABLES + REPAIR + merge table result in
            memory/cpu hogging
Bug 26377 - Deadlock with MERGE and FLUSH TABLE
Bug 25038 - Waiting TRUNCATE
Bug 25700 - merge base tables get corrupted by
            optimize/analyze/repair table
Bug 30275 - Merge tables: flush tables or unlock tables
            causes server to crash
Bug 19627 - temporary merge table locking
Bug 27660 - Falcon: merge table possible
Bug 30273 - merge tables: Can't lock file (errno: 155)

The problems were:

Bug 26379 - Combination of FLUSH TABLE and REPAIR TABLE
                corrupts a MERGE table

  1. A thread trying to lock a MERGE table performs busy waiting while
     REPAIR TABLE or a similar table administration task is ongoing on
     one or more of its MyISAM tables.
  
  2. A thread trying to lock a MERGE table performs busy waiting until all
     threads that did REPAIR TABLE or similar table administration tasks
     on one or more of its MyISAM tables in LOCK TABLES segments do UNLOCK
     TABLES. The difference against problem #1 is that the busy waiting
     takes place *after* the administration task. It is terminated by
     UNLOCK TABLES only.
  
  3. Two FLUSH TABLES within a LOCK TABLES segment can invalidate the
     lock. This does *not* require a MERGE table. The first FLUSH TABLES
     can be replaced by any statement that requires other threads to
     reopen the table. In 5.0 and 5.1 a single FLUSH TABLES can provoke
     the problem.

Bug 26867 - LOCK TABLES + REPAIR + merge table result in
            memory/cpu hogging

  Trying DML on a MERGE table, which has a child locked and
  repaired by another thread, made an infinite loop in the server.

Bug 26377 - Deadlock with MERGE and FLUSH TABLE

  Locking a MERGE table and its children in parent-child order
  and flushing the child deadlocked the server.

Bug 25038 - Waiting TRUNCATE

  Truncating a MERGE child, while the MERGE table was in use,
  let the truncate fail instead of waiting for the table to
  become free.

Bug 25700 - merge base tables get corrupted by
            optimize/analyze/repair table

  Repairing a child of an open MERGE table corrupted the child.
  It was necessary to FLUSH the child first.

Bug 30275 - Merge tables: flush tables or unlock tables
            causes server to crash

  Flushing and optimizing locked MERGE children crashed the server.

Bug 19627 - temporary merge table locking

  Use of a temporary MERGE table with non-temporary children
  could corrupt the children.

  Temporary tables are never locked. So we do now prohibit
  non-temporary chidlren of a temporary MERGE table.

Bug 27660 - Falcon: merge table possible

  It was possible to create a MERGE table with non-MyISAM children.

Bug 30273 - merge tables: Can't lock file (errno: 155)

  This was a Windows-only bug. Table administration statements
  sometimes failed with "Can't lock file (errno: 155)".

These bugs are fixed by a new implementation of MERGE table open.

When opening a MERGE table in open_tables() we do now add the
child tables to the list of tables to be opened by open_tables()
(the "query_list"). The children are not opened in the handler at
this stage.

After opening the parent, open_tables() opens each child from the
now extended query_list. When the last child is opened, we remove
the children from the query_list again and attach the children to
the parent. This behaves similar to the old open. However it does
not open the MyISAM tables directly, but grabs them from the already
open children.

When closing a MERGE table in close_thread_table() we detach the
children only. Closing of the children is done implicitly because
they are in thd->open_tables.

For more detail see the comment at the top of ha_myisammrg.cc.

Changed from open_ltable() to open_and_lock_tables() in all places
that can be relevant for MERGE tables. The latter can handle tables
added to the list on the fly. When open_ltable() was used in a loop
over a list of tables, the list must be temporarily terminated
after every table for open_and_lock_tables().
table_list->required_type is set to FRMTYPE_TABLE to avoid open of
special tables. Handling of derived tables is suppressed.
These details are handled by the new function
open_n_lock_single_table(), which has nearly the same signature as
open_ltable() and can replace it in most cases.

In reopen_tables() some of the tables open by a thread can be
closed and reopened. When a MERGE child is affected, the parent
must be closed and reopened too. Closing of the parent is forced
before the first child is closed. Reopen happens in the order of
thd->open_tables. MERGE parents do not attach their children
automatically at open. This is done after all tables are reopened.
So all children are open when attaching them.

Special lock handling like mysql_lock_abort() or mysql_lock_remove()
needs to be suppressed for MERGE children or forwarded to the parent.
This depends on the situation. In loops over all open tables one
suppresses child lock handling. When a single table is touched,
forwarding is done.

Behavioral changes:
===================

This patch changes the behavior of temporary MERGE tables.
Temporary MERGE must have temporary children.
The old behavior was wrong. A temporary table is not locked. Hence
even non-temporary children were not locked. See
Bug 19627 - temporary merge table locking.

You cannot change the union list of a non-temporary MERGE table
when LOCK TABLES is in effect. The following does *not* work:
CREATE TABLE m1 ... ENGINE=MRG_MYISAM ...;
LOCK TABLES t1 WRITE, t2 WRITE, m1 WRITE;
ALTER TABLE m1 ... UNION=(t1,t2) ...;
However, you can do this with a temporary MERGE table.

You cannot create a MERGE table with CREATE ... SELECT, neither
as a temporary MERGE table, nor as a non-temporary MERGE table.
CREATE TABLE m1 ... ENGINE=MRG_MYISAM ... SELECT ...;
Gives error message: table is not BASE TABLE.


include/my_base.h:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added HA_EXTRA_ATTACH_CHILDREN and HA_EXTRA_DETACH_CHILDREN.
include/myisammrg.h:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added element 'children_attached' to MYRG_INFO.
  Added declarations for myrg_parent_open(),
  myrg_attach_children() and myrg_detach_children()
  for the new MERGE table open approach.
mysql-test/extra/binlog_tests/blackhole.test:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Preliminarily added new error message with a comment.
mysql-test/r/create.result:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Fixed test result.
mysql-test/r/delayed.result:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Moved test result from here to merge.result.
mysql-test/r/merge.result:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Fixed/added test result.
mysql-test/r/myisam.result:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Moved test result for bug 8306 from here to merge.result.
mysql-test/suite/binlog/r/binlog_stm_blackhole.result:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Fixed test result.
mysql-test/t/create.test:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Fixed error number.
mysql-test/t/delayed.test:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Moved test from here to merge.test.
mysql-test/t/merge.test:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Fixed test for new temporary MERGE table behavior.
  Exchanged error numbers by symbolic codes.
  Added tests. Included are tests for bugs
  8306 (moved from myisam.test), 26379, 19627, 25038, 25700, 26377,
  26867, 27660, 30275, and 30273.
  Fixed changes resulting from disabled CREATE...SELECT.
  Integrated tests moved from delayed.test and myisam.test to here.
mysql-test/t/myisam.test:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Moved test for bug 8306 from here to merge.test.
mysys/thr_lock.c:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added code to let the owner of a high priority lock (TL_WRITE_ONLY)
  to bypass its own lock.
sql/ha_ndbcluster_binlog.cc:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added 'thd' argument to init_tmp_table_share().
sql/handler.cc:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added 'thd' argument to init_tmp_table_share().
sql/mysql_priv.h:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Removed declaration of check_merge_table_access(). It is now static
  in sql_parse.cc.
  Added declaration for fix_merge_after_open().
  Renamed open_and_lock_tables() to open_and_lock_tables_derived()
  with additional parameter 'derived'.
  Added inline functions simple_open_n_lock_tables() and
  open_and_lock_tables(), which call open_and_lock_tables_derived()
  and add the argument for 'derived'.
  Added new function open_n_lock_single_table(), which can be used
  as an replacement for open_ltable() in most situations. Internally
  it calls simple_open_n_lock_tables() so hat it is appropriate for
  MERGE tables.
  Added 'thd' argument to init_tmp_table_share().
sql/slave.cc:
  ug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added comment.
sql/sql_base.cc:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  
  Defined new functions add_merge_table_list(),
  attach_merge_children(), detach_merge_children(), and
  fix_merge_after_open() for the new MERGE table open approach.
  
  Added calls of the new functions to
  close_handle_and_leave_table_as_lock(), close_thread_tables(),
  close_thread_table(), unlink_open_table(), reopen_name_locked_table(),
  reopen_table(), drop_locked_tables(), close_temporary_table(),
  and open_tables() respectively.
  
  Prevented special lock handling of merge children (like
  mysql_lock_remove, mysql_lock_merge or mysql_lock_abort)
  at many places. Some of these calls are forwarded to the
  parent table instead.
  
  Added code to set thd->some_tables_deleted for every thread that has
  a table open that we are flushing.
  Added code for MERGE tables to unlink_open_table().
  Added MERGE children to the list of unusable tables in open_table().
  Added MERGE table handling to reopen_table().
  Added lock handling and closing of a parent before the children
  in close_data_files_and_morph_locks().
  Added code for re-attaching children in reopen_tables().
  Added MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN to the locking flags and
  error reporting after mysql_lock_tables() in reopen_tables().
  Added lock handling and closing of a parent before the children
  in close_old_data_files().
  Added lock handling and detaching in drop_locked_tables().
  Added code for removing the children list from the statement list
  to prepare for a repetition in open_tables().
  Added new function open_n_lock_single_table(), which can be used
  as an replacement for open_ltable() in most situations. Internally
  it calls simple_open_n_lock_tables() so hat it is appropriate for
  MERGE tables.
  Disabled use of open_ltable() for MERGE tables.
  Removed function simple_open_n_lock_tables(). It is now inline
  declared in mysql_priv.h.
  Renamed open_and_lock_tables() to open_and_lock_tables_derived()
  with additional parameter 'derived'. open_and_lock_tables() is now
  inline declared in mysql_priv.h.
  Added a check for end-of-list in two loops in lock_tables().
  Added 'thd' argument to init_tmp_table_share().
sql/sql_insert.cc:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Changed from open_ltable() to open_n_lock_single_table() in
  handle_delayed_insert().
  Reestablished LEX settings after lex initialization.
  Added 'thd' argument to init_tmp_table_share().
sql/sql_parse.cc:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Made check_merge_table_access() a static function.
  Disabled use of CREATE...SELECT for MERGE tables.
sql/sql_partition.cc:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Fixed comment typo.
sql/sql_select.cc:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added 'thd' argument to init_tmp_table_share().
sql/sql_table.cc:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Optimized use of mysql_ha_flush() in mysql_rm_table_part2().
  Disabled the use of MERGE tables with prepare_for_restore() and
  prepare_for_repair().
  Changed from open_ltable() to open_n_lock_single_table() in
  mysql_alter_table() and mysql_checksum_table().
  Disabled change of child list under LOCK TABLES.
  Initialized table_list->table in mysql_recreate_table().
sql/sql_trigger.cc:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added code for allowing CREATE TRIGGER under LOCK TABLE, to be able
  to test it with MERGE tables.
sql/table.cc:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added 'thd' argument to init_tmp_table_share().
  Setting table_map_id from query_id in init_tmp_table_share().
  Added member function TABLE::is_children_attached().
sql/table.h:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added access method get_table_def_version() to TABLE_SHARE.
  Added elements for MERGE tables to TABLE and TABLE_LIST.
storage/myisam/ha_myisam.cc:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added an unrelated comment to the function comment of table2myisam().
storage/myisam/ha_myisam.h:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added new member function MI_INFO::file_ptr().
storage/myisammrg/ha_myisammrg.cc:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added callback functions to support parent open and children attach
  of MERGE tables.
  Changed ha_myisammrg::open() to initialize storage engine structures
  and create a list of child tables only. Child tables are not opened.
  Added ha_myisammrg::attach_children(), which does now the main part
  of MERGE open.
  Added ha_myisammrg::detach_children().
  Added calls to ::attach_children() and ::detach_children() to
  ::extra() on HA_EXTRA_ATTACH_CHILDREN and HA_EXTRA_DETACH_CHILDREN
  respectively.
  Added a check for matching TEMPORARY type for children against
  parent.
  Added a check for table def version.
  Added support for thd->open_options to attach_children().
  Changed child path name generation for temporary tables so that
  it does nothing special for temporary tables.
storage/myisammrg/ha_myisammrg.h:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added elements to class ha_myisammrg to support the new
  open approach.
  Changed empty destructor definition to a declaration.
  Implemented in ha_myisammrg.cc.
  Added declaration for methods attach_children() and
  detach_children().
  Added definition for method table_ptr() for use with
  callback functions.
storage/myisammrg/myrg_close.c:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Added a check to avoid closing of MyISAM tables when the
  child tables are not attached.
  Added freeing of rec_per_key_part when the child tables
  are not attached.
storage/myisammrg/myrg_extra.c:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  Some ::extra() functions and ::reset() can be called when
  children are detached.
storage/myisammrg/myrg_open.c:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE
              corrupts a MERGE table
  
  Kept old myrg_open() for MERGE use independent from MySQL.
  Removed an always true condition in myrg_open().
  Set children_attached for independent MERGE use in myrg_open().
  
  Added myrg_parent_open(), myrg_attach_children(), and
  myrg_detach_children() for the new MERGE table open approach.
mysql-test/r/merge-big.result:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table
  New test result
mysql-test/t/merge-big.test:
  Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table
  New test case
2007-11-15 20:25:43 +01:00
unknown
91f0013986 A patch for BUG#19723: kill of active connection yields
different error code depending on platform.

On Mac OS X, KILL statement issued to kill the current
connection would return a different error code and message than on
other platforms ('MySQL server has gone away' instead of 'Shutdown
in progress').

The reason for this difference was that on Mac OS X we have macro
SIGNAL_WITH_VIO_CLOSE defined. This macro forces KILL
implementation to close the communication socket of the thread
that is being killed. SIGNAL_WITH_VIO_CLOSE macro is defined on
platforms where just sending a signal is not a reliable mechanism
to interrupt the thread from sleeping on a blocking system call.
In a nutshell, closing the socket is a hack to work around an
operating system bug and awake the blocked thread no matter what.

However, if the thread that is being killed is the same
thread that issued KILL statement, closing the socket leads to a
prematurely lost connection. At the same time it is not necessary
to close the socket in this case, since the thread in question
is not inside a blocking system call.

The fix, therefore, is to not close the socket if the thread that
is being killed is the same that issued KILL statement, even with
defined SIGNAL_WITH_VIO_CLOSE.


mysql-test/r/kill.result:
  Update result file.
mysql-test/t/kill.test:
  Added a test case for BUG#19723: kill of active connection yields
  different error code depending on platform.
sql/sql_class.cc:
  Call close_active_vio() only if we're killing another thread.
2007-11-15 15:35:35 +03:00
unknown
9e0d1dbd0a Merge dl145h.mysql.com:/data0/mkindahl/mysql-5.0-rpl-merge
into  dl145h.mysql.com:/data0/mkindahl/mysql-5.1-rpl-merge


mysql-test/r/mysqlbinlog.result:
  Auto merged
mysql-test/t/mysqlbinlog.test:
  Auto merged
sql/log_event.cc:
  Auto merged
BitKeeper/deleted/.del-compile-solaris-amd64:
  Delete: BUILD/compile-solaris-amd64
2007-11-15 13:31:39 +01:00
unknown
26b5030487 Merge damien-katzs-computer.local:/Users/dkatz/mysql-5.1-runtime
into  damien-katzs-computer.local:/Users/dkatz/cmdline_events_bug
2007-11-14 16:34:01 -05:00