Commit graph

26029 commits

Author SHA1 Message Date
Dmitry Shulga
6c777a6220 Fixed bug#58026 - massive recursion and crash in regular expression
handling.

The problem was that parsing of nested regular expression involved
recursive calls. Such recursion didn't take into account the amount of
available stack space, which ended up leading to stack overflow crashes.
2011-02-04 10:47:46 +06:00
Georgi Kodinov
63a40fe65c merge 2011-02-02 20:13:11 +02:00
Georgi Kodinov
6954b67255 Bug #52315 part 2 addendum : reset back the timestamp 2011-02-02 20:10:57 +02:00
Georgi Kodinov
ac3243c8c8 merge to 5.1. 2011-02-02 19:05:28 +02:00
Georgi Kodinov
59f68983ff Fixes for Bug #55755 and Bug #52315 part 2
Bug #55755 : Date STD variable signness breaks server on FreeBSD and OpenBSD

* Added a check to configure on the size of time_t
* Created a macro to check for a valid time_t that is safe to use with datetime 
  functions and store in TIMESTAMP columns.
* Used the macro consistently instead of the ad-hoc checks introduced by 52315
* Fixed compliation warnings on platforms where the size of time_t is smaller than
  the size of a long (e.g. OpenBSD 4.8 64 amd64).

Bug #52315: utc_date() crashes when system time > year 2037

* Added a correct check for the timestamp range instead of just variable size check to
SET TIMESTAMP.
* Added overflow checking before converting to time_t. 
* Using a correct localized error message in this case instead of the generic error.
* Added a test suite.
* fixed the checks so that they check for unsigned time_t as well. Used the checks 
  consistently across the source code.
* fixed the original test case to expect the new error code.
2011-02-02 18:51:35 +02:00
Dmitry Lenev
3473329d3b Fix for bug #58650 "Failing assertion: primary_key_no == -1 ||
primary_key_no == 0".

Attempt to create InnoDB table with non-nullable column of
geometry type having an unique key with length 12 on it and
with some other candidate key led to server crash due to
assertion failure in both non-debug and debug builds.

The problem was that such a non-candidate key could have
been sorted as the first key in table/.FRM, before any legit
candidate keys. This resulted in assertion failure in InnoDB
engine which assumes that primary key should either be the
first key in table/.FRM or should not exist at all.

The reason behind such an incorrect sorting was an wrong
value of Create_field::key_length member for geometry field
(which was set to its pack_length == 12) which confused code
in mysql_prepare_create_table(), so it would skip marking
such key as a key with partial segments.

This patch fixes the problem by ensuring that this member
gets the same value of Create_field::key_length member as 
for other blob fields (from which geometry field class is
inherited), and as result unique keys on geometry fields
are correctly marked as having partial segments.
2011-02-02 16:17:48 +03:00
Ole John Aske
c8de3bba8e Fix for bug#57030: ('BETWEEN' evaluation is incorrect')
Root cause for this bug is that the optimizer try to detect&
optimize the special case:
      
'<field>  BETWEEN c1 AND c1' and handle this as the condition '<field>  = c1'
            
This was implemented inside add_key_field(.. *field, *value[]...)
which assumed field to refer key Field, and value[] to refer a [low...high]
constant pair. value[0] and value[1] was then compared for equality.
            
In a 'normal' BETWEEN condition of the form '<field>  BETWEEN val1 and val2' the
BETWEEN operation is represented with an argementlist containing the
values [<field>, val1, val2] - add_key_field() is then called with
parameters field=<field>, *value=val1.
            
However, if the BETWEEN predicate specified:
            
 1)  '<const1>  BETWEEN<const2>  AND<field>
            
the 'field' and 'value' arguments to add_key_field() had to be swapped.
This was implemented by trying to cheat add_key_field() to handle it like:
            
 2) '<const1>  GE<const2>  AND<const1>  LE<field>'
            
As we didn't really replace the BETWEEN operation with 'ge' and 'le',
add_key_field() still handled it as a 'BETWEEN' and compared the (swapped)
arguments<const1>  and<const2>  for equality. If they was equal, the
condition 1) was incorrectly 'optimized' to:
            
 3) '<field>  EQ <const1>'
            
This fix moves this optimization of '<field>  BETWEEN c1 AND c1' into
add_key_fields() which then calls add_key_equal_fields() to collect 
key equality / comparison for the key fields in the BETWEEN condition.
2011-02-01 13:20:16 +01:00
Alfranio Correia
b6b7be691c Post-fix for BUG#59338. 2011-01-31 14:31:33 +00:00
Alfranio Correia
cb52e82ea7 merge mysql-5.1 (local) --> mysql-5.1 2011-01-31 10:11:01 +00:00
Alfranio Correia
631f5d0ef3 merge mysql-5.1 (local) --> mysql-5.1 2011-01-31 10:08:58 +00:00
Sandeep Doddaballapur
2fc1c66b1b automerge 2011-01-31 11:21:30 +05:30
Vasil Dimov
a6e860790a Merge mysql-5.1-innodb -> mysql-5.1 2011-01-30 18:41:58 +02: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
Alfranio Correia
66abb3d1bb BUG#59338 Inconsistency in binlog for statements that don't change any rows STATEMENT SBR
In SBR, if a statement does not fail, it is always written to the binary
log, regardless if rows are changed or not. If there is a failure, a
statement is only written to the binary log if a non-transactional (.e.g.
MyIsam) engine is updated.

INSERT ON DUPLICATE KEY UPDATE and INSERT IGNORE were not following the
rule above and were not written to the binary log, if then engine was
Innodb.
2011-01-28 12:09:15 +00:00
Alfranio Correia
5a0af47919 BUG#55675 rpl.rpl_log_pos fails sporadically with error binlog truncated in the middle
There are two calls to read_log_event() on master in mysql_binlog_send().
Each call reads 19 bytes in this test case and the error of the second
read_log_event() is reported to the slave.

The second read_log_event() starts from position 94 (75 + 19) to 113
(75 + 19 + 19). Usually, there are two events in the binary log:

    . 0   - 3   - Header
    . 4   - 105 - Format Descriptor Event
    . 106 - 304 - Query Event

and both reads fail because operations are reading from invalid positions
as expected.

However, mysql_binlog_send() does not use the same IO_CACHE that is used to
write into binary log (i.e. mysql_bin_log.log_file) for the hot binary log.
It opens the binary log file directly by calling open_binlog() and creates a
separated IO_CACHE. So there is a possibly that after a master has flushed
the binary log file, the content has been cached by the filesystem, and has
not updated the disk file. If this happens, then a slave will only see part
of the file, and thus the second read_log_event() will report event truncated
error.

To fix the problem, if the first read_log_event() has failed, we ensure that
the second one will try to read from the same position.
2011-01-28 01:25:26 +00:00
Mattias Jonsson
03225027db merge 2011-01-27 23:39:17 +01:00
John H. Embretsen
610393709f Merge two patches for bug 56895 into tip of mysql-5.1 branch. 2011-01-27 12:38:13 +01:00
Horst.Hunger
eb33996589 due to merge. 2011-01-27 08:59:45 +01:00
Horst.Hunger
fa0ad4803c Merge of results of the review done in 5.1-bugteam to 5.1. 2011-01-27 08:56:59 +01:00
Sandeep Doddaballapur
d36659c4e8 2011-01-27 11:37:55 +05:30
Mattias Jonsson
4e47db3af4 merge 2011-01-26 16:50:21 +01:00
Ramil Kalimullin
4eb7054598 Bug #47811 : remove the non-default alignment specification.
Fix backported from to 5.0.
"Remove the alignment option, let valgrind use its default"
2011-01-26 15:49:09 +03:00
Alfranio Correia
5a19661d4f Disabled rpl_row_until and rpl_stm_until due to BUG#59543. 2011-01-26 12:37:24 +00:00
Bjorn Munch
60faa02188 merge from 5.1 main 2011-01-25 13:07:23 +01:00
Sandeep Doddaballapur
ae789b6ec8 2011-01-25 12:14:28 +05:30
Vasil Dimov
9395126ec4 Merge mysql-5.1 -> mysql-5.1-innodb 2011-01-24 09:40:37 +02:00
Bjorn Munch
0850b60759 Bug #59063 rpl_migration_crash_safe fails on Windows
Race condition may occur: mtr sees the .expect file but it's empty
Fix: wait and try again if file is empty
Addendum: try again if line isn't 'wait' or 'restart'
Also added verbose printout of extra restart options
2011-01-21 13:57:21 +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
Bjorn Munch
5a9b65cb1e merge from 5.1 main 2011-01-19 11:19:54 +01:00
Mattias Jonsson
28604b18a6 Bug#59418: parts suite have several failures with --embedded-server
The test were using external tools not available for embedded.

Fixed by rewriting the test to not rely on external tools like the mysql-client

Also fixed some non portable --exec commands and replaced #p# to #P# to pass
on windows.
2011-01-18 23:55:39 +01:00
Libing Song
5d75729c92 Bug#58546 test rpl_packet timeout failure sporadically on PB
rpl_packet got a timeout failure sporadically on PB when stopping
slave. The real reason of this bug is that STOP SLAVE stopped
IO thread first and then stopped SQL thread. It was
possible that IO thread stopped after replicating part of a
transaction which SQL thread was executing. SQL thread would
be hung if the transaction could not be rolled back safely.
            
After this patch, STOP SLAVE will stop SQL thread first and then stop IO
thread, which guarantees that IO thread will fetch the reset of the
events of the transaction that SQL thread is executing, so that SQL
thread can finish the transaction if it cannot be rolled back safely.
            
Added below auxiliary files to make the test code neater.
restart_slave_sql.inc
rpl_connection_master.inc
rpl_connection_slave.inc
rpl_connection_slave1.inc
2011-01-19 01:23:49 +08:00
Bjorn Munch
9c7abc2549 Bug #59063 rpl_migration_crash_safe fails on Windows
Undoing the patch, it complicates the code but is not the solution

I do not beleive newline mismatch could be the cause of this failure
First, I cannot see how this could be a problem, mtr ignores the newline
  when reading the expect file, and the file is written and read on Windows.
Second, if this really was the problem it should have been deterministic:
  either the newline is correctly interepreted or it is not.
2011-01-18 12:25:07 +01:00
Bjorn Munch
813af29b73 oops forgot one file in last commit 2011-01-18 12:11:52 +01:00
Bjorn Munch
89aa03aea6 Some more copyright fixes in mtr 2011-01-18 12:01:40 +01:00
Bjorn Munch
097445ebf5 Fixed copyright headers in mtr src files 2011-01-18 11:03:44 +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
Vinay Fisrekar
f25ab9fe22 BUG#58858 : sys_vars.innodb_max_dirty_pages_pct_func fails sporadically
Committing After latest merge.      
Modified check_pct procedure to check return value of wait condition instead 
of calling "dirty_pct".
   
Adding Review comments:
1) Added comment for success variable value
2) Procedure check_pct changed For Adding BOOLEAN input and SELECT QUERY Change
2011-01-18 09:24:52 +05:30
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
ade1c74b3f BUG#49124 Security issue with /*!-versioned */ SQL statements on Slave
Backport to 5.0.

/*![:version:] Query Code */, where [:version:] is a sequence of 5 
digits representing the mysql server version(e.g /*!50200 ... */),
is a special comment that the query in it can be executed on those 
servers whose versions are larger than the version appearing in the 
comment. It leads to a security issue when slave's version is larger 
than master's. A malicious user can improve his privileges on slaves. 
Because slave SQL thread is running with SUPER privileges, so it can
execute queries that he/she does not have privileges on master.
      
This bug is fixed with the logic below: 
- To replace '!' with ' ' in the magic comments which are not applied on
  master. So they become common comments and will not be applied on slave.
      
- Example:
  'INSERT INTO t1 VALUES (1) /*!10000, (2)*/ /*!99999 ,(3)*/
   will be binlogged as
  'INSERT INTO t1 VALUES (1) /*!10000, (2)*/ /* 99999 ,(3)*/
2011-01-15 13:48:16 +08:00
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
Jimmy Yang
669ce69483 Fix Bug#30423 "InnoDBs treatment of NULL in index stats causes bad
"rows examined" estimates". This change implements "innodb_stats_method"
with options of "nulls_equal", "nulls_unequal" and "null_ignored".
      
rb://553 approved by Marko
2011-01-14 09:02:28 -08:00
John H. Embretsen
4a62ee2c95 Bug#56895 part 2 of 2: Backport of revid holyfoot@mysql.com-20100825135522-8wrjjmvh2u2t0qo6 from mysql-5.5.
Without this patch mysqlhotcopy tests would fail due to not finding the mysqlhotcopy tool in release-like builds.
With this patch the tests would either pass, or fail due to missing Perl modules (see 56817).
Text conflict in mysql-test/mysql-test-run.pl:
 - resolved by using logic from 5.5 to find mysqlhotcopy, the intention of this backport. Changed bindir to basedir.
2011-01-14 17:01:13 +01: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
John H. Embretsen
dc7289128d Bug#56895 part 1 of 2: Backport of revid holyfoot@mysql.com-20100823084827-js10vjuil88je35r from mysql-5.5.
The purpose is to make MTR logic for mysqlhotcopy the same in 5.1 as in 5.5, making it easier to maintain and fix bugs such as 56817.
2011-01-14 14:50:39 +01:00
Sven Sandberg
d3ea6f9bb1 BUG#59063: rpl_migration_crash_safe fails on Windows
Backported the fix to 5.1.
Problem: the auxiliary test files rpl_start_server.inc and rpl_stop_server.inc
write a file that is later read by mtr. The bug was that the file was written
with platform-dependent newline terminators, i.e., \r\n on windows, whereas mtr
only understands \n.
Fix: write the file so that it uses \n on all platforms.
2011-01-14 11:33:12 +01:00
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