Commit graph

24881 commits

Author SHA1 Message Date
Georgi Kodinov
b385a2d8a5 merged 5.0-bugteam -> 5.1-bugtteam 2009-01-16 12:45:17 +02:00
Georgi Kodinov
683542698f merged Bug 38795 to 5.0-bugteam 2009-01-15 16:15:38 +02:00
Davi Arnaut
e48c7178f7 Merge from 5.0-bugteam 2009-01-15 08:28:10 -02:00
Alexander Nozdrin
852d1d66f6 Pull from 5.0-bugteam 2009-01-15 13:10:20 +03:00
Alexander Nozdrin
9a6e05d8b9 Backport patch for Bug#31222 (com_% global status counters behave randomly
with mysql_change_user) to 5.0.
2009-01-15 12:36:34 +03:00
Ramil Kalimullin
53e42d9ee4 Fix for
bug#33094: Error in upgrading from 5.0 to 5.1 when table contains
triggers
and
#41385: Crash when attempting to repair a #mysql50# upgraded table
with triggers.

Problem:
1. trigger code didn't assume a table name may have
a "#mysql50#" prefix, that may lead to a failing ASSERT().
2. "ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME" failed
for databases with "#mysql50#" prefix if any trigger.
3. mysqlcheck --fix-table-name didn't use UTF8 as a default
character set that resulted in (parsing) errors for tables with
non-latin symbols in their names and definitions of triggers.

Fix:
1. properly handle table/database names with "#mysql50#" prefix.
2. handle --default-character-set mysqlcheck option;
if mysqlcheck is launched with --fix-table-name or --fix-db-name
set default character set to UTF8 if no --default-character-set
option given.

Note: if given --fix-table-name or --fix-db-name option,
without --default-character-set mysqlcheck option
default character set is UTF8.


client/mysqlcheck.c:
  Fix for
  bug#33094: Error in upgrading from 5.0 to 5.1 when table contains
  triggers
  and
  #41385: Crash when attempting to repair a #mysql50# upgraded table
  with triggers.
    - check and set default charset if --default-character-set option
      given.
    - set default charset to "utf8" if there's
      --fix-table-name or --fix-db-name and no --default-character-set.
mysql-test/r/mysqlcheck.result:
  Fix for
  bug#33094: Error in upgrading from 5.0 to 5.1 when table contains
  triggers
  and
  #41385: Crash when attempting to repair a #mysql50# upgraded table
  with triggers.
    - test result.
mysql-test/t/mysqlcheck.test:
  Fix for
  bug#33094: Error in upgrading from 5.0 to 5.1 when table contains
  triggers
  and
  #41385: Crash when attempting to repair a #mysql50# upgraded table
  with triggers.
    - test case.
sql/mysql_priv.h:
  Fix for
  bug#33094: Error in upgrading from 5.0 to 5.1 when table contains
  triggers
  and
  #41385: Crash when attempting to repair a #mysql50# upgraded table
  with triggers.
    - check_n_cut_mysql50_prefix() introduced.
sql/sql_table.cc:
  Fix for
  bug#33094: Error in upgrading from 5.0 to 5.1 when table contains
  triggers
  and
  #41385: Crash when attempting to repair a #mysql50# upgraded table
  with triggers.
    - tablename_to_filename() code split into 2 parts
    - check_n_cut_mysql50_prefix() introduced to cut #mysql50# prefixes,
      used in the trigger code as well.
sql/sql_trigger.cc:
  Fix for
  bug#33094: Error in upgrading from 5.0 to 5.1 when table contains
  triggers
  and
  #41385: Crash when attempting to repair a #mysql50# upgraded table
  with triggers.
    - Table_triggers_list::check_n_load() - checking triggers assume
      a table/database name given may have "#mysql50#" prefix in some cases.
    - Table_triggers_list::change_table_name_in_triggers() -
      create .TRG file in new database directory and delete it in old one,
      as they may differ in case of
      "ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME"
    - Table_triggers_list::change_table_name_in_trignames() - remove stale .TRN
      files in #mysql50#dbname directory in case of database upgrade
    - Table_triggers_list::change_table_name() - allow changing trigger's
      database in case of its upgrading
sql/sql_trigger.h:
  Fix for
  bug#33094: Error in upgrading from 5.0 to 5.1 when table contains
  triggers
  and
  #41385: Crash when attempting to repair a #mysql50# upgraded table
  with triggers.
    - new old_db_name parameter added in
      Table_triggers_list::change_table_name_in_trignames() and
      Table_triggers_list::change_table_name_in_triggers()
2009-01-14 18:50:51 +04:00
He Zhenxing
45140a8ea3 Auto merge 2009-01-14 17:32:25 +08:00
He Zhenxing
f2c122bf90 BUG#41986 Replication slave does not pick up proper AUTO_INCREMENT value for Innodb tables
The next number (AUTO_INCREMENT) field of the table for write
rows events are not initialized, and cause some engines (innodb)
not correctly update the tables's auto_increment value.

This patch fixed this problem by honor next number fields if present.

mysql-test/extra/rpl_tests/rpl_auto_increment.test:
  Add test code for BUG#41986
mysql-test/suite/rpl/r/rpl_auto_increment.result:
  update test result file for BUG#41986
sql/log_event.cc:
  set next_number_field before writing rows, and reset next_number_field after finished writing rows
2009-01-14 16:27:32 +08:00
Davi Arnaut
3d6cea324a Bug#36326: nested transaction and select
The problem is that the query cache stores packets containing
the server status of the time when the cached statement was run.
This might lead to a wrong transaction status in the client side
if a statement is cached during a transaction and is later served
outside a transaction context (and vice-versa).

The solution is to take into account the transaction status when
storing in and serving from the query cache.

mysql-test/r/innodb_cache.result:
  Update test case result.
mysql-test/r/query_cache.result:
  Add test case result for Bug#36326
mysql-test/t/query_cache.test:
  Add test case for Bug#36326
sql/mysql_priv.h:
  Add new flags.
sql/sql_cache.cc:
  Remember the transaction and autocommit status stored in the packet.
tests/mysql_client_test.c:
  Add test case for Bug#36326
2009-01-13 20:07:06 -02:00
Georgi Kodinov
ba47e3bc4d Bug #38795: Automatic search depth and nested join's results in server crash
The greedy optimizer tracks the current level of nested joins and the position
inside these by setting and maintaining a state that's global for the whole FROM
clause.
This state was correctly maintained inside the selection of the next partial plan
table (in best_extension_by_limited_search()). 
greedy_search() also moves the current position by adding the last partial match 
table when there's not enough tables in the partial plan found by 
best_extension_by_limited_search().
This may require update of the global state variables that describe the current
position in the plan if the last table placed by greedy_search is not a top-level 
join table.
Fixed by updating the state after placing the partial plan table in greedy_search()
in the same way this is done on entering the best_extension_by_limited_search().
Fixed the signature of the function called to update the state : 
check_interleaving_with_nj

mysql-test/r/greedy_optimizer.result:
  Bug #38795: test case
mysql-test/t/greedy_optimizer.test:
  Bug #38795: test case
sql/sql_select.cc:
  Bug #38795: correctly update current position when placing
  the next partial plan table in greedy_search().
2009-01-13 13:09:12 +02:00
Georgi Kodinov
b91bbba2df Fixed a warning in sql_profile.cc 2009-01-12 18:17:15 +02:00
Georgi Kodinov
e0df7f1cd5 merged 41453 to 5.1-bugteam 2009-01-12 17:52:46 +02:00
Tatiana A. Nurnberg
95e0d3bd06 Bug#31177: Server variables can't be set to their current values
Bounds-checks and blocksize corrections were applied to user-input,
but constants in the server were trusted implicitly. If these values
did not actually meet the requirements, the user could not set change
a variable, then set it back to the (wonky) factory default or maximum
by explicitly specifying it (SET <var>=<value> vs SET <var>=DEFAULT).

Now checks also apply to the server's presets. Wonky values and maxima
get corrected at startup. Consequently all non-offsetted values the user
sees are valid, and users can set the variable to that exact value if
they so desire.

mysql-test/r/read_buffer_size_basic.result:
  test sets out of bounds value; we now throw a warning for this.
  This is a side-effect: before, the maximum was higher than the
  value we set here. The value was corrected to block-size, the
  maximum was not, hence the value was smaller than the maximum
  in this particular case. Now that we align the maxima at startup,
  the value in SET is larger than the (corrected) maximum, and we
  see a warning in this particular case. "This means we're doing it right."
mysql-test/r/read_rnd_buffer_size_basic.result:
  test sets out of bounds value; we now throw a warning for this.
  This is a side-effect: before, the maximum was higher than the
  value we set here. The value was corrected to block-size, the
  maximum was not, hence the value was smaller than the maximum
  in this particular case. Now that we align the maxima at startup,
  the value in SET is larger than the (corrected) maximum, and we
  see a warning in this particular case. "This means we're doing it right."
mysys/my_getopt.c:
  Do bounds-checking at start-up time so we'll catch and correct
  wonky default values and upper limits.
sql/mysqld.cc:
  If 0 is a legal value per the docs, not to mention the default, we shouldn't give 1 as
  the lower limit.
storage/innobase/handler/ha_innodb.cc:
  We are setting upper bounds here.
  ~0L gives -1. That is NOT what we want!
2009-01-12 06:32:49 +01:00
Georgi Kodinov
d09185fafa merged 41437 to 5.1-bugteam 2009-01-09 19:51:52 +02:00
Mattias Jonsson
fffe666f6d merge 2009-01-09 14:21:29 +01:00
Mattias Jonsson
efea2e68d8 Bug#40972: Partition pruning can lead to crash for bad dates
post push fix, added test found a valgrind warning

sql/sql_partition.cc:
  Bug#40972: Partition pruning can lead to crash for bad dates
  
  Fix for valgrind warning
2009-01-09 14:18:08 +01:00
Sven Sandberg
8576423de8 BUG#41924: high-level replication functions are not commented
Adding comments to some of the high-level functions in replication.

sql/log_event.h:
  Fixed some mistakes in comments.
sql/repl_failsafe.cc:
  Added comment for show_slave_hosts()
sql/slave.cc:
  Added comment for show_master_info(), handle_slave_[sql|io](), and next_event()
sql/sql_binlog.cc:
  Added @param comment.
sql/sql_lex.h:
  Added comment for st_lex_master_info.
sql/sql_repl.cc:
  Added comments for functions executing a statement:
      PURGE BINARY LOGS
      START SLAVE
      STOP SLAVE
      RESET SLAVE
      CHANGE MASTER
      RESET MASTER
      SHOW BINLOG EVENTS
      SHOW MASTER STATUS
      SHOW BINARY LOGS
2009-01-09 13:49:24 +01:00
Georgi Kodinov
5f4585626d Bug #41543: Assertion `m_status == DA_ERROR' failed in Diagnostics_area::sql_errno
No need to mask the error code returned by getting the next row to end of file when
doing filesort.

mysql-test/r/innodb_mysql_rbk.result:
  Bug #41543: test case
mysql-test/t/innodb_mysql_rbk-master.opt:
  Bug #41543: test case
mysql-test/t/innodb_mysql_rbk.test:
  Bug #41543: test case
sql/filesort.cc:
  Bug #41543: No need to mask the error code returned by getting the next row to end of file when
  doing filesort.
2009-01-09 14:04:47 +02:00
Georgi Kodinov
ac885d5dfb Bug #41437: Value stored in 'case' lacks charset, causes segfault
When substituting system constant functions with a constant result
the server was not expecting that the function may return NULL.
Fixed by checking for NULL and returning Item_null (in the relevant
collation) if the result of the system constant function was NULL.

mysql-test/r/mysql.result:
  Bug #41437: test case
mysql-test/t/mysql.test:
  Bug #41437: test case.
  Relies on database() returning NULL if no database is
  selected.
sql/item_strfunc.cc:
  Bug #41437: Check for NULL result on evaluating the system
  constant function and return a constant NULL item.
2009-01-09 13:50:18 +02:00
Sven Sandberg
8873e4eea3 Merged fix of BUG#41961 in 5.1-bugteam with recent changes in 5.1-bugteam 2009-01-09 11:37:08 +01:00
Sven Sandberg
b0fadb57ec merge fix of BUG#41961 in 5.1-bugteam with recent changes in 5.1-bugteam 2009-01-09 11:35:26 +01:00
Davi Arnaut
8dbb9c885d Bug#37016: TRUNCATE TABLE removes some rows but not all
The special TRUNCATE TABLE (DDL) transaction wasn't being properly
rolled back if a error occurred during row by row deletion. The
error can be caused by a foreign key restriction imposed by InnoDB
SE and would cause the server to erroneously issue a implicit
commit.

The solution is to rollback the transaction if a truncation via row
by row deletion fails, otherwise commit. All effects of a TRUNCATE 
ABLE operation are rolled back if a row by row deletion fails.

mysql-test/include/commit.inc:
  Truncate always starts a transaction and commits at the end.
  The commit at the end increases the count by two, one is the
  storage engine commit and the other is the binary log.
mysql-test/r/commit_1innodb.result:
  Update test case results.
mysql-test/r/innodb_mysql.result:
  Update test case results.
mysql-test/t/innodb_mysql.test:
  Add test case for Bug#37016
sql/sql_delete.cc:
  Move truncation using row by row deletion to its own function.
  If row by row deletion fails, rollback the transaction.
  
  Remove the meddling with disabling and enabling of autocommit
  as TRUNCATE transaction is now explicitly ended (committed
  or rolled back).
2009-01-09 08:20:32 -02:00
Sven Sandberg
5c92f27f63 BUG#41961: Some log_event types do not skip post-header when reading
Problem: when the server reads a log_event from file, it should read
the post-header lengths from the format_description_log_event. Some
event types which currently have post-header length 0 did not do this,
and instead had a hard-coded zero length for the post-header. That
means the current server version will not be able to read future
versions of these events.
Fix: make the reader functions read the post-header.


sql/log_event.cc:
   - Made Format_description_log_event constructor initialize all
     post-header lengths explicitly, to make it easier to find them
     in the source code.
   - After this, it is no longer necessary to pass the MY_ZEROFILL
     flag to my_malloc. I removed the flag and added a sanity-check
     that will be executed only in debug-mode.
   - Made INTVAR, RAND, USER_VAR, and XID events skip post_header_len
     when reading from file.
sql/log_event.h:
  Added explicit defines for the lengths of all event types.
2009-01-09 10:48:01 +01:00
Davi Arnaut
1a6452a208 Auto-merge from upstream 5.1-bugteam 2009-01-08 16:28:30 -02:00
Mattias Jonsson
13bb89ed06 merge 2009-01-08 11:17:21 +01:00
Timothy Smith
a58bc1bef3 Auto-merge from upstream 5.1-bugteam 2009-01-08 03:16:22 +01:00
Timothy Smith
88cd7a98a5 Fix a few problems after latest bunch of InnoDB snapshot changes:
The binlog_innodb test was sensitive to what tests ran before it.  Now run
FLUSH STATUS before performing operations that need to be checked.

sys_var_thd_ulong::update() was improperly casting an option value from
ulonglong to ulong before comparing it to the max allowed value.  On systems
where ulong and ulonglong are of different size, this caused values greater
than ULONG_MAX to wrap around (not be truncated to ULONG_MAX, which appears to
have been the intention of the original coder), and caused some checks to work
incorrectly.  This wasn't generally visible to the user, because later checks
would prevent the wrapped-around value from being used.  But it caused warning
messages to differ between 32- and 64-bit platforms.  Fix is to just remove the
cast.  Also added a DBUG_ASSERT to ensure that the value really is capped
properly before finally stuffing it into the ulong.
2009-01-08 03:06:54 +01:00
Mattias Jonsson
50c10a187b merge 2009-01-07 23:30:10 +01:00
Mattias Jonsson
f1731568e6 merge 2009-01-07 23:28:49 +01:00
Vladislav Vaintroub
4bd55050ad fix misspelling 2009-01-07 13:44:32 +01:00
Davi Arnaut
7ba37134d2 Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites
locking type of temp table

The problem is that INSERT INTO .. SELECT FROM .. and CREATE
TABLE .. SELECT FROM a temporary table could inadvertently
overwrite the locking type of the temporary table. The lock
type of temporary tables should be a write lock by default.

The solution is to reset the lock type of temporary tables
back to its default value after they are used in a statement.

mysql-test/r/innodb_mysql.result:
  Add test case result for Bug#41348
mysql-test/r/temp_table.result:
  Add test case result for Bug#41348
mysql-test/t/innodb_mysql.test:
  Add test case for Bug#41348
mysql-test/t/temp_table.test:
  Add test case for Bug#41348
sql/sql_base.cc:
  Allow the lock type of temp tables to be overwritten now that
  the the value is being restored once the table is marked as
  free for re-use. This makes the behavior consistent with that
  of non-temporary tables and avoids confusion.
2009-01-07 10:11:37 -02:00
Georgi Kodinov
6ff7a3264f merged 5.0-bugteam -> 5.1-bugteam 2009-01-05 20:47:28 +02:00
Georgi Kodinov
f97ef7a40e merged 5.1-main -> 5.1-bugteam 2009-01-05 18:10:20 +02:00
Georgi Kodinov
4978004e8d Reverted the fix for bug #25830 because of omissions and non-complete test
case.
2009-01-05 12:37:56 +02:00
Gleb Shchepa
335e842d24 Bug #41363: crash of mysqld on windows with aggregate in case
Execution of queries containing the CASE function of
aggregate function like in "SELECT ... CASE ARGV(...) WHEN ..."
crashed the server.


The CASE function caches pointers to concrete comparison
functions for an each pair of types of CASE-WHERE clause
parameters, i.e. for the "CASE INT_RESULT WHERE REAL_RESULT
THEN ... WHERE DECIMAL_RESULT ... END" function call it
caches comparisons for INT_RESULT with REAL_RESULT and
for INT_RESULT with DECIMAL_RESULT. Usually a result
type is known after a call to the fix_fields function,
however, the setup_copy_fields function call may
wrap aggregate items with Item_copy_string that has
STRING_RESULT result type, so setup_copy_fields may
change argument result types of the CASE function after
call to Item_func_case::fix_fields/fix_length_and_dec.
Then the Item_func_case::find_item function tries to
use comparison function for unexpected pair of the
STRING_RESULT and some other type - that caused
an assertion failure of server crash.

The Item_func_case::fix_length_and_dec function has
been modified to take into account possible STRING_RESULT
result type in the presence of aggregate arguments of
the CASE function.


mysql-test/r/func_in.result:
  Added test case for bug #41363.
mysql-test/t/func_in.test:
  Added test case for bug #41363.
sql/item_cmpfunc.cc:
  Bug #41363: crash of mysqld on windows with aggregate in case
  
  The Item_func_case::fix_length_and_dec function has
  been modified to take into account possible STRING_RESULT
  result type in the presence of aggregate arguments of
  the CASE function.
2008-12-31 15:55:04 +04:00
Tatiana A. Nurnberg
899546118d auto-merge 2008-12-30 12:51:00 +01:00
Tatiana A. Nurnberg
60e32e5e92 auto-merge 2008-12-30 12:48:38 +01:00
Tatiana A. Nurnberg
728c75cc0b auto-merge 2008-12-30 12:47:34 +01:00
Sven Sandberg
ba835f89ba BUG#40482: server/mysqlbinlog crashes when reading invalid Incident_log_event
Problem: When an Incident_log_event contains a bad incident number on disk,
the server crashes with an assertion.
Fix: Don't validate input with assertions. Use errors.

mysql-test/include/cleanup_fake_relay_log.inc:
  Added auxiliary file to restore things that setup_fake_relay_log.inc did.
mysql-test/include/setup_fake_relay_log.inc:
  Added auxiliary file to setup replication from an existing relay log.
mysql-test/std_data/bug40482-bin.000001:
  Binlog file for rpl.rpl_binlog_corruption
mysql-test/suite/rpl/t/rpl_binlog_corruption.test:
  New test file.
sql/log_event.cc:
  Check that the incident number is correct at the time the event is constructed.
  Do not assert it at the time it is printed.
sql/log_event.h:
  Incident_log_event::is_valid() should verify that the incident number is valid.
sql/rpl_constants.h:
  Incident numbers should be hard-coded, since they may appear in files.
2008-12-29 17:04:10 +01:00
Sergey Glukhov
39442f0903 5.0-bugteam->5.1-bugteam merge 2008-12-29 16:15:48 +04:00
Sergey Glukhov
3b617acb87 Bug#41131 "Questions" fails to increment - ignores statements instead stored procs(5.0 ver)
Added global status variable 'Queries' which represents
total amount of queries executed by server including
statements executed by SPs.
note: It's old behaviour of 'Questions' variable.


mysql-test/r/status.result:
  test result
mysql-test/t/status.test:
  test case
sql/mysqld.cc:
  Added global status variable 'Queries' which represents
  total amount of queries executed by server including
  statements executed by SPs.
  note: It's old behaviour of 'Questions' variable.
sql/sql_show.cc:
  Added global status variable 'Queries' which represents
  total amount of queries executed by server including
  statements executed by SPs.
  note: It's old behaviour of 'Questions' variable.
sql/structs.h:
  Added global status variable 'Queries' which represents
  total amount of queries executed by server including
  statements executed by SPs.
  note: It's old behaviour of 'Questions' variable.
2008-12-29 16:06:53 +04:00
Mattias Jonsson
f257aac814 Bug#40972: some sql execution lead the whole databse crashing
Problem was an errornous date that lead to end partition
was before the start, leading to a crash.

Solution was to check greater or equal instead of only
equal between start and end partition.

NOTE: partitioning pruning handles incorrect dates
differently than index lookup, which can give different
results in a partitioned table versus a non partitioned
table for queries having 'bad' dates in the where clause.

mysql-test/r/partition_pruning.result:
  Bug#40972: some sql execution lead the whole databse crashing
  
  Updated result file
mysql-test/t/partition_pruning.test:
  Bug#40972: some sql execution lead the whole databse crashing
  
  Added test.
sql/sql_partition.cc:
  Bug#40972: some sql execution lead the whole databse crashing
  
  There can be cases where the start/cur partition is greater
  than the end partition, so it must not continue, since that
  can lead to a crash.
2008-12-28 12:33:49 +01:00
Sergey Glukhov
bcfa0cedb2 5.0-bugteam->5.1-bugteam merge 2008-12-24 19:26:48 +04:00
Sergey Glukhov
ce985aa36e Bug#40953 SELECT query throws "ERROR 1062 (23000): Duplicate entry..." error
Table could be marked dependent because it is
either 1) an inner table of an outer join, or 2) it is a part of
STRAIGHT_JOIN. In case of STRAIGHT_JOIN table->maybe_null should not
be assigned. The fix is to set st_table::maybe_null to 'true' only
for those tables which are used in outer join.



mysql-test/r/select.result:
  test result
mysql-test/t/select.test:
  test case
sql/sql_select.cc:
  Table could be marked dependent because it is
  either 1) an inner table of an outer join, or 2) it is a part of
  STRAIGHT_JOIN. In case of STRAIGHT_JOIN table->maybe_null should not
  be assigned. The fix is to set st_table::maybe_null to 'true' only
  for those tables which are used in outer join.
sql/sql_select.h:
  added comment
2008-12-24 19:24:11 +04:00
Sergey Glukhov
e75ba73a07 5.0-bugteam->5.1-bugteam merge 2008-12-24 19:16:50 +04:00
Sergey Glukhov
7103f4c916 Bug#41456 SET PASSWORD hates CURRENT_USER()
init user->user struct with 
thd->security_ctx->priv_user context
if user->user is not initializied

mysql-test/r/grant.result:
  test result
mysql-test/t/grant.test:
  test case
sql/set_var.cc:
  init user->user struct with 
  thd->security_ctx->priv_user context
  if user->user is not initializied
2008-12-24 19:14:59 +04:00
Sergey Glukhov
15015b59e4 5.0-bugteam->5.1-bugteam merge 2008-12-24 19:09:00 +04:00
Sergey Glukhov
65c3d37111 Bug#25830 SHOW TABLE STATUS behaves differently depending on table name
replace wild_case_compare with my_wildcmp which is multibyte safe function


mysql-test/r/lowercase_utf8.result:
  test result
mysql-test/t/lowercase_utf8-master.opt:
  test case
mysql-test/t/lowercase_utf8.test:
  test case
sql/sql_show.cc:
  replace wild_case_compare with my_wildcmp which is multibyte safe function
2008-12-24 19:01:41 +04:00
Sergey Glukhov
853f4ba37b 5.0-bugteam->5.1-bugteam merge 2008-12-24 18:47:24 +04:00
Sergey Glukhov
4794f463b6 compiler warning fix 2008-12-24 18:45:47 +04:00