Commit graph

105 commits

Author SHA1 Message Date
Sergey Glukhov
278ae9a8d5 Bug#53334 Incorrect result for InnoDB in LEFT JOIN with impossible condition
The fix actually reverts the change introduced
by the patch for bug 51494.
The fact is that patches for bugs 52177&48419
fix bugs 51194&50575 as well.



mysql-test/r/innodb_mysql.result:
  test case
mysql-test/t/innodb_mysql.test:
  test case
sql/sql_select.cc:
  reverted wrong fix for bug 51494
2010-05-07 10:38:42 +05:00
Georgi Kodinov
4d0e9957ac Bug #47453: InnoDB incorrectly changes TIMESTAMP columns when JOINed
during an UPDATE

Extended the fix for bug 29310 to multi-table update:

When a table is being updated it has two set of fields - fields required for
checks of conditions and fields to be updated. A storage engine is allowed
not to retrieve columns marked for update. Due to this fact records can't
be compared to see whether the data has been changed or not. This makes the
server always update records independently of data change.
  
Now when an auto-updatable timestamp field is present and server sees that
a table handle isn't going to retrieve write-only fields then all of such
fields are marked as to be read to force the handler to retrieve them.
2010-04-28 15:55:54 +03:00
Georgi Kodinov
ae49d9710b Bug #49838: DROP INDEX and ADD UNIQUE INDEX for same index may corrupt
definition at engine

If a single ALTER TABLE contains both DROP INDEX and ADD INDEX using 
the same index name (a.k.a. index modification) we need to disable 
in-place alter table because we can't ask the storage engine to have 
two copies of the index with the same name even temporarily (if we 
first do the ADD INDEX and then DROP INDEX) and we can't modify 
indexes that are needed by e.g. foreign keys if we first do 
DROP INDEX and then ADD INDEX.
Fixed the problem by disabling in-place ALTER TABLE for these cases.
2010-03-17 16:18:46 +02:00
Gleb Shchepa
63a88e1373 Bug #39653: find_shortest_key in sql_select.cc does not
consider clustered primary keys

Choosing a shortest index for the covering index scan,
the optimizer ignored the fact, that the clustered primary
key read involves whole table data.

The find_shortest_key function has been modified to
take into account that fact that a clustered PK has a
longest key of possible covering indices.


mysql-test/r/innodb_mysql.result:
  Test case for bug #39653.
mysql-test/t/innodb_mysql.test:
  Test case for bug #39653.
sql/sql_select.cc:
  Bug #39653: find_shortest_key in sql_select.cc does not
              consider clustered primary keys
  
  The find_shortest_key function has been modified to
  take into account that fact that a clustered PK has a
  longest key of possible covering indices.
2010-03-05 23:45:55 +04:00
Evgeny Potemkin
2d4db52eda Bug#50843: Filesort used instead of clustered index led to
performance degradation.

Filesort + join cache combination is preferred to full index scan because it
is usually faster. But it's not the case when the index is clustered one.

Now test_if_skip_sort_order function prefers filesort only if index isn't
clustered.

mysql-test/r/innodb_mysql.result:
  Added a test case for the bug#50843.
mysql-test/t/innodb_mysql.test:
  Added a test case for the bug#50843.
sql/sql_select.cc:
  Bug#50843: Filesort used instead of clustered index led to
  performance degradation.
  Now test_if_skip_sort_order function prefers filesort only if index isn't
  clustered.
2010-02-26 14:17:00 +03:00
Georgi Kodinov
6d38c898a6 Bug #49324: more valgrind errors in test_if_skip_sort_order
Fixed 2 problems :
1. test_if_order_by_key() was continuing on the primary key
as if it has a primary key suffix (as the secondary keys do).
This leads to crashes in ORDER BY <pk>,<pk>.
Fixed by not treating the primary key as the secondary one
and not depending on it being clustered with a primary key.
2. The cost calculation was trying to read the records 
per key when operating on ORDER BYs that order on all of the 
secondary key + some of the primary key.
This leads to crashes because of out-of-bounds array access.
Fixed by assuming we'll find 1 record per key in such cases.
2010-01-29 17:04:37 +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
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
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
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
Georgi Kodinov
33380cf0b7 Bug #36259 (Optimizing with ORDER BY) and bug#45828 (Optimizer won't
use partial primary key if another index can prevent filesort

The fix for bug #28404 causes the covering ordering indexes to be 
preferred unconditionally over non-covering and ref indexes.

Fixed by comparing the cost of using a covering index to the cost of
using a ref index even for covering ordering indexes.
Added an assertion to clarify the condition the local variables should
be in.

mysql-test/include/mix1.inc:
  Bug #36259: fixed a non-stable test case
mysql-test/r/innodb_mysql.result:
  Bug #36259 and #45828 : test case
mysql-test/t/innodb_mysql.test:
  Bug #36259 and #45828 : test case
sql/sql_select.cc:
  Bug #36259 and #45828 : don't consider covering indexes supperior to
  ref keys.
2009-07-07 15:52:34 +03:00
Gleb Shchepa
ed7f0f3023 Bug #44886: SIGSEGV in test_if_skip_sort_order() -
uninitialized variable used as subscript

Grouping select from a "constant" InnoDB table (a table
of a single row) joined with other tables caused a crash.


mysql-test/r/innodb_mysql.result:
  Added test case for bug bug #44886.
mysql-test/t/innodb_mysql.test:
  Added test case for bug bug #44886.
sql/sql_select.cc:
  Bug #44886: SIGSEGV in test_if_skip_sort_order() -
              uninitialized variable used as subscript
  
  1. The test_if_order_by_key function returned unitialized
     used_key_parts parameter in case of a "constant" InnoDB
     table. Calling function uses this parameter values as
     an array index, thus sometimes it caused a crash.
     The test_if_order_by_key function has been modified
     to set used_key_parts to 0 (no need for ordering).
  
  2. The test_if_skip_sort_order function has been
     modified to accept zero used_key_parts value and
     to prevent an array access by negative index.
2009-06-08 01:40:53 +05:00
Martin Hansson
391364fac7 Bug#43580: Issue with Innodb on multi-table update
Certain multi-updates gave different results on InnoDB from
to MyISAM, due to on-the-fly updates being used on the former and
the update order matters.
Fixed by turning off on-the-fly updates when update order 
dependencies are present.


mysql-test/r/innodb_mysql.result:
  Bug#43580: Test result.
mysql-test/suite/rpl/r/rpl_slave_skip.result:
  Bug#43580: Changed test result. The InnoDB result is now what it would have been on MyISAM.
mysql-test/t/innodb_mysql.test:
  Bug#43580: Test case.
sql/sql_base.cc:
  Bug#43580: Added a word of caution about using tmp_set here.
sql/sql_update.cc:
  Bug#43580: Fix.
  Calls to TABLE::mark_columns_needed_for_update() are moved
  from mysql_multi_update_prepare() and right before the decison
  to do on-the-fly updates to the place where we do (or don't do)
  on-the-fly updates.
2009-05-05 11:38:19 +02:00
Kristofer Pettersson
a20bc967ce Bug#40127 Multiple table DELETE IGNORE hangs on foreign key constraint violation
on 5.0            
The server crashes on an assert in net_end_statement indicating that the
Diagnostics area wasn't set properly during execution.
This happened on a multi table DELETE operation using the IGNORE keyword.
The keyword is suppose to allow for execution to continue on a best effort
despite some non-fatal errors. Instead execution stopped and no client
response was sent which would have led to a protocol error if it hadn't been
for the assert.
This patch corrects this issue by checking for the existence of an IGNORE
option before setting an error state during row-by-row delete iteration.


mysql-test/r/innodb_mysql.result:
  * Added test case for bug40127
mysql-test/t/innodb_mysql.test:
  * Added test case for bug40127
sql/sql_delete.cc:
  * IGNORE option wasn't implemented in multi_delete::send_data
    and multi_delete::do_deletes
2009-03-27 17:08:14 +01:00
Georgi Kodinov
1f6d6fa905 merged 5.0-bugteam -> 5.1-bugteam 2009-02-20 11:50:50 +02:00
Georgi Kodinov
a67725ac75 Bug #42419: test suite fix
Moved the test case for the bug into a separate file (and restored the 
original innodb_mysql test setup).
Used the new wait_show_condition test macro to avoid the usage of sleep

mysql-test/include/wait_show_condition.inc:
  Bug #42419: new test macro to wait for a row in SHOW to have a certain value.
mysql-test/r/innodb_bug42419.result:
  Bug #42419: test case
mysql-test/r/innodb_mysql.result:
  Bug #42419: revert to the original innodb_mysql test
mysql-test/t/innodb_bug42419.test:
  Bug #42419: test case
mysql-test/t/innodb_mysql-master.opt:
  Bug #42419: revert to the original innodb_mysql test
mysql-test/t/innodb_mysql.test:
  Bug #42419: revert to the original innodb_mysql test
2009-02-20 11:12:06 +02:00
Georgi Kodinov
901427b241 merged 5.0-bugteam -> 5.1-bugteam 2009-02-19 20:30:05 +02:00
Georgi Kodinov
29476d879f Bug #42419: Server crash with "Pure virtual method called" on two concurrent
connections
The problem is that tables can enter open table cache for a thread without 
being properly cleaned up. This can happen if make_join_statistics() fails 
to read a const table because of e.g. a deadlock. It does set a member of 
TABLE structure to a value it allocates, but doesn't clean-up this setting 
on error nor does it set the rest of the members in JOIN to allow for 
automatic cleanup.
As a result when such an error occurs and the next statement depends re-uses 
the table from the open tables cache it will get it with this 
TABLE::reginfo.join_tab pointing to a memory area that's freed.
Fixed by making sure make_join_statistics() cleans up TABLE::reginfo.join_tab 
on error.

mysql-test/r/innodb_mysql.result:
  Bug #42419: test case
mysql-test/t/innodb_mysql-master.opt:
  Bug #42419: increase the timeout so it covers te conservative 
  sleep 3 in the test
mysql-test/t/innodb_mysql.test:
  Bug #42419: test case
sql/sql_select.cc:
  Bug #42419: clean up the members of TABLE on failure in 
          make_join_statisitcs()
2009-02-19 17:30:03 +02:00
Davi Arnaut
8dbb9c885d Bug#37016: TRUNCATE TABLE removes some rows but not all
The special TRUNCATE TABLE (DDL) transaction wasn't being properly
rolled back if a error occurred during row by row deletion. The
error can be caused by a foreign key restriction imposed by InnoDB
SE and would cause the server to erroneously issue a implicit
commit.

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

mysql-test/include/commit.inc:
  Truncate always starts a transaction and commits at the end.
  The commit at the end increases the count by two, one is the
  storage engine commit and the other is the binary log.
mysql-test/r/commit_1innodb.result:
  Update test case results.
mysql-test/r/innodb_mysql.result:
  Update test case results.
mysql-test/t/innodb_mysql.test:
  Add test case for Bug#37016
sql/sql_delete.cc:
  Move truncation using row by row deletion to its own function.
  If row by row deletion fails, rollback the transaction.
  
  Remove the meddling with disabling and enabling of autocommit
  as TRUNCATE transaction is now explicitly ended (committed
  or rolled back).
2009-01-09 08:20:32 -02:00
Davi Arnaut
7ba37134d2 Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites
locking type of temp table

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

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

mysql-test/r/innodb_mysql.result:
  Add test case result for Bug#41348
mysql-test/r/temp_table.result:
  Add test case result for Bug#41348
mysql-test/t/innodb_mysql.test:
  Add test case for Bug#41348
mysql-test/t/temp_table.test:
  Add test case for Bug#41348
sql/sql_base.cc:
  Allow the lock type of temp tables to be overwritten now that
  the the value is being restored once the table is marked as
  free for re-use. This makes the behavior consistent with that
  of non-temporary tables and avoids confusion.
2009-01-07 10:11:37 -02:00
Georgi Kodinov
a10c3ff2b0 merged bug 37742 to 5.1-bugteam 2008-12-08 12:23:33 +02:00
Georgi Kodinov
ab4d8812f4 Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of requested
column
      
When the storage engine uses secondary keys clustered with the primary key MySQL was
adding the primary key parts to each secondary key.
In doing so it was not checking whether the index was on full columns and this
resulted in the secondary keys being added to the list of covering keys even if 
they have partial columns.
Fixed by not adding a primary key part to the list of columns that can be used 
for index read of the secondary keys when the primary key part is a partial key part.

mysql-test/r/innodb_mysql.result:
  Bug #37742: test case
mysql-test/t/innodb_mysql.test:
  Bug #37742: test case
sql/table.cc:
  Bug #37742: don't add the primary key part to the list of covering key parts
  of a secondary key if it's a partial key part.
2008-11-29 15:36:17 +02:00
Sergey Glukhov
0385618e05 5.0-bugteam->5.1-bugteam merge 2008-11-27 19:03:13 +04:00
Sergey Glukhov
1182c0979a Bug#37284 Crash in Field_string::type()
The bug is repeatable with latest(1.0.1) InnoDB plugin on Linux, Win,
If MySQL is compiled with valgrind there are errors about
using of uninitialized variable(orig_table).
The fix is to set field->orig_table correct value.


mysql-test/r/innodb_mysql.result:
  test result
mysql-test/t/innodb_mysql.test:
  test case
sql/sql_base.cc:
  set field->orig_table to 'table' value because it may be bogus and
  it leads to crash on Field_string::type() function.
2008-11-27 18:54:23 +04:00
Mats Kindahl
ad8ffe6add Bug #40360: Binlog related errors with binlog off
Adding missing drop of created table and tidying display.


mysql-test/t/innodb_mysql.test:
  Adding drop of created table and cleaning variable display
2008-11-03 18:46:47 +01:00
Mats Kindahl
c3a5b59676 Bug #40360: Binlog related errors with binlog off
When statement-based replication is used, and the
transaction isolation level is READ-COMMITTED or stricter,
InnoDB will print an error because statement-based
replication might lead to inconsistency between master
and slave databases. However, when the binary log is not
engaged, this is not an issue and an error should
not be printed.

This patch makes thd_binlog_format() return BINLOG_FORMAT_
UNSPEC when the binary log is not engaged for the given
thread.

mysql-test/t/innodb_mysql.test:
  Adding test that no error message is printed from inside
  InnoDB when the binary log is turned off.
2008-11-03 12:14:48 +01:00
Georgi Kodinov
dd85aa78ba Bug#37830 : ORDER BY ASC/DESC - no difference
Range scan in descending order for c <= <col> <= c type of
ranges was ignoring the DESC flag.
However some engines like InnoDB have the primary key parts 
as a suffix for every secondary key.
When such primary key suffix is used for ordering ignoring 
the DESC is not valid.
But we generally would like to do this because it's faster.
            
Fixed by performing only reverse scan if the primary key is used.
Removed some dead code in the process.

mysql-test/r/innodb_mysql.result:
  Bug#37830 : test case
mysql-test/t/innodb_mysql.test:
  Bug#37830 : test case
sql/opt_range.cc:
  Bug#37830 : 
  - preserve and use used_key_parts to
    distinguish when a primary key suffix is used
  - removed some dead code
sql/opt_range.h:
  Bug#37830 : 
  - preserve used_key_parts
  - dead code removed
sql/sql_select.cc:
  Bug#37830 : Do only reverse order traversal
  if the primary key suffix is used.
2008-07-23 14:25:00 +03:00
unknown
87e5098249 BUG#35850 "Performance regression in 5.1.23/5.1.24"
- Disable the "prefer full scan on clustered primary key over full scan
  of any secondary key" rule introduced by BUG#35850.
- Update test results accordingly 
(bk trigger: file this for BUG#35850)


mysql-test/r/innodb.result:
  BUG#35850 "Performance regression in 5.1.23/5.1.24"
  - Update test results
mysql-test/r/innodb_mysql.result:
  BUG#35850 "Performance regression in 5.1.23/5.1.24"
  - Testcase
  - Update test results
mysql-test/r/join_outer_innodb.result:
  BUG#35850 "Performance regression in 5.1.23/5.1.24"
  - Update test results
mysql-test/t/innodb_mysql.test:
  BUG#35850 "Performance regression in 5.1.23/5.1.24"
  - Testcase
sql/sql_select.cc:
  BUG#35850 "Performance regression in 5.1.23/5.1.24"
  - Disable the "prefer full scan on clustered primary key over full scan
    of any secondary key" rule introduced by BUG#35850.
2008-05-07 09:58:21 +04:00
unknown
a4eaf17ccb innodb_mysql.test, variables.result, variables.test, innodb_mysql.result:
Minor post-fix for bug#34223.


mysql-test/r/innodb_mysql.result:
  Minor post-fix for bug#34223.
mysql-test/r/variables.result:
  Minor post-fix for bug#34223.
mysql-test/t/innodb_mysql.test:
  Minor post-fix for bug#34223.
mysql-test/t/variables.test:
  Minor post-fix for bug#34223.
2008-02-07 11:12:49 +04:00
unknown
33f82b1789 Merge mysql.com:/home/gluh/MySQL/Merge/5.0
into  mysql.com:/home/gluh/MySQL/Merge/5.0-opt


client/mysql.cc:
  Auto merged
client/mysqltest.c:
  Auto merged
include/mysql_com.h:
  Auto merged
libmysql/CMakeLists.txt:
  Auto merged
myisam/mi_check.c:
  Auto merged
mysql-test/r/delayed.result:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/r/myisam.result:
  Auto merged
mysql-test/r/ps.result:
  Auto merged
mysql-test/t/merge.test:
  Auto merged
mysql-test/t/myisam.test:
  Auto merged
mysql-test/t/subselect.test:
  Auto merged
mysql-test/t/type_datetime.test:
  Auto merged
mysql-test/t/variables.test:
  Auto merged
sql/field.cc:
  Auto merged
sql/ha_myisam.cc:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/func_misc.result:
  manual merge
mysql-test/r/innodb_mysql.result:
  manual merge
mysql-test/t/func_misc.test:
  manual merge
mysql-test/t/innodb_mysql.test:
  manual merge
sql/sql_insert.cc:
  manual merge
2007-12-13 14:52:49 +04:00
unknown
d776054e00 Fixed bug #32815.
The index (key_part_1, key_part-2) was erroneously considered as compatible
with the required ordering in the function test_test_if_order_by_key when 
a query with an ORDER BY clause contained a condition of the form
  key_part_1=const OR key_part_1 IS NULL 
and the order list contained only key_part_2. This happened because the value
of the const_key_parts field in the KEYUSE structure was not formed correctly
for the keys that could be used for ref_or_null access. 
This was fixed in the code of the update_ref_and_keys function.
The problem could not manifest itself for MyISAM databases because the
implementation of the keys_to_use_for_scanning() handler function always
returns an empty bitmap for the MyISAM engine.


mysql-test/r/innodb_mysql.result:
  Added a test case for bug #32815.
mysql-test/t/innodb_mysql.test:
  Added a test case for bug #32815.
sql/sql_select.cc:
  Fixed bug #32815.
  The index (key_part_1, key_part-2) was erroneously considered as compatible
  with the required ordering in the function test_test_if_order_by_key when 
  a query with an ORDER BY clause contained a condition of the form
    key_part_1=const OR key_part_1 IS NULL 
  and the order list contained only key_part_2. This happened because the value
  of the const_key_parts field in the KEYUSE structure was not formed correctly
  for the keys that could be used for ref_or_null access. 
  This was fixed in the code of the update_ref_and_keys function.
2007-12-07 17:14:59 -08:00
unknown
d7d93cf548 Fix for bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0,
file .\ha_innodb.

Problem: if a partial unique key followed by a non-partial one we declare
the second one as a primary key.

Fix: sort non-partial unique keys before partial ones.


include/my_base.h:
  Fix for bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0, 
  file .\ha_innodb.
    - sort unique keys that don't contain partial segments before other keys:
        set HA_KEY_HAS_PART_KEY_SEG flag for such keys in the mysql_prepare_table(),
        use it in the sort_keys();
mysql-test/r/innodb_mysql.result:
  Fix for bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0, 
  file .\ha_innodb.
    - test result.
mysql-test/r/key.result:
  Fix for bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0, 
  file .\ha_innodb.
    - test result.
mysql-test/t/innodb_mysql.test:
  Fix for bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0, 
  file .\ha_innodb.
    - test case.
mysql-test/t/key.test:
  Fix for bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0, 
  file .\ha_innodb.
    - test case.
sql/sql_table.cc:
  Fix for bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0, 
  file .\ha_innodb.
    - sort unique keys that don't contain partial segments before other keys:
        set HA_KEY_HAS_PART_KEY_SEG flag for such keys in the mysql_prepare_table(),
        use it in the sort_keys();
sql/structs.h:
  Fix for bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0, 
  file .\ha_innodb.
    - sort unique keys that don't contain partial segments before other keys:
        set HA_KEY_HAS_PART_KEY_SEG flag for such keys in the mysql_prepare_table(),
        use it in the sort_keys();
2007-10-26 15:37:38 +05:00
unknown
7bb3501ff9 sql_plugin.cc:
fixed uninit memory access in SET pluginvar=DEFAULT
innodb_mysql.test, innodb_mysql.result:
  test case for SET pluginvar=DEFAULT


mysql-test/r/innodb_mysql.result:
  test case for SET pluginvar=DEFAULT
mysql-test/t/innodb_mysql.test:
  test case for SET pluginvar=DEFAULT
sql/sql_plugin.cc:
  fixed uninit memory access in SET pluginvar=DEFAULT
2007-10-08 20:57:37 +02:00
unknown
ad496be063 Bug #31001: ORDER BY DESC in InnoDB not working
The optimizer sets index traversal in reverse order only if there are 
 used key parts that are not compared to a constant.
However using the primary key as an ORDER BY suffix rendered the check
incomplete : going in reverse order must still be used even if 
all the parts of the secondary key are compared to a constant.

Fixed by relaxing the check and set reverse traversal even when all
the secondary index keyparts are compared to a const.
Also account for the case when all the primary keys are compared to a
constant.


mysql-test/r/innodb_mysql.result:
  Bug #31001: test case
mysql-test/t/innodb_mysql.test:
  Bug #31001: test case
sql/sql_select.cc:
  Bug #31001: 
   - account for the case when all the primary key parts are compared
     to a constant
   - force test_if_skip_sort_order to go backwards over the key even 
     when the number of keyparts used is the same as the number of 
     keyparts equal to a constant. (because of the primary key 
     suffix).
2007-09-14 17:43:14 +03:00
unknown
bdf19dc73b Merge mhansson@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  linux-st28.site:/home/martin/mysql/src/bugx/my50-bugx


mysql-test/t/innodb_mysql.test:
  Auto merged
sql/sql_select.cc:
  Auto merged
mysql-test/r/innodb_mysql.result:
  SCCS merged
2007-08-29 10:49:19 +02:00
unknown
2368664681 Bug #30596 GROUP BY optimization gives wrong result order
The optimization that uses a unique index to remove GROUP BY, did not 
ensure that the index was actually used, thus violating the ORDER BY
that is impled by GROUP BY.
Fixed by replacing GROUP BY with ORDER BY if the GROUP BY clause contains
a unique index. In case GROUP BY ... ORDER BY null is used, GROUP BY is
simply removed.


BitKeeper/etc/ignore:
  Added support-files/mysqld_multi.server tests/bug25714 cscope.in.out cscope.out cscope.po.out to the ignore list
mysql-test/r/distinct.result:
  Bug#30596: Changed test case. 
  Prior to Bug#16458, These queries use temp table and filesort. The
  bug was that they used a temp table. However, that patch removed
  filesort also, in which case we can no longer gurantee correct ordering.
mysql-test/r/group_by.result:
  Bug#30596: Correct result
mysql-test/r/innodb_mysql.result:
  Bug#30596: Test case for innodb. Here, as opposed to for MyISAM, row 
  lookup is done using index whenever the index covers the group list.
mysql-test/t/group_by.test:
  Bug#30596: Test case
mysql-test/t/innodb_mysql.test:
  Bug#30596: Test case
sql/sql_select.cc:
  Bug#30596: The fix, replacing GROUP BY with ORDER BY unless 
  ORDER BY [NULL|<constant>]
2007-08-27 17:33:41 +02:00
unknown
f4a163c3a5 Merge mhansson@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  dl145s.mysql.com:/data0/mhansson/my50-bug28570


sql/opt_range.cc:
  Auto merged
mysql-test/r/innodb_mysql.result:
  Bug#28570: Manual Merge
mysql-test/t/innodb_mysql.test:
  Bug#28570: Manual Merge
2007-08-16 14:13:07 +02:00
unknown
01f8130aa6 bug#28570: handler::index_read() is called with different find_flag when
ORDER BY is used

The range analysis module did not correctly signal to the 
handler that a range represents a ref (EQ_RANGE flag). This causes 
non-range queries like 
SELECT ... FROM ... WHERE keypart_1=const, ..., keypart_n=const 
ORDER BY ... FOR UPDATE
to wait for a lock unneccesarily if another running transaction uses
SELECT ... FOR UPDATE on the same table.

Fixed by setting EQ_RANGE for all range accesses that represent 
an equality predicate. 


mysql-test/r/innodb_mysql.result:
  bug#28570: Test Result
mysql-test/t/innodb_mysql.test:
  bug#28570: Test Case
sql/handler.cc:
  bug#28570: Updated comment
sql/opt_range.cc:
  bug#28570: Removed the criterion that key has to be unique (HA_NOSAME) in 
  order for the EQ_RANGE flag to be set. It is sufficient that the range 
  represent a ref access.
2007-08-15 09:23:44 +02:00
unknown
41ac5d83b2 Merge ramayana.hindu.god:/home/tsmith/m/bk/50
into  ramayana.hindu.god:/home/tsmith/m/bk/maint/50


mysql-test/r/federated.result:
  Auto merged
mysql-test/t/federated.test:
  Auto merged
sql/ha_federated.h:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_table.cc:
  Auto merged
mysql-test/r/innodb_mysql.result:
  Manual merge
mysql-test/t/innodb_mysql.test:
  Manual merge
2007-08-01 18:14:50 -06:00
unknown
91f54bf1f7 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  bodhi.(none):/opt/local/work/mysql-5.0-runtime


client/mysqldump.c:
  Auto merged
mysql-test/r/mysqldump.result:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/table.cc:
  Auto merged
mysql-test/r/innodb_mysql.result:
  Manual merge.
mysql-test/t/innodb_mysql.test:
  Manual merge.
sql/sql_table.cc:
  Manual merge.
2007-07-31 20:03:52 +04:00
unknown
0936976e8d A fix and a test case for Bug#24918 drop table and lock / inconsistent
between perm and temp tables. Review fixes.

The original bug report complains that if we locked a temporary table
with LOCK TABLES statement, we would not leave LOCK TABLES mode
when this temporary table is dropped.

Additionally, the bug was escalated when it was discovered than
when a temporary transactional table that was previously
locked with LOCK TABLES statement was dropped, futher actions with
this table, such as UNLOCK TABLES, would lead to a crash.

The problem originates from incomplete support of transactional temporary
tables. When we added calls to handler::store_lock()/handler::external_lock()
to operations that work with such tables, we only covered the normal
server code flow and did not cover LOCK TABLES mode. 
In LOCK TABLES mode, ::external_lock(LOCK) would sometimes be called without
matching ::external_lock(UNLOCK), e.g. when a transactional temporary table
was dropped. Additionally, this table would be left in the list of LOCKed 
TABLES.

The patch aims to address this inadequacy. Now, whenever an instance
of 'handler' is destroyed, we assert that it was priorly
external_lock(UNLOCK)-ed. All the places that violate this assert
were fixed.

This patch introduces no changes in behavior -- the discrepancy in
behavior will be fixed when we start calling ::store_lock()/::external_lock()
for all tables, regardless whether they are transactional or not, 
temporary or not.


mysql-test/r/innodb_mysql.result:
  Update test results (Bug#24918)
mysql-test/t/innodb_mysql.test:
  Add a test case for Bug#24918
sql/handler.h:
  Make handler::external_lock() a protected method. Backport from 5.1 its
  public wrapper handler::ha_external_lock().
  Assert that the handler is not closed if it is still locked.
sql/lock.cc:
  In mysql_lock_tables only call lock_external() for the list of tables that
  we called store_lock() for. 
  E.g. get_lock_data() does not add non-transactional temporary tables to the
  lock list, so lock_external() should not be called for them.
  
  Use handler::ha_external_lock() instead of handler::external_lock().
  
  Add comments for mysql_lock_remove(), parameterize one strange
  side effect that it has. At least in one place where mysql_lock_remove
  is used, this side effect is not desired (DROP TABLE). The parameter
  will be dropped in 5.1, along with the side effect.
sql/mysql_priv.h:
  Update declaration of mysql_lock_remove().
sql/opt_range.cc:
  Deploy handler::ha_external_lock() instead of handler::external_lock()
sql/sql_base.cc:
  When closing a temporary table, remove the table from the list of LOCKed 
  TABLES of this thread, in case it's there. 
  It's there if it is a transactional temporary table.
  Use a new declaration of mysql_lock_remove().
sql/sql_class.h:
  Extend the comment for THD::temporary_tables.
sql/sql_table.cc:
  Deploy handler::ha_external_lock() instead of handler::external_lock()
2007-07-27 16:37:29 +04:00
unknown
c29002a5b6 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/autopush/B29644-5.0-opt


sql/ha_innodb.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
mysql-test/r/innodb_mysql.result:
  5.0-opt merge
mysql-test/t/innodb_mysql.test:
  5.0-opt merge
2007-07-23 17:07:29 +03:00
unknown
240bb90ef1 Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into  magare.gmz:/home/kgeorge/mysql/autopush/B28951-5.0-opt


mysql-test/t/innodb_mysql.test:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/table.cc:
  Auto merged
mysql-test/r/innodb_mysql.result:
  merge of 5.0-opt
2007-07-22 19:23:29 +03:00
unknown
95a8c6c327 Bug #28591: MySQL need not sort the records in case of
ORDER BY primary_key on InnoDB table

Queries that use an InnoDB secondary index to retrieve
data don't need to sort in case of ORDER BY primary key
if the secondary index is compared to constant(s).
They can also skip sorting if ORDER BY contains both the
the secondary key parts and the primary key parts (in
that order).
This is because InnoDB returns the rows in order of the
primary key for rows with the same values of the secondary
key columns.
Fixed by preventing temp table sort for the qualifying 
queries.


mysql-test/r/innodb_mysql.result:
  Bug #28591: test case
mysql-test/t/innodb_mysql.test:
  Bug #28591: test case
sql/sql_select.cc:
  Bug #28591: Use the primary key as suffix when testing
  if the key can be used for ORDER BY on supporting engines.
sql/table.cc:
  Bug #28591: can use the primary key
  as a suffix for the secondary keys
2007-07-20 21:05:29 +03:00
unknown
eea5c2a3c5 Bug #29644: alter table hangs if records locked in share mode
by long running transaction

On Windows opened files can't be deleted. There was a special
upgraded lock mode (TL_WRITE instead of TL_WRITE_ALLOW_READ) 
in ALTER TABLE to make sure nobody has the table opened
when deleting the old table in ALTER TABLE. This special mode
was causing ALTER TABLE to hang waiting on a lock inside InnoDB.
This special lock is no longer necessary as the server is 
closing the tables it needs to delete in ALTER TABLE.
Fixed by removing the special lock.
Note that this also reverses the fix for bug 17264 that deals with
another consequence of this special lock mode being used.


mysql-test/r/innodb_mysql.result:
  Bug #29644: test case
mysql-test/t/innodb_mysql.test:
  Bug #29644: test case
sql/ha_innodb.cc:
  Bug #29644: reverse the (now excessive) fix
  for bug 17264 (but leave the test case).
sql/sql_base.cc:
  Bug #29644: don't need a special lock mode for Win32 anymore: 
  the table is closed before the drop.
2007-07-20 14:17:15 +03:00
unknown
91e5864d70 Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0-maint
into  mysql.com:/home/ram/work/b28125/b28125.5.0


mysql-test/t/innodb_mysql.test:
  Auto merged
mysql-test/r/innodb_mysql.result:
  manual merge.
2007-07-20 15:23:35 +05:00
unknown
6947f2d131 Fix for bug #28125: ERROR 2013 when adding index.
Problem: we may break a multibyte char sequence using a key 
reduced to maximum allowed length for a storage engine
(that leads to failed assertion in the innodb code, 
see also #17530). 

Fix: align truncated key length to multibyte char boundary.


mysql-test/r/innodb_mysql.result:
  Fix for bug #28125: ERROR 2013 when adding index.
    - test result.
mysql-test/t/innodb_mysql.test:
  Fix for bug #28125: ERROR 2013 when adding index.
    - test case.
sql/sql_table.cc:
  Fix for bug #28125: ERROR 2013 when adding index.
    - align truncated key length to multibyte char boundary.
    - display real key length in bytes raising warnings.
2007-07-18 12:13:45 +05:00
unknown
b94fb82847 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  bodhi.(none):/opt/local/work/mysql-5.0-runtime


mysql-test/t/sp.test:
  Auto merged
sql/item.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/innodb_mysql.result:
  Manual merge.
mysql-test/t/innodb_mysql.test:
  Manual merge.
2007-07-16 23:41:28 +04:00
unknown
8023d91929 Add a teste case for Bug#27296 "Assertion in ALTER TABLE SET DEFAULT in
Linux Debug build (possible deadlock)"

The bug is not repeatable any more.


mysql-test/r/innodb_mysql.result:
  Update test results (Bug#27296)
mysql-test/t/innodb_mysql.test:
  Add a teste case for Bug#27296 "Assertion in ALTER TABLE SET DEFAULT in 
  Linux Debug build (possible deadlock)"
2007-07-15 13:34:35 +04:00
unknown
16fc3a2771 Merge gleb.loc:/home/uchum/work/bk/5.0
into  gleb.loc:/home/uchum/work/bk/5.0-opt


mysql-test/r/innodb_mysql.result:
  Auto merged
mysql-test/t/innodb_mysql.test:
  Merge with 5.0 (main).
2007-07-08 00:19:31 +05:00