Commit graph

18399 commits

Author SHA1 Message Date
Evgeny Potemkin
7fff3efb46 Merged corrected fix for the bug#46051. 2009-07-18 18:11:33 +04:00
Evgeny Potemkin
32b02e0b4d Bug#46051: Incorrectly market field caused wrong result.
When during the optimization an item is moved to the upper select
the item's context left unchanged. This caused wrong result in the 
PS/SP mode.
The Item_ident::remove_dependence_processor now sets the context
of the select to which the item is moved to.
2009-07-18 18:09:56 +04:00
Evgeny Potemkin
0ee9fe2262 Merged fix for the bug#46051. 2009-07-17 18:45:32 +04:00
Evgeny Potemkin
af2c91b701 Bug#46051: Incorrectly market field caused wrong result.
In a subselect all fields from outer selects are marked as dependent on
selects they are belong to. In some cases optimizer substitutes it for an
equivalent expression. For example "a_field IN (SELECT outer_field)" is
substituted with "a_field = outer_field". As we moved the outer_field to the
upper select it's not really outer anymore. But it was left marked as outer.
If exists an index over a_field optimizer choose wrong execution plan and thus
return wrong result.

Now the Item_in_subselect::single_value_transformer function removes dependent
marking from fields when a subselect is optimized away.
2009-07-16 19:43:46 +04:00
Georgi Kodinov
127296601d Bug #46003 and bug #46034: backported the fixes from azalea. 2009-07-16 15:19:22 +03:00
Georgi Kodinov
5a6809590c Bug #46080: group_concat(... order by) crashes server when
sort_buffer_size cannot allocate

The NULL return from tree_insert() (on low memory) was not
checked for in Item_func_group_concat::add(). As a result
on low memory conditions a crash happens.

Fixed by properly checking the return code.
2009-07-10 15:00:34 +03:00
Georgi Kodinov
bf6e255d8c Bug #45287: phase 2 : 5.0 64 bit compilation warnings
Fixed various compilation warnings when compiling on a 
 64 bit windows.
2009-07-16 15:37:38 +03:00
Georgi Kodinov
1b7754a533 automerge 2009-07-15 17:00:26 +03:00
Georgi Kodinov
8acf778eae Bug #45287: phase 1 : 32 bit compilation warnings
Fixed the following problems:
1. cmake 2.6 warning because of a changed default on
how the dependencies to libraries with a specified 
path are resolved.
Fixed by requiring cmake 2.6.
2. Removed an obsolete pre-NT4 hack including defining
Windows system defines to alter the behavior of windows.h.
3. Disabled warning C4065 on compiling sql_yacc.cc because
of a know incompatibility in some of the newer bison binaries.
2009-07-15 16:46:25 +03:00
Anurag Shekhar
7c670fc3e1 Bug#37740 Server crashes on execute statement with full text search and
match against.


Server crashes when executing prepared statement with duplicating
MATCH() function calls in SELECT and ORDER BY expressions, e.g.:
SELECT MATCH(a) AGAINST('test') FROM t1 ORDER BY MATCH(a) AGAINST('test')

This query gets optimized by the server, so the value returned
by MATCH() from the SELECT list is reused for ORDER BY purposes.
To make this optimization server is comparing items from
SELECT and ORDER BY lists. We were getting server crash because
comparision function for MATCH() item is not intended to be called
at this point of execution.

In 5.0 and 5.1 this problem is workarounded by resetting MATCH()
item to the state as it was during PREPARE.

In 6.0 correct comparision function will be implemented and
duplicating MATCH() items from the ORDER BY list will be
optimized.
2009-07-15 15:00:58 +05:30
Georgi Kodinov
aa737dfc22 automerge 2009-07-14 11:47:22 +03:00
Georgi Kodinov
80dd3a593a Bug #40113: Embedded SELECT inside UPDATE or DELETE can timeout
without error

When using quick access methods for searching rows in UPDATE or 
DELETE there was no check if a fatal error was not already sent 
to the client while evaluating the quick condition.
As a result a false OK (following the error) was sent to the 
client and the error was thus transformed into a warning.

Fixed by checking for errors sent to the client during 
SQL_SELECT::check_quick() and treating them as real errors.

Fixed a wrong test case in group_min_max.test
Fixed a wrong return code in mysql_update() and mysql_delete()
2009-07-13 18:11:16 +03:00
Sergey Glukhov
1a539f170d Bug#45806 crash when replacing into a view with a join!
The crash happend because for views which are joins
we have table_list->table == 0 and 
table_list->table->'any method' call leads to crash.
The fix is to perform table_list->table->file->extra()
method for all tables belonging to view.
2009-07-03 13:35:00 +05:00
Staale Smedseng
490f443221 Bug #45790 Potential DoS vector: Writing of user input to log
without proper formatting
      
The problem is that a suitably crafted database identifier
supplied to COM_CREATE_DB or COM_DROP_DB can cause a SIGSEGV,
and thereby a denial of service. The database name is printed
to the log without using a format string, so potential
attackers can control the behavior of my_b_vprintf() by
supplying their own format string. A CREATE or DROP privilege
would be required.
      
This patch supplies a format string to the printing of the
database name. A test case is added to mysql_client_test.
2009-07-01 14:09:44 +02:00
Staale Smedseng
19dfaa5824 Merge from 5.0-bt 2009-06-29 15:17:01 +02:00
Satya B
c417035866 Applying InnoDB snashot 5.0-ss5406, part 2. Fixes BUG#40565
BUG#40565 - Update Query Results in "1 Row Affected" But Should Be "Zero Rows"

Detailed revision comments:

r5232 | marko | 2009-06-03 14:31:04 +0300 (Wed, 03 Jun 2009) | 21 lines
branches/5.0: Merge r3590 from branches/5.1 in order to fix Bug #40565
(Update Query Results in "1 Row Affected" But Should Be "Zero Rows").

Also, add a test case for Bug #40565.

rb://128 approved by Heikki Tuuri
  ------------------------------------------------------------------------
  r3590 | marko | 2008-12-18 15:33:36 +0200 (Thu, 18 Dec 2008) | 11 lines

  branches/5.1: When converting a record to MySQL format, copy the default
  column values for columns that are SQL NULL.  This addresses failures in
  row-based replication (Bug #39648).

  row_prebuilt_t: Add default_rec, for the default values of the columns in
  MySQL format.

  row_sel_store_mysql_rec(): Use prebuilt->default_rec instead of
  padding columns.

  rb://64 approved by Heikki Tuuri
  ------------------------------------------------------------------------
2009-06-25 15:20:26 +05:30
Staale Smedseng
2b48caa42d Bug #32223 SETting max_allowed_packet variable
Inconsistent behavior of session variable max_allowed_packet 
(and net_buffer_length); only assignment to the global variable 
has any effect, without this being obvious to the user.
      
The patch for Bug#22891 is backported to 5.0, making the two
session variables read-only. As this is a backport to GA 
software, the error used when trying to assign to the read-
only variable is ER_UNKNOWN_ERROR. The error message is the 
same as in 5.1+.
2009-06-19 11:27:19 +02:00
Alfranio Correia
9069e110d4 auto-merge mysql-5.0-bugteam (local) --> mysql-5.0-bugteam 2009-06-18 18:28:47 +01:00
Staale Smedseng
30fccdaaae Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2
      
Compiling MySQL with gcc 4.3.2 and later produces a number of 
warnings, many of which are new with the recent compiler
versions.
                  
This bug will be resolved in more than one patch to limit the
size of changesets. This is the second patch, fixing more
of the warnings.
2009-06-17 15:54:01 +02:00
Georgi Kodinov
b1560b9f2f Bug #44810: index merge and order by with low sort_buffer_size
crashes server!

The problem affects the scenario when index merge is followed by a filesort
and the sort buffer is not big enough for all the sort keys.
In this case the filesort function will read the data to the end through the 
index merge quick access method (and thus closing the cursor etc), 
but will leave the pointer to the quick select method in place.
It will then create a temporary file to hold the results of the filesort and
will add it as a sort output file (in sort.io_cache).
Note that filesort will copy the original 'sort' structure in an automatic
variable and restore it after it's done.
As a result at exiting filesort() we have a sort.io_cache filled in and 
nothing else (as a result of close of the cursors at end of reading data 
through index merge).
Now create_sort_index() will note that there is a select and will clean it up
(as it's been used already by filesort() reading the data in). While doing that
a special case in the index merge destructor will clean up the sort.io_cache,
assuming it's an output of the index merge method and is not needed anymore.
As a result the code that tries to read the data back from the filesort output 
will get no data in both memory and disk and will crash.
      
Fixed similarly to how filesort() does it : by copying the sort.io_cache structure
to a local variable, removing the pointer to the io_cache (so that it's not freed 
by QUICK_INDEX_MERGE_SELECT::~QUICK_INDEX_MERGE_SELECT) and restoring the original 
structure (together with the valid pointer) after the cleanup is done.
This is a safe thing to do because all the structures are already cleaned up by
hitting the end of the index merge's read method (QUICK_INDEX_MERGE_SELECT::get_next()) 
and the cleanup code being written in a way that tolerates repeating cleanups.
2009-06-15 16:38:15 +03:00
Georgi Kodinov
1f2b5b3037 Bug #45386: Wrong query result with MIN function in field list,
WHERE and GROUP BY clause

Loose index scan may use range conditions on the argument of 
the MIN/MAX aggregate functions to find the beginning/end of 
the interval that satisfies the range conditions in a single go.
These range conditions may have open or closed minimum/maximum 
values. When the comparison returns 0 (equal) the code should 
check the type of the min/max values of the current interval 
and accept or reject the row based on whether the limit is 
open or not.
There was a wrong composite condition on checking this and it was
not working in all cases.
Fixed by simplifying the conditions and reversing the logic.
2009-06-12 15:38:55 +03:00
Alfranio Correia
93598a3a45 BUG#34687 Error in bin-log after shutdown restart binlog was not closed properly
While reading a binary log that is being used by a master or was not properly
closed, most likely due to a crash, the following warning message is being
printed out: "Warning: this binlog was not closed properly. Most probably mysqld
crashed writing it.". This was scaring our users as the message was not taking
into account the possibility of the file is being just used by the master.

To avoid unnecessarily scaring our users, we replace the original message by the
following one: Warning: "this binlog is either is use or was not closed properly.".
2009-06-11 02:08:40 +01:00
Staale Smedseng
dae006c17f Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2
      
Compiling MySQL with gcc 4.3.2 and later produces a number of 
warnings, many of which are new with the recent compiler
versions.
      
This bug will be resolved in more than one patch to limit the
size of changesets. This is the first patch, fixing a number 
of the warnings, predominantly "suggest using parentheses 
around && in ||", and empty for and while bodies.
2009-06-09 18:11:21 +02:00
Tatiana A. Nurnberg
57c253bcb1 auto-merge 2009-06-05 23:29:37 +02:00
Tatiana A. Nurnberg
b89d2fce58 Bug#32149: Long semaphore wait for adaptive hash latch
Holding on to the temporary inno hash index latch is an optimization in
many cases, but a pessimization in some others.

Release temporary latches for those corner cases we (or rather, or customers,
thanks!) have identified, that is, when we are about to do something that
might take a really long time, like REPAIR or filesort.
2009-06-05 00:23:08 +02:00
Georgi Kodinov
932c7a316c Bug #36995: valgrind error in remove_const during subquery executions
When copying the Item class one must copy its attributes as well.
2009-06-04 12:52:40 +03:00
Sergey Glukhov
1a1ffe7312 Bug#44798 MySQL engine crashes when creating stored procedures with execute_priv=N
The crash happens because of uninitialized
lex->ssl_cipher, lex->x509_subject, lex->x509_issuer variables.
The fix is to add initialization of these variables for
stored procedures&functions.
2009-06-04 10:28:45 +05:00
Sergey Glukhov
83ec6e0592 Bug#45152 crash with round() function on longtext column in a derived table
The crash happens due to wrong max_length value which is set on
Item_func_round::fix_length_and_dec() stage. The value is set to
args[0]->max_length which is too big in case of LONGTEXT(LONGBLOB) fields.
The fix is to set max_length using float_length() function.
2009-06-02 11:38:13 +05:00
Alexey Kopytov
8787989473 Automerge. 2009-06-01 16:42:24 +04:00
He Zhenxing
c0fde0eda7 BUG#43263 BEGIN skipped in some replicate-do-db cases
BEGIN/COMMIT/ROLLBACK was subject to replication db rules, and
caused the boundary of a transaction not recognized correctly 
when these queries were ignored by the rules.

Fixed the problem by skipping replication db rules for these
statements.
2009-05-31 11:26:58 +08:00
Sergey Glukhov
cb07978da9 Bug#41212 crash after race condition between merge table and table_cache evictions
On 64-bit Windows: querying MERGE table with keys may cause
server crash.The problem is generic and may affect any statement
accessing MERGE table cardinality values.
When MERGE engine was copying cardinality statistics, it was
using incorrect size of element in cardinality statistics array
(sizeof(ptr)==8 instead of sizeof(ulong)==4), causing access
of memory beyond of the allocated bounds.
2009-05-27 15:34:21 +05:00
Alexey Kopytov
2df531fdc4 Bug #44767: invalid memory reads in password() and
old_password() functions   
The PASSWORD() and OLD_PASSWORD() functions could lead to   
memory reads outside of an internal buffer when used with BLOB   
arguments.   
  
String::c_ptr() assumes there is at least one extra byte  
in the internally allocated buffer when adding the trailing  
'\0'.  This, however, may not be the case when a String object  
was initialized with externally allocated buffer.  
  
The bug was fixed by adding an additional "length" argument to  
make_scrambled_password_323() and make_scrambled_password() in  
order to avoid String::c_ptr() calls for  
PASSWORD()/OLD_PASSWORD().  
  
However, since the make_scrambled_password[_323] functions are  
a part of the client library ABI, the functions with the new  
interfaces were implemented with the 'my_' prefix in their  
names, with the old functions changed to be wrappers around  
the new ones to maintain interface compatibility.
2009-05-27 14:20:57 +04:00
Luis Soares
2b4fcc1dbf BUG#41725: slave crashes when inserting into temporary table after
stop/start slave
      
When stopping and restarting the slave while it is replicating
temporary tables, the server would crash or raise an assertion
failure. This was due to the fact that although temporary tables are
saved between slave threads restart, the reference to the thread in
use (table->in_use) was not being properly updated when the restart
happened (it would still reference the old/invalid thread instead of
the new one).
      
This patch addresses this issue by resetting the reference to the new
slave thread on slave thread restart.
2009-05-23 00:15:21 +01:00
Alexey Kopytov
a46f4b31fc Automerge. 2009-05-21 16:15:25 +04:00
Alexey Kopytov
85645fe3f6 Bug #44796: valgrind: too many my_longlong10_to_str_8bit
warnings after uncompressed_length 
 
UNCOMPRESSED_LENGTH() did not validate its argument. In 
particular, if the argument length was less than 4 bytes, 
an uninitialized memory value was returned as a result. 
 
Since the result of COMPRESS() is either an empty string or 
a 4-byte length prefix followed by compressed data, the bug was 
fixed by ensuring that the argument of UNCOMPRESSED_LENGTH() is 
either an empty string or contains at least 5 bytes (as done in 
UNCOMPRESS()). This is the best we can do to validate input 
without decompressing.
2009-05-20 12:30:06 +04:00
Gleb Shchepa
8a39147a6a Bug#40825: Error 1356 while selecting from a view
with a "HAVING" clause though query works

SELECT from views defined like:

  CREATE VIEW v1 (view_column)
    AS SELECT c AS alias FROM t1 HAVING alias

fails with an error 1356:
  View '...' references invalid table(s) or column(s)
  or function(s) or definer/invoker of view lack rights
  to use them


CREATE VIEW form with a (column list) substitutes
SELECT column names/aliases with names from a
view column list.
However, alias references in HAVING clause was
not substituted.


The Item_ref::print function has been modified
to write correct aliased names of underlying
items into VIEW definition generation/.frm file.
2009-05-18 23:43:06 +05:00
Georgi Kodinov
3d94a6ba00 backported a change from 5.1 2009-05-15 16:13:54 +03:00
Georgi Kodinov
182bc3062c fixed a win32 compile error 2009-05-15 16:11:27 +03:00
Georgi Kodinov
803ce846a3 merged 5.0-main -> 5.0-bugteam 2009-05-15 12:29:41 +03:00
Alexey Kopytov
9a0e01d73e Automerge. 2009-05-15 12:54:40 +04:00
Alexey Kopytov
12f18228b4 Bug #44792: valgrind warning when casting from time to time
Field_time::get_time() did not initialize some members of 
MYSQL_TIME which led to valgrind warnings when those members 
were accessed in Protocol_simple::store_time(). 
 
It is unlikely that this bug could result in wrong data 
being returned, since Field_time::get_time() initializes the 
'day' member of MYSQL_TIME to 0, so the value of 'day' 
in Protocol_simple::store_time() would be 0 regardless 
of the values for 'year' and 'month'.
2009-05-15 12:16:00 +04:00
Sergey Glukhov
f024bde473 Bug#43612 crash with explain extended, union, order by
In UNION if we use last SELECT without braces and this
SELECT have ORDER BY clause, such clause belongs to
global UNION. It is parsed like last SELECT
part and used further as 'unit->global_parameters->order_list' value.
During DESCRIBE EXTENDED we call select_lex->print_order() for
last SELECT where order fields refer to tmp table 
which already freed. It leads to crash.
The fix is clean up global_parameters->order_list
instead of fake_select_lex->order_list.
2009-05-15 12:03:34 +05:00
Ramil Kalimullin
ae8348c249 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().
2009-05-12 13:18:27 +05:00
Chad MILLER
f72ddaebbf Fix improperly-protected variable definition and use.
Also, add CPP so Windows works properly for profiling. Community-server
functionality is required.
2009-05-11 10:00:03 -04:00
Ramil Kalimullin
0781a30262 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.
2009-05-10 20:50:14 +05:00
Chad MILLER
128afdc3e5 Merge community up to enterprise, thus ending the community-server
adventure.
2009-05-06 09:06:32 -04:00
Anurag Shekhar
81de724743 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).
2009-05-06 13:37:10 +05:30
Chad MILLER
9d58239dea Pull 5.1 treatment of community features into 5.0. 2009-05-05 17:03:23 -04:00
Gleb Shchepa
480fac6107 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.
2009-05-01 00:20:37 +05:00
Andrei Elkin
6b39bb5eac merging from 5.0-bt rep to a local branch 2009-04-30 15:41:47 +03:00