Commit graph

12353 commits

Author SHA1 Message Date
Evgeny Potemkin
63e6a59d73 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.

mysql-test/r/subselect.result:
  Added a test case for the bug#46051.
mysql-test/t/subselect.test:
  Added a test case for the bug#46051.
sql/item_subselect.cc:
  Bug#46051: Incorrectly market field caused 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
924c8c5bfb Addendum to the fix for bug #46080: fixed the test case 2009-07-10 17:03:09 +03:00
Georgi Kodinov
5beae1f8dc 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
Sergey Glukhov
2dd7094681 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.


mysql-test/r/view.result:
  test result
mysql-test/t/view.test:
  test case
sql/sql_insert.cc:
  added prepare_for_positional_update() function
  which updates extra info about primary key for
  tables belonging to view.
2009-07-03 13:35:00 +05:00
Bernt M. Johnsen
15b23550d4 Prepare for push 2009-07-03 10:36:10 +02:00
Bernt M. Johnsen
e0a3403b45 Bug#15866 Prepared for push on 5.0 2009-07-03 10:19:32 +02:00
Matthias Leich
3abee40e6b Fix for Bug#45902 rpl_sp fails sporadically in check testcases
Details:
- Add "sync_slave_with_master" at test end
- Restore the initial value of log_bin_trust_function_creators
2009-07-02 13:22:12 +02:00
Satya B
faaa9e0855 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
37d2019d17 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+.

mysql-test/t/variables.test:
  Tests are changed to account for the new semantics, and assignment to the read-only variables is added to test 
  the emission of the correct error message.
sql/set_var.cc:
  Both max_allowed_packet and net_buffer_length are changed 
  to be of type sys_var_thd_ulong_session_readonly. ER_UNKNOWN_ERROR is used to indicate an attempt to assign 
  to an instance of a read-only variable.
sql/set_var.h:
  Class sys_var_thd_ulong_session_readonly is added.
2009-06-19 11:27:19 +02:00
Alexey Kopytov
689901f36f Automerge. 2009-06-17 16:36:45 +04:00
Georgi Kodinov
6df6c8ee95 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.

mysql-test/r/index_merge.result:
  Bug #44810: test case
mysql-test/t/index_merge.test:
  Bug #44810: test case
sql/sql_select.cc:
  Bug #44810: preserve the io_cache produced by filesort while cleaning up
  the index merge quick access method (QUICK_INDEX_MERGE_SELECT).
2009-06-15 16:38:15 +03:00
Georgi Kodinov
3e82a86ed2 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.

mysql-test/r/group_min_max.result:
  Bug #45386: test case
mysql-test/t/group_min_max.test:
  Bug #45386: test case
sql/opt_range.cc:
  Bug #45386: fix the check whether to use the value if on the
  interval boundry
2009-06-12 15:38:55 +03:00
Alexey Kopytov
897a1b56d8 Bug #45236: large blob inserts from mysqldump fail, possible
memory issue ? 
 
The mysql command line client could misinterpret some character 
sequences as commands under some circumstances. 
 
The upper limit for internal readline buffer was raised to 1 GB 
(the same as for server's max_allowed_packet) so that any input 
line is processed by add_line() as a whole rather than in 
chunks.

client/mysql.cc:
  The upper limit for internal readline buffer was raised to 1 GB 
  (the same as for server's max_allowed_packet) so that any input 
  line is processed by add_line() as a whole rather than in 
  chunks.
mysql-test/r/mysql-bug45236.result:
  Added a test case for bug #45236.
mysql-test/t/mysql-bug45236.test:
  Added a test case for bug #45236.
2009-06-10 11:24:47 +04:00
Bernt M. Johnsen
6199226f94 Bug#15866 Split of main.sp and main.sp-fib. Merged from 5.0 gca 2009-06-04 16:13:16 +02:00
Bernt M. Johnsen
a3ac1f7e78 Bug#15866 main.sp-fib split from main.sp 2009-06-04 13:38:53 +02:00
Georgi Kodinov
a037071a75 Bug #36995: valgrind error in remove_const during subquery executions
When copying the Item class one must copy its attributes as well.

mysql-test/r/innodb_mysql.result:
  Bug #36995: test case
mysql-test/t/innodb_mysql.test:
  Bug #36995: test case
sql/item.cc:
  Bug #36995: copy attributes in the copy constructor
2009-06-04 12:52:40 +03:00
Sergey Glukhov
8041311e24 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.


mysql-test/r/sp_notembedded.result:
  test result
mysql-test/t/sp_notembedded.test:
  test case
sql/sql_acl.cc:
  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
33734e956f 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.



mysql-test/r/func_math.result:
  test result
mysql-test/t/func_math.test:
  test case
sql/item_func.cc:
  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
47b334a642 Automerge. 2009-06-01 16:42:24 +04:00
He Zhenxing
83a11b78df post fix of test result 2009-05-31 20:10:59 +08:00
He Zhenxing
5dd1abae7d 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.


sql/log_event.cc:
  Skip checking replication db rules for BEGIN/COMMIT/ROLLBACK statements
2009-05-31 11:26:58 +08:00
Sergey Glukhov
4cfc9d771a test case fix 2009-05-28 16:19:49 +05:00
Sergey Glukhov
1b91400ac6 Bug#37268 'binary' character set makes CLI-internal commands case sensitive
The fix is to use case insensitive collation
for mysql client command search.



client/mysql.cc:
  The fix is to use case insensitive collation
  for mysql client command search.
mysql-test/r/mysql.result:
  test result
mysql-test/t/mysql.test:
  test case
2009-05-28 13:34:30 +05:00
Alexey Kopytov
1b8322c3c6 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.  

mysql-test/r/func_crypt.result:
  Added a test case for bug #44767.
mysql-test/t/func_crypt.test:
  Added a test case for bug #44767.
sql/item_strfunc.cc:
  Use the new my_make_scrambled_password*() to avoid 
  String::c_ptr().
sql/item_strfunc.h:
  Changed Item_func[_old]_password::alloc() interfaces so that
  we can use the new my_make_scrambled_password*() functions.
sql/mysql_priv.h:
  Added declarations for the new my_make_scrambled_password*() 
  functions.
sql/password.c:
  Added new my_make_scrambled_password*() functions with an
  additional "length" argument. Changed ones to be wrappers
  around the new ones to maintain interface compatibility.
sql/sql_yacc.yy:
  Utilize the new password hashing functions with additional length
  argument.
2009-05-27 14:20:57 +04:00
Luis Soares
8e589d1d06 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.

mysql-test/r/rpl_temporary.result:
  Result file.
mysql-test/t/rpl_temporary.test:
  Test case that checks that both failures go away.
sql/slave.cc:
  Changed slave.cc to reset sql_thd reference in temporary tables.
2009-05-23 00:15:21 +01:00
Patrick Crews
a41d2dafa0 merge 2009-05-22 11:38:52 -04:00
Patrick Crews
e42f28192d Bug#40465 - mysqldump.test does no checking of dump or restore
Created new .test file - mysqldump_restore that does test restore from mysqldump
output for a limited number of basic cases.
Create new .inc file - mysqldump.inc - renames original table and uses mysqldump
output to recreate the table, then uses diff_tables.inc to compare the two tables.
Backported include/diff_tables.inc to facilitate this testing.
New patch incorporating review feedback prior to push.

mysqldump.test - removed redundant call to include/have_log_bin.inc (was used twice in the test!)
2009-05-22 10:38:17 -04:00
Patrick Crews
2a47699cad Bug#40465: mysqldump.test does no checking of dump or restore.
Created new .test file - mysqldump_restore that does this for a limited number
of basic cases.
Created new .inc file - mysqldump.inc - renames original table and uses mysqldump
output to recreate the table, then uses diff_tables.inc to compare the two tables.
Backported include/diff_tables.inc to facilitate this testing.
2009-05-21 16:03:53 -04:00
Alexey Kopytov
645817dd56 Automerge. 2009-05-21 21:50:58 +04:00
Alexey Kopytov
82c878f913 Attempt #2 to fix PB failures introduced by the patch for bug #44796.
Since max_allowed_packet is a read-only variable in 5.1 and up,
disable warnings to avoid unnecessary test case complication.
2009-05-21 21:50:17 +04:00
Alexey Kopytov
9cf94dadeb Automerge. 2009-05-21 19:17:39 +04:00
Alexey Kopytov
2cd3eaf27d Fixed a PB failure introduced by the patch for bug #44796.
Set max_allowed_packet to get a consistent error message.
2009-05-21 19:14:56 +04:00
Alexey Kopytov
336028da76 Automerge. 2009-05-21 16:15:25 +04:00
Alexey Kopytov
0b62b7f26d 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. 

mysql-test/r/func_compress.result:
  Added a test case for bug #44796.
mysql-test/t/func_compress.test:
  Added a test case for bug #44796.
sql/item_strfunc.cc:
  Make sure that the argument of UNCOMPRESSED_LENGTH() contains 
  at least 5 bytes (as done in UNCOMPRESS()).
2009-05-20 12:30:06 +04:00
Sergey Glukhov
0a892c46e0 Bug#39793 Foreign keys not constructed when column has a '#' in a comment or default value
Internal InnoDN FK parser does not recognize '\'' as quotation symbol.
Suggested fix is to add '\'' symbol check for quotation condition
(dict_strip_comments() function).


innobase/dict/dict0dict.c:
  Internal InnoDN FK parser does not recognize '\'' as quotation symbol.
  Suggested fix is to add '\'' symbol check for quotation condition
  (dict_strip_comments() function).
mysql-test/r/innodb_mysql.result:
  test result
mysql-test/t/innodb_mysql.test:
  test case
2009-05-19 11:32:21 +05:00
Gleb Shchepa
a7294532b2 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.


mysql-test/r/view.result:
  Added test file for bug #40825.
mysql-test/t/view.test:
  Added test file for bug #40825.
sql/item.cc:
  Bug#40825: Error 1356 while selecting from a view
             with a "HAVING" clause though query works
  
  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
Matthias Leich
1d03fb715e Merge of fix into GCA tree, no conflicts 2009-05-15 17:41:35 +02:00
Philip Stoev
8e72b44969 Bug #32651 grant_cache.test fails
It turns out that this test case no longer fails with the discrepancy
  in numbers that was the original cause for disabling this test (and showed
  potential genuine issues with the query cache). Therefore
  this test is being enabled after some minor adjustment of error codes and
  messages.
2009-05-15 13:06:11 +03:00
Matthias Leich
f4eb0953b1 Fix for Bug#44826 main.information_schema_db could harm succeeding tests
Details:
1. Add missing "disconnect <session>"
2. Take care that the disconnects are finished when the test terminates
3. Replace error names by error numbers
4. Minor beautifying of script code
2009-05-15 11:59:31 +02:00
Georgi Kodinov
812d2559b5 merged 5.0-main -> 5.0-bugteam 2009-05-15 12:29:41 +03:00
Alexey Kopytov
d68ea7d519 Automerge. 2009-05-15 12:54:40 +04:00
Alexey Kopytov
22e840d707 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'.

mysql-test/r/type_time.result:
  Added a test case for bug #44792.
mysql-test/t/type_time.test:
  Added a test case for bug #44792.
sql/field.cc:
  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().
2009-05-15 12:16:00 +04:00
Sergey Glukhov
fc57b4cfb5 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.


mysql-test/r/union.result:
  test result
mysql-test/t/union.test:
  test case
sql/sql_union.cc:
  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
80fdebafa8 Fix for bug#44774 merged. 2009-05-13 09:21:38 +05:00
Jim Winstead
c65ebb5d13 Merge from 5.0-bugteam 2009-05-12 14:20:33 -07:00
Chad MILLER
dbf8997b40 Remove community-server only feature and place in its own test
with appropriate condition.
2009-05-12 09:14:23 -04: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
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
Alexey Kopytov
f68ae2f514 Automerge. 2009-05-08 21:58:39 +04:00
Jim Winstead
3fe1d299ec Fix support for -i (--ignore-spaces) in the mysql command line application,
which didn't actually do anything. (Bug #39101)
2009-05-07 10:28:29 -07:00