Commit graph

25140 commits

Author SHA1 Message Date
Kristofer Pettersson
61b9ce16fd Automerge 2010-03-25 13:26:48 +01:00
Kristofer Pettersson
ea7d830ad2 Bug#46615 Assertion in Query_cache::invalidate in INSERT in a VIEW of a MERGE table
If the listed columns in the view definition of 
the table used in a 'INSERT .. SELECT ..'
statement mismatched, a debug assertion would
trigger in the cache invalidation code
following the failing statement.

Although the find_field_in_view() function
correctly generated ER_BAD_FIELD_ERROR during
setup_fields(), the error failed to propagate
further than handle_select(). This patch fixes
the issue by adding a check for the return
value.


mysql-test/r/query_cache_with_views.result:
  * added test for bug 46615
mysql-test/t/query_cache_with_views.test:
  * added test for bug 46615
sql/sql_parse.cc:
  * added check for handle_select() return code before attempting to invalidate the cache.
2010-03-24 17:37:41 +01:00
Sergey Glukhov
fe25ec8f24 5.0-bugteam->5.1-bugteam merge 2010-03-24 14:45:09 +04:00
Sergey Glukhov
bccf219bfc Bug#48483 crash in get_best_combination()
The crash happens because greedy_serach
can not determine best plan due to
wrong inner table dependences. These
dependences affects join table sorting
which performs before greedy_search starting.
In our case table which has real 'no dependences'
should be put on top of the list but it does not
happen as inner tables have no dependences as well.
The fix is to exclude RAND_TABLE_BIT mask from
condition which checks if table dependences
should be updated.


mysql-test/r/join.result:
  test result
mysql-test/t/join.test:
  test case
sql/sql_select.cc:
  RAND_TABLE_BIT mask should not be counted as it
  prevents update of inner table dependences.
  For example it might happen if RAND() function
  is used in JOIN ON clause.
2010-03-24 14:37:28 +04:00
Georgi Kodinov
a9a2ceae1f Bug #51850: crash/memory overlap when using load data infile and set
col equal to itself!

There's no need to copy the value of a field into itself.
While generally harmless (except for some performance penalties)
it may be dangerous when the copy code doesn't expect this.
Fixed by checking if the source field is the same as the destination
field before copying the data.
Note that we must preserve the order of assignment of the null 
flags (hence the null_value assignment addition).
2010-03-23 17:07:00 +02:00
Georgi Kodinov
5167451a92 Bug #51893: crash with certain characters given to load_file
function on windows

When making sure that the directory path ends up with a 
slash/backslash we need to check for the correct length of 
the buffer and trim at the appropriate location so we don't
write past the end of the buffer.
2010-03-23 16:54:16 +02:00
Sergey Glukhov
3658bde736 5.0-bugteam->5.1-bugteam merge 2010-03-26 11:46:18 +04:00
Tatiana A. Nurnberg
28e95ba535 Bug#48525: trigger changes "Column 'id' cannot be null" behaviour
CHECK_FIELD_IGNORE was treated as CHECK_FIELD_ERROR_FOR_NULL;
UPDATE...SET...NULL on NOT NULL fields behaved differently after
a trigger.

Now distinguishes between IGNORE and ERROR_FOR_NULL and save/restores
check-field options.


mysql-test/r/trigger.result:
  Show that UPDATE...SET...NULL on NOT NULL columns doesn't behave differently
  when run after a trigger.
mysql-test/t/trigger.test:
  Show that UPDATE...SET...NULL on NOT NULL columns doesn't behave differently
  when run after a trigger.
sql/field_conv.cc:
  CHECK_FIELD_IGNORE was treated as CHECK_FIELD_ERROR_FOR_NULL.
  Distinguish between the two.
sql/sp_head.cc:
  Raise error as needed.
sql/sql_class.cc:
  Save and restore check-fields options.
sql/sql_class.h:
  Make room so we can save check-fields options.
sql/sql_insert.cc:
  Raise error as needed.
2010-03-29 03:32:30 +01:00
Sergey Vojtovich
b602127bf0 BUG#51868 - crash with myisam_use_mmap and partitioned
myisam tables

Queries following TRUNCATE of partitioned MyISAM table
may crash server if myisam_use_mmap is true.

Internally this is MyISAM bug, but limited to partitioned
tables, because MyISAM doesn't use ::delete_all_rows()
method for TRUNCATE, but goes via table recreate instead.

MyISAM didn't properly fall back to non-mmaped I/O after
mmap() failure. Was not repeatable on linux before, likely
because (quote from man mmap):
  SUSv3  specifies  that  mmap() should fail if length is 0.
  However, in kernels before 2.6.12, mmap() succeeded in
  this case: no mapping was created and the call returned
  addr. Since kernel 2.6.12, mmap() fails with the error
  EINVAL for this case.

mysql-test/r/partition.result:
  A test case for BUG#51868.
mysql-test/t/partition.test:
  A test case for BUG#51868.
storage/myisam/mi_delete_all.c:
  _mi_unmap_file() is compressed record format specific,
  which is read-only. As compressed MyISAM data files are
  read-only, we must never use _mi_unmap_file() in
  mi_delete_all_rows().
storage/myisam/mi_dynrec.c:
  Make myisam mmap code more durable to errors:
  - set file_read/file_write handlers if mmap succeeded;
  - reset file_read/file_write handlers on unmap.
storage/myisam/mi_extra.c:
  Moved file_read/file_write handlers initialization to
  mi_dynmap_file().
storage/myisam/myisamdef.h:
  Added mi_munmap_file() declaration.
2010-03-22 16:30:27 +04:00
Alexander Barkov
a35418784b Merging the latest changes 2010-03-22 16:29:53 +04:00
Alexander Barkov
84fc3da40f Bug #51976 LDML collations issue
Problem: caseup_multiply and casedn_multiply members      
were not initialized for a dynamic collation, so          
UPPER() and LOWER() functions returned empty strings.      
Fix: initializing the members properly.

Adding tests:
  mysql-test/r/ctype_ldml.result
  mysql-test/t/ctype_ldml.test

Applying the fix:
  mysys/charset.c
2010-03-22 16:27:59 +04:00
Mats Kindahl
cd7d8f98f8 Merging with mysql-5.1-bugfixing. 2010-03-22 13:12:57 +01:00
Mats Kindahl
f172ddd655 BUG#49618: Field length stored incorrectly in binary log
for InnoDB

Patch to fix result files for the binlog suite under row-
based replication.
2010-03-22 13:10:18 +01:00
Luis Soares
fc34cd1c21 BUG#51987: revoke privileges logs wrong error code
A failed REVOKE statement is logged with error=0, thus causing
the slave to stop. The slave should not stop as this was an
expected error. Given that the execution failed on the master as
well the error code should be logged so that the slave can replay
the statement, get an error and compare with the master's
execution outcome. If errors match, then slave can proceed with
replication, as the error it got, when replaying the statement,
was expected.

In this particular case, the bug surfaces because the error code
is pushed to the THD diagnostics area after writing the event to
the binary log. Therefore, it would be logged with the THD
diagnostics area clean, hence its error code would not contain 
the correct code.

We fix this by moving the error reporting ahead of the call to
the routine that writes the event to the binary log.
2010-03-22 09:51:16 +00:00
John H. Embretsen
be16e48633 Merge fix for bug 52060 into tip of 5.1-bugteam. 2010-03-22 10:06:56 +01:00
Gleb Shchepa
8feadddbe4 Bug #49910: Behavioural change in SELECT/WHERE on YEAR(4) data type
(Original patch by Sinisa Milivojevic)

The YEAR(4) value of 2000 was equal to the "bad" YEAR(4) value of 0000.                              

The get_year_value() function has been modified to not adjust bad                                    
YEAR(4) value to 2000.


mysql-test/r/type_year.result:
  Test case for bug #49910.
mysql-test/t/type_year.test:
  Test case for bug #49910.
sql/item_cmpfunc.cc:
  Bug #49910: Behavioural change in SELECT/WHERE on YEAR(4) data type                                  
  
  The get_year_value() function has been modified to not adjust bad                                    
  YEAR(4) value to 2000.
2010-03-22 12:33:25 +04:00
Andrei Elkin
e66128972d bug#51648
comments to rpl_show_slave_running test are added to ease merging
2010-03-22 07:50:19 +02:00
Andrei Elkin
402d6ce67f merging bug@51648 to 5.1-bt, pe from local bugfixing branch 2010-03-21 21:30:49 +02:00
Sergey Glukhov
ad6e00e3b2 Bug#51242 HAVING clause on table join produce incorrect results
The problem is that when we make conditon for
grouped result const part of condition is cut off.
It happens because some parts of 'having' condition
which refer to outer join become const after
make_join_statistics. These parts may be lost
during further having condition transformation
in JOIN::exec. The fix is adding 'having'
condition check for const tables after
make_join_statistics is performed.


mysql-test/r/having.result:
  test case
mysql-test/t/having.test:
  test result
sql/sql_select.cc:
  added 'having' condition check for const tables
  after make_join_statistics is performed.
2010-03-19 13:09:22 +04:00
Andrei Elkin
c3cd608aef Bug #51648 DBUG_SYNC_POINT is not defined on all platforms and mtr cant pre-check that
DBUG_SYNC_POINT has at least one strong limitation that it's not defined
on all platforms. It has issues cooperating with @@debug.
All in all its functionality is superseded by DEBUG_SYNC facility and
there is no reason to maintain the old less flexible one.

Fixed with adding debug_sync_set_action() function as a facility to set up
a sync-action in the server sources code and re-writing existing simulations
(found 3) to use it.
Couple of tests have been reworked as well.

The patch offers a pattern for setting sync-points in replication threads
where the standard DEBUG_SYNC does not suffice to reach goals.





mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test:
  rewriting the test from GET_LOCK()-based to DEBUG_SYNC-based;
  a pattern of usage DEBUG_SYNC for replication testing is provided.
mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result:
  results are changed.
mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test:
  rewriting the test from GET_LOCK()-based to DEBUG_SYNC-based;
  limiting the test to run only with MIXED binlog-format as the test last
  some 10 secs sensitively contributing to the total of tests run.
mysql-test/suite/rpl/t/rpl_show_slave_running.test:
  rewriting the test from GET_LOCK()-based to DEBUG_SYNC-based.
sql/debug_sync.cc:
  adding debug_sync_set_action() function as a facility to set up
  a sync-action in the server sources code.
sql/debug_sync.h:
  externalizing debug_sync_set_action().
sql/item_func.cc:
  purging sources from DBUG_SYNC_POINT.
sql/mysql_priv.h:
  purging sources from DBUG_SYNC_POINT.
sql/slave.cc:
  rewriting failure simulations to base on DEBUG_SYNC rather than GET_LOCK()-based DBUG_SYNC_POINT.
sql/sql_repl.cc:
  removing an orphan failure simulation line because no counterpart in tests existing.
2010-03-19 11:06:40 +02:00
Martin Hansson
a76b8f9a1d Post-push fix to disable a subset of the test case for Bug#47762.
This has been back-ported from 6.0 as the problems proved to afflict 
5.1 as well.
The fix exposed two new bugs. They were reported as follows.
      
Bug no 52174: Sometimes wrong plan when reading a MAX value 
from non-NULL index
      
Bug no 52173: Reading NULL value from non-NULL index gives wrong 
result in embedded server 
      
Both bugs taken together affect a much smaller class of queries than #47762, 
so the fix stays for now.
2010-03-19 09:23:44 +01:00
Sergey Glukhov
d1c2e8508f Bug#51598 Inconsistent behaviour with a COALESCE statement inside an IN comparison
Optimizer erroneously translated LEFT JOIN into INNER JOIN.
It leads to cutting rows with NULL right side. It happens
because Item_row uses not_null_tables() method form the
base(Item) class and does not calculate 'null tables'
properly. The fix is adding calculation of 'not null tables'
to Item_row.


mysql-test/r/join_outer.result:
  test result
mysql-test/t/join_outer.test:
  test case
sql/item_row.cc:
  adding calculation of 'not null tables' to Item_row.
sql/item_row.h:
  adding calculation of 'not null tables' to Item_row.
2010-03-19 10:21:37 +04:00
Sergey Glukhov
caa1ccb0c3 Bug#51494 crash with join, explain and 'sounds like' operator
The crash happens because of discrepancy between values of
conts_tables and join->const_table_map(make_join_statisctics).
Calculation of conts_tables used condition with
HA_STATS_RECORDS_IS_EXACT flag check. Calculation of
join->const_table_map does not use this flag check.
In case of MERGE table without union with index
the table does not become const table and
thus join_read_const_table() is not called
for the table. join->const_table_map supposes
this table is const and later in make_join_select
this table is used for making&calculation const
condition. As table record buffer is not populated
it leads to crash.
The fix is adding a check if an engine supports
HA_STATS_RECORDS_IS_EXACT flag before updating
join->const_table_map.


mysql-test/r/merge.result:
  test result
mysql-test/t/merge.test:
  test case
sql/sql_select.cc:
  adding a check if an engine supports
  HA_STATS_RECORDS_IS_EXACT flag before updating
  join->const_table_map.
2010-03-19 10:01:02 +04:00
John H. Embretsen
b453707680 Bug#52060 - test udf fails on Snow Leopard
reverse DNS lookup of "localhost" returns "broadcasthost" on Snow Leopard, and NULL on most others.
Simply ignore the output, as this is not an essential part of UDF testing.
2010-03-18 11:26:27 +01:00
Omer BarNir
c92b9b7315 Test suites for engine testing, moved from test-extra so will be available
for general use.


mysql-test/Makefile.am:
  Adding directories of additional test suites
mysql-test/mysql-stress-test.pl:
  Adding check for additional errors checking during test run
2010-03-17 23:42:07 -07:00
Mats Kindahl
96d4a03846 Merging with mysql-5.1-bugteam 2010-03-17 19:15:41 +01:00
Mats Kindahl
2c5f439d65 BUG#49618: Field length stored incorrectly in binary log
for InnoDB
            
The class Field_bit_as_char stores the metadata for the
field incorrecly because bytes_in_rec and bit_len are set
to (field_length + 7 ) / 8 and 0 respectively, while
Field_bit has the correct values field_length / 8 and
field_length % 8.
            
Solved the problem by re-computing the values for the
metadata based on the field_length instead of using the
bytes_in_rec and bit_len variables.
            
To handle compatibility with old server, a table map
flag was added to indicate that the bit computation is
exact. If the flag is clear, the slave computes the
number of bytes required to store the bit field and
compares that instead, effectively allowing replication
*without conversion* from any field length that require
the same number of bytes to store.


mysql-test/suite/rpl/t/rpl_typeconv_innodb.test:
  Adding test to check compatibility for bit field
  replication when using InnoDB
sql/field.cc:
  Extending compatible_field_size() with flags from
  table map to allow fields to check master info.
sql/field.h:
  Extending compatible_field_size() with flags from
  table map to allow fields to check master info.
sql/log.cc:
  Removing table map flags since they are not used
  outside table map class.
sql/log_event.cc:
  Removing flags parameter from table map constructor
  since it is not used and does not have to be exposed.
sql/log_event.h:
  Adding flag to denote that bit length for bit field type
  is exact and not potentially rounded to even bytes.
sql/rpl_utility.cc:
  Adding fields to table_def to store table map flags.
sql/rpl_utility.h:
  Removing obsolete comment and adding flags to store
  table map flags from master.
2010-03-17 15:28:49 +01: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
Sergey Vojtovich
ae42e96d28 Merge fix for BUG47444 to mysql-5.1-bugteam. 2010-03-16 21:33:56 +04:00
Martin Hansson
4a0dd699b1 Merge of fix for Bug#47762. 2010-03-16 17:21:38 +01:00
Martin Hansson
7dc693229f Bug#47762: Incorrect result from MIN() when WHERE tests NOT
NULL column for NULL

The optimization to read MIN() and MAX() values from an
index did not properly handle comparisons with NULL
values. Fixed by giving up the particular optimization step
if there are non-NULL safe comparisons with NULL values, as 
the result is NULL anyway.

Also, Oracle copyright notice was added to all files.
2010-03-16 15:51:00 +01:00
Mattias Jonsson
7297ec560e merge 2010-03-16 15:09:58 +01:00
Sergey Vojtovich
87e80b6593 Merge fix for BUG47444 to mysql-5.1-bugteam. 2010-03-16 18:06:03 +04:00
Luis Soares
cc223d3883 Automerge: mysql-5.1-bugteam bug branch --> mysql-5.1-bugteam latest. 2010-03-16 11:47:15 +00:00
Martin Hansson
0ed4684547 Bug#50918: Date columns treated differently in Views than in
Base Tables

The type inferrence of a view column caused the result to be
interpreted as the wrong type: DATE colums were interpreted
as TIME and TIME as DATETIME. This happened because view
columns are represented by Item_ref objects as opposed to
Item_field's. Item_ref had no method for retrieving a TIME
value and thus was forced to depend on the default
implementation for any expression, which caused the
expression to be evaluated as a string and then parsed into
a TIME/DATETIME value.

Fixed by letting Item_ref classes forward the request for a
TIME value to the referred Item - which is a field in this
case - this reads the TIME value directly without
conversion.
2010-03-16 10:20:07 +01:00
Davi Arnaut
57a96c77db Post-merge fix: replace plugin extension output. 2010-03-14 08:16:59 -03:00
Davi Arnaut
4c205a65fb Post-merge fix: remove unnecessary flush privileges. 2010-03-13 18:32:42 -03:00
Mattias Jonsson
e62c30b5f8 merge 2010-03-12 11:52:38 +01:00
Sergey Vojtovich
e0aadfd491 BUG#47444 - --myisam_repair_threads>1can result in all
index cardinalities=1

Parallel repair didn't poroperly update index cardinality
in certain cases.

When myisam_sort_buffer_size is not enough to store all
keys, index cardinality was updated before index was
actually written, when no index statistic is available.

mysql-test/r/myisam.result:
  A test case for BUG#47444.
mysql-test/t/myisam.test:
  A test case for BUG#47444.
storage/myisam/sort.c:
  update_key_parts() must be called after all index
  entries are written, when index statistic is available.
2010-03-12 14:43:30 +04:00
Mattias Jonsson
7871605bcf merge 2010-03-12 11:41:29 +01:00
Mattias Jonsson
f3190ea61f merged 2010-03-12 11:14:40 +01:00
Mattias Jonsson
78dd2652df Bug#48229: group by performance issue of partitioned table
Additional result file update
2010-03-12 11:14:04 +01:00
Mattias Jonsson
459d04c639 merge 2010-03-11 14:25:33 +01:00
Mattias Jonsson
1a9ec92049 merge 2010-03-11 14:18:44 +01:00
Sergey Vojtovich
4f34e8bbd1 Merge fix for BUG48265 to mysql-5.1-bugteam. 2010-03-11 18:28:39 +04:00
Martin Hansson
dcc5b43b35 Bug#50545: Single table UPDATE IGNORE crashes on
join view in sql_safe_updates mode. 

This bug was unexpectedly fixed along with bug 
number 49534. This patch contains only the test
case.
2010-03-10 17:10:05 +01:00
Sergey Vojtovich
6b69a14543 Merge an addition to BUG51342 5.0-bugteam -> 5.1-bugteam. 2010-03-10 19:31:22 +04:00
Sergey Vojtovich
2a667b7bcb An addition to fix for
BUG#51342 - more xid crashing

Restore autocommit variable by supplying explicit value.

mysql-test/r/xa.result:
  Restore autocommit variable by supplying explicit value.
mysql-test/t/xa.test:
  Restore autocommit variable by supplying explicit value.
2010-03-10 19:28:49 +04:00
Sergey Vojtovich
f0c4da7ca2 Merge fix for BUG51307 to 5.1-bugteam. 2010-03-10 16:32:12 +04:00
Sergey Vojtovich
680cc263ec Merge fix for BUG51342 to 5.1-bugteam. 2010-03-10 16:26:39 +04:00
Mattias Jonsson
29b39e7a44 Bug#51830: Incorrect partition pruning on range partition
(regression)

Problem was that partition pruning did not exclude the
last partition if the range was beyond it
(i.e. not using MAXVALUE)

Fix was to not include the last partition if the
partitioning function value was not within the partition
range.

mysql-test/r/partition_innodb.result:
  Bug#51830: Incorrect partition pruning on range partition
  (regression)
  
  Updated result
mysql-test/r/partition_pruning.result:
  Bug#51830: Incorrect partition pruning on range partition
  (regression)
  
  Updated result
mysql-test/t/partition_innodb.test:
  Bug#51830: Incorrect partition pruning on range partition
  (regression)
  
  Added test for pruning in InnoDB, since it does not show
  for MyISAM due to 'Impossible WHERE noticed after reading
  const tables'.
mysql-test/t/partition_pruning.test:
  Bug#51830: Incorrect partition pruning on range partition
  (regression)
  
  Added test
sql/sql_partition.cc:
  Bug#51830: Incorrect partition pruning on range partition
  (regression)
  
  Also increase the partition id if not inside the last partition
  (and no MAXVALUE is defined).
  
  Added comments and DBUG_ASSERT.
2010-03-10 12:56:05 +01:00
Sergey Vojtovich
992f6754ac Merge fix for BUG51342 to 5.0-bugteam. 2010-03-10 15:07:35 +04:00
Sergey Vojtovich
405fd82207 BUG#51342 - more xid crashing
SET autocommit=1 while XA transaction is active may
cause various side effects, including memory corruption
and server crash.

The problem is that SET autocommit=1 and further queries
attempt to commit local transaction, whereas XA transaction
is still active.

As local and XA transactions are mutually exclusive, this
patch forbids enabling autocommit mode while XA transaction
is active.

mysql-test/r/xa.result:
  A test case for BUG#51342.
mysql-test/t/xa.test:
  A test case for BUG#51342.
sql/set_var.cc:
  Forbid enabling autocommit mode while XA transaction is
  active.
2010-03-10 15:04:32 +04:00
Georgi Kodinov
e48779e929 merge 2010-03-10 12:22:08 +02:00
Georgi Kodinov
91056475e1 merged the test disablement because of bug 51357 to 5.0-bugteam 2010-03-10 12:11:39 +02:00
Georgi Kodinov
d63b0a5c62 Bug #35250: readline check breaks when doing vpath build
MySQL uses two source layouts when building : the bzr 
layout and the source package layout.
The previous fix for bug 35250 contained 1 change that is
valid for both modes and a number of changes that are valid
only for the bzr source layout.
The important thing was to fix the source package layout.
And for this the change in configure.in was sufficient.
It's not trivial (and not requested by this bug) to support 
VPATH builds from the bzr trees.
This is why the other changes are reverted and the change to
fix the VPATH build for source distributions is left intact.
2010-03-09 17:51:31 +02:00
Luis Soares
4dbcac20b4 Post-push fix for BUG#51251.
The test case added in previous patch missed a RESET MASTER on
test start up. Without it, showing binary log contents can
sometimes show spurious entries from previously executed tests,
ultimately causing test failure - result mismatch.

The test file was added in:
revid:luis.soares@sun.com-20100224190153-k0bpdx9abe88uoo2

This patch also moves the test case into binlog_innodb_row.test
file. This way we avoid having yet another test file,
binlog_row_innodb_truncate.test, whose only purpose is to host
one test case. This had been actually suggested during original
patch review, but somehow the binlog_innodb_row was missed when
searching for a file to host the test case.
2010-03-09 23:41:21 +00:00
Davi Arnaut
81ffd72a58 Bug#51770: UNINSTALL PLUGIN requires no privileges
The problem was that UNINSTALL PLUGIN wasn't performing privilege
checks before removing a plugin. Any user (including users without 
any kind of privileges) could uninstall any plugin.

The solution is to verify if the user has the DELETE privilege for
the mysql.plugin table before uninstalling a plugin.

mysql-test/r/plugin_not_embedded.result:
  Add test case result for Bug#51770.
mysql-test/t/plugin_not_embedded-master.opt:
  Add example plugin path.
mysql-test/t/plugin_not_embedded.test:
  Add test case for Bug#51770.
  Skip embedded as test relies on privileges checks.
2010-03-09 09:16:17 -03:00
Sergey Glukhov
b8132a8d94 Bug#41788 mysql_fetch_field returns org_table == table by a view
The problem is that Item_direct_view_ref which is inherited
from Item_ident updates orig_table_name and table_name with
the same values. The fix is introduction of new constructor
into Item_ident and up which updates orig_table_name and
table_name separately.


mysql-test/r/metadata.result:
  test case
mysql-test/t/metadata.test:
  test case
sql/item.cc:
  new constructor which updates
  orig_table_name and table_name
  separately.
sql/item.h:
  new constructor which updates
  orig_table_name and table_name
  separately.
sql/table.cc:
  used new constructor
2010-03-12 10:33:16 +04:00
Davi Arnaut
f502deac11 Bug#40277: SHOW CREATE VIEW returns invalid SQL
The problem is that not all column names retrieved from a SELECT
statement can be used as view column names due to length and format
restrictions. The server failed to properly check the conformity
of those automatically generated column names before storing the
final view definition on disk.

Since columns retrieved from a SELECT statement can be anything
ranging from functions to constants values of any format and length,
the solution is to rewrite to a pre-defined format any names that
are not acceptable as a view column name.

The name is rewritten to "Name_exp_%u" where %u translates to the
position of the column. To avoid this conversion scheme, define
explict names for the view columns via the column_list clause.
Also, aliases are now only generated for top level statements.

mysql-test/include/view_alias.inc:
  Add test case for Bug#40277
mysql-test/r/compare.result:
  Bug#40277: SHOW CREATE VIEW returns invalid SQL
mysql-test/r/group_by.result:
  Bug#40277: SHOW CREATE VIEW returns invalid SQL
mysql-test/r/ps.result:
  Bug#40277: SHOW CREATE VIEW returns invalid SQL
mysql-test/r/subselect.result:
  Bug#40277: SHOW CREATE VIEW returns invalid SQL
mysql-test/r/subselect3.result:
  Bug#40277: SHOW CREATE VIEW returns invalid SQL
mysql-test/r/type_datetime.result:
  Bug#40277: SHOW CREATE VIEW returns invalid SQL
mysql-test/r/union.result:
  Bug#40277: SHOW CREATE VIEW returns invalid SQL
mysql-test/r/view.result:
  Add test case result for Bug#40277
mysql-test/r/view_alias.result:
  Add test case result for Bug#40277
mysql-test/t/view_alias.test:
  Add test case for Bug#40277
sql/sql_view.cc:
  Check if auto generated column names are conforming. Also, the
  make_unique_view_field_name function is not used as it uses the
  original name to construct a new one, which does not work if the
  name is invalid.
2010-03-09 07:36:26 -03:00
Davi Arnaut
02ac873ccf Bug#51650: crash with user variables and triggers
The problem was that bits of the destructive equality propagation
optimization weren't being undone after the execution of a stored
program. Modifications to the parse tree that are based on transient
properties must be undone to enable the re-execution of stored
programs.

The solution is to cleanup any references to predicates generated
by the equality propagation during the execution of a stored program.

mysql-test/r/trigger.result:
  Add test case result for Bug#51650.
mysql-test/t/trigger.test:
  Add test case for Bug#51650.
sql/item.cc:
  Remove reference to a equality predicate.
2010-03-09 18:55:08 -03:00
Georgi Kodinov
fd35fc4ea2 Disable the second part of the test for bug #51357 until bug #51877 is fixed. 2010-03-09 19:00:15 +02:00
Georgi Kodinov
d0bb5465b8 Addendum to the test for bug 51357 : disable the (possibly binary)
output from HANDLER ... READ .. NEXT ...
2010-03-09 15:46:27 +02:00
Luis Soares
f8ce47b7a5 Automerge BUG 51251 bundle from bug report --> mysql-5.1-bugteam. 2010-03-09 00:02:28 +00:00
Luis Soares
3995884714 Automerge BUG 51226 bzr bundle from bug report --> myqsl-5.1-bugteam. 2010-03-08 23:57:26 +00:00
Luis Soares
17a30e02af Automerge: BUG 48993 bundle from bug report --> mysql-5.1-bugteam. 2010-03-08 23:55:19 +00:00
Georgi Kodinov
2ba46ad4fa Backport of the fix for bug #51357 to 5.0-bugteam.:
Spatial indexes were not checking for out-of-record condition in
the handler next command when the previous command didn't found
rows.

Fixed by making the rtree index to check for end of rows condition
before re-using the key from the previous search.

Fixed another crash if the tree has changed since the last search.
Added a test case for the other error.
2010-03-08 12:39:57 +02:00
Mattias Jonsson
1f77c7b49a Bug#50392: insert_id is not reset for partitioned tables
auto_increment on duplicate entry

The bug was that when INSERT_ID was used and the storage
engine was told to release any reserved but not used
auto_increment values, it set the highest auto_increment
value to INSERT_ID.

The fix was to check if the auto_increment value was forced
by user (INSERT_ID) or by slave-thread, i.e. not auto-
generated. So that it is only allowed to release generated
values.

mysql-test/r/partition_error.result:
  Bug#50392: insert_id is not reset for partitioned tables
  auto_increment on duplicate entry
  
  updated result
mysql-test/suite/parts/inc/partition_auto_increment.inc:
  Bug#50392: insert_id is not reset for partitioned tables
  auto_increment on duplicate entry
  
  Added test
mysql-test/suite/parts/r/partition_auto_increment_archive.result:
  Bug#50392: insert_id is not reset for partitioned tables
  auto_increment on duplicate entry
  
  Added result, note that archive does only allow increasing
  auto_increment values
mysql-test/suite/parts/r/partition_auto_increment_blackhole.result:
  Bug#50392: insert_id is not reset for partitioned tables
  auto_increment on duplicate entry
  
  Added result, note that blackhole accepts all inserts :)
mysql-test/suite/parts/r/partition_auto_increment_innodb.result:
  Bug#50392: insert_id is not reset for partitioned tables
  auto_increment on duplicate entry
  
  Added result, note that innodb rolls back inserts on error,
  but keeps the auto_increment value.
mysql-test/suite/parts/r/partition_auto_increment_memory.result:
  Bug#50392: insert_id is not reset for partitioned tables
  auto_increment on duplicate entry
  
  Added result, note that memory and myisam inserts all rows
  before the error.
mysql-test/suite/parts/r/partition_auto_increment_myisam.result:
  Bug#50392: insert_id is not reset for partitioned tables
  auto_increment on duplicate entry
  
  Added result, note that memory and myisam inserts all rows
  before the error.
mysql-test/suite/parts/r/partition_auto_increment_ndb.result:
  Bug#50392: insert_id is not reset for partitioned tables
  auto_increment on duplicate entry
  
  Added result, note that NDB does not seem to handle
  INSERT_ID as other engines. (Martin will look into it).
mysql-test/t/partition_error.test:
  Bug#50392: insert_id is not reset for partitioned tables
  auto_increment on duplicate entry
  
  Added test
sql/ha_partition.cc:
  Bug#50392: insert_id is not reset for partitioned tables
  auto_increment on duplicate entry
  
  If the next_insert_id comes from non generated (i.e
  forced by INSERT_ID or slave-thread) then we cannot
  lower the reserved auto_increment value, since it have
  not reserved any values.
2010-03-04 18:16:10 +01:00
Georgi Kodinov
d934426ff5 Bug #51357: crash when using handler commands on spatial indexes
Spatial indexes were not checking for out-of-record condition in
the handler next command when the previous command didn't found
rows.

Fixed by making the rtree index to check for end of rows condition
before re-using the key from the previous search.

Fixed another crash if the tree has changed since the last search.
Added a test case for the other error.
2010-03-04 18:13:08 +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
Tatiana A. Nurnberg
fbad82deaa auto-merge 2010-03-05 17:45:29 +00:00
Tatiana A. Nurnberg
823661bdf0 manual merge 2010-03-05 16:44:37 +00:00
Ramil Kalimullin
2eb9d388f6 Fix for bug#32426: "FEDERATED query returns corrupt results
for ORDER BY on a TEXT or VARCHAR field" backported to 5.1.
2010-03-05 14:51:37 +04:00
Tatiana A. Nurnberg
62809e2a09 auto-merge 2010-03-04 12:39:29 +00:00
Mattias Jonsson
48d986f511 Bug#50104: Partitioned table with just 1 partion works with fk
There was no check for foreign keys when altering partitioned
tables.

Added check for FK when altering partitioned tables.

mysql-test/r/partition_innodb.result:
  Bug#50104: Partitioned table with just 1 partion works with fk
  
  Updated test result
mysql-test/t/partition_innodb.test:
  Bug#50104: Partitioned table with just 1 partion works with fk
  
  Added test for adding FK on partitioned tables (both 1 and 2
  partitions)
sql/sql_partition.cc:
  Bug#50104: Partitioned table with just 1 partion works with fk
  
  Disabled adding foreign key when altering a partitioned table.
2010-03-04 12:29:22 +01:00
Mattias Jonsson
e46d120e8e Bug#48229: group by performance issue of partitioned table
Problem was block_size on partitioned tables was not set,
resulting in keys_per_block was not correct which affects
the cost calculation for read time of indexes (including
cost for group min/max).Which resulted in a bad optimizer
decision.

Fixed by setting stats.block_size correctly.

mysql-test/r/partition_range.result:
  Bug#48229: group by performance issue of partitioned table
  
  Added result
mysql-test/t/partition_range.test:
  Bug#48229: group by performance issue of partitioned table
  
  Added test
sql/ha_partition.cc:
  Bug#48229: group by performance issue of partitioned table
  
  Added missing assignment of stats.block_size.
2010-03-04 12:09:09 +01:00
Luis Soares
7768ccbb54 BUG#51055: Replication failure on duplicate key + traditional SQL
mode

When the master was executing in sql_mode='traditional' (which
implies that really_abort_on_warning returns TRUE - because of
MODE_STRICT_ALL_TABLES), the error code (ER_DUP_ENTRY in the
reported case) was not being set in the
Query_log_event. Therefore, even if a failure was to be expected
when replaying the statement on the slave, a failure would occur,
because the Query_log_event was not transporting the expected
error code, but 0 instead.

This was because when the master was getting the error code to
set it in the Query_log_event, the executing thread would be
assumed to have been killed:
THD::killed==THD::KILL_BAD_DATA. This would make the error code
fetch routine not to check thd->main_da.sql_errno(), but instead
the thd->killed value. What's more, is that the server would
thd->killed value if thd->killed == THD::KILL_BAD_DATA and return
0 instead. So this is a double inconsistency, as the we should
not even check thd->killed but rather thd->main_da.sql_errno().

We fix this by extending the condition used to choose whether to
check the thd->main_da.sql_errno() or thd->killed, so that it
takes into consideration the case when:
thd->killed==THD::KILL_BAD_DATA.
2010-03-04 10:18:06 +00:00
Luis Soares
d13db314dd BUG#51226: mysqlbinlog replay: ERROR 1146 when using temp tables
+ failing statements

Implicit DROP event for temporary table is not getting
LOG_EVENT_THREAD_SPECIFIC_F flag, because, in the previous
executed statement in the same thread, which might even be a
failed statement, the thread_specific_used flag is set to
FALSE (in mysql_reset_thd_for_next_command) and not set to TRUE
before connection is shutdown. This means that implicit DROP
event will take the FALSE value from thread_specific_used and
will not set LOG_EVENT_THREAD_SPECIFIC_F in the event header. As
a consequence, mysqlbinlog will not print the pseudo_thread_id
from the DROP event, because one of the requirements for the
printout is that this flag is set to TRUE.

We fix this by setting thread_specific_used whenever we are
binlogging a DROP in close_temporary_tables, and resetting it to
its previous value afterward.
2010-03-03 12:16:18 +00:00
Sergey Vojtovich
1d2aeb3da2 BUG#48265 - MRG_MYISAM problem (works in 5.0.85, does't
work in 5.1.40)

MERGE engine fails to open child table from a different
database if child table/database name contains characters
that are subject for table name to filename encoding
(WL1324).

Another problem is that MERGE engine didn't properly open
child table from the same database if child table name
contains characters like '/', '#'.

The problem was that table name to file name encoding was
applied inconsistently:
* On CREATE: encode table name + database name if child
  table is in different database; do not encode table
  name if child table is in the same database;
* No decoding on open.

With this fix child table/database names are always
encoded on CREATE and decoded on open. Compatibility
with older tables preserved.

Along with this patch comes fix for SHOW CREATE TABLE,
which used to show child table/database path instead
of child table/database names.

mysql-test/r/merge.result:
  A test case for BUG#48265.
mysql-test/std_data/bug48265.frm:
  MERGE table from 5.0 to test fix for BUG#48265 compatibility.
mysql-test/t/merge.test:
  A test case for BUG#48265.
storage/myisammrg/ha_myisammrg.cc:
  On CREATE always write child table/database name encoded
  by table name to filename encoding to dot-MRG file.
  
  On open decode child table/database name.
  Compatibilty with previous versions preserved.
  
  Fixed ::append_create_info() to return child
  table/database name instead of path.
storage/myisammrg/myrg_open.c:
  Move if (has_path) branch from myrg_parent_open() to
  myisammrg_parent_open_callback. The callback function
  needs to know if child table was written along with
  database name to dot-MRG file. Needed for compatibility
  reasons.
2010-03-03 14:49:03 +04:00
Tatiana A. Nurnberg
a3edaa0cea manual merge 2010-03-02 18:13:43 +00:00
Tatiana A. Nurnberg
c610e9783a Bug#48295: explain extended crash with subquery and ONLY_FULL_GROUP_BY sql
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).

backport from 5.1

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.
2010-03-02 18:00:53 +00:00
Tatiana A. Nurnberg
42585b098e auto-merge 2010-03-02 16:18:16 +00:00
Georgi Kodinov
ee4a3099b3 Moved the ndb related tests out of the per-push pb2 run to the daily pb2 run. 2010-03-02 14:43:21 +02:00
Sergey Vojtovich
a82cc50958 BUG#51307 - widespread corruption with partitions and
insert...select

Queries following bulk insert into an empty MyISAM table
may break it. This was pure MyISAM problem.

When bulk insert into an empty table is complete, MyISAM
may want to enable indexes via repair by sort. If repair
by sort fails (e.g. insufficient buffer), MyISAM failover
to repair with key cache, requesting repair of data file.

Repair of data file performs data file substitution. This
means that current table instance will point to new data
file. Other cached table instances are still pointing to
an old, deleted data file.

This is fixed by not requesting repair of data file
during enable indexes.

Explicit REPAIR is not affected, since it flushes all
table instances.

mysql-test/r/myisam.result:
  A test case for BUG#51307.
mysql-test/t/myisam.test:
  A test case for BUG#51307.
storage/myisam/ha_myisam.cc:
  When enabling indexes do not attempt to repair data file.
2010-03-02 13:45:50 +04:00
Andrei Elkin
dbb9e58c13 Bug #51600 rpl_slave_skip waits for slave to stop incorrectly
START SLAVE UNTIL MASTER ... specifies only SQL thread to stop.
rpl_slave_skip erronously deployed waiting for stop of both threads.

Corrected with deploying the correct macro.
Notice, earlier a similar bug@47749 was fixed in mysql-trunk.

mysql-test/suite/rpl/t/rpl_slave_skip.test:
  changing two waiting calls for offline of both threads into waiting for SQL to stop.
2010-03-01 14:33:15 +02:00
Ramil Kalimullin
9715539ebd Fix for bug#51304: checksum table gives different results
for same data when using bit fields

Problem: checksum for BIT fields may be computed incorrectly 
in some cases due to its storage peculiarity.

Fix: convert a BIT field to a string then calculate its checksum.


mysql-test/r/myisam.result:
  Fix for bug#51304: checksum table gives different results 
  for same data when using bit fields
    - test result.
mysql-test/t/myisam.test:
  Fix for bug#51304: checksum table gives different results 
  for same data when using bit fields
    - test case.
sql/sql_table.cc:
  Fix for bug#51304: checksum table gives different results 
  for same data when using bit fields
    - convert BIT fields to strings calculating its checksums
  as some bits may be saved among NULL bits in the record buffer.
2010-02-28 21:29:19 +04:00
Andrei Elkin
723e67b925 Bug #51574 rpl_row_create_table fails in ps-protocol at CREATE TABLE IF NOT EXISTS bug48506
disabling the test to not run on PB
2010-02-27 17:08:53 +02:00
Davi Arnaut
0ecc8963a0 Force execution now that another test case might run mysql_upgrade first.
mysql-test/t/mysql_upgrade.test:
  For execution, mostly testing the presence of the binary anyway.
2010-02-26 23:19:59 -03:00
Andrei Elkin
684b293c22 merging from 5.1 rep to a local branch 2010-02-26 22:00:03 +02:00
Andrei Elkin
7fcd6c5989 merging from 5.1 rep to a local branch 2010-02-26 21:07:26 +02:00
Sergey Glukhov
ca6691533a Bug#47669 Query showed by EXPLAIN EXTENDED gives different result from original query
Item_field::print method does not take into
account fields whose values may be null.
The fix is to print 'NULL' if field value is null.


mysql-test/r/explain.result:
  test case
mysql-test/r/func_str.result:
  result fix
mysql-test/r/having.result:
  result fix
mysql-test/r/select.result:
  result fix
mysql-test/r/subselect.result:
  result fix
mysql-test/r/union.result:
  result fix
mysql-test/t/explain.test:
  test case
sql/item.cc:
  print 'NULL' if field value is null.
2010-02-26 17:40:01 +04:00
Andrei Elkin
817debb65b merging from 5.1-bt rep to local branch 2010-02-26 15:14:34 +02:00
Sergey Vojtovich
fe229e33f7 Merge innodb-5.1-ss6765 to 5.1-bugteam. 2010-02-26 16:34:13 +04:00
Davi Arnaut
b0a1ae09ae Bug#49823: mysql_upgrade fatal error due to general_log / slow_low CSV NULL
The problem was that the CSV storage engine does not support NULL
fields, yet in some early 5.1 version the log tables (general_log
and slow_log) were created with null fields. On top of this, when
altering a CSV table column, all fields of the table must be NOT
NULL otherwise the alteration fails.

The solution is to ensure that during upgrade all columns of the
log tables are NOT NULL.

mysql-test/r/log_tables_upgrade.result:
  Add test case result for Bug#49823.
mysql-test/std_data/bug49823.CSV:
  Sample data for test.
mysql-test/std_data/bug49823.frm:
  Add a CSV table which mimics the general_log table, except that
  it contains a nullable column.
mysql-test/t/log_tables_upgrade.test:
  Add test case for Bug#49823.
scripts/mysql_system_tables_fix.sql:
  Ensure that all columns of the log tables are NOT NULL.
2010-02-26 09:22:48 -03:00
Andrei Elkin
f16145a592 merging fixes of bug@45576 to 5.1-bt 2010-02-26 14:19:49 +02:00
Sergey Glukhov
03561d35e3 automerge 2010-02-26 16:19:05 +04:00
Andrei Elkin
5693e220d5 Bug #45576 rpl_row_create_table fails on PB2
The test failed due to Bug #29790.
However, logics of the failing part does not need I_S selecting.

Fixing to remove the non-deterministic I_S selecting as redundant
from a part of the test dealing with BUG@22864.


mysql-test/suite/rpl/r/rpl_row_create_table.result:
  results updated.
mysql-test/suite/rpl/t/disabled.def:
  rpl_row_create_table is re-enabled.
mysql-test/suite/rpl/t/rpl_row_create_table.test:
  removed a non-deterministic I_S selecting as redundant
  from a part of the test dealing with BUG@22864.
2010-02-26 14:18:13 +02:00
Andrei Elkin
b3c6f110b2 merging fixes of bug@51089 to 5.1-bt 2010-02-26 14:10:08 +02:00
Andrei Elkin
058b494051 merging fixes of bug@51089 to 5.1-bt 2010-02-26 14:09:47 +02:00
Andrei Elkin
991c69e991 bug#51089
correcting c&p typos in the results
2010-02-26 14:09:26 +02:00