Commit graph

24916 commits

Author SHA1 Message Date
Georgi Kodinov
0dde5599bd merged 2009-12-01 11:24:42 +02:00
Georgi Kodinov
f1eb8d937e Bug #45576: moving the test from experimental to disabled. 2009-12-01 11:21:15 +02:00
Georgi Kodinov
248a74eaa1 Revert of the push of bug #20837 due to failing regression tests. 2009-12-01 11:19:51 +02:00
unknown
f5b7184919 Updated experimental test list for rpl.rpl_cross_version
and rpl.rpl_get_master_version_and_clock.
2009-12-01 16:27:21 +08:00
Satya B
43f7cd0172 merge to mysql-5.1-bugteam 2009-11-30 19:31:09 +05:30
Satya B
1e26b2c26b Applying InnoDB Plugin 1.0.6 snapshot, part 8. Fixes BUG#48782
applied revisions: r6185, r6186, r6189, r6194

r6185 - only code changes incorporated, changesets which change
        innodb tests in the main mysql suite are discarded

r61889 - Fixes BUG#48782

Detailed revision comments:

r6185 | marko | 2009-11-17 16:44:20 +0200 (Tue, 17 Nov 2009) | 16 lines
branches/zip: Report duplicate table names
to the client connection, not to the error log.  This change will allow
innodb-index.test to be re-enabled.  It was previously disabled, because
mysql-test-run does not like output in the error log.

row_create_table_for_mysql(): Do not output anything to the error log
when reporting DB_DUPLICATE_KEY.  Let the caller report the error.
Add a TODO comment that the dict_table_t object is apparently not freed
when an error occurs.

create_table_def(): Convert InnoDB table names to the character set
of the client connection for reporting.  Use my_error(ER_WRONG_COLUMN_NAME)
for reporting reserved column names.  Report my_error(ER_TABLE_EXISTS_ERROR)
when row_create_table_for_mysql() returns DB_DUPLICATE_KEY.

rb://206
r6186 | vasil | 2009-11-17 16:48:14 +0200 (Tue, 17 Nov 2009) | 4 lines
branches/zip:

Add ChangeLog entry for r6185.

r6189 | marko | 2009-11-18 11:36:18 +0200 (Wed, 18 Nov 2009) | 5 lines
branches/zip: ha_innobase::add_index(): When creating the primary key
and the table is being locked by another transaction,
do not attempt to drop the table. (Bug #48782)

Approved by Sunny Bains over IM
r6194 | vasil | 2009-11-19 09:24:45 +0200 (Thu, 19 Nov 2009) | 5 lines
branches/zip:

Increment version number from 1.0.5 to 1.0.6 since 1.0.5 was just released
by MySQL and we will soon release 1.0.6.
2009-11-30 18:43:34 +05:30
Satya B
d813b43048 Applying InnoDB Plugin 1.0.6 snapshot, part 7
Fixes several test cases.

applied revisions: r6181, r6182, r6183, r6184

r6183 - changes are made only to tests in innodb suite which is only 
        innodb-consistent-master.opt

Detailed revision comments:

r6181 | vasil | 2009-11-17 12:21:41 +0200 (Tue, 17 Nov 2009) | 33 lines
branches/zip:

At the end of innodb-index.test: restore the environment as it was before
the test was started to silence this warning:

  MTR's internal check of the test case 'main.innodb-index' failed.
  This means that the test case does not preserve the state that existed
  before the test case was executed.  Most likely the test case did not
  do a proper clean-up.
  This is the diff of the states of the servers before and after the
  test case was executed:
  mysqltest: Logging to '/tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.log'.
  mysqltest: Results saved in '/tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.result'.
  mysqltest: Connecting to server localhost:13000 (socket /tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/mysqld.1.sock) as 'root', connection 'default', attempt 0 ...
  mysqltest: ... Connected.
  mysqltest: Start processing test commands from './include/check-testcase.test' ...
  mysqltest: ... Done processing test commands.
  --- /tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.result	2009-11-17 13:10:40.000000000 +0300
  +++ /tmp/autotest.sh-20091117_033000-zip.btyZwu/mysql-5.1/mysql-test/var/tmp/check-mysqld_1.reject	2009-11-17 13:10:54.000000000 +0300
  @@ -84,7 +84,7 @@
   INNODB_DOUBLEWRITE	ON
   INNODB_FAST_SHUTDOWN	1
   INNODB_FILE_FORMAT	Antelope
  -INNODB_FILE_FORMAT_CHECK	Antelope
  +INNODB_FILE_FORMAT_CHECK	Barracuda
   INNODB_FILE_PER_TABLE	OFF
   INNODB_FLUSH_LOG_AT_TRX_COMMIT	1
   INNODB_FLUSH_METHOD	
  
  mysqltest: Result content mismatch
  
  not ok

r6182 | marko | 2009-11-17 13:49:15 +0200 (Tue, 17 Nov 2009) | 1 line
branches/zip: Set svn:eol-style on mysql-test files.
r6183 | marko | 2009-11-17 13:51:16 +0200 (Tue, 17 Nov 2009) | 1 line
branches/zip: Prepend loose_ to plugin-only mysql-test options.
r6184 | marko | 2009-11-17 13:52:01 +0200 (Tue, 17 Nov 2009) | 1 line
branches/zip: innodb-index.test: Restore innodb_file_format_check.
2009-11-30 18:19:13 +05:30
Satya B
444c6d0d73 Applying InnoDB Plugin 1.0.6 snapshot, part 6. Add Testcase for BUG#46676
1. add testcase for BUG#46676
2. Allow CREATE INDEX to be interrupted
3. ha_innobase::change_active_index(): When the history is
   missing, report it to the client, not to the error log
4. ChangeLog entries

appplied revisions:r6169, r6170, r6175, r6177, r6179

Detailed revision comments:

r6169 | calvin | 2009-11-12 14:40:43 +0200 (Thu, 12 Nov 2009) | 6 lines
branches/zip: add test case for bug#46676

This crash is reproducible with InnoDB plugin 1.0.4 + MySQL 5.1.37.
But no longer reproducible after MySQL 5.1.38 (with plugin 1.0.5).
Add test case to catch future regression.

r6170 | marko | 2009-11-12 15:49:08 +0200 (Thu, 12 Nov 2009) | 4 lines
branches/zip: Allow CREATE INDEX to be interrupted.  (Issue #354)

rb://183 approved by Heikki Tuuri

r6175 | vasil | 2009-11-16 20:07:39 +0200 (Mon, 16 Nov 2009) | 4 lines
branches/zip:

Wrap line at 78th char in the ChangeLog

r6177 | calvin | 2009-11-16 20:20:38 +0200 (Mon, 16 Nov 2009) | 2 lines
branches/zip: add an entry to ChangeLog for r6065

r6179 | marko | 2009-11-17 10:19:34 +0200 (Tue, 17 Nov 2009) | 2 lines
branches/zip: ha_innobase::change_active_index(): When the history is
missing, report it to the client, not to the error log.
2009-11-30 17:54:54 +05:30
Satya B
e50e69409b Applying InnoDB Plugin 1.0.6 snapshot, part 3. Fixes BUG#47167
applied revisions: r6157

Detailed revision comments:

r6157 | jyang | 2009-11-11 14:27:09 +0200 (Wed, 11 Nov 2009) | 10 lines
branches/zip: Fix an issue that a local variable defined
in innodb_file_format_check_validate() is being referenced
across function in innodb_file_format_check_update().
In addition, fix "set global innodb_file_format_check =
DEFAULT" call.
Bug #47167: "set global innodb_file_format_check" cannot
set value by User-Defined Variable."
rb://169 approved by Sunny Bains and Marko.
2009-11-30 17:26:21 +05:30
Satya B
54e01f3ce1 Applying InnoDB Plugin 1.0.6 snapshot, part 2. Fixes BUG#32430
Enable partition_innodb_plugin.test for BUG#32430
applied revisions: r6134, r6137, r6153

Detailed revision comments:

r6134 | marko | 2009-11-04 09:57:29 +0200 (Wed, 04 Nov 2009) | 5 lines
branches/zip: innobase_convert_identifier(): Convert table names with
explain_filename() to address Bug #32430: 'show innodb status'
causes errors Invalid (old?) table or database name in logs.

rb://134 approved by Sunny Bains
r6137 | marko | 2009-11-04 15:24:28 +0200 (Wed, 04 Nov 2009) | 1 line
branches/zip: dict_index_too_big_for_undo(): Correct a typo.
r6153 | vasil | 2009-11-10 15:33:22 +0200 (Tue, 10 Nov 2009) | 145 lines
branches/zip: Merge r6125:6152 from branches/5.1:

(everything except the last white-space change was skipped as it is already
in branches/zip)

  ------------------------------------------------------------------------
  r6127 | vasil | 2009-10-30 11:18:25 +0200 (Fri, 30 Oct 2009) | 18 lines
  Changed paths:
     M /branches/5.1/Makefile.am
     M /branches/5.1/mysql-test/innodb-autoinc.result
     M /branches/5.1/mysql-test/innodb-autoinc.test
  
  branches/5.1:
  
  Backport c6121 from branches/zip:
  
    ------------------------------------------------------------------------
    r6121 | sunny | 2009-10-30 01:42:11 +0200 (Fri, 30 Oct 2009) | 7 lines
    Changed paths:
       M /branches/zip/mysql-test/innodb-autoinc.result
    
    branches/zip: This test has been problematic for sometime now. The underlying
    bug is that the data dictionaries get out of sync. In the AUTOINC code we
    try and apply salve to the symptoms. In the past MySQL made some unrelated
    change and the dictionaries stopped getting out of sync and this test started
    to fail. Now, it seems they have reverted that changed and the test is
    passing again. I suspect this is not he last time that this test will change.
    
    ------------------------------------------------------------------------
  
  ------------------------------------------------------------------------
  r6129 | vasil | 2009-10-30 17:14:22 +0200 (Fri, 30 Oct 2009) | 4 lines
  Changed paths:
     M /branches/5.1/Makefile.am
  
  branches/5.1:
  
  Revert a change to Makefile.am that sneaked unnoticed in c6127.
  
  ------------------------------------------------------------------------
  r6136 | marko | 2009-11-04 12:28:10 +0200 (Wed, 04 Nov 2009) | 15 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/include/ha_prototypes.h
     M /branches/5.1/ut/ut0ut.c
  
  branches/5.1: Port r6134 from branches/zip:
  
    ------------------------------------------------------------------------
    r6134 | marko | 2009-11-04 07:57:29 +0000 (Wed, 04 Nov 2009) | 5 lines
  
    branches/zip: innobase_convert_identifier(): Convert table names with
    explain_filename() to address Bug #32430: 'show innodb status'
    causes errors Invalid (old?) table or database name in logs.
  
    rb://134 approved by Sunny Bains
    ------------------------------------------------------------------------
  
  innobase_print_identifier(): Replace with innobase_convert_name().
  
  innobase_convert_identifier(): New function, called by innobase_convert_name().
  ------------------------------------------------------------------------
  r6149 | vasil | 2009-11-09 11:15:01 +0200 (Mon, 09 Nov 2009) | 5 lines
  Changed paths:
     M /branches/5.1/CMakeLists.txt
  
  branches/5.1:
  
  Followup to r5700: Adjust the changes so they are the same as in the BZR
  repository.
  
  ------------------------------------------------------------------------
  r6150 | vasil | 2009-11-09 11:43:31 +0200 (Mon, 09 Nov 2009) | 58 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
  
  branches/5.1:
  
  Merge a part of r2911.5.5 from MySQL:
  (the other part of this was merged in c5700)
  
    ------------------------------------------------------------
    revno: 2911.5.5
    committer: Vladislav Vaintroub <vvaintroub@mysql.com>
    branch nick: 5.1-innodb_plugin
    timestamp: Wed 2009-06-10 10:59:49 +0200
    message:
      Backport WL#3653 to 5.1 to enable bundled innodb plugin.
      Remove custom DLL loader code from innodb plugin code, use 
      symbols exported from mysqld.
    removed:
      storage/innodb_plugin/handler/handler0vars.h
      storage/innodb_plugin/handler/win_delay_loader.cc
    added:
      storage/mysql_storage_engine.cmake
      win/create_def_file.js
    modified:
      CMakeLists.txt
      include/m_ctype.h
      include/my_global.h
      include/my_sys.h
      include/mysql/plugin.h
      libmysqld/CMakeLists.txt
      mysql-test/mysql-test-run.pl
      mysql-test/t/plugin.test
      mysql-test/t/plugin_load-master.opt
      mysys/charset.c
      sql/CMakeLists.txt
      sql/handler.h
      sql/mysql_priv.h
      sql/mysqld.cc
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_list.h
      sql/sql_profile.h
      storage/Makefile.am
      storage/archive/CMakeLists.txt
      storage/blackhole/CMakeLists.txt
      storage/csv/CMakeLists.txt
      storage/example/CMakeLists.txt
      storage/federated/CMakeLists.txt
      storage/heap/CMakeLists.txt
      storage/innobase/CMakeLists.txt
      storage/innobase/handler/ha_innodb.cc
      storage/innodb_plugin/CMakeLists.txt
      storage/innodb_plugin/handler/ha_innodb.cc
      storage/innodb_plugin/handler/handler0alter.cc
      storage/innodb_plugin/handler/i_s.cc
      storage/innodb_plugin/plug.in
      storage/myisam/CMakeLists.txt
      storage/myisammrg/CMakeLists.txt
      win/Makefile.am
      win/configure.js
  
  ------------------------------------------------------------------------
  r6152 | vasil | 2009-11-10 15:30:20 +0200 (Tue, 10 Nov 2009) | 4 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
  
  branches/5.1:
  
  White space fixup.
  
  ------------------------------------------------------------------------
2009-11-30 17:12:51 +05:30
Magne Mahre
732e5a2634 Bug #20837 Apparent change of isolation level during transaction
SET TRANSACTION ISOLATION LEVEL is used to temporarily set
the trans.iso.level for the next transaction.  After the
transaction, the iso.level is (re-)set to value of the 
session variable 'tx_isolation'.

The bug is caused by setting the thd->variables.tx_isolation 
field to the value of the session variable upon each
statement commit.  It should only be set at the end of the
full transaction.

The fix has been to remove the setting of the variable in
ha_autocommit_or_rollback if we're in a transaction, as it 
will be correctly set in  either ha_rollback or 
ha_commit_one_phase.  

If, on the other hand, we're in  autocommit mode, tx_isolation 
will be explicitly set here.



mysql-test/t/innodb_mysql.test:
  "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED" sets
  the trans.isolation for the next transaction.  We test
  that @@tx_isolation keeps this value during the transaction,
  and is only reset back to the session value at the end
  of the transaction.
2009-11-30 12:30:28 +01:00
Satya B
cefd968ddd Applying Innodb Snapshot 5.1-ss6242, part 9.
1. Enabling the disabled test for BUG#32430 for builtin innodb
2. Disabling the innodb-autoinc.test for innodb plugin.
2009-11-30 16:24:20 +05:30
Satya B
cde05f0645 Applying InnoDB snapshot 5.1-ss6242, part 8. Fixes BUG#47720
1. BUG#47720 - REPLACE INTO Autoincrement column with negative values.

Detailed revision comments:

r6235 | sunny | 2009-11-26 01:14:42 +0200 (Thu, 26 Nov 2009) | 9 lines
branches/5.1: Fix Bug#47720 - REPLACE INTO Autoincrement column with negative values.

This bug is similiar to the negative autoinc filter patch from earlier,
with the additional handling of filtering out the negative column values
set explicitly by the user.

rb://184
Approved by Heikki.
2009-11-30 15:16:45 +05:30
Satya B
4b3114b60d Applying InnoDB snapshot 5.1-ss6242, part 7. Fixes BUG#49032
1. BUG#49032 - auto_increment field does not initialize to last value 
               in InnoDB Storage Engine

2. Fix whitespace issues and fix tests and make read float/double arg const

Detailed revision comments:

r6231 | sunny | 2009-11-25 10:26:27 +0200 (Wed, 25 Nov 2009) | 7 lines
branches/5.1: Fix BUG#49032 - auto_increment field does not initialize to last value in InnoDB Storage Engine.

We use the appropriate function to read the column value for non-integer
autoinc column types, namely float and double.

rb://208. Approved by Marko.

r6232 | sunny | 2009-11-25 10:27:39 +0200 (Wed, 25 Nov 2009) | 2 lines
branches/5.1: This is an interim fix, fix white space errors.

r6233 | sunny | 2009-11-25 10:28:35 +0200 (Wed, 25 Nov 2009) | 2 lines
branches/5.1: This is an interim fix, fix tests and make read float/double arg const.


r6234 | sunny | 2009-11-25 10:29:03 +0200 (Wed, 25 Nov 2009) | 2 lines
branches/5.1: This is an interim fix, fix whitepsace issues.
2009-11-30 15:11:38 +05:30
Satya B
2faa75ed26 Applying InnoDB snapshot 5.1-ss6242, part 6. Fixes BUG#48482
1. BUG#48482 - innodb-autoinc.test fails with results difference

2. enable the disabled test

Detailed revision comments:

r6230 | sunny | 2009-11-24 23:52:43 +0200 (Tue, 24 Nov 2009) | 3 lines
branches/5.1: Fix autoinc failing test results.
(this should be skipped when merging 5.1 into zip)
2009-11-30 14:38:41 +05:30
Satya B
181a29f20a Additional Fix for BUG#47671 - wrong character-set after upgrade from 5.1.34 to 5.1.39
Fix for failure on windows PB2 because of the result content mismatch.
In windows additional information about TCP port was causing failures.
Added to regex.
2009-11-30 10:54:26 +05:30
unknown
b9f9fe2e1a Bug #43913 rpl_cross_version can't pass on conflicts complainig clash with --slave-load-tm
The 'slave_patternload_file' is assigned to the real path of the load data file 
when initializing the object of Relay_log_info. But the path of the load data
file is not formatted to real path when executing event from relay log. So the 
error will be encountered if the path of the load data file is a symbolic link.

Actually the global 'opt_secure_file_priv' is not formatted to real path when 
loading data from file. So the same thing will happen too.

      
To fix these errors, the path of the load data file should be formatted to 
real path when executing event from relay log. And the 'opt_secure_file_priv' 
should be formatted to real path when loading data infile.


mysql-test/suite/rpl/r/rpl_loaddata_symlink.result:
  Test result for bug#43913.
mysql-test/suite/rpl/t/rpl_loaddata_symlink-master.sh:
  Added the test file to create a link from $MYSQLTEST_VARDIR/std_data 
  to $MYSQLTEST_VARDIR/std_data_master_link
mysql-test/suite/rpl/t/rpl_loaddata_symlink-slave.sh:
  Added the test file to create a link from $MYSQLTEST_VARDIR/std_data 
  to $MYSQLTEST_VARDIR/std_data_slave_link
mysql-test/suite/rpl/t/rpl_loaddata_symlink.test:
  Added the test file to verify if loading data infile will work fine 
  if the path of the load data file is a symbolic link.
sql/rpl_rli.cc:
  Added call 'my_realpath' function for avoiding sometimes the 'fn_format' 
  function can't format real path rightly.
2009-11-28 12:43:16 +08:00
Georgi Kodinov
c256e3ab29 merge 2009-11-27 18:10:28 +02:00
Georgi Kodinov
b7ed14638f Addendum to bug #48872: disable output in the test case because errors are
dependent on the case mode
2009-11-27 18:07:31 +02:00
Alfranio Correia
8cda87e433 merge mysql-5.1-bugteam (local) --> mysql-5.1-bugteam 2009-11-27 15:01:16 +00:00
Georgi Kodinov
14b9f46db4 merge 2009-11-27 16:41:45 +02:00
Georgi Kodinov
d877f0a045 added the missing remove of the temp file 2009-11-27 16:36:22 +02:00
Georgi Kodinov
f7887695d6 merge 2009-11-27 16:20:02 +02:00
Georgi Kodinov
9f7fc19a0c merge 2009-11-27 16:17:24 +02:00
Sergey Vojtovich
88893ddfe5 Fixes for bug47671.test:
- embedded server doesn't support external clients
- removed unnecessary command line options
2009-11-27 17:55:08 +04:00
Georgi Kodinov
514d33c866 Addendum to Bug #27884: fixed test incompatibility on windows. 2009-11-27 15:46:54 +02:00
Alfranio Correia
95e420c636 BUG#48506 crash in CREATE TABLE IF NOT EXISTS <existing_view> LIKE
<tmp_tbl> with RBL

When binlogging the statement, the server always handle the existing
object as a table, even though it is a view. However a view is
handled differently in other parts of the code thus leading the
statement to crash in RBL if the view exists.

This happens because the underlying tables for the view are not opened
when we try to call store_create_info() on the view in order to build
a CREATE TABLE statement.

This patch will only address the crash problem, other binlogging
problems related to CREATE TABLE IF NOT EXISTS LIKE when the existing
object is a view will be solved by BUG 47442.
2009-11-27 13:34:39 +00:00
Georgi Kodinov
c431088d03 merge 2009-11-27 12:32:15 +02:00
Georgi Kodinov
2ac344ecf6 Bug #48872 : Privileges for stored functions ignored if function name
is mixed case

Transcode the procedure name to lowercase when searching for it in the 
hash. This is the missing part of the fix for bug #41049.
2009-11-27 11:59:44 +02:00
Martin Hansson
4afa24086f Merge of fix for Bug#48459 2009-11-26 10:41:40 +01:00
Satya B
fab8effefe merge to mysql-5.1-bugteam 2009-11-26 13:12:16 +05:30
Davi Arnaut
8022ff5cf5 Automerge. 2009-11-25 11:09:12 -02:00
Martin Hansson
14f2eb1244 Bug#48459: valgrind errors with query using 'Range checked
for each record'

There was an error in an internal structure in the range
optimizer (SEL_ARG). Bad design causes parts of a data
structure not to be initialized when it is in a certain
state. All client code must check that this state is not
present before trying to access the structure's data. Fixed
by

- Checking the state before trying to access data (in
several places, most of which not covered by test case.)

- Copying the keypart id when cloning SEL_ARGs


mysql-test/r/range.result:
  Bug#48459: Test result.
mysql-test/t/range.test:
  Bug#48459: Test case.
sql/opt_range.cc:
  Bug#48459: Fix + doxygenated count_key_part_usage comment.
2009-11-25 11:02:25 +01:00
Satya B
97d74332c2 Applying InnoDB snapshot 5.0-ss6230, part 2. Fixes BUG#46000
BUG#46000 - using index called GEN_CLUST_INDEX crashes server

Detailed revision comments:

r6180 | jyang | 2009-11-17 10:54:57 +0200 (Tue, 17 Nov 2009) | 7 lines
branches/5.0: Merge/Port fix for bug #46000 from branches/5.1
-r5895 to branches/5.0. Disallow creating index with the
name of "GEN_CLUST_INDEX" which is reserved for the default
system primary index. Minor adjusts on table name screening
format for added tests.
2009-11-25 15:29:25 +05:30
Satya B
2bf2e8f9dd Applying InnoDB snapshot 5.0-ss6230, Part 1. Fixes BUG#47777
BUG#47777 - innodb dies with spatial pk: Failing assertion: buf <= original_buf + buf_len

Detailed revision comments:

r6178 | jyang | 2009-11-17 08:52:11 +0200 (Tue, 17 Nov 2009) | 6 lines
branches/5.0: Merge fix for bug #47777 from branches/5.1 -r6045
to bracnches/5.0. Treat the Geometry data same as Binary BLOB
in ha_innobase::store_key_val_for_row(), since the Geometry
data is stored as Binary BLOB in Innodb.
2009-11-25 15:08:52 +05:30
Satya B
82b115ec16 Fix for BUG#47671 - wrong character-set after upgrade from 5.1.34 to 5.1.39
mysql client displays wrong character-set of server. When a user changes the
charset of a server, mysql client 'status' command displays wrong charset but
the command "SHOW VARIABLES LIKE "%charset%" displayed correct charset results.
The problem is only with the mysql client's 'status' command output.

In mysql client, the method mysql_store_lazy_result() returns 0 for
success and non-zero for failure. The method com_status() was using this method
wrongly. Fixed all such instances according to return value of the method 
mysql_store_lazy_result().

client/mysql.cc:
  Fix for BUG#47671 - wrong character-set after upgrade from 5.1.34 to 5.1.39
  
  Fix com_status() method to use mysql_store_lazy_result() properly.
mysql-test/r/bug47671.result:
  Fix for BUG#47671 - wrong character-set after upgrade from 5.1.34 to 5.1.39
  
  Testcase for BUG#47671
mysql-test/t/bug47671-master.opt:
  Fix for BUG#47671 - wrong character-set after upgrade from 5.1.34 to 5.1.39
  
  Testcase for BUG#47671
mysql-test/t/bug47671.test:
  Fix for BUG#47671 - wrong character-set after upgrade from 5.1.34 to 5.1.39
  
  Testcase for BUG#47671
2009-11-25 12:25:49 +05:30
Tatiana A. Nurnberg
9ae245009c auto-merge 2009-11-24 10:22:22 -08:00
Evgeny Potemkin
8af680218e Auto-merge. 2009-11-24 18:30:21 +03:00
Evgeny Potemkin
9f638f535e Manual merge of the fix for bug#43668. 2009-11-24 18:26:13 +03:00
Jim Winstead
84c5abbd33 Backport fix for Bug #27884. 2009-11-23 14:38:08 -08:00
Alexey Kopytov
908323304e Automerge. 2009-11-23 13:07:18 +03:00
Alexey Kopytov
6780169613 Automerge. 2009-11-23 13:05:35 +03:00
Alexey Kopytov
38ed9324be Automerge. 2009-11-23 13:04:17 +03:00
unknown
a2ed682967 Bug #48350 truncate temporary table crashes replication
In RBR, All statements operating on temporary tables should not be binlogged.
Despite this fact, after executing 'TRUNCATE... ' on a temporary table, 
the command is still logged, even if in row-based mode. Consequently, this raises
problems in the slave as the table may not exist, resulting in an
execution failure. Ultimately, this causes the slave to report
an error and abort.

After this patch, 'TRUNCATE ...' statement on a temporary table will not be
binlogged in RBR.
2009-11-22 13:10:33 +08:00
Alfranio Correia
897d87f63a merge 5.1-bugteam (local) --> 5.1-bugteam 2009-11-21 13:02:18 +00:00
Davi Arnaut
c70a9fa1e3 Bug#41726: upgrade from 5.0 to 5.1.30 crashes if you didn't run mysql_upgrade
The problem is that the server could crash when attempting
to access a non-conformant proc system table. One such case
was a crash when invoking stored procedure related statements
on a 5.1 server with a proc system table in the 5.0 format.

The solution is to validate the proc system table format
before attempts to access it are made. If the table is not
in the format that the server expects, a message is written
to the error log and the statement that caused the table to
be accessed fails.

mysql-test/r/sp-destruct.result:
  Add test case result for Bug#41726
mysql-test/t/sp-destruct.test:
  Add test case for Bug#41726
sql/event_db_repository.cc:
  Update code to use new structures.
sql/sp.cc:
  Describe the proc table format and use it to validate when
  opening a instance of the table.
  Add a check to insure that a error message is written to
  the error log only once.
sql/sql_acl.cc:
  Remove unused variable and use new structure.
sql/sql_acl.h:
  Export field definition.
sql/table.cc:
  Accept the field count and definition in a single structure.
sql/table.h:
  Combine the field count and definition in a single structure.
  Transform function into a class in order to support different
  ways of reporting a error.
  Add a pointer cache to TABLE_SHARE.
2009-11-21 09:18:21 -02:00
Georgi Kodinov
a21cd97c35 Bug #45261 : Crash, stored procedure + decimal
Bug #48370  Absolutely wrong calculations with GROUP BY and
  decimal fields when using IF

Added the test cases in the above two bugs for regression
testing.
Added additional tests that demonstrate a incomplete fix.
Added a new factory method for Field_new_decimal to 
create a field from an (decimal returning) Item.
In the new method made sure that all the precision and 
length variables are capped in a proper way. 
This is required because Item's can have larger precision
than the decimal fields and thus need to be capped when
creating a field based on an Item type.
Fixed the wrong typecast to Item_decimal.
2009-11-20 12:10:47 +02:00
Georgi Kodinov
405c9310cf Bug #48665: sql-bench's insert test fails due to wrong result
When merging ranges during calculation of the result of OR
to two range sets the current range may be obsoleted by the 
resulting merged range.
The first overlapping range can be obsoleted as well.

Fixed by moving the pointer to the first overlapping range to the
pointer of the resulting union range.
Added few comments at key places in key_or().
2009-11-19 18:26:19 +02:00
Sven Sandberg
2f78abd21b BUG#47995: Mark system functions as unsafe
Problem: Some system functions that could return different values on
master and slave were not marked unsafe. In particular:
 GET_LOCK
 IS_FREE_LOCK
 IS_USED_LOCK
 MASTER_POS_WAIT
 RELEASE_LOCK
 SLEEP
 SYSDATE
 VERSION
Fix: Mark these functions unsafe.


mysql-test/extra/rpl_tests/rpl_stm_000001.test:
  - The test does not work in mixed mode any more, since it tries to
    simulate an error in the sql thread in a query that uses get_lock.
    Since get_lock now causes the query to be logged in row format,
    the error didn't happen. Hence, we now force statement mode.
  - Warnings must be disabled when the unsafe query is issued.
  - Replaced some save_master_pos+connection slave+sync_with_master
    by sync_slave_with_master.
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
  updated result file
mysql-test/suite/binlog/r/binlog_stm_row.result:
  updated result file
mysql-test/suite/binlog/r/binlog_unsafe.result:
  updated result file
mysql-test/suite/binlog/t/binlog_killed.test:
  binlog_killed only works in statement format now, since
  it switches to row mode in mixed mode.
mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam.test:
  suppress warnings for unsafe statements
mysql-test/suite/binlog/t/binlog_stm_row.test:
  - Suppress warnings in test that causes warnings.
  - The test sets binlog format explicitly, so no need to execute it
    twice.
mysql-test/suite/binlog/t/binlog_unsafe.test:
  Added test for all unsafe system functions. This test also includes
  system functions that were unsafe prior to BUG#47995.
mysql-test/suite/rpl/r/rpl_err_ignoredtable.result:
  updated result file
mysql-test/suite/rpl/r/rpl_get_lock.result:
  updated result file
mysql-test/suite/rpl/r/rpl_nondeterministic_functions.result:
  new result file
mysql-test/suite/rpl/r/rpl_stm_000001.result:
  updated result file
mysql-test/suite/rpl/r/rpl_trigger.result:
  updated result file
mysql-test/suite/rpl/t/rpl_err_ignoredtable.test:
  - suppress warnings for unsafe statement
  - replaced save_master_pos+connection slave+sync_with_master
    with sync_slave_with_master
mysql-test/suite/rpl/t/rpl_get_lock.test:
  update test case that causes new warnings
mysql-test/suite/rpl/t/rpl_nondeterministic_functions.test:
  Added new test case for nondeterministic functions.
mysql-test/suite/rpl/t/rpl_trigger.test:
  update test case that causes new warnings
sql/item_create.cc:
  Marked some system functions unsafe.
sql/item_strfunc.cc:
  Clarified comment related to this bug.
sql/sql_yacc.yy:
  Marked sysdate unsafe.
2009-11-18 15:50:31 +01:00
Jon Olav Hauglid
7524b96102 Postfix for Bug #47682 strange behaviour of INSERT DELAYED
Fixed a problem with the test case when executed with ps-protocol.
There the conflicing lock would be noticed during prepare, not
during execution of the insert - leading to a different (but 
equally appropriate) error message.
2009-11-18 13:49:45 +01:00
Mattias Jonsson
f6ec131ff9 merge 2009-11-18 11:21:26 +01:00
Magne Mahre
58f4345957 merge 2009-11-18 10:45:32 +01:00
Magne Mahre
3987c7ac4b Bug #46425 crash in Diagnostics_area::set_ok_status , empty statement,
DELETE IGNORE

The ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG error was set in the
diagnostics area when it happened, but the DELETE cleanup code
never checked for a non-fatal error condition, thus trying to
set diag.area to "ok".  This triggered an assert checking that
the diag.area was empty.

The fix was to test if there existed a non-fatal error condition
(thd->is_error() before ok'ing the operation.
2009-11-18 10:32:03 +01:00
Jon Olav Hauglid
41ba429286 Bug #47682 strange behaviour of INSERT DELAYED
The problem was a "self-deadlock" if the connection issuing INSERT DELAYED
had both the global read lock (FLUSH TABLES WITH READ LOCK) and LOCK TABLES
mode active. The table being inserted into had to be different from the 
table(s) locked by LOCK TABLES.

For INSERT DELAYED, the connection thread waits until the handler thread has
opened and locked its table before returning. But since the global read lock
was active, the handler thread would be unable to lock and would wait for the
global read lock to go away.

So the handler thread would be waiting for the connection thread to release
the global read lock while the connection thread was waiting for the handler
thread to lock the table. This gave a "self-deadlock" (same connection,
different threads).

The deadlock would only happen if we also had LOCK TABLES mode since the
INSERT otherwise will try to get protection against global read lock before
starting the handler thread. It will then notice that the global read lock
is owned by the same connection and report ER_CANT_UPDATE_WITH_READLOCK.

This patch removes the deadlock by reporting ER_CANT_UPDATE_WITH_READLOCK
also if we are inside LOCK TABLES mode.

Test case added to delayed.test.
2009-11-18 10:02:21 +01:00
Mattias Jonsson
3faaf33333 merge 2009-11-17 22:51:49 +01:00
Mattias Jonsson
7a6ab645ab merge 2009-11-17 22:48:28 +01:00
Mattias Jonsson
98fd304278 backport of bug#45904 from mysql-pe to 5.1
sql/sql_partition.cc:
  Bug#45904 Used list_of_part_fields instead of list_of_subpart_fields to discover if KEY subpartitioning => caused failure when charset=utf8 even for subpartitioning by key, would also allow for subpartitioning by hash with utf8 erroneously
2009-11-17 22:47:34 +01:00
Mattias Jonsson
e6d02a127e merge 2009-11-17 16:24:46 +01:00
Alexey Kopytov
8cfa50e677 Bug #48472: Loose index scan inappropriately chosen for some
WHERE conditions 
 
check_group_min_max() checks if the loose index scan 
optimization is applicable for a given WHERE condition, that is 
if the MIN/MAX attribute participates only in range predicates 
comparing the corresponding field with constants. 
 
The problem was that it considered the whole predicate suitable 
for the loose index scan optimization as soon as it encountered 
a constant as a predicate argument. This is obviously wrong for 
cases when a constant is the first argument of a predicate 
which does not satisfy the above condition. 
 
Fixed check_group_min_max() so that all arguments of the input 
predicate are considered to decide if it passes the test, even 
though a constant has already been encountered.

mysql-test/r/group_min_max.result:
  Added a test case for bug #48472.
mysql-test/t/group_min_max.test:
  Added a test case for bug #48472.
sql/opt_range.cc:
  Fixed check_group_min_max() so that all arguments of the input 
  predicate are considered to decide if it passes the test, even 
  though a constant has already been encountered.
2009-11-17 17:07:14 +03:00
Evgeny Potemkin
bc43bff7ed Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
MySQL manual describes values of the YEAR(2) field type as follows:
values 00 - 69 mean 2000 - 2069 years and values 70 - 99 mean 1970 - 1999
years. MIN/MAX and comparison functions was comparing them as int values
thus producing wrong result.

Now the Arg_comparator class is extended with compare_year function which
performs correct comparison of the YEAR type.
The Item_sum_hybrid class now uses Item_cache and Arg_comparator objects to
correctly calculate its value.
To allow Arg_comparator to use func_name() function for Item_func and Item_sum
objects the func_name declaration is moved to the Item_result_field class.
A helper function is_owner_equal_func is added to the Arg_comparator class.
It checks whether the Arg_comparator object owner is the <=> function or not.
A helper function setup is added to the Item_sum_hybrid class. It sets up
cache item and comparator.

mysql-test/r/func_group.result:
  Added a test case for the bug#43668.
mysql-test/t/func_group.test:
  Added a test case for the bug#43668.
sql/item.cc:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  Now Item_cache_int returns the type of cached item.
sql/item.h:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  To allow Arg_comparator to use func_name() function for Item_func and Item_sum
  objects the func_name declaration is moved to the Item_result_field class.
sql/item_cmpfunc.cc:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  The Arg_comparator class is extended with compare_year function which
  performs correct comparison of the YEAR type.
sql/item_cmpfunc.h:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  The year_as_datetime variable is added to the Arg_comparator class.
  It's set to TRUE when YEAR value should be converted to the
  YYYY-00-00 00:00:00 format for correct YEAR-DATETIME comparison.
sql/item_geofunc.cc:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  Item_func_spatial_rel::val_int chenged to use Arg_comparator's string
  buffers.
sql/item_subselect.h:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  Added an implementation of the virtual func_name function.
sql/item_sum.cc:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  The Item_sum_hybrid class now uses Item_cache and Arg_comparator objects to
  correctly calculate its value.
  A helper function setup is added to the Item_sum_hybrid class. It sets up
  cache item and comparator.
sql/item_sum.h:
  Bug#43668: Wrong comparison and MIN/MAX for YEAR(2)
  The Item_sum_hybrid class now uses Item_cache and Arg_comparator objects to
  correctly calculate its value.
  Added an implementation of the virtual func_name function.
2009-11-17 17:06:46 +03:00
Jorgen Loland
a120e969a8 Bug#48052: Valgrind warning - uninitialized value in
init_read_record() - (records.cc:274)
      
Item_cond::used_tables_cache was accessed in
records.cc#init_read_record() without being initialized. It had
not been initialized because it was wrongly assumed that the
Item's variables would not be accessed, and hence
quick_fix_field() was used instead of fix_fields() to save a few
CPU cycles at creation time.

The fix is to properly initilize the Item by replacing
quick_fix_field() with fix_fields().


mysql-test/r/select.result:
  Add test for BUG#48052
mysql-test/t/select.test:
  Add test for BUG#48052
sql/sql_select.cc:
  Properly initialize Item_cond_and by calling fix_fields (instead of quick_fix_field) when the Item that "ANDs" WHERE clause conditions with HAVING clause conditions is created.
2009-11-13 12:22:39 +01:00
Luis Soares
9c23a442b2 BUG#48738: Backport patch for Bug 34582 to 5.0 codebase.
From BUG 34582 commit message:

Issuing 'FLUSH LOGS' does not close and reopen indexfile.
Instead a SEEK_SET is performed.
            
This patch makes index file to be closed and reopened whenever a
rotation happens (FLUSH LOGS is issued or binary log exceeds 
maximum configured size).
2009-11-13 10:30:56 +00:00
Davi Arnaut
356b3df743 Bug#47627 SET @@{global.session}.local_variable in stored routine causes crash
This patch borrows ideas, text and code from Kristofer
Pettersson's patch.

An assignment of a system variable sharing the same base
name as a declared stored procedure variable in the same
context could lead to a crash.

The reason was that during the parsing of the syntactic
rule 'option_value' an uninitialized set_var object was
pushed to the parameter stack of the SET statement. The
parent rule 'option_type_value' interpreted the existence
of variables on the parameter stack as an assignment and
wrapped it in a sp_instr_set object.

As the procedure later was executed an attempt was made
to run the method 'check()' on an uninitialized member
object (NULL value) belonging to the previously created
but uninitialized object.

This patch refactors the 'internal_variable_name' rule and
copies the semantic analysis part to the depending parent
rule: 'option_value'. This makes it possible to account
for any prefixes affecting the interpretation of the
internal_variable_name.

mysql-test/r/sp.result:
  Add test case result.
mysql-test/t/sp.test:
  Add test case for bug.
sql/sql_yacc.yy:
  - Reduce churn in rule sys_option_value by moving to
    specialized functions.
  - Comment the the lookup in the rule internel_variable_name
    is a best effort operation.
  - Lookup for a system variable in the option_value if one was
    not found (the variable could have been shadowed)
2009-11-12 23:03:26 -02:00
Andrei Elkin
f1abd015dc Bug #47210 first execution of "start slave until" stops too early
Until-pos guarding did not distiguish the master originated events from ones that the slave 
can introduce to the relay log e.g Rotate to the next relay log at slave restarting.
The local Rotate's coordinate are incomparable with the Until-master-pos.
That led to the unexpectable stop this bug describes.

Fixed with to avoid Until-master-pos comparison for a local slave's event.
Notice that if --replicate-same-server is true such event is treated as coming from
the master side.


mysql-test/r/rpl_until.result:
  results changed.
mysql-test/t/rpl_until.test:
  regression test for bug#47210 is added.
sql/slave.cc:
  st_relay_log_info::is_until_satisfied() is augmented with avoidance of 
  Until-master-pos comparison for a local slave's event.
  if --replicate-same-server is true such event is treated as coming from
  the master side.
sql/slave.h:
  signature of is_until_satisfied() changed to supply THD and Event to the routine.
2009-11-12 17:10:19 +02:00
Magne Mahre
552965eff9 Bug #37183 insert ignore into .. select ... hangs after
deadlock was encountered

The bug is caused by an inconsistent handling of the IGNORE
clause.  A read from a const table caused a lock timeout
(ER_LOCK_TIMEOUT) in innodb.  Since the IGNORE clause was
given, the timeout was converted into a warning instead of
an error, thus not populating the diagnostics area.  When
innodb subsequently marked the transaction for rollback,
mysql asserted since the diag.area was empty.

This patch consists of only a test case, as the bug itself
was fixed by the patch for Bug #46539
2009-11-12 12:43:33 +01:00
Anurag Shekhar
c87375150b Bug #47012 archive tables are not upgradeable, and server crashes
on any access

Archive engine for 5.1 (and latter) version uses a modified 
version of zlib (azlib). These two version are incompatible
so a proper upgrade is needed before tables created in 5.0 
can be used reliable.

This upgrade can be performed using repair. But due to lack 
of test its risky to allow upgrade for now. This patch addresses
only the crashing issue. Any attempt to repair will be blocked.

Eventually repair can be allowed to run through (which will also
cause an upgrade from older version to newer) but only after a 
thorough testing.

mysql-test/r/archive.result:
  Updated result file for test case for bug#47012
mysql-test/std_data/bug47012.ARM:
  part of archive table (t1) created in mysql 5.0
mysql-test/std_data/bug47012.ARZ:
  part of archive table (t1) created in mysql 5.0
mysql-test/std_data/bug47012.frm:
  part of archive table (t1) created in mysql 5.0
mysql-test/t/archive.test:
  Added test case for bug#47012.
storage/archive/azio.c:
  Fixed a minor issues (minor version overwriting version in 
  stream structure)
  Removed assertion when an older version is found. Instead
  setting the correct version (2) in s->version
  If an unknown version is found marked it as corrupt.
storage/archive/ha_archive.cc:
  Detecting the archive version in getShare and marking
  it as need to upgrade.
  Blocking open if the archive needs an upgrade. This
  can be allowed in case of open for repair to upgrade
  the archive but needs to tested.
2009-11-11 13:33:29 +05:30
Georgi Kodinov
4519d5e4f1 Bug #48458: simple query tries to allocate enormous amount of
memory

The server was doing a bad class typecast causing setting of 
wrong value for the maximum number of items in an internal
structure used in equality propagation.
Fixed by not doing the wrong typecast and asserting the type
of the Item where it should be done.
2009-11-09 16:09:46 +02:00
Georgi Kodinov
ddd90017e7 Bug #42760: Select doesn't return desired results when we have null
values
 
 We should re-set the access method functions when changing the access
 method when switching to another index to avoid sorting.
 
 Fixed by doing a little re-engineering : encapsulating all the function
 assignment into a special function and calling it when flipping the 
 indexes.
2009-11-10 10:21:41 +02:00
Mattias Jonsson
785b5c4e7a Bug#48276: can't add column if subpartition exists
Bug when setting up default partitioning,
used an uninitialized variabe.

mysql-test/r/partition.result:
  Bug#48276: can't add column if subpartition exists
  
  Added result
mysql-test/t/partition.test:
  Bug#48276: can't add column if subpartition exists
  
  Added test
sql/sql_partition.cc:
  Bug#48276: can't add column if subpartition exists
  
  even if is_create_table_ind was set, one tried to set no_subparts
  with the unitialized no_parts local variable.
  
  Fixed by rearrange the code to be to only execute
  the statements when is_create_table_ind was not set.
2009-11-09 11:26:01 +01:00
Luis Soares
25b7b377f2 auto-merge bzr bundle from bug report into latest mysql-5.1-bugteam. 2009-11-06 17:08:06 +00:00
Alexey Kopytov
ee049964df Automerge. 2009-11-06 17:56:58 +03:00
Alexey Kopytov
05c4f3f396 Automerge. 2009-11-06 17:54:19 +03:00
Alexey Kopytov
39f9a3ffd0 Bug #48475: DISTINCT is ignored with GROUP BY WITH ROLLUP and
only const tables

The problem was caused by two shortcuts in the optimizer that
are inapplicable in the ROLLUP case.

Normally in a case when only const tables are involved in a
query, DISTINCT clause can be safely optimized away since there
may be only one row produced by the join. Similarly, we don't
need to create a temporary table to resolve DISTINCT/GROUP
BY/ORDER BY. Both of these are inapplicable when the WITH
ROLLUP modifier is present.

Fixed by disabling the said optimizations for the WITH ROLLUP
case.

mysql-test/r/olap.result:
  Added a test case for bug #48475.
mysql-test/t/olap.test:
  Added a test case for bug #48475.
sql/sql_select.cc:
  Disabled const-only table optimizations for the WITH ROLLUP
  case.
2009-11-06 09:44:01 +03:00
Georgi Kodinov
43d7fb43cd Bug #46175: NULL read_view and consistent read assertion
The SE API requires mysql to notify the storage engine that
it's going to read certain tables at the beginning of the 
statement (by calling start_stmt(), store_lock() or
external_lock()).
These are typically called by the lock_tables(). 
However SHOW CREATE TABLE is not pre-locking the tables
because it's not expected to access the data at all.
But for some view definitions (that include comparing a
date/datetime/timestamp column to a string returning
scalar subquery) the JOIN::prepare may still access data
when materializing the scalar non-correlated subquery
in Arg_comparator::can_compare_as_dates().
Fixed by not materializing the subquery when the function
is called in a SHOW/EXPLAIN/CREATE VIEW
2009-11-04 13:54:28 +02:00
Georgi Kodinov
3778d52d11 merge 2009-11-04 11:18:34 +02:00
Georgi Kodinov
d66b794ec5 Disabled the rpl_killed_ddl test in 5.0 because of bug #45520 2009-11-04 11:13:22 +02:00
Luis Soares
27028272f3 BUG#47743: rpl.rpl_log_pos fails sporadically
BUG#47983: rpl_extraColmaster_myisam failed in PB2 with "Found
warnings!!"

BUG 45214 fixed the case when get_master_version_and_clock
function, used by the slave, would not report errors. The slave
now detects them and if related to transient network failures, it
prints some warnings and retries to connect. On the other hand,
if not network related, it just gives up and fails.

As such, sometimes, in PB2, the slave comes across some transient
communication issues between master and slave, while calling
get_master_version_and_clock, causing warnings print outs to the
error log. Nevertheless, in such cases slave retries to connect,
in which it succeeds, and the test case continues as it normally
would. But then, at the end of a successful test run, MTR checks
the error log, finds the unexpected warnings and considers them
harmful. This causes MTR to report error and, consequently, PB2
to report a failing test.

We fix this by adding to the global warnings suppress list the
warnings related to transient network failures only, which are
reported while in function get_master_version_and_clock.
2009-11-04 01:56:36 +00:00
Konstantin Osipov
cb0cca8655 A fix and a test case for
Bug#41756 "Strange error messages about locks from InnoDB".
      
In JT_EQ_REF (join_read_key()) access method, 
don't try to unlock rows in the handler, unless certain that 
a) they were locked
b) they are not used.

Unlocking of rows is done by the logic of the nested join loop,
and is unaware of the possible caching that the access method may
have. This could lead to double unlocking, when a row
was unlocked first after reading into the cache, and then 
when taken from cache, as well as to unlocking of rows which
were actually used (but taken from cache).
      
Delegate part of the unlocking logic to the access method,
and in JT_EQ_REF count how many times a record was actually 
used in the join. Unlock it only if it's usage count is 0.

Implemented review comments.

mysql-test/r/innodb_lock_wait_timeout_1.result:
  Update results (Bug41756).
mysql-test/t/innodb_lock_wait_timeout_1.test:
  Add a test case (Bug#41756).
sql/item_subselect.cc:
  Complete struct READ_RECORD initialization with a new
  member to unlock records.
sql/records.cc:
  Extend READ_RECORD API with a method to unlock read records.
sql/sql_select.cc:
  In JT_EQ_REF (join_read_key()) access method, 
  don't try to unlock rows in the handler, unless certain that 
  a) they were locked
  b) they are not used.
sql/sql_select.h:
  Add members to TABLE_REF to count TABLE_REF buffer usage count.
sql/structs.h:
  Update declarations.
2009-11-03 20:45:52 +03:00
Magnus Blåudd
7b7f01499a Merge bug#47867 to 5.1-bugteam 2009-11-03 18:07:19 +01:00
Konstantin Osipov
06c9d62a9f A fix and a test case for
Bug#41756 "Strange error messages about locks from InnoDB".

In JT_EQ_REF (join_read_key()) access method,
don't try to unlock rows in the handler, unless certain that
a) they were locked
b) they are not used.

Unlocking of rows is done by the logic of the nested join loop,
and is unaware of the possible caching that the access method may
have. This could lead to double unlocking, when a row
was unlocked first after reading into the cache, and then
when taken from cache, as well as to unlocking of rows which
were actually used (but taken from cache).

Delegate part of the unlocking logic to the access method,
and in JT_EQ_REF count how many times a record was actually
used in the join. Unlock it only if it's usage count is 0.

Implemented review comments.


mysql-test/r/bug41756.result:
  Add result file (Bug#41756)
mysql-test/t/bug41756-master.opt:
  Use --innodb-locks-unsafe-for-binlog, as in 5.0 just
  using read_committed isolation is not sufficient to 
  reproduce the bug.
mysql-test/t/bug41756.test:
  Add a test file (Bug#41756)
sql/item_subselect.cc:
  Complete struct READ_RECORD initialization with a new
  member to unlock records.
sql/records.cc:
  Extend READ_RECORD API with a method to unlock read records.
sql/sql_select.cc:
  In JT_EQ_REF (join_read_key()) access method,
  don't try to unlock rows in the handler, unless certain that
  a) they were locked
  b) they are not used.
sql/sql_select.h:
  Add members to TABLE_REF to count TABLE_REF buffer usage count.
sql/structs.h:
  Update declarations.
2009-11-03 19:58:54 +03:00
Kristofer Pettersson
cafe3c7fca automerge 2009-11-03 17:23:05 +01:00
Kristofer Pettersson
cea642e32b Moved test case for bug 31157 from query_cache.test to subselect.test 2009-11-03 17:18:43 +01:00
Sergey Vojtovich
0212e73613 Merge of innodb-zip-ss6129 snapshot. 2009-11-03 18:44:39 +04:00
Sergey Vojtovich
7c4cae75b8 Clean-up after applying innodb-zip-ss6129 snapshot:
- re-enabled main.innodb_bug44369;
- re-enabled main.innodb_bug47777;
- re-enabled innodb.innodb_information_schema.
2009-11-03 18:41:04 +04:00
Jorgen Loland
bec35067d3 Bug#48177 - SELECTs with NOT IN subqueries containing NULL
values return too many records

WHERE clauses with "outer_value_list NOT IN subselect" were
handled incorrectly if the outer value list contained multiple 
items where at least one of these could be NULL. The first 
outer record with NULL value was handled correctly, but if a 
second record with NULL value existed, the optimizer would 
choose to reuse the result it got on the last execution of the 
subselect. This is incorrect if the outer value list has 
multiple items.
     
The fix is to make Item_in_optimizer::val_int (in 
item_cmpfunc.cc) reuse the result of the latest execution
for NULL values only if all values in the outer_value_list 
are NULL.


mysql-test/r/subselect3.result:
  Added test for BUG#48177
mysql-test/t/subselect3.test:
  Added test for BUG#48177
sql/item_cmpfunc.cc:
  Make Item_in_optimizer::val_int (in item_cmpfunc.cc) reuse the result of the latest execution for NULL values only if all values in the outer_value_list are NULL.
2009-11-03 13:48:59 +01:00
Sergey Vojtovich
e4a0641f13 Applying InnoDB plugin snashot
Detailed revision comments:

r6101 | jyang | 2009-10-23 11:45:50 +0300 (Fri, 23 Oct 2009) | 7 lines
branches/zip: Update test result with the WARN_LEVEL_ERROR
to WARN_LEVEL_WARN change. This is the same result as 
submitted in rb://172 review, which approved by Sunny Bains
and Marko.
2009-11-03 14:21:39 +04:00
Sergey Vojtovich
7d263d1072 Applying InnoDB plugin snashot
Detailed revision comments:

r6100 | jyang | 2009-10-22 06:51:07 +0300 (Thu, 22 Oct 2009) | 6 lines
branches/zip: As a request from mysql, WARN_LEVEL_ERROR cannot
be used for push_warning_* call any more. Switch to 
WARN_LEVEL_WARN. Bug #47233.
rb://172 approved by Sunny Bains and Marko.
2009-11-03 14:20:18 +04:00
unknown
9519c8e597 Manual Merge 2009-11-03 18:20:08 +08:00
Sergey Vojtovich
ad75bfc829 Applying InnoDB plugin snashot
Detailed revision comments:

r6095 | vasil | 2009-10-19 16:04:59 +0300 (Mon, 19 Oct 2009) | 7 lines
branches/zip:

Fix Bug#47808 innodb_information_schema.test fails when run under valgrind 

by using the wait_until_rows_count macro that loops until the number of
rows becomes 14 instead of sleep 0.1, which is obviously very fragile.
2009-11-03 14:04:18 +04:00
unknown
9819885177 BUG#48216 Replication fails on all slaves after upgrade to 5.0.86 on master
When a sessione is closed, all temporary tables of the session are automatically 
dropped and are binlogged. But it will be binlogged with wrong database names when
the length of the temporary tables' database names are greater than the 
length of the current database name or the current database is not set.

Query_log_event's db_len is forgot to set when Query_log_event's db is set.
This patch wrote code to set db_len immediately after db has set.
2009-11-03 17:00:41 +08:00
Sergey Vojtovich
b703edd747 Clean-ups after applying InnoDB snapshot 5.1-ss6129:
- disabled main.innodb_bug47777.test with InnoDB plugin
  until fix for plugin is applied.
- disabled main.innodb-autoinc.test (failing)
- re-enabled main.innodb_bug39438.test
- added error message suppression to innodb_bug39438, as
  requested by InnoDB/Oracle
- reverted change to main.innodb_bug34300 as plugin specific.
2009-11-03 12:46:04 +04:00
Mattias Jonsson
b35feb1ed0 Bug#46923: select count(*) from partitioned table fails with
ONLY_FULL_GROUP_BY

Problem was that during checking and preparation of the
partitioining function as a side effect in fix_fields
the full_group_by_flag was changed.

Solution was to set it back to its original value after
calling fix_fields.

Updated patch, to also exclude allow_sum_func from being
affected of fix_fields, as requested by reviewer.

mysql-test/r/partition.result:
  Bug#46923: select count(*) from partitioned table fails with
  ONLY_FULL_GROUP_BY
  
  Updated result file
mysql-test/t/partition.test:
  Bug#46923: select count(*) from partitioned table fails with
  ONLY_FULL_GROUP_BY
  
  Extended test case to cover this bug
sql/sql_partition.cc:
  Bug#46923: select count(*) from partitioned table fails with
  ONLY_FULL_GROUP_BY
  
  Resetting full_group_by_flag and allow_sum_func
  back to their original values,
  not conflicting with the sql_mode 'ONLY_FULL_GROUP_BY'
2009-11-03 09:22:01 +01:00
Sergey Vojtovich
66fc82247d Applying InnoDB snashot 5.1-ss6129
Detailed revision comments:

r6127 | vasil | 2009-10-30 11:18:25 +0200 (Fri, 30 Oct 2009) | 18 lines
branches/5.1:

Backport c6121 from branches/zip:

  ------------------------------------------------------------------------
  r6121 | sunny | 2009-10-30 01:42:11 +0200 (Fri, 30 Oct 2009) | 7 lines
  Changed paths:
     M /branches/zip/mysql-test/innodb-autoinc.result
  
  branches/zip: This test has been problematic for sometime now. The underlying
  bug is that the data dictionaries get out of sync. In the AUTOINC code we
  try and apply salve to the symptoms. In the past MySQL made some unrelated
  change and the dictionaries stopped getting out of sync and this test started
  to fail. Now, it seems they have reverted that changed and the test is
  passing again. I suspect this is not he last time that this test will change.
  
  ------------------------------------------------------------------------
2009-11-02 19:06:58 +04:00
Sergey Vojtovich
c29b740bec Applying InnoDB snashot 5.1-ss6129
Detailed revision comments:

r6122 | jyang | 2009-10-30 05:18:38 +0200 (Fri, 30 Oct 2009) | 7 lines
branches/5.1: Chnage WARN_LEVEL_ERROR to WARN_LEVEL_WARN
for push_warning_printf() call in innodb.
Fix Bug#47233: Innodb calls push_warning(MYSQL_ERROR::WARN_LEVEL_ERROR)

rb://170 approved by Marko.
2009-11-02 18:59:44 +04:00
Sergey Vojtovich
ebc3626738 Applying InnoDB snashot 5.1-ss6129
Detailed revision comments:

r6052 | sunny | 2009-10-12 07:09:56 +0300 (Mon, 12 Oct 2009) | 4 lines
branches/5.1: Reset the statement level autoinc counter on ROLLBACK. Fix
the test results too.
rb://164

r6053 | sunny | 2009-10-12 07:37:49 +0300 (Mon, 12 Oct 2009) | 6 lines
branches/5.1: Copy the maximum AUTOINC value from the old table to the new
table when MySQL does a CREATE INDEX ON T. This is required because MySQL
does a table copy, rename and drops the old table.
Fix Bug#47125: auto_increment start value is ignored if an index is created and engine=innodb
rb://168
2009-11-02 18:58:09 +04:00
Sergey Vojtovich
c8d97af6b0 Applying InnoDB snashot 5.1-ss6129
Detailed revision comments:

r6051 | sunny | 2009-10-12 07:05:00 +0300 (Mon, 12 Oct 2009) | 6 lines
branches/5.1: Ignore negative values supplied by the user when calculating the
next value to store in dict_table_t. Setting autoincrement columns top negative
values is undefined behavior and this change should bring the behavior of
InnoDB closer to what users expect. Added several tests to check.
rb://162
2009-11-02 18:43:20 +04:00
Sergey Vojtovich
71d24a2371 Applying InnoDB snashot 5.1-ss6129
Detailed revision comments:

r6045 | jyang | 2009-10-08 02:27:08 +0300 (Thu, 08 Oct 2009) | 7 lines
branches/5.1: Fix bug #47777. Treat the Geometry data same as
Binary BLOB in ha_innobase::store_key_val_for_row(), since the
Geometry data is stored as Binary BLOB in Innodb.

Review: rb://180 approved by Marko Makela.
2009-11-02 18:41:40 +04:00
Martin Hansson
740b7c4e36 Bug#47925: regression of range optimizer and date comparison in 5.1.39!
When a query was using a DATE or DATETIME value formatted
using any other separator characters beside hyphen '-', a
query with a greater-or-equal '>=' condition matching only
the greatest value in an indexed column, the result was
empty if index range scan was employed.

The range optimizer got a new feature between 5.1.38 and
5.1.39 that changes a greater-or-equal condition to a
greater-than if the value matching that in the query was not
present in the table. But the value comparison function
compared the dates as strings instead of dates.

The bug was fixed by splitting the function
get_date_from_str in two: One part that parses and does
error checking. This function is now visible outside the
module. The old get_date_from_str now calls the new
function.


mysql-test/r/range.result:
  Bug#47925: Test result
mysql-test/t/range.test:
  Bug#47925: Test case
sql/item.cc:
  Bug#47925: Fix + some edit on the comments
sql/item.h:
  Bug#47925: Changed function signature
sql/item_cmpfunc.cc:
  Bug#47925: Split function in two
sql/item_cmpfunc.h:
  Bug#47925: Declaration of new function
sql/opt_range.cc:
  Bug#47925: Added THD to function call
sql/time.cc:
  Bug#47925: Added microsecond comparison
2009-11-02 13:24:07 +01:00
Davi Arnaut
1ca80ed19e Bug#48370: Absolutely wrong calculations with GROUP BY and decimal fields when using IF
Bug#45261: Crash, stored procedure + decimal

Revert fix for Bug#45261 due to unforeseen bugs.
2009-11-02 09:21:39 -02:00
Sergey Vojtovich
cd167ee2e9 Merge innodb-5.1-ss6129 to mysql-5.1-bugteam. 2009-11-03 13:19:02 +04:00
Vladislav Vaintroub
b51777484f merge 2009-11-03 01:52:57 +01:00
Vladislav Vaintroub
2377eed362 Bug #47423 mtr connects to wrong database
The reason for the bug is that mysqtest as well as other client tools
running in test suite (mysqlbinlog, mysqldump) will first try to connect 
whatever database has created shared memory with default base name 
"MySQL" and use this. (Same effect could be seen on Unix if mtr would
not care to calculate "port" and "socket" parameter).
      
The fix ensures that all client tools and  running in mtr use unique  
per-database shared memory base parameters, so there is no possibility
to clash with already installed one. We use socket name for shared memory 
base (it's known to be unique). This shared-memory-base is written to the
MTR config file to the [client] and [mysqld] sections. Fix made also made 
sure all client tools understand and correctly handle --shared-memory-base.
Prior to this patch  it was not the case for  mysqltest, mysqlbinlog and 
mysql_client_test.
      
All new connections done from mtr scripts via connect() will by default 
set shared-memory-base. And finally, there is a possibility to force 
shared memory or pipe connection and overwrite shared memory/pipe base name
from within mtr scripts via optional PIPE or SHM modifier. This functionality
was manually backported from 6.0
(original patch  http://lists.mysql.com/commits/74749)
2009-11-03 01:19:37 +01:00
Luis Soares
b4eead7e20 Auto-merging mysql-5.1-bugteam-gca into mysql-5.1-bugteam latest. 2009-11-02 16:02:55 +00:00
Luis Soares
d699ba3b74 Auto-merging bzr bundle from bug report in mysql-5.1-bugteam-gca 2009-11-02 15:57:25 +00:00
Tatiana A. Nurnberg
09c50b6303 auto-merge 2009-11-02 00:13:13 -08:00
Luis Soares
2ad0d6910c BUG#42829: manually merged approved bzr bundle from bug report.
Conflicts
=========

Text conflict in sql/sql_class.cc
1 conflicts encountered.
2009-11-01 23:13:11 +00:00
Sergey Vojtovich
d395e824ad Merge fix for BUG#43171. 2009-10-31 14:50:25 +04:00
Alexey Kopytov
3df1ae7a1a Automerge. 2009-10-30 19:16:29 +03:00
Alexey Kopytov
23cbd659a0 Automerge. 2009-10-30 18:59:06 +03:00
Alexey Kopytov
b67cdaa351 Bug #48131: crash group by with rollup, distinct, filesort,
with temporary tables

There were two problems the test case from this bug was
triggering:

1. JOIN::rollup_init() was supposed to wrap all constant Items
into another object for queries with the WITH ROLLUP modifier
to ensure they are never considered as constants and therefore
are written into temporary tables if the optimizer chooses to
employ them for DISTINCT/GROUP BY handling.

However, JOIN::rollup_init() was called before
make_join_statistics(), so Items corresponding to fields in
const tables could not be handled as intended, which was
causing all kinds of problems later in the query execution. In
particular, create_tmp_table() assumed all constant items
except "hidden" ones to be removed earlier by remove_const()
which led to improperly initialized Field objects for the
temporary table being created. This is what was causing crashes
and valgrind errors in storage engines.

2. Even when the above problem had been fixed, the query from
the test case produced incorrect results due to some
DISTINCT/GROUP BY optimizations being performed by the
optimizer that are inapplicable in the WITH ROLLUP case.

Fixed by disabling inapplicable DISTINCT/GROUP BY optimizations
when the WITH ROLLUP modifier is present, and splitting the
const-wrapping part of JOIN::rollup_init() into a separate
method which is now invoked after make_join_statistics() when
the const tables are already known.

mysql-test/r/olap.result:
  Added a test case for bug #48131.
mysql-test/t/olap.test:
  Added a test case for bug #48131.
sql/sql_select.cc:
  1. Disabled inapplicable DISTINCT/GROUP BY optimizations when
  the WITH ROLLUP modifier is present.
  2. Split the const-wrapping part of JOIN::rollup_init() into a
  separate method.
sql/sql_select.h:
  Added rollup_process_const_fields() declaration.
2009-10-30 18:54:53 +03:00
Georgi Kodinov
5bba20bb6a merge 2009-10-30 16:13:13 +02:00
Georgi Kodinov
9d96cd6dcb Bug #48291 : crash with row() operator,select into @var, and
subquery returning multiple rows

Error handling was missing when handling subqueires in WHERE 
and when assigning a SELECT result to a @variable.
This caused crash(es). 

Fixed by adding error handling code to both the WHERE 
condition evaluation and to assignment to an @variable.
2009-10-30 15:15:43 +02:00
Georgi Kodinov
1e7fb59272 merge 2009-10-30 11:56:32 +02:00
Georgi Kodinov
851e250953 Bug #48293: crash with procedure analyse, view with > 10 columns,
having clause...

The fix for bug 46184 was not very complete. It was not covering
views using temporary tables and multiple tables in a FROM clause.
Fixed by reverting the fix for 46184 and making a more general
check that is checking at the right execution stage and for all
of the non-supported cases.
Now PROCEDURE ANALYZE on non-top level SELECT is also forbidden.
Updated the analyse.test and subselect.test accordingly.
2009-10-30 11:40:44 +02:00
Georgi Kodinov
bba3b76cdb merge 2009-10-30 10:03:18 +02:00
Tatiana A. Nurnberg
be04d1a479 Bug#48319: Server crashes on "GRANT/REVOKE ... TO CURRENT_USER"
CURRENT_USER() in GRANT ... TO CURRENT_USER() only gave us a definer,
not a full user (i.e., password-element was not initiliazed). Hence
dereferencing the password led to a crash.

Properly initializes definers now, just so there are no misunderstandings.
Also does some magic so IDENTIFIED BY ... works with CURRENT_USER().

mysql-test/r/grant2.result:
  Show GRANT ... TO CURRENT_USER() no longer crashes.
  Show it to work with IDENTIFIED BY to boot.
mysql-test/t/grant2.test:
  Show GRANT ... TO CURRENT_USER() no longer crashes.
  Show it to work with IDENTIFIED BY to boot.
sql/sql_acl.cc:
  Make IDENTIFIED BY ... work with CURRENT_USER()
sql/sql_parse.cc:
  Zero password-part of definer just in case somebody mistakes this for
  a complete LEX_USER!
2009-10-29 22:06:10 -07:00
Tatiana A. Nurnberg
eaad6119da Bug#48295: explain extended crash with subquery and ONLY_FULL_GROUP_BY sql_mode
If an outer query is broken, a subquery might not even get set up.
EXPLAIN EXTENDED did not expect this and merrily tried to de-ref all
of the half-setup info.

We now catch this case and print as much as we have, as it doesn't cost us
anything (doesn't make regular execution slower).

mysql-test/r/explain.result:
  Show that EXPLAIN EXTENDED with subquery and illegal out query doesn't crash.
  Show also that SHOW WARNINGS will render an additional Note in the hope of
  being, well, helpful.
mysql-test/t/explain.test:
  If we have only half a query for EXPLAIN EXTENDED to print (i.e.,
  incomplete subquery info as outer query is illegal), we should
  provide the user with as much info as we easily can if they ask
  for it. What we should not do is crash when they come asking for
  help, that violates etiquette in some countries.
sql/item_subselect.cc:
  If the sub-query's actually set up, print it. Otherwise, elide.
2009-10-29 16:01:54 -07:00
Georgi Kodinov
ac37324843 Bug #42116 : Mysql crash on specific query
Queries with nested outer joins may lead to crashes or 
bad results because an internal data structure is not handled
correctly.
The optimizer uses bitmaps of nested JOINs to determine
if certain table can be placed at a certain place in the
JOIN order.
It does maintain a bitmap describing in which JOINs 
last placed table is nested.
When it puts a table it makes sure the bit of every JOIN that
contains the table in question is set (because JOINs can be nested).
It does that by recursively setting the bit for the next enclosing
JOIN when this is the first table in the JOIN and recursively 
resetting the bit if it's the last table in the JOIN.
When it removes a table from the join order it should do the
opposite : recursively unset the bit if it's the only remaining 
table in this join and and recursively set the bit if it's removing
the last table of a JOIN.
There was an error in how the bits was set for the upper levels :
when removing a table it was setting the bit for all the enclosing 
nested JOINs even if there were more tables left in the current JOIN
(which practically means that the upper nested JOINs were not affected).
Fixed by stopping the recursion at the relevant level.

mysql-test/r/join.result:
  Bug #42116: test case
mysql-test/t/join.test:
  Bug #42116: test case
sql/sql_select.cc:
  Bug #41116: don't go up and set the bits if more tables in
  at the current JOIN level
2009-10-29 17:24:29 +02:00
unknown
09668c0124 Bug #46828 rpl_get_master_version_and_clock fails on PB-2
The 'rpl_get_master_version_and_clock' test verifies if the slave I/O 
thread tries to reconnect to master when it tries to get the values of 
the UNIX_TIMESTAMP, SERVER_ID from master under network disconnection. 
So the master server is restarted for making the transient network 
disconnection. Restarting master server can bring two problems as following:

1. The time out error is encountered sporadically. The slave I/O thread tries 
   to reconnect master ten times, which is set in my.cnf. So in the test 
   framework sporadically the slave I/O thread really stoped when it can't 
   reconnect to master in the ten times successfully before the master starts, 
   then the time out error will be encountered while waiting for the slave to 
   start.

2. These warnings and errors are produced in server log file when 
   the slave I/O thread tries to get the values of the UNIX_TIMESTAMP, 
   SERVER_ID from master under the transient network disconnection.

To fix problem 1, increase the master retry count to sixty times, 
so that the slave I/O thread has enough time to reconnect master 
successfully.
To fix problem 2, suppress these warnings and errors by mtr suppression, 
because they are expected.


mysql-test/suite/rpl/t/rpl_get_master_version_and_clock-slave.opt:
  Added the *.opt file for increasing master retry count to 
  sixty times.
mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test:
  Added mtr suppression for suppressing warnings and errors 
  in server log file.
2009-10-29 10:26:59 +08:00
Sergey Vojtovich
17ed708975 BUG#43171 - Assertion failed: thd->transaction.xid_state.xid.is_null()
XA START may cause assertion failure/server crash when it is called
after unilateral roll back issued by the Resource Manager (both
in regular transaction and after XA transaction).

The problem was that rm_error variable wasn't set/reset properly.

mysql-test/r/xa.result:
  A test case for BUG#43171.
mysql-test/t/xa.test:
  A test case for BUG#43171.
sql/handler.cc:
  Setting rm_error when we're out of XA transaction has no
  special meaning. But it blocks reset of thd->transaction.xid
  structure later.
sql/sql_parse.cc:
  Reset rm_error before we enter ha_rollback(), so
  thd->transaction.xid strucure is reinitialized.
2009-10-28 19:39:08 +04:00
Konstantin Osipov
f130de4fb8 A patch and a test case for
Bug#46539 Various crashes on INSERT IGNORE SELECT + SELECT FOR UPDATE.

If a transaction was rolled back inside InnoDB due to a deadlock
or lock wait timeout, and the statement had IGNORE clause,
the server could crash at the end of the statement or on shutdown.

This was caused by the error handling infrastructure's attempt to 
ignore a non-ignorable error.

When a transaction rollback request is raised, switch off 
current_select->no_error flag, so that the following error
won't be ignored.

Instead, we could add !thd->is_fatal_sub_stmt_error to
my_message_sql(), but since in write_record() we switch
off no_error, the same approach is used in 
thd_mark_transaction_to_rollback().

@todo: call thd_mark_transaction_to_rollback() from 
handler::print_error(), then we can easily make sure
that the error reported by print_error is not ignored.

mysql-test/r/innodb_lock_wait_timeout_1.result:
  Update results (Bug#46539).
mysql-test/t/innodb_lock_wait_timeout_1.test:
  Add a test case for Bug#46539
sql/sql_class.cc:
  When a transaction rollback request is raised, switch of 
  current_select->no_error flag, so that the following error
  won't be ignored.
2009-10-28 17:49:56 +03:00
Sergey Glukhov
97f4ca3acd 5.0-bugteam->5.1-bugteam merge 2009-10-28 13:23:02 +04:00
Sergey Glukhov
0b10509e3b Bug#41049 does syntax "grant" case insensitive?
test result fix

mysql-test/suite/funcs_1/r/is_columns_mysql.result:
  test result fix
mysql-test/suite/funcs_1/r/is_statistics.result:
  test result fix
2009-10-28 13:15:33 +04:00
Luis Soares
a382917684 BUG#48297: Schema name is ignored when LOAD DATA is written into
binlog, replication aborts

In SBR or MBR, the schema name is not being written to the binlog
when executing a LOAD DATA statement. This becomes a problem when
the current database (lets call it db1) is different from the
table's schema (lets call it db2). For instance, take the
following statements:
  
  use db1;
  load data local infile 'infile.txt' into table db2.t

Should this statement be logged without t's schema (db2), when
replaying it, one can get db1.t populated instead of db2.t (if
db1.t exists). On the other hand, if there is no db1.t at all,
replication will stop.

We fix this by always logging the table (in load file) with fully
qualified name when its schema is different from the current
database or when no default database was selected.
2009-10-27 15:15:53 +00:00
Sergey Vojtovich
a5b5db32b4 Merge 5.1-bugteam -> 5.1-bugteam-local. 2009-10-27 18:30:02 +04:00
Sergey Vojtovich
578007404d A follow-up to fix for
BUG#47073 - valgrind errs, corruption,failed repair of partition,
            low myisam_sort_buffer_size

Fixed race conditions discovered with the provided test case and
stabilized test case.

include/myisam.h:
  Serialize submission of messages from multi-threaded REPAIR.
mysql-test/r/myisam.result:
  REPAIR output highly depend on threads activity. Disabled
  result log to make test case deterministic.
mysql-test/t/myisam.test:
  REPAIR output highly depend on threads activity. Disabled
  result log to make test case deterministic.
storage/myisam/ha_myisam.cc:
  Serialize submission of messages from multi-threaded REPAIR.
storage/myisam/mi_check.c:
  Serialize submission of messages from multi-threaded REPAIR.
storage/myisam/sort.c:
  Only master thread is allowed to detach write cache from
  the share.
2009-10-27 18:27:27 +04:00
Georgi Kodinov
313c5a01ee Bug #47930: MATCH IN BOOLEAN MODE returns too many results
inside subquery

Re-setting a fulltext index was a no-operation if not all
the matches of a search were consumed by reading them.
This was preventing a joined table using a fulltext index
in a subquery that requires only 1 row of output (e.g. EXISTS) 
from working correctly because the second execution of the 
sub-query has the fulltext index cursor in a wrong state and
was not finding results.
Fixed by making the re-init code _ftb_init_index_search() 
to re-set open cursors in addition to depleted ones.
2009-10-27 14:43:12 +02:00
Georgi Kodinov
bbbad7fee5 merge 2009-11-10 12:59:02 +02:00
Georgi Kodinov
0daad80228 merge 2009-11-10 10:58:43 +02:00
Sergey Glukhov
3823ac329e automerge 2009-10-27 15:04:59 +04:00
Sergey Glukhov
f554a3c094 5.0-bugteam->5.1-bugteam merge 2009-10-27 14:09:36 +04:00
Tatiana A. Nurnberg
6ceaf234bb auto-merge 2009-10-27 02:53:16 -07:00
Sergey Glukhov
f0a7ff8419 Bug#41049 does syntax "grant" case insensitive?
Problem 1:
column_priv_hash uses utf8_general_ci collation
for the key comparison. The key consists of user name,
db name and table name. Thus user with privileges on table t1
is able to perform the same operation on T1
(the similar situation with user name & db name, see acl_cache).
So collation which is used for column_priv_hash and acl_cache
should be case sensitive.
The fix:
replace system_charset_info with my_charset_utf8_bin for
column_priv_hash and acl_cache
Problem 2:
The same situation with proc_priv_hash, func_priv_hash,
the only difference is that Routine name is case insensitive.
So the fix is to use my_charset_utf8_bin for
proc_priv_hash & func_priv_hash and convert routine name into lower
case before writing the element into the hash and
before looking up the key.
Additional fix: mysql.procs_priv Routine_name field collation
is changed to utf8_general_ci.
It's necessary for REVOKE command
(to find a field by routine hash element values).
Note: 
It's safe for lower-case-table-names mode too because
db name & table name are converted into lower case
(see GRANT_NAME::GRANT_NAME).


mysql-test/include/have_case_insensitive_fs.inc:
  test case
mysql-test/r/case_insensitive_fs.require:
  test case
mysql-test/r/grant_lowercase_fs.result:
  test result
mysql-test/r/lowercase_fs_off.result:
  test result
mysql-test/r/ps_grant.result:
  test result
mysql-test/r/system_mysql_db.result:
  changed Routine_name field collation to case insensitive
mysql-test/t/grant_lowercase_fs.test:
  test case
mysql-test/t/lowercase_fs_off.test:
  test case
scripts/mysql_system_tables.sql:
  changed Routine_name field collation to case insensitive
scripts/mysql_system_tables_fix.sql:
  changed Routine_name field collation to case insensitive
sql/sql_acl.cc:
  Problem 1:
  column_priv_hash uses utf8_general_ci collation
  for the key comparison. The key consists of user name,
  db name and table name. Thus user with privileges on table t1
  is able to perform the same operation on T1
  (the similar situation with user name & db name, see acl_cache).
  So collation which is used for column_priv_hash and acl_cache
  should be case sensitive.
  The fix:
  replace system_charset_info with my_charset_utf8_bin for
  column_priv_hash and acl_cache
  Problem 2:
  The same situation with proc_priv_hash, func_priv_hash,
  the only difference is that Routine name is case insensitive.
  So the fix is to use my_charset_utf8_bin for
  proc_priv_hash & func_priv_hash and convert routine name into lower
  case before writing the element into the hash and
  before looking up the key.
  Additional fix: mysql.procs_priv Routine_name field collation
  is changed to utf8_general_ci.
  It's necessary for REVOKE command
  (to find a field by routine hash element values).
  Note: 
  It's safe for lower-case-table-names mode too because
  db name & table name are converted into lower case
  (see GRANT_NAME::GRANT_NAME).
2009-10-27 12:09:19 +04:00
Georgi Kodinov
fb043f9bc2 rpl_cross_version made experimental because of bug #43913 2009-10-26 14:33:03 +02:00
Georgi Kodinov
9a5a77eb68 automerge 2009-10-24 09:57:31 +03:00
Ramil Kalimullin
1339fb17fe Auto-merge. 2009-10-23 23:37:57 +05:00
Jon Olav Hauglid
c2d3d6bbef automerge 2009-10-23 16:35:06 +02:00
Georgi Kodinov
d539c1570b Revert the fix for bug #47627 as it's causing the regression tests in pb2 to
fail.
2009-10-23 16:54:58 +03:00
Jon Olav Hauglid
6354112983 Bug #47919 assert in open_table during ALTER temporary table
This assertion would occur if UPDATE was used to update multiple
tables containing an AUTO_INCREMENT column and if the inserted
row had a user-supplied value for that column. The assertion 
could then be triggered by the next statement.

The problem was only noticeable on debug builds of the server.

The cause of the problem was that the code for multi update did
not properly reset the TABLE->auto_increment_if_null flag after update.
The flag is used to indicate that a non-null value of an auto_increment field
has been provided by the user or retrieved from a current record.
Open_tables() contains an assertion that tests this flag, and this
was triggered in this case by ALTER TABLE.

This patch fixes the problem by resetting the auto_increment_if_null
field to FALSE once a row has been updated.

This bug is similar to Bug#47274, but for multi update rather
than INSERT DELAYED.

Test case added to update.test.
2009-10-23 15:09:14 +02:00
Georgi Kodinov
88084d6763 merged 5.1-main-> 5.1-bugteam 2009-10-23 15:12:26 +03:00
Ramil Kalimullin
b7ce2a01bc Fix for bug#48258: Assertion failed when using a spatial index
Problem: involving a spatial index for "non-spatial" queries
(that don't containt MBRXXX() functions) may lead to failed assert.

Fix: don't use spatial indexes in such cases.


mysql-test/r/gis-rtree.result:
  Fix for bug#48258: Assertion failed when using a spatial index
    - test result.
mysql-test/t/gis-rtree.test:
  Fix for bug#48258: Assertion failed when using a spatial index
    - test case.
sql/opt_range.cc:
  Fix for bug#48258: Assertion failed when using a spatial index
    - allow only spatial functions (MBRXXX) for itMBR keyparts.
2009-10-23 16:26:48 +05:00
Luis Soares
3fd3aa4620 BUG#34582: mysql-5.1-bugteam-bug-branch --> mysql-5.1-bugteam-latest
(automerge)
2009-10-23 01:03:41 +01:00
Ramil Kalimullin
77998869ee Autopush 2009-10-22 14:40:15 +05:00
Alfranio Correia
0c2d74c60b BUG#48091 valgrind errors when slave has double not null and master has double null
Backporting BUG#47741 to mysql-5.1-bugteam
2009-10-22 01:21:50 +01:00
Alfranio Correia
925ac7f4eb BUG#48091 valgrind errors when slave has double not null and master has double null
Backporting BUG#43789 to mysql-5.1-bugteam

Post-fix for BUG#43789.
2009-10-22 01:19:52 +01:00
Alfranio Correia
7e5cf52c3e BUG#48091 valgrind errors when slave has double not null and master has double null
Backporting BUG#43789 to mysql-5.1-bugteam
                              
The replication was generating corrupted data, warning messages on Valgrind
and aborting on debug mode while replicating a "null" to "not null" field.
Specifically the unpack_row routine, was considering the slave's table
definition and trying to retrieve a field value, where there was nothing to be
retrieved, ignoring the fact that the value was defined as "null" by the master.
                              
To fix the problem, we proceed as follows:
                              
1 - If it is not STRICT sql_mode, implicit default values are used, regardless
if it is multi-row or single-row statement.
                              
2 - However, if it is STRICT mode, then a we do what follows:
                              
2.1 If it is a transactional engine, we do a rollback on the first NULL that is
to be set into a NOT NULL column and return an error.
                              
2.2 If it is a non-transactional engine and it is the first row to be inserted
with multi-row, we also return the error. Otherwise, we proceed with the
execution, use implicit default values and print out warning messages.
                        
Unfortunately, the current patch cannot mimic the behavior showed by the master
for updates on multi-tables and multi-row inserts. This happens because such
statements are unfolded in different row events. For instance, considering the
following updates and strict mode:
                        
(master)
create table t1 (a int);
create table t2 (a int not null);
insert into t1 values (1);
insert into t2 values (2);
update t1, t2 SET t1.a=10, t2.a=NULL;
                        
t1 would have (10) and t2 would have (0) as this would be handled as a
multi-row update. On the other hand, if we had the following updates:
                        
(master)
create table t1 (a int);
create table t2 (a int);
                        
(slave)
create table t1 (a int);
create table t2 (a int not null);
                        
(master)
insert into t1 values (1);
insert into t2 values (2);
update t1, t2 SET t1.a=10, t2.a=NULL;
                        
On the master t1 would have (10) and t2 would have (NULL). On
the slave, t1 would have (10) but the update on t1 would fail.
2009-10-22 01:15:45 +01:00
Alfranio Correia
deea727fce BUG#48091 valgrind errors when slave has double not null and master has double null
Backporting BUG#38173 to mysql-5.1-bugteam

The reason of  the bug was incompatibile with the master side behaviour.
INSERT query on the master is allowed to insert into a table without specifying
values of DEFAULT-less fields if sql_mode is not strict.
                  
Fixed with checking sql_mode by the sql thread to decide how to react.
Non-strict sql_mode should allow Write_rows event to complete.
                  
todo: warnings can be shown via show slave status, still this is a 
separate rather general issue how to show warnings for the slave threads.
2009-10-22 01:10:42 +01:00
Ramil Kalimullin
17ed6b9abd Fix for bug#47019: Assertion failed: 0, file .\rt_mbr.c,
line 138 when forcing a spatial index

Problem: "Spatial indexes can be involved in the search 
for queries that use a function such as MBRContains() 
or MBRWithin() in the WHERE clause".
Using spatial indexes for JOINs with =, <=> etc.
predicates is incorrect.

Fix: disable spatial indexes for such queries.


mysql-test/r/select.result:
  Fix for bug#47019: Assertion failed: 0, file .\rt_mbr.c, 
  line 138 when forcing a spatial index
    - test result.
mysql-test/t/select.test:
  Fix for bug#47019: Assertion failed: 0, file .\rt_mbr.c, 
  line 138 when forcing a spatial index
    - test case.
sql/sql_select.cc:
  Fix for bug#47019: Assertion failed: 0, file .\rt_mbr.c, 
  line 138 when forcing a spatial index
    - disable spatial indexes for queries which use 
  non-spatial conditions (e.g. NATURAL JOINs).
2009-10-21 14:04:08 +05:00
Georgi Kodinov
19ffe23085 Bug #47780: crash when comparing GIS items from subquery
If the first argument to GeomFromWKB function is a geometry
field then the function just returns its value.
However in doing so it's not preserving first argument's 
null_value flag and this causes unexpected null value to
be returned to the calling function.
      
Fixed by updating the null_value of the GeomFromWKB function
in such cases (and all other cases that return a NULL e.g.
because of not enough memory for the return buffer).
2009-10-21 11:43:45 +03:00
Tatiana A. Nurnberg
b25cc8f23f auto-merge 2009-10-20 20:38:56 -07:00
Tatiana A. Nurnberg
495cde347b auto-merge 2009-10-20 20:37:33 -07:00
Tatiana A. Nurnberg
3f0d0d0633 manual merge of 28141 2009-10-20 11:00:07 -07:00
Bjorn Munch
0777ef567d merge 48149 2009-10-20 12:05:28 +02:00
Luis Soares
6395cb8ecf BUG#34582: FLUSH LOGS does not close and reopen the binlog index
file
      
Issuing 'FLUSH LOGS' does not close and reopen indexfile.
Instead a SEEK_SET is performed.
      
This patch makes index file to be closed and reopened whenever a
rotation happens (FLUSH LOGS is issued or binary log exceeds 
maximum configured size).

mysql-test/suite/binlog/r/binlog_delete_and_flush_index.result:
  Result file.
mysql-test/suite/binlog/t/binlog_delete_and_flush_index.test:
  Test case.
sql/log.cc:
  Added LOG_CLOSE_INDEX flag when calling MYSQL_BIN_LOG::close
  from within MYSQL_BIN_LOG::new_file_impl (which should just be
  called whenever a rotation is to happen - FLUSH LOGS issued or
  binlog size exceeds the maximum configured).
2009-10-20 09:39:40 +01:00
Kristofer Pettersson
e942adb23d Automerge 2009-10-20 09:00:01 +02:00
Satya B
362aaccba0 merge mysql-5.0-bugteam to mysql-5.1-bugteam 2009-10-20 12:07:58 +05:30
Kristofer Pettersson
c310a5c9e1 automerge 2009-10-20 08:21:35 +02:00
Satya B
882535423d Fix for Bug #41597 - After rename of user, there are additional grants when
grants are reapplied.


After renaming a user and trying to re-apply grants results in additional
grants.

This is because we use username as part of the key for GRANT_TABLE structure.
When the user is renamed, we only change the username stored and the hash key
still contains the old user name and this results in the extra privileges

Fixed by rebuilding the hash key and updating the column_priv_hash structure
when the user is renamed

mysql-test/r/grant3.result:
  Bug #41597 - After rename of user, there are additional grants when 
               grants are reapplied.
  
  Testcase for BUG#41597
mysql-test/t/grant3.test:
  Bug #41597 - After rename of user, there are additional grants when 
               grants are reapplied.
  
  Testcase for BUG#41597
sql/sql_acl.cc:
  Bug #41597 - After rename of user, there are additional grants when 
               grants are reapplied.
  
  Fixed handle_grant_struct() to update the hash key when the user is renamed.
  Added to set_user_details() method to GRANT_NAME class
2009-10-20 11:47:57 +05:30
Sergey Vojtovich
0ae6a35e10 Merge 5.1-bugteam -> 5.1-bugteam-local. 2009-10-20 10:40:47 +05:00
Tatiana A. Nurnberg
5ef63a4f1c Bug#28141: Control C on query waiting on lock causes ERROR 1053 (server shutdown)
If a thread is killed in the server, we throw "shutdown" only if one is actually in
progress; otherwise, we throw "query interrupted".

Control-C in the mysql command-line client is "incremental" now.
First Control-C sends KILL QUERY (when connected to 5.0+ server, otherwise, see next)
Next  Control-C sends KILL CONNECTION
Next  Control-C aborts client.

As the first two steps only pertain to an existing query,
Control-C will abort the client right away if no query is running.

client will give more detailed/consistent feedback on Control-C now.


client/mysql.cc:
  Extends Control-C handling; enhances up feedback to user.
  
  On 5.0+ servers, we try to be nice and send KILL QUERY first
  if Control-C is pressed in the command-line client, but if
  that doesn't work, we now give the user the opportunity to
  send KILL CONNECTION with another Control-C (and to kill the
  client with another Control-C if that somehow doesn't work
  either).
mysql-test/t/flush_read_lock_kill.test:
  we're getting correct "thread killed" rather than
  "in shutdown" error now
mysql-test/t/kill.test:
  we're getting correct "thread killed" rather than
  "in shutdown" error now
mysql-test/t/rpl000001.test:
  we're getting correct "thread killed" rather than
  "in shutdown" error now
mysql-test/t/rpl_error_ignored_table.test:
  we're getting correct "thread killed" rather than
  "in shutdown" error now
sql/records.cc:
  make error messages on KILL uniform for rr_*()
  by folding that handling into rr_handle_error()
sql/sql_class.h:
  Only throw "shutdown" when we have one flagged as being in progress;
  otherwise, throw "query interrupted" as it's likely to be "KILL CONNECTION"
  or related.
2009-10-19 21:42:10 -07:00
Georgi Kodinov
74b0f6be2f Bug #47788: Crash in TABLE_LIST::hide_view_error on
UPDATE + VIEW + SP + MERGE + ALTER

When cleaning up the stored procedure's internal 
structures the flag to ignore the errors for 
INSERT/UPDATE IGNORE was not cleaned up.
As a result error ignoring was on during name 
resolution. And this is an abnormal situation : the
SELECT_LEX flag can be on only during query execution.

Fixed by correctly cleaning up the SELECT_LEX flag 
when reusing the SELECT_LEX in a second execution.
2009-10-19 16:55:04 +03:00
Georgi Kodinov
8363e26659 Bug #47412: Valgrind warnings / user can read uninitalized memory using
SP variables

A function call may end without throwing an error or without setting 
the return value. This can happen when e.g. an error occurs while 
calculating the return value.

Fixed by setting the value to NULL when error occurs during evaluation
of an expression.
2009-10-26 11:55:57 +02:00
Bjorn Munch
e6bc01d170 Bug #48149 MTR should automatically skip SSL tests if SSL not supported
Knowledge of no SSL support is not used
Skip tests the same way e.g. innodb tests are
Does not refer to have_ssl_communication.inc, 
     will add this when merging to 6.0-codebase
2009-10-19 15:51:47 +02:00
Bjorn Munch
2f36bc160a merge 48130 and 48133 2009-10-19 15:33:34 +02:00
Alexander Barkov
ead175bb07 Bug#45645 Mysql server close all connection and restart using lower function
Problem: the "caseinfo" member of CHARSET_INFO structure was not
initialized for user-defined Unicode collations, which made the
server crash.
Fix: initializing caseinfo properly.
2009-10-19 18:23:53 +05:00
Alexander Barkov
14fe0fa509 Bug#43207 wrong LC_TIME names for romanian locale
Adding tests for the bug.
2009-10-19 13:44:44 +05:00
Kristofer Pettersson
834ba32293 Bug#47627 SET @@{global.session}.local_variable in stored routine causes crash
Adding @@session and @@global prefixes to a
declared variable in a stored procedure the server
would lead to a crash.

The reason was that during the parsing of the
syntactic rule 'option_value' an uninitialized
set_var object was pushed to the parameter stack
of the SET statement. The parent rule
'option_type_value'  interpreted the existence of
variables on the parameter stack as an assignment
and wrapped it in a sp_instr_set object.

As the procedure later was executed an attempt
was made to run the method 'check()' on an
uninitialized member object (NULL value) belonging
to the previously created but uninitialized object.


sql/sql_yacc.yy:
  * Assign the option_type at once since it is needed by the next
    parsing rule (internal_variable_name)
  * Rearranged the if statement to reduce negations and gain more
    clarity of code.
  * Added check for option_type to better detect if current
    variable is a SP local variable or a system variable.
2009-10-19 09:43:33 +02:00
Ramil Kalimullin
0b43c4e74c Fix for bug#47963: Wrong results when index is used
Problem: using null microsecond part in a WHERE condition 
(e.g. WHERE date_time_field <= "YYYY-MM-DD HH:MM:SS.0000") 
may lead to wrong results due to improper DATETIMEs 
comparison in some cases.

Fix: comparing DATETIMEs as strings we must trim trailing 0's
in such cases.


mysql-test/r/innodb_mysql.result:
  Fix for bug#47963: Wrong results when index is used
    - test result.
mysql-test/t/innodb_mysql.test:
  Fix for bug#47963: Wrong results when index is used
    - test case.
sql/item.cc:
  Fix for bug#47963: Wrong results when index is used
    - comparing DATETIMEs as strings we must trim trailing 0's in the 
  microsecond part to ensure
  'YYYY-MM-DD HH:MM:SS.000' == 'YYYY-MM-DD HH:MM:SS'
2009-10-18 21:26:55 +05:00
Bjorn Munch
c6533f9eb3 Bug #48133 MTR should not dump entire history of mysqld log when failing to start server
Don't print entire log, but use extract_server_log() introduced by 46007
2009-10-18 13:01:46 +02:00
Bjorn Munch
dcf6aae407 Bug #48130 Expected failures should not count towards max-test-fail
Test batches may be terminated too early
Avoid counting exp-fail tests
2009-10-17 18:34:56 +02:00
Bjorn Munch
72c96cbd0e merge from 5.1 main 2009-10-16 23:25:05 +02:00
Alexey Kopytov
f6868a4eb4 Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN
The problem was in incorrect handling of predicates involving 
NULL as a constant value by the range optimizer. 
 
For example, when creating a SEL_ARG node from a condition of 
the form "field < const" (which would normally result in the 
"NULL < field < const" SEL_ARG),  the special case when "const" 
is NULL was not taken into account, so "NULL < field < NULL" 
was produced for the "field < NULL" condition. 
 
As a result, SEL_ARG structures of this form could not be 
further optimized which in turn could lead to incorrectly 
constructed SEL_ARG trees. In particular, code assuming SEL_ARG 
structures to always form a sequence of ordered disjoint 
intervals could enter an infinite loop under some 
circumstances. 
 
Fixed by changing get_mm_leaf() so that for any sargable 
predicate except "<=>" involving NULL as a constant, "empty" 
SEL_ARG is returned, since such a predicate is always false. 

mysql-test/r/partition_pruning.result:
  Fixed a broken test case.
mysql-test/r/range.result:
  Added a test case for bug #47123.
mysql-test/r/subselect.result:
  Fixed a broken test cases.
mysql-test/t/range.test:
  Added a test case for bug #47123.
sql/opt_range.cc:
  Fixed get_mm_leaf() so that for any sargable
  predicate except "<=>" involving NULL as a constant, "empty"
  SEL_ARG is returned, since such a predicate is always false.
2009-10-17 00:19:51 +04:00
Martin Hansson
3bd2461668 Bug#46019: ERROR 1356 When selecting from within another
view that has Group By
      
When SELECT'ing from a view that mentions another,
materialized, view, access was being denied. The issue was
resolved by lifting a special case which avoided such access
checking in check_single_table_access. In the past, this was
necessary since if such a check were performed, the error
message would be downgraded to a warning in the case of SHOW
CREATE VIEW. The downgrading of errors was meant to handle
only that scenario, but could not distinguish the two as it
read only the error messages.
      
The special case was needed in the fix of bug no 36086.
Before that, views were confused with derived tables.
      
After bug no 35996 was fixed, the manipulation of errors
during SHOW CREATE VIEW execution is not dependent on the
actual error messages in the queue, it rather looks at the
actual cause of the error and takes appropriate
action. Hence the aforementioned special case is now
superfluous and the bug is fixed.


mysql-test/r/view_grant.result:
  Bug#46019: Test result.
mysql-test/t/view_grant.test:
  Bug#46019: Test case.
sql/sql_parse.cc:
  Bug#46019: fix.
2009-10-16 13:12:21 +02:00
Georgi Kodinov
d80e35f26f Revert the fix for bug #47123 until test suite failures are resolved. 2009-10-16 11:42:16 +03:00
Georgi Kodinov
d6573fea19 All NDB tests made experimental after a discussion with Bernhard Ocklin. 2009-10-15 14:22:25 +03:00
Alexey Kopytov
79406bc49a Manual merge. 2009-10-15 14:42:51 +04:00
Sergey Vojtovich
eade898061 Disabled part of test for BUG#47073 until additional fix is pushed. 2009-10-15 12:31:11 +05:00
Georgi Kodinov
26b3613b0e merge 2009-10-14 18:46:45 +03:00
Georgi Kodinov
445454f728 merged 5.1-main 2009-10-14 17:30:39 +03:00
He Zhenxing
7048cfde0a Attempt to fix Windows testcase output issue 2009-10-14 21:25:11 +08:00
Sergey Vojtovich
8e65618fa9 BUG#47455 - The myisam_crash_before_flush_keys test fails on Windows
Simplified and made more determenistic myisam_crash_before_flush_keys
test.

mysql-test/r/myisam_crash_before_flush_keys.result:
  We don't need myisamchk to test this bug fix. CHECK TABLE
  after server restart is enough to ensure that the fix
  works.
mysql-test/t/myisam_crash_before_flush_keys.test:
  We don't need myisamchk to test this bug fix. CHECK TABLE
  after server restart is enough to ensure that the fix
  works.
2009-10-14 16:26:16 +05:00
Jorgen Loland
6da93b223b Bug#47280 - strange results from count(*) with order by multiple
columns without where/group
                     
Simple SELECT with implicit grouping used to return many rows if
the query was ordered by the aggregated column in the SELECT
list. This was incorrect because queries with implicit grouping
should only return a single record.
                              
The problem was that when JOIN:exec() decided if execution needed
to handle grouping, it was assumed that sum_func_count==0 meant
that there were no aggregate functions in the query. This
assumption was not correct in JOIN::exec() because the aggregate
functions might have been optimized away during JOIN::optimize().
                  
The reason why queries without ordering behaved correctly was
that sum_func_count is only recalculated if the optimizer chooses
to use temporary tables (which it does in the ordered case).
Hence, non-ordered queries were correctly treated as grouped.
                  
The fix for this bug was to remove the assumption that
sum_func_count==0 means that there is no need for grouping. This
was done by introducing variable "bool implicit_grouping" in the
JOIN object.

mysql-test/r/func_group.result:
  Add test for BUG#47280
mysql-test/t/func_group.test:
  Add test for BUG#47280
sql/opt_sum.cc:
  Improve comment for opt_sum_query()
sql/sql_class.h:
  Add comment for variables in TMP_TABLE_PARAM
sql/sql_select.cc:
  Introduce and use variable implicit_grouping instead of (!group_list && sum_func_count) in places that need to test if grouping is required. Also added comments for: optimization of aggregate fields for implicitly grouped queries  (JOIN::optimize) and choice of end_select method (JOIN::execute)
sql/sql_select.h:
  Add variable implicit_grouping, which will be TRUE for queries that contain aggregate functions but no GROUP BY clause. Also added comment to sort_and_group variable.
2009-10-14 10:46:50 +02:00
Bjorn Munch
972e938dac Bug #46007 Tests fail due to a crash while running 'check testcase before test'
Difficult to debug due to lacking report
This does not solve the real issue, but extracts server log when it happens
Forst commit was incomplete, didn't cover all cases
2009-10-14 09:31:34 +02:00
unknown
f9c6730258 Bug#46640: output from mysqlbinlog command in 5.1 breaks replication
The BINLOG statement was sharing too much code with the slave SQL thread, introduced with
the patch for Bug#32407. This caused statements to be logged with the wrong server_id, the
id stored inside the events of the BINLOG statement rather than the id of the running 
server.
      
Fix by rearranging code a bit so that only relevant parts of the code are executed by
the BINLOG statement, and the server_id of the server executing the statements will 
not be overrided by the server_id stored in the 'format description BINLOG statement'.

mysql-test/extra/binlog_tests/binlog.test:
  Added test to verify if the server_id stored in the 'format 
  description BINLOG statement' will override the server_id
  of the server executing the statements.
mysql-test/suite/binlog/r/binlog_row_binlog.result:
  Test result for bug#46640
mysql-test/suite/binlog/r/binlog_stm_binlog.result:
  Test result for bug#46640
sql/log_event.cc:
  Moved rows_event_stmt_clean() call from update_pos() to apply_event(). This in any case
  makes more sense, and is needed as update_pos() is no longer called when executing
  BINLOG statements.
  
  Moved setting of rli->relay_log.description_event_for_exec from 
  Format_description_log_event::do_update_pos() to 
  Format_description_log_event::do_apply_event()
sql/log_event_old.cc:
  Moved rows_event_stmt_clean() call from update_pos() to apply_event(). This in any case
  makes more sense, and is needed as update_pos() is no longer called when executing
  BINLOG statements.
sql/slave.cc:
  The skip flag is no longer needed, as the code path for BINLOG statement has been 
  cleaned up.
sql/sql_binlog.cc:
  Don't invoke the update_pos() code path for the BINLOG statement, as it contains code 
  that is redundant and/or harmful (especially setting thd->server_id).
2009-10-14 09:39:05 +08:00
Alexey Kopytov
bc9f56a6c2 Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN
The problem was in incorrect handling of predicates involving 
NULL as a constant value by the range optimizer.  
 
For example, when creating a SEL_ARG node from a condition of 
the form "field < const" (which would normally result in the 
"NULL < field < const" SEL_ARG),  the special case when "const" 
is NULL was not taken into account, so "NULL < field < NULL" 
was produced for the "field < NULL" condition. 
 
As a result, SEL_ARG structures of this form could not be 
further optimized which in turn could lead to incorrectly 
constructed SEL_ARG trees. In particular, code assuming SEL_ARG 
structures to always form a sequence of ordered disjoint 
intervals could enter an infinite loop under some 
circumstances. 
 
Fixed by changing get_mm_leaf() so that for any sargable 
predicate except "<=>" involving NULL as a constant, "empty" 
SEL_ARG is returned, since such a predicate is always false. 

mysql-test/r/range.result:
  Added a test case for bug #47123.
mysql-test/t/range.test:
  Added a test case for bug #47123.
sql/opt_range.cc:
  Fixed get_mm_leaf() so that for any sargable 
  predicate except "<=>" involving NULL as a constant, "empty" 
  SEL_ARG is returned, since such a predicate is always false.
2009-10-13 19:49:32 +04:00
Satya B
610213149c merge to mysql-5.1-bugteam 2009-10-13 12:48:29 +05:30
Ramil Kalimullin
662d836744 Fix for bug#47963: Wrong results when index is used
Problem: using null microsecond part (e.g. "YYYY-MM-DD HH:MM:SS.0000") 
in a WHERE condition may lead to wrong results due to improper
DATETIMEs comparison in some cases.

Fix: as we compare DATETIMEs as strings we must trim trailing 0's
in such cases.


mysql-test/r/innodb_mysql.result:
  Fix for bug#47963: Wrong results when index is used
    - test result.
mysql-test/t/innodb_mysql.test:
  Fix for bug#47963: Wrong results when index is used
    - test case.
sql/item.cc:
  Fix for bug#47963: Wrong results when index is used
    - comparing DATETIMEs trim trailing 0's in the 
  microsecond part.
2009-10-13 09:43:27 +05:00
He Zhenxing
6ba225893a Auto merge 2009-10-13 12:24:59 +08:00
unknown
1994d2c11e Bug#45578: Test binlog_tmp_table fails ramdonly on PB2: Unknown table 't2'
The bug has been closed.
2009-10-13 10:26:15 +08:00
V Narayanan
c2c12c2402 Bug#46448 trailing spaces are not ignored when user collation maps space != 0x20
changing year in copyright header to 2009.
2009-10-12 15:25:59 +05:30
V Narayanan
409773e807 Bug#46448 trailing spaces are not ignored when user collation maps space != 0x20
Fixing copyright header in test collation file.

mysql-test/std_data/latin1.xml:
  Bug#46448 trailing spaces are not ignored when user collation maps space != 0x20
  
  Fixing copy right header in test collation file.
2009-10-12 15:05:40 +05:30
V Narayanan
64e89a7ed2 Bug#46448 trailing spaces are not ignored when user collation maps space != 0x20
In MySQL when the mapping for space is changed to something other than
0x20 by defining a different collation, then space is not ignored when
comparing two strings.

This was happening because the function that performs the comparison
of two strings while ignoring ending spaces, was comparing the collation
value of a space with the ascii value of the ' ' character. This should
be changed to do comparison between the collated values.

mysql-test/r/ctype_ldml.result:
  Bug#46448 trailing spaces are not ignored when user collation maps space != 0x20
  
  Result file for test case.
mysql-test/std_data/Index.xml:
  Bug#46448 trailing spaces are not ignored when user collation maps space != 0x20
  
  Added entry for new test collation in the index file.
mysql-test/std_data/latin1.xml:
  Bug#46448 trailing spaces are not ignored when user collation maps space != 0x20
  
  Added support for new collation for test.
mysql-test/t/ctype_ldml.test:
  Bug#46448 trailing spaces are not ignored when user collation maps space != 0x20
  
  Added test case to ensure trailing spaces are not ignored.
strings/ctype-simple.c:
  Bug#46448 trailing spaces are not ignored when user collation maps space != 0x20
  
  change my_strnncollsp_simple to compare collated values when checking
  for trailing spaces. Currently the comparison happens between a collated
  value and the ascii value.
2009-10-12 13:13:15 +05:30
Tatiana A. Nurnberg
2fc28dd688 manual merge of Bug#43508 2009-10-09 23:57:43 +02:00
Sergey Vojtovich
f1c2f6e84e Merge fix for BUG47073. 2009-10-09 21:21:21 +05:00
Sergey Vojtovich
adbd70aa12 BUG#47073 - valgrind errs, corruption,failed repair of partition,
low myisam_sort_buffer_size

Repair by sort (default) or parallel repair of a MyISAM table
(doesn't matter partitioned or not) as well as bulk inserts
and enable indexes some times didn't failover to repair with
key cache.

The problem was that after unsuccessful attempt, data file was
closed. Whereas repair with key cache requires open data file.
Fixed by reopening data file.

Also fixed a valgrind warning, which may appear during repair
by sort or parallel repair with certain myisam_sort_buffer_size
number of rows and length of an index entry (very dependent).

mysql-test/r/myisam.result:
  A test case for BUG#47073.
mysql-test/t/myisam.test:
  A test case for BUG#47073.
storage/myisam/ha_myisam.cc:
  Reverted fix for BUG25289. Not needed anymore.
storage/myisam/mi_check.c:
  Reopen data file, when repair by sort or parallel repair
  fails.
  
  When repair by sort is requested to rebuild data file, data file
  gets rebuilt while fixing first index. When rebuild is completed,
  info->dfile is pointing to temporary data file, original data file
  is closed.
  
  It may happen that repair has successfully fixed first index and
  rebuilt data file, but failed to fix second index. E.g.
  myisam_sort_buffer_size was big enough to fix first shorter index,
  but not enough to fix subsequent longer index.
  
  In this case we end up with info->dfile pointing to temporary file,
  which is removed and info->dfile is set to -1.
  
  Though repair by sort failed, the upper layer may still want to
  try repair with key cache. But it needs info->dfile pointing to
  valid data file.
storage/myisam/sort.c:
  When performing a copy of IO_CACHE structure, current_pos and
  current_end must be updated separatly to point to memory we're
  copying to (not to memory we're copying from).
  
  As t_file2 is always WRITE cache, proper members are write_pos
  and write_end accordingly.
2009-10-09 21:16:29 +05:00
Martin Hansson
2ef6c821d8 Merge of bug#42846 2009-10-09 17:35:04 +02:00
Mattias Jonsson
3844852170 Bug#46922 post push update
Disable the test when it will not hit the open_files_limit
2009-10-09 16:12:01 +02:00
Satya B
2ad81fd74c Applying InnoDB Plugin 1.0.5 snapshot, part 10
From r5917 to r5940

Detailed revision comments:

r5917 | marko | 2009-09-16 04:56:23 -0500 (Wed, 16 Sep 2009) | 1 line
branches/zip: innobase_get_cset_width(): Cache the value of current_thd.
r5919 | vasil | 2009-09-16 13:37:13 -0500 (Wed, 16 Sep 2009) | 4 lines
branches/zip:

Whitespace cleanup in the ChangeLog.

r5920 | vasil | 2009-09-16 13:47:22 -0500 (Wed, 16 Sep 2009) | 4 lines
branches/zip:

Add ChangeLog entries for r5916.

r5922 | marko | 2009-09-17 01:32:08 -0500 (Thu, 17 Sep 2009) | 4 lines
branches/zip: innodb-zip.test: Make the test work with zlib 1.2.3.3.
Apparently, the definition of compressBound() has slightly changed.

This has been filed as Mantis Issue #345.
r5924 | vasil | 2009-09-17 23:59:30 -0500 (Thu, 17 Sep 2009) | 4 lines
branches/zip:

White space and formatting cleanup in the ChangeLog

r5934 | vasil | 2009-09-18 12:06:46 -0500 (Fri, 18 Sep 2009) | 4 lines
branches/zip:

Fix typo.

r5935 | calvin | 2009-09-18 16:08:02 -0500 (Fri, 18 Sep 2009) | 6 lines
branches/zip: fix bug#44338; minor non-functional changes

Bug#44338 innodb has message about non-existing option 
innodb_max_files_open. Change the option to innodb_open_files.
The fix was committed into 6.0 branch.

r5938 | calvin | 2009-09-19 02:14:25 -0500 (Sat, 19 Sep 2009) | 41 lines
branches/zip: Merge revisions 2584:2956 from branches/6.0,
except c2932.

Bug#37232 and bug#31183 were fixed in the 6.0 branch only.
They should be fixed in the plugin too, specially MySQL 6.0
is discontinued at this point.

    ------------------------------------------------------------------------
    r2604 | inaam | 2008-08-21 09:37:06 -0500 (Thu, 21 Aug 2008) | 8 lines

    branches/6.0     bug#37232

    Relax locking behaviour for REPLACE INTO t SELECT ... FROM t1.
    Now SELECT on t1 is performed as a consistent read when the isolation
    level is set to READ COMMITTED.

    Reviewed by: Heikki
    ------------------------------------------------------------------------
    r2605 | inaam | 2008-08-21 09:59:33 -0500 (Thu, 21 Aug 2008) | 7 lines

    branches/6.0

    Added a comment to clarify why distinct calls to read MySQL binary
    log file name and log position do not entail any race condition.

    Suggested by: Heikki
    ------------------------------------------------------------------------
    r2956 | inaam | 2008-11-04 04:47:30 -0600 (Tue, 04 Nov 2008) | 11 lines

    branches/6.0  bug#31183

    If the system tablespace runs out of space because 'autoextend' is
    not specified with innodb_data_file_path there was no error message
    printed to the error log. The client would get 'table full' error.
    This patch prints an appropriate error message to the error log.

    rb://43

    Approved by: Marko
    ------------------------------------------------------------------------

r5940 | vasil | 2009-09-21 00:26:04 -0500 (Mon, 21 Sep 2009) | 4 lines
branches/zip:

Add ChangeLog entries for c5938.
2009-10-09 19:07:47 +05:30
Bjorn Munch
052d9bef83 avoid regexp warning after 46625 2009-10-09 15:16:36 +02:00
Tatiana A. Nurnberg
798ce98340 Bug#43508: Renaming timestamp or date column triggers table copy
We set up DATE and TIMESTAMP differently in field-creation than we
did in field-MD creation (for CREATE). Admirably, ALTER TABLE
detected this and didn't damage any data, but it did initiate a
full copy/conversion, which we don't really need to do.

Now we describe Field and Create_field the same for those types.
As a result, ALTER TABLE that only changes meta-data (like a
field's name) no longer forces a data-copy when there needn't
be one.


mysql-test/r/alter_table.result:
  0 rows should be affected when a meta-data change is enough ALTER TABLE.
mysql-test/t/alter_table.test:
  add test-case: show that we don't do a full data-copy on ALTER TABLE
  when we don't need to.
sql/field.cc:
  Remove Field_str::compare_str_field_flags() (now in Field/Create_field as
  field_flags_are_binary().
  
  Correct some field-lengths!
sql/field.h:
  Clean-up: use defined constants rather than numeric literals for certain
  field-lengths.
  
  Add enquiry-functions binaryp() to classes Field and Create_field.
  This replaces field.cc's Field_str::compare_str_field_flags().
2009-10-09 14:41:04 +02:00
Martin Hansson
5ef9ec9d9e Bug#42846: wrong result returned for range scan when using
covering index
      
When two range predicates were combined under an OR
predicate, the algorithm tried to merge overlapping ranges
into one. But the case when a range overlapped several other
ranges was not handled. This lead to

1) ranges overlapping, which gave repeated results and 
2) a range that overlapped several other ranges was cut off.  

Fixed by 

1) Making sure that a range got an upper bound equal to the
next range with a greater minimum.
2) Removing a continue statement


mysql-test/r/group_min_max.result:
  Bug#42846: Changed query plans
mysql-test/r/range.result:
  Bug#42846: Test result.
mysql-test/t/range.test:
  Bug#42846: Test case.
sql/opt_range.cc:
  Bug#42846: The fix. 
  
  Part1: Previously, both endpoints from key2 were copied,
  which is not safe. Since ranges are processed in ascending
  order of minimum endpoints, it is safe to copy the minimum
  endpoint from key2 but not the maximum. The maximum may only
  be copied if there is no other range or the other range's
  minimum is greater than key2's maximum.
2009-10-09 11:30:40 +02:00
He Zhenxing
fa4006bc8a Bug#47323 : mysqlbinlog --verbose displays bad output when events contain subset of columns
Commit the non-NDB specific part (originated by frazer) to 5.1 mainline.
2009-10-09 16:54:48 +08:00
Mattias Jonsson
ef31b39d1d merge into mysql-5.1-bugteam 2009-10-09 09:56:07 +02:00
Mattias Jonsson
8905075456 merge into mysql-5.1-bugteam 2009-10-09 09:54:48 +02:00
Frazer Clement
c7470df2fe Merge 5.0-bugteam-> 5.1-bugteam 2009-10-08 16:36:36 +01:00
Mattias Jonsson
62395e6ffa Bug#44059: Incorrect cardinality of indexes on a partitioned table
backport for bug#44059 from mysql-pe to mysql-5.1-bugteam

Using the partition with most rows instead of first partition
to estimate the cardinality of indexes.

mysql-test/r/partition.result:
  Bug#44059: Incorrect cardinality of indexes on a partitioned table
  
  Added test result
mysql-test/t/partition.test:
  Bug#44059: Incorrect cardinality of indexes on a partitioned table
  
  Added test case
sql/ha_partition.cc:
  Bug#44059: Incorrect cardinality of indexes on a partitioned table
  
  Checking which partition that has the most rows, and using that
  partition for HA_STATUS_CONST instead of first partition
2009-10-08 15:58:17 +02:00
Mattias Jonsson
0186334ae8 Bug#46922: crash when adding partitions and open_files_limit
is reached

Problem was bad error handling, leaving some new temporary
partitions locked and initialized and some not yet initialized
and locked, leading to a crash when trying to unlock the not
yet initialized and locked partitions

Solution was to unlock the already locked partitions, and not
include any of the new temporary partitions in later unlocks

mysql-test/r/partition_open_files_limit.result:
  Bug#46922: crash when adding partitions and open_files_limit
  is reached
  
  New test result
mysql-test/t/partition_open_files_limit-master.opt:
  Bug#46922: crash when adding partitions and open_files_limit
  is reached
  
  New test opt-file for testing when open_files_limit is reached
mysql-test/t/partition_open_files_limit.test:
  Bug#46922: crash when adding partitions and open_files_limit
  is reached
  
  New test case testing when open_files_limit is reached
sql/ha_partition.cc:
  Bug#46922: crash when adding partitions and open_files_limit
  is reached
  
  When cleaning up the partitions already locked need to be unlocked,
  and not be unlocked/closed after cleaning up.
2009-10-08 15:36:43 +02:00
Georgi Kodinov
0d0f06da3a automerge 2009-10-08 16:24:58 +03:00
Bjorn Munch
79060e12ee Remove obsolete comments after fixing 42408 2009-10-08 14:31:39 +02:00
Magnus Blåudd
0b1fdf0bd8 BUG#47129 fix small bug in test 2009-10-08 14:00:43 +02:00
Ramil Kalimullin
3185118e1a Fix for bug #42803: Field_bit does not have unsigned_flag field,
can lead to bad memory access

Problem: Field_bit is the only field which returns INT_RESULT
and doesn't have unsigned flag. As it's not a descendant of the 
Field_num, so using ((Field_num *) field_bit)->unsigned_flag may lead
to unpredictable results.

Fix: check the field type before casting.


mysql-test/r/type_bit.result:
  Fix for bug #42803: Field_bit does not have unsigned_flag field,
  can lead to bad memory access
    - test result.
mysql-test/t/type_bit.test:
  Fix for bug #42803: Field_bit does not have unsigned_flag field,
  can lead to bad memory access
    - test case.
sql/opt_range.cc:
  Fix for bug #42803: Field_bit does not have unsigned_flag field,
  can lead to bad memory access
    - don't cast to (Field_num *) Field_bit, as it's not a Field_num
  descendant and is always unsigned by nature.
2009-10-08 16:56:31 +05:00
Satya B
abfdf76bbf Applying InnoDB Plugin 1.0.5 snapshot, part 4
From revision r5703 to r5716

Detailed revision comments:

r5703 | marko | 2009-08-27 02:25:00 -0500 (Thu, 27 Aug 2009) | 41 lines
branches/zip: Replace the constant 3/8 ratio that controls the LRU_old
size with the settable global variable innodb_old_blocks_pct. The
minimum and maximum values are 5 and 95 per cent, respectively. The
default is 100*3/8, in line with the old behavior.

ut_time_ms(): New utility function, to return the current time in
milliseconds. TODO: Is there a more efficient timestamp function, such
as rdtsc divided by a power of two?

buf_LRU_old_threshold_ms: New variable, corresponding to
innodb_old_blocks_time. The value 0 is the default behaviour: no
timeout before making blocks 'new'.

bpage->accessed, bpage->LRU_position, buf_pool->ulint_clock: Remove.

bpage->access_time: New field, replacing bpage->accessed. Protected by
buf_pool_mutex instead of bpage->mutex. Updated when a page is created
or accessed the first time in the buffer pool.

buf_LRU_old_ratio, innobase_old_blocks_pct: New variables,
corresponding to innodb_old_blocks_pct

buf_LRU_old_ratio_update(), innobase_old_blocks_pct_update(): Update
functions for buf_LRU_old_ratio, innobase_old_blocks_pct.

buf_page_peek_if_too_old(): Compare ut_time_ms() to bpage->access_time
if buf_LRU_old_threshold_ms && bpage->old.  Else observe
buf_LRU_old_ratio and bpage->freed_page_clock.

buf_pool_t: Add n_pages_made_young, n_pages_not_made_young,
n_pages_made_young_old, n_pages_not_made_young, for statistics.

buf_print(): Display buf_pool->n_pages_made_young,
buf_pool->n_pages_not_made_young.  This function is only for crash
diagnostics.

buf_print_io(): Display buf_pool->LRU_old_len and quantities derived
from buf_pool->n_pages_made_young, buf_pool->n_pages_not_made_young.
This function is invoked by SHOW ENGINE INNODB STATUS.

rb://129 approved by Heikki Tuuri.  This addresses Bug #45015.
r5704 | marko | 2009-08-27 03:31:17 -0500 (Thu, 27 Aug 2009) | 32 lines
branches/zip: Fix a critical bug in fast index creation that could
corrupt the created indexes.

row_merge(): Make "half" an in/out parameter. Determine the offset of
half the output file. Copy the last blocks record-by-record instead of
block-by-block, so that the records can be counted. Check that the
input and output have matching n_rec.

row_merge_sort(): Do not assume that two blocks of size N are merged
into a block of size 2*N. The output block can be shorter than the
input if the last page of each input block is almost empty. Use an
accurate termination condition, based on the "half" computed by
row_merge().

row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.

merge_file_t, row_merge_file_create(): Add n_rec, the number of records
in the merge file.

row_merge_read_clustered_index(): Update n_rec.

row_merge_blocks(): Update and check n_rec.

row_merge_blocks_copy(): New function, for copying the last blocks in
row_merge().  Update and check n_rec.

This bug was discovered with a user-supplied test case that creates an
index where the initial temporary file is 249 one-megabyte blocks and
the merged files become smaller. In the test, possible merge record
sizes are 10, 18, and 26 bytes.

rb://150 approved by Sunny Bains.  This addresses Issue #320.
r5705 | marko | 2009-08-27 06:56:24 -0500 (Thu, 27 Aug 2009) | 11 lines
branches/zip: dict_index_find_cols(): On column name lookup failure,
return DB_CORRUPTION (HA_ERR_CRASHED) instead of abnormally
terminating the server.  Also, disable the previously added diagnostic
output to the error log, because mysql-test-run does not like extra
output in the error log.  (Bug #44571)

dict_index_add_to_cache(): Handle errors from dict_index_find_cols().

mysql-test/innodb_bug44571.test: A test case for triggering the bug.

rb://135 approved by Sunny Bains.
r5706 | inaam | 2009-08-27 11:00:27 -0500 (Thu, 27 Aug 2009) | 20 lines
branches/zip rb://147

Done away with following two status variables:

innodb_buffer_pool_read_ahead_rnd
innodb_buffer_pool_read_ahead_seq

Introduced two new status variables:
innodb_buffer_pool_read_ahead = number of pages read as part of
readahead since server startup
innodb_buffer_pool_read_ahead_evicted = number of pages that are read
in as readahead but were evicted before ever being accessed since
server startup i.e.: a measure of how badly our readahead is
performing

SHOW INNODB STATUS will show two extra numbers in buffer pool section:
pages read ahead/sec and pages evicted without access/sec

Approved by: Marko

r5707 | inaam | 2009-08-27 11:20:35 -0500 (Thu, 27 Aug 2009) | 6 lines
branches/zip

Remove unused macros as we erased the random readahead code in r5703.
Also fixed some comments.


r5708 | inaam | 2009-08-27 17:43:32 -0500 (Thu, 27 Aug 2009) | 4 lines
branches/zip

Remove redundant TRUE : FALSE from the return statement

r5709 | inaam | 2009-08-28 01:22:46 -0500 (Fri, 28 Aug 2009) | 5 lines
branches/zip rb://152

Disable display of deprecated parameter innodb_file_io_threads in
'show variables'.

r5714 | marko | 2009-08-31 01:10:10 -0500 (Mon, 31 Aug 2009) | 5 lines
branches/zip: buf_chunk_not_freed(): Do not acquire block->mutex unless
block->page.state == BUF_BLOCK_FILE_PAGE.  Check that block->page.state
makes sense.

Approved by Sunny Bains over the IM.
r5716 | vasil | 2009-08-31 02:47:49 -0500 (Mon, 31 Aug 2009) | 9 lines
branches/zip:

Fix Bug#46718 InnoDB plugin incompatible with gcc 4.1 (at least: on PPC): "Undefined symbol"

by implementing our own check in plug.in instead of using the result from
the check from MySQL because it is insufficient.

Approved by:	Marko (rb://154)
2009-10-08 16:58:37 +05:30
Magnus Blåudd
8f7f8b5a74 Merge 2009-10-08 13:25:11 +02:00
Bjorn Munch
9edd40c87e Bug #47218 mysqltest ignores "error" command inside if inside loop
This was affected by same problem as append_file etc.
Added Q_ERROR to special handling, and added small test
2009-10-08 11:30:03 +02:00
Bjorn Munch
b1b958ffab Bug #47716 mtr2 prints obscure error when started with -gdb and xterm is missing
Tried to use an expression inside ""
Go via variable, and add $exe to the output
2009-10-08 11:23:04 +02:00
Bjorn Munch
0aca4f0011 Bug #46625 Pushbuild2: does not notice test failure in "Innodb Plugin" mode
Disallow (and don't use) space in combination names
2009-10-08 11:14:42 +02:00
Satya B
d88861948d Applying InnoDB Plugin 1.0.5 snapshot , part 1
From revision r5537 to r5636
r5527 is already applied before

Detailed revision comments:
For HotBackup builds we don't want to hide the symbols.

r5537 | vasil | 2009-07-21 04:31:26 -0500 (Tue, 21 Jul 2009) | 5 lines
branches/zip:

Fixups in ChangeLog: sort filenames alphabetically and wrap to 78 chars per
line.

r5539 | vasil | 2009-07-21 05:28:27 -0500 (Tue, 21 Jul 2009) | 4 lines
branches/zip:

Add a test program to check whether the PAUSE instruction is available.

r5625 | vasil | 2009-08-04 00:52:48 -0500 (Tue, 04 Aug 2009) | 32 lines
branches/zip: Merge 5518:5622 from branches/5.1, resolving conflict in r5622
(after resolving the conflict Makefile.am was not changed so I have made
a dummy change so I can commit and thus record that branches/5.1 has been
merged in branches/zip up to 5622):

  ------------------------------------------------------------------------
  r5622 | vasil | 2009-08-03 15:27:00 +0300 (Mon, 03 Aug 2009) | 20 lines
  Changed paths:
     M /branches/5.1/Makefile.am
  
  branches/5.1:
  
  Merge a change from MySQL:
  
    ------------------------------------------------------------
    revno: 2988
    committer: Satya B <satya.bn@sun.com>
    branch nick: mysql-5.1-bugteam
    timestamp: Wed 2009-07-01 11:06:05 +0530
    message:
      Fix build failure after applying Innodb snapshot 5.1-ss5282
      
      After applying Innodb snapshot 5.1-ss5282, build was broken
      because of missing header file. 
      
      Adding the header file to Makefile.am after informing the 
      innodb developers.
    modified:
      storage/innobase/Makefile.am
  
  ------------------------------------------------------------------------

r5626 | vasil | 2009-08-04 00:53:31 -0500 (Tue, 04 Aug 2009) | 4 lines
branches/zip:

Revert the dummy change from c5625.

r5629 | marko | 2009-08-04 06:42:44 -0500 (Tue, 04 Aug 2009) | 1 line
branches/zip: mysql-test: Pass MTR's internal checks.
r5635 | marko | 2009-08-05 06:06:55 -0500 (Wed, 05 Aug 2009) | 2 lines
branches/zip: Replace <number> with NUMBER in some comments,
to avoid problems with Doxygen XML output.
r5636 | marko | 2009-08-05 07:27:30 -0500 (Wed, 05 Aug 2009) | 2 lines
branches/zip: lock_rec_validate_page(): Add the parameter zip_size.
This should help track down Mantis Issue #289.
2009-10-08 14:43:16 +05:30
Magnus Blåudd
fabde82dbd Bug#47801 The plugin test fails with the Embedded Server on Windows
- Remove the "hack" from mtr.pl that skipped searching for the .dll files
  when embedded and windows. Now the variables will be preoperly initialized.
 - Make the tests detect that they can't run on windows+embedded
2009-10-08 10:39:15 +02:00
Magnus Blåudd
7a633b68d2 Merge 2009-10-08 10:32:43 +02:00
Luis Soares
9226c847f5 BUG#44661: automerge local 5.1-bt bug branch --> local 5.1-bt up to date 2009-10-07 22:26:36 +01:00
Georgi Kodinov
1a48dd4e2b Bug #43029: FORCE INDEX FOR ORDER BY is ignored when join
buffering is used

FORCE INDEX FOR ORDER BY now prevents the optimizer from 
using join buffering. As a result the optimizer can use
indexed access on the first table and doesn't need to 
sort the complete resultset at the end of the statement.
2009-10-07 18:03:42 +03:00
Vladislav Vaintroub
b96230c858 merge 2009-10-07 16:34:45 +02:00
Magnus Blåudd
610778dcce BUG#47612 - fix review comment 2009-10-07 16:25:36 +02:00
Magnus Blåudd
6ff8f716c3 Bug#47867 compiler warning _WIN32_WINNT macro redefinition
- Remove the conflicting macro definitions since we define a higher value
   directly in the cmake files.
2009-10-06 18:10:34 +02:00
Bjorn Munch
6eb9c2bec9 merge of 47383 from 5.1-mtr 2009-10-06 14:37:37 +02:00
Alfranio Correia
15127bcdf3 mysql-5.1-bugteam (local) --> mysql-5.1-bugteam 2009-10-06 11:25:36 +01:00
Bjorn Munch
3141528ea8 Bug #47811 ./mysql-test-run.pl --valgrind uses old (too narrow) allignment
Remove the alignment option, let valgrind use its default
2009-10-06 10:42:05 +02:00
Bjorn Munch
109ae607fb Bug #46327 MTR2 prevents gcov data accumulation
mysqladmin fails on Linux in 6.0 without --character-sets-dir
Also added timeout for server shutdown, hope this will solve it
2009-10-06 10:35:35 +02:00
Georgi Kodinov
b202a9860c merge mysql-5.1-pe 2009-10-06 10:10:47 +03:00
Alfranio Correia
7e0da4352c BUG#47678 Changes to n-tables that happen early in a trans. are only flushed upon commit
Let
    - T be a transactional table and N non-transactional table.
    - B be begin, C commit and R rollback.
    - N be a statement that accesses and changes only N-tables.
    - T be a statement that accesses and changes only T-tables.

In RBR, changes to N-tables that happen early in a transaction are not immediately flushed
upon committing a statement. This behavior may, however, break consistency in the presence
of concurrency since changes done to N-tables become immediately visible to other
connections. To fix this problem, we do the following:

  . B N N T C would log - B N C B N C B T C.
  . B N N T R would log - B N C B N C B T R.

Note that we are not preserving history from the master as we are introducing a commit that
never happened. However, this seems to be more acceptable than the possibility of breaking
consistency in the presence of concurrency.
2009-10-06 01:54:00 +01:00
Alfranio Correia
14d1909440 BUG#47287 RBR: replication diff on basic case with txn- and non-txn tables in a statement
Let
  - T be a transactional table and N non-transactional table.
  - B be begin, C commit and R rollback.
  - M be a mixed statement, i.e. a statement that updates both T and N.
  - M* be a mixed statement that fails while updating either T or N.

This patch restore the behavior presented in 5.1.37 for rows either produced in
the RBR or MIXED modes, when a M* statement that happened early in a transaction
had their changes written to the binary log outside the boundaries of the
transaction and wrapped in a BEGIN/ROLLBACK. This was done to keep the slave
consistent with with the master as the rollback would keep the changes on N and
undo them on T. In particular, we do what follows:

  . B M* T C would log - B M* R B T C.

Note that, we are not preserving history from the master as we are introducing a
rollback that never happened. However, this seems to be more acceptable than
making the slave diverge. We do not fix the following case:

  . B T M* C would log B T M* C.

The slave will diverge as the changes on T tables that originated from the M
statement are rolled back on the master but not on the slave. Unfortunately, we
cannot simply rollback the transaction as this would undo any uncommitted
changes on T tables.

SBR is not considered in this patch because a failing statement is written to
the binary along with the error code and a slave executes and then rolls back
the statement when it has an associated error code, thus undoing the effects
on T. In RBR and MBR, a full-fledged fix will be pushed after the WL 2687.
2009-10-06 01:38:58 +01:00
John H. Embretsen
85bb4aa09e Bug#47746 - main.innodb_mysql fails sporadically:
Mask part of EXPLAIN output with '#' to account for varying row count estimation.

mysql-test/include/mix1.inc:
  Mask 'rows' column in EXPLAIN output (number varies sometimes between 1 and 2).
mysql-test/r/innodb_mysql.result:
  Update result file after masking of rows estimation in EXPLAIN output.
2009-10-05 15:16:27 +02:00
Satya B
95c6cc51a5 Applying InnoDB snapshot 5.1-ss5921, part 2. Fixes BUG#44369
BUG#44369 - InnoDB: Does not uniformly disallow disallowed column names

Detailed revision comments:

r5741 | jyang | 2009-09-03 07:16:01 +0300 (Thu, 03 Sep 2009) | 5 lines
branches/5.1: Block creating table with column name conflicting
with Innodb reserved key words. (Bug #44369) rb://151 approved
by Sunny Bains.


r5760 | jyang | 2009-09-04 07:07:34 +0300 (Fri, 04 Sep 2009) | 3 lines
branches/5.1: This is to revert change 5741. A return status for
create_table_def() needs to be fixed.

r5834 | jyang | 2009-09-11 00:43:05 +0300 (Fri, 11 Sep 2009) | 5 lines
branches/5.1: Block creating table with column name conflicting
with Innodb reserved key words. (Bug #44369) rb://151 approved
by Sunny Bains.
2009-10-05 16:47:48 +05:30
Satya B
b9ce9f79d6 Applying InnoDB snapshot 5.1-ss5921, Part 1. Fixes BUG#46000
1. BUG#46000 - using index called GEN_CLUST_INDEX crashes server

Detailed revision comments:

r5895 | jyang | 2009-09-15 03:39:21 +0300 (Tue, 15 Sep 2009) | 5 lines
branches/5.1: Disallow creating index with the name of
"GEN_CLUST_INDEX" which is reserved for the default system
primary index. (Bug #46000) rb://149 approved by Marko Makela.
2009-10-05 16:39:07 +05:30
Bjorn Munch
861cf983fc Bug #47243 Allow MTR to read max auto setting for --parallel from env. variable
In stead of hard-coded 8, read from $MTR_MAX_PARALLEL if set
2009-10-05 13:08:10 +02:00
Georgi Kodinov
00968ae167 fixed typos in exeprimental list 2009-10-05 11:18:59 +03:00
Gleb Shchepa
33cd911a16 Bug #44139: Table scan when NULL appears in IN clause
SELECT ... WHERE ... IN (NULL, ...) does full table scan,
even if the same query without the NULL uses efficient range scan.

The bugfix for the bug 18360 introduced an optimization:
if
  1) all right-hand arguments of the IN function are constants
  2) result types of all right argument items are compatible
     enough to use the same single comparison function to
     compare all of them to the left argument,

then

  we can convert the right-hand list of constant items to an array
  of equally-typed constant values for the further
  QUICK index access etc. (see Item_func_in::fix_length_and_dec()).

The Item_null constant item objects have STRING_RESULT
result types, so, as far as Item_func_in::fix_length_and_dec()
is aware of NULLs in the right list, this improvement efficiently
optimizes IN function calls with a mixed right list of NULLs and
string constants. However, the optimization doesn't affect mixed
lists of NULLs and integers, floats etc., because there is no
unique common comparator.


New optimization has been added to ignore the result type
of NULL constants in the static analysis of mixed right-hand lists.
This is safe, because at the execution phase we care about
presence of NULLs anyway.

1. The collect_cmp_types() function has been modified to optionally
   ignore NULL constants in the item list.
2. NULL-skipping code of the Item_func_in::fix_length_and_dec()
   function has been modified to work not only with in_string
   vectors but with in_vectors of other types.


mysql-test/r/func_in.result:
  Added test case for the bug #44139.
mysql-test/t/func_in.test:
  Added test case for the bug #44139.
sql/item_cmpfunc.cc:
  Bug #44139: Table scan when NULL appears in IN clause
  
  1. The collect_cmp_types() function has been modified to optionally
     ignore NULL constants in the item list.
  2. NULL-skipping code of the Item_func_in::fix_length_and_dec()
     function has been modified to work not only with in_string
     vectors but with in_vectors of other types.
2009-10-05 10:27:36 +05:00
Georgi Kodinov
39c7863dd6 rpl.rpl_trigger made experimental because of bug #47810 :
rpl.rpl_trigger.test fails with valgrind errors with the innodb plugin
2009-10-04 13:31:55 +03:00
Georgi Kodinov
103cd1898a Make innodb-autoinc.test experimental until bug#47809 is fixed. 2009-10-04 13:16:56 +03:00
Georgi Kodinov
795a335b33 Disable innodb_information_schema.test until bug #47808 is fixed. 2009-10-04 13:15:53 +03:00
Ingo Struewing
91178418a2 auto-merge 2009-10-02 13:27:48 +02:00
Bjorn Munch
28b190b272 Bug #47383 let mysql-test-run.pl run innodb tests using the plugin
Alt. solution: let the "InnoDB plugin" combinations apply
Added some alternative plugin paths (I need to move the code anyway)
2009-10-02 10:36:38 +02:00
Ingo Struewing
1f37e3d834 auto-merge 2009-10-01 15:54:11 +02:00
unknown
41e0d0a3ab Bug #45677 Slave stops with Duplicate entry for key PRIMARY when using trigger
The problem is that there is only one autoinc value associated with 
the query when binlogging. If more than one autoinc values are used 
in the query, the autoinc values after the first one can be inserted 
wrongly on slave. So these autoinc values can become inconsistent on 
master and slave.

The problem is resolved by marking all the statements that invoke 
a trigger or call a function that updated autoinc fields as unsafe, 
and will switch to row-format in Mixed mode. Actually, the statement 
is safe if just one autoinc value is used in sub-statement, but it's 
impossible to check how many autoinc values are used in sub-statement.)

mysql-test/suite/rpl/r/rpl_auto_increment_update_failure.result:
  Test result for bug#45677
mysql-test/suite/rpl/t/rpl_auto_increment_update_failure.test:
  Added test to verify the following two properties:
  P1) insert/update in an autoinc column causes statement to 
  be logged in row format if binlog_format=mixed
  P2) if binlog_format=mixed, and a trigger or function contains 
      two or more inserts/updates in a table that has an autoinc 
      column, then the slave should not go out of sync, even if 
      there are concurrent transactions.
sql/sql_base.cc:
  Added function 'has_write_table_with_auto_increment' to check 
  if one (or more) write tables have auto_increment columns.
  
  Removed function 'has_two_write_locked_tables_with_auto_increment', 
  because the function is included in function 
  'has_write_table_with_auto_increment'.
2009-10-01 07:19:36 +08:00
Davi Arnaut
436ccb6984 Manual merge. 2009-09-30 19:25:06 -03:00
Davi Arnaut
565f1bc4a1 Bug#47525: MySQL crashed (Federated)
On Mac OS X or Windows, sending a SIGHUP to the server or a
asynchronous flush (triggered by flush_time), would cause the
server to crash.

The problem was that a hook used to detach client API handles
wasn't prepared to handle cases where the thread does not have
a associated session.

The solution is to verify whether the thread has a associated
session before trying to detach a handle.

mysql-test/r/federated_debug.result:
  Add test case result for Bug#47525
mysql-test/t/federated_debug-master.opt:
  Debug point.
mysql-test/t/federated_debug.test:
  Add test case for Bug#47525
sql/slave.cc:
  Check whether a the thread has a associated session.
sql/sql_parse.cc:
  Add debug code to simulate a reload without thread session.
2009-09-30 18:38:02 -03:00
Martin Hansson
f0deca7377 Merge of Bug#35996 2009-09-30 09:31:20 +02:00
unknown
508527a94c Bug #46998 mysqlbinlog can't output BEGIN even if the database is included in a transaction
The 'BEGIN/COMMIT/ROLLBACK' log event could be filtered out if the
database is not selected by --database option of mysqlbinlog command.
This can result in problem if there are some statements in the
transaction are not filtered out.

To fix the problem, mysqlbinlog will output 'BEGIN/ROLLBACK/COMMIT' 
in regardless of the database filtering rules.

client/mysqlbinlog.cc:
  Skip the database check for BEGIN/COMMIT/ROLLBACK log events.
mysql-test/r/mysqlbinlog.result:
  Test result for bug#46998
mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test:
  The test case is updated duo to the patch of bug#46998
mysql-test/t/mysqlbinlog.test:
  Added test to verify if the 'BEGIN', 'COMMIT' and 'ROLLBACK' are output
  in regardless of database filtering
2009-09-30 10:31:25 +08:00
unknown
de04eb6c37 Bug #46998 mysqlbinlog can't output BEGIN even if the database is included in a transaction
The 'BEGIN/COMMIT/ROLLBACK' log event could be filtered out if the
database is not selected by --database option of mysqlbinlog command.
This can result in problem if there are some statements in the
transaction are not filtered out.

To fix the problem, mysqlbinlog will output 'BEGIN/ROLLBACK/COMMIT' 
in regardless of the database filtering rules.

client/mysqlbinlog.cc:
  Skip the database check for BEGIN/COMMIT/ROLLBACK log events.
mysql-test/r/mysqlbinlog.result:
  Test result for bug#46998
mysql-test/t/mysqlbinlog.test:
  Added test to verify if the 'BEGIN', 'COMMIT' and 'ROLLBACK' are output
  in regardless of database filtering
2009-09-30 10:01:52 +08:00
Vladislav Vaintroub
017a0fd20d Bug #47731 mtr freezes for many seconds when process to be killed has already gone.
The problem is that safe_kill_win fails to detect a dead process. OpenProcess() will 
succeed even after the process died, it will first fail after the last handle to process 
is closed.

To fix the problem, check process status with GetExitCodeProcess() and consider 
process to be dead if the exit code returned by this routine is not STILL_ALIVE.
2009-09-30 00:19:00 +02:00