Commit graph

28727 commits

Author SHA1 Message Date
Joerg Bruehe
ad1e123f47 Merge 5.5.24 back into main 5.5.
This is a weave merge, but without any conflicts.
In 14 source files, the copyright year needed to be updated to 2012.
2012-05-07 22:20:42 +02:00
Alexander Nozdrin
bcc3d5ce25 Third attempt to do a follow-up for Bug#12762885 - 61713: MYSQL WILL NOT BIND
TO "LOCALHOST" IF LOCALHOST IS BOTH IPV4/IPV6 ENABLED.

Previous commit comments were wrong. The default value has always been NULL.
The original patch for Bug#12762885 just makes it visible in the logs.

This patch uses "0.0.0.0" string if bind-address is not set.
2012-04-27 21:14:35 +04:00
Alexander Nozdrin
5f4c6942bf Revert two follow-ups for Bug#12762885:
- alexander.nozdrin@oracle.com-20120427151428-7llk1mlwx8xmbx0t
  - alexander.nozdrin@oracle.com-20120427144227-kltwiuu8snds4j3l.
2012-04-27 21:07:53 +04:00
Alexander Nozdrin
3885dc55dd Proper follow-up for Bug#12762885 - 61713: MYSQL WILL NOT BIND TO "LOCALHOST"
IF LOCALHOST IS BOTH IPV4/IPV6 ENABLED.

The original patch removed default value of the bind-address option.
So, the default value became NULL. By coincedence NULL resolves
to 0.0.0.0 and ::, and since the server chooses first IPv4-address, 
0.0.0.0 is choosen. So, there was no change in the behaviour.

This patch restores default value of the bind-address option to "0.0.0.0".
2012-04-27 19:14:28 +04:00
Alexander Nozdrin
cb4490919b Follow-up for Bug#12762885 - 61713: MYSQL WILL NOT BIND TO "LOCALHOST"
IF LOCALHOST IS BOTH IPV4/IPV6 ENABLED.

The original patch removed default value of the bind-address option.
So, the default value became NULL. By coincedence NULL resolves
to 0.0.0.0 and ::, and since the server chooses first IPv4-address, 
0.0.0.0 is choosen. So, there was no change in the behaviour.

This patch restores default value of the bind-address option to "0.0.0.0".
2012-04-27 18:42:27 +04:00
Andrei Elkin
8f737d31fd merge bug11754117-45670 fixes from 5.1: fixing comments in sql_lex.h. 2012-04-21 15:06:06 +03:00
Andrei Elkin
bf66e3ab63 merge bug11754117-45670 fixes from 5.1. 2012-04-21 13:24:39 +03:00
Nuno Carvalho
8ac39aa8e0 BUG#13979418: SHOW BINLOG EVENTS MAY CRASH THE SERVER
Merge from 5.1 into 5.5.

Conflicts:
 * sql/log.h
 * sql/sql_repl.cc
2012-04-20 23:35:53 +01:00
Nuno Carvalho
ca33df2094 BUG#13979418: SHOW BINLOG EVENTS MAY CRASH THE SERVER
The function mysql_show_binlog_events has a local stack variable
'LOG_INFO linfo;', which is assigned to thd->current_linfo, however
this variable goes out of scope and is destroyed before clean
thd->current_linfo.

The problem is solved by moving 'LOG_INFO linfo;' to function scope.
2012-04-20 22:25:59 +01:00
Andrei Elkin
f3509d1d67 BUG#11754117 incorrect logging of INSERT into auto-increment
BUG#11761686 insert_id event is not filtered.
  
Two issues are covered.
  
INSERT into autoincrement field which is not the first part in the composed primary key 
is unsafe by autoincrement logging design. The case is specific to MyISAM engine
because Innodb does not allow such table definition.
  
However no warnings and row-format logging in the MIXED mode was done, and
that is fixed.
  
Int-, Rand-, User-var log-events were not filtered along with their parent
query that made possible them to screw up execution context of the following
query.
  
Fixed with deferring their execution until the parent query.

******
Bug#11754117 

Post review fixes.
2012-04-20 19:41:20 +03:00
Mayank Prasad
2786a6e232 BUG#12427262 : 60961: SHOW TABLES VERY SLOW WHEN NOT IN SYSTEM DISK CACHE
Details:
- Merge : 5.1 -> 5.5
- Addded a new test case which was not added in 5.1 because PS was
  not there in 5.1.
2012-04-19 15:59:46 +05:30
Mayank Prasad
5203d9bb98 BUG#12427262 : 60961: SHOW TABLES VERY SLOW WHEN NOT IN SYSTEM DISK CACHE
Reason:
 This is a regression happened because of changes done in code refactoring 
 in 5.1 from 5.0.

Issue: 
 While doing "Show tables" lex->verbose was being checked to avoid opening
 FRM files to get table type. In case of "Show full table", lex->verbose
 is true to indicate table type is required. In 5.0, this check was
 present which got missing in >=5.5.

Fix:
 Added the required check to avoid opening FRM files unnecessarily in case
 of "Show tables".
2012-04-19 14:57:34 +05:30
Tor Didriksen
adb352ca3e new header file must be listed in Makefile.am 2012-04-18 14:13:13 +02:00
Tor Didriksen
d612986b36 Backport 5.5=>5.1 Patch for Bug#13805127:
Stored program cache produces wrong result in same THD.
2012-04-18 13:14:05 +02:00
Nuno Carvalho
0eea06c5d0 WL#6236: Allow SHOW MASTER LOGS and SHOW BINARY LOGS with REPLICATION CLIENT
Merge from 5.1 into 5.5.
2012-04-18 10:12:19 +01:00
Nuno Carvalho
a9a7e6ea24 WL#6236: Allow SHOW MASTER LOGS and SHOW BINARY LOGS with REPLICATION CLIENT
Currently SHOW MASTER LOGS and SHOW BINARY LOGS require the SUPER
privilege. Monitoring tools (such as MEM) often want to check this 
output - for instance MEM generates the SUM of the sizes of the logs 
reported here, and puts that in the Replication overview within the MEM
Dashboard.
However, because of the SUPER requirement, these tools often have an 
account that holds open the connection whilst monitoring, and can lock
out administrators when the server gets overloaded and reaches
max_connections - there is already another SUPER privileged account
connected, the "monitor". 

As SHOW MASTER STATUS, and all other replication related statements,
return with either REPLICATION CLIENT or SUPER privileges, this worklog 
is to make SHOW MASTER LOGS and SHOW BINARY LOGS be consistent with this
as well, and allow both of these commands with either SUPER or 
REPLICATION CLIENT. 
This allows monitoring tools to not require a SUPER privilege any more,
so is safer in overloaded situations, as well as being more secure, as 
lighter privileges can be given to users of such tools or scripts.
2012-04-18 10:08:01 +01:00
Chaithra Gopalareddy
2479f3cb7b Merge from 5.1 to 5.5 2012-04-18 11:34:36 +05:30
Chaithra Gopalareddy
81058259c7 Bug#12713907:STRANGE OPTIMIZE & WRONG RESULT UNDER
ORDER BY COUNT(*) LIMIT.

PROBLEM:
With respect to problem in the bug description, we
exhibit different behaviors for the two tables
presented, because innodb statistics (rec_per_key
in this case) are updated for the first table
and not so for the second one. As a result the
query plan gets changed in test_if_skip_sort_order
to use 'index' scan. Hence the difference in the
explain output. (NOTE: We can reproduce the problem
with first table by reducing the number of tuples
and changing the table structure)

The varied output w.r.t the query on the second table
is because of the result in the query plan change.
When a query plan is changed to use 'index' scan,
after the call to test_if_skip_sort_order, we set
keyread to TRUE immedietly. If for some reason
we drop this index scan for a filesort later on,
we fetch only the keys not the entire tuple.
As a result we would see junk values in the result set.

Following is the code flow:

Call test_if_skip_sort_order
-Choose an index to give sorted output
-If this is a covering index, set_keyread to TRUE
-Set the scan to INDEX scan

Call test_if_skip_sort_order second time
-Index is not chosen (note that we do not pass the
actual limit value second time. Hence we do not choose
index scan second time which in itself is a bug fixed
in 5.6 with WL#5558)
-goto filesort

Call filesort
-Create quick range on a different index
-Since keyread is set to TRUE, we fetch only the columns of
the index
-results in the required columns are not fetched

FIX:
Remove the call to set_keyread(TRUE) from
test_if_skip_sort_order. The access function which is
'join_read_first' or 'join_read_last' calls set_keyread anyways.
2012-04-18 11:25:01 +05:30
Annamalai Gurusami
6fc42540f8 Bug #12902967 CREATING SELF REFERENCING FK ON SAME INDEX
UNHANDLED, CONFUSING ERROR

The main confusion with the error message is that "it 
implies that your data dictionary may now be out of 
sync".  This patch will remove the unwanted and the 
misleading error message by not doing an unnecessary 
operation in the error handling code.  

rb://980 approved by: Dmitry Lenev
2012-04-17 16:54:02 +05:30
Tor Didriksen
582b728347 Bug#13871079 RQG_MYISAM_DML_ALTER_VALGRIND FAILS ON VALGRIND PN PB2
The class Copy_field contains a String tmp, 
which may allocate memory on the heap.
That means that all instances of Copy_field
must be properly destroyed. Alas they are not.

Solution: don't use Copy_field::tmp for copying
from_field => tmp => to_field
in do_field_string()
2012-04-12 15:04:22 +02:00
Georgi Kodinov
d59986d974 merge mysql-5.5->mysql-5.5-security 2012-04-12 14:04:12 +03:00
Sujatha Sivakumar
79579f5681 BUG#12662190:COM_COMMIT IS NOT INCREMENTED FROM THE BINARY LOGS ON SLAVE, COM_BEGIN IS
PROBLEM:

--------

When binary log statements are replayed on the slave, BEGIN is represented

in com_counters but COMMIT is not. Similarly in 'ROW' based replication

'INSERT','UPDATE',and 'DELETE' com_counters are not getting incremented

when the binary log statements are replayed at slave.

ANALYSIS:
---------

In 'ROW' based replication for COMMIT,INSERT,UPDATE and DELETE operations
following special events are invoked.
Xid_log_event,Write_rows_log_event,Update_rows_log_event,Update_rows_log_event.

The above mentioned events doesn't go through the parser where the
'COM_COUNTERS' are incremented.


FIX:
-----
Increment statements are added at appropriate events.
Respective functions are listed below.

'Xid_log_event::do_apply_event'
'Write_rows_log_event::do_before_row_operations'
'Update_rows_log_event::do_before_row_operations'
'Delete_rows_log_event::do_before_row_operations'
2012-04-12 11:07:39 +05:30
gopal.shankar@oracle.com
796fad1424 Bug#11815557 60269: MYSQL SHOULD REJECT ATTEMPTS TO CREATE SYSTEM
TABLES IN INCORRECT ENGINE

PROBLEM:
  CREATE/ALTER TABLE currently can move system tables like
mysql.db, user, host etc, to engines other than MyISAM. This is not
completely supported as of now, by mysqld. When some of system tables
like plugin, servers, event, func, *_priv, time_zone* are moved
to innodb, mysqld restart crashes. Currently system tables
can be moved to BLACKHOLE also!!!.

ANALYSIS:
  The problem is that there is no check before creating or moving
a system table to some particular engine.

  System tables are suppose to be residing in MyISAM. We can think
of restricting system tables to exist only in MyISAM. But, there could
be future needs of these system tables to be part of other engines
by design. For eg, NDB cluster expects some tables to be on innodb
or ndb engine. This calls for a solution, by which system
tables can be supported by any desired engine, with minimal effort.

FIX:
  The solution provides a handlerton interface using which,
mysqld server can query particular storage engine handlerton for
system tables that it supports. This way each storage engine
layer can define their own system database and system tables.

  The check_engine() function uses the new handlerton function
ha_check_if_supported_system_table() to check if db.tablename
provided in the DDL is supported by the SE.

Note: This fix has modified a test in help.test, which was moving
mysql.help_* to innodb. The primary intention of the test was not
to move them between engines.
2012-04-11 15:53:17 +05:30
Georgi Kodinov
e6704d116d merge mysql-5.5->mysql-5.5-security 2012-04-10 14:23:17 +03:00
Manish Kumar
d3782bffbd BUG#13917335 - ASSERTION `REPORT_PORT != 0' FAILED IN NETWORK_INIT ()
Problem - The cause of the failure is mainly due to the assert added in
          the code as a result of the fix of the BUG-13333431. When we
          start the server with the --skip-networking option enabled
          we have the mysqld_port explicitly to 0. Since the value of
          report_port is set to mysqld_port, the assertion that
          (report_port!= 0) fails.

Fix - the fix of the problem is to assert the not zero value of
      report_port only in the case the --skip-networking option is not
      used to start the mysqld server.
2012-04-10 16:15:06 +05:30
Georgi Kodinov
0409d6c05f auto mere mysql-5.1-security->mysql-5.5-security 2012-04-06 13:20:33 +03:00
Georgi Kodinov
5ac773b9b4 Bug #13934049: 64884: LOGINS WITH INCORRECT PASSWORD ARE ALLOWED
Fixed an improper type conversion on return that can make the server accept
logins with a wrong password.
2012-04-06 12:04:07 +03:00
Sergey Glukhov
eb790303d8 5.1-security -> 5.5-security merge 2012-04-04 14:19:00 +04:00
Sergey Glukhov
17817a3009 Bug#11766300 59387: FAILING ASSERTION: CURSOR->POS_STATE == 1997660512 (BTR_PCUR_IS_POSITIONE
Bug#13639204 64111: CRASH ON SELECT SUBQUERY WITH NON UNIQUE INDEX
The crash happened due to wrong calculation
of key length during creation of reference for
sort order index. The problem is that
keyuse->used_tables can have OUTER_REF_TABLE_BIT enabled
but used_tables parameter(create_ref_for_key() func) does
not have it. So key parts which have OUTER_REF_TABLE_BIT
are ommited and it could lead to incorrect key length
calculation(zero key length).
2012-04-04 13:29:45 +04:00
Praveenkumar Hulakund
aab9623a8d Bug#12762885: 61713: MYSQL WILL NOT BIND TO "LOCALHOST" IF LOCALHOST IS BOTH
IPV4/IPV6 ENABLED

Analysis:
----------------------
The problem was that if a hostname resolves to more than one IP-address,
the server (5.5) does not start due to an error. In 5.1 the server used to
take some IP-address and start.

It's a regression and should be fixed.

5.5 supports IPv6, while 5.1 does not. However, that should not 
prevent the server from start -- if a hostname has both IPv4 and IPv6 addresses,
the server should choose some IPv4-address and start.

It's been decided to prefer IPv4-address to be backward compatible with 5.1.

Another problem was that the 5.6 server did not report proper error message
when the specified hostname could not be resolved. So, the code has been 
changed to report proper error message.

Testing
================================
5.5
=============================
invalid hostname (localhos):
  => Following error message reported.
     120308 15:52:09 [ERROR] Can't start server: cannot resolve hostname!
     120308 15:52:09 [ERROR] Aborting

invalid ip_address:
  => Following error message reported.
      120308 15:56:06 [Note] Server hostname (bind-address): '123.123.123.123'; port: 3306
      120308 15:56:06 [Note]   - '123.123.123.123' resolves to '123.123.123.123';
      120308 15:56:06 [Note] Server socket created on IP: '123.123.123.123'.
      120308 15:56:06 [ERROR] Can't start server: Bind on TCP/IP port: Cannot assign requested address

Only ipv4 host configured:
  => Following message logged 
    120308 16:02:50 [Note] Server hostname (bind-address): 'localhost'; port: 3306
    120308 16:02:50 [Note]   - 'localhost' resolves to '127.0.0.1';
    120308 16:02:50 [Note] Server socket created on IP: '127.0.0.1'

Only ipv6 host configured:    
  => Following message logged 
    120308 16:04:03 [Note] Server hostname (bind-address): 'localhost'; port: 3306
    120308 16:04:03 [Note]   - 'localhost' resolves to '::1';
    120308 16:04:03 [Note] Server socket created on IP: '::1'.

ipv4 and ipv6 host configured:
  => Following message logged
    120308 16:05:02 [Note] Server hostname (bind-address): 'localhost'; port: 3306
    120308 16:05:02 [Note]   - 'localhost' resolves to '::1';
    120308 16:05:02 [Note]   - 'localhost' resolves to '127.0.0.1';
    120308 16:05:02 [Note] Server socket created on IP: '127.0.0.1'.
  => Non localhost address  
    120308 16:08:20 [Note] Server hostname (bind-address): 'mysql_addr'; port: 3306
    120308 16:08:20 [Note]   - 'mysql_addr' resolves to '10.178.58.216';
    120308 16:08:20 [Note]   - 'mysql_addr' resolves to 'fe80::120b:a9ff:fe69:59ec';
    120308 16:08:20 [Note] Server socket created on IP: '10.178.58.216'.

More than one entry for ipv4 and ipv6 address:
  => Following message logged
    120308 16:06:19 [Note] Server hostname (bind-address): 'localhost'; port: 3306
    120308 16:06:19 [Note]   - 'localhost' resolves to '::1';
    120308 16:06:19 [Note]   - 'localhost' resolves to '::1';
    120308 16:06:19 [Note]   - 'localhost' resolves to '127.0.0.1';
    120308 16:06:19 [Note]   - 'localhost' resolves to '127.0.0.1';
    120308 16:06:19 [Note] Server socket created on IP: '127.0.0.1'.
2012-04-04 11:13:42 +05:30
Rohit Kalhans
6b6b8f0582 BUG#11765650 Follow-up patch for Valgrind failures on PB2. 2012-04-03 00:35:43 +05:30
Rohit Kalhans
fe9352454f BUG#11765650 - 58637: MARK UPDATES THAT DEPEND ON ORDER OF TWO KEYS UNSAFE
Description: When the table has more than one unique or primary key, 
 INSERT... ON DUP KEY UPDATE statement is sensitive to the order in which
 the storage engines checks the keys. Depending on this order, the storage
 engine may determine different rows to mysql, and hence mysql can update
 different rows on master and slave.
      
 Solution: We mark INSERT...ON DUP KEY UPDATE on a table with more than on unique
 key as unsafe therefore the event will be logged in row format if it is available
 (ROW/MIXED). If only STATEMENT format is available, a warning will be thrown.
2012-03-30 18:35:53 +05:30
Tor Didriksen
71261282b1 Patch for Bug#13805127: Stored program cache produces wrong result in same THD.
Background:

  - as described in MySQL Internals Prepared Stored
    (http://forge.mysql.com/wiki/MySQL_Internals_Prepared_Stored),
    the Optimizer sometimes does destructive changes to the parsed
    LEX-object (Item-tree), which makes it impossible to re-use
    that tree for PS/SP re-execution.

  - in order to be able to re-use the Item-tree, the destructive
    changes are remembered and rolled back after the statement execution.

The problem, discovered by this bug, was that the objects representing
GROUP-BY clause did not restored after query execution. So, the GROUP-BY
part of the statement could not be properly re-initialized for re-execution
after destructive changes.

Those objects do not take part in the Item-tree, so they can not be saved
using the approach for Item-tree.

The fix is as follows:

  - introduce a new array in st_select_lex to store the original
    ORDER pointers, representing the GROUP-BY clause;

  - Initialize this array in fix_prepare_information().

  - restore the list of GROUP-BY items in reinit_stmt_before_use().
2012-03-29 15:07:54 +02:00
Tor Didriksen
1f9561d2f2 merge 5.1 => 5.5 2012-03-27 14:55:29 +02:00
Tor Didriksen
efc29bc531 Backport of fix for Bug#12763207 - ASSERT IN SUBSELECT::SINGLE_VALUE_TRANSFORMER 2012-03-27 14:39:27 +02:00
Praveenkumar Hulakund
bfd312df83 Merge from 5.1 to 5.5 2012-03-27 15:20:14 +05:30
Praveenkumar Hulakund
7ed197c95f Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE
Analysis:
-------------------------------
According to the Manual
(http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitivity.html):
"Column, index, stored routine, and event names are not case sensitive on any
platform, nor are column aliases."

In other words, 'lower_case_table_names' does not affect the behaviour of 
those identifiers.

On the other hand, trigger names are case sensitive on some platforms,
and case insensitive on others. 'lower_case_table_names' does not affect
the behaviour of trigger names either.

The bug was that SHOW statements did case sensitive comparison
for stored procedure / stored function / event names.

Fix:
Modified the code so that comparison in case insensitive for routines 
and events for "SHOW" operation.
2012-03-27 12:42:11 +05:30
Georgi Kodinov
b3099b51fa merge mysql-5.5->mysql-5.5-security 2012-03-21 14:56:29 +02:00
Georgi Kodinov
262c156849 merge mysql-5.1->mysql-5.1-security 2012-03-21 14:53:09 +02:00
Joerg Bruehe
a70c8c4b20 Merge the 5.5.22 release build into main 5.5,
conflict in "sql/filesort.cc" solved manually.
2012-03-20 22:27:49 +01:00
karen.langford@oracle.com
3adb401c8a Merge from mysql-5.1.62-release 2012-03-20 17:35:41 +01:00
Alexander Barkov
f75dbdd160 Bug#13832953 MY_STRNXFRM_UNICODE: ASSERTION `SRC' FAILED. | MY_STRNXFRM_UNICODE/MAKE_SORTKEY
Problem:

Field_set::val_str in case of an empty SET value
returned a String with str_length==0 and Ptr==0,
which is not expected by some pieces of the code.

Fix:
      
Returning an empty string with str_length==0 and Ptr=="",
like Field_enum does.
2012-03-20 09:16:51 +04:00
Jon Olav Hauglid
70207671eb Merge from mysql-5.5 to mysql-5.5-security
Text conflict in sql/share/errmsg-utf8.txt
2012-03-15 12:29:01 +01:00
Jon Olav Hauglid
f901156905 Merge from mysql-5.5 to mysql-5.5-security
Text conflict in sql/filesort.cc
2012-03-15 11:28:29 +01:00
Jon Olav Hauglid
e57cba1035 Merge from mysql-5.5 to mysql-5.5-security
No conflicts
2012-03-15 11:25:53 +01:00
Jon Olav Hauglid
f270614180 Bug#13833438: ERROR CODES MUST HAVE SAME VALUE ACROSS MYSQL VERSIONS
Pre-requisite patch.
Add end-of-file marker to 5.5 version of errmsg-utf8.txt.
2012-03-15 10:15:50 +01:00
Dmitry Shulga
1a7e7a0f75 This patch fixes the bug#13737343 (formerly known as 64374): XA TRANSACTIONS
AND SAVEPOINT.
      
The bug was introduced by the patch for bug#11766752. This patch sets too
strong condition on XA state for SAVEPOINT statement that disallows its
execution during XA transaction. But since the statement SAVEPOINT doesn't
imply implicit commit we can allow its handling during XA transaction.

The patch explicitly check for transaction state against states XA_NOTR
and XA_ACTIVE for which the handling of statement SAVEPOINT for XA
transaction is allowed.
2012-03-15 15:10:57 +06:00
Mattias Jonsson
aaf0e5d604 merge of bug#1364811 into mysql-5.5 2012-03-14 21:57:15 +01:00
Mattias Jonsson
f8eb62625f bug#13694811
Updated code comments according to reviewers requests.
2012-03-14 20:36:42 +01:00
Tor Didriksen
c8f4e2793d Bug#13721076 CRASH WITH TIME TYPE/TIMESTAMP() AND WARNINGS IN SUBQUERY
The table contains one time value: '00:00:32'
This value is converted to timestamp by a subquery.

In convert_constant_item we call (*item)->is_null()
which triggers execution of the Item_singlerow_subselect subquery,
and the string "0000-00-00 00:00:32" is cached
by Item_cache_datetime.
We continue execution and call update_null_value, which calls val_int()
on the cached item, which converts the time value to ((longlong) 32)
Then we continue to do (*item)->save_in_field()
which ends up in Item_cache_datetime::val_str() which fails,
since (32 < 101) in number_to_datetime, and val_str() returns NULL.

Item_singlerow_subselect::val_str isnt prepared for this:
if exec() succeeds, and return !null_value, then val_str()
*must* succeed.

Solution: refuse to cache strings like "0000-00-00 00:00:32"
in Item_cache_datetime::cache_value, and return NULL instead.

This is similar to the solution for 
Bug#11766860 - 60085: CRASH IN ITEM::SAVE_IN_FIELD() WITH TIME DATA TYPE

This patch is for 5.5 only.
The issue is not present after WL#946, since a time value
will be converted to a proper timestamp, with the current date
rather than "0000-00-00"
2012-03-14 13:25:14 +01:00