Commit graph

20054 commits

Author SHA1 Message Date
John H. Embretsen
c2f4219a3e Merge fix for bug 56817 from mysql-5.1 to mysql-5.5. 2011-01-29 12:49:55 +01:00
John H. Embretsen
2388766830 Fix for Bug#56817 - mysqlhotcopy tests fail when DBI and DBD-mysql perl modules are not found
Third updated patch - this version also includes copyright notice in added Perl script.
This patch implements a check for such modules at runtime. If modules are not found or unable to load, the test is skipped with 
the following message:
            
            [ skipped ]  Test needs Perl modules DBI and DBD::mysql
            
Checks are done via a helper Perl script which looks for the module in a runtime environment that is as similar to that of the 
mysqlhotcopy script as possible (thus not intended for Windows environments at this time).
The helper script tells mysql-test about the result by writing information to a temporary file that is later read by mysql-test.
See comments in added files (have_dbi_dbd-mysql.inc and checkDBI_DBD-mysql.pl) for details.
The patch also removes the mysqlhotcopy tests from the list of disabled tests.
2011-01-29 12:38:36 +01:00
Mattias Jonsson
04a8611112 merge of bug 47902 and (null-merge) of bug 57924.
bug#57924 does not occur in 5.5, so I reverted the 5.1 specific
code and used the errors from 5.5 instead in the tests
2011-01-26 19:33:53 +01:00
Mattias Jonsson
4e47db3af4 merge 2011-01-26 16:50:21 +01:00
Jon Olav Hauglid
5e03579061 Bug #42230 during add index, cannot do queries on storage engines
that implement add_index

The problem was that ALTER TABLE blocked reads on an InnoDB table
while adding a secondary index, even if this was not needed. It is
only needed for the final step where the .frm file is updated.

The reason queries were blocked, was that ALTER TABLE upgraded the
metadata lock from MDL_SHARED_NO_WRITE (which blocks writes) to
MDL_EXCLUSIVE (which blocks all accesses) before index creation.

The way the server handles index creation, is that storage engines
publish their capabilities to the server and the server determines
which of the following three ways this can be handled: 1) build a
new version of the table; 2) change the existing table but with
exclusive metadata lock; 3) change the existing table but without
metadata lock upgrade.

For InnoDB and secondary index creation, option 3) should have been
selected. However this failed for two reasons. First, InnoDB did
not publish this capability properly.

Second, the ALTER TABLE code failed to made proper use of the
information supplied by the storage engine. A variable
need_lock_for_indexes was set accordingly, but was not later used.
This patch fixes this problem by only doing metadata lock upgrade
before index creation/deletion if this variable has been set.

This patch also changes some of the related terminology used 
in the code. Specifically the use of "fast" and "online" with
respect to ALTER TABLE. "Fast" was used to indicate that an
ALTER TABLE operation could be done without involving a
temporary table. "Fast" has been renamed "in-place" to more
accurately describe the behavior.

"Online" meant that the operation could be done without taking
a table lock. However, in the current implementation writes
are always prohibited during ALTER TABLE and an exclusive
metadata lock is held while updating the .frm, so ALTER TABLE
is not completely online. This patch replaces "online" with 
"in-place", with additional comments indicating if concurrent
reads are allowed during index creation/deletion or not.

An important part of this update of terminology is renaming
of the handler flags used by handlers to indicate if index
creation/deletion can be done in-place and if concurrent reads
are allowed. For example, the HA_ONLINE_ADD_INDEX_NO_WRITES
flag has been renamed to HA_INPLACE_ADD_INDEX_NO_READ_WRITE,
while HA_ONLINE_ADD_INDEX is now HA_INPLACE_ADD_INDEX_NO_WRITE.
Note that this is a rename to clarify current behavior, the
flag values have not changed and no flags have been removed or
added.

Test case added to innodb_mysql_sync.test.
2011-01-26 14:23:29 +01:00
Martin Hansson
616e2227cc Bug#59173: Failure to handle DATE(TIME) values where Year, Month or Day is
ZERO
      
When dates are represented internally as strings, i.e. when a string constant
is compared to a date value, both values are converted to long integers,
ostensibly for fast comparisons. DATE typed integer values are converted to
DATETIME by multiplying by 1,000,000 (each digit pair representing hour,
minute and second, respectively). But the mechanism did not distuinguish
cached INTEGER values, already in correct format, from newly converted
strings.

Fixed by marking the INTEGER cache as being of DATETIME format.
2011-01-19 15:09:32 +01:00
Alexander Barkov
cf0e22fe75 Bug#44332 my_xml_scan reads behind the end of buffer
Problem: the scanner function tested for strings "<![CDATA[" and
"-->" without checking input string boundaries, which led to valgrind's
"Conditional jump or move depends on uninitialised value(s)" error.

Fix: Adding boundary checking.

  @ mysql-test/r/xml.result
  @ mysql-test/t/xml.test
  Adding test

  @ strings/xml.c
  Adding a helper function my_xml_parser_prefix_cmp(),
  with input string boundary check.
2011-01-18 09:38:41 +03:00
Alexander Barkov
18e4f23a88 Bug#58371 Assertion failed: !s.uses_buffer_owned_by(this) with format string function
Introduced by the fix for bug#44766.

Problem: it's not correct to use args[0]->str_value as a buffer,
because args[0] may need this buffer for its own purposes.

Fix: adding a new class member tmp_value to use as return value.

  @ mysql-test/r/ctype_many.result
  @ mysql-test/t/ctype_many.test
  Adding tests

  @ sql/item_strfunc.cc
  Changing code into traditional style:
  use "str" as a buffer for the argument and tmp_value for the result value.

  @ sql/item_strfunc.h
  Adding tmp_value
2011-01-17 15:11:33 +03:00
Alexander Barkov
1c9515f616 Bug#59149 valgrind warnings with "like .. escape .." function
Problem: when processing a query like:
  SELECT '' LIKE '1' ESCAPE COUNT(1);
escape_item->val_str() was never executed and the "escape" class member
stayed initialized, which led to valgrind uninitialized memory error.
      
Note, a query with some tables in "FROM" clause
returns ER_WRONG_ARGUMENTS in the same situation:

   SELECT '' LIKE '1' ESCAPE COUNT(1) FROM t1;
   ERROR 1210 (HY000): Incorrect arguments to ESCAPE

Fix: disallowing using aggregate functions in ESCAPE clause,
even if there are no tables used. There is no much use of that anyway.
2011-01-17 12:30:22 +03:00
Nirbhay Choubey
44d23cdbc0 Bug#58221 : mysqladmin --sleep=x --count=x keeps looping
When mysqldadmin is run with sleep and count options,
it goes into an infinite loop and keeps executing the
specified command.

This happened because the statement, responsible for
decrementing the count value, was missing.

Fixed by adding a statement which will decrement the
count value for each iteration.
2011-01-16 02:04:08 +05:30
Alexey Botchkov
0b6925002f Bug#52208 gis fails on some platforms (Solaris, HP-UX, Linux)
IA64 and some other arcitectures use different float rounding mode and
        i find no decent way to make it consistent.
        So the test changed to be insensitive to this.

per-file messages:
  mysql-test/t/gis.test
Bug#52208      gis fails on some platforms (Solaris, HP-UX, Linux)
        --replace_result added
2011-01-15 00:56:09 +04:00
Martin Hansson
99f18f0ffa Merge of fix for Bug#59173. 2011-01-19 15:12:43 +01:00
John H. Embretsen
634b102533 Post push test fix for show_check.test.
Fix for bug#45740 introduced test case using SHOW TABLE STATUS against a Memory table using latin1 character in table name.
The test failed on Windows and FreeBSD due to a difference in the value for Avg_row_length.
The average row length normally depends on the values for data length and row count. According to the 5.5 manual data length is approximate with Memory tables.
With MyISAM and InnoDB the Avg_row_length is the same on Windows and Solaris.
The solution implemented by this patch is to mask out the value for Avg_row_length, as it may vary when using Memory tables.
2011-01-18 13:04:17 +01:00
Alexander Barkov
8a576b8360 Merging from 5.1. 2011-01-18 09:50:03 +03:00
Nirbhay Choubey
95e07a6fb7 Bug#13618 : mysqldump --xml omits comment on table field
When mysqldump tries to dump information in xml format,
the result does not contain field level comments.

In order to retrieve various informations for a field/column,
mysqldump currently uses 'show fields from <tab>' statement.
The attributes returned by the statement lacks the information
regarding field comments.

Fixed by changing the query to one that probes I_S to retrieve
required field informations, including the field comment.
2011-01-14 19:50:34 +05:30
Luis Soares
e55b6e5767 Automerge from bug branch into latest mysql-5.1. 2011-01-13 11:41:00 +00:00
Martin Hansson
3ef71bfac7 Bug#58165: "my_empty_string" gets modified and causes LOAD DATA to fail and
other crashes

Some string manipulating SQL functions use a shared string object intended to
contain an immutable empty string. This object was used by the SQL function
SUBSTRING_INDEX() to return an empty string when one argument was of the wrong
datatype. If the string object was then modified by the sql function INSERT(),
undefined behavior ensued.

Fixed by instead modifying the string object representing the function's
result value whenever string manipulating SQL functions return an empty
string.

Relevant code has also been documented.
2011-01-13 08:57:15 +01:00
Bjorn Munch
f23725f2bb merge from 5.1-mtr 2011-01-12 23:29:53 +01:00
Luis Soares
51c6f8ebac BUG#59177: mysqlbinlog_row_big fails on Windows with out of memory
The test case fails with out of memory while updating a table
with several multi-megabytes sized rows. This can probably be too
exhausting for PB2 env.
      
The quick fix here is to reduce the size of the biggest
row (256MB) so that it becomes a little smaller (64MB).
2011-01-12 19:32:45 +00:00
Bjorn Munch
06c43adcad merge from 5.1 2011-01-12 15:20:40 +01:00
Dmitry Lenev
94fbedd3e3 Fix for bug #58499 "DEFINER-security view selecting from
INVOKER-security view access check wrong".

When privilege checks were done for tables used from an 
INVOKER-security view which in its turn was used from 
a DEFINER-security view connection's active security
context was incorrectly used instead of security context
with privileges of the second view's creator.

This meant that users which had enough rights to access
the DEFINER-security view and as result were supposed to 
be able successfully access it were unable to do so in 
cases when they didn't have privileges on underlying tables 
of the INVOKER-security view.

This problem was caused by the fact that for INVOKER-security
views TABLE_LIST::security_ctx member for underlying tables
were set to 0 even in cases when particular view was used from 
another DEFINER-security view. This meant that when checks of
privileges on these underlying tables was done in
setup_tables_and_check_access() active connection security 
context was used instead of context corresponding to the 
creator of caller view.

This fix addresses the problem by ensuring that underlying
tables of an INVOKER-security view inherit security context
from the view and thus correct security context is used for
privilege checks on underlying tables in cases when such view 
is used from another view with DEFINER-security.
2011-01-12 16:08:30 +03:00
Alexey Botchkov
e073e2c0be Bug #57321 crashes and valgrind errors from spatial types
Item_func_spatial_collection::fix_length_and_dec didn't call parent's method, so
        the maybe_null was set to '0' after it. But in this case the result was
        just NULL, that caused wrong behaviour.

per-file comments:
  mysql-test/r/gis.result
Bug #57321 crashes and valgrind errors from spatial types 
        test result updated.

  mysql-test/t/gis.test
Bug #57321 crashes and valgrind errors from spatial types 
        test case added.
  sql/item_geofunc.h
Bug #57321 crashes and valgrind errors from spatial types 
        Item_func_geometry::fix_length_and_dec() called in
        Item_func_spatial_collection::fix_length_and_dec().
2011-01-12 17:02:41 +04:00
Martin Hansson
fc42cbaca3 Bug#58207: invalid memory reads when using default column value and
tmptable needed

The function DEFAULT() works by modifying the the data buffer pointers (often
referred to as 'record' or 'table record') of its argument. This modification
is done during name resolution (fix_fields().) Unfortunately, the same
modification is done when creating a temporary table, because default values
need to propagate to the new table.

Fixed by skipping the pointer modification for fields that are arguments to
the DEFAULT function.
2011-01-12 09:55:31 +01:00
Bjorn Munch
0630418539 Bug #58900 query_get_value crashes when result begins with dollar sign
Generalized fix for recursive backtick
Optional arg to eval_expr telling it not to interpret
2011-01-11 10:54:42 +01:00
Mattias Jonsson
9ecf315679 Bug#57924: crash when creating partitioned table with
multiple columns in the partition key

ndb crash if duplicate columns in the partitioning key.

Backport from mysql-5.1-telco-7.0, see bug#53354.

Changed from case sensitive field name comparision
to non case sensitive too.
2011-01-10 16:20:28 +01:00
Mattias Jonsson
99e95e8dab merge 2011-01-10 12:56:27 +01:00
Jon Olav Hauglid
78df8c4fba Bug #50619 assert in handler::update_auto_increment
This assert could be triggered if -1 was inserted into
an auto increment column by a statement writing more than
one row.

Unless explicitly given, an interval of auto increment values
is generated when a statement first needs an auto increment
value. The triggered assert checks that the auto increment
counter is equal to or higher than the lower bound of this
interval.

Generally, the auto increment counter starts at 1 and is
incremented by 1 each time it is used. However, inserting an
explicit value into the auto increment column, sets the auto
increment counter to this value + 1 if this value is higher
than the current value of the auto increment counter.

This bug was triggered if the explicit value was -1. Since the
value was converted to unsigned before any comparisons were made,
it was found to be higher than the current vale of the auto
increment counter and the counter was set to -1 + 1. This value
was below the reserved interval and caused the assert to be
triggered the next time the statement tried to write a row.

With the patch for Bug#39828, this bug is no longer repeatable.
Now, -1 + 1 is detected as an "overflow" which causes the auto
increment counter to be set to ULONGLONG_MAX. This avoids hitting
the assert for the next insert and causes a new interval of
auto increment values to be generated. This resolves the issue.

This patch therefore only contains a regression test and no code
changes. Test case added to auto_increment.test.
2011-01-04 14:36:37 +01:00
Mattias Jonsson
16994abf9a merge 2011-01-04 14:13:20 +01:00
Alexander Barkov
b627c68162 Merging from 5.1. 2011-01-17 15:26:13 +03:00
Alexander Barkov
a16fea437c Merging from mysql-5.1 2011-01-17 12:39:59 +03:00
John H. Embretsen
67bcf3e3be Fix for Bug#45730 - Test case disabled in show_check.test due to WL#1324.
Enabled test snippet for bug 4374, tested on Mac OS X 10.6 as well as Solaris.
Moved test snippet to a different place in the file, in order to avoid having 
to save and restore "SET NAMES" setting. New surroundings expect latin1, as is 
used in the testsnippet.

An extra copy of the commented test snippet is removed, a comment is added,
SQL keywords are converted to uppercase, and engine name "heap" is updated to 
"Memory".

Also added Copyright statement and a notice about the file's encoding(s).
2011-01-17 08:12:38 +01:00
Nirbhay Choubey
974bf57dac Bug#58139 : default-auth option not recognized in MySQL standard
command line clients.

Postfix covering other mysql standard clients like mysql_upgrade,
mysqlbinlog, mysqlcheck, mysqlimport, mysqlshow and mysqlslap.
2011-01-16 09:29:05 +05:30
Nirbhay Choubey
fbc10eeb9d Merge of fix for bug#58221 from mysql-5.1 -> mysql-5.5. 2011-01-16 02:08:24 +05:30
Alexey Botchkov
d027ad5193 merging. 2011-01-15 01:02:02 +04:00
Tor Didriksen
02d7b27641 Bug #59498 div function broken in mysql-trunk 2011-01-14 15:03:37 +01:00
Nirbhay Choubey
43a2f80e16 Merging fix of Bug#13618 from mysql-5.1. 2011-01-14 20:11:00 +05:30
Tor Didriksen
8dfab82ee0 Bug #59241 invalid memory read in do_div_mod with doubly assigned variables
Fix: copy my_decimal by value, to avoid dangling pointers.
2011-01-14 10:05:14 +01:00
Luis Soares
df7ab312af Automerge from mysql-5.1 into latest mysql-5.5. 2011-01-13 11:42:34 +00:00
Ole John Aske
970c3fb244 Fix for #58422: Incorrect result when OUTER JOIN'ing with an empty table.
Fixed incorrect checks in join_read_const_table() for when to 
accept a non-existing, or empty const-row as a part of the const'ified 
set of tables.
      
Intention of this test is to only accept NULL-rows if this table is outer joined
into the resultset. (In case of an inner-join we can conclude at this point that 
resultset will be empty, end we want to return 'error' to signal this.)
      
Initially 'maybe_null' is set to the same value as 'outer_join' in 
setup_table_map(), mysql_priv.h ~line 2424. Later simplify_joins() will
attemp to replace outer joins by inner join whenever possible. This
will cause 'outer_join' to be updated. However, 'maybe_null' is *not* updated
to reflect this rewrite as this field is used to currectly set the 'nullability'
property for the columns in the resultset.
      
We should therefore change join_read_const_table() to check the 'outer_join'
property instead of 'maybe_null', as this correctly reflect the nullability of
the *execution plan* (not *resultset*).
2011-01-13 11:42:48 +01:00
Ole John Aske
3e1ce666c4 Fix for Bug#57034 incorrect OUTER JOIN result when joined on unique key
Item_equal::val_int() checked for NULL-values by checking Item::null_value
*before* the respective ::store_value() and ::cmp(Item*) metods where called.

As Item::null_value is set by these metods, the value of 'null_value' 
is not valid until *after* ::store_value() or ::cmp() has
been called for the Item object.
      
Fix is to swap order of ::store_value()/::cmp() and checking of Item::null_value.
This pattern is widely used other places inside item_cmpfunc.cc .
2011-01-13 09:33:30 +01:00
Martin Hansson
cecc99db20 Merge of fix for Bug#58165. 2011-01-13 09:07:21 +01:00
Bjorn Munch
1dc4837a15 merge from 5.5-mtr 2011-01-12 23:32:39 +01:00
Evgeny Potemkin
ce692c661a Auto-merge. 2011-01-12 19:47:00 +03:00
Bjorn Munch
d3c60fa6b4 merge from 5.5 main 2011-01-12 15:25:59 +01:00
Dmitry Lenev
bc8e89c926 Merged fix for bug #58499 "DEFINER-security view selecting from
INVOKER-security view access check wrong" into mysql-5.5 tree.
2011-01-12 16:28:33 +03:00
Alexey Botchkov
405fb864c5 merging. 2011-01-12 17:11:31 +04:00
Evgeny Potemkin
d6922c7e83 Bug#59330: Incorrect result when comparing an aggregate function with
TIMESTAMP.

Item_cache::get_cache wasn't treating TIMESTAMP as a DATETIME value thus
returning string cache for items with TIMESTAMP type. This led to incorrect
TIMESTAMP -> INT conversion and to a wrong query result.

Fixed by using Item::is_datetime function to check for DATETIME type group.
2011-01-12 15:58:47 +03:00
Ole John Aske
003e87fef0 Fix for bug#58818: Incorrect result for IN/ANY subquery
If the ::single_value_transformer() find an existing HAVING condition it used
to do the transformation:
            
  1) HAVING cond -> (HAVING Cond) AND (cond_guard (Item_ref_null_helper(...))
      
As the AND condition in 1) is Mc'Carty evaluated, the
right side of the AND cond should be executed only if the 
original 'HAVING evaluated' to true.
      
However, as we failed to set 'top_level' for the tranformed HAVING condition,
'abort_on_null' was FALSE after transformation. An
UNKNOWN having condition will then not terminate evaluation of the
transformed having condition, and we incorrectly continued
into the Item_ref_null_helper() part.
2011-01-12 13:15:22 +01:00
Martin Hansson
b48abbc5e1 Merge of fix for Bug#58207. 2011-01-12 10:31:41 +01:00
Bjorn Munch
3494a915fa upmerge 58896,58900,59002 2011-01-11 15:15:25 +01:00