Commit graph

25242 commits

Author SHA1 Message Date
Kristofer Pettersson
a41d3800bc Auto merge 2009-05-15 09:36:42 +02:00
Kristofer Pettersson
afee63222a Bug#19027 MySQL 5.0 starts even with Fatal InnoDB errors
It is not possible to prevent the server from starting if a mandatory
built-in plugin fails to start. This can in some cases lead to data
corruption when the old table name space suddenly is used by a different
storage engine.

A boolean command line option in the form of --foobar is automatically
created for every existing plugin "foobar". By changing this command line
option from a boolean to a tristate { OFF, ON, FORCE } it is possible to
specify the plugin loading policy for each plugin.

The behavior is specified as follows:
   OFF   = Disable the plugin and start the server
   ON    = Enable the plugin and start the server even if an error occurrs
           during plugin initialization.
   FORCE = Enable the plugin but don't start the server if an error occurrs
           during plugin initialization.


mysql-test/lib/mtr_cases.pm:
  * Changed --<pluginname> from a boolean to a tristate.
mysys/my_getopt.c:
  * Changed --<pluginname> from boolean to tristate. Optional arguments
    must still work for tristates. It is praxis that disable means value 0
    and enable is value 1. Since plugin name is the only tristate with
    optional arguments this principle will still hold.
sql/sql_plugin.cc:
  * Changed --<pluginname> option from a boolean type to a tristate.
    - FORCE will now terminate the server if the plugin fails to
      initialize properly.
  * Refactored prototypes for test_plugin_options() and construct_options()
    to get rid of the 'enable' value pointer.
  * Cleaned up code related to option name constructing.
  * Added documentation
sql/sql_plugin.h:
  * Introduced new member to st_plugin_int structure.
2009-05-14 14:03:33 +02:00
Luis Soares
e8e8f2faf4 merge: 5.1-bt local bug fix branch --> 5.1-bt up-to-date. 2009-05-14 12:51:03 +01:00
Luis Soares
60a2bbb8dd BUG#42749: infinite loop writing to row based binlog - processlist shows
"freeing items"

The calculation of the table map log event in the event constructor
was one byte shorter than what would be actually written. This would
lead to a mismatch between the number of bytes written and the event
end_log_pos, causing bad event alignment in the binlog (corrupted
binlog) or in the transaction cache while fixing positions
(MYSQL_BIN_LOG::write_cache). This could lead to impossible to read
binlog or even infinite loops in MYSQL_BIN_LOG::write_cache.

This patch addresses this issue by correcting the expected event
length in the Table_map_log_event constructor, when the field metadata
size exceeds 255.

sql/log_event.cc:
  Added the extra byte as net_store_length imposes.
2009-05-12 12:53:46 +01:00
Davi Arnaut
d37aa50557 Bug#44664: valgrind warning for COMMIT_AND_CHAIN and ROLLBACK_AND_CHAIN
The problem is that the internal variable used to specify a
transaction with consistent read was being used outside the
processing context of a START TRANSACTION WITH CONSISTENT
SNAPSHOT statement. The practical consequence was that a
consistent snapshot specification could leak to unrelated
transactions on the same session.

The solution is to ensure a consistent snapshot clause is
only relied upon for the START TRANSACTION statement.

This is already fixed in a similar way on 6.0.

mysql-test/r/consistent_snapshot.result:
  Add test case result for Bug#44664
mysql-test/t/consistent_snapshot.test:
  Add test case for Bug#44664
sql/sql_parse.cc:
  The WITH CONSISTENT SNAPSHOT clause is only valid for the
  START TRANSACTION statement.
2009-05-11 20:54:00 -03:00
Ramil Kalimullin
d0128f5ec0 Auto-merge. 2009-05-13 23:39:35 +05:00
Martin Hansson
5811a13712 Merge. 2009-05-13 17:24:27 +02:00
Gleb Shchepa
bd59628754 Bug #44290: explain crashes for subquery with distinct in
SQL_SELECT::test_quick_select

The crash was caused by an incomplete cleanup of JOIN_TAB::select
during the filesort of rows for GROUP BY clause inside a subquery.
Queries where a quick index access is replaced with filesort was
was affected. For example:

  SELECT 1 FROM
    (SELECT COUNT(DISTINCT c1) FROM t1
       WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x

Quick index access related data in the SQL_SELECT::test_quick_select
function was inconsistent after an incomplete cleanup.
This function has been completed to prevent crashes in the
SQL_SELECT::test_quick_select function.


mysql-test/include/mix1.inc:
  Add test case for bug #44290.
mysql-test/r/innodb_mysql.result:
  Add test case for bug #44290.
sql/sql_select.cc:
  Bug #44290: explain crashes for subquery with distinct in
              SQL_SELECT::test_quick_select
  
  Quick index access related data in the SQL_SELECT::test_quick_select
  function was inconsistent after an incomplete cleanup.
  This function has been completed to prevent crashes in the
  SQL_SELECT::test_quick_select function.
2009-05-12 22:42:31 +05:00
Ramil Kalimullin
8b9084eff4 Fix for bug#44774: load_file function produces valgrind warnings
Problem: using LOAD_FILE() in some cases we pass a file name string
without a trailing '\0' to fn_format() which relies on that however.
That may lead to valgrind warnings.

Fix: add a trailing '\0' to the file name passed to fn_format().


mysql-test/r/func_str.result:
  Fix for bug#44774: load_file function produces valgrind warnings
    - test result.
mysql-test/t/func_str.test:
  Fix for bug#44774: load_file function produces valgrind warnings
    - test case.
sql/item_strfunc.cc:
  Fix for bug#44774: load_file function produces valgrind warnings
    - passing a file name to fn_format(), file_name->c_ptr() replaced
      with file_name->c_ptr_safe() to ensure we have a trailing '\0'.
2009-05-12 13:18:27 +05:00
Mats Kindahl
206bdd67c6 Merging with 5.1-bugteam tree. 2009-05-11 15:28:02 +02:00
Mats Kindahl
8f95c5e183 Bug #44442: Incident events are silent in mysqlbinlog output
In the output from mysqlbinlog, incident log events were
represented as just a comment. Since the incident log event
represents an incident that could cause the contents of the
database to change without being logged to the binary log,
it means that if the SQL is applied to a server, it could
potentially lead to that the databases are out of sync.

In order to handle that, this patch adds the statement "RELOAD
DATABASE" to the SQL output for the incident log event. This will
require a DBA to edit the file and handle the case as apropriate
before applying the output to a server.

mysql-test/suite/binlog/t/binlog_incident-master.opt:
  Options file to cause server to generate an incident log
  event when executing a REPLACE.
mysql-test/suite/binlog/t/binlog_incident.test:
  Test to check that the incident log event is represented
  correctly in the output from mysqlbinlog.
sql/log_event.cc:
  The incident log event now ouput a "RELOAD DATABASE" instead
  of just a comment. RELOAD DATABASE is not an existing command
  and will generate a syntax error.
2009-05-11 13:32:38 +02:00
Ramil Kalimullin
3c08b9b1ab Manual merge. 2009-05-10 21:20:35 +05:00
Ramil Kalimullin
d615a11bd5 Fix for bug#42009: SELECT into variable gives different results to direct SELECT
Problem: storing "SELECT ... INTO @var ..." results in variables we used val_xxx()
methods which returned results of the current row. 
So, in some cases (e.g. SELECT DISTINCT, GROUP BY or HAVING) we got data
from the first row of a new group (where we evaluate a clause) instead of
data from the last row of the previous group.

Fix: use val_xxx_result() counterparts to get proper results.


mysql-test/r/distinct.result:
  Fix for bug#42009: SELECT into variable gives different results to direct SELECT
    - results adjusted.
mysql-test/r/user_var.result:
  Fix for bug#42009: SELECT into variable gives different results to direct SELECT
    - test result.
mysql-test/t/user_var.test:
  Fix for bug#42009: SELECT into variable gives different results to direct SELECT
    - test case.
sql/item_func.cc:
  Fix for bug#42009: SELECT into variable gives different results to direct SELECT
    - Item_func_set_user_var::save_item_result() added to evaluate and store 
      an item's result into a user variable.
sql/item_func.h:
  Fix for bug#42009: SELECT into variable gives different results to direct SELECT
    - Item_func_set_user_var::save_item_result() added to evaluate and store 
      an item's result into a user variable.
sql/sql_class.cc:
  Fix for bug#42009: SELECT into variable gives different results to direct SELECT
    - use Item_func_set_user_var::save_item_result() to store results into user 
      variables.
2009-05-10 20:50:14 +05:00
Anurag Shekhar
b1a02aef50 merging with local fix. 2009-05-06 15:00:14 +05:30
Anurag Shekhar
609a794b15 Bug #39918 memory (heap) engine crashing with b-tree index and DELETE
with seg fault

Multiple-table DELETE from a table joined to itself may cause
server crash. This was originally discovered with MEMORY engine,
but may affect other engines with different symptoms.

The problem was that the server violated SE API by performing
parallel table scan in one handler and removing records in
another (delete on the fly optimization).


mysql-test/r/heap_btree.result:
  Updated test result after adding new test for this bug.
mysql-test/t/heap_btree.test:
  Updated test result after adding new test for the bug report.
sql/sql_delete.cc:
  Updated to check if the files in delete list appears in join list and disable 
  delete while scanning, if it appears.
2009-05-06 13:37:10 +05:30
Narayanan V
32be241480 merging with mysql-5.1-bugteam 2009-05-05 15:16:05 +05:30
Martin Hansson
391364fac7 Bug#43580: Issue with Innodb on multi-table update
Certain multi-updates gave different results on InnoDB from
to MyISAM, due to on-the-fly updates being used on the former and
the update order matters.
Fixed by turning off on-the-fly updates when update order 
dependencies are present.


mysql-test/r/innodb_mysql.result:
  Bug#43580: Test result.
mysql-test/suite/rpl/r/rpl_slave_skip.result:
  Bug#43580: Changed test result. The InnoDB result is now what it would have been on MyISAM.
mysql-test/t/innodb_mysql.test:
  Bug#43580: Test case.
sql/sql_base.cc:
  Bug#43580: Added a word of caution about using tmp_set here.
sql/sql_update.cc:
  Bug#43580: Fix.
  Calls to TABLE::mark_columns_needed_for_update() are moved
  from mysql_multi_update_prepare() and right before the decison
  to do on-the-fly updates to the place where we do (or don't do)
  on-the-fly updates.
2009-05-05 11:38:19 +02:00
Sergei Golubchik
ad7518418c bug#44166
removed few sprintf's
2009-05-04 22:33:23 +02:00
Martin Hansson
7e66dbea48 Bug#44306: Assertion fail on duplicate key error in
'INSERT ... SELECT' statements

Merge
2009-05-04 14:57:42 +02:00
Martin Hansson
fdd5a63fe6 Bug#44306: Assertion fail on duplicate key error in
'INSERT ... SELECT' statements
            
The code that produces result rows expected that a duplicate row
error could not occur in INSERT ... SELECT statements with 
unfulfilled WHERE conditions. This may happen, however, if the 
SELECT list contains only aggregate functions.
Fixed by checking if an error occured before trying to send EOF
to the client.


mysql-test/r/insert_select.result:
  Bug#44306: Test result
mysql-test/t/insert_select.test:
  Bug#44306: Test case
sql/sql_select.cc:
  Bug#44306: Fix
2009-05-04 14:45:36 +02:00
Narayanan V
3023bca110 BUG#39802 On Windows, 32-bit time_t should be enforced
A backport of fix for "BUG40092 - Storage engine API uses
time_t datatype".

Starting from MSVC C++ 2005 (v8), the default size of time_t
is changed from 32-bit to 64-bit. As the result, the binaries
built with pre-v8 MSVC C++ do not work with the binaries
(storage engine plugins) built with v8 or after (server
crashes).

Fixed storage engine API to use datatype with known size
(ulong) instead of time_t.

sql/handler.h:
  Bug#39802 On Windows, 32-bit time_t should be enforced
  
  Change create_time, check_time, update_time
  in the ha_statistics and PARTITION_INFO
  structures to ulong.
2009-05-04 15:30:15 +05:30
Andrei Elkin
a83b1bdb95 removing the source of a warning in slave.cc:468 2009-05-04 12:59:10 +03:00
Gleb Shchepa
24457353c7 auto-upmerge 5.0-bugteam --> 5.1-bugteam (bug 37362) 2009-05-01 00:27:10 +05:00
Gleb Shchepa
f0791b8b6b Bug #37362: Crash in do_field_eq
EXPLAIN EXTENDED of nested query containing a error:

   1054 Unknown column '...' in 'field list'

may cause a server crash.


Parse error like described above forces a call to
JOIN::destroy() on malformed subquery.
That JOIN::destroy function closes and frees temporary
tables. However, temporary fields of these tables
may be listed in st_select_lex::group_list of outer
query, and that st_select_lex may not cleanup them
properly. So, after the JOIN::destroy call that
st_select_lex::group_list may have Item_field
objects with dangling pointers to freed temporary
table Field objects. That caused a crash.


mysql-test/r/subselect3.result:
  Added test case for bug #37362.
mysql-test/t/subselect3.test:
  Added test case for bug #37362.
sql/sql_select.cc:
  Bug #37362: Crash in do_field_eq
  
  The JOIN::destroy function has been modified to
  cleanup temporary table column items.
2009-05-01 00:20:37 +05:00
Andrei Elkin
a152aa32de merging 5.0-bt to 5.1-bt 2009-04-30 16:17:46 +03:00
Andrei Elkin
cc491da07f merge bug#44179 fixes to 5.1-bt 2009-04-30 15:47:09 +03:00
Andrei Elkin
9cf91b4cd9 merging from 5.0-bt rep to a local branch 2009-04-30 15:41:47 +03:00
Andrei Elkin
2d20930eee Bug #44179 reset slave crashes in my_error when reset_logs returns non-zero
my_error() was invoked in reset_slave()'s with purge_relay_logs()-failing branch
without passing sql_errno to it.

Fixed with setting sql_errno= ER_RELAY_LOG_FAIL in the purge_relay_logs()-failing branch.




sql/sql_repl.cc:
  set sql_errno= ER_RELAY_LOG_FAIL when purge_relay_logs() fails.
2009-04-30 15:28:07 +03:00
Sergey Glukhov
5d41d82174 Bug#43962 "Packets out of order" calling a SHOW TABLE STATUS
Error happens because sp_head::MULTI_RESULTS is not set for SP
which has 'show table status' command.
The fix is to add a SQLCOM_SHOW_TABLE_STATUS case into
sp_get_flags_for_command() func.


mysql-test/r/sp.result:
  test result
mysql-test/t/sp.test:
  test case
sql/sp_head.cc:
  Error happens because sp_head::MULTI_RESULTS is not set for SP
  which has 'show table status' command.
  The fix is to add a SQLCOM_SHOW_TABLE_STATUS case into
  sp_get_flags_for_command() func.
2009-04-30 14:37:29 +05:00
Alexey Botchkov
0e88c80580 merging 2009-04-29 07:59:10 +05:00
Andrei Elkin
d38e62634f Bug #38694 Race condition in replication thread shutdown
The issue of the current bug is unguarded access to mi->slave_running 
by the shutdown thread calling end_slave() that is bug#29968 
(alas happened not to be cross-linked with the current bug)

Fixed:

with removing the unguarded read of the running status
and perform reading it in terminate_slave_thread()
at time run_lock is taken (mostly bug#29968 backporting, still with some
improvements over that patch - see the error reporting from 
terminate_slave_thread()).
Issue of bug#38716 is fixed here for 5.0 branch as well.

Note:

There has been a separate artifact identified - 
a race condition between init_slave() and  end_slave() - 
reported as  Bug#44467.

mysql-test/r/rpl_bug38694.result:
  a new results file is added.
mysql-test/t/rpl_bug38694-slave.opt:
  simulating delay at slave threads shutdown.
mysql-test/t/rpl_bug38694.test:
  A new test to check if a delay at the termination phase of slave threads
  could cause any issue.
sql/slave.cc:
  The unguarded read of the running status is removed. Its reading is done in
  terminate_slave_thread() at time run_lock is taken;
  Calling terminate_slave_threads(skip_lock := !need_slave_mutex) in the failing branch of start_slave_threads() which is bug#38716 issue.
sql/slave.h:
  removing terminate_slave_thread() out of the global interface scope.
2009-04-28 14:46:07 +03:00
Alexey Botchkov
ddc9a19550 merging 2009-04-28 14:48:54 +05:00
Alexey Botchkov
620fb880d7 Bug#38990 Arbitrary data input plus GIS functions causes mysql server crash
the Point() and Linestring() functions create WKB representation of an
   object instead of an real geometry object.
   That produced bugs when these were inserted into tables.

   GIS tests fixed accordingly.
            
per-file messages:
  mysql-test/r/gis-rtree.result
Bug#38990 Arbitrary data input plus GIS functions causes mysql server crash 
    test result
  mysql-test/r/gis.result
Bug#38990 Arbitrary data input plus GIS functions causes mysql server crash 
    test result
  mysql-test/t/gis-rtree.test
Bug#38990 Arbitrary data input plus GIS functions causes mysql server crash 
    test fixed - GeomFromWKB invocations removed
  mysql-test/t/gis.test
Bug#38990 Arbitrary data input plus GIS functions causes mysql server crash 
    test fixed - AsWKB invocations added
  sql/item_geofunc.cc
Bug#38990 Arbitrary data input plus GIS functions causes mysql server crash 
     Point() and similar functions to create a proper object
2009-04-28 14:47:26 +05:00
Gleb Shchepa
755d312e84 manual merge 5.0-bugteam --> 5.1-bugteam 2009-04-28 05:27:38 +05:00
Gleb Shchepa
def0470598 backport from 6.0:
Bug #40925: Equality propagation takes non indexed attribute

Query execution plans and execution time of queries like

  select a, b, c from t1
    where a > '2008-11-21' and b = a limit 10

depended on the order of equality operator parameters:
"b = a" and "a = b" are not same. 


An equality propagation algorithm has been fixed:
the substitute_for_best_equal_field function should not
substitute a field for an equal field if both fields belong
to the same table.


mysql-test/r/select.result:
  Added test case for bug #40925.
mysql-test/t/select.test:
  Added test case for bug #40925.
sql/item.cc:
  Bug #40925: Equality propagation takes non indexed attribute
  
  An equality propagation algorithm has been fixed:
  the substitute_for_best_equal_field function should not 
  substitute a field for an equal field if both fields belong
  to the same table.
2009-04-28 05:19:13 +05:00
Satya B
55533a7efd merge to latest 5.0-bugteam tree 2009-04-24 16:53:56 +05:30
Satya B
4610c13a24 Fix for BUG#43660- SHOW INDEXES/ANALYZE does NOT update cardinality
for indexes of InnoDB table

Fixes by replacing the PRNG that is used to pick random pages with a 
better one. 

Also adds a configuration option "innodb_use_legacy_cardinality_algorithm"
to enable the fix only when the option is set.

This patch is from http://bugs.mysql.com/file.php?id=11789
2009-04-24 16:33:50 +05:30
Staale Smedseng
533514580f Merge from 5.0-bugteam 2009-04-23 19:55:32 +02:00
Staale Smedseng
e1b22ab9a1 Bug#33146 CHECKSUM TABLE is not interruptable by KILL
QUERY statement
      
Commit 55629 applied to 5.0-bugteam and 5.1-bugteam: 
Check for thd->killed in CHECKSUM loop.
2009-04-23 19:52:39 +02:00
Sergey Glukhov
40e0bcab4c Bug#44367 valgrind warnings with find_in_set() functions
init 'wc' variable


mysql-test/r/func_set.result:
  test result
mysql-test/t/func_set.test:
  test case
sql/item_func.cc:
  init 'wc' variable
2009-04-23 12:50:34 +05:00
Sergey Glukhov
9bd3ef2ebb Bug#44365 valgrind warnings with encrypt() function
replaced String->c_ptr() with String->c_ptr_safe()


mysql-test/r/func_encrypt.result:
  test result
mysql-test/t/func_encrypt.test:
  test case
sql/item_strfunc.cc:
  replaced String->c_ptr() with String->c_ptr_safe()
2009-04-23 12:47:54 +05:00
Sergey Glukhov
5f9e40a5f8 Bug#44358 valgrind errors with decode() function
The warning happens because string argument is not zero ended.
The fix is to add new parameter 'length' to SQL_CRYPT() and
use ptr() instead of c_ptr().


mysql-test/r/func_str.result:
  test result
mysql-test/t/func_str.test:
  test case
sql/item_strfunc.cc:
  Added new parameter 'length' to SQL_CRYPT
sql/sql_crypt.cc:
  Added new parameter 'length' to SQL_CRYPT
sql/sql_crypt.h:
  Added new parameter 'length' to SQL_CRYPT
2009-04-23 12:43:42 +05:00
Alfranio Correia
e0526914b6 BUG#44378 rpl_binlog_corruption fails with warning messages in Valgrind
The rpl_binlog_corruption test case was inject failures, specifically,
incidents with invalid numbers to see if the replication was failing
gracefully. However, this test was causing the following warning message
in Valgrind: "Conditional jump or move depends on uninitialised value(s)"
      
The patch fixes the problem by correctly initializing the m_inicident 
number.
2009-04-21 15:31:21 +01:00
Andrei Elkin
19fd076fb1 merge bug#38205 fixes to 5.1-bt 2009-04-21 11:30:40 +03:00
Georgi Kodinov
ed2d0035de merged bug 35087 to 5.1-bugteam 2009-04-17 19:18:00 +03:00
Georgi Kodinov
0804479569 Bug #35087: Inserting duplicate values at one time with DES_ENCRYPT leads
to wrong results
      
3 problems found with DES_ENCRYPT/DES_DECRYPT :

1. The max length was not calculated properly. Fixed in fix_length_and_dec()
2. DES_ENCRYPT had a side effect of sometimes reallocating and changing 
the value of its argument. Fixed by explicitly pre-allocating the necessary
space to pad the argument with trailing '*' (stars) when calculating the 
DES digest.
3. in DES_ENCRYPT the string buffer for the result value was not 
reallocated to the correct size and only string length was assigned to it. 
Fixed by making sure there's enough space to hold the result.
2009-04-17 18:52:57 +03:00
Sergey Glukhov
bf2e29d374 5.0-bugteam->5.1-bugteam merge 2009-04-17 13:46:27 +05:00
Sergey Glukhov
ff923cc82d Bug#44151 using handler commands on information_schema tables crashes server
information schema tables are based on internal tmp tables which are removed
after each statement execution. So HANDLER comands can not be used with
information schema.


mysql-test/r/handler.result:
  test result
mysql-test/t/handler.test:
  test case
sql/sql_handler.cc:
  information schema tables are based on internal tmp tables which are removed
  after each statement execution. So HANDLER comands can not be used with
  information schema.
2009-04-17 12:41:15 +05:00
Anurag Shekhar
0501328a7d Bug#44040 MySQL allows creating a MERGE table upon VIEWs but crashes when
using it.
The crash was due to a null pointer present for select_lex while 
processing the view.
Adding a check while opening the view to see if its a child of a 
merge table fixed this problem.

mysql-test/r/merge.result:
  Updated result for the new test case.
mysql-test/t/merge.test:
  Added test case based on the bug description.
sql/sql_base.cc:
  Added a check to check if the view being opened is a child table of a
  merge table and return error if it is.
2009-04-17 11:21:51 +05:30
Davi Arnaut
b27261a6f7 Bug#44164: TL_WRITE has no description in lock_descriptions[]
The problem was that new lock types were being added without a
corresponding description. Since the lock types (enum values)
are used as indices to the description array, the descriptions
could be shifted depending on the lock type. The solution is to
ensure that every lock type has a correspondent description.

include/thr_lock.h:
  Add warning.
sql/sql_test.cc:
  Update lock descriptions.
2009-04-14 14:05:32 +02:00